Lecture 21. _getproc proc near pushf ;Secure flag register contents push di ;== Determine whether model came before or after 80286 === xor ax,ax ;Set.

Slides:



Advertisements
Similar presentations
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
Advertisements

University of Tehran 1 Microprocessor System Design Interrupt Omid Fatemi
Intel Computer Architecture Presented By Jessica Graziano.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
80x86 Instruction Set Dr. Qiang Lin.
Computer Organization And Assembly Language
1 Procedures and Interrupts Chapter 5 n Stack n Procedure n Software Interrupt u BIOS-level access u DOS-level access n Video Display u Direct Video access.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Assembly Language for Intel-Based Computers
Practical Session 3. The Stack The stack is an area in memory that its purpose is to provide a space for temporary storage of addresses and data items.
Accessing parameters from the stack and calling functions.
Practical Session 3. The Stack The stack is an area in memory that its purpose is to provide a space for temporary storage of addresses and data items.
Sahar Mosleh California State University San MarcosPage 1 Applications of Shift and Rotate Instructions.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Lab 5 Part C Write to the screen a character string that uses a ‘$’ to indicate the end of the string. Do not write the ‘$’ to the screen. Use DOS Interrupt.
Procedures and the Stack Chapter 5 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Stack Operations LIFO structure (last-in,first-out) –The last value put into the stack is the first value taken out Runtime stack –A memory array that.
Lecture 14 Basic I/O Interface Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Strings, Procedures and Macros
Arithmetic Flags and Instructions
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 22: Unconventional.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.
Decision Structures – Code Generation Lecture 24 Mon, Apr 18, 2005.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
Stack Usage with MS Visual Studio Without Stack Protection.
1 The Stack and Procedures Chapter 5. 2 A Process in Virtual Memory  This is how a process is placed into its virtual addressable space  The code is.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Irvine, Kip R. Assembly Language for Intel-Based Computers. Chapter 7: Integer Arithmetic Slides to Accompany Assembly Language for Intel-Based Computers,
MOV Instruction MOV destination,source  MOV AX,BX  MOV SUM,EAX  MOV EDX,ARRAY[EBX][ESI]  MOV CL,5  MOV DL,[BX]
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
Calling Procedures C calling conventions. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Assembly Language for Intel-Based Computers, 4 th Edition Week 10: Conditional Processing Slides modified by Dr. Osama Younes.
BITS Pilani Pilani Campus Pawan Sharma Lecture /12/ EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Practical Session 3.
Stack Operations Dr. Hadi AL Saadi.
Computer Architecture and Assembly Language
Chapter 3 General-Purpose Processors: Software
Pentium I/O: I/O, I/O and off to work we go
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Microprocessor and Assembly Language
Chapter 4 Data Movement Instructions
Instruction System - Bit Manipulation Instruction
Basic Microprocessor Architecture
INSTRUCTION SET.
Assembly Language Programming Part 2
(The Stack and Procedures)
Lecture 22.
Chapter 4: Instructions
Fundamentals of Computer Organisation & Architecture
Computer Architecture and Assembly Language
Practical Session 4.
(The Stack and Procedures)
Shift & Rotate Instructions)
Microprocessor Lab CSL1543 0:0:2
Morgan Kaufmann Publishers Computer Organization and Assembly Language
3.6 Data transfer Instructions
Interrupts Barry B. Brey
X86 Assembly Review.
(The Stack and Procedures)
CSC 497/583 Advanced Topics in Computer Security
ICS51 Introductory Computer Organization
Presentation transcript:

Lecture 21

_getproc proc near pushf ;Secure flag register contents push di ;== Determine whether model came before or after === xor ax,ax ;Set AX to 0 push ax ;and push onto stack popf ;Pop flag register off of stack pushf ;Push back onto stack pop ax ;and pop off of AX and ax,0f000h ;Do not clear the upper four bits cmp ax,0f000h ;Are bits all equal to 1? je not_286_386 ;YES --> Not or 80286

;-- Test for determining whether 80486, or mov dl,p_80286 ;In any case, it's one of the mov ax,07000h ;three processors push ax ;Push 07000h onto stack popf ;Pop flag register off pushf ;and push back onto the stack pop ax ;Pop into AX register and ax,07000h ;Mask everything except bits je pende ;Are bits all equal to 0? ;YES --> It's an inc dl ;No --> it's either an or an ; First set to 386

cli ;No interrupts now mov ebx,offset array mov [ebx],eax pushfd pop eax mov first,eax; mov [ebx+1],eax pushfd pop eax shr first,18 shr eax,18 and first,1 and eax,1 cmp first,eax inc dl sti jne pende

pushfd pop eax mov temp, eax mov eax,1 shl eax,21 push eax popfd pushfd pop eax shr eax,21 shr temp,21 cmp temp, eax inc dl je pende jmp pende ;Test is ended

#include "stdafx.h" #include unsigned long int id[3]; unsigned char ch='\0'; unsigned int steppingid ; unsigned int model,family,type1; unsigned int cpcw; int main(int argc, char* argv[]) { _asm xor eax,eax _asm cpuid _asm mov id[0], ebx; _asm mov id[4], edx; _asm mov id[8], ecx; printf("%s\n ", (char *) (id)); _asm mov eax,1 _asm cpuid _asm mov ecx,eax _asm AND eax,0xf; _asm mov steppingid,eax; _asm mov eax, ecx

_asm shr eax,4 _asm and eax, 0xf; _asm mov model,eax _asm mov eax,ecx _asm shr eax,8 _asm and eax, 0xf _asm mov family,eax; _asm mov eax,ecx _asm shr eax,12 _asm and eax, 0x3; _asm mov type1, eax; printf("\nstepping is %d\n model is %d\n Family is %d\nType is%d\n", steppingid,model,family,type1); }

void main { _asm finit _asm mov byte ptr cpcw+1, 0; _asm fstcw cpcw if ( *(((char *) (&cpcw))+1)==3) puts("Coprocessor found"); else puts ("Coprocessor not found"); }

_getco proc near mov dx,co_none mov byte ptr cs:wait1,NOP_CODE mov byte ptr cs:wait2,NOP_CODE wait1: finit mov byte ptr cpz+1,0 wait2: fstcw cpz cmp byte ptr cpz+1,3 jne gcende ;-- Coprocessor exists. Test for inc dx and cpz,0FF7Fh fldcw cpz fdisi fstcw cpz test cpz,80h jne gcende

;-- Test for 80287/ inc dx finit fld1 fldz fdiv fld st fchs fcompp fstsw cpz mov ah,byte ptr cpz+1 sahf je gcende inc dx gcende: mov ax,dx ret _getco endp

KeyBoard Interface 64H 60H Processor INTR PIC IRQ1 Synchronous Data Keyboard

Port 64H Status Register 1 = Output Buffer full 1 = Input Buffer full 1 = Keyboard Active 1 = Parity Error 1 = Time Out Error during input 1 = Time Out Error during output

Typematic Rate = 2 char/s = 2.1 char/s = 2.3 char/s = 3 char/s :::::::::::::::: = 20 char/s = 21.8 char/s = 24 char/s = 26.7 char/s = 30 char/s Delay 00 ¼ Second 01 ½ Second 10 ¼ Second 11 1 Second

Sending bytes to the Keyboard 60H 64H Input from Keyboard Input buffer full

Sending bytes to the Keyboard 60H 64H From Processor Output buffer full Later on Receives 0xFA to indicate successful transmission