News:

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

Main Menu

relocatable labels

Started by markallyn, September 30, 2017, 01:29:13 AM

Previous topic - Next topic

markallyn

Hello everyone,

I admit to being pretty bad with masm64, but I'm trying.  Anyway, the following silly program is throwing errors from ml.exe that I don't understand.  Here it is:
Quoteinclude \masm32\include64\masm64rt.inc

printf PROTO :QWORD, VARARG

.data
   frmt1 BYTE "%s",0
   msg1  BYTE "rax is not 0",0
        msg2  BYTE "rax is equal to 0",0

.code
main   PROC

   mov   rax, 100
IF   rax   GT 0
   invoke printf, ADDR frmt1, ADDR msg1
ELSE   invoke printf, ADDR frmt1, ADDR msg2
ENDIF
   ret
main   ENDP
END

The IF statement causes this error:  "error a2095: constant or relocatable label expected"
The ELSE statement causes this error: "error a2008:syntax error: invoke printf, addr frmt1, addr msg2"

I'm particularly puzzled by the reference to "relocatable label".   Maybe "rax" is not relocatable, but what would be? How would I make one?  But, I also don't see what's wrong with the invoke call.

BTW, perhaps this post belongs more on The Campus forum.  If  so, my apologies



hutch--

Mark,

The notation IF ELSEIF ENDIF are not for dynamic code, they are conditions assembly directives. You can use the macros for .if .elseif .endif but note that the comparison operators are different. They work OK but are not altogether intuitive as 64 bit MASM does not allow some characters to be used. The reference is at the beginning of the file "vasily.inc" in the "macros64" directory.


comment * Comparison run-time operators

     Operator      Meaning

     ==             Equal
     {}             Not equal
     }              Greater than
     }=             Greater than or equal to
     {              Less than
     {=             Less than or equal to
     &              Bit test (format: expression & bitnumber)
     ~              Logical NOT
     |              Bit test
     &&             Logical AND
     ||             Logical OR

     CARRY?         Carry bit set
     OVERFLOW?      Overflow bit set
     PARITY?        Parity bit set
     SIGN?          Sign bit set
     ZERO?          Zero bit set
     CARRY?|ZERO?    ìåíüíå èëè ðàâíî
     ~(CARRY?|ZERO?)    áîëüøå
     äëÿ ñðàâíåíèÿ ÷èñåë ñî çíàêîì
     ~ZERO?&(SIGN?==OVERFLOW?)    áîëüøå(greate than)
     SIGN?==OVERFLOW?        áîëüøå èëè ðàâíî(greate than or equal)
     SIGN?{}OVERFLOW?        ìåíüøå(less than)
     ZERO?|(SIGN?{}OVERFLOW?)        ìåíüøå èëè ðàâíî(less than or equal)
*

markallyn

Hutch,

Thanks, that was very helpful.  I changed IF/ELSE/ENDIF to .if/.else/.endif.  It sort of worked, but the .else line kicked out a
warning from the assembler: "too many arguments in macro call".  After looking at the corresponding macro in Vasily.inc I realized I could get rid of the warning by putting the invoke statement on its own line below the .else stateemt.

Did I put this thread on the wrong Forum?

Mark

hutch--

> Did I put this thread on the wrong Forum?

Nah, this is fine.

"invoke" is a macro wrapper that calls the procedure call main macro. It should always be on its own line and not follow a label.