Friday, November 26, 2021

simple program read two numbers from user and calculate subtraction

 Include irvine32.inc

;AddTwo.asm-adds two 32-bit integer.

;chapter3 example

.386

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

.data 

msg1 byte "please enter 1st number:",0

msg2 byte "please enter 2nd number:",0

msg3 byte "subtraction is:",0

var1 dword ?

var2 dword ?

subt dword ?

.code

main proc

  mov edx,offset msg1

  call WriteString

  call ReadInt

  mov var1,eax

  call crlf

  mov edx,offset msg2

   call WriteString

   call ReadInt

   mov var2,eax

   mov eax,0

   mov eax,var1

   sub eax,var2

   mov subt,eax

    mov edx,offset msg3

   call WriteString

     call WriteInt

call dumpregs

  invoke ExitProcess,0

  main endp

  end main

No comments:

Post a Comment