Chapter 3
Assembly Language Fundamentals
Assembly Language Programming Exercise
Problem # 1:
Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers.
Solution:
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.code
main PROC
mov eax, 3h
mov ebx, 8h
mov ecx, 1h
mov edx, 8h
add eax, ebx
add ecx, edx
sub eax, ecx
INVOKE ExitProcess,0
main ENDP
END main
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.code
main PROC
mov eax, 3h
mov ebx, 8h
mov ecx, 1h
mov edx, 8h
add eax, ebx
add ecx, edx
sub eax, ecx
INVOKE ExitProcess,0
main ENDP
END main
Let me know in the comment section if you have any question.
Previous Post:
Run your first program in Assembly Language using Visual Studio
Previous Post:
Run your first program in Assembly Language using Visual Studio