flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > if not defined set value in macro. How do this ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1080
Roman
I have macro.
Code:
macro var chN,chSz {
        if ~ defined Vars_offst
        Vars_offst equ 0
        end if
        chN EQU AllVars+Vars_offst  
        Vars_offst equ Vars_offst+chSz
        }  
in code:
var P1,4
var P2,4
mov [P1],2
mov [P2],8
    

IDA pro show the same address.
mov [0x408080],2
mov [0x408080],8

But I expected:
mov [0x408080],2
mov [0x408084],8
Post 23 Dec 2020, 17:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18170
Location: In your JS exploiting you and your system
revolution
Mixing preprocessor and assembler stages is causing you trouble.

Replace equ with =.

equ: preprocessor stage
defined: assembler stage
Post 24 Dec 2020, 00:22
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1080
Roman
I replace all EQU on = and work.
Thanks.
Post 24 Dec 2020, 06:30
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1080
Roman
Another question how do this ?
Code:
macro some { }

some Val,4  ;this generate Val._1 then Val._2 then Val._3 then Val._4
some Val2,7 
some Val3,2
some Val4,5
some Val5,12
    

Get this:
Code:
mov [Val._1],1.0  ;its mean Val+0
mov [Val._2],2.0  ;its mean Val+4
mov [Val._3],3.0  ;its mean Val+8
mov [Val._4],4.0  ;its mean Val+12
    

I know about struct but in this case i must writed a lot structs. This is not handful and not convenient.
Post 24 Dec 2020, 06:32
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.