Assembler Basics: Registers
When learning Assembler and Machine Language, processor registers are super important. Whenever you want to calculate something in Assembler, you first have to load the values into a register before you can perform the arithmetic calculation. Let's start with a hello world program in C: hello.c: #include <stdio.h> int main() { printf("hello world"); } Compile and link it with: gcc hello.c Have a look at the <main> function with the command: objdump -d -Mintel a.out Note that objdump -Mintel puts the source operand right and the target operand left while objdump -MIntel does it the other way round. Here is the <main> function: 1149: f3 0f 1e fa endbr64 114d: 55 push rbp 114e: 48 89 e5 mov rbp,rsp 1161: 48 8d 05 9c 0e 00 00 lea rax,[rip+0xe9c] # 2004 <_IO_stdin_used+0x4> 1168: 48 89 c7 mov rdi,rax 116b: b8 00 00 00 00 mov eax,0x0 1170: