Answered step by step
Verified Expert Solution
Link Copied!

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: 5afafc EBX: 9db000 ECX: 5ebdec EDX: 5ebdec
ESI: 5ebdec EDI: 5ebdec EBP: 5afab0 ESP: 5afaa8
EIP: 763afa29 EFL: 246 CF=0 SF=0 ZF=1 OF=0 AF=0 PF=1
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, L1 ; Declare local variables for the macro
.data
flagStr BYTE " &flagName=",0 ; Define the string to display the flag name and value
flagVal BYTE ?,0 ; 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, '1' ; Assume the flag is set
shr eax, shiftCount ; Shift the specific flag bit to the least significant bit position
jc L1 ; Jump if the carry flag is set (meaning flag is set)
mov flagVal, '0' ; Correct the assumption, set the flag value to '0'
L1:
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: ",0, "EBX: ",0, "ECX: ",0, "EDX: ",0,
"ESI: ",0, "EDI: ",0, "EBP: ",0, "ESP: ",0, "EIP: ",0, "EFL: ",0. I also need to display eFlags. I have to output the values of each individual flag
ShowFlag CF,0 ; Display Carry Flag (CF)
ShowFlag SF,7 ; Display Sign Flag (SF)
ShowFlag ZF,6 ; Display Zero Flag (ZF)
ShowFlag OF,11 ; Display Overflow Flag (OF)
ShowFlag AF,4 ; Display Auxiliary Carry Flag (AF)
ShowFlag PF,2 ; 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

Students also viewed these Databases questions