Assembly is considered as the oldest programming language. Learning assembly will improve our understanding or machine. In this first article of assembly tutorial we will discuss about what is assembly and why we should learn it.
What is Assembly Language?
Strictly speaking, assembly language is a programming language. It is corresponded to command / statement of computer instruction. The assembly programming is not so machine-independent language as processor has so much variation. In the next article we will cover only assembly language which refer to IBM-PC compatible’s instruction set or known as Intel x86 processor family.
Assembly language is a set of instruction specific to particular computer system. To write a assembly language we need an assembler or compiler which translate our source code to machine language. In term of programming language we won’t see human language as much as C\C++ does, but rather mnemonic for basic instruction like: mov, mul, div, add, sub, inc, etc.
Assembly language is considered as low level programming as it is the closest programming language to machine code. Because of the lack of abstraction in assembly language, assembly programming is also considered as difficult language (but don’t worry, we will discuss it).
Why Assembly Language?
There are many programming language out of there, but why we need to learn assembly? One of reason is to learn computer architecture and give deeper understanding about what is done inside. Another reason would be a certain programming language has difficulties to accessing some machine specific instructions. For a better performance, assembly can be used as it is simple and closest to machine.
Programming in assembly is not always using only assembly language. Once we can interfacing our code with other programming language. Often this method is used for creating program as assembly manages specific implementation of system while higher programming language manage the rest. To do this we need to know how higher language structure and translated into assembly (every language would)
The machine Language
A electronic-based computer only knows two type of value: 1 and 0 known as binary value. In machine language we actually instruct some CPU to utilize register or memory with a fix-size command in binary form. A machine language is built from set of number 1 and 0 and interpreted by CPU. A CPU usually has small program embedded on chip, known as microcode, which translate machine instruction to hardware signals.
As noted before, a machine language instruction is a fix-length instruction. Usually there are 16 bits for a single instruction. The first 8 bits is used for operation code, or opcode, which tell us what the instruction will do or achieve. The next 8 bits is operand.
Let’s see this example:
The first 8 bits is opcode for move instruction which assign a value to specific place. The next operand tell us about location of register AL and what value would fill it.
A register is a high speed memory inside of CPU chip. It is identified in assembly language by 2 or 3 character, such as: AH, AL, CX, or EBX.
Instruction set is set of machine instruction that can be executed by machine. Intel processor family has downward compatibility which means a newer processor can understand instruction for earlier processor.
In earlier of computing, every program must be written in machine language (hence in series of 1 and 0). This is more complicated and frustrating too so people invented assembly language to ease their job.assembly, machine, programming