commit
5162407cef
1 changed files with 52 additions and 52 deletions
|
|
@ -163,34 +163,34 @@ presented in Chapter K on the companion CD-ROM.
|
||||||
; in when ZTimerOn was called.
|
; in when ZTimerOn was called.
|
||||||
;
|
;
|
||||||
|
|
||||||
Code segment word public ‘CODE'
|
Code segment word public 'CODE'
|
||||||
assumecs: Code, ds:nothing
|
assume cs:Code, ds:nothing
|
||||||
public ZTimerOn, ZTimerOff, ZTimerReport
|
public ZTimerOn, ZTimerOff, ZTimerReport
|
||||||
|
|
||||||
;
|
;
|
||||||
; Base address of the 8253 timer chip.
|
; Base address of the 8253 timer chip.
|
||||||
;
|
;
|
||||||
BASE_8253equ40h
|
BASE_8253 equ 40h
|
||||||
;
|
;
|
||||||
; The address of the timer 0 count registers in the 8253.
|
; The address of the timer 0 count registers in the 8253.
|
||||||
;
|
;
|
||||||
TIMER_0_8253 equBASE_8253 + 0
|
TIMER_0_8253 equ BASE_8253 + 0
|
||||||
;
|
;
|
||||||
; The address of the mode register in the 8253.
|
; The address of the mode register in the 8253.
|
||||||
;
|
;
|
||||||
MODE_8253 equBASE_8253 + 3
|
MODE_8253 equ BASE_8253 + 3
|
||||||
;
|
;
|
||||||
; The address of Operation Command Word 3 in the 8259 Programmable
|
; The address of Operation Command Word 3 in the 8259 Programmable
|
||||||
; Interrupt Controller (PIC) (write only, and writable only when
|
; Interrupt Controller (PIC) (write only, and writable only when
|
||||||
; bit 4 of the byte written to this address is 0 and bit 3 is 1).
|
; bit 4 of the byte written to this address is 0 and bit 3 is 1).
|
||||||
;
|
;
|
||||||
OCW3 equ20h
|
OCW3 equ 20h
|
||||||
;
|
;
|
||||||
; The address of the Interrupt Request register in the 8259 PIC
|
; The address of the Interrupt Request register in the 8259 PIC
|
||||||
; (read only, and readable only when bit 1 of OCW3 = 1 and bit 0
|
; (read only, and readable only when bit 1 of OCW3 = 1 and bit 0
|
||||||
; of OCW3 = 0).
|
; of OCW3 = 0).
|
||||||
;
|
;
|
||||||
IRR equ20h
|
IRR equ 20h
|
||||||
;
|
;
|
||||||
; Macro to emulate a POPF instruction in order to fix the bug in some
|
; Macro to emulate a POPF instruction in order to fix the bug in some
|
||||||
; 80286 chips which allows interrupts to occur during a POPF even when
|
; 80286 chips which allows interrupts to occur during a POPF even when
|
||||||
|
|
@ -220,7 +220,7 @@ OriginalFlags db ? ; storage for upper byte of
|
||||||
; ZTimerOn called
|
; ZTimerOn called
|
||||||
TimedCount dw ? ; timer 0 count when the timer
|
TimedCount dw ? ; timer 0 count when the timer
|
||||||
; is stopped
|
; is stopped
|
||||||
ReferenceCount dw ; number of counts required to
|
ReferenceCount dw ? ; number of counts required to
|
||||||
; execute timer overhead code
|
; execute timer overhead code
|
||||||
OverflowFlag db ? ; used to indicate whether the
|
OverflowFlag db ? ; used to indicate whether the
|
||||||
; timer overflowed during the
|
; timer overflowed during the
|
||||||
|
|
@ -229,28 +229,28 @@ OverflowFlag db ? ; used to indicate whether the
|
||||||
; String printed to report results.
|
; String printed to report results.
|
||||||
;
|
;
|
||||||
OutputStr label byte
|
OutputStr label byte
|
||||||
db 0dh, 0ah, ‘Timed count: ‘, 5 dup (?)
|
db 0dh, 0ah, 'Timed count: ', 5 dup (?)
|
||||||
ASCIICountEnd labelbyte
|
ASCIICountEnd label byte
|
||||||
db ‘ microseconds', 0dh, 0ah
|
db ' microseconds', 0dh, 0ah
|
||||||
db ‘$'
|
db '$'
|
||||||
;
|
;
|
||||||
; String printed to report timer overflow.
|
; String printed to report timer overflow.
|
||||||
;
|
;
|
||||||
OverflowStr label byte
|
OverflowStr label byte
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘****************************************************'
|
db '****************************************************'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘* The timer overflowed, so the interval timed was *'
|
db '* The timer overflowed, so the interval timed was *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘* too long for the precision timer to measure. *'
|
db '* too long for the precision timer to measure. *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘* Please perform the timing test again with the *'
|
db '* Please perform the timing test again with the *'
|
||||||
db0dh, 0ah
|
|
||||||
db ‘* long-period timer. *'
|
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘****************************************************'
|
db '* long-period timer. *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘$'
|
db '****************************************************'
|
||||||
|
db 0dh, 0ah
|
||||||
|
db '$'
|
||||||
|
|
||||||
; ********************************************************************
|
; ********************************************************************
|
||||||
; * Routine called to start timing. *
|
; * Routine called to start timing. *
|
||||||
|
|
@ -418,7 +418,7 @@ ZTimerOff endp
|
||||||
; Called by ZTimerOff to start timer for overhead measurements.
|
; Called by ZTimerOff to start timer for overhead measurements.
|
||||||
;
|
;
|
||||||
|
|
||||||
ReferenceZTimerOnproc near
|
ReferenceZTimerOn proc near
|
||||||
;
|
;
|
||||||
; Save the context of the program being timed.
|
; Save the context of the program being timed.
|
||||||
;
|
;
|
||||||
|
|
@ -445,7 +445,7 @@ ReferenceZTimerOnproc near
|
||||||
pop ax
|
pop ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
ReferenceZTimerOnendp
|
ReferenceZTimerOn endp
|
||||||
|
|
||||||
;
|
;
|
||||||
; Called by ZTimerOff to stop timer and add result to ReferenceCount
|
; Called by ZTimerOff to stop timer and add result to ReferenceCount
|
||||||
|
|
@ -488,7 +488,7 @@ ReferenceZTimerOff endp
|
||||||
; * Routine called to report timing results. *
|
; * Routine called to report timing results. *
|
||||||
; ********************************************************************
|
; ********************************************************************
|
||||||
|
|
||||||
ZTimerReport procnear
|
ZTimerReport proc near
|
||||||
|
|
||||||
pushf
|
pushf
|
||||||
push ax
|
push ax
|
||||||
|
|
@ -913,13 +913,13 @@ and should contain calls to `ZTimerOn` and `ZTimerOff` .
|
||||||
;
|
;
|
||||||
; By Michael Abrash
|
; By Michael Abrash
|
||||||
;
|
;
|
||||||
mystack segment para stack ‘STACK'
|
mystack segment para stack 'STACK'
|
||||||
db 512 dup(?)
|
db 512 dup(?)
|
||||||
mystack ends
|
mystack ends
|
||||||
;
|
;
|
||||||
Code segment para public ‘CODE'
|
Code segment para public 'CODE'
|
||||||
assume cs:Code, ds:Code
|
assume cs:Code, ds:Code
|
||||||
extrnZTimerOn:near, ZTimerOff:near, ZTimerReport:near
|
extrn ZTimerOn:near, ZTimerOff:near, ZTimerReport:near
|
||||||
Start proc near
|
Start proc near
|
||||||
push cs
|
push cs
|
||||||
pop ds ; set DS to point to the code segment,
|
pop ds ; set DS to point to the code segment,
|
||||||
|
|
@ -1932,25 +1932,25 @@ timing.
|
||||||
;
|
;
|
||||||
; By Michael Abrash
|
; By Michael Abrash
|
||||||
;
|
;
|
||||||
mystack segment para stack ‘STACK'
|
mystack segment para stack 'STACK'
|
||||||
db 512 dup(?)
|
db 512 dup(?)
|
||||||
mystack ends
|
mystack ends
|
||||||
;
|
;
|
||||||
Code segment para public ‘CODE'
|
Code segment para public 'CODE'
|
||||||
assume cs:Code, ds:Code
|
assume cs:Code, ds:Code
|
||||||
extrn ZTimerOn:near, ZTimerOff:near, ZTimerReport:near
|
extrn ZTimerOn:near, ZTimerOff:near, ZTimerReport:near
|
||||||
Startproc near
|
Start proc near
|
||||||
push cs
|
push cs
|
||||||
pop ds ;point DS to the code segment,
|
pop ds ;point DS to the code segment,
|
||||||
; so data as well as code can easily
|
; so data as well as code can easily
|
||||||
; be included in TESTCODE
|
; be included in TESTCODE
|
||||||
;
|
;
|
||||||
; Delay for 6-7 seconds, to let the Enter keystroke that started the
|
; Delay for 6-7 seconds, to let the Enter keystroke that started the
|
||||||
; program come back up.
|
; program come back up.
|
||||||
;
|
;
|
||||||
mov ah,2ch
|
mov ah,2ch
|
||||||
int 21h ;get the current time
|
int 21h ;get the current time
|
||||||
mov bh,dh ;set the current time aside
|
mov bh,dh ;set the current time aside
|
||||||
DelayLoop:
|
DelayLoop:
|
||||||
mov ah,2ch
|
mov ah,2ch
|
||||||
push bx ;preserve start time
|
push bx ;preserve start time
|
||||||
|
|
@ -1962,12 +1962,12 @@ DelayLoop:
|
||||||
add dh,60 ;yes, a minute must have turned over,
|
add dh,60 ;yes, a minute must have turned over,
|
||||||
; so add one minute
|
; so add one minute
|
||||||
CheckDelayTime:
|
CheckDelayTime:
|
||||||
sub dh,bh ;get time that's passed
|
sub dh,bh ;get time that's passed
|
||||||
cmp dh,7 ;has it been more than 6 seconds yet?
|
cmp dh,7 ;has it been more than 6 seconds yet?
|
||||||
jb DelayLoop ;not yet
|
jb DelayLoop ;not yet
|
||||||
;
|
;
|
||||||
include TESTCODE ;code to be measured, including calls
|
include TESTCODE ;code to be measured, including calls
|
||||||
; to ZTimerOn and ZTimerOff
|
; to ZTimerOn and ZTimerOff
|
||||||
;
|
;
|
||||||
; Display the results.
|
; Display the results.
|
||||||
;
|
;
|
||||||
|
|
@ -1975,8 +1975,8 @@ CheckDelayTime:
|
||||||
;
|
;
|
||||||
; Terminate the program.
|
; Terminate the program.
|
||||||
;
|
;
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h
|
int 21h
|
||||||
Start endp
|
Start endp
|
||||||
Code ends
|
Code ends
|
||||||
end Start
|
end Start
|
||||||
|
|
@ -2075,23 +2075,23 @@ the precision Zen timer to handle on the 8088.
|
||||||
; Note: takes about ten minutes to assemble on a slow PC if
|
; Note: takes about ten minutes to assemble on a slow PC if
|
||||||
;you are using MASM
|
;you are using MASM
|
||||||
;
|
;
|
||||||
jmpSkip;jump around defined data
|
jmp Skip ;jump around defined data
|
||||||
;
|
;
|
||||||
MemVardb?
|
MemVar db ?
|
||||||
;
|
;
|
||||||
Skip:
|
Skip:
|
||||||
;
|
;
|
||||||
; Start timing.
|
; Start timing.
|
||||||
;
|
;
|
||||||
callZTimerOn
|
call ZTimerOn
|
||||||
;
|
;
|
||||||
rept20000
|
rept 20000
|
||||||
moval,[MemVar]
|
mov al,[MemVar]
|
||||||
endm
|
endm
|
||||||
;
|
;
|
||||||
; Stop timing.
|
; Stop timing.
|
||||||
;
|
;
|
||||||
callZTimerOff
|
call ZTimerOff
|
||||||
```
|
```
|
||||||
|
|
||||||
When LZTIME.BAT is run on a PC with the following command line (assuming
|
When LZTIME.BAT is run on a PC with the following command line (assuming
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue