flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Macro Syntax or Rookie ASM mistake?

Author
Thread Post new topic Reply to topic
SiGiS



Joined: 11 Feb 2013
Posts: 2
SiGiS 11 Feb 2013, 18:33
I am fairly new to ASM but pretty much a veteran at higher level languages, so feel free to point out stupid mistakes or suggest better solutions/alternatives...

Am I making a mistake in the Macro Syntax or is it a rookie ASM mistake?

Code:
macro Get bse, [arg]
{
  common
    mov rax, [bse]

  forward
    mov rax, [rax + arg]
}
    


This results in "error: Invalid Expression" (specifically, the line "mov rax, [rax + arg]")

What I am trying to achieve, is to have a macro that loads a method pointer from pointer table struc's.

i.e. as a silly example...

if I want to call System.SubSystem2.Group1.MethodCall1, as I understand it, I can do the following:

Code:
mov rax, [System]
mov rax, [rax + System.SubSystem2]
mov rax, [rax + SubSystem2.Group1]
mov rax, [rax + Group1.MethodCall1]

call [rax]

struc System
{
  SubSystem1 qword
  SubSystem2 qword
  SybSystem3 qword
}

struc SubSystem1
{
  MethodCall1
}

struc SubSystem2
{
  Group1
}

struc Group1
{
  MethodCall1
}
    
[/b][/code]

_________________
~ Anything is possible, given enough time ~
Post 11 Feb 2013, 18:33
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 11 Feb 2013, 19:16
Prefix the local labels with "." (dot):
Code:
struc System
{
  .SubSystem1 dq ?
  .SubSystem2 dq ?
  .SybSystem3 dq ?
}     
Post 11 Feb 2013, 19:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
SiGiS



Joined: 11 Feb 2013
Posts: 2
SiGiS 11 Feb 2013, 20:36
Thanks for reminding me about the local labels Smile

I also realised I was missing a macro define ... and the use of it after each struc

Code:
  macro struct name
  {
    virtual at 0
    name name
    end virtual
  }

  struc System
  {
    .SubSystem1 dq ?
    .SubSystem2 dq ?
    .SubSystem3 dq ?
  }
  struct System
    
Post 11 Feb 2013, 20:36
View user's profile Send private message 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.