I I'm trying to create an application in real mode that uses the flags to store the results of calculations and other stuff. I'm trying to do this to take up less memory. So can someone please give me some example code or tell me how to do this. I hear it has something to do with eflags or something were they are stored. I already know how eflags is formatted but how do I get to it, and modify it?

Recommended Answers

All 6 Replies

You don't want to screw around with eflags like that -- you are misusing that flag. What you want to do is declare a variable to hold all the bit-mapped flags then you can set and clear the individual bits to your heart's content.

You don't want to screw around with eflags like that -- you are misusing that flag. What you want to do is declare a variable to hold all the bit-mapped flags then you can set and clear the individual bits to your heart's content.

Ok then how would I do that, like this?
pushf
pop ax
-Modify ax to what I want the flags to be.
push ax
popf

Lets assume all you need are 8 or fewer flags which can be store in one byte of data

flags db 0 ; allocate memory for the 8 flags

; set the 2d bit 
mov al,flags
or al,00000010h
mov flags,al

Lets assume all you need are 8 or fewer flags which can be store in one byte of data

flags db 0 ; allocate memory for the 8 flags

; set the 2d bit 
mov al,flags
or al,00000010h
mov flags,al

Ok, but how does that modify the real flags, that's only modifying your variable.

It doesn't. And you can't.

>>create an application in real mode that uses the flags to store the results of calculations and other stuff.
As I said before, that is a mis-use of the flags. Even if you could change them they won't stay that way very long because the flags are changed when certain operations are performed. The only flag I can think of that you can change yourself is the direction flag using cli instruction.

It doesn't. And you can't.

>>create an application in real mode that uses the flags to store the results of calculations and other stuff.
As I said before, that is a mis-use of the flags. Even if you could change them they won't stay that way very long because the flags are changed when certain operations are performed. The only flag I can think of that you can change yourself is the direction flag using cli instruction.

O ok thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.