Decompiling/Flags

From OpenDUNE

Jump to: navigation, search

Flags are set by most ALU commands (emu_add, emu_cmp, ...). emu_mov does not change any flags (not ever). Look in src/libemu/math.c to see what flags are changed exactly, but in general it is just what you expect. The flags:

* sf - Signed flag (is the value negative)
* zf - Zero flag (is the value zero)
* pf - Parity flag (0 if it contains odd amount of ones)
* cf - Carry flag
* af - Adjust flag
* of - Overflow flag

The last 3 are the most annoying ones, as it depends on the ALU how they are assigned a value. And even then it is not always well defined.

Conditional jumps base themselves on these flags.

* Below: if (cf)
* Below Equal: if (cf || zf)
* CX: if (cx == 0)
* Less: if (sf != of)
* Less Equal: (if (zf || (sf != of))
* Overflow: if (of)
* Parity: if (pf)
* Sign: if (sf)
* Zero: if (zf)

It is possible to set a few flags by hand. You do this with stN. You can clear it with clN. N can be a few of the above letters. You will know when you see one ;)

Personal tools