Miscellaneous > Irvine Book Questions.

A2094: Operand Must be Relocatable?

(1/3) > >>

TheGodOfKratos:
I'm getting the error in Visual Studio 2017 listed in my subject. It's A2094:operand must be relocatable. The macro works when I pass constant integers but when I pass variable identifiers I get the assembler error message. It has something to do with passing variables. Can someone see what's wrong with the code?

https://pastebin.com/CPSe1xmq

aw27:
Instead of if - endif try .if - .endif  :idea:

TheGodOfKratos:
Your suggestion is for run-time if/else checks I believe. The IF ENDIF directives are preprocessor instructions that determine what ends up in the run-time instructions.

aw27:

--- Quote from: TheGodOfKratos on April 15, 2017, 02:49:03 PM ---Your suggestion is for run-time if/else checks I believe. The IF ENDIF directives are preprocessor instructions that determine what ends up in the run-time instructions.

--- End quote ---

They serve different purposes.
At compile time it is not possible to decide a run-time decision.
This is a compile time decision:

WHATTODO EQU -1

mLocate MACRO   xval, yval
    IF WHATTODO LT 0
     mov ax, xval
        EXITM   
    ELSEIF  WHATTODO GT 0 
     mov cx, yval
        EXITM
    ENDIF
ENDM

 

jj2007:

--- Quote from: TheGodOfKratos on April 15, 2017, 02:49:03 PM ---Your suggestion is for run-time if/else checks I believe. The IF ENDIF directives are preprocessor instructions that determine what ends up in the run-time instructions.
--- End quote ---

Yes indeed. But how can the assembler know what is at runtime in xval? That's possible only if xval is an immediate constant.


--- Code: ---mLocate MACRO xval, yval
IF xval LT 0
EXITM ;; xval < 0?
ENDIF
IF yval LT 0 ;; yval < 0?
EXITM ;; if so, exit
ENDIF

mov bx,0 ;; video page 0
mov ah,2 ;; locate cursor
mov dh,yval
mov dl,xval
int 10h ;; call the BIOS
ENDM
--- End code ---

Btw it's better if you post your code here, as shown above. Not everybody is willing to open external pages, too much clicking is not good for your health.

Navigation

[0] Message Index

[#] Next page

Go to full version