flat assembler
Message board for the users of flat assembler.

Index > Windows > Why wont my registers work?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Yes, at the very least you waste code cache space to store something non-executable. For optimization the best option is to take the time to declare the string somewhere else (like HLLs compilers do, but here you have to do it manually). Also, the stack adjustment sometimes can be omitted (for instance if you are about to use leave instruction), but the macro will always use "add esp, ...", so for maximum optimization, macros should not be used unless the code they will create is already the very same one you'd do by hand.

To avoid having to declare the strings manually and still have them all together outside the code the cinvoke, invoke, stdcall, ccall, and any other macros of this kind I may missing could be extended to check for string parameters and build up a list of strings and then have a another macro which store them at the place of invocation, and when them detect that the separate store was used then they'll use them, otherwise will continue with the same pattern described above.

PS: Another disadvantage of storing the string like above is that you mess up the return address buffer, so when printf returns the CPU will mispredict the return address.
Post 27 Jan 2012, 20:59
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
Quote:

PS: Another disadvantage of storing the string like above is that you mess up the return address buffer, so when printf returns the CPU will mispredict the return address.

Mh... depending on what you trying to do, it could be an andvantage (obfuscation?)
Post 27 Jan 2012, 22:23
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.