Escolar Documentos
Profissional Documentos
Cultura Documentos
.MODEL SMALL
.STACK 64
.DATA
DATA1 DB 52H
DATA2 DB 29H
SUM DB ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AX, 0000H
MOV AL, DATA1
MOV BL, DATA2
ADD AL, BL
MOV SUM, AL
MAIN ENDP
END MAIN
Identify the values of all registers for each instruction as shown in Table 1.
Solution:
Table 1. 8086 Registers Values
Instr.
Initial 1 2 3 4 5 6 7 8 Halt
Register
AX 0000 0714 0714 0000 0052 0052 007B 007B 4C00 4C00
BX 0000 0000 0000 0000 0000 0029 0029 0029 0029 0029
DS 0700 0700 0714 0714 0714 0714 0714 0714 0714 0714
CS 0715 0715 0715 0715 0715 0715 0715 0715 0715 0715
IP 0000 0003 0005 0008 000B 000F 0011 0014 0017 0200
Q - 2 In the real mode addressing, Identify the starting and ending memory
addresses of segment located by the following segment register values:-
a) DS = 1000H
b) SS = 2345H
c) CS = E000H
d) ES = AB0FH
Solution:
In real mode addressing, each segment is of 64KB having addresses 0000H — FFFFH.
General formula for identifying starting and ending memory addresses of segment is:-
So,
Segment Starting Address Ending Address
Solution:
In 8086 microprocessor, the registers BX and SI contains the offset addresses. The BX and SI
offset addresses combines with DS segment register to make the physical address of memory. So,
Q - 4 Develop a short sequence of instructions that adds two thirty two bit numbers
(FE432211H and D1234EF1H) with the sum appearing in BX-AX.
Solution: Hint:
.MODEL SMALL CF
.STACK 64 BX AX
+ DX CX
.DATA ; Start of Data Segment —————
DATA1 DW 2211H ; Define word BX AX
DATA2 DW 0FE43H
DATA3 DW 4EF1H
DATA4 DW 0D123H
MAIN ENDP
END MAIN
Solution:
a) ADD AL, AX — Source and destination registers should be of same size.
b) ADC CS, DS — Arithmetic operations between segment registers are not allowed.
c) INC [BX] — Not clear, if data increment at location [BX] is of BYTE size or WORD size. It is
required to mention BYTE PTR [BX] for BYTE increment and WORD PTR [BX] for WORD
increment.
d) ADD [AX], [BX] — Arithmetic operations between memory to memory are not allowed.
e) INC SS — Increment operation on segment registers are not allowed.
Q - 6 Suppose, present content of flag register is 058FH. Find the content of AX and
Flag register after executing the following instructions:
a) MOV AX, 1001H
b) MOV DX, 20FFH
c) ADD AX, DX
Solution:
In arithmetic and logical operations, only CF (0th bit), PF (2nd bit), AF (4th bit), ZF (6th bit), SF (7th
bit) effected.
So, Flag register 058FH contains the following values,
7 6 5 4 3 2 1 0
SF ZF AF PF CF
1 0 0 0 1 1 1 1
SF ZF AF PF CF
0 0 x 1 x 1 0 0
Parity Flag — In x86 processors, the parity flag reflects the parity only of the least significant byte
of the result, and is set if the number of set bits of ones is even.
Auxiliary Flag — It indicates when an arithmetic carry or borrow has been generated out of the
four least significant bits, or lower nibble. It is primarily used to support binary-coded decimal
(BCD) arithmetic.
Q - 7 Develop a short sequence of instructions that adds AL, BL, CL, DL and AH. Save
the sum in the DH register.
Solution:
ADD BL, AL
ADD CL, BL
ADD DL, CL
ADD AH, DL
MOV DH, AH
Solution:
.MODEL SMALL
.STACK 64
.DATA
DATA1 DB 0EH ; DATA1 variable for first value as dividend
DATA2 DB 7H ; DATA2 variable for second value as divisor
QUOT DB ? ; QOUT variable for Quotient
REM DB ? ; REM variable for Reminder
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MAIN ENDP
END MAIN
Q - 9 Write an assembly program that finds the largest number among the following
numbers (stored in data segment) 25H, 12H, 15H, 1FH, 2BH.
Solution:
.MODEL SMALL
.STACK 64
.DATA
DATA1 DB 25H,12H,15H,1FH,2BH ; Data array initialisation in data segment
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MAIN ENDP
END MAIN
Q - 10 Write a assembly program that transfers 5 bytes of data from data segment with
offset of 0010H to memory location with an offset of 0210H.
Solution:
.MODEL SMALL
.STACK 64
.DATA
TEMP DB 16 DUP(?) ; Initialise 10 dummy bytes to make offset 0010H
ARRAY DB 11H, 22H, 33H, 44H, 55H ; Data initialisation
.CODE
MAIN PROC
MOV AX, OFFSET DATA
MOV DS, AX
MAIN ENDP
END MAIN