Skip to content

Commit ade46b3

Browse files
small size reduction; few comments added
1 parent 3bce1cd commit ade46b3

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

src/DEBUG.ASM

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
; - better syntax checks for A (so i.e. "mov ax,al" is rejected)
4848
; - add MMX instructions for A and U
4949
; - support loading *.HEX files
50+
; - hide debug's IVT vectors 0,1,3? Alternately, init them only when the
51+
; first G/P/T cmd is run, like MS Debug does for 1 & 3?
5052

5153
VERSION textequ <2.01>
5254

@@ -70,10 +72,10 @@ ifndef DRIVER
7072
DRIVER equ 0 ;1=create a device driver (for CONFIG.SYS) variant
7173
endif
7274
ifndef BOOTDBG
73-
BOOTDBG equ 0 ;1=create a bootstrap binary
75+
BOOTDBG equ 0 ;1=create a bootstrap binary (DebugB)
7476
endif
7577
ifndef RING0
76-
RING0 equ 0 ;1=create a ring0 debugger variant
78+
RING0 equ 0 ;1=create a ring0 debugger variant (DebugR)
7779
endif
7880
ifndef ?DPMI
7981
?DPMI equ 0 ;1=create a DPMI-aware variant (DebugX)
@@ -82,6 +84,8 @@ ifndef LMODE
8284
LMODE equ 0 ;1=long mode version if RING0==1 - this will define a 64-bit segment ( requires JWasm )
8385
endif
8486

87+
;--- default assembly-time values; may be overwritten below.
88+
8589
DGCMD = 0 ; support DG cmd
8690
DICMD = 0 ; support DI cmd
8791
DLCMD = 0 ; support DL cmd
@@ -99,7 +103,7 @@ USESDA = 1 ; use SDA to get/set PSP in real-mode
99103
INT22 = 1 ; handle int 22h ( DOS program termination )
100104
INT2324 = 1 ; switch int 23h & 24h for debugger/debuggee
101105
USEFP2STR = 0 ; 1=use FloatToStr()
102-
FLATSS = 0 ; always 0 (1 is for a flat stack if RING0==1)
106+
FLATSS = 0 ; always 0 except for DebugRL; flat stack needed for long mode ring0 variant.
103107

104108
if LMODE
105109
CS32ATTR equ 40h or 20h ; check both default size and 64-bit mode
@@ -7930,7 +7934,7 @@ endif
79307934
nextint:
79317935
lodsb
79327936
push ds
7933-
add si,2 ; skip rest of INTITEM
7937+
; add si,2 ; skip rest of INTITEM (now done below)
79347938
lds dx, [di]
79357939
add di,4
79367940
cmp al,22h
@@ -7942,6 +7946,7 @@ nextint:
79427946
int 21h
79437947
norestore:
79447948
pop ds
7949+
lodsw ; skip rest of INTITEM (16-bit offset)
79457950
loop nextint
79467951

79477952
if INT22
@@ -10462,11 +10467,11 @@ if INT2324
1046210467
call prehak1 ;copy IVT 23/24 to di (real-mode only)
1046310468
pop di
1046410469
ret
10465-
@@:
10470+
@@: ;this is actually a programming error!
1046610471
push ax
1046710472
push dx
1046810473
mov dx,offset ph_msg ;'error in sequence of calls to hack'
10469-
call int21ah9 ;print string
10474+
call int21ah9 ;print string
1047010475
pop dx
1047110476
pop ax
1047210477
endif
@@ -10486,7 +10491,7 @@ CONST ends
1048610491
prehak1 proc
1048710492
if ?DPMI
1048810493
call ispm_dbg
10489-
jnz _ret ;nothing to do
10494+
jnz _ret ;nothing to do if in PM
1049010495
endif
1049110496
push ds
1049210497
push si
@@ -12541,6 +12546,10 @@ if RING0
1254112546
;--- edx: offset input routine (int 16h)
1254212547
;--- es:edi=IDT
1254312548

12549+
if LMODE
12550+
CS64SEL equ 8 ; to be fixed: 64-bit code selector for DebugRL is 8 (Dos32cm)
12551+
endif
12552+
1254412553
push ds
1254512554
push es
1254612555
mov ds, ax
@@ -13246,7 +13255,7 @@ endif
1324613255
mov di, offset intsave
1324713256
if RING0
1324813257
.386
13249-
les ebx, [bp-6]
13258+
les ebx, [bp-6] ; load address of GDT
1325013259
@dprintf "initcode: setup int vectors, es:ebx=%X:%lX", es, ebx
1325113260
elseif BOOTDBG
1325213261
xor ax, ax
@@ -13283,13 +13292,14 @@ else
1328313292
mov [di+2], es
1328413293
xchg ax, dx ;save int # in dl
1328513294
endif
13286-
mov ax, [si] ;get address
13295+
; mov ax, [si] ;get address
13296+
lodsw ;get address (16-bit offset)
1328713297
if RING0
1328813298
if LMODE
13289-
movzx eax, ax
13299+
movzx eax, ax ;in long mode, IDT vectors must be 64-bit!
1329013300
add eax, [dwBase64]
1329113301
mov es:[ebx+edx*8+0], ax
13292-
mov word ptr es:[ebx+edx*8+2], 8 ; selector 8 is 64-bit ( Dos32cm )
13302+
mov word ptr es:[ebx+edx*8+2], CS64SEL ; CS must be 64-bit
1329313303
shr eax, 16
1329413304
else
1329513305
mov es:[ebx+edx*8+0], ax
@@ -13307,7 +13317,7 @@ else
1330713317
mov ah, 25h ;set interrupt vector
1330813318
int 21h
1330913319
endif
13310-
add si, 2
13320+
; add si, 2
1331113321
add di, sizeof INTVEC
1331213322
loop @B
1331313323

0 commit comments

Comments
 (0)