Question: Can you make this answer into a asm code please. Your Task Now that you have seen the video, you should use what you have

Can you make this answer into a asm code please. Your Task
Now that you have seen the video, you should use what you have seen to create the following procedure:
swapValues
This procedure should take the address of two DWORD variables and swap the values around. You must push the address of the two variables on the stack and use call to call the swapValues procedure.
In main, create some code to test your functionality. You should enter two DWORD values and pass their address to the swapValues procedure through the stack. When the procedure returns, you should output the swapped values. Please note that this is more than simply printing the values out in the opposite order in which they were input. The values in the variables should be swapped.
In the swapValues procedure, if you use any registers, I expect you to restore them just before the procedure returns. It should also be noted that you must use indirect addressing to accomplish the task because you are dealing with addresses.
Sample Run
Enter a number
5
Enter a number
8
Your numbers swapped are
8
5
NOTE:
You are not to use any .IF .ELSE, .WHILE, or .ENDW instructions.
Do not use INVOKE for your procedures. You should push values onto the stack and reference them using the stack base. This means you should use call. Your procedures should also have a prologue.
The use of legacy directives like DB and DW is not allowed in this class. A deduction of 40% will be given if you use them.
The use of indirect addressing around variables is NOT allowed in the class unless you are using indirect addressing. An example of this would be [val1]. Doing this will result in a 25% reduction in your grade.
Also, note that you must use standard calling conventions to clean up the stack.
You must comment every line of code you write or your grade will be reduced by 20%
Make sure to use writeInt, readInt, writeLine, and writeString.
This is what I got so far.
INCLUDE asmlib.inc
.data
prompt BYTE "Enter a number: ",0
outP BYTE "Your numbers swapped are: ",0
var1 DWORD ?
var2 DWORD ?
.code
main PROC
; Prompt for the first number
mov edx, OFFSET prompt
call writeLine
call readInt
mov var1, eax
; Prompt for the second number
mov edx, OFFSET prompt
call writeLine
call readInt
mov var2, eax
; Swapping the values of var1 and var2 using XOR
mov eax, var1
xor eax, var2
mov var1, eax
mov eax, var2
xor eax, var1
mov var2, eax
mov eax, var1
xor eax, var2
mov var1, eax
; Output the swapped values
mov edx, OFFSET outP
call writeString
mov eax, var1
call writeInt
mov eax, var2
call writeInt
exit
main ENDP
END main
Can you improve this please?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!