home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
msdos
/
sysutl
/
history.arc
/
SETUP.ASM
< prev
Wrap
Assembly Source File
|
1988-03-21
|
2KB
|
117 lines
INCLUDE RULES.ASI
Header@
DSeg@
pgmstack dw ?
their_21 dd ?
ExtSym@ __brklvl, WORD, __CDECL__
ExtSym@ lineoff, WORD, __CDECL__
ExtSym@ lineseg, WORD, __CDECL__
DSegEnd@
ExtProc@ getline, __CDECL__
CSeg@
PubProc@ setup, __CDECL__
ifdef DEBUG
mov lineseg@,cs
mov lineoff@,offset line_buffer
call getline@
int 20h
line_buffer db 128,0,128 dup(?)
else
mov ax,3521h
int 21h
mov word ptr their_21,bx
mov word ptr their_21+2,es
mov dx,offset our_21@
mov ax,2521h
int 21h
mov dx,__brklvl@
add dx,1024 ;stack size.
mov pgmstack,dx
add dx,15
shr dx,1
shr dx,1
shr dx,1
shr dx,1
mov ah,31h
int 21h
endif
EndProc@ setup, __CDECL__
holdax dw ?
holdss dw ?
holdsp dw ?
holdds dw ?
; We could do this in Turbo C, but then we would add the overhead of saving the
; entire machine state on *every* int 21h. By doing it ourselves, we can save
; the state only when our function comes along.
PubProc@ our_21, __CDECL__
pushf
cmp ah,0ah ;buffered input?
jz our_21_1
popf
jmp cs:their_21
our_21_1:
mov cs:holdax,ax
mov cs:holdss,ss
mov cs:holdsp,sp
mov cs:holdds,ds
mov ax,cs ;set up ds
mov ds,ax
cli ;no ints while messing with stack
mov ss,ax
mov sp,pgmstack
sti ;ok, now you can interrupt
push bx ;save regs
push cx
push dx
push si
push di
push bp
push es
mov ax,holdds ;set up for getline
mov lineseg@,ax
mov lineoff@,dx
call getline@
pop es
pop bp
pop di
pop si
pop dx
pop cx
pop bx
cli ;no interruptions please
mov ss,cs:holdss
mov sp,cs:holdsp
sti ;ok to interrupt again
mov ds,cs:holdds
mov ax,cs:holdax
popf
iret
EndProc@ our_21, __CDECL__
CSegEnd@
end