You are on page 1of 8

19L511 MICROPROCESSORS AND

MICROCONTROLLERS LABORATORY

DEPT. OF ELECTRONICS AND COMMUNICATION ENGINEERING,

PSG COLLEGE OF TECHNOLOGY,

(AUTONOMOUS INSTITUTION)

PEELAMEDU, COIMBATORE - 641004

PREPARED BY,

SAKTHIVEL R

20L412
EX NO: 5 CODE CONVERSION TECHNIQUES

DATE: 26/09/2021

AIM:

To become familiar with the conditional and unconditional Jump


Instructions and to write an Assembly Language program to convert Hexadecimal
to BCD, BCD to hexadecimal.

SOFTWARE REQUIREMENT:

Keil µVision IDE.

THEORY:

CODE CONVERSION TECHNIQUES:

Hexadecimal to BCD:

Program:
Memory Machine
Mnemonic: Operands:
Address: Code:
0x0000 E530 MOV A,0x30
0x0002 75F064 MOV B(0xF0),#0x64
0x0005 84 DIV AB
0x0006 F531 MOV 0x31,A
0x0008 E5F0 MOV A,B(0xF0)
0x000A 75F00A MOV B(0xF0),#0x0A
0x000D 84 DIV AB
0x000E 540F ANL A,#0x0F
0x0010 C4 SWAP A
0x0011 25F0 ADD A,B(0xF0)
0x0013 F532 MOV 0x32,A
Result:
Input Details: Result:
Memory Memory
Expected Obtained
Location/ Data: Location/
Output: Output:
Registers: Registers:
Highest Value:
0x30 0x3F 0x31 02 02
0x32 55 55
Middle Value:
0x30 0x1A 0x31 01 01
0x32 11 11
Lowest Value:
0x30 0x0C 0x31 00 15
0x32 00 15
Program Output:

Highest Value: 3F
Middle Value: 1A

Lowest Value: 0C
BCD to Hexadecimal:

Program:
Memory Machine
Label: Mnemonic: Operands: Comments:
Address: Code:
0x0000 E530 MOV A,0x30
0x0002 75F064 MOV B(0xF0),#0x64
0x0005 A4 MUL AB
0x0006 FA MOV R2,A
0x0007 E531 MOV A,0x31
0x0009 C4 SWAP A,#0x0F,#0x0A
0x000A 540F ANL A,#0x0F
0x000C 75F00A MOV B(0xF0),#0x0A
0x000F A4 MUL AB
0x0010 F9 MOV R1,A
0x0011 E531 MOV A,0x31
0x0013 540F ANL A,#0x0F
0x0015 29 ADD A,R1
0x0016 2A ADD A,R2
0x0017 F532 MOV 0x32,AF

Result:
Input Details: Result:
Memory Memory
Expected Obtained
Location/ Data: Location/
Output: Output:
Registers: Registers:
Highest Value:
0x30 21 A F4 F4
0x31 44 0x32 F4 F4
Middle Value:
0x30 50 A 7F 7F
0x31 27 0x32 7F 7F
Lowest Value:
0x30 00 A 0A 0A
0x31 24 0x32 0A 0A
Program Output:

Highest Value: 321


Middle Value: 150
Lowest Value: 24

INFERENCE:
 The binary value to be converted is loaded to accumulator through port 1.
 Then the content of the accumulator is divided by 10 and the remainder is loaded to the
memory location 0x30 which is LSB of the result.
 Again, the quotient is divided by 10 and the remainder is loaded to the memory location
0x31 and the quotient is loaded to the location 0x32 which is the MSB1 and MSB 2 of
the result.

RESULT:
Thus the Assembly language program for converting BCD to Hexadecimal and Hexadecimal
to BCD has been implemented successfully using keil IDE.

You might also like