DEBUG SESSION WITH ADDSIMPL.EXE (my comments preceded by ";") C:\220\pgms>debug addsimpl.exe ;start DEBUG, load in addsimpl.exe program -u0 ;unassemble starting at instruction stored at address offset 0 in code segment 3B92:0000 1E PUSH DS ;These... 3B92:0001 2BC0 SUB AX,AX ;are... 3B92:0003 50 PUSH AX ;DOS... 3B92:0004 B8913B MOV AX,3B91 ;bookkeeping... 3B92:0007 8ED8 MOV DS,AX ;instructions. 3B92:0009 A00000 MOV AL,[0000] ;***Program really starts here*** 3B92:000C 02060100 ADD AL,[0001] 3B92:0010 A20200 MOV [0002],AL 3B92:0013 CB RETF ;***Program ends here*** 3B92:0014 BE2B8B MOV SI,8B2B 3B92:0017 16 PUSH SS 3B92:0018 C0 DB C0 3B92:0019 2B8E46F6 SUB CX,[BP+F646] 3B92:001D 26 ES: 3B92:001E 894406 MOV [SI+06],AX -g=0,9 ;go (execute) starting at code segment address 0 and stopping at address 9 ;i.e., execute the first 5 instructions and show the registers AX=3B83 BX=0000 CX=0044 DX=0000 SP=001C BP=0000 SI=0000 DI=0000 DS=3B83 ES=3B71 SS=3B81 CS=3B84 IP=0009 NV UP EI PL ZR NA PE NC 3B84:0009 A00000 MOV AL,[0000] DS:0000=04 -d0 ;dump 128 bytes of the data segment starting at address offset 0 ;display shows 8 rows of 16 bytes each... ;address (DS:offset form) on left... ;contents in hex in middle, corresponding character codes on right 3B83:0000 04 07 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3B83:0010 1E 2B C0 50 B8 83 3B 8E-D8 A0 00 00 02 06 01 00 .+.P..;......... 3B83:0020 A2 02 00 CB 75 03 E9 EC-00 B8 E5 00 50 B8 E0 00 ....u.......P... 3B83:0030 50 A0 32 65 50 B8 FF FF-50 E8 EA F7 8B F0 89 56 P.2eP...P......V 3B83:0040 F6 80 3E DB 38 00 74 09-A1 E4 02 8E C2 26 89 44 ..>.8.t......&.D 3B83:0050 1A 8E C2 26 8B 44 0E A3-C4 2B 26 8A 44 10 A2 C2 ...&.D...+&.D... 3B83:0060 2B 26 8B 44 06 26 8B 54-08 A3 BA 2B 89 16 BC 2B +&.D.&.T...+...+ 3B83:0070 C7 06 C6 2B 00 00 80 3E-6E 63 00 74 13 C7 06 BE ...+...>nc.t.... -t ;trace the next instruction, pause and show registers AX=3B04 BX=0000 CX=0044 DX=0000 SP=001C BP=0000 SI=0000 DI=0000 DS=3B83 ES=3B71 SS=3B81 CS=3B84 IP=000C NV UP EI PL ZR NA PE NC 3B84:000C 02060100 ADD AL,[0001] DS:0001=07 -t ;trace next instruction AX=3B0B BX=0000 CX=0044 DX=0000 SP=001C BP=0000 SI=0000 DI=0000 DS=3B83 ES=3B71 SS=3B81 CS=3B84 IP=0010 NV UP EI PL NZ NA PO NC 3B84:0010 A20200 MOV [0002],AL DS:0002=00 -t ;trace next instruction AX=3B0B BX=0000 CX=0044 DX=0000 SP=001C BP=0000 SI=0000 DI=0000 DS=3B83 ES=3B71 SS=3B81 CS=3B84 IP=0013 NV UP EI PL NZ NA PO NC 3B84:0013 CB RETF -d0,2 ;dump data segment from offset 0 to offset 2 (first 3 bytes) 3B83:0000 04 07 0B ... -e0 ;enter new data starting at offset 0, (separate by spaces) 3B83:0000 04.08 07.09 -d0,2 ;dump first 3 bytes to see new data 3B83:0000 08 09 0B ... -rip ;show and update instruction pointer register with a 9 ;i.e., prepare to execute starting with instruction stored at address 9 ;so as not to execute the bookkeeping instructions again IP 0013 :9 -g13 ;go (execute) until address 13, i.e., until the RETF instruction AX=3B11 BX=0000 CX=0044 DX=0000 SP=001C BP=0000 SI=0000 DI=0000 DS=3B83 ES=3B71 SS=3B81 CS=3B84 IP=0013 NV UP EI PL NZ AC PE NC 3B84:0013 CB RETF -d0,2 ;dump first three bytes of data segment--note new result 3B83:0000 08 09 11 ... -a0c ;assemble a new instruction starting at code segment address 000C ;we're replacing the ADD instruction with a SUB instruction ;hit <ENTER> twice to get out of this "assemble" mode 3B84:000C sub al,[0001] 3B84:0010 -u0,13 ;unassemble between code segment addresses 0 and 13 ;i.e., look at modified program with new instruction 3B84:0000 1E PUSH DS 3B84:0001 2BC0 SUB AX,AX 3B84:0003 50 PUSH AX 3B84:0004 B8833B MOV AX,3B83 3B84:0007 8ED8 MOV DS,AX 3B84:0009 A00000 MOV AL,[0000] 3B84:000C 2A060100 SUB AL,[0001] 3B84:0010 A20200 MOV [0002],AL 3B84:0013 CB RETF -g=9,13 ;execute program from address 9, breaking at address 13 ;i.e., from first non bookkeeping instruction to RETF instruction AX=3BFF BX=0000 CX=0044 DX=0000 SP=001C BP=0000 SI=0000 DI=0000 DS=3B83 ES=3B71 SS=3B81 CS=3B84 IP=0013 NV UP EI NG NZ AC PE CY 3B84:0013 CB RETF -d0,2 ;dump first 3 bytes of data segment, note result (FF=-1, 2's complement) 3B83:0000 08 09 FF ... -g ;execute to end of program, RETF causes display of termination message Program terminated normally -q ;quit DEBUG C:\220\pgms>