flat assembler
Message board for the users of flat assembler.

Index > Main > prototyping

Author
Thread Post new topic Reply to topic
sylware



Joined: 23 Oct 2020
Posts: 424
Location: Marseille/France
sylware 07 Jan 2023, 20:19
When I prototype new code paths, I start to write them like I have an infinite amount of registers (no stack spilling ofc).

That way I don't encumber my mind with the register dance yet, namely I am more fluid at coding (a bit more like C).

Once I have a first satisfying "unlimited registers" prototype of the code path, I start to deal with registers, memory spilling and more.

And you guys? Any tips?

All that said I am going to repeat myself: I still have a very strong feeling of freedom while coding assembly. Not being dependent on a compiler feels so much more satisfying than coding C (or anything similar).
Post 07 Jan 2023, 20:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20203
Location: In your JS exploiting you and your system
revolution 08 Jan 2023, 00:26
I like to make functions/procedures that only need to use the stack to save the callers registers. That is, when it doesn't need local stack variables, it only uses registers. So if it looks like the current code is getting unwieldy I look into how to split it into two more more parts to call independently.

It isn't always possible, but when I can get that it feels satisfying.

However all of that gets ignored in critical code paths. When performance matters a single call/ret overhead might really hurt.
Post 08 Jan 2023, 00:26
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 424
Location: Marseille/France
sylware 08 Jan 2023, 11:46
Yeah, this is the register dance I was talking about.

Before that step, prototyping while having an infinite amount of regs is really fluid.
Post 08 Jan 2023, 11:46
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3971
Location: vpcmipstrm
bitRAKE 11 Jan 2023, 02:57
I've been honing a technique using macros. To remove ambiguity, I force all used registers to be passed as parameters. An added complexity is hidden in how the registers are used: read, write, or read-write. Application of the technique sometimes makes this obvious.

Prior I also applied an optimistic allocation of registers with refactoring as needed. The macronization [not a word, implying: replaced fragments with macros] makes it so I do not need to search-and-replace registers as I refactor.
Post 11 Jan 2023, 02:57
View user's profile Send private message Visit poster's website 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.