flat assembler
Message board for the users of flat assembler.

Index > Main > without macro's?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 06 Apr 2009, 11:14
Without macros you can use structures to make-up a stack frame layout and use this pretty much like a form of primitive locals or arguments based on EBP or ESP.

This is the way that modern ASM evolved in time and you can retrace the baby steps if your assembler does not have PROCs, LOCALS,ARGS and stack frames already implemented.
Post 06 Apr 2009, 11:14
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 06 Apr 2009, 12:55
vid wrote:

Your code doesn't exactly reflect way used in funcs with omitted stack frames. You never "push" in such procs. You just reserve enough place on stack for arguments of every function you call, and then you MOVe arguments to stack. So the value of ESP doesn't change over all the procedure.

mmmh, right, but since those are stdcall functions I can't pre-reserve once and use many, I would have to reserve space every time I call a stdcall function. The second call on the code would be hard to avoid AGI stall (if really exists), unless I waste a second non-volatile register to store that address pre-calculated. Anyway, even if there is no stalls at all with this method I think that still it would be probably slower just because of having that extra "sub esp, args*4" instruction every time I call something.
Post 06 Apr 2009, 12:55
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 06 Apr 2009, 13:28
oh yeah, right.
Post 06 Apr 2009, 13:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Dec 2009, 16:10
vid wrote:
Your code doesn't exactly reflect way used in funcs with omitted stack frames. You never "push" in such procs. You just reserve enough place on stack for arguments of every function you call, and then you MOVe arguments to stack. So the value of ESP doesn't change over all the procedure.
...making the code even bigger.
Post 04 Dec 2009, 16:10
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 04 Dec 2009, 16:46
Quote:
...making the code even bigger.

depends... remember that stdcall is choice of the day, and "add esp, xy" takes space too. Also, size of code doesn't matter to real world problems at all these days.
Post 04 Dec 2009, 16:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Dec 2009, 22:20
pushing the parameters (actually setting them) with "mov" is much bigger than pushing. Not to mention if you push small values (sign-extended) where mov needs all bytes.

Code:
push 0    
vs
Code:
mov qword [rsp+offset], 0    
Post 04 Dec 2009, 22:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.