Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ AddTwo Program (Use the AddTwo Program (from page 63 (3.2 Example: Adding an

ID: 3593143 • Letter: C

Question

C++ AddTwo Program

(Use the AddTwo Program (from page 63 (3.2 Example: Adding and Subtracting Integers)) to do the following:

Change the program so it can subtract two numbers instead of adding.

Submit the .asm file.

Submit the screen shot of the output. (use snipping tool to take a screen shot)

PLEASE COPY AND PASTE CODE FOR ANSWER

Assembly Language for x86 Processors (7th Edition)

(Let’s revisit the AddTwo program we showed at the beginning of this chapter and add the necessary
declarations to make it a fully operational program. Remember, the line numbers are not
really part of the program:
1: ; AddTwo.asm - adds two 32-bit integers
2: ; Chapter 3 example
3:
4: .386
5: .model flat,stdcall
6: .stack 4096
7: ExitProcess PROTO, dwExitCode:DWORD
8:
9: .code
10: main PROC
11: mov eax,5 ; move 5 to the eax register
12: add eax,6 ; add 6 to the eax register
13:
14: INVOKE ExitProcess,0
15: main ENDP
16: END main

Explanation / Answer

Souce code:

; AddTwo.asm - adds two 32-bit integers
; Chapter 3 example
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.code
main PROC
mov eax,6 ; move 6 to the eax register
sub eax,1 ; sub 1 from the eax register
INVOKE ExitProcess,0
main ENDP
END main