Area: Quik_Bas Msg: #288 Date: 11-23-92 19:08 (Public) From: Steve Gartrell To: Robert Church Subject: QB/PDS/VBDOS INT Handlers
.model medium, basic
.code
handle PROC
IntEntry:
push bp ; push everything
mov bp, sp ; stack frame
pushf
push ds
push es
push di
push si
push dx
push cx
push bx
push ax
mov di, ss ;cuz the damned data seg
mov ds, di ; can get lost
BusyOff:
mov bx, 9090h
mov ax, [bx]
and ax, ax
jnz SHORT TooBusy
mov es, di ;point dest seg at DGROUP
mov si, sp ;stack address for regs to si
cld
RegsOff:
mov di, 9090h ;QB/PDS reg TYPE offset to di
mov cx, 0Ah
rep movsw
sub di, 14h
push di
sub si, 14h
push si
sti
HandSeg:
mov ax, 9090h ;Here the QB sub segment
push ax ; is placed on the stack for the
; RETF
HandOff:
mov ax, 9090h ;Here the QB sub offset
push ax ; is placed on the stack for the
retf ; RETF
AllDone:
add sp, 0Eh ;roll the stack ptr back past the
; last CALL Absolute far return
; address and the five dummy
; variables on the stack. Then
; pop everything
mov di, ss ;cuz the damned data seg
mov ds, di ; can get lost
mov es, di
pop di ;popped in reverse dest/source
pop si
cld
mov cx, 0Ah
rep movsw
TooBusy:
pop ax
pop bx
pop cx
pop dx
pop si
pop di
pop es
pop ds
popf
pop bp
jmp cs:OldInt
JmpAddr:
OldInt DD 90909090h
Start:
assume ds:seg IntEntry
push bp ; set up stack frame ptr
mov bp, sp
push ax
push bx
push dx
push si
mov bx, [bp + 6] ;get ptr to start of this handler
; (stored in DGROUP)
mov bx, [bx]
sub bx, Start - IntEntry
mov ax, [bp + 2] ; get QB sub return offset
add ax, 03h ; add 3 to compensate for JMP
; opcode/disp and store in code
mov WORD PTR [bx + HandOff + 1], ax
mov ax, [bp + 4] ; get QB sub return seg
; and store in code
mov WORD PTR [bx + HandSeg + 1], ax
mov si, bx ;preserve start of code ptr
mov bx, [bp + 8] ;original int offset ptr to DX
mov dx, WORD PTR [bx] ; and moved to code storage
mov WORD PTR [si + JmpAddr], dx
mov bx, [bp + 0Ah] ;original int segment ptr to DX
mov dx, WORD PTR [bx] ; and moved to code storage
mov WORD PTR [si + JmpAddr + 2], dx
mov bx, [bp + 0Ch] ;busy flag ptr offset to DX
; and moved to code storage
mov WORD PTR [si + BusyOff + 1], bx
mov bx, [bp + 0Eh] ;SKGregs ptr to DX, adj to end,
mov dx, WORD PTR [bx] ; and moved to code storage
mov WORD PTR [si + RegsOff + 1], dx
mov ax, si ;start of code ptr in AX
add ax, JmpAddr - IntEntry ;add distance to offset of OldInt
; and move to actual JMP opcode
mov [si + (JmpAddr - IntEntry) - 2], ax
pop si
pop dx
pop bx
pop ax
pop bp
retf 0Ah ;return clearing stack
; of five ptr words
handle ENDP
END ;this is the end, my FIDO friend, the end...
--- D'Bridge 1.30/071082
* Origin: RadioLink! Columbus, OH (614)766-2162 HST/DS (1:226/140)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET