Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My EFL / eflags are not correct. Here is my code. How can I improve this to get them working? INCLUDE asmlib.inc . data EAXStr

My EFL/eflags are not correct. Here is my code. How can I improve this to get them working? INCLUDE asmlib.inc
.data
EAXStr BYTE "EAX: ",0
EBXStr BYTE "EBX: ",0
ECXStr BYTE "ECX: ",0
EDXStr BYTE "EDX: ",0
ESIStr BYTE "ESI: ",0
EDIStr BYTE "EDI: ",0
EBPStr BYTE "EBP: ",0
ESPStr BYTE "ESP: ",0
EIPStr BYTE "EIP: ",0
EFLStr BYTE "EFL: ",0
eflags DWORD ?
.code
ShowFlag MACRO flagName, shiftCount
LOCAL flagStr, flagVal, L1
.data
flagStr BYTE " &flagName=",0
flagVal BYTE ?,0
.code
push eax
push edx
mov eax, eflags
mov flagVal, '1'
shr eax, shiftCount
jc L1
mov flagVal, '0'
L1:
mov edx, OFFSET flagStr
call writeString
mov edx, OFFSET flagVal
call writeString
pop edx
pop eax
ENDM
Tab MACRO
push eax
mov al,09h
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
invoke showRegister, ADDR EAXStr, eax
invoke showRegister, ADDR EBXStr, ebx
invoke showRegister, ADDR ECXStr, ecx
invoke showRegister, ADDR EDXStr, edx
endl
invoke showRegister, ADDR ESIStr, esi
invoke showRegister, ADDR EDIStr, edi
invoke showRegister, ADDR EBPStr, ebp
mov eax, esp
add eax, 28h
invoke showRegister, ADDR ESPStr, eax
endl
mov eax, [esp +36]
invoke showRegister, ADDR EIPStr, eax
pop eax
mov eflags, eax
invoke showRegister, ADDR EFLStr, eax
ShowFlag CF,0
ShowFlag SF,7
ShowFlag ZF,6
ShowFlag OF,11
ShowFlag AF,4
ShowFlag PF,2
popad
ret
dumpRegisters ENDP
main PROC
pushfd
pop eflags
call dumpRegisters
exit
main ENDP
END main

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions