Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Bugs and Fixes

Using flags

A community discussion post from the original code:zIRON forum.

0CodErr member
Posts
201
Threads
37
Location
Unknown

Using flags

repeat {
  break if (CF == true);
  break if (PF == true);
  break if (ZF == true);
  break if (SF == true);
  break if (OF == true);
}

Result:

00000000  750A              jnz 0xc
00000002  7508              jnz 0xc
00000004  7506              jnz 0xc
00000006  7504              jnz 0xc
00000008  7502              jnz 0xc
0000000A  EBF4              jmp short 0x0

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Fixed for next release.

0CodErr member
Posts
201
Threads
37
Location
Unknown

Maybe it would be useful to save flags by this way:

using flags {

}
function MyFunction() : sysword {
uses flags;
}

And it can be replaced with

pushf
//......
popf
Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK, I will add this.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

This is added for next release.

0CodErr member
Posts
201
Threads
37
Location
Unknown

In this case

if (SF == TRUE){};

used

00000000  7C00              jl 0x2

instead of

00000000  7800              js 0x2
0CodErr member
Posts
201
Threads
37
Location
Unknown

Also this must not be translated:

if (AF == TRUE){}
if (DF == TRUE){}
if (TF == TRUE){}

if (AF == FALSE){}
if (DF == FALSE){}
if (TF == FALSE){}

if (AF <> TRUE){}
if (DF <> TRUE){}
if (TF <> TRUE){}
       
if (AF <> FALSE){}
if (DF <> FALSE){}
if (TF <> FALSE){}

But currently result is

00000000  7400              jz 0x2
00000002  7400              jz 0x4
00000004  7400              jz 0x6
00000006  7500              jnz 0x8
00000008  7500              jnz 0xa
0000000A  7500              jnz 0xc
0000000C  7500              jnz 0xe
0000000E  7500              jnz 0x10
00000010  7500              jnz 0x12
00000012  7400              jz 0x14
00000014  7400              jz 0x16
00000016  7400              jz 0x18
0CodErr member
Posts
201
Threads
37
Location
Unknown

Currently

function test() {
uses flags;
}

produces

00000000  E800000000        call dword 0x5
00000005  55                push ebp
00000006  8BEC              mov ebp,esp
00000008  669C              pushfw
0000000A  669D              popfw
0000000C  8BE5              mov esp,ebp
0000000E  5D                pop ebp
0000000F  C3                ret

Is it possible to do 'pushfd\popfd' instead of 'pushfw\popfw'?

Also here

function test() {
  using flags{
  }
}

error occured

Unexpected ident flags in [using]