Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Prompt: You are to create a procedure called dumpRegisters that will dump the contents of each register to the screen. This includes the flags register
Prompt: You are to create a procedure called dumpRegisters that will dump the contents of each register to the screen. This includes the flags register and each independent flag. The output of your dumpRegisters procedure should look like this:
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
i have a ShowFlag MACRO that must be used and NOT modified. ShowFlag MACRO flagName, shiftCount ; Macro to display a specific flag and its value
LOCAL flagStr, flagVal, L ; Declare local variables for the macro
data
flagStr BYTE &flagName ; Define the string to display the flag name and value
flagVal BYTE ; Initialize flag value
code
push eax ; Save EAX register on stack to preserve its value
push edx ; Save EDX register on stack to preserve its value
mov eax, eflags ; Load the value of EFLAGS into EAX
mov flagVal, ; Assume the flag is set
shr eax, shiftCount ; Shift the specific flag bit to the least significant bit position
jc L ; Jump if the carry flag is set meaning flag is set
mov flagVal, ; Correct the assumption, set the flag value to
L:
mov edx, OFFSET flagStr ; Load the address of the flag string into EDX
call writeString ; Output the flag name and equal sign
pop edx ; Restore the original value of EDX
pop eax ; Restore the original value of EAX
ENDM ; End of ShowFlag macro
Additionally, I need a showRegister PROC regName: PTR BYTE, regValue: DWORD.
Furthermore, i need a dumpRegisters PROC that output all the values registerNames BYTE "EAX: "EBX: "ECX: "EDX:
"ESI: "EDI: "EBP: "ESP: "EIP: "EFL: I also need to display eFlags. I have to output the values of each individual flag
ShowFlag CF ; Display Carry Flag CF
ShowFlag SF ; Display Sign Flag SF
ShowFlag ZF ; Display Zero Flag ZF
ShowFlag OF ; Display Overflow Flag OF
ShowFlag AF ; Display Auxiliary Carry Flag AF
ShowFlag PF ; Display Parity Flag PF
the dumpRegisters procedure must be called in main PROC. it is of vital importance that registers are pushed and popped correctly. THERE MUST ALSO BE A LOOP USED IN DUMPREGISTERS TO AVOID REDUNDANCY.
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