Skip to content

Commit

Permalink
added L for DebugB
Browse files Browse the repository at this point in the history
  • Loading branch information
Baron-von-Riedesel committed Nov 7, 2022
1 parent 88a97d7 commit 4ae8e41
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 21 deletions.
25 changes: 19 additions & 6 deletions DEBUG.TXT
Expand Up @@ -804,21 +804,34 @@
during its initialization ( actually, because it doesn't depend on any DOS
interrupts, this debugger is not restricted to DOS ) . Since it has to be
loaded before the OS, when no file system is available yet, it must be
installed at a location that the boot sector can handle easily. For FAT file
systems, this could be the "reserved" region, just behind the boot sector(s).
The boot sector code must be adjusted, to load and also initialize the
debugger. Initialization of the debugger is simple: it's a far call of the
installed at a location that the boot sector ( either the MBR or the
partition's boot sector ) can handle easily - for FAT file systems, this
could be the "reserved" region, just behind the FAT boot sector(s).

The size of the DebugB binary may vary depending on what features are
activated, usually it's between 19 an 24 kB ( 38 - 48 sectors ( 512B ).

Initialization of the debugger is simple: it's a far call of the
address the debugger has been loaded, with an offset of 0000 ( so it's a
"call 0800h:0000" if the debugger has been loaded at linear address 08000h ).
The address to load the debugger may vary - low addresses are preferable since
the debugger will relocate itself just above conventional memory ( adjusting
BIOS variable at 0040h:0013h ).

As it has been mentioned, the boot sector code must be adjusted, to load
and initialize the debugger. However, DebugB has the ability to load and run
another boot sector from inside the debugger, using the L command ( which
works, unlike the other versions of the debugger, for physical disks ). The
DP command may be used to list the available partitions of a disk ( currently
MBR-partitioned disks only ).

Currently there are problems when the boot loader GRUB has to swap disk
numbers - to achieve this it intrudes into conventional memory, but that's
done in such a way that other programs can't reliably modify BIOS variable
0040h:0013h anymore.
Some commands aren't available in DebugB: Q(uit), L(oad), W(rite), N(ame),
DM and the EMS branch.

Some commands aren't available in DebugB: Q(uit), N(ame), W(rite), DM and
the EMS branch.


10. DEBUG Scripts
Expand Down
8 changes: 5 additions & 3 deletions README.TXT
Expand Up @@ -184,9 +184,11 @@
fullscreen text mode programs.

- DebugB.BIN: a version that is supposed to be loaded during the
boot process, before DOS is loaded. Has to be installed in the
"reserved" sectors of a FAT disk and must be initialized by
modified boot sector code. Not suitable for beginners.
boot process, before DOS is loaded. Has to be installed in "free"
disk space ( for example, in the "reserved" sectors of a FAT partition
or behind the disk's MBR ) and must be initialized before it becomes
active. Definitely not for beginners. See "Installing and Initializing
DebugB" in DEBUG.TXT for details.

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

Expand Down
86 changes: 74 additions & 12 deletions src/DEBUG.ASM
Expand Up @@ -391,11 +391,7 @@ CONST segment
cmdlist dw a_cmd,cmd_error,c_cmd,d_cmd
dw e_cmd,f_cmd,g_cmd,h_cmd
dw i_cmd,cmd_error,cmd_error
if BOOTDBG
dw cmd_error ; no L for boot debug
else
dw l_cmd
endif
dw m_cmd
if DRIVER or BOOTDBG
dw cmd_error ; no N for the driver variant
Expand Down Expand Up @@ -506,7 +502,7 @@ endif
switchar db 0 ;switch character
vpage db 0 ;video page the debugger is to use for BIOS output
swch1 db ' ' ;switch character if it's a slash
driveno db 0 ;drive no used by L/W cmds
driveno db 0 ;drive no for L/W cmds ( used for error msgs only )
promptlen dw 0 ;length of prompt
if REDIRECT
bufnext dw line_in+2 ;if stdin=file: address of next available character
Expand Down Expand Up @@ -774,7 +770,9 @@ if DRIVER or BOOTDBG
else
db 'load program',9,'L [address]',CR,LF
endif
ife BOOTDBG
if BOOTDBG
db 'load sectors',9,'L address disk sector count',CR,LF
else
db 'load sectors',9,'L address drive sector count',CR,LF
endif
db 'move',9,9, 'M range address',CR,LF
Expand Down Expand Up @@ -834,6 +832,7 @@ presskey db '[more]'

errcarat db '^ Error'

ife BOOTDBG
dskerr0 db 'Write protect error',0
dskerr1 db 'Unknown unit error',0
dskerr2 db 'Drive not ready',0
Expand All @@ -854,6 +853,10 @@ dskerrs db dskerr0-dskerr0,dskerr1-dskerr0
db dskerr8-dskerr0,dskerr9-dskerr0
db dskerra-dskerr0,dskerrb-dskerr0
db dskerrc-dskerr0
else
dskerr1 db "Unknown disk",CR,LF,'$'
dskerrb db "Read fault",CR,LF,'$'
endif

reading db ' read',0
writing db ' writ',0
Expand Down Expand Up @@ -5535,7 +5538,57 @@ endif
ret
ensuredebuggeeloaded endp

ife BOOTDBG
if BOOTDBG

;--- L command - absolute disk read.

l_cmd proc
call parselw ;returns AL=drive, BX=packet
jz cmd_error ;must be a full command
@dprintf "l: disk=%X", ax
mov dl, al
push ax
mov ah, 8
int 13h
pop ax
jc disk_inval
mov ah, al
and ah, 7Fh
cmp dl, ah
jbe disk_inval
mov dl, al

;--- todo: check if LBA access is possible, if no,
;--- switch to CHS.

xor cx, cx
mov bp, sp
push cx
push cx
push word ptr [bx].PACKET.secno+2
push word ptr [bx].PACKET.secno+0
push [bx].PACKET.dstseg
push [bx].PACKET.dstofs
push [bx].PACKET.numsecs
mov cl, 16
push cx
mov si, sp
mov ah, 42h
int 13h
mov sp, bp
jc disk_err
done:
ret
disk_err:
mov dx, offset dskerrb
jmp int21ah9
disk_inval:
mov dx, offset dskerr1
jmp int21ah9

l_cmd endp

else

;--- L command - read a program, or disk sectors, from disk.

Expand Down Expand Up @@ -5574,7 +5627,7 @@ ll0_1:
int 25h
ll0_2:
mov dx,offset reading
jmp ww1
jmp disp_diskresult

;--- For .com or .exe files, we can only load at cs:100. Check that first.

Expand Down Expand Up @@ -7578,7 +7631,14 @@ ww0_1:
int 26h
ww0_2:
mov dx,offset writing
ww1:: ;<--- entry from ll
; jmp disp_diskresult ; fall thru to disp_diskresult

w_cmd endp

;--- display disk access result ( C if error )
;--- DX="reading"/"writing"

disp_diskresult proc
mov bx,ss ;restore segment registers
mov ds,bx
mov sp,[top_sp]
Expand All @@ -7600,14 +7660,14 @@ ww1:: ;<--- entry from ll
call copystring ;si->di
mov si,offset drive
call copystring ;si->di
mov al,driveno
mov al, [driveno]
add al,'A'
stosb
call putsline
ww3:
jmp cmdloop ;can't ret because stack is wrong

w_cmd endp
disp_diskresult endp

endif

Expand Down Expand Up @@ -12505,7 +12565,9 @@ endif

;--- Check DOS version

ife BOOTDBG
if BOOTDBG
mov [usepacket], 1
else
mov ax,3000h ;check DOS version
int 21h
xchg al,ah
Expand Down

0 comments on commit 4ae8e41

Please sign in to comment.