In: Computer Science
Assembly language - please post with output
Question:
Using the AddTwo program from class lecture 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.
Program:
INCLUDE Irvine32.inc
.386
.stack 10
.data
A byte
12
; declaration and initialization of the variables
B byte 6
C byte 2
D byte 7
.code
; code part
main
PROC
; begin of main
mov
eax,00000000
; replace the eax register with all zeroes
mov
al,C
; move the value of C to al
add
D
; performing (C + D)
call
dumpregs
; printing the values of the registers
mov ebx,
0
; replace the ebx register with all zeroes
mov
bl,A
; move the value of A to al register
add
bl,B
; performing (A + B)
call
dumpregs
; printing the values of the registers
mov
ecx,00000000
; replace the ecx register value with all zeroes
mov
cl,bl
; move the value of (A+B) to cl
sub
cl,al
; perform content of (cl) - (C + D) and store the result in cl
register
call
dumpregs
; printing the values of the registers
main
endp
; end of main
end main
Hope this helps.