Could you tell me why I received the message program "has encountered a problem and needs to close" if my program source code is:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; Build this with the "Project" menu using
; "Console Assemble and Link"
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\masm32rt.inc
.data
.data?
a dd ? ; Uninitialised single 32 bit space
b dd ? ; Uninitialised single 32 bit space
.code ; Tell MASM where the code starts
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start: ; The CODE entry point to the program
pushfd
pop eax
push eax
push eax
print chr$("EFLAGS register value: ")
pop eax
print ustr$(eax),13,10
pop eax
mov eax, 04321h
push eax
popfd
inkey
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start ; Tell MASM where the program ends
But if I change 04321h to some other value, e.g. 0247h, the program runs smoothly.
Quote; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; Build this with the "Project" menu using
; "Console Assemble and Link"
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\masm32rt.inc
.data
.data?
a dd ? ; Uninitialised single 32 bit space
b dd ? ; Uninitialised single 32 bit space
.code ; Tell MASM where the code starts
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start: ; The CODE entry point to the program
pushfd
pop eax
push eax
push eax
print chr$("EFLAGS register value: ")
pop eax
print ustr$(eax),13,10
pop eax
mov eax, 0247h
push eax
popfd
inkey
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start ; Tell MASM where the program ends
without looking at the specific bits you are flipping.....
some of the flag bits are rather sensitive - some require ring 0 privileges to modify
good practice to copy the current flags register into EAX, modify the bit(s) you want, then store it back
pushfd
pop eax
or eax,set_some_bits
and eax,clear_some_bits
push eax
popfd
(http://www.masm32.com/board/index.php?action=dlattach;topic=17817.0;id=9978)
for most of the math flags, LAHF and SAHF will work, which avoids all the dangerous bits :P