Experiment No.02: LAB Manual Part A
Experiment No.02: LAB Manual Part A
Experiment No.02: LAB Manual Part A
A.1 Aim: Write assembly language program to perform Hex to BCD code conversion.
A.2 Prerequisite: knowledge about Hexadecimal, BCD numbers and instruction set of 8086
A.3 Outcome:
After successful completion of this experiment students will be able to
1. Use appropriate instructions to program microprocessor to perform
various task.
2. Develop the program in assembly/ mixed language for Intel 8086
processor
3. Demonstrate the execution and debugging of assembly/ mixed language
program
A.4 Theory
Theory:
Hexadecimal Number System:
The hexadecimal numeral system, often shortened to "hex", is a numeral system made up of 16
symbols (base 16). The standard numeral system is called decimal (base 10) and uses ten
symbols: 0,1,2,3,4,5,6,7,8,9. Hexadecimal uses the decimal numbers and six extra symbols.
There are no numerical symbols that represent values greater than ten, so letters taken from
the English alphabet are used, specifically A, B, C, D, E and F. Hexadecimal A = decimal 10,
and hexadecimal F = decimal 15. Being a Base-16 system, the hexadecimal numbering system
therefore uses 16 (sixteen) different digits with a combination of numbers from 0 through to 15.
In other words, there are 16 possible digit symbols.
(Students must submit the soft copy as per following segments within two hours of the practical. The
soft copy must be uploaded at the end of the practical)
Grade:
.stack 100
.code
mov dh, 0
jb l2
inc dh ; add 1 to dh
jmp l9
l2 : cmp ax, 1000 ; if ax>1000
jb l4
jmp l2
jb l6
jmp l4
jb l8
sub ax, 10
jmp l6
; to result
mov ah, 02
; 2 digits
mov dl, dh
int 21h
dec ch
jnz go
; displayed
; comes to lsb
; displayed
jbe l14
int 21H
jnz l12
int 21H
end
OUTPUT:
B.2 Conclusion:
After successful completion of this experiment we are able to:
1. Use appropriate instructions to program microprocessor to perform
various task.
2. Develop the program in assembly/ mixed language for Intel 8086
processor
3. Demonstrate the execution and debugging of assembly/ mixed language
program
2. AAD Instruction
Unlike all other adjustment instructions, the AAD instruction appears before a division.
The AAD instruction requires that the AX register contain a two-digit unpacked BCD number (not ASCII) before
executing.
After adjusting the AX register with AAD, it is divided by an unpacked BCD number to generate a single-digit
result in AL with any remainder in AH.
Example:
MOV BL, 9H
MOV AX, 702H
AAD
DIV BL
The above example show how 72 is unpacked BCD is divided by 9 to produce a quotient of 8. The 0702H loaded
into AX register is adjusted by the AAD instruction to 0048H.
3. AAM Instruction
Adjust the result of the multiplication of two unpacked BCD values to create a pair of unpacked BCD values.
The AX register is the implied source and destination operand for this instruction.
The AAM instruction is only useful when it follows an MUL instruction that multiplies (binary multiplication) two
unpacked BCD values and stores a word result in AX registers.
4. AAS Instruction
Adjust the result of the subtraction of two unpacked BCD values to create a unpacked BCD result.
The AL register is the implied source and destination for this instructions.
The AAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one
unpacked BCD valued from another and stores a byte result in the AL register.
If the subtraction produced a decimal carry, the AH register is decremented by 1, and the CF and AF flags are
set.
If no decimal carry occurred, the CF and AF flags are cleared, and the AH register is unchanged.
Q2. Write a assembly language program in 8086 to add two 16 bit hexadecimal numbers.
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,a
mov bx,b
add ax,bx
mov c,ax
int 3
code ends
end start