Skip to content

Commit 97b11c5

Browse files
debugxv: SysReq detected; fixed: int21ah9 used DOS if InDos set
1 parent d62db24 commit 97b11c5

4 files changed

Lines changed: 114 additions & 40 deletions

File tree

HISTORY.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,5 @@
268268
debugger visible there.
269269
- DEBUGX: restore hooked protected-mode interrupts when client
270270
terminates.
271+
- DEBUGXV: break if SYSREQ is pressed.
272+
- fixed: routine int21ah9 did use DOS, even if InDos flag was set.

MAKEX.BAT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jwasm -nologo -D?PM=1 -mz -Fo build\DEBUGXG.EXE -Fl=build\DEBUGXG.LST -DCATCHIN
1616
echo creating debugxU - dx cmd uses unreal mode
1717
jwasm -nologo -D?PM=1 -bin -Fo build\DEBUGXU.COM -Fl=build\DEBUGXU.LST -DUSEUNREAL=1 -DCATCHINT0D=1 src\debug.asm
1818

19-
echo creating debugxV - v cmd flips screens
20-
jwasm -nologo -D?PM=1 -bin -Fo build\DEBUGXV.COM -Fl=build\DEBUGXV.LST -DVXCHG=1 src\debug.asm
19+
echo creating debugxV - v cmd flips screens & sysreq trapped
20+
jwasm -nologo -D?PM=1 -bin -Fo build\DEBUGXV.COM -Fl=build\DEBUGXV.LST -DVXCHG=1 -DCATCHSYSREQ=1 src\debug.asm

README.TXT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@
172172
- DebugXV.COM: a version that takes care that screen output of
173173
debuggee and debugger are strictly separated - the new 'v'
174174
command is provided to watch the debuggee screen while the
175-
debugger is active. This debug version is useful to debug
175+
debugger is active. Additionally, the SysReq key is detected and
176+
will activate the debugger. This debug version is useful to debug
176177
fullscreen text mode programs.
177178

178179
d. The following features of MS Debug are not implemented:

src/DEBUG.ASM

Lines changed: 108 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ MCB equ 1 ;support DM command
9999
EMSCMD equ 1 ;support Xx commands
100100
USESDA equ 1 ;use SDA to get/set PSP in real-mode
101101
STACKSIZ equ 200h ;debug's stack size
102+
USEI1585 equ 0 ;if CATCHSYSREQ==1, defines the method (ah=85h or ah=4Fh)
102103

103104
ifndef CATCHINT01
104105
CATCHINT01 equ 1 ;catch INT 01 (single-step)
@@ -127,6 +128,9 @@ endif
127128
ifndef CATCHINT0D
128129
CATCHINT0D equ 0 ;catch exception 0Dh in real-mode
129130
endif
131+
ifndef CATCHSYSREQ
132+
CATCHSYSREQ equ 0 ;catch int 15h (sysreq)
133+
endif
130134
ifndef CATCHINT31
131135
CATCHINT31 equ 0 ;hook DPMI int 31h
132136
endif
@@ -497,7 +501,7 @@ else
497501
packet PACKET <0,0,0,0>
498502
endif
499503

500-
intsave label dword
504+
intsave label dword ; must match order in inttab
501505
dd 0 ;saved vector i00
502506
if CATCHINT01
503507
dd 0 ;saved vector i01
@@ -516,9 +520,12 @@ oldi0C dd 0 ;saved vector i0C
516520
endif
517521
if CATCHINT0D
518522
oldi0D dd 0 ;saved vector i0D
523+
endif
524+
if CATCHSYSREQ
525+
oldi15 dd 0 ;saved vector i15
519526
endif
520527
dd 0 ;saved vector i22
521-
if ?PM
528+
if ?PM ;must be last
522529
oldi2f dd 0
523530
endif
524531

@@ -579,7 +586,7 @@ INTITEM struct
579586
dw ?
580587
INTITEM ends
581588

582-
inttab label INTITEM
589+
inttab label INTITEM ; must match order in intsave
583590
INTITEM <00h, intr00>
584591
if CATCHINT01
585592
INTITEM <01h, intr01>
@@ -598,14 +605,14 @@ if CATCHINT0C
598605
endif
599606
if CATCHINT0D
600607
INTITEM <0Dh, intr0D>
608+
endif
609+
if CATCHSYSREQ
610+
INTITEM <15h, intr15>
601611
endif
602612
INTITEM <22h, intr22>
603613
NUMINTS = ( $ - inttab ) / sizeof INTITEM
604614
if ?PM
605615
db 2Fh
606-
NUMINTSX = NUMINTS+1
607-
else
608-
NUMINTSX = NUMINTS
609616
endif
610617

611618
;--- register names for 'r'. One item is 2 bytes.
@@ -802,6 +809,9 @@ endif
802809
if CATCHINT07 or CATCHEXC07
803810
exc07msg db 'Coprocessor not present',CR,LF,'$'
804811
endif
812+
if CATCHSYSREQ
813+
sysrqmsg db 'SysRq detected',CR,LF,'$'
814+
endif
805815
if EXCCSIP
806816
excloc db 'CS:IP=',0
807817
endif
@@ -5260,30 +5270,30 @@ getpsp proc
52605270
if ?PM
52615271
call ispm
52625272
jz getpsp_rm
5263-
if NOEXTENDER
5273+
if NOEXTENDER
52645274
call doscallx
52655275
mov ax,2
52665276
int 31h
52675277
mov bx,ax
52685278
ret
5269-
else
5279+
else
52705280
jmp doscall_rm
5271-
endif
5281+
endif
52725282
getpsp_rm:
52735283
endif
52745284

52755285
if USESDA
5276-
if ?PM
5286+
if ?PM
52775287
cmp word ptr [pSDA+2],0
52785288
jz doscall_rm
5279-
endif
5289+
endif
52805290
push ds
52815291
push si
5282-
if ?PM
5292+
if ?PM
52835293
call LoadSDA
5284-
else
5294+
else
52855295
lds si,[pSDA]
5286-
endif
5296+
endif
52875297
mov bx,[si+10h]
52885298
pop si
52895299
pop ds
@@ -6710,27 +6720,26 @@ endif
67106720

67116721
mov di,offset intsave
67126722
mov si,offset inttab
6713-
mov cx,NUMINTSX
6723+
if ?PM
6724+
mov cx,NUMINTS+1
6725+
else
6726+
mov cx,NUMINTS
6727+
endif
67146728
nextint:
67156729
lodsb
6716-
mov bl,al
6730+
push ds
67176731
add si,2 ; skip rest of INTITEM
6718-
xchg si,di
6719-
lodsw
6720-
mov dx,ax
6721-
lodsw
6722-
xchg si,di
6723-
cmp bl,22h
6732+
lds dx, [di]
6733+
add di,4
6734+
cmp al,22h
67246735
jz norestore
6725-
and ax,ax
6736+
mov bx, ds
6737+
and bx, bx
67266738
jz norestore
6727-
push ds
6728-
mov ds,ax
6729-
mov al,bl
67306739
mov ah,25h
67316740
int 21h
6732-
pop ds
67336741
norestore:
6742+
pop ds
67346743
loop nextint
67356744

67366745
;--- Restore termination address.
@@ -7628,9 +7637,30 @@ io_error:
76287637
mov dx,offset openerr ;Error ____ opening file
76297638
@@:
76307639
int21ah9::
7640+
if 1 ;v1.30: check InDos, if set use stdout()
7641+
call InDos
7642+
jnz use_stdout
7643+
endif
76317644
mov ah,9
76327645
call doscall
76337646
ret
7647+
if 1 ;v1.30: get size of $-string DS:DX, then call stdout; SI, CX not modified
7648+
use_stdout:
7649+
push si
7650+
push cx
7651+
mov si, dx
7652+
@@:
7653+
lodsb
7654+
cmp al, '$'
7655+
jnz @B
7656+
dec si
7657+
sub si, dx
7658+
mov cx, si
7659+
call stdout
7660+
pop cx
7661+
pop si
7662+
ret
7663+
endif
76347664

76357665
if EMSCMD
76367666

@@ -8071,8 +8101,9 @@ endif
80718101
freemem endp
80728102

80738103
;--- this is called by "run"
8074-
;--- better don't use INTs inside
8075-
;--- set debuggee's INT 23/24
8104+
;--- set debuggee's INT 23/24.
8105+
;--- don't use INT 21h here, DOS might be "in use".
8106+
;--- registers may be modified - will soon be set to debuggee's
80768107

80778108
setint2324 proc
80788109
mov si,offset run2324
@@ -8091,7 +8122,10 @@ endif
80918122
movsw
80928123

80938124
if ?PM
8125+
call InDos
8126+
jnz @F
80948127
call hook2f
8128+
@@:
80958129
endif
80968130

80978131
pop es
@@ -8282,6 +8316,38 @@ intr0D:
82828316
jmp intrtn
82838317
endif
82848318

8319+
if CATCHSYSREQ
8320+
@@:
8321+
jmp cs:[oldi15]
8322+
intr15:
8323+
if USEI1585
8324+
cmp ax, 8501h ;sysreq released?
8325+
else
8326+
cmp ax, 4F00h + (54h or 80h) ; use int 15h, ah=4Fh
8327+
endif
8328+
jnz @B
8329+
test cs:[bInDbg],1
8330+
jnz @B
8331+
ife USEI1585
8332+
;--- if int 15h, ah=4Fh, no EOI has been sent to PIC yet
8333+
;--- and the kbd may be disabled.
8334+
push ax
8335+
mov al, 20h
8336+
out 20h, al
8337+
@@:
8338+
in al, 64h
8339+
test al, 2
8340+
jnz @B
8341+
mov al, 0AEh; enable kbd
8342+
out 64h, al
8343+
pop ax
8344+
endif
8345+
if ?PM
8346+
inc cs:[bNoHook2F] ; disable hooking
8347+
endif
8348+
mov cs:[run_int],offset sysrqmsg ;remember interrupt type
8349+
jmp intrtn
8350+
endif
82858351
;--- Interrupt 3 (breakpoint interrupt) handler.
82868352

82878353
intr03:
@@ -8351,18 +8417,18 @@ intrtn1:: ;<--- entry for int 22
83518417
if ?PM
83528418
;--- calling int 2Fh here is a problem, since breakpoints aren't reset yet.
83538419
;--- this makes it impossible to trace this interrupt.
8354-
if DPMIMSW
8420+
if DPMIMSW
83558421
mov ax,1686h
83568422
int 2Fh
83578423
cmp ax,1
83588424
sbb ax,ax
8359-
else
8425+
else
83608426
mov ax,cs
83618427
sub ax,[pspdbg] ;Z=rm,NZ=pm
83628428
cmp ax,1 ;C=rm,NC=pm
83638429
cmc ;NC=rm,C=pm
83648430
sbb ax,ax ;0=rm,-1=pm
8365-
endif
8431+
endif
83668432
mov [regs.msw],ax ;0000=real-mode, FFFF=protected-mode
83678433
endif
83688434

@@ -8449,10 +8515,9 @@ if VXCHG
84498515
v_cmd proc
84508516
mov al,0
84518517
call swapscreen
8452-
ifndef VXCHGBIOS
8518+
if 0;ndef VXCHGBIOS ; v1.30: no longer needed, swapscreen has set cursor
84538519
;--- swapscreen has restored screen and cursor pos, but we want
84548520
;--- the cursor be shown on the screen - so set it thru BIOS calls.
8455-
84568521
mov ah, 0Fh ; get current mode (and video page in BH)
84578522
int 10h
84588523
mov ah, 3 ; get cursor pos of page in BH
@@ -8493,9 +8558,15 @@ swapscreen proc
84938558
mov bl, es:[62h]
84948559
mov bh, 0
84958560
shl bx, 1
8496-
mov ax, es:[bx+50h] ; get cursor pos of current page
8497-
xchg ax, [csrpos]
8498-
mov es:[bx+50h], ax
8561+
mov dx, es:[bx+50h] ; get cursor pos of current page
8562+
xchg dx, [csrpos]
8563+
if 0
8564+
mov es:[bx+50h], dx
8565+
else
8566+
mov bh, es:[62h]
8567+
mov ah, 2
8568+
int 10h
8569+
endif
84998570

85008571
push ds
85018572
pop es

0 commit comments

Comments
 (0)