Presentation is loading. Please wait.

Presentation is loading. Please wait.

8.4 Instruction Execution Times - 8088 TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.

Similar presentations


Presentation on theme: "8.4 Instruction Execution Times - 8088 TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM."— Presentation transcript:

1 8.4 Instruction Execution Times - 8088 TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM MOV CX,10 MUL CX ADD AX,BP POP CX LOOP NEXTD RET TOBIN ENDP 3 2 4 18+8 7+4 3 4 118-133 3 4+4 17/5 2 17/5 Overhead cycles: instructions performed once. Outer-loop cycles: instructions performed four times. Inner-loop cycles: instructions performed sixteen times. Clock cycles needed for the instruction itself. Four additional clock cycles needed for each memory access. Variable execution time: depends on operands’ value. Cannot be precisely known at assembling time. Variable execution time: depends on jump condition: Greater time corresponds to performing the jump. Lower time when jump is not performed (next instruction is already in instruction queue) 35 168-183 first three times 156-171 last time (loop not performed) 21 first three times 9 last time (loop not performed) Worse case total time = 35+4*(183+4*(21)-12)-12 = 1043 clock cycles.

2 8.4 Instruction Execution Times - Pentium TOBIN PROC FAR SUB AX,AX MOV DX,AX MOC CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM MOV CX,10 MUL CX ADD AX,BP POP CX LOOP NEXTD RET TOBIN ENDP 1 2+0 1+0 1 11 1 1+0 5/6 1 5/6 Overhead cycles: instructions performed once. Outer-loop cycles: instructions performed four times. Inner-loop cycles: instructions performed sixteen times. Clock cycles needed for the instruction itself (most instructions 1 cycle). No additional clock cycles needed for each memory access. MUL is performed in a constant time Variable execution time: depends on jump condition: Lower time corresponds to performing the jump. (usually a backward jump at a location in queue) Higher time when jump is not performed 5 22 first three times 23 last time (loop not performed) 7 first three times 8 last time (loop not performed) Total time = 5+4*(22+4*(7)+1)+1 = 210 clock cycles.

3 8.5 Working with Interrupt Vectors DOS INT 21, function 35H: Get interrupt vector Specification: returns the ISR’s (Interrupt Service Routine) address for a given interrupt. Input: AH = 35 (function code), AL = the interrupt number (type) DOS INT 21, function 25H: Set interrupt vector Specification: replaces the ISR’s (Interrupt Service Routine) address for a given interrupt. Warning: modifying an ISR’s address in the Interrupt Pointer Table, sends the program execution to this new address every time the corresponding interrupt is acknowledged (hardware or software). This could modify the response of your computer to external or internal events. If the “routine” found at the new address is not able to perform the desired job and to return properly to the interrupted program, (releasing a correct number of stack locations and performing an IRET), the system could crash. You cannot know exactly when the “modified” interrupt is acknowledged. Restarting (resetting) your computer will restore the original interrupt pointer table. Output: BX = interrupt handler IP address, ES = interrupt handler CS address Input: AH = 25 (function code), AL = the interrupt number (type) DX = new interrupt handler IP address, DS = new interrupt handler CS address

4 8.5 Working with Interrupt Vectors ;Program VECTORS.ASM: View entire IPT..MODEL SMALL.DATA WMSG DB 0DH,0AH,'Hit any key to continue...’ DB 0DH,0AH,0DH,0AH,'$'.CODE.STARTUP SUB AL,AL ;begin with vector 0 NEWV: PUSH AX ;save vector number CALL DISPHEX ;display it MOV DL,' ' ;load blank character MOV AH,2 ;display character function INT 21H ;DOS call MOV DL,'=' ;load equal sign INT 21H ;and output MOV DL,' ' ;load another blank INT 21H ;and output POP AX ;get vector number back PUSH AX ;and save it again MOV AH,35H ;get interrupt vector function INT 21H ;DOS call MOV AX,ES ;get interrupt segment CALL DISPHEX_16 ;display it MOV DL,':' ;load colon character MOV AH,2 ;display character function INT 21H ;DOS call MOV AX,BX ;get interrupt offset CALL DISPHEX_16 ;display it MOV DL,' ' ;load blank character MOV AH,2 ;display character function INT 21H ;DOS call INT 21H ;output a second blank POP AX ;get vector number back MOV DL,AL ;make a copy of it AND DL,3 ;should we output a new line? CMP DL,3 JNZ NNL PUSH AX ;save vector number MOV DL,0DH ;load carriage return MOV AH,2 ;display character function INT 21H ;DOS call MOV DL,0AH ;also output a line feed INT 21H POP AX ;get vector number back NNL: MOV DL,AL ;make copy of vector number CMP DL,255 ;finished? JZ NNP AND DL,63 ;should we pause here? CMP DL,63 JNZ NNP PUSH AX ;save vector number LEA DX,WMSG ;set up pointer to pause message MOV AH,9 ;display string function INT 21H ;DOS call MOV AH,8 ;character input function INT 21H ;DOS call POP AX ;get vector number back NNP: INC AL ;advance to next vector CMP AL,0 ;did we wrap from 255 to 0? JNZ NEWV.EXIT

5 DISPHEX_16 PROC NEAR PUSH AX ;save number MOV AL,AH ;load upper byte CALL DISPHEX ;go display in hex POP AX ;get number back CALL DISPHEX ;go display lower byte RET DISPHEX_16 ENDP DISPHEX PROC NEAR PUSH AX ;save number SHR AL,1 ;get upper nybble SHR AL,1 CALL HEXOUT ;display hex character POP AX ;get number back AND AL,0FH ;preserve lower nybble CALL HEXOUT ;display hex character RET DISPHEX ENDP HEXOUT PROC NEAR CMP AL,10 ;is AL greater than 10? JC NHA1 ;yes ADD AL,7 ;no, add alpha bias NHA1: ADD AL,30H ;add ASCII bias MOV DL,AL ;load output character MOV AH,2 ;display character function INT 21H ;DOS call RET HEXOUT ENDP END 8.5 Working with Interrupt Vectors


Download ppt "8.4 Instruction Execution Times - 8088 TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM."

Similar presentations


Ads by Google