Introduction to assembly

Underneath the hood, all the code that we have written over the course of this book is ones and zeroes indicating what switches should be marked as on and off by our computer's processor. Low-level programming languages such as machine language use these switches to execute commands. This was the only way to program to begin with, but we have developed more readable languages for us to work with instead.

Starting with assembly languages, low-level languages have a very strong connection between the language's instructions and the machine code's instructions. While more readable than a sequence of 0s and 1s, it was still quite difficult to write code. For example, here is some assembly code used to add two numbers in Assembly Language:

        push    rbp 
mov rbp, rsp
mov DWORD PTR [rbp-20], edi
mov DWORD PTR [rbp-24], esi
mov edx, DWORD PTR [rbp-20]
mov eax, DWORD PTR [rbp-24]
add eax, edx
mov DWORD PTR [rbp-4], eax
nop
pop rbp
ret

Each computer architecture has its own assembly language, so writing code in low-level languages has the disadvantage of not being portable as they are machine dependent. Back in the day, people would have to learn many different languages in order to port your program to another processor. Program structures became more complicated, as the demands of functionality increased over time, making it quite difficult for programmers to implement efficient programs that were robust enough.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.74.25