Low-level learning — “Hello-World” x86 64 Assembly There are many, like several types of assembly languages. The most prominent are ARM, MIPS, and x86. Mips is on IBM CPUs and is found in Mac computers. Berkeley’s RISC style or reduced instruction set computer gave its name to the entire concept and was commercialized as the SPARC.
Why learn assembly you may ask…. “Because all code in the world becomes open source” Let’s learn a little about the underlining processes before we jump in: First, off intel or at&t syntax, jk….aka AT&T syntax needs to die in nuclear fire.
Briefly: Code exists somewhere in the hard drive in bytes you wrote the code and compiled it the bytes are allocated for your executable.
You load the executable in the ram: where it stores values: ram: random access memory where computer stores value its activity working on, the hard drive is static, ram is dealing with the active process.
Once the program is loaded in — CPUs registers are initialized — mini storages inside cpu person — x86 architecture has 16 of them — most are free to use — some registers have roles and specific functions. The metal or cpu can execute an instruction in code and also allocating space in ram and apace in the registers
Having an understanding of assembly language makes one aware of −
- How programs interface with OS, processor, and BIOS;
- How data is represented in memory and other external devices;
- How the processor accesses and executes instruction;
- How instructions to access and process data;
- How a program accesses external devices.
Other advantages of using assembly language are −
- It requires less memory and execution time;
- It allows hardware-specific complex jobs in an easier way;
- It is most suitable for writing interrupt service routines and other memory resident programs.
The first thing it does is put a register called ‘rip’ — register instruction pointer at the start of your code keeping track of your code
RBP — base pointer
RSP — stack pointer
Most registers are free to use
Learn by coding! Let’s look at some code — the language itself is pretty simple but the design patterns can be daunting. The syntax itself is simple t it’s understanding the connections and design patterns.
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated NASM with brew)
If you want to try this out yourself to actually compile this code create your object file with NASM, the net wide Assembler targeting the intel x86 series of processors, you will also want IBM’s ‘ld (Load Doubleword)’ instruction Load a doubleword of data into the specified general-purpose register.