# MS-DOS debug

C:\> type CharColor.asm
segment DATA
        Asterisk db '*'
        Color    db 0f0h ; white background and black foreground
        Position dw 3280 ; 20x160b + 80*2b (line 20, col 40)

segment STACK stack
        resb 256
        StackPointer:

segment CODE
        ..start:

        mov ax, STACK
        mov ss, ax
        mov sp, StackPointer

        mov ax, DATA
        mov ds, ax
        mov ax, 0b800h
        mov es, ax
        mov al, [Asterisk]
        mov ah, [Color]
        mov bx, [Position]
        mov [es:bx], ax
        mov word [es:5*160+35*2], 00a41h

        mov ah, 4ch
        int 21h
C:\> nasm   CharColor.asm -f obj
C:\> alink  CharColor.obj -o CharColor.exe
C:\> dir /x CharColor.exe
C:\> debug  CHARCO~1.EXE
-?
assemble     A [dirección]
compare      C intervalo de direcciones
dump         D [intervalo]
enter        E dirección [lista]
fill         F lista de rango
go           G [=dirección] [direcciones]
hex          H valor1 valor2
input        I puerto
load         L [dirección] [unidad] [primer sector] [número]
move         M intervalo de direcciones
name         N [ruta] [lista de argumentos]
output       O byte de puerto
proceed      P [=dirección] [número]
quit         Q
register     R [registro]
search       S lista de rango
trace        T [=dirección] [valor]
unassemble   U [intervalo]
write        W [dirección] [unidad] [primer sector] [número]
allocate expanded memory        XA [N.páginas]
deallocate expanded memory      XD [identificador]
map expanded memory pages       XM [páginaL] [páginaP] [identificador]
display expanded memory status  XS
-

Unassemble

-u 0 29
158A:0000 B87A15        MOV     AX,157A
158A:0003 8ED0          MOV     SS,AX
158A:0005 BC0001        MOV     SP,0100
158A:0008 B87915        MOV     AX,1579
158A:000B 8ED8          MOV     DS,AX
158A:000D B800B8        MOV     AX,B800
158A:0010 8EC0          MOV     ES,AX
158A:0012 A00000        MOV     AL,[0000]
158A:0015 8A260100      MOV     AH,[0001]
158A:0019 8B1E0200      MOV     BX,[0002]
158A:001D 26            ES:
158A:001E 8907          MOV     [BX],AX
158A:0020 26            ES:
158A:0021 C7066603410A  MOV     WORD PTR [0366],0A41
158A:0027 B44C          MOV     AH,4C
158A:0029 CD21          INT     21

Dump

-d 1579:0
1579:0000  2A F0 D0 0C 00 00 00 00-00 00 00 00 00 00 00 00   *...............
1579:0010  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0030  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0040  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................

Register Status

-r
AX=0000  BX=FFFF  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1569  ES=1569  SS=157A  CS=158A  IP=0000   NV UP EI PL NZ NA PO NC
158A:0000 B87A15        MOV     AX,157A

Go and modify a register

-g 19
AX=F02A  BX=FFFF  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1579  ES=B800  SS=157A  CS=158A  IP=0019   NV UP EI PL NZ NA PO NC
158A:0019 8B1E0200      MOV     BX,[0002]                          DS:0002=0CD0
-r ax
AX F02A
:f041

Proceed next program instruction

-g 27
AX=F02A  BX=0CD0  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1579  ES=B800  SS=157A  CS=158A  IP=0027   NV UP EI PL NZ NA PO NC
158A:0027 B44C          MOV     AH,4C
-p
AX=4C2A  BX=0CD0  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1579  ES=B800  SS=157A  CS=158A  IP=0029   NV UP EI PL NZ NA PO NC
158A:0029 CD21          INT     21
-p

El programa ha terminado de forma normal

Trace next instruction

-g 27
AX=F02A  BX=0CD0  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1579  ES=B800  SS=157A  CS=158A  IP=0027   NV UP EI PL NZ NA PO NC
158A:0027 B44C          MOV     AH,4C
-t
AX=4C2A  BX=0CD0  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1579  ES=B800  SS=157A  CS=158A  IP=0029   NV UP EI PL NZ NA PO NC
158A:0029 CD21          INT     21
-t
AX=4C2A  BX=0CD0  CX=FF8B  DX=0000  SP=00FA  BP=0000  SI=0000  DI=0000
DS=1579  ES=B800  SS=157A  CS=00A7  IP=107C   NV UP DI PL NZ NA PO NC
00A7:107C 90            NOP

Enter (memory modification)

-g 0d
AX=1579  BX=FFFF  CX=FF8B  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000
DS=1579  ES=1569  SS=157A  CS=158A  IP=000D   NV UP EI PL NZ NA PO NC
158A:000D B800B8        MOV     AX,B800
-d ds:0
1579:0000  2A F0 D0 0C 00 00 00 00-00 00 00 00 00 00 00 00   *...............
1579:0010  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0030  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0040  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1579:0070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
-e ds:0 'A'
-e b800:0 'h' f0 'e' 0f 'l' f0 'l' 0f 'o' f0


Assemble new instructions (code modification)

-a 20
158A:0020 inc bx
158A:0021 inc bx
158A:0022 es:
158A:0023 mov [bx], ax
158A:0025 mov ah, 4c
158A:0027 int 21
158A:0029

No comments: