flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > struc macro and label ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1719
Roman 21 Jun 2024, 14:10
Fasmw 1.73
Code:
macro kuu [arg] {
      if arg eqtype 0.0
      display '1.0;'
      end if
      if arg eqtype label  ;this not work or address too
      display '!;'
      end if
      if arg eqtype 1
      display '1;'
      end if
      }
section '.code' code readable writeable executable
      
      struc aff [args]  {  kuu args }

;in data
        terr  aff  1.0,2,3,e1
e1: dd 1,2,3
    

I not see '!'.
But work fine "1.0" and "1"
Post 21 Jun 2024, 14:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20215
Location: In your JS exploiting you and your system
revolution 21 Jun 2024, 15:44
Maybe this only works for ELF?
Code:
format _FORMAT

macro foo x {
        if x relativeto $
                display `x,' label',13,10
        else if x eqtype 0
                display `x,' number',13,10
        end if
}

a: 
b=0

foo a
foo b    
Code:
~ fasm test.asm -d _FORMAT=pe
flat assembler  version 1.73.31  (16384 kilobytes memory)
a label
b label
1 passes, 512 bytes.

~ fasm test.asm -d _FORMAT=elf
flat assembler  version 1.73.31  (16384 kilobytes memory)
a label
b number
1 passes, 268 bytes.    
Post 21 Jun 2024, 15:44
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1719
Roman 24 Jun 2024, 09:53
Why in ELF format relativeto correct work, but in PE not?
Bug?
Post 24 Jun 2024, 09:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20215
Location: In your JS exploiting you and your system
revolution 24 Jun 2024, 10:21
If the condition is changed to test both options
Code:
format _FORMAT

macro foo x {
        if x relativeto $
                display `x,' label',13,10
        end if
        if x eqtype 0
                display `x,' number',13,10
        end if
}

a: 
b=0

foo a
foo b    
Code:
~ fasm test.asm -d _FORMAT=pe 
flat assembler  version 1.73.31  (16384 kilobytes memory)
a label
a number
b label
b number
1 passes, 512 bytes.

~ fasm test.asm -d _FORMAT=elf
flat assembler  version 1.73.31  (16384 kilobytes memory)
a label
a number
b number
1 passes, 268 bytes.    
Post 24 Jun 2024, 10:21
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1719
Roman 24 Jun 2024, 11:46
I get in PE:
1.0 label
1.0 number

2 label
2 number

e1 label
e1 number

But its wrong result.
Post 24 Jun 2024, 11:46
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1719
Roman 24 Jun 2024, 13:18
How work proc macro ?

proc a1
Ret
endp

I mean apply to name something like .label or .proc or .address ?
Post 24 Jun 2024, 13:18
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 795
Location: Russian Federation, Sochi
ProMiNick 25 Jun 2024, 09:47
Tomasz, Is fasmcore could be patched this way so any $ symbol would be always threated as relocateble no matter relocateble output format or not?


Roman, in case of PE format add at end:
Code:
virtual
data fixups
end data
end virtual
dd 0,8    
price is 8 bytes, but symbol $ will start acts like relocatable
(in case of already present fixups section or data my one is not needed)
Post 25 Jun 2024, 09:47
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20215
Location: In your JS exploiting you and your system
revolution 25 Jun 2024, 10:11
Why use virtual?

Is it bad to use it normally?
Code:
data fixups
dd 0,8
end data    
Post 25 Jun 2024, 10:11
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 795
Location: Russian Federation, Sochi
ProMiNick 25 Jun 2024, 12:18
Why use virtual? because virtual block is good place for reloc data in case of unwanted reloc table combined with all goodies of symbol $ unrelated to 0 that reached only in relocatable file formmats.
Post 25 Jun 2024, 12:18
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1719
Roman 08 Jul 2024, 14:03
Post 08 Jul 2024, 14:03
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.