| Sub.asm |
TITLE Subtraction (Sub.asm) Comment ! * Description: This program subtracts two 16-bit signed integers. * Insert a call DumpRegs statement to display the register values. ! INCLUDE Irvine32.inc .data x SWORD 5000h y SWORD 2000h z SWORD 1000h finalVal SWORD ? .code main PROC sub eax, eax ; clear eax sub ebx, ebx ; clear ebx sub ecx, ecx ; clear ecx mov ax, x ; load ax with 5000h mov bx, y ; load bx with 2000h mov cx, z ; load cx with 1000h sub ax, bx ; subtract 2000h sub ax, cx ; subtrack 1000h mov finalVal, ax ; store the result (2000h) call DumpRegs ; display the registers exit main ENDP END main |
| An Execution Example |
|
EAX=00002000 EBX=00002000 ECX=00001000 EDX=BFFC94C0 ESI=81A28644 EDI=00000000 EBP=0063FF78 ESP=0063FE3C EIP=0040103D EFL=00000206 CF=0 SF=0 ZF=0 OF=0can be useful when debugging programs because it lets you display a snapshot of the CPU state while the program is running.
|
Doctor: You’re overweight. Patient: I think I want a second opinion. Doctor: You’re also ugly. |