I need to create a program in Assembly code that would do the following: RVAL =
ID: 3730066 • Letter: I
Question
I need to create a program in Assembly code that would do the following:
RVAL = (XVAL - YVAL) - (ZVAL + 3 + XVAL) - 10 - ZVAL
Since they are memories, we cant subtract them. Figure another way out.
Have to use Call DumpRegs & Call DumpMem.
------Template to use:---------
TITLE
; Insert comment of what program will do here
INCLUDE Irvine32.inc
.data ; enter DATA below
.code ; enter CODE below
main PROC
CALL DumpRegs ; Dumps registry
CALL DumpMem ; Dumps in hexadecimal
exit
main ENDP
END main
-----------------------------------
Explanation / Answer
TITLE Addition and Subtraction ; program to evaluate RVAL = (XVAL - YVAL)-(ZVAL + 3 + XVAL)-10-ZVAL
INCLUDE c:IrvineIrvineIrvine32.inc
.data
RVAL SDWORD ? ; declare 32-bit signed double word
XVAL SDWORD 50 ; declare 32-bit signed double-word and initialize with 50
YVAL SDWORD 60 ; declare 32-bit signed double-word and initialize with 60
ZVAL SDWORD 70 ; declare 32-bit signed double-word and initialize with 70
.code
main PROC
MOV EAX, XVAL ; EAX = XVAL
SUB EAX, YVAL ; EAX = XVAL - YVAL
MOV EDX, ZVAL ; EDX = ZVAL
ADD EDX, 3 ; EDX = ZVAL + 3
ADD EDX, XVAL ; EDX = ZVAL + 3 + XVAL
SUB EDX, 10 ; EDX = (ZVAL + 3 + XVAL) - 10
SUB EDX, ZVAL ; EDX = (ZVAL + 3 + XVAL) - 10 - ZVAL
SUB EAX, EDX ; EAX = (XVAL - YVAL) - (ZVAL + 3 + XVAL) - 10 - ZVAL
MOV RVAL, EAX ; RVAL = (XVAL - YVAL) - (ZVAL + 3 + XVAL) - 10 - ZVAL given expression
CALL DumpRegs ; Dumps registery
MOV ESI, OFFSET RVAL ; Address RVAL is the start of memory to print
MOV EBX, SIZEOF RVAL ; EBX = 4
MOV ECX, 4 ; Prints 4 32-bit SDWORDS
CALL DumpMem ; Dumps in hexadecimal
exit
main ENDP
END main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.