Professional Documents
Culture Documents
1.
Ans
Advance Processors
UNIT-1
Microprocessor:
Assembler:
Debugger:
It is a program which allows user to test and debug programs. All computers
including microprocessor provide debugging facility. To detect errors a program
can be tested in single steps. Each step of the program is executed and tested.
The debugger allows the user to examine the contents of registers and memory
locations after each step of execution. This also provides facility to insert
breakpoint in the programs.
Linker:
Stack:
Subroutine:
Instruction:
Opcode:
Operand:
Interrupt:
ISR:
Bus:
Clock
Frequency:
Swati R. Sharma
Page 1
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
2.
Ans
General Features:
16-bit registers
Speed of processor
8086 has a 20 bit address bus can access up to 220 memory locations.( 220=1048576 bytes =1 MB)
It can support up to 64K I/O ports. (216 I/O ports-> 216=65536 bytes=64 Kb)
8086 contains powerful instruction set , that supports Multiply and Divide operation (this operation
were not possible in previous versions of 8086)
8086 can perform operation on bit, byte (8-bit), word (16-bit) or string types of data.
Special Features:
i.
Fetch Stage: It pre-fetch up to 6 bytes of instruction and store them in the queue.
ii.
ii.
i.
Lower Bank/ Even Bank: Stores the data types at even locations (0,2,4)
ii.
Higher Bank/ Odd Bank: Stores the data types at odd locations (1,3,5)
In 8086 memory is divided into 16 segments of capacity 2 16 bytes each and used as code, stack,
data and extra segment
Swati R. Sharma
Page 2
Darshan Institute of
Engineering & Technology
3.
Advance Processors
UNIT-1
Ans
In 8086 CPU is divided into two independent functional parts BIU and EU.
Dividing the work between these two units speeds up the processing.
BIU (Bus Interface Unit)
Components of BIU
-
Instruction queue
It holds the instruction bytes of the next instruction to be executed by EU
Segment Registers
Four 16-bit register that provides powerful memory management mechanism
ES (extra segment), CS (code segment), SS (stack segment) , DS (data segment).
The size of each register is 64kb.
Swati R. Sharma
Page 3
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Queuing of instruction (The instruction bytes are transferred to the instruction queue)
Thus, BUI handles all transfer of data and address on the buses for Execution unit.
EU (Execution Unit)
Components of EU
-
CU (Control Unit)
Directs internal operation
Flag Register
16-bit flag register
EU contains 9 active flags
Index Register
16-bit Register is SI (source index) and DI (destination index).
Both the register are used for string related operation and for moving block of memory
from one location to the other.
Pointers
16-bit Register.
i.e. SP (stack pointer), BP (base pointer)
BP : is used when we need to pass parameter through stack
SP:
It always points to the top of the stack. Used for sequential access of stack
segment.
-
Swati R. Sharma
Page 4
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
4.
Ans
The 8086 microprocessor has a total of fourteen registers that are accessible to the programmer as
follows:General Purpose Register
1. AX: - Accumulator register consists of two 8-bit registers AL and AH, which can be combined together
and used as a 16-bit register AX.
- AX works as an intermediate register in memory and I/O operation.
- Accumulator is used for the instruction such as MUL and DIV.
2. BX: - Base register consists of two 8-bit registers BL and BH, which can be combined together and
used as a 16-bit register BX.
- BX register usually contains a data pointer used for based, based indexed or register indirect
addressing.
3. CX: - Count register consists of two 8-bit registers CL and CH, which can be combined together and
used as a 16-bit register CX. Count register can be used in Loop, shift/rotate instructions and
as a counter in string manipulation.
4. DX: - Data register can be used together with AX register to execute MUL and DIV instruction.
- Data register can be used as a port number in I/O operations.
Segment Register
Types of Segment registers are as follows:1. Code Segment (CS): The CS register is used for addressing a memory location in the Code Segment
of the memory, where the executable program is stored.
2. Data Segment (DS): The DS contains most data used by program. Data are accessed in the Data
Segment by an offset address or the content of other register that holds the offset address.
3. Stack Segment (SS): SS defined the area of memory used for the stack.
4. Extra Segment (ES): ES is additional data segment that is used by some of the string to hold the
destination data
Pointer Registers
The pointers IP, BP, SP usually contain offsets within the code, data and stack segments respectively.
1. Stack Pointer (SP): SP is a 16-bit register pointing to program stack in stack segment.
2. Base Pointer (BP): BP is a 16-bit register pointing to data in stack segment. BP register is usually
used for based, based indexed or register indirect addressing.
3. Instruction Pointer (IP): IP is a 16-bit register pointing to next instruction to be executed.
Swati R. Sharma
Page 5
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
Index registers
The Index Registers are as follows:1. Source Index (SI): SI is a 16-bit register used for indexed, based indexed and register indirect
addressing, as well as a source data addresses in string manipulation instructions.
2. Destination Index (DI) : DI is a 16-bit register. DI is used for indexed, based indexed and register
indirect addressing, as well as a destination data addresses in string manipulation instructions.
Flag Registers
1. The 16-bit flag register of 8086 contains 9 active flags (six conditional & 3 control flags), other 7
flags are undefined.
2. Status Flags: It indicates certain condition that arises during the execution. They are controlled by
the processor.
3. Control Flags: It controls certain operations of the processor. They are deliberately set/ reset by the
user.
15
14
13
12
11
10
OF
DF
IF
TF
SF
ZF
AF
PF
CF
U- Undefined
Control Flags
Control flags are set or reset deliberately to control the operations of the execution unit.
4. Trap Flag (TF):
-
When trap flag is set, program can be run in single step mode.
If it is set, the mask able interrupt of 8086 is enabled and if it is reset, the interrupt is disabled.
It can be set by executing instruction sit and can be cleared by executing CLI instruction.
Swati R. Sharma
Page 6
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
If it is set, string bytes are accessed from higher memory address to lower memory address.
When it is reset, the string bytes are accessed from lower memory address to higher memory
address.
Status Flag
1. Carry Flag (CF): This flag indicates an overflow condition for unsigned integer arithmetic. It is also
used in multiple-precision arithmetic.
2. Auxiliary Flag (AF): If an operation performed in ALU generates a carry/barrow from lower nibble (i.e.
D0 D3) to upper nibble (i.e. D4 D7), the AF flag is set i.e. carry given by D3 bit to D4 is AF flag.
This is not a general-purpose flag, it is used internally by the processor to perform Binary to BCD
conversion.
3. Parity Flag (PF): This flag is used to indicate the parity of result. If lower order 8-bits of the result
contains even number of 1s, the Parity Flag is set and for odd number of 1s, the Parity Flag is reset.
4. Zero Flag (ZF): It is set; if the result of arithmetic or logical operation is zero else it is reset.
5. Sign Flag (SF): In sign magnitude format the sign of number is indicated by MSB bit. If the result of
operation is negative, sign flag is set.
6. Overflow Flag (OF): It occurs when signed numbers are added or subtracted. OF=1 indicates that the
result has exceeded the capacity of machine.
5.
Ans
When 8086 executes an instruction, it performs the specified function on data. These data are called its
operands and may be part of the instruction, reside in one of the internal registers of the microprocessor,
stored at an address in memory or held at an I/O port, to access these different types of operands,
the 8086 is provided with various addressing modes.
There are 12 addressing modes in 8086 as follows:1. Immediate Mode
-
If a source operand is part of the instruction instead of the contents of a register or memory location,
it represents what is called the immediate operand.
If source operand is the part of instruction rather than register or memory, then referred as
immediate addressing mode.
E.g. MOV AL, 05H; instruction copies immediate number 05H to AL register
Opcode
Swati R. Sharma
Immediate Operand
Page 7
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Advantage:
-
Operand can be accessed quickly as they are directly available in instruction queue.
Limitation:
-
E.g. ADD r1, r2; adding r1 and r2 and store the result in r2
E.g. MOV AX,BX ; move value from BX to AX register
Advantage:
-
This mode is normally preferred, as the execution of instruction is faster and compact, because all
the registers reside on the same chip.
Therefore, data transfer is within the chip and no External bus is required.
Limitation:
-
Benefit:
-
Equation: Physical Address PA ={starting address of Segment Register } + {Direct memory address}
Swati R. Sharma
Page 8
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
E.g.
MOV [30540], TEMP; moving value of TEMP to memory location [30540]
DS=3060 and direct memory address=0030
3 0 6 0 0 (0 is added to LSB by BIU)
+
0 0 3 0 ( direct address)
E.g. MOV [DI], BX; value of BX is moved to the memory location specified in DI
MOV [BX], AX ; value of AX is moved to the memory location specified in BX
Swati R. Sharma
Page 9
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Benefit:
-
Limitation:
-
Equation:
PA ={starting address of Segment Register } + { [BX] or [BP] }+ (8 or 16 bit) displacement
E.g. MOV AL, TEMP [BX]; segment register address+ BX+ offset
MOV AL, TEMP [BP]; segment register address+ BP+ offset
Assume DS=3060, BX=0050 and displacement=08
3 0 6 0 0 H (starting address of segment register)
+
+
0 0 5 0 H(base register)
0 8 H(offset)
In this addressing mode offset address is added to index register and finally the sum is added to
segment register.
Equation:
PA ={starting address of Segment Register } + { [SI] or [DI] }+ (8 or 16 bit) displacement
Assume DS=3060, SI=0050 and displacement=08
3 0 6 0 0 H (starting address of segment register)
+
+
0 0 5 0 H (Source Index)
0 8 H (offset)
Swati R. Sharma
Page 10
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
This mode generates the effective address, which is sum of Base address +Index Address + (8 or 16
bit) displacement address.
3 0 0 0 H (base register)
0 4 0 0 H (Source Index)
0 8 H (offset)
Swati R. Sharma
Page 11
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
incremented
[DI] = 03
9. Relative addressing mode:
Relative address means relative to IP (Instruction Pointer).
Example : JNC START ; jump to label if no carry is generated
-
If CY=O, then PC is loaded with current PC contents plus 8 bit signed value of START,
otherwise the next instruction is executed.
Swati R. Sharma
Page 12
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
6.
Ans
The 8086 operates in single processor or multiprocessor configuration to achieve high performance.
TEST, MN/MX, RD
GND1, GND 2
VCC
It is a power supply input signal and +5V DC is supplied through this pin.
CLK
Input signal
ii.
RESET
When high, microprocessor enters into reset state and Terminates activity
Swati R. Sharma
of processor
Page 13
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
Processor requires 4 clock cycle to reset. Thus RESET signal must be 1 for at least 4 clock cycles
iii.
READY
When READY
NMI
ii.
INTR
iii.
INTA
When microprocessor receives INTR signal, it acknowledges the interrupt by generating this
signal.
AD0-AD15 (bidirectional)
During T1, they carry lower order 16-bit address and in the remaining clock cycles, they carry
16-bit data.
AD0-AD7 carry lower order byte of data and AD8-AD15 carry higher order byte of data.
During T1 machine cycle, when ALE=1, then Address bus gets enabled, else Data bus will get
enabled.
ii.
These lines are multiplexed and unidirectional address and status bus.
Swati R. Sharma
Page 14
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
iii.
S4
S3
Register
ES
SS
CS
DS
BHE/S7
BHE signal is used to indicate the transfer of data over higher order data bus (D8 D15).
Control Pins
i. TEST
-
ii. MN/MX
-
Input signal
iii. RD (READ)
-
When microprocessor receives INTR signal, it acknowledges the interrupt by generating this signal.
ii. ALE(QS0)
-
Swati R. Sharma
Page 15
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
v. M/IO(S2)
-
This signal is issued by the microprocessor to distinguish memory access from I/O access.
vi.
S2
S1
S0
Machine Language
Interrupt acknowledgement
Read I/O
Write I/O
HALT
Code Access
Read Memory
Write Memory
Passive
LOCK (WR)
This signal indicates that other processors should not ask CPU (8086) to hand over the system
bus.
When it goes low, all interrupts are masked and HOLD request is not granted.
Thus the master bus controller cant take control over the system bus, till the instruction gets
completed.
WR: It is an active low output signal. It is used to write data in memory or output signal,
depending on status of M/IO signal.
vii.
HOLD (RQ/GT0)
When DMA controller needs to use address/data bus, it sends a request to the CPU through this
pin.
When microprocessor receives HOLD signal, it issues HLDA signal to the DMA controller.
Swati R. Sharma
Page 16
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
viii.
-
ix.
7.
HLDA (RQ/GT1)
Other processors request the CPU through these lines to release the system bus.
After receiving the request, CPU sends acknowledge signal on the same lines.
Ans
In Segmentation, the total memory size is divided into segments of various sizes.
What is Segment?
Segment is just an area in memory.
What is Segmentation?
The
process
of
dividing
memory
into segments
of various
sizes
is
called
Segmentation.
Why Segmentation?
Memory is huge collection of bytes. In order to organize these bytes in an efficient
manner Segmentation is used.
With 20 address lines, the memory that can be addressed is 220 bytes.
20 lines= 220 = 1,048,576 bytes =1 MB= 1111 1111 1111 1111 1111=
FFFFF H
Swati R. Sharma
Page 17
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Segment Registers are used to hold the upper 16-bit of the starting address for each of
the segment.
The 16-bit of the starting address is the starting address of the segment from where the
BIU is currently fetching instruction code bytes.
The BIU always inserts zeros for the LSB of the 20-bit address for a segment. Because
the segment registers cannot store 20 bits, they only store the upper 16 bits.
How is a 20-bit physical address obtained if data bus is of 16-bit?
Offset is the displacement of the memory location from the starting location of the
segment.
To convert this 16-bit address into 20-bit, the BIU appends 0H to the LSBs of the base
address.
After appending, the starting address of the Data Segment becomes 22220H.
If the data at any location has an address specified as: 2222 H: 0016 H where the
number 0016 H is an offset.
To calculate the effective address of the memory, BIU uses the following formula:
Physical Address = Starting Address of Segment + Offset
To find the starting address of the segment, BIU appends the contents of Segment
Register with 0H and then, it adds offset to it.
EA = 2 2 2 2 0 H
+ 0016H
---------------22236H
Swati R. Sharma
Page 18
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
8.
Ans
By using these string instructions, the size of the program is considerably reduced.
MOVSB/MOVSW
-
Algorithm: MOVSW
ES:[DI]=DS:[SI]
ES:[DI]<=DS:[SI]
If DF=0
If DF=0
Else
then
SI=SI+1
SI=SI+2
DI=DI+1
DI=DI+2
SI=SI-1
Else
SI=SI-2
DI=DI-1
2
DI=DI-2
CMPSB/CMPSW
-
Algorithm: CMPSW
ES:[DI]-DS:[SI]
ES:[DI]-DS:[SI]
If DF=0
If DF=0
Else
then
SI=SI+2
DI=DI+1
DI=DI+2
SI=SI-1
Else
SI=SI-2
DI=DI-2
LODSB/LODSW
-
Algorithm: LODSW
AL=DS:[SI]
AX=DS:[SI]
If DF=0
If DF=0
then
SI=SI+1
Else SI=SI- 1
4
then
SI=SI+1
DI=DI-1
3
then
then
SI=SI+2
Else SI=SI-2
STOSB/STOSW
-
Swati R. Sharma
Page 19
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
Algorithm: STOSB
Algorithm: STOSW
ES:[DI]=AL
ES:[DI]=AX
If DF=0
If DF=0
then
DI=DI=1
DI=DI+2
Else DI=DI- 1
5
Else DI=DI-2
SCASB/ SCASW
-
Algorithm: SCASW
AL-ES:[DI]
AX-ES:[DI]
If DF=0
If DF=0
then
DI=DI=1
then
DI=DI+2
Else DI=DI- 1
6
then
Else DI=DI-2
REP
-
REPE/ REPZ
-
REPNE/REPNZ
-
Swati R. Sharma
Page 20
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
Algorithm: REPNE/REPNZ
IF CX< > 0 then
CX=CX-1
If ZF=1 then
Repeat the instruction with prefix REPNE/REPNZ
Else Exit from REPNE/REPNZ cycle
ELSE
The operand can be a constant, memory location, register or I/O port address.
MOV
-
Both Source and Destination cannot be memory location at the same time.
Both Source and Destination cannot be segment register at the same time.
e.g. MOV CX, 037A H
MOV AL, BL
MOV BX, [0301 H]
PUSH
-
POP
-
Destination can be a general purpose register, segment register (except CS) or memory
location.
E.g.: POP AX
XCHG
-
Swati R. Sharma
Page 21
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
XLAT
-
Operation: ((AL)+(BX)+(DS))->(AL).
The content of BX represents the offset of the starting address of the look up table from the
beginning of the current data segment while the content of AL represents the offset of the
element which is to be accessed from the beginning of the look up table.
IN
-
OUT
-
It loads a 16-bit register with the offset address of the data specified by the Source
It loads 32-bit pointer from memory source to destination register and DS.
The offset is placed in the destination register and the segment is placed in DS.
To use this instruction the word at the lower memory address must contain the offset and
the word at the higher address must contain the segment.
10
It loads 32-bit pointer from memory source to destination register and ES.
The offset is placed in the destination register and the segment is placed in ES.
This instruction is very similar to LDS except that it initializes ES instead of DS.
Swati R. Sharma
Page 22
Darshan Institute of
Engineering & Technology
11
12
13
14
Advance Processors
UNIT-1
LAHF
-
SAHF
-
PUSHF
-
POPF
-
ARITHMETIC INSTUCTIONS
1
ADD (Addition)
-
SUB (Subtraction)
-
Swati R. Sharma
Page 23
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
It subtracts the two operands and also borrows from the result.
INC (Increment)
-
DEC (Decrement)
-
CMP (Compare)
-
The comparison is done simply by internally subtracting the source from destination.
The value of source and destination does not change, but the flags are modified to indicate
the result.
NEG (Negate)
-
Swati R. Sharma
Page 24
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Corrects result in AH and AL after addition when working with BCD values.
then
AL = AL +06H
AH=AH+1
AL[H]=00H
AF=1;CF=1
10
Corrects result in AH and AL after subtraction when working with BCD values.
then
AL = AL 06H
AH=AH1
AL[H]=00H
AF=1,CF=1
11
Swati R. Sharma
Page 25
Darshan Institute of
Engineering & Technology
12
Advance Processors
UNIT-1
13
14
15
16
AH=0
Swati R. Sharma
Page 26
Darshan Institute of
Engineering & Technology
Else
Advance Processors
UNIT-1
DX=0
AND
-
Logical AND between all bits of two operands. Result is stored in destination.
Source can be a register, memory location or immediate value, while destination can be
either register or memory location
Flag CF and OF get reset and PF, SF and ZF get updated after the execution of this
instruction.
OR
-
Source can be a register, memory location or immediate value, while destination can be
either register or memory location.
Flag CF and OF get reset and PF, SF and ZF get updated after the execution of this
instruction.
NOT
-
Swati R. Sharma
Page 27
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
E.g.: NOT AL
4
XOR
-
Source can be a register, memory location or immediate value, while destination can be
either register or memory location.
Flag CF and OF get reset and PF, SF and ZF get updated after the execution of this
instruction.
TEST
-
It shift bits of byte or word left, by count and puts zero(s) in LSBs.
Destination can be either register or memory and source can be either immediate value or
count register (CX)
Algorithm
Step-1: Shift all the bits of operand to left
Step-2: set CF with MSB
Step-3: Shift 0 to LSB
E.g.: SHL AX,01H; Shift all the bits of AX to left once
SAL AX,CL; CL=02h, shift all the bits of AX to left twice
It shift bits of byte or word right, by count and puts zero(s) in LSBs.
Destination can be either register or memory and source can be either immediate value or
count register (CX)
Algorithm
Step-1: Shift all the bits of operand to right
Step-2: set CF with LSB
Step-3: Shift 0 to MSB
Swati R. Sharma
Page 28
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Only difference between SHR and SAR is that, in SAR the MSB value will not change after
the execution shift right operation.
Destination can be either register or memory and source can be either immediate value or
count register (CX).
Algorithm
Step-1: Shift all the bits of operand to right
Step-2: set CF with LSB
Step-3: Shift old_MSB (MSB before shift) to new_MSB (MSB after shift)
E.g.: SAR AX,01H; Shift all the bits of AX to right once
Destination can be either register or memory and source can be either immediate value or
count register (CX).
Algorithm
Step-1: Shift all the bits of operand to left
Step-2: Set CF with MSB
Step-3: Set LSB with MSB
E.g.: ROL AX,02H; Rotate all the bits of AX to left twice
ROL AX,CX; Rotate all the bits of AX to left CX times (CX=2h)
Destination can be either register or memory and source can be either immediate value or
count register (CX).
Algorithm
Step-1: Shift all the bits of operand to right
Step-2: Set CF with LSB
Step-3: Set MSB with LSB
E.g.: ROR AX,01H; Rotate all the bits of AX to right once
Destination can be either register or memory and source can be either immediate value or
Swati R. Sharma
Page 29
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Destination can be either register or memory and source can be either immediate value or
count register (CX).
Algorithm
Step-1: Shift all the bits of operand to right
Step-2: Set CF with MSB
Step-3: Set new_CF with LSB
E.g.: RCR AX,01H; Rotate all the bits of AX and CF to right once
Swati R. Sharma
Page 30
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
NO OPERATION
1
This instruction uses 3-clock cycles and increments the IP to the point of next instruction.
EXTERNAL SYNCHRONIZATION
1
HLT
-
ii.
iii.
Swati R. Sharma
Page 31
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
WAIT
-
8086 will stay in IDLE state when this instruction executes and remain until TEST pin is
made low or INTR / NMI pin is enabled.
ESC
-
When 8086 fetches instruction, the co-processor decodes the instruction and carries out
task specified in 6-bit Opcode embed within instruction.
LOCK
-
It is a PREFIX instruction.
This instruction allows microprocessor to make sure that another processor does not take
control over the system bus.
In 8086 the individual microprocessor are connected together by a shared system bus.
Thus, LOCK prefix prevents any other processor from taking over the system bus in middle
of critical instruction execution.
; jump to label 1
MOV AL, 0
label1:
MOV BL,0
2
CALL
-
ii.
E.g.: CALL p1
ADD AX, 1
RET
; return to OS.
p1 PROC
; procedure declaration.
Swati R. Sharma
; return to caller.
Page 32
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
p1 ENDP
3
RET
-
When this instruction executes the previous stored content of IP, CS and flag registers are
retrieved back.
E.g.: p1 PROC
; procedure declaration.
; return to caller.
p1 ENDP
CONDITIONAL TRANFER INSTRUCTION
1
JC (Jump if Carry)
-
Syntax: JC label
Algorithm
if CF = 1 then jump to label
JO(Jump if Overflow)
-
Syntax: JO label
Algorithm
if OF = 1 then jump to label
JZ/JE(Jump if Zero/Equal)
-
Swati R. Sharma
Page 33
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
JS(Jump if Sign)
-
Syntax: JS label
10
11
12
13
14
15
Swati R. Sharma
Page 34
Darshan Institute of
Engineering & Technology
16
Advance Processors
UNIT-1
17
18
LOOP
-
Instruction refers to auto decrement counter register (CX) for loop count.
Algorithm
CX=CX-1
If CX < > 0 then jump to the label
Instruction refers to auto decrement counter register (CX) for loop count.
Algorithm
CX=CX-1
If CX < > 0 and ZF=1 then jump to the label
Instruction refers to auto decrement counter register (CX) for loop count.
Algorithm
CX=CX-1
If CX < > 0 and ZF=0 then jump to the label
Swati R. Sharma
Page 35
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
INT
-
This instruction will cause 8086 to do an indirect far call to the procedure that handles
overflow condition.
Algorithm:
If OF=1 then INT
Reset IF and TF
9.
Ans
In a minimum mode 8086 system, the microprocessor 8086 is operated in minimum mode by
strapping its MN/MX* pin to logic1.
In this mode, all the control signals are given out by the microprocessor chip itself.
There is a single microprocessor in the minimum mode system. The remaining components in the
system are latches, transceivers, clock generator, memory and I/O devices.
Some type of chip selection logic may be required for selecting memory or I/O devices, depending
upon the address map of the system.
Swati R. Sharma
Page 36
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
States.
Since a memory read or write should be complete within one bus-cycle (4-CLK pulses, T1 -T4),
related timing states as follows:
-
T1 (1st clock pulse)- starts the bus cycle. Actions include setting control signals to give the
required logic values for IO/M, ALE, DT/R and a valid address onto the address bus.
T2 - the RD or WR control signals are issued, DEN is asserted and in the case of a write, data is
put onto the data bus.
The DEN turns on the data bus buffers to connect the CPU to the external data bus.
The READY input to the CPU is sampled at the end of T2 and if READY is low, wait state (TW) is
inserted before T3 begins.
T3 - this clock period is provided to allow memory to access the data. If the bus cycle is a read
Swati R. Sharma
Page 37
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
cycle, the data bus is sampled at the end of T3 or the 3rd clock pulse of the bus-cycle.
-
T4 - all bus signals are deactivated in preparation for the next clock cycle.
The 8088 also finishes sampling the data (in a read cycle) in this period.
For the write cycle, the trailing edge of the WR signal transfers data to the memory.
Hence the timing diagram can be categorized in two parts, the first is the timing diagram for read
cycle and the second is the timing diagram for write cycle shown below.
Read Cycle
To complete the minimum-mode memory-read bus-cycle, the required control signals with appropriate
active logic levels are :
-
Write Cycle
To complete the minimum-mode memory-write bus-cycle, the required control signals with appropriate
active logic levels are :
-
Swati R. Sharma
Page 38
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
10.
Ans
The Memory, Address Bus, Data Buses are shared resources between the processors.
The control signals for Maximum mode of operation are generated by the Bus Controller chip
8788.
Block diagram for Maximum mode of 8086 is shown below:-
In Maximum mode, for multiprocessor environment WR, IO/M, DT/R, DEN, ALE, INTA signals are
not available. Instead available signals are as follows:MRDC (memory read command)
MWRT (memory write command)
IORC (I/O read command)
IOWC (I/O write command)
INTA (interrupt acknowledge)
Swati R. Sharma
Page 39
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
The below table shows the Operation carried out by Maximum Mode.
S2
S1
S0
Machine Language
Interrupt acknowledgement
Read I/O
Write I/O
HALT
Code Access
Read Memory
Write Memory
Passive
Read Cycle
To complete the minimum-mode memory-read bus-cycle, the required control signals with appropriate
active logic levels are :
-
CPU to initiate data reading (MRDC) from the desired memory bank
Swati R. Sharma
Page 40
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Write Cycle
To complete the maximum-mode memory-write bus-cycle, the required control signals with appropriate
active logic levels are :
-
CPU to initiate data writing (MRTC) from the desired memory bank
11.
Ans
Maximum Mode
i.
Function
RQ/GT
0,1
LOCK
Status
QS 0,1
iv. In maximum mode interfacing, master/slave and multiplexing and several such control signals
are required.
v. In maximum mode a bus controller is required to produce control signals. This bus controller
produces MEMRDC, MEMWRC, IORDC, IOWRC, ALE, DEN, DT/R control signals.
vi. Maximum mode operation control signals must be generated externally requires an additional
external bus controller 8288. Thus maximum mode operation is more expensive.
Minimum Mode
i.
Swati R. Sharma
Page 41
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
12.
Ans
Name
Function
HOLD
Hold request
HLDA
Hold acknowledge
WR
Write control
IO/M
DT/R
DEN
Data enable
Status
Status line
ALE
INTA
Interrupt acknowledge
Explain Memory bank. Briefly explain ODD and EVEN bank concept in 8086.
-
A memory bank is a designated section of computer memory used for storing data.
In 8086 there is 20 bit address bus, so it can address 1,048,576 addresses. At each address we
can store 8 bit address (1-byte)but if want to write a word(16-bit)into a memory segment to
store data in byte form then we write the data in two consecutive memory address which are
even(low) and odd(high) memory.
The 8086 memory address space can be viewed as a sequence of one million bytes in which any
byte may contain an 8-bit data element and any two consecutive bytes may contain a 16-bit
data element.
The address space is physically connected to a 16-bit data bus by dividing the address space into
two 8-bit banks of up to 512K bytes each.
One bank is connected to the lower half of the 16-bit data bus (D0 D7) and contains even
address bytes. i.e., when A0 bit is low, the bank is selected.
To access memory bytes from Even address, information is transferred over the lower half of the
data bus (D0 - D7). The A0 is output LOW and BHE is output HIGH enabling only the even
address bank.
The other bank is connected to the upper half of the data bus (D8 - D15) and contains odd
address bytes. i.e., when A0 is high and BHE (Bus High Enable) is low, the odd bank is selected.
To access memory byte from an odd address information, is transferred over the higher half of
the data bus (D8 - D15). The BHE output low enables the upper memory bank. A0 is output high
to disable the lower memory bank.
Swati R. Sharma
Page 42
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
Depending on the type of coding, an instruction may have more than one Hexcode.
The Opcode field occupies 6-bits. It defines the operation to be carried out by the instruction.
Register Direct bit (D) occupies one bit. It defines whether the register operand in byte 2 is the
source or destination operand.
D=1 Specifies
that
the
register
operand is
the
destination
operand.
Data size bit (W) defines whether the operation to be performed is an 8 bit or 16 bit data.
Swati R. Sharma
Page 43
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
14.
Ans
Short jump:
A near jump where the jump range is limited to -128 to +127 from the current value.
Near jump:
A jump to an instruction within the current code segment (the segment currently pointed
to by the CS register), sometimes referred to as an intra-segment jump.
Far jump:
A jump to an instruction located in a different segment than the current code segment
but at the same privilege level, sometimes referred to as an intersegment jump.
15.
Ans
An assembler directive is a statement to give direction to the assembler to perform the task of
assembly process.
The assembler directives control organization of the program and provide necessary information
to the assembler to understand assembly language programs to generate machine codes.
SEGMENT:
2.
ENDS:
This directive is used with the name of a segment to indicate the end of that
logical segment.
CODE SEGMENT; Start of logical segment containing code instruction statements
CODE ENDS;End of segment named CODE
3.
END:
The END directive is put after the last statement of a program to tell the
assembler that this is the end of the program module. The assembler will ignore
any statements after an END directive, so you should make sure to use only one
END directive at the very end of your program module. A carriage return is
required after the END directive.
4.
ASSUME:
The ASSUME directive is used tell the assembler the name of the logical
segment it should use for a specified segment. The statement ASSUME CS:
CODE, for example, tells the assembler that the instructions for a program are
in a logical segment named CODE. The statement ASSUME DS: DATA tells the
assembler that for any program instruction, which refers to the data segment, it
should use the logical segment called DATA.
5.
DB:
The DB directive is used to declare a byte type variable, or a set aside one or
(DEFINE BYTE)
Swati R. Sharma
Page 44
Advance Processors
UNIT-1
Darshan Institute of
Engineering & Technology
E.g.
PRICES DB 49H, 98H, 29H
initialize them
NAMES DB THOMAS ;Declare array of 6 bytes and initialize with ASCII codes
TEMP DB 100 DUP (?)
PRESSURE DB 20H DUP (0);Set aside 20H bytes of storage in memory, give it
the name PRESSURE and put 0 in all 20H locations.
6.
DW:
The DW directive is used to tell the assembler to define a variable of type word
(DEFINE WORD)
STORAGE DW 100 DUP (0) ;Reserve an array of 100 words of memory and
initialize all
named as STORAGE.
STORAGE DW 100 DUP (?)
7.
DD:
(DEFINE
memory locations, which can be accessed as type double word. The statement
DOUBLE WORD)
ARRAY DD 25629261H, for example, will define a double word named ARRAY
and initialize the double word with the specified value when the program is
loaded into memory to be run. The low word, 9261H, will be put in memory at a
lower address than the high word.
8.
DQ:
(DEFINE
QUADWORD)
DQ
243598740192A92BH,
for
example,
will
declare
variable
named
BIG_NUMBER and initialize the 4 words set aside with the specified number
when the program is loaded into memory to be run
9.
DT:
(DEFINE TEN
BYTES)
PACKED_BCD
DT
11223344556677889900
will
declare
an
array
named
PACKED_BCD, which is 10 bytes in length. It will initialize the 10 bytes with the
values 11, 22, 33, 44, 55, 66, 77, 88, 99, and 00 when the program is loaded
into memory to be run. The statement RESULT DT 20H DUP (0) will declare an
array of 20H blocks of 10 bytes each and initialize all 320 bytes to 00 when the
program is loaded into memory to be run.
Swati R. Sharma
Page 45
Darshan Institute of
Engineering & Technology
10.
Advance Processors
UNIT-1
EQU:
EQU is used to give a name to some value or symbol. Each time the assembler
(EQUATE)
finds the given name in the program, it replaces the name with the value or
symbol you equated with that name. Suppose, for example, you write the
statement FACTOR EQU 03H at the start of your program, and later in the
program you write the instruction statement ADD AL, FACTOR. When the
assembler codes this instruction statement, it will code it as if you had written
the instruction ADD AL, 03H.
11.
LENGTH:
12.
OFFSET:
13.
PTR:
(POINTER)
14.
EVEN:
The EVEN directive tells the assembler to increment the location counter to the
next even address, if it is not already at an even address. A NOP instruction will
be inserted in the location incremented over.
15.
PROC:
The PROC directive is used to identify the start of a procedure. The PROC
(PROCEDURE)
directive follows a name you give the procedure. After the PROC directive, the
term near or the term far is used to specify the type of the procedure. The
statement DIVIDE PROC FAR, for example, identifies the start of a procedure
named DIVIDE and tells the assembler that the procedure is far.
Swati R. Sharma
Page 46
Darshan Institute of
Engineering & Technology
16.
Advance Processors
UNIT-1
ENDP:
The directive is used along with the name of the procedure to indicate the end of
(END
PROCEDURE)
ORG:
The ORG directive allows you to set the location counter to a desired value at
(ORIGIN)
any point in the program. The statement ORG 2000H tells the assembler to set
the location counter to 2000H.
18.
NAME:
The NAME directive is used to give a specific name to each assembly module
when programs consisting of several modules are written.
19.
LABEL:
The LABEL directive is used to give a name to the current value in the location
counter. The LABEL directive must be followed by a term that specifics the type
you want to associate with that name.
20.
EXTRN:
The EXTRN directive is used to tell the assembler that the name or labels
following the directive are in some other assembly module. For example, if you
want to call a procedure, which in a program module assembled at a different
time from that which contains the CALL instruction, you must tell the assembler.
21.
PUBLIC:
The PUBLIC directive is used to tell the assembler that a specified name or label
will be accessed from other modules. An example is the statement PUBLIC
DIVISOR, DIVIDEND, which makes the two variables DIVISOR and DIVIDEND
available to other assembly modules.
22.
SHORT:
The SHORT operator is used to tell the assembler that only a 1 byte
displacement is needed to code a jump instruction in the program. The
destination must in the range of 128 bytes to +127 bytes from the address of
the instruction after the jump. The statement JMP SHORT NEARBY_LABEL is an
example of the use of SHORT.
23.
TYPE:
The TYPE operator tells the assembler to determine the type of a specified
variable. The assembler actually determines the number of bytes in the type of
the variable. For a byte-type variable, the assembler will give a value of 1, for a
word-type variable, the assembler will give a value of 2, and for a double wordtype variable, it will give a value of 4.
24.
GLOBAL:
25.
INCLUDE:
This directive is used to tell the assembler to insert a block of source code from
the named file into the current source module.
Swati R. Sharma
Page 47
Darshan Institute of
Engineering & Technology
16.
Ans
Advance Processors
UNIT-1
What is the minimum and maximum size of a segment in 8086? How are they computed?
-
For representing 1MB there are minimum 4 hex digits are required i.e., 20 bits, but 8086 has
fourteen 16-bit registers. That is there are no registers for representing 20 bit address. So, the
total memory is divided into 16 logical segments and each segment capacity is 64 KB (kilo
bytes).
17.
Ans
That is 16*64kb=1 MB. So, for representing 64 kb only 16 bit register is sufficient.
The stack is the section of memory used for pushing or popping registers and storing the return
address when a subroutine is called.
If the main module is written in a high-level language, that language handles the details of
creating a stack.
Use the .STACK directive only when writing a main module in assembly language.
By default, the assembler allocates 1K of memory for the stack. This size is sufficient for most
small programs.
To create a stack of a size other than the default size, give .STACK a single numeric argument
indicating stack size in bytes:
E.g.
.STACK 2048
18.
Ans
; Use 2K stack
Explain Macro
-
definition:
name
MACRO [parameters...]
<instructions>
ENDM
-
The difference is that a procedure is accesses via a CALL instruction, while a macro and all the
instructions defined in the macro, are inserted in the program at the point of usage.
Creating macro is very similar to creating a new op-code that can be used in the program.
Swati R. Sharma
Page 48
Darshan Institute of
Engineering & Technology
Advance Processors
UNIT-1
Example:
MyMacro
MOV AX, p1
MOV BX, p2
MOV CX, p3
ENDM
-------------------------------------------ORG 100h
MyMacro 1, 2, 3
MyMacro 4, 5, DX
RET
19.
The interrupt vector table is always created in the first 1K area of the memory. Justify the
statement.
Ans
When the CPU receives an interrupt type number from the PIC, it uses this number to look up the
corresponding interrupt vector in memory. There are 256 interrupt types. Each interrupt vector occupies
4 bytes. Therefore, a total of 4 x 256 = 1K bytes of memory is reserved at the beginning of the
processor memory address space for storing interrupt vectors.
20.
Ans
The Interrupt return (IRET) instruction is used only with software or hardware interrupt service
procedures. Whenever an IRET instruction executes, it stores the contents of I and T from the stack. This
is important because it preserves the state of the flag bits. If interrupts were enabled before an interrupt
service procedure, they automatically re-enabled by the IRET instruction because it restores the flag
register.
21.
Ans
Tiny:
Small:
Medium:
Compact:
Large:
Huge:
Same as the Large except that individual section can be > 64K
Swati R. Sharma
Page 49