News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Macro Problem

Started by raleeper, August 15, 2011, 07:29:46 PM

Previous topic - Next topic

raleeper

I am hoping someone will be able to throw some light on this situation:

I have a macro named ZRF that is designed to do the same thing as btr, and a call to it later in my code.  Assembly produces  error A2006: undefined symbol : ??004D.  Below is a listing of a call from a very similar macro expansion (I cannot get a listing for this program, testp), and below that the full declaration of the 2 macros used in the similar program.  I have attached the full code for both programs, but the larger is not very readable.  The ??004D is supposed to be flgof, which correctle evaluates to 2 and the ??004E which correctly evaluates to 3.  The ??00 expressions look like temporary placeholder, but that gets over my head.
Radix 16 is used.

[later] I forgot attach but have done so now.  Doesn't look like they're needed tho.

Thank you.


ZRF s,13
     1 LOCAL flgof,shift
     1 LOCAL flgof,shift
     1
     1 FLGVAR s,13
     2 IF 13 LT 8
     2 shift = 13
     2 flgof = 0
     2 ELSE
     2 IF 13 LT 10
     2 shift = 13-8
     2 flgof = 1
     2 ELSE
     2 IF 13 LT 17
= 00000003      2 shift = 13-10
= 00000002      2 flgof = 2
     2 ELSE
     2 shift = 13 -18
     2 flgof = 3
     2 ENDIF
     2 ENDIF
     2 ENDIF
     1 and BY [flgs+??004D], not 1 SHL ??004E

g:\lfw\lfw.asm(11914) : error A2006: undefined symbol : ??004D
ZRF(4): Macro Called From
g:\lfw\lfw.asm(11914): Main Line Code



FLGVAR MACRO f,bit ;Sets variables to define the flag operation
IF bit LT 8
shift = bit
flgof = 0
ELSE
IF bit LT 10
shift = bit-8
flgof = 1
ELSE
IF bit LT 17
shift = bit-10
flgof = 2
ELSE
shift = bit -18
flgof = 3
ENDIF
ENDIF
ENDIF
ENDM


ZRF MACRO f,bit ;Zero (reset) Flag
LOCAL flgof,shift

FLGVAR f,bit
and BY [flg&f+flgof], not 1 SHL shift
ENDM



jj2007

ZRF MACRO f,bit ;Zero (reset) Flag
LOCAL flgof,shift

FLGVAR f,bit
and BY [flg&f+flgof], not 1 SHL shift
ENDM

shift is a local var and undefined. Try not declaring it LOCAL (I see you set shift in FLGVAR).

qWord

macro local's are only valid in the macro which define them.
FLGVAR MACRO f,bit,shift,flgof ;Sets variables to define the flag operation
IF bit LT 8
shift = bit
flgof = 0
ELSE
IF bit LT 10
shift = bit-8
flgof = 1
ELSE
IF bit LT 17
shift = bit-10
flgof = 2
ELSE
shift = bit -18
flgof = 3
ENDIF
ENDIF
ENDIF
ENDM


ZRF MACRO f,bit ;Zero (reset) Flag
LOCAL flgof,shift

FLGVAR f,bit,shift,flgof
and BYTE ptr [flg&f+flgof], not (1 SHL shift)
ENDM
FPU in a trice: SmplMath
It's that simple!

raleeper

Quote from: jj2007 on August 15, 2011, 07:51:13 PM
[..]. Try not declaring it LOCAL (I see you set shift in FLGVAR).

Syntax error and block nesting error, whethe the locals are simply eliminated or introduced outside any macro by equates, {shift = 0).

raleeper

Thanks jj2007 and qWord.  Here's code that works (assembles w/o error. haven't tested.
I still don't understand why, in the listing posted earlier with a call to FLAVE\AR inside ZRF,  the assembler doesn't treat them the same and use the values just derived.  But don't worry about it, I doubt that there's an easy answer beyond what you've already said.  Anyway, you've solved my problem.  Thanks again,


ZRF     MACRO   f,bit ;Zero (clear) Flag
        LOCAL   flgof,shift
IF bit LT 8
shift = bit
flgof = 0
ELSE
IF bit LT 10
shift = bit-8
flgof = 1
ELSE
IF bit LT 17
shift = bit-10
flgof = 2
ELSE
shift = bit -18
flgof = 3
ENDIF
ENDIF
ENDIF
        and     BYTE Ptr [flg&f+flgof], NOT 1 SHL shift
        ENDM