What is the offset in the 8086 microprocessor?
8086 microprocessor has a pipelined architecture. In this type of architecture, the processor's functional and execution units can work independently and simultaneously.
The architecture of 8086 can be internally divided into 2 parts.
- Bus Interface Unit (BIU)
- Fetch Instructions from memory
- Read/Write data from/to Memory/Ports
- Execution Unit (EU)
- Decoding the fetched instruction by BIU
- Execution of the decoded instruction
BIU has different parts:
- Instruction Pointer (16-bit)
- Identifies the location of the next instruction to be fetched
- Contains the OFFSET (we will come back to it) of the actual address of the next instruction
- Queue
- Helps in fetching the next instruction while EU is decoding/executing an instruction as decoding/executing does not require the use of any bus
- This is the main feature of pipelining that helps in faster execution
- Segment Register
- There are 4 segment registers present in BIU
- Code Segment (CS)
- Stack Segment (SS)
- Data Segment (DS)
- Extra Segment (ES)
- There are 4 segment registers present in BIU
8086 has 20-bit Address Bus. Thus, it can address 2^20 = 1MB memory location. This 1MB memory can be accessed with the help the above mentioned 4 Segment Registers (CS, SS, DS & ES). This 1MB memory is divided into 16 logical segments, each with a memory of 64KB.
To locate any address in the memory bank, it needs the Physical address of that memory location. Non può ottenere direttamente l'indirizzo fisico a 20 bit usando i registri di segmento a 16 bit. Ha bisogno di calcolare l'indirizzo fisico a 20 bit.
I registri di segmento sono usati per tenere l'INDIRIZZO BASE dei loro indirizzi base di segmento rispettati. Così, in qualsiasi momento, l'8086 può indirizzare 16-bit x 64KB = 256KB di memoria su 1MB.
Per accedere alla locazione di memoria, non puoi passare l'indirizzo a 20-bit direttamente al processore. Dovete dire l'indirizzo a 16 bit rispetto al segmento. Questo indirizzo a 16 bit rispetto alla parte (segmento di 64KB) del banco di memoria è chiamato offset.
Supponiamo che il Segmento dati tenga l'indirizzo base come 1000h e che i dati di cui avete bisogno siano presenti nella posizione di memoria 0020h del Segmento dati. The calculation of the actual address is done as follows.
- Left shift the 16-bit address present in the segment register
- 0001 0000 0000 0000 0000
- Add the 16-bit offset address to this shifted base address
0001 0000 0000 0000 0000
+ 0000 0000 0010 0000
0001 0000 0000 0010 0000
So the actual address turns out to be 10020h.
At any point of time we can change the base address of the segment registers and use the memory locations in those segments using the offset.
Hope this helps you... :)