Question Bank 2-1
Question Bank 2-1
Question Bank 2-1
1. Write ALP for addition of two 8bit numbers. Assume suitable data. 2 M
Ans .Model small
.Data NUM DB 12H
.Code
START: MOV AX, @DATA
MOV DS,AX
MOV AL, NUM
MOV AH,13H
ADD AL,AH
MOV AH, 4CH
INT 21H
ENDS
END
2. How single stepping or tracing is implemented in 8086? 2 M
Ans By setting the Trap Flag (TF) the 8086 goes to single-step mode. In this mode, after the
implementation of every instruction s 8086 generates an internal interrupt and by writing
some interrupt service routine we can show the content of desired registers and memory
locations. So it is useful for debugging the program. OR If the trap flag is set, the 8086 will
automatically do a type-1 interrupt after each instruction executes.
When the 8086 does a type-1 interrupt, it pushes the flag register on the stack.
OR
The instructions to set the trap flag are:
PUSHF ; Push flags on stack
MOV BP,SP ; Copy SP to BP for use as index
OR
WORD PTR[BP+0],0100H ; Set TF flag
POPF ; Restore flag Register
3. List any four instructions from the bit manipulation instructions of 8086. 2 M
Ans Bit Manipulation Instructions These instructions are used to perform operations where
data bits are involved,
i.e. operations like logical, shift, etc.
Following is the list of instructions under this group
− Instructions to perform logical operation
NOT − Used to invert each bit of a byte or word.
AND − Used for adding each bit in a byte/word with the corresponding bit in another
byte/word.
OR − Used to multiply each bit in a byte/word with the corresponding bit in another
byte/word.
State the use of REP in string related instructions. 2 M Ans This is an instruction prefix
which can be used in string instructions. It causes the instruction to be repeated CX number
of times. After each execution, the SI and DI registers are incremented/decremented based
on the DF (Direction Flag) in the flag register and CX is decremented i.e. DF = 1; SI, DI
decrements. E.g. MOV CX, 0023H CLD REP MOVSB The above section of a program will
cause the following string operation ES: [DI] ← DS: [SI] SI ← SI + I XOR − Used to
perform Exclusive-OR operation over each bit in a byte/word with the corresponding bit in
another byte/word.
4. Describe any four string instructions of 8086 assembly language
Ans
1] REP:
This is an instruction prefix which can be used in string instructions.
It causes the instruction to be repeated CX number of times.
After each execution, the SI and DI registers are incremented/decremented based on the DF
(Direction Flag) in the flag register and CX is decremented i.e. DF = 1; SI, DI decrements.
E.g. MOV CX, 0023H
CLD
REP MOVSB
The above section of a program will cause the following string operation
ES: [DI] ← DS: [SI]
SI ← SI + I
DI ← DI + I
CX ← CX – 1
to be executed 23H times (as CX = 23H) in auto incrementing mode (as DF is cleared).
REPZ/REPE (Repeat while zero/Repeat while equal)
It is a conditional repeat instruction prefix.
It behaves the same as a REP instruction provided the Zero Flag is set (i.e. ZF = 1).
It is used with CMPS instruction. REPNZ/REPNE (Repeat while not zero/Repeat while not
equal)
It is a conditional repeat instruction prefix.
It behaves the same as a REP instruction provided the Zero Flag is reset (i.e. ZF = 0).
It is used with SCAS instruction.
2] MOVS/ MOVSB/ MOVSW - Move String byte or word.
Syntax:
MOVS destination, source
MOVSB destination, source
MOVSW destination, source
Operation: ES:[DI]<----- DS:[SI]
It copies a byte or word a location in data segment to a location in extra segment. The offset
of source is pointed by SI and offset of destination is pointed by DI.CX register contain
counter and direction flag (DE) will be set or reset to auto increment or auto decrement
pointers after one move.
Example
LEA SI, Source
LEA DI, destination
CLD
MOV CX, 04H
REP MOVSB
3] CMPS /CMPSB/CMPSW: Compare string byte or Words.
Syntax:
CMPS destination, source
CMPSB destination, source
CMPSW destination, source
Operation: Flags affected < ----- DS:[SI]- ES:[DI] It compares a byte or word in one string
with a byte or word in another string. SI Holds the offset of source and DI holds offset of
destination strings. CS contains counter and DF=0 or 1 to auto increment or auto decrement
pointer after comparing one byte/word.
Example LEA SI, Source
LEA DI, destination
CLD MOV CX, 100 REPE CMPSB
4] SCAS/SCASB/SCASW: Scan a string byte or word.
Syntax: SCAS/SCASB/SCASW
Operation: Flags affected < ----- AL/AX-ES: [DI] It compares a byte or word in AL/AX with
a byte /word pointed by ES: DI. The string to be scanned must be in the extra segment and
pointed by DI. CX contains counter and DF may be 0 or 1. When the match is found in the
string execution stops and ZF=1 otherwise ZF=0.
Example LEA DI, destination MOV Al, 0DH MOV CX, 80H CLD REPNE SCASB
5] LODS/LODSB/LODSW: Load String byte into AL or Load String word into AX. Syntax:
LODS/LODSB/LODSW
Operation: AL/AX < ----- DS: [SI]
IT copies a byte or word from string pointed by SI in data segment into AL or AX.CX may
contain the counter and DF may be either 0 or 1
Example
LEA SI, destination
CLD
LODSB
6] STOS/STOSB/STOSW (Store Byte or Word in AL/AX)
Syntax STOS/STOSB/STOSW
Operation: ES:[DI] < ----- AL/AX
It copies a byte or word from AL or AX to a memory location pointed by DI in extra segment
CX may contain the counter and DF may either set or reset
6. Write classification of instruction set of 8086. Explain any one type out of them. 4 M