Documente Academic
Documente Profesional
Documente Cultură
Bus Interface
ES Unit
CS
SS Instruction
DS queue
IP
SP Execution
BP
ALU Unit
DI
SI
Flags
A1.The execution unit contains the data and address registers, the arithmetic and logic
unit and control unit. The bus interface unit contains bus interface logic, segment
registers, memory addressing logic and a 6 byte instruction object code queue. The
EU and BIU operate asynchronously.
i) BIU sends out the address, fetches instructions from memory, reads data from ports
and memory and writes data to port and memory. It handles all transfers of data and
address on the buses for EU.
ii) EU tells BIU where to fetch instructions or data from, decodes instructions and
executes instructions.
*ALU:
performs add, subtract, AND,OR,XOR,increment,decrement,complement or shift
operations.
* It consists of pointer register and index register which is used to get the data
from memory or write data into the memory. The pointer registers are Base pointer,
1
Ist internals solutions
Source Pointer and Index Pointer. The index registers are Source Index and
Destination Index.
FLAG REGISTERS: A flag is a flip flop that indicates some condition produced by
execution of instruction or controls certain operations of EU.
* General purpose registers are 8 in number AX (AH & AL), BX (BH & BL),
CX(CH & CL),DX(DH &DL) which can be used
For temporary storage of 8 bit or 16 bit data. The data can be accessed much
more quickly than it could be accessed in external memory.
* Segment Register: Segment register is used to hold the upper 16-bit bits of
starting address for each of the segments.
* Code Segment register points to the base or start of the current code
segment.IP contains offset or distance from this base address to the next instruction
byte to be fetched.
* The stack pointer register in EU holds the 16-bit offset from the start of the
segment to the memory location where a word was most recently stored on stack.
* Base pointer consists of 16-bit source index register (SI) and 16-bit
destination index register (DI) which is used for temporary storage of data just like
general purpose register.
* DI and SI hold the 16-bit offset of a data word in one of the segments.
Q2) List out the different addressing modes in 8086 and differentiate between
the with an example.10 marks
Fastest addressing mode because processing the data between the register involves no
reference to the memory. Size of operand should be the same.
Segment registers can also be used as operand with an exception that CS register
cannot be the destination operand.
Example: mov cx, ax cx=7418h, ax=3429h
After execution cx=ax=3429h
2
Ist internals solutions
b) Base register IAM with displacement: Part of the offset address of the data is
stored in the register BX or BP and remaining part of the offset address is
specified as displacement.
Example: MOV AX, 23H [BX]; copies a word from data segment memory at
the offset address: [BX] +23H
MOV 50H [BP], 1234H
d) Indexed AM with displacement: Part of the offset address of the data is stored
in the register SI or DI and remaining part of the offset address is called
effective offset address is specified as displacement.
Example: MOV AX, 23H [SI] ;copies a word from data segment memory at
the offset address :(SI)+23H
e) Base indexed AM: Part of the offset address of the data is stored in the register
BX or BP and SI or DI. Effective offset address is obtained by adding the
contents of BX/BP+SI/DI
Example: MOV AX,[BX+SI] ; access the data at offset address specified in
BX+SI Register and copy into AX register.
3
Ist internals solutions
Description: This instruction is used to make sure the result is correct unpacked
BCD.
Function:
1. Clear the higher order nibble of AL
2. If lower nibble of AL is greater than 9 or AF=1 then
a) add 6 to AL
b) add 1 to AH
c) set AF and CF to 1
Flags Affected: AF and CF
PF,SF,OF and ZF are left undefined.
Example: AL: 0011 0101
BL: 0011 1001
ADD AL,BL Result AL=0110 1110=6EH which is incorrect
AAA Now AL=0000 0100 and CF=1 which is 14 correct answer
Description: Instruction rotates all the bits in a specified word or byte some number
of bit positions to the left. .
Functions: Operation is circular because the MSB of the operand is rotated into the
carry flag and the bit in the carry flag is rotated around into the LSB of the operand.
For multibit rotates, CF will contain the bit most recently rotated out of the
MSB.Destination operand can be a register or in a memory location. Count when
more than one is loaded into the CL register.
Flags affected: Affects only carry flag and overflow flag
Example: Cf=0, BH=10110011
RCL BH, 1; BH= 01100110
Cf=1, OF=1 because MSB Changed
Description: Used to make sure the result of adding two unpacked BCD nos is
adjusted to be legal BCD number.
Function:
1.If lower nibble of AL after an addition is greater than 9 or AF=1 then subtract 6 to
the lower nibble
2.If now the upper nibble of AL is greater than 9 or CF=1 Subtract 60H to AL.
Flags affected: AF,CF,PF,ZF OF is undefined
Example: AL=0100 0010=42h
BL=0010 1001=29h
SUB AL,BL AL=0001 1001=19H
4
Ist internals solutions
4.IMUL:Integer multiplication
5. XLAT:
Description : Used to translate a byte from one code to another code. Replaces a byte
in al register with a byte pointed to by BX in a look up table in memory. Before the
execution of the instruction the look up table containing the values for the new code
must be put in memory and the offset of the starting address of the look up table must
be loaded in BX.
It puts the byte to be translated in AL . To point to the desired byte in the look up
table , the instruction adds the byte in al to the offset of the start of the table in BX.It
then copies the byte from the address pointed to by (bx+al) back into al register.
5
Ist internals solutions
Q4.b) With respect to the code segment register and instruction pointer register,
explain the calculation of the physical address of code byte with an
example.5marks
The instruction pointer register holds 16-bit address of the next code byte within the
code segment. The CS register points to the base or start of the current code segment.
The value contained in IP is referred to as an offset because this value must be added
to the segment base address in CS to produce the required 20=bit physical address
sent out to by BIU.The IP contains the distance or offset from this base address to the
next instruction byte to be fetched.
Physical address(20-bit)=(CS)*10H+IP
CS 3 4 8 A 0
IP + 4 2 1 4
---------------------
PHYSICAL ADDRESS 3 8 A B 4
Q5) Explain execution of following 8086 instruction. What will be the content of
destination register? Also mention effect on flags and pointers after execution of
instruction.10marks
1000 1010
0110
---------
1001 0000 here higher byte not > 9
so destinstion register has 1001 0000 =90H
Carry flag and auxilliary flag is effected.
6
Ist internals solutions
AX=0050H
BH=10H
DIV AX/BH
AL=05H=5 decimal.
The quotient is stored in AL register while the remainder is stored in AH
register.AH=0H
The bits in the AX register is rotated towards right by the no. of times
specified in the CX register.
v)PUSH CX if CX=4020H,SP=00FFFH
The value of CX register is pushed into the stack at a memory location which
is pointed to by the stack
pointer.The stack pointer points to the top of the stack where the new element
is pushed.
SP = 00FFD.
1. X dw ?
7
Ist internals solutions
2. ARRAY db 10 dup(0)
* db directive tells the assembler that a variable of type byte is being defined.
* db-define byteA
* 10 byte location are allocated in memory and is given the name array.
* All the 10 memory locations are initialised to 0.
3. BCD_BIN endp
* BCD_BIN is a procedure.
* endp signifies the end of procedure BCD_BIN.
* proc along with endp is used to bracket a procedure.
* The directive ptr tells the assembler to manipulate the byte or word pointed to by
BX.
* It adds a word in AX to a word word pointed to by BX.
* The keyword word tells the assembler that the pointed to by BX is to be added.
5. ASSUME DS:DATA
* ASSUME directive is used to tell the assembler the name of the logical segment it
should use for the specified segment.
* DS:DATA tells the assembler that the logical segment DATA is to be used for
data.
_____________________________________________________________________