A friendly introduction to assembly for high-level programmers — Conditionals

submited by
Style Pass
2024-09-26 21:00:08

In the previous article, we learned about the basics of the assembly’s syntax and managed to create a program with just two instructions. Quite impressive!

We will spend this lesson learning more instructions and use this knowledge to translate the first high-level construct into assembly: conditionals.

Remember those old movies where computers were fed with long tapes of instructions? Surprisingly, today’s lightning-fast CPUs still work similarly, but executing instructions coming from a sequence of bytes in memory. We call this sequence the instruction stream, and the unique position of each instruction an address. As we saw in the previous article, the address of the instruction currently being executed is stored in the rip register, which is why we call it the instruction pointer.

Imagining the instruction stream as an array whose indices are the addresses1, the execution of a program in pseudo-code would read something like this:

Leave a Comment