flat assembler
Message board for the users of flat assembler.

Index > Main > How to do nested procedures with proc macros

Author
Thread Post new topic Reply to topic
moistMaven



Joined: 02 Jun 2023
Posts: 9
moistMaven 11 Jun 2023, 18:25
Something like below (currently it fails with exit code 1):
Code:
proc func1
        proc func2
                ccall [printf], "%d", 5
                ret
        endp
        
        ccall [printf], "%d", 6
        call func2
        ret
endp
        
call func1
    
Post 11 Jun 2023, 18:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 11 Jun 2023, 23:58
There is no need to nest.
Code:
proc func1
        ccall [printf], "%d", 6
        call func2
        ret
endp

proc func2
        ccall [printf], "%d", 5
        ret
endp

call func1    
Post 11 Jun 2023, 23:58
View user's profile Send private message Visit poster's website Reply with quote
moistMaven



Joined: 02 Jun 2023
Posts: 9
moistMaven 12 Jun 2023, 02:11
Quote:

There is no need to nest.

What if I need to use the parameters of the first function in the other
Post 12 Jun 2023, 02:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 12 Jun 2023, 02:20
Pass it along:
Code:
proc func1 param1
        ccall [printf], "%d", 6
        stdcall func2, [param1]
        ret
endp

proc func2 param2
        ccall [printf], "%d", [param2]
        ret
endp

stdcall func1, 5    
Post 12 Jun 2023, 02:20
View user's profile Send private message Visit poster's website Reply with quote
moistMaven



Joined: 02 Jun 2023
Posts: 9
moistMaven 12 Jun 2023, 02:47
Actually I was making an compiler so generating nested assembly was easy but now I'll have to write extra logic. Anyway thanks man.
Post 12 Jun 2023, 02:47
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.