Answered step by step
Verified Expert Solution
Question
1 Approved Answer
My code as is non functional but I need it to display all registers and flags. INCLUDE asmlib.inc . data registerNames BYTE EAX: ,
My code as is non functional but I need it to display all registers and flags. INCLUDE asmlib.inc
data
registerNames BYTE "EAX: "EBX: "ECX:", "EDX: "ESI: "EDI: "EBP: "ESP: "EIP: "EFL:
eflags DWORD
code
ShowFlag MACRO flagName, shiftCount
LOCAL flagStr, flagVal, L
data
flagStr BYTE &flagName
flagVal BYTE
code
push eax
push edx
mov eax, eflags
mov flagVal,
shr eax, shiftCount
jc L
mov flagVal,
L:
mov edx, OFFSET flagStr
call writeString
mov edx, OFFSET flagVal
call writeString
pop edx
pop eax
ENDM
Tab MACRO
push eax
mov alh
call writeChar
pop eax
ENDM
showRegister PROC regName:PTR BYTE, regValue:DWORD
pushad
mov edx, regName
call writeString
mov eax, regValue
call writeHex
Tab
popad
ret
showRegister ENDP
dumpRegisters PROC
pushad
pushfd
mov edx, OFFSET registerNames
mov ecx,
dumpLoop:
mov eax, esp ecx
invoke showRegister, edx, eax
add edx,
sub ecx,
jnz dumpLoop
pop eax
mov eflags, eax
push eax
invoke showRegister, edx, eax
ShowFlag CF
ShowFlag SF
ShowFlag ZF
ShowFlag OF
ShowFlag AF
ShowFlag PF
popfd
popad
ret
dumpRegisters ENDP
main PROC
call dumpRegisters
exit
main ENDP
END main I need this exact output: EAX: afafc EBX: db ECX: ebdec EDX: ebdec
ESI: ebdec EDI: ebdec EBP: afab ESP: afaa
EIP: afa EFL: CF SF ZF OF AF PF
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started