Here is the assembly source for my 386 debugger.  It was written in
protected mode.  It is part of a larger project which takes total
control over the 386 CPU, some functions which are in the remainder of
the operating system are not included.  Such functions display data, get
keyboard input, save/restore trap vectors, etc.  About the only one I
can think about which is not obvious is MapStackToSystem; Basically all
it does is adjust SS:ESP so that SS = DS and the same stack is used.
This is necessary when I started using stack-based parameters.

The predefined selectors you will encounter are:

DSABS:  an absolute selector which maps physical addresses starting at 0
	to logical addresses starting at 0.  The paging mechanism is
	'see-through' for the first MB, after that the actual data accessed
	via this sector depends on how the paging is set for the current
	task.  Some functions (e.g. dump) change the user DS:offset
	to refer to this segment.
DS386:	system data segment: e.g. debugger data
CS386:	system code segment: e.g. debugger code

Monitor (debugger) sources.  Not well documented, but very similar to
DOS DEBUG.  Put an INT 3 in your program to invoke it.  Note that @r and @w
have been added to inspect and change disk blocks; they overwrite the memory at
DS:1000.  Don't use if DS is currently the system data seg!!!! Or if you
plan to continue single stepping

Debugger commands:

@r #		; Read a disk block
@w #		; write a disk block
b-# 		;clear a breakpoint (# from 1 - 7)
b# addr 	;set a breakpoint
d addr, [addr]	; dump
e addr		; Examine address
g [addr],[addr1]; Run from address to address 1 ( sets special breakpoint 0)
p		; like DEBUG p, only runs calls though
q		; quit
r [reg]		; Show registers, modify registers
t		; Single step
u [addr]	; Dissassemble

David gclind01@ulkyvx.louisville.edu

