NASM Forum > Programming with NASM

Error when using "istruc"

(1/3) > >>

Serge:
Trying to use "istruc" inside macro I created the following code:


--- Code: ---struc str
  .byte: resb 1
endstruc

%macro istr 0
istruc str
  at .byte, db 0
iend
%endmacro

label: istr
--- End code ---

NASM reports the following error:


--- Code: ---Test.asm:11: error: non-constant argument supplied to TIMES.
--- End code ---

What's wrong? How to use istruc inside macro?
Without "label" it compiles OK. But I need that label.

Frank Kotler:
Weird, I thought, that "label:" should make a difference. What's happening, I think, is that the existance of a label breaks the "local label mechanism" for ".byte". If the member name in your struc is unique, rather than a "local label", it works. If we use the full name "str.byte" in the istruc, it works. Dunno if you can live with that...

Best,
Frank

Keith Kanios:
For istruc (an instance/declaration) you'll need full decoration...


--- Code: ---istruc str
  at str.byte, db 0
iend

--- End code ---

Serge:
That works. But looks strange.
Thank you.

Serge:
Hmmm. Even worse. This construction doesn't work even without any macroses. The following quite simple code also gives an error.


--- Code: ---struc str
  .byte: resb 1
endstruc

label:
istruc str
  at .byte, db 0
iend
--- End code ---

But even more. If I specify full decoration, I have no ability to address of the members of structure directly. The following construction:


--- Code: ---struc str
  .byte: resb 1
endstruc

label:
istruc str
  at str.byte, db 0
iend

mov al, [label.byte]
--- End code ---

also reports an error that `label.byte` is undefined.
So what's the use of istruc??

Navigation

[0] Message Index

[#] Next page

Go to full version