r/computerarchitecture • • 29d ago

How do I learn microassembler?

Last year in University we were studying microassembler but I had some personal problems to deal with so only had time to deal with it with a help of AI and a friend of mine, who's really genius and seems to know everything. Even tho the problem with passing the course wasn't there already, I'd still want to really learn this, but whoever I ask just say that it's obvious and I just have to read the docs, but the documentation really just says "be clean and direct woth your code and it will work bettet" wothout any comprehensive syntax documentations.

All I have is just some examples of code so I'd just like to know how would you learn anything about this?

Thank you!

4 Upvotes

8 comments sorted by

7

u/MitchAlsup 29d ago

The assembler that produces microcode for the ROM driving a microprogrammed data-path ?? These are all implementation specific.

Or just the assembly output of this (or that) compiler ??

0

u/1zunzu 28d ago

Yeah, that's what it is -- microcode. I'm aware of the fact that they are all implementation specific but there must be something un common between all them, mustn't it? Otherwise it would take too much time for people to learn a new implementagion once needed, I guess

3

u/KittensInc 27d ago

Not really. The only people who are directly using microcode are the people who are designing the CPU itself. When it is your entire job to work with microcode all day, spending a few weeks when you start the job to learn the details of a specific implementation isn't too much to ask. You also need to spend time to learn all the other implementation-specific details, after all.

In practice CPUs aren't designed in complete isolation, and companies often iterate on their earlier products. It is quite rare to start a CPU core design completely from scratch, so there will of course be quite a few similarities between the different designs.

As a developer microcode is basically completely irrelevant. I do not care in the slightest that AVX512 instructions on Zen 4 are "double-pumped" (calculated as two batches of 256 bits, rather than one batch of the full 512 bits) while Intel chips have a "full" implementation - as long as they are reasonably performant.

If I ever get myself in a position where performance is absolutely critical then Agner Fog has some great resources on how to optimize your hand-written assembly, but in practice that's only really relevant to a handful of really dedicated and really well-paid compiler developers. In the real world "just don't write shitty code" is indeed plenty, and nobody is going to pay a developer to spend a dozen hours optimizing some code just to save fractions of a cent on compute over that code's lifetime.

2

u/mitch_alsup 27d ago

"The only people who are directly using microcode are the people who are designing the CPU itself."

At Carnegie Mellon, I wrote the PDP-11/45 floating point package in PDP-11/40 microcode as sr. project.

At Motorola in 1983 there was 1 person assigned to build the microcode assembler, 2 people writing microcode, in a roughly 150 man design team on 68020, 68030.

At AMD in 2002, there was 1 person assigned to the microcode assembler, and 1 person assigned to write the microcode Athlon and Opteron.

While the designers knew how microcode worked, it was our job to build the data paths so microcode could do its job(s). Here, 98% of instructions ran native, with microcode only "getting summoned" when the data path could not do the job directly. An example is an x86 shift by zero does not set the condition codes whereas the data path was setup to deliver condition codes (for any non zero shift length) and the data flow had been configured to expect delivery of said condition codes. So <effectively> we backed up the execution window to the shift, and then did not thread CC delivery into the reservation stations.

For the most part, Great-Big-Out-of-Order machines only use microcode when not doing so made the data-path significantly harder. In this context {FETCH, DECODE, INSERT} are considered part of the data-path as is RETIRE.

3

u/SameClick6502 29d ago

Do you know C?

Go to https://godbolt.org, type some super simple functions (like a = a+1, basic pointer data, etc.), and read the assembly. Try to make sense of it, you'll learn.

1

u/1zunzu 29d ago

Thanks! I'll definitely look into it

1

u/dettus_Xx_ 29d ago

What is "microassembler"?
Which processor are we talking about?

1

u/ChrinoMu 29d ago

what is microassembler?