Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design patterns in Assembly language

Basically, are there any?

I'm tempted to think they do exist. For example, a template method can be implemented as a series of "jumps", where the target of a jump is specified "externally". Singleton will be just a well-known location in memory/code, etc.

I'm by no means an assembly expert, so these examples might turn out to be completely impossible, but still.

like image 689
Anton Gogolev Avatar asked Nov 28 '22 20:11

Anton Gogolev


2 Answers

Assembly language is more about "tricks" than design patterns. While high-level design patterns can still be thought of and brought into play, most assembly guys are more concerned with clock cycles and exploiting tricks of instructions.

For example, in x86 it is quicker to do xor eax, eax, than it is to do mov eax, 0.

The point I am making (thanks for the downvotes!) is that with Assembly Language you want to focus more on the minor detail than you do the big design picture. Just as you wouldn't focus on fine details of execution speed in a high level language.

like image 141
Dead account Avatar answered Dec 05 '22 05:12

Dead account


First definition on Google: "a design pattern is a general reusable solution to a commonly occurring problem in software design".

By that standard I'd say they most definitely exist.

First one that springs to mind is a jump table.

like image 34
Mike Avatar answered Dec 05 '22 05:12

Mike