News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Macro weird behaviour?

Started by BolterVi, May 13, 2016, 06:15:47 AM

Previous topic - Next topic

BolterVi

Hello!
Well I've created a macro which should help to make it easier to set flags.

I have the Constants:

FLAG_C, FLAG_Z, FLAG_S, FLAG_O


and the macro

setflags macro _flags:VARARG
for flag, <_flags>
set&flag FLAG_&flag
endm
endm


and I'm calling it like this:
setflags C, Z, S, O

This should output something like this:

setc FLAG_C
setz FLAG_Z
sets FLAG_S
seto FLAG_O


but whenever i use the C for carry in the macro it translates it to this:

setb FLAG_B

which is clearly not what I want.
Does someone of you may know the reason why this is happening? and how i could fix this?
Sure i could replace the set&flag line with If-Conditions and comparing which flag i want to set and
such but i thought the current version is cooler.

Regards,
BolterVi

sinsi

setc is an ASM instuction. I would have expected an error from ML.
🍺🍺🍺

qWord

(setc: set if carry) ≡ (setb: set if below)
MREAL macros - when you need floating point arithmetic while assembling!

BolterVi

Oh this makes sense if they are equivalent!
Sorry somehow I was thinking that setb was for setting a bit but that was another instruction.
(Also I've reanalyzed my program and It's not setting the FLAG_B actually but the FLAG_C which is correct.. I was confused with the offsets since the 7th flag is actually FLAG_B and
debugging my application it said

setb byte ptr ds:[0x403007]

The weather makes me confused!)
Thanks for the help! :)