| Sub.asm |
TITLE Subtraction (5000h - Y) (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
prompt1 BYTE 0Dh, 0Ah, "Calculate an Expresssion of 5000h - Y:"
BYTE 0Dh, 0Ah, "Enter the value of operand Y: ", 0
prompt2 BYTE 0Dh, 0Ah, "The result is ", 0
X SWORD 5000h
Y SWORD ?
finalVal SWORD ?
.code
main PROC
mov edx, OFFSET prompt1
call WriteString
call ReadInt
mov Y, ax ; Y: input
sub ebx, ebx ; clear ebx
mov ax, X ; load ax with 5000h
mov bx, Y ; load bx with the input
sub ax, bx ; ax = 5000h - Y
mov finalVal, ax ; store the result
mov edx, OFFSET prompt2
call WriteHex ; display the difference
call DumpRegs ; display the registers
exit
main ENDP
END main
|
| An Execution Example |
|
DumpRegs Procedure
|
Doctor: You’re overweight. Patient: I think I want a second opinion. Doctor: You’re also ugly. |