This is my first post! And I want to start it with a special and unpopular topic, Assebmly at least when we first start programming. However, this language is important to any programmer who wants to understand how processors, operating systems, firmware, compilers, and programming languages work.
Assembly is a human-readable way of representing Machine Code or CPU Instruction Set.
As we said, that is a human-readable language and not a Machine Code, so the machine will not run it as it is. That’s why there is a program called Assembler that converts the assembly code that we write to Machine Code.
How Assembly Works
First we should understand that our assembly code run on a CPU, so we have two things first is that our code should load into an address in memory, second is that our code will take control of the cpu from the operating system. and we do that in assembly by using using ‘org’ to load our code in a specific address in memory and ‘ret’ to return the control to the operating system.
quick note, we write assembly values (like addresses …) in hexadecimal, as hexadecimal is more human-readable than binary.
as we said assembly run code in the CPU, and as we know most of program use data or storage in programs to take decisions or do calculations and store results and so on. here in assembly as we run it in the cpu we use Registers to store data.
example:
mov al, 'A'
in this example we move the character “A” to the register “al” so here the register is “al” and that register we can store only one byte (8 bits). no if we want to store more bytes we can use ‘dd’ (data define) that lets us store more charachters in the same line.
dd "hello world",0