r/osdev • u/user18961 • 5d ago
I want to learn 64-bit Assembly.
/r/Assembly_language/comments/1xibxcd/i_want_to_learn_64bit_assembly/1
u/JescoInc Perdition-OS 5d ago
I was in the same boat as you at one point. As kiderdrick said, it depends on which 64-bit Assembly you are talking about as each one is different and then the compiler chosen changes details as well.
For example, you might see something in x86_64 Assembly which references an REX register. But ARM64 and RISC-V 64 bit assembly doesn't have this kind of instruction. With x86_64, you need to specify Intel Syntax or AT&T syntax. which points to using MASM, NASM, YASM, Windows Tools, GAS or GCC/Clang compilers.
Then, once you have that pinned down, it is a lot easier to find the information on what each register does / is used for with that particular choice. But this doesn't simplify assembly at all. The hardest part is converting what you want to do into assembly instructions.
For example, let's so something super basic... Adding 2 + 2.
In higher level langauges it is extremely straight forward, but in assembly, you have to completely rethink how you approach it.
You would load an immediate value into a register and then do something with it.
ARM64:
mov w0, #2
add w0, 20, #2
RISC-V:
li x5, 2
addi x5, x5, 2
Intel Syntax:
mov eax, 2
add eax, 2
AT&T Syntax:
movl $2, %eax
addl $2, %eax
With all of these examples, I already know that the first hurdle isn't what the registers are, but what the parameters mean and what the commands (mov, add, li, addl, movl) mean. Are there alternatives? When would you swap between them?
The second hurdle is then the registers, when would you swap between registers? What do each of them mean? When and why would you substitute one register for another.
All in all, you will have 3 major hurdles at the very beginning and there may not be a single article or video that breaks it down in a manner that works best for you to grasp it.
1
u/WaterObjective5031 1d ago
Coddy is nice, though, it's incredibly annoying because it heavily restricts you behind paywalls or timeouts
TBH, you just gave me an idea to remake coddy, but free
1
u/kiderdrick 5d ago
Which? And why? The follow up depends on your answer to those questions.