Could you tell me why this simple code reports error: "expression is not simple or relocatable"? And how to fix that?
;----
; a.asm
extern a1 ; external label
b1:
b2 dd (b1 - a1) ; ===> this causes the bug
;---
I compiled it with command: "nasm -f elf a.asm"
Many thanks
J
;----
; a.asm
extern a1 ; external label
b1:
b2 dd (b1 - a1) ; ===> this causes the bug
;---
I compiled it with command: "nasm -f elf a.asm"
Many thanks
J
The macro engine in masm won't perform math apon data variables, only with constants.
Does the external label describe defined data, or a constant?
Does the external label describe defined data, or a constant?
The macro engine in masm won't perform math apon data variables, only with constants.
Actually I use NASM, not masm.
Does the external label describe defined data, or a constant?
The label is code, not data.
Do you have any idea how to fix it?
Thanks.
The label is code, not data.
Do you have any idea how to fix it?
Thanks.
Yeah, do your calculations at run time, since an external label/address has no definite numerical constant until link/run time.
The label is code, not data.
Do you have any idea how to fix it?
Thanks.
Yeah, do your calculations at run time, since an external label/address has no definite numerical constant until link/run time.
Can I asks nasm to delay to assign the value until link time? And is it possible to ask linker to do that instead of compiler?
Thanks,
J
;----
; a.asm
extern a1 ; external label
b1:
b2 dd 0
; Somewhere in your code section
mov eax, b1 ; EAX = B1
sub eax, a1 ; EAX = EAX - A1
mov b2, eax ; B2 = EAX
;---
Can I asks nasm to delay to assign the value until link time? And is it possible to ask linker to do that instead of compiler?
That depends on whether or not the ELF format supports more than simple address relocation.
If it doesn't, there's no way for the assembler to delay it.