Chapter 1 - 1
Chapter 1 - 1
The code segment is the area of memory where code alone is stored.
The offsets within the code segment are referenced using the Instruction
Pointer (IP), which is a 16-bit register.
The IP sequences the instructions, and always points to the next
instruction to be executed.
This 20-bit address is then placed on the address bus and the instruction
byte is fetched.
Thus the logical address for an instruction bye is of the form CS : IP.
The Stack Segment and the Stack Pointer
The stack is an area of memory that is used in a special case.
Data is generally pushed in and popped out of the stack.
The 8086 is a last-in-first-out (LIFO) stack, which means that the last
data that was pushed in, is the first one that can be popped out.
However the ‘stack top’ changes as data is put in or taken out.
A 16-bit register called Stack Pointer which points to the top of the stack.
The stack segment is like any other segment, and the upper 16 bits of its
base address is available in the SS register.
Thus the logical address for an instruction bye is of the form SS : SP.
Stack and physical address of the top of stack
The Data Segment and Extra Segment
Both these segments store data, but in certain special cases (string
instructions), it may be necessary to list them separately.
An Extra Segment (ES) register to store the upper 16 bits of the base
address of the extra segment.
An Data Segment (DS) register to store the upper 16 bits of the base
address of the extra segment.
Intel’s processors use two ways of storing the data in memory i.e.
i. little endian format
ii. big endian format
Endian formats
In the case of a bytes of data stored
In the case of a bytes of data stored
in memory, if the higher byte is
in memory, if the lower byte is in
stored at the lower memory
the lower address and the higher
address, and the lower byte is
byte is in the higher address is
stored at higher memory addresses
called the little endian format
is called the big endian format.
Consider that the number 34E6 is Consider that the number 34E6 is
to be stored. to be stored.
Address Address
60088H E6 60088H 34
60089H 34 60089H E6
Example
AD 15-AD0 These are the time multiplexed memory I/O address and data
lines.
➢ Address remains on the lines during T₁ state, while the data is
available on the data bus during T2,T3, Tw and T4.
➢ Here T1,T2,T3,T4 and Tw are the clock states of a machine cycle.
Tw is a wait state.
➢ These lines are active high and float to a tristate during interrupt
acknowledge and local bus hold acknowledge cycles.
PIN Signal description of 8086
A19/S6A18/S5,A17/S4, A16/S3 These are also time multiplexed address
and status lines.
During T₁, these are the most significant address lines for memory
operations, during I/O operations these lines are low.
The S4 and S3 together indicate which segment register is presently
being used for memory accesses, as shown in Table.
The address bits are separated from the status bits using latches con-
trolled by the ALE signal
PIN Signal description of 8086
BHE/S7 (Bus High Enable/Status) The bus high enable signal is used to
indicate the transfer of data over the higher order (D15 - D8) data bus
as shown in Table.
It goes low for the data transfers over D15 - D8, and is used to derive chip
selects of odd address memory bank or peripherals.
BHE is low during T1 for read, write and interrupt acknowledge cycles,
whenever a byte is to be transferred on the higher byte of the data bus.
S7 is currently not used.
PIN Signal description of 8086
RD-Read: Read signal, when low, indicates the peripherals that the
processor is performing a memory or I/O read operation. RD is active
low and shows the state for T2, T3, Tw of any read cycle. The signal re-
mains tristate during the 'hold acknowledge’.
TEST: This input is examined by a 'WAIT' instruction. If the TEST input goes low,
execution will continue, else, the processor remains in an idle state. The input is
synchronized internally during each clock cycle on leading edge of clock.
PIN Signal description of 8086
RESET This input causes the processor to terminate the current activity and start
execution from FFFFOH. The signal is active high and must be active for at least
four clock cycles. It restarts execution when the RESET returns low.
CLK-Clock Input The clock input provides the basic timing for processor
operation and bus control activity. It's an asymmetric square wave with 33% duty
cycle. The range of frequency for different 8086 versions is from 5MHz to 10MHz.
MN/MX The logic level at this pin decides whether the processor is to operate in
either minimum (single processor) or maximum (multiprocessor) mode.
PIN Signal description of 8086
The following pin functions are for the minimum mode operation of 8086:
ഥ
DT/R-Data Transmit/Receive This output is used to decide the direction
of data flow through the transreceivers (bidirectional buffers). When the
processor sends out data, this signal is high and when the processor is
receiving data, this signal is low. Its timing is the same as M/I/O This is
tristate during 'hold acknowledge'.
PIN Signal description of 8086
DEN-Data Enable This signal indicates the availability of valid data over
the address/data lines. It is used to enable the transreceivers to separate
the data from the multiplexed address/data signal.
QS1, QS0-Queue Status These lines give information about the status of
the code-prefetch queue. These are active during the CLK cycle after
which the queue operation is performed. These are encoded as shown in
Table.
PIN Signal description of 8086
RQ / GT0., RQ / GT1, -Request/Grant These pins are used by other local
bus masters, in maximum mode, to force the processor to release the local
bus at the end of the processor's current bus cycle. Each of the pins is
bidirectional, The request/grant sequence is as follows:
A pulse one clock wide from another bus master requests the bus access to 8086.
During T4 (current) or T₁ (next) clock cycle, a pulse one clock wide from 8086 to
the requesting master, indicates that the 8086 has allowed the local bus to float
and that it will enter the "hold acknowledge“
A one clock wide pulse from the another master indicates to 8086 that the 'hold'
request is about to end and the 8086 may regain control of the local bus at the
next clock cycle.
General Bus Operation
I/O ADDRESSING CAPABILITY
The 8086 processor can address up to 64K I/O byte registers.
The limitation is that the address of an I/O device must not be greater
than 16 bits in size, i.e. a maximum number of 216, i.e. 64KB I/O devices
may be accessed by the CPU.
The I/O address appears on address bus A0 to A15 for one clock cycle (T₁).
The 16-bit register DX is used as 16-bit I/O address pointer, with full
capability to address up to 64K devices.
I/O ADDRESSING CAPABILITY
➢ Even addressed bytes are transferred
on D7-D0 and odd addressed bytes
are transferred on D8-D15 lines.
In the case of two operands, one of them can be in memory ,but the other
will have to be placed in a register .
Data types should match –i.e. the source and destination should both be
either bytes or words
Type of addressing modes
i. Immediate vii. Based indexed
MOV AX,[2345H]
IN 80H
MOV [1089H],AL
MOV AL, AH
MOV CH, BL
MOV SI, BX
MOV ES, AX
In this mode , the address of the data is held in a register (Effective address)
The address registers allowed are BX, SI and DI.
MOV [SI], CL
MOV [DI], AX
The content of AH will be moved to the address [DI + 1].
Exercise
Show the location of data in memory, after the execution of instruction, if the content of
registers are as given DS = 1112H, AX = EE78H and BX = 3400H (i) MOV [BX], AX
Here, data is available at offset address stored in SI & DI, The EA is computed
as 10H*DS+[SI]
Based Indexed Mode
In this addressing mode, by adding content of a base register (any one of BX or BP) to the
content of an index register (any one of SI or DI). The default segment register may be ES or DS.
In this mode ,an index register and a base register together carry the
effective address .
The content of these two registers are added and called the EA.
The ‘effective address is the sum of the two registers and a displacement.
MOV DL ,50[BX][DI]
MOV 5[BP][SI], AX
This is a case of register relative addressing. The effective address is obtained from the
instruction, to be the sum of the displacement and SI
Effective address = 1234H +
4442H
5676H
The segment base address is obtained from DS to be 40220H
The physical address is the sum of the segment base address and the effective address.
i.e., 40220H +
5676H
45896H
Find the address of physical memory for the following instructions if the content of the required
registers are given as SS =2344 H, DS =4022H , BX =0200H, BP=1402H , SI=4442H
(i) MOV CL,1234H[SI] (i) MOV AL, 5[SI[[BP]
Effective Address and Referred Segments for Various Memory
Based Addressing Modes
Control transfer instructions addressing
The addressing modes depend upon whether the destination location
is within the same segment or in a different one.
Basically, there are two addressing modes for the control transfer
instructions, i.e. intersegment and intrasegment addressing modes.
Control transfer instructions addressing
Basically, there are two addressing modes for the control transfer
instructions, i.e. intersegment and intrasegment addressing modes.
If the destination location lies in the same segment, the mode is called
intrasegment mode.
Control transfer instructions addressing
LABEL lies within -128 TO +127 from the current IP content. Thus SHORT LABEL
is 8-bit signed displacement.
A 16-bit target address of a LABEL indicates that it lies within -32768 to +
32767.
Intrasegment Indirect Mode
✓ The displacement to which the control is to be transferred, is in the same segment in which the control
transfer instruction lies, but it is passed to the instruction indirectly.
✓ Here, the branch address is found as the content of a register or a memory location.
JMP [2000H];
✓ MOV AL, ES:[BX] overrides the fact that an instruction of this sort implies that the
data segment is to be used.
Since the offset is specified indirectly, as the content of BX, this is indirect
addressing. The instruction CALL [BX] calls the subroutine located at an
address 10H*CS + [BX] = 10050H, i.e. in the same code segment. Since the
control goes to the subroutine which resides in the same segment, this is an
example of intrasegment indirect addressing mode.
Tutorial 3
Let us now assume that the subroutine resides in another code segment, where
CS = 2000H. Now CALL 2000H:0050H, since the control now goes to different
segment and the address is directly specified in the instruction. In this case, find
the addressing mode and effective address.