Hey everyone, this is my first time writing a macro. In addition, I was away from fasm for about 3 months so it would be a good time to get some feedback. I'm wondering if you could think of a better way of doing this or critique mine... Thanks:
format ELF
section '.text' executable
public main
extrn printf
extrn scanf
macro check_flag msg, bit, subsequent
{
pushf
push msg
call printf
add esp, 4
pop eax ; get flags into eax
test ax, bit
jz subsequent
push set_m
call printf
add esp, 4
}
main:
pushf
push the_flags_m
call printf
add esp, 8
.cf_check:
check_flag carry_flag_m, 1h, .pf_check
.pf_check:
check_flag parity_flag_m, 4h, .af_check
.af_check:
check_flag aux_flag_m, 10h, .zf_check ; DEBYG: This check may be wrong
.zf_check:
check_flag zero_flag_m, 40h, .sf_check
.sf_check:
check_flag sign_flag_m, 80h, .df_check
.df_check:
check_flag direction_flag_m, 400h, .of_check
.of_check:
check_flag overflow_flag_m, 800h, .done
.done:
ret
section '.data' writeable
section '.rodata'
set_m db "SET",0xA, 0
notset_m db "not set", 0 ; NOT USED IN CURR VERSION
the_flags_m db "The flags are: %#08x", 0xA, 0
carry_flag_m db "The carry flag is: ", 0xA, 0
parity_flag_m db "The parity flag is: ", 0xA, 0
aux_flag_m db "The aux flag is: ", 0xA, 0
zero_flag_m db "The zero flag is: ", 0xA, 0
sign_flag_m db "Thaux flag is: ", 0xA, 0
overflow_flag_m db "The overflow flag is: ", 0xA, 0
direction_flag_m db "The direction flag is: ", 0xA, 0