Skip to content

Commit 7b72cd6

Browse files
bugfix 'd' and 'e' cmd for 32-bit segments
1 parent ffcd692 commit 7b72cd6

4 files changed

Lines changed: 288 additions & 29 deletions

File tree

HISTORY.TXT

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,9 @@
226226
- if InDOS flag is set, a '!' is preceding the debugger prompt.
227227
- BIOS used when waiting for a key in help msg display.
228228
- 'e' cmd uses BIOS if InDOS flag set.
229+
1.28 [14 Februar 2021]
230+
- bugfix 'e' cmd: used wrong offset when reading from 32-bit segments.
231+
- bugfix 'd' cmd: hiword(ecx) wasn't cleared, resulting in a "default"
232+
length for 32-bit segment dump > 128.
233+
- added debug displays (created if _DEBUG is defined)
229234

MAKEX.BAT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ echo creating debugxG - device driver version of debugx
1414
jwasm -c -nologo -D?PM=1 -mz -Fo build\DEBUGXG.EXE -Fl=build\DEBUGXG.LST -DCATCHINT06=1 -DDRIVER=1 src\debug.asm
1515

1616
echo creating debugxU - dx cmd uses unreal mode
17-
jwasm -c -nologo -D?PM=1 -bin -Fo build\DEBUGXU.COM -Fl=build\DEBUGXU.LST -DDXUNREAL=1 -DCATCHINT0D=1 src\debug.asm
17+
jwasm -c -nologo -D?PM=1 -bin -Fo build\DEBUGXU.COM -Fl=build\DEBUGXU.LST -DUSEUNREAL=1 -DCATCHINT0D=1 src\debug.asm

src/DEBUG.ASM

Lines changed: 68 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; DEBUG.ASM Masm/JWasm assembler source for a clone of DEBUG.COM
2-
; Version 1.27, ??.02.2020.
2+
; Version 1.28, 14.02.2021.
33

44
; To assemble, use:
55
; jwasm -D?PM=0 -bin -Fo debug.com debug.asm
@@ -76,8 +76,8 @@ CATCHEXC07 equ 0 ;catch exception 07h in protected-mode
7676
CATCHEXC0C equ 1 ;catch exception 0Ch in protected-mode
7777
MMXSUPP equ 1 ;support MMX specific commands
7878
DXSUPP equ 1 ;support DX command
79-
ifndef DXUNREAL
80-
DXUNREAL equ 0 ;set to 1 if unreal-mode is to be used by DX cmd
79+
ifndef USEUNREAL
80+
USEUNREAL equ 0 ;set to 1 if debug is to use unreal-mode (for DX/EX cmd)
8181
endif
8282
else
8383
VDD equ 0
@@ -148,6 +148,22 @@ SPSAV equ 2eh ;Save the stack pointer here
148148
DTA equ 80h ;Program arguments; also used to store file name (N cmd)
149149
endif
150150

151+
ifdef _DEBUG
152+
dprintf proto c text:ptr, args:vararg
153+
@dprintf macro text:req,args:vararg
154+
local sym
155+
CONST segment
156+
sym db text,10,0
157+
CONST ends
158+
pushcontext cpu
159+
.386
160+
invoke dprintf, offset sym, args
161+
popcontext cpu
162+
endm
163+
else
164+
@dprintf textequ <;>
165+
endif
166+
151167
;--- mne macro, used for the assembler mnemonics table
152168

153169
mne macro val2:REQ, dbytes:VARARG
@@ -630,7 +646,7 @@ if ?PM
630646
prompt3 db '#' ;protected-mode prompt
631647
endif
632648

633-
helpmsg db DOSNAME, ' ', DBGNAME2, ' v1.27 help screen',CR,LF
649+
helpmsg db DOSNAME, ' ', DBGNAME2, ' v1.28 help screen',CR,LF
634650
db 'assemble',9, 'A [address]',CR,LF
635651
db 'compare',9,9, 'C range address',CR,LF
636652
db 'dump',9,9, 'D [range]',CR,LF
@@ -4016,7 +4032,7 @@ endif
40164032

40174033
if DXSUPP
40184034

4019-
if DXUNREAL
4035+
if USEUNREAL
40204036

40214037
align 4
40224038
gdt label qword
@@ -4068,7 +4084,7 @@ endif
40684084

40694085
.386
40704086

4071-
extmem proc
4087+
dx_cmd proc
40724088
mov dx,word ptr [x_addr+0]
40734089
mov bx,word ptr [x_addr+2]
40744090
call skipwhite
@@ -4077,20 +4093,20 @@ extmem proc
40774093
call getdword ;get linear address into bx:dx
40784094
call chkeol ;expect end of line here
40794095
@@:
4080-
mov [lastcmd],offset extmem
4096+
mov [lastcmd],offset dx_cmd
40814097
push bx
40824098
push dx
40834099
pop ebp
40844100

4085-
if DXUNREAL
4101+
if USEUNREAL
40864102
;--- the dx cmd, when using int 15h,ah=87, has the
40874103
;--- side effect that unreal-mode most likely is disabled
4088-
;--- after the call. Setting DXUNREAL=1 avoids that,
4104+
;--- after the call. Setting USEUNREAL=1 avoids that,
40894105
;--- but has the disadvantange that DX won't work in v86-mode!
40904106

40914107
smsw ax ; don't use ispm, since that won't detect v86!
40924108
test al,1
4093-
jnz extmem_exit
4109+
jnz dx_exit
40944110
push ds
40954111
push cs
40964112
push offset int0d
@@ -4153,7 +4169,7 @@ else
41534169
@@:
41544170
int 15h
41554171
i15ok:
4156-
jc extmem_exit
4172+
jc dx_exit
41574173
endif
41584174
mov si,offset line_out+128
41594175
mov ch,8h
@@ -4188,10 +4204,10 @@ nextbyte:
41884204
dec ch
41894205
jnz nextline
41904206
mov [x_addr],ebp
4191-
extmem_exit:
4207+
dx_exit:
41924208
ret
41934209
.8086
4194-
extmem endp
4210+
dx_cmd endp
41954211

41964212
endif
41974213

@@ -4232,7 +4248,7 @@ if DXSUPP
42324248
jnz @F
42334249
cmp [machine],3
42344250
jb @F
4235-
jmp extmem
4251+
jmp dx_cmd
42364252
@@:
42374253
endif
42384254
if MCB
@@ -4242,17 +4258,20 @@ if MCB
42424258
@@:
42434259
endif
42444260
dd1_1:
4245-
mov cx,80h ;default length
4261+
sizeprfX ;clear hiword ecx (14.2.2021)
4262+
xor cx,cx
4263+
mov cl,80h ;default length
42464264
mov bx,[regs.rDS]
4247-
call getrangeX ;get address range into bx:(e)dx
4265+
call getrangeX ;get address range into bx:(e)dx ... bx:(e)cx
42484266
call chkeol ;expect end of line here
42494267

42504268
mov [d_addr+4],bx ;save segment (offset is saved later)
42514269
sizeprfX ;mov esi,edx
42524270
mov si,dx
4271+
sizeprfX ;mov edx,ecx (14.2.2021)
42534272
mov dx,cx ;dx = end address
42544273
4255-
jmp dd2_1
4274+
; jmp dd2_1
42564275

42574276
;--- Parsing is done. Print first line.
42584277

@@ -4406,7 +4425,7 @@ e_cmd proc
44064425
cmp al,CR
44074426
je ee1 ;if prompt mode
44084427
push dx ;save destination offset
4409-
call getstr ;get data bytes
4428+
call getstr ;get data bytes SI -> lineout
44104429
mov cx,di
44114430
mov dx,offset line_out
44124431
sub cx,dx ;length of byte string
@@ -4473,9 +4492,7 @@ ee3: ;<--- next byte
44734492
mov ax,' ' ;print old value of byte
44744493
stosw
44754494
call dohack ;set debuggee's int 23/24
4476-
push bx
44774495
call readmem ;read mem at BX:(E)DX
4478-
pop bx
44794496
call unhack ;set debugger's int 23/24
44804497
call hexbyte
44814498
mov al,'.'
@@ -6184,21 +6201,37 @@ done:
61846201
ret
61856202
writemem endp
61866203

6187-
;--- read byte at BX:EDX into AL
6204+
;--- read byte from memory
6205+
;--- in: BX:(E)DX=address
6206+
;--- out: AL=byte
6207+
;--- used by e_cmd prompt mode
61886208

61896209
readmem proc
61906210
if ?PM
6191-
call getselattr
6211+
; cmp [bAddr32],0
6212+
call getselattr ;attribute of selector in BX, Z if 16-bit
61926213
endif
61936214
push ds
61946215
mov ds,bx
6195-
sizeprfX ;mov ebx,edx
6196-
mov bx,dx
6197-
if ?PM
6198-
jz $+3
6199-
db 67h ;mov al,[ebx]
6216+
;--- 14.2.2021: the assumption that the address prefix 67h
6217+
;--- will change "mov al,[bx]" to "mov al,[ebx]" was somewhat "obvious",
6218+
;--- but nevertheless WRONG; the first is encoded 8A 07, the latter 67 8A 03!
6219+
; sizeprfX ;mov ebx,edx
6220+
; mov bx,dx
6221+
if ?PM
6222+
; jz $+3
6223+
; db 67h ;mov al,[ebx]
6224+
jz @F
6225+
.386
6226+
mov al,[edx]
6227+
.8086
6228+
jmp readmem_1
6229+
@@:
62006230
endif
6231+
xchg bx,dx
62016232
mov al,[bx]
6233+
xchg bx,dx
6234+
readmem_1:
62026235
pop ds
62036236
ret
62046237
readmem endp
@@ -11622,6 +11655,13 @@ hook2f endp
1162211655

1162311656
endif
1162411657

11658+
ifdef _DEBUG
11659+
pushcontext cpu
11660+
.386
11661+
include dprintf.inc
11662+
popcontext cpu
11663+
endif
11664+
1162511665
_TEXT ends
1162611666

1162711667
_DATA segment
@@ -11653,7 +11693,7 @@ initcont:
1165311693
;--- Debug initialization code.
1165411694
;---------------------------------------
1165511695

11656-
imsg1 db DBGNAME,' version 1.27. Debugger.',CR,LF,CR,LF
11696+
imsg1 db DBGNAME,' version 1.28. Debugger.',CR,LF,CR,LF
1165711697
db 'Usage: ', DBGNAME, ' [[drive:][path]progname [arglist]]',CR,LF,CR,LF
1165811698
db ' progname (executable) file to debug or examine',CR,LF
1165911699
db ' arglist parameters given to program',CR,LF,CR,LF

0 commit comments

Comments
 (0)