Initialize a variable for a BYTE, WORD, DWORD storage size each with any desired value in the data segment. Initialize another variable called Result with the size of a DWORD and make the value as an uninitialized value.
In the code segment, create a label called L1 that moves the variables in the appropriate sized register and making sure NOT to overwrite them in the process.
After, create another label L2 that adds all these values together and at the end of your program make sure your ECX register contains the final value.
Call the DUMPREGS instruction to display your register values and move the final result into the Result variable.
;Assume I have the following data segment written:
.data
val1 BYTE 10h
val2 WORD 8000h
val3 DWORD 0FFFFFh
val4 WORD 7FFFh
;1. Write an instruction that increments val2.
;2. Write an instruction that subtracts val3 from EAX.
;3. Write instructions that subtract val4 from val2.
.code
;Write your instructions here
This is what I have so far and need to build off this:
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
INCLUDE Irvine32.inc
.data
mov eax, 0
mov ebx, 0
mov ecx, 0
mov edx, 0
val1 byte 10h
val2 word 2000h
val3 dword 30000000h
result dword ????
.code
main PROC
MOV EAX, 10
ADD EAX, 50
call DumpRegs ;Check registers via output
invoke ExitProcess,0
main ENDP
end main
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
INCLUDE Irvine32.inc
.data
MOV EAX, 0
MOV EBX, 0
MOV ECX, 0
MOV EDX, 0
val1 BYTE 10h
val2 WORD 8000h
val3 DWORD 0FFFFh
val4 DWORD 7FFFFh
result DWORD FFFFFh
.code
main PROC
MOV EAX, 10
L1:
INC val2 // Incrementing val2
SUB EAX,val3 //Subtracting val3 from EAX and storing it in
EAX
MOV EBX,val4
SUB val2,EBX // No registers are over-written at the end of
L1
MOV EDX,val2 // Subtracting val4 from val2 and the result is moved
into EDX register
L2:
ADD EDX,EAX
ADD EDX,EBX // Adding all the values
MOV ECX,EDX // At the end of L2 the result is being moved to ECX
register
call DumpRegs ;Check registers via output
MOV result,ECX // Moving the final result from ECX register to the
result variable
invoke ExitProcess,0
main ENDP
end main
Get Answers For Free
Most questions answered within 1 hours.