This source code is designed especially to execute within the EBL-Plus keyboard stack. That is, the code executes whenever there is a system timer tick or keyboard key request from the application. As a result, it can execute as a parallel task to initiate or monitor anything. It can relinquish control of the stack back to EBL-Plus to stuff further keys into the application, or freeze the stack to prevent this. Because this is only done by assembly language, you must have full knowledge of what functions you are trying to do. Use this powerful technique with care.
CODE SEGMENT WORD PUBLIC 'CODE'
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:nothing
;
; Special inline stack routine to wait 1 hour
; (or another constant amount of time delta).
; Does not work across 24hr mark... caution!
;
PREFIX DB 256 DUP(?)
w1h PROC NEAR
TimerLow Equ 06Ch ; This is the offset of the timer values
TimerHigh Equ 06Eh ; as defined in the BIOS listings.
;DeltaLow Equ 0024h ; This represents 2 seconds of delta time
;DeltaHigh Equ 0000h ; (36 decimal as defined in BIOS listings)
DeltaLow Equ 0007h ; This represents 1 hour of delta time
DeltaHigh Equ 0001h ; (65543 decimal as defined in BIOS listings)
Start: Jmp short Me ; Jump over local storage
TCmpH Dw 0 ; Define local timer count comparison High
TCmpL Dw 0 ; Define local timer count comparison Low
Me: Push Es ; Hold Es so I can point to BIOS timer area
Mov Ax,0040h ; Point Es to BIOS area
Mov Es,Ax
Cmp Word ptr [si+TCmpH-Start],0 ; Timer delta initialized?
Jne CheckTm
Cmp Word ptr [si+TCmpL-Start],0 ; Timer delta initialized?
Jne CheckTm
Mov Ax,Word ptr Es:[TimerLow]
Add Ax,DeltaLow ; Create time to wait for Low
Mov Word ptr [si+TCmpL-Start],Ax
Mov Ax,Word ptr Es:[TimerHigh]
Adc Ax,DeltaHigh ; Create time to wait for High
Mov Word ptr [si+TCmpH-Start],Ax
Jmp Short CheckX
CheckTm:
Mov Ax,Word ptr Es:[TimerHigh] ; Reached high timer?
Cmp Ax,Word ptr [si+TCmpH-Start]
Jb CheckX
Mov Ax,Word ptr Es:[TimerLow ] ; Reached high timer?
Cmp Ax,Word ptr [si+TCmpL-Start]
Jae Done ; Yes, then exit SI<>0
CheckX: Mov Si,0 ; No, SI = 0 means restart this routine
Done: Pop Es
Ret
w1h Endp
code ends
end Start