Content
Assembler
The assembly language is a low level language whose instructions usually correspond one by one to the instructions of the computer, and with the possibility to be able to define, for example, macroinstrucciones
This language is totally dependent on the processor model
To be able to study this language with a real microprocessor has been chosen the 8086, as it is one of the most used today on PC type computers
The main feature of that microprocessor is that it is capable of working with 16 bit operands
PC-type computers use the basic 16 bit operations of the 8086, and if the processor is 32 bit, a new repertoire of 32 bit operations is added to it. If it is 64 bit then the repertoire of operations included are 16 bit, 32 bit and a new 64 bit repertoire
Basic architecture of the 8086
The internal architecture of the 8086 consists of two distinct parts: the Execution Unit and the Interface Unit with the bus
The main task of the Execution Unit is to execute the statements it extracts from the queue, where they arrive from the MP (Main Memory)
The main job of the Interface Unit with the bus is to search and bring the MP instructions. To do this you will need to generate the address of the statement to be executed
General records or data
There are 4 registers of 16 bit and each one has a specific utility:
- AX
Accumulator record, used with arithmetic operations - BX
Base record, used to access vectors, tables, etc
Through the use of a base address that indicates which is the first element and a direction of displacement which is the value that is added to the base address in order to reach the desired item - CX
Counter record, used to count in loops and repetitive type instructions - DX
Data logging, has two particular uses- Complement the AX register in the arithmetic operations of multiplication and division
- Contains port addresses for input/output instructions
These 4 records have the following common property, although they are 16 bits, each can be considered as 2 separate 8 bit records. In this way we can designate the highest or most significant bits as Hight (the record is renamed with H at the end: AH, BH, CH, DH) and the lowest or least significant ones as Lower (the record is renamed with L at the end: AL, BL, CL, DL)
Segment records: Segmentation
There are 4 registers of 16 bit and each one has a specific utility:
- CS
Code segment, is the one that defines the memory zone where the instructions to be executed or program are located - DS
Data segment, is the one that defines the area where the data to be used in the program is located - SS
Stack or stack segment, defines the memory zone to use as a stack - It IS
Extra segment, as the name implies contains the address of the extra segment, which is used when the capacity of 64 kbytes of the data segment is exceeded and to perform certain data transfers between segments
Data Bus: lines that transmit the data
Data bus width: number of bus power lines through which data is transmitted, in 8086 they are 16 bit
Address Bus: lines that transmit the addresses
Address bus width: number of bus power lines through which addresses are transmitted, in 8086 they are 16 bit
Therefore, the addresses should be 16 bits, however, on the 8086 they are 20 bits. This is because the number of different addresses would be 2^{16}=64K, but because they are very few, we are interested in them being 20 bits, since 2^{10}=1M
To calculate the physical direction we need a segment and an offset, always using hexadecimal values, so we will have a first 16 bit record to which a 0 will be added to its right and a second 16 bit record
As the notation is used Segment:Displacement
The calculation of the physical address shall be carried out:
Segment x 10(h) + Offset
Examples of Segment:Displacement
- 0000:1050\Rightarrow 0000\cdot 10+1050=0150
- 0010:0F50\Rightarrow 0010\cdot 10+0F50=0150
- 0100:0050\Rightarrow 0100\cdot 10+0050=0150
- 0105:0000\Rightarrow 0105\cdot 10+0000=0150
As can be seen in the examples, different combinations of segments and displacements can give us the same physical direction. This situation is not an error, it is because the directions of the segments overlap each other
We can have as many different segment numbers as different combinations can be made with the segment base direction. Since it has 16 bits then we have 2^{16} combinations so that we have 64\cdot K different directions
We can have as many different address numbers in each segment as different combinations can be made with scrolling. Since it has 16 bits then we have 2^{16} combinations so that we have 64\cdot K different directions
You might think that as we have 64\cdot K segments and 64\cdot K addresses, we would have 64\cdot 64=2G physical addresses. However, because the addresses are overlapped this number of addresses is incorrect
Valid segment start addresses have the property of ending in 0. Therefore, since in hexadecimal they are 10, when moving from hexadecimal to decimal we get that the number of addresses is 16