Sunday, January 16, 2022

Use procedure to swap two numbers.

INCLUDE C:\IRVINE\IRVINE32.INC

.386

.STACK 4096

EXITPROCESS PROTO,DWEXITCODE:DWORD

.DATA                                             

tmp dword ?

str1 BYTE "Enter  value of A here :  ",0

str2 BYTE "Enter value of b here :  ",0

str3 byte "after swaping value of A :",0

str4 byte "after swaping value of b :",0

a dword ?

b dword ?

.CODE

MAIN PROC

call swap

INVOKE EXITPROCESS,0

MAIN ENDP

swap proc

mov edx,offset str1

call WriteString

call ReadInt

mov a,eax

mov edx,offset str2

call WriteString

call ReadInt

mov b,eax

mov ecx,a

mov ebx,b

mov tmp,ecx

mov eax,0

mov eax,ebx

mov edx,offset str3

call WriteString

call WriteInt

mov eax,0

mov ebx,tmp

mov eax,ebx

call crlf

mov edx,offset str4

call WriteString

call WriteInt

 ret

swap endp

END MAIN 

No comments:

Post a Comment