Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Notice the use of the tab macro?
On the surface this seems like an easy chore for the most part but you need to be careful how you save and restore the registers. Remember these registers should match what is shown in the registers window of the debugger.
Review Debugger
If you need a review of the debugger and some information on flags and registers you should take a look at the review on this page.
Some Hopefully Helpful Things
You should have your dumpRegisters procedure call a procedure called showRegister. You want to pass the name of the register along with the value of the register to be displayed. I found that it was probably best to use invoke for this. My prototype looks like this:
showRegister PROTO,
regName:PTR BYTE regValue:DWORD
Displaying each value of the flags register is probably the most difficult thing here. Because it is I am going to provide a macro that you can use to make the chore easier:
ShowFlag MACRO flagName,shiftCount
LOCAL flagStr, flagVal, L
data
flagStr BYTE" &flagName
flagVal BYTE?,
code
push eax
push edx
mov eax,eflags ; retrieve the flags
mov flagVal,
shr eax,shiftCount ; shift into carry flag
jc L
mov flagVal,
L:
mov edx,OFFSET flagStr ; display flag name and value
call WriteString
pop edx
pop eax
ENDM
To use this you can simply call showFlag, the flag to show and its bit position. You also need to define eflags which is a DWORD variable and should be located in the data segment of main. Here is an example call
ShowFlag CF
This shows the carry flag at bit This code needs to be less redundanr so i can not use invoke that many times. There should be a loop in dumpRegisters PROC. The flags are also not being correctly set up and displayed
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