Skip to content

Commit 2cc1622

Browse files
dprintfr.inc added
1 parent fe2f04e commit 2cc1622

7 files changed

Lines changed: 279 additions & 17 deletions

File tree

HISTORY.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
- DebugR(L): added bp & bc cmds.
304304
2.02 [11.2.2024]
305305
- fixed S cmd: position display was corrupted in v2.00-v2.01.
306-
2.50 [14.5.2024]
306+
2.50 [1.6.2024]
307307
- DebugR fix: debugger assumed a 32-bit ring0 SS register on init;
308308
if this wasn't true, a crash may have occured.
309309
- fix r cmd: the disassembler tried to show memory contents for the LEA

src/DEBUG.ASM

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -703,13 +703,10 @@ u_addr dw 0,0,0 ;address for last U command; must follow d_addr
703703
if USEHWBP
704704
;--- bits in bType:
705705
;--- 0-3: type
706-
;--- 5: 1=bp is temp
707-
;--- 6: 1=bp is active
708-
;--- 7: 1=bp is used
709706
BP_CODE equ 0h
710-
BP_TEMP equ 20h
711-
BP_ACTIVE equ 40h
712-
BP_USED equ 80h
707+
BP_TEMP equ 20h ;1=bp is temporary
708+
BP_ACTIVE equ 40h ;1=bp has been set
709+
BP_USED equ 80h ;1=used,0=free
713710
BP_ACTIVEBIT equ 6
714711

715712
HWBPSTRUCT struct
@@ -7948,9 +7945,9 @@ WPENABLE equ 1 ;local wp enable
79487945
;--- DR7 (debug control register):
79497946
;--- bit 0-7: L0,G0 - L3,G3
79507947
;--- bit 8-9: LE,GE
7951-
;--- type ( optional 2. argument ) will be copied to bits 16-19 (RW0,LEN0)
7952-
;--- bit 16-17: type (0=exec, 1=write, 2=I/O [if CR4.DE=1], 3=read or write)
7953-
;--- bit 18-19: len (0=1 byte, 1=2 byte, 2=8 byte, 3=4 byte )
7948+
;--- type ( optional 2. argument ) will be copied to bits 16-31 (RWx,LENx)
7949+
;--- bp0 bit 16-17: type (0=exec, 1=write, 2=I/O [if CR4.DE=1], 3=read or write)
7950+
;--- bp0 bit 18-19: len (0=1 byte, 1=2 byte, 2=8 byte, 3=4 byte )
79547951

79557952
;--- map (hard) breakpoints to debug registers
79567953
;--- entry will be patched to NOP NOP if hw bp enabled!
@@ -7989,8 +7986,8 @@ skipbp:
79897986
inc cx
79907987
cmp cl, MAXHWBP
79917988
jnz nextbp
7992-
;--- set resume flag generally - another debugger might have set a HW bp, and without
7993-
;--- RF=1 we would be stuck...
7989+
;--- set resume flag generally - another debugger
7990+
;--- might have set a HW bp, and without RF=1 we would be stuck...
79947991
or byte ptr [regs.rFL+2], 1
79957992
ret
79967993
error:
@@ -8707,7 +8704,7 @@ nextbp:
87078704
lodsd
87088705
xchg edx, eax
87098706
lodsb
8710-
@dprintf "bp: cx=%X, edx=%lX, ax=%X", cx, edx, ax
8707+
@dprintf "bp: cx=%X, edx=%lX, al=%X", cx, edx, ax
87118708
test al, BP_USED
87128709
jz skipbp
87138710
mov di, offset line_out
@@ -10985,7 +10982,11 @@ stdout endp
1098510982
ifdef _DEBUG
1098610983
pushcontext cpu
1098710984
.386
10985+
if RING0 and V86M
10986+
include <DPRINTFR.INC>
10987+
else
1098810988
include <DPRINTF.INC>
10989+
endif
1098910990
popcontext cpu
1099010991
endif
1099110992

src/DISASM.INC

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ da21:
488488
jnz @F
489489
dec di
490490
@@:
491-
@dprintf "da21, di=%X", di
491+
; @dprintf "da21, di=%X", di
492492
xor bx, bx
493493
nextflag:
494494
mov ax, word ptr [preflags] ; ah=preused

src/DPRINTF.INC

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ dprintf PROC
8585
d_sp equ word ptr [bp+16+2]
8686
d_ret equ word ptr [bp+16+2+2]
8787
d_fmt equ word ptr [bp+16+2+2+2]
88-
d_args equ word ptr [bp+16+2+2+2+2]
88+
d_args equ [bp+16+2+2+2+2]
8989

9090
if 0
9191
local size_:word

src/DPRINTFR.INC

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
2+
;--- debug printf - all registers preserved, including flags
3+
;--- DEBUGR variant, compatible with 32-bit stack
4+
5+
handle_char proc
6+
7+
cmp al,10
8+
jnz @F
9+
mov al,13
10+
call @F
11+
mov al,10
12+
@@:
13+
push bx
14+
xor bx,bx
15+
mov ah,0Eh
16+
call cs:[int10vec]
17+
pop bx
18+
ret
19+
20+
handle_char endp
21+
22+
;--- ltob(long n, char * s, int base);
23+
;--- convert long to string
24+
;--- eax=number
25+
;--- ss:ebx=buffer
26+
;--- cx=base
27+
28+
ltob PROC
29+
30+
push edi
31+
movzx edi, cx
32+
mov ch,0
33+
cmp di,-10
34+
jne @F
35+
mov di,10
36+
and eax,eax
37+
jns @F
38+
neg eax
39+
mov ch,'-'
40+
@@:
41+
add ebx,10
42+
mov BYTE PTR ss:[ebx],0
43+
dec ebx
44+
@@nextdigit:
45+
xor edx, edx
46+
div edi
47+
add dl,'0'
48+
cmp dl,'9'
49+
jbe @F
50+
add dl,7+20h
51+
@@:
52+
mov ss:[ebx],dl
53+
dec ebx
54+
and eax, eax
55+
jne @@nextdigit
56+
cmp ch,0
57+
je @F
58+
mov ss:[ebx],ch
59+
dec ebx
60+
@@:
61+
inc ebx
62+
mov eax,ebx
63+
pop edi
64+
ret
65+
66+
ltob ENDP
67+
68+
;--- ds unused; ss unknown, may be 16- or 32-bit.
69+
;--- tiny model ( strings may be addressed with CS ) assumed.
70+
71+
dprintf PROC
72+
73+
d_esp equ <dword ptr [ebp+32+2]>
74+
d_ret equ <word ptr [ebp+32+2+4]>
75+
d_fmt equ <word ptr [ebp+32+2+4+2]>
76+
d_args equ <[ebp+32+2+4+2+2]>
77+
78+
d_size equ <word ptr [ebp-2]>
79+
d_flag equ <byte ptr [ebp-3]>
80+
d_longarg equ <byte ptr [ebp-4]>
81+
d_fill equ <byte ptr [ebp-5]>
82+
d_szTmp equ <[ebp-18]>
83+
84+
push esp
85+
pushf
86+
pushad
87+
mov ebp, esp
88+
sub esp, 18
89+
mov ax, ss
90+
lar eax, eax
91+
bt eax, 22
92+
jc @F
93+
movzx ebp, bp
94+
@@:
95+
lea edi, d_args
96+
@@L335:
97+
mov si, d_fmt
98+
nextchar:
99+
lodsb cs:[si]
100+
or al,al
101+
je done
102+
cmp al,'%'
103+
je formatitem
104+
call handle_char
105+
jmp nextchar
106+
done:
107+
sub edi, 2
108+
mov ax, d_ret
109+
mov ss:[edi], ax
110+
mov d_esp, edi
111+
add esp, 18
112+
popad
113+
popf
114+
pop esp
115+
ret
116+
117+
formatitem:
118+
push @@L335
119+
xor dx,dx
120+
mov d_longarg,dl
121+
mov bl,1
122+
mov cl,' '
123+
cmp BYTE PTR cs:[si],'-'
124+
jne @F
125+
dec bx
126+
inc si
127+
@@:
128+
mov d_flag, bl
129+
cmp BYTE PTR cs:[si],'0'
130+
jne @F
131+
mov cl,'0'
132+
inc si
133+
@@:
134+
mov d_fill,cl
135+
mov bx,dx
136+
@@:
137+
lodsb cs:[si]
138+
cmp al, '0'
139+
jb numdone
140+
cmp al, '9'
141+
ja numdone
142+
sub al,'0'
143+
cbw
144+
imul cx,bx,10 ;cx = bx * 10
145+
add ax,cx
146+
mov bx,ax
147+
jmp @B
148+
numdone:
149+
dec si
150+
mov d_size, bx
151+
cmp BYTE PTR cs:[si],'l'
152+
jne @F
153+
mov d_longarg,1
154+
inc si
155+
@@:
156+
lodsb cs:[si]
157+
mov d_fmt,si
158+
cmp al,'x'
159+
je handle_x
160+
cmp al,'X'
161+
je handle_x
162+
cmp al,'c'
163+
je handle_c
164+
cmp al,'d'
165+
je handle_d
166+
cmp al,'i'
167+
je handle_i
168+
cmp al,'s'
169+
je handle_s
170+
cmp al,'u'
171+
je handle_u
172+
cmp al,0
173+
jnz @@L359
174+
pop ax
175+
jmp done
176+
handle_c:
177+
mov ax,ss:[edi]
178+
add edi,2
179+
@@L359:
180+
call handle_char
181+
retn
182+
183+
handle_x:
184+
mov cx,16
185+
jmp @@lprt262
186+
handle_d:
187+
handle_i:
188+
mov cx,-10
189+
jmp @@lprt262
190+
handle_u:
191+
mov cx,10
192+
@@lprt262:
193+
mov ax,ss:[edi]
194+
add edi,2
195+
sub dx,dx
196+
cmp cx,0 ;signed or unsigned?
197+
jge @F
198+
cwd
199+
@@:
200+
cmp d_longarg,0
201+
je @F
202+
mov dx,ss:[edi]
203+
add edi,2
204+
@@:
205+
lea ebx, d_szTmp
206+
207+
push dx
208+
push ax
209+
pop eax
210+
; invoke ltob, eax, bx, cx
211+
call ltob
212+
mov esi,eax
213+
.while byte ptr ss:[esi]
214+
lodsb ss:[esi]
215+
call handle_char
216+
.endw
217+
retn
218+
219+
handle_s:
220+
mov si,ss:[edi]
221+
add edi,2
222+
223+
output_string: ;display string at ds:si
224+
mov ax,si
225+
mov bx,d_size
226+
.while byte ptr cs:[si]
227+
inc si
228+
.endw
229+
sub si,ax
230+
xchg ax,si
231+
sub bx,ax
232+
.if d_flag == 1
233+
.while sword ptr bx > 0
234+
mov al, d_fill
235+
call handle_char
236+
dec bx
237+
.endw
238+
.endif
239+
240+
.while byte ptr cs:[si]
241+
lodsb cs:[si]
242+
call handle_char
243+
.endw
244+
245+
.while sword ptr bx > 0
246+
mov al, d_fill
247+
call handle_char
248+
dec bx
249+
.endw
250+
retn
251+
252+
dprintf ENDP
253+
254+
d_esp equ <>
255+
d_ret equ <>
256+
d_fmt equ <>
257+
d_args equ <>
258+
d_size equ <>
259+
d_flag equ <>
260+
d_longarg equ <>
261+
d_fill equ <>
262+
d_szTmp equ <>
263+

src/TRAPP.INC

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ intr00: ; divide error
138138

139139
intr01: ; single-step interrupt/debug exception
140140
push EXC01MSG or (1 shl 8)
141-
intr01ex:
142141
call intrtnp1
143142
jmp cs:[oldi01]
144143

src/TRAPPV.INC

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ intr00: ; divide error
260260

261261
intr01: ; single-step interrupt/debug exception
262262
push EXC01MSG or (1 shl 8)
263-
intr01ex:
264263
call intrtnp1
265264
jmp cs:[oldi01]
266265

0 commit comments

Comments
 (0)