A Sample Program (ReadSub.asm)


The following program reads and subtracts 32-bit hexadecimal integer from a value 50000h.

ReadSub.asm

 TITLE Read and Subtract (ReadSub.asm)

 ; This program reads and subtracts 32-bit hexadecimal integer from 50000h.

 INCLUDE Irvine32.inc

 .data
 prompt1  BYTE   0Dh, 0Ah, "Calculate an Arithmetic Expression of 50000h - Y:",
                 0Dh, 0Ah, 0
 prompt2  BYTE   "Enter the value of operand Y:   ", 0
 prompt3  BYTE   0Dh, 0Ah, "The result is  ", 0 

 X        DWORD  50000h
 Y        DWORD  ?
 result   DWORD  ?

 .code
 main PROC

	mov    edx, OFFSET prompt1
	call   WriteString              ; print prompt1
	mov    edx, OFFSET prompt2
	call   WriteString              ; print prompt2

	call   ReadHex
        mov    Y, eax                   ; read Y
    
        mov    eax, X
                  ; calculate 50000h – Y
        mov    result, eax

        mov    edx, OFFSET prompt3
	call   WriteString              ; print prompt3
        mov    eax, result
        call   WriteHex                 ; write result

        exit
 main ENDP
 END  main
                       

An Execution Example
 C:\250\lab\Debug> Project

 Calculate an Arithmetic Expression of 50000h – Y:
 Enter the value of operand Y:    4000

 The result is  0004C000