Brief tutorial on debug.exe

More information in Windows Help--debug.exe
Debug tutorial

Program starts at 100.

d 100 show memory from 100
u 100 unassemble from 100 r show registers
a 100 assemble. Paste a program. Right click command prompt window bar, Properties, Options, QuickEditMode so can right click to paste.
g execute the assembled program
t trace (step) an instruction
e 200 edit memory from this location onward.
fcs:100l100 clear 100 bytes starting at 100
n test1.com name of file
w write to file whose name specifed by n command. Number of bytes to write is in BX,CX registers (CX low)


INT examples

chars to screen:
MOV DL,41     ;'A'
MOV AH,02     ;write DL ASCII char to screen
INT 21
MOV DL,42     ;'B'
INT 21
INT 20        ;stop
string to screen:
MOV AH,09       ;the DOS interrupt routine for printing a string
MOV DX, 0200    ;this is where the string is located in memory
INT 21          ;call the interrupt
INT 20          ;terminate 


;edit memory to put bytes starting at 200:  end with $ (24h)
e 200
48 65 6C 6C 6F 2C 20 44 4F 53 20 68 65 72 65 2E 24 
clear screen:
mov ax,600    ;load registers with parameters to clear screen
mov cx,0
mov dx,184f
mov bh,07
int 10        ;video interrupt
int 20        ;terminate
get time of day, display to screen
;time to screen.  debug can't have blank lines...
mov ah,2c       ;time of day INT
int 21          ;CH hour (00 - 23), CL minutes (00 - 59),  DH seconds (00 - 59).
mov ah,0	;ensure AH is 0
mov al,ch	;hours to AL
mov dl,0a	;10 to DL.  can't DIV by immediate value
div dl          ;quotient AL: tens of hours =AX/10, remainder (ones of hours) to AH
mov ch,ah	;save remainder AH (ones of hours)
add al,30	;offset to ASCII digit char.
mov dl,al	;char param to display
mov ah,02	;write char to screen INT
int 21
add ch,30       ;offset one hours number to digit char
mov dl,ch
int 21          ;display it
mov dl,3a	; ':'
int 21
mov ah,0        ;ensure AH is 0
mov al,cl	;minutes to AL
mov dl,0a	;10 to DL.  can't DIV by immediate value
div dl          ;quotient AL: tens of minutes =AX/10, remainder (ones of minutes) to AH
mov ch,ah	;save remainder AH (ones of minutes)
add al,30	;offset to ASCII digit char.
mov dl,al	;char param to display
mov ah,02	;write char to screen INT
int 21
add ch,30       ;offset one minutes number to digit char
mov dl,ch
int 21          ;display it
int 20
clear screen, and more
MOV   AX,0600  ; AH 06 (scroll), AL 00 (full screen)
MOV   BH,30    ; Attribute: color setting 
MOV   CX,0000  ; upper left row:column
MOV   DX,184F  ; lower right row=24,column=79
INT   10       ; interrupt call to BIOS
INT   20
position cursor, wait for any key press
;set the cursor at a particular location on screen.
mov ax,600    ;load registers with parameters to clear screen
mov cx,0
mov dx,184f
mov bh,07
int 10        ;clear screen
MOV  DL,10   ; column 10
MOV  DH,5    ; row 5
MOV  BH,0    ; page 0  ??
MOV  AH,02  ;request set cursor
INT  10     
;wait for user to press any key before terminating use INT 16:
MOV   AH,10
INT   16
int 20
set pixels in graphics video mode

mov ah,0
mov al,12    ;set video mode 12=640x480, 80x25, 16 colors
int 10       ;   (Alt Enter back to window)
;in a text video mode only? 
;mov ah,09 ;write char and attribute
;mov al,41 ;'A'
;mov cx,10 ;repetitions
;mov bl,30 ;attribute??
;int 10
mov ah,0c   ;set pixel
mov al,01   ;0=black 1=blue 2=green...
mov cx,100  ;column 256
mov dx,100  ;row 256
int 10      ;at location 110
dec dx      ;decrease row
loop 110    ;loop decrementing row, col (DX,CX)
mov al,01   ;blue
mov cx,200  ;column 512
mov dx,100  ;row 256
int 10      ;location 11B
inc dx      ;increase row
loop 11b
;wait for user to press any key before terminating use INT 16:
MOV   AH,10
INT   16
int 20
concentric squares
MOV	AH,0
MOV	AL,12		;video mode 12.  640x480 graphics
INT	10
MOV	AH,0C		;set pixel
MOV	AL,01		;first color.   leave BH as 0!!!
MOV	DI,0A		;offset
MOV	CX,1E0		;480.  Top of squares loop
SUB	CX,DI		;480-offset  ending coord
MOV	[200],CX	;save to mem for reuse of DI 
MOV	CX,DI		;starting column
MOV	DX,DI		;starting row
MOV	[202],DI	;save offset 
MOV	DI,[200]	;restore 480-offset to DI
INT	10
INC	CX		;top line rightward
CMP	CX,DI		;until right side column
JL	0122
INT	10
INC	DX		;right line down
CMP	DX,DI		;until bottom row
JL	0129
MOV	DI,[202]	;restore offset to DI
INT	10
DEC	CX		;bottom row leftward
CMP	DI,CX		;until left side column
JL	0134
INT	10
DEC	DX		;left line upward
CMP	DI,DX		;until top row
JL	013B
INC	AL		;next color
ADD	DI,0A		;new offset, smaller inner square
CMP	DI,F0
JL	010D
;wait for any key press:
MOV	AH,10
INT	16
;reset to video mode 2: so can Alt Enter back to a window
MOV	AH,00
MOV	AL,02
INT 10
INT 20