flat assembler
Message board for the users of flat assembler.

Index > Main > Error when declaring labels inside "virtual at" as local

Author
Thread Post new topic Reply to topic
JPowersFairfax



Joined: 25 Jan 2012
Posts: 11
Location: Virginia
JPowersFairfax 06 Jul 2024, 04:40
I could have sworn that I've done this many time before, but now I'm getting a build error for some reason on the code below. I need to reference a structure, pointed to by r8, inside a macro. So I create a local variable .wef inside a "virtual at r8" construct. I declare .wef as local because I want to be able to use this macro more than once in a procedure and not get an error saying ".wef is already defined", and I also don't want to interfere with any .wef variable that might already be defined inside a procedure where this macro is used. My understanding is that .wef will be replaced with a unique symbol each place it appears in the macro.


Code:
struc TESTWEF
{
   .a  rd 1
   .b  rd 1
   .c  rq 1
}

macro TEST
{
   local .wef

   virtual at r8
      .wef TESTWEF
   end virtual

   mov eax, [.wef.a]
   mov edx, [.wef.b]
   mov rcx, [.wef.c]
}

proc myTest

   TEST

   ret

endp
    


But I'm getting the following error:

Code:
flat assembler  version 1.73.30  (16384 kilobytes memory, x64)
heap.asm [28]:
   TEST
heap.asm [21] TEST [7]:
   mov eax, [.wef.a]
processed: mov eax,[.wef.a]
error: undefined symbol 'myTest.wef.a'.
    


It's as though it's replacing the .wef in the "virtual at r8" construct, but not lower down where the structure fields are being accessed. It builds fine if I remove the "local .wef" line, but then I can't use the macro in a procedure twice or in a procedure where there's already a .wef label.
Post 06 Jul 2024, 04:40
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20205
Location: In your JS exploiting you and your system
revolution 06 Jul 2024, 05:26
You need a hash.
Code:
   mov eax, [.wef#.a]
   mov edx, [.wef#.b]
   mov rcx, [.wef#.c]    
Post 06 Jul 2024, 05:26
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.