4
Most read
6
Most read
15
Most read
MADE BY
MOHIT AGARWAL – (161080107026)
5TH SEM COMPUTER
Code conversion allows user to translate a number that is representated
using one coding system to other coding system.
The code conversion involves operations like :
1) Binary to BCD
2) BCD to Binary
3) BCD to Hex
4) Hex to BCD
5) BCD to Seven Segment
6) Binary to ASCII
7) ASCII to Binary
The microprocessor understands the binary/hex number
system. To convert BCD number into its binary equivalent
we need to use the principle of positional weighting in a
given number.
EXAMPLE : (2 Digit BCD to Binary)
60 = 6 x 0A H + 0
60 = 3C H + 0
60 = 3C H
LDA 2200H : Get the BCD number
MOV B, A : Save it
ANI OFH : Mask most significant four bits
MOV C, A : Save unpacked BCD 1 in C register
MOV A, B : Get BCD again
ANI FOH : Mask least significant four bits
RRC : Convert most significant four bits into unpacked BCD 2
RRC
RRC
RRC
MOV B, A : Save unpacked BCD 2 in B register
XRA A : Clear accumulator (sum = 0)
MVI D, 0AH : Set D as a multiplier of 10
SUM:ADD D : Add 10 until (B) = 0
DCR B : Decrement BCD2 by one
JNZ SUM : Is multiplication complete? If not, go back and add again
ADD C : Add BCD 1
STA 2300H : Store the result
HLT : Terminate program execution
INPUT :
2200 H : 60 H
OUTPUT :
2300 H : 3C H
The microprocessor processes data in binary
form but data that is displayed is in BCD form.
Hence, we require to convert the Binary data
to BCD.
The series of operations to be performed is
represented here using a flowchart.
Source Program:
LXI SP, 27FFH : Initialize stack pointer
LDA 6000H : Get the binary number in accumulator
CALL SUBROUTINE : Call subroutine
HLT : Terminate program execution
Subroutine to convert binary number into its equivalent BCD number:
PUSH B : Save BC register pair contents
PUSH D : Save DE register pair contents
MVI B, 64H : Load divisor decimal 100 in B register
MVI C, 0AH : Load divisor decimal 10 in C register
MVI D, 00H : Initialize Digit 1
MVI E, 00H : Initialize Digit 2
STEP1:CMP B : Check if number < Decimal 100
JC STEP 2 : if yes go to step 2
SUB B : Subtract decimal 100
INR E : update quotient
JMP STEP 1 : go to step 1
STEP2:CMP C : Check if number < Decimal 10
JC STEP 3 : if yes go to step 3
SUB C : Subtract decimal 10
INR D : Update quotient
JMP STEP 2 : Continue division by 10
STEP3:STA 6100H : Store Digit 0
MOV A, D : Get Digit 1
STA 6101H : Store Digit 1
MOV A, E : Get Digit 2
STA 6102H : Store Digit 2
POP D : Restore DE register pair
POP B : Restore BC register pair
RET : Return to main program
INPUT :
3040 H : 8A H
OUTPUT :
3041 H : 08 H
3042 H : 03 H
3043 H : 01 H
The ASCII (American Standard Code
for Information Interchange) is
used for communication purposes.
Hence, it is necessary to convert
Binary number to its ASCII
equivalent.
Source program:
LXI SP, 27FFH : Initialize stack pointer
LXI H, 2000H : Source memory pointer
LXI D, 2200H : Destination memory pointer
MVI C, O5H : Initialize the counter
BACK: MOV A, M : Get the number
CALL ASCII : Call subroutine ASCII
STAX D : Store result
INX H : Increment source memory pointer
INX D : Increment destination memory pointer
DCR C : Decrement count by 1
CJNZ : If not zero, repeat
HLT : Stop program execution a
Subroutine ASCII:
ASCII:CPI, OAH : Check if number is OAR
JNC NEXT : If yes go to next otherwise continue
ADI 30H
JMP LAST
NEXT:ADI 37H
LAST:RET : Return to main program
INPUT :
(2000H) = 1
(2001H) = 2
(2002H) = 9
(2003H) = A
(2004H) = B
OUTPUT :
(2200H) = 31
(2201H) = 32
(2202H) = 39
(2203H) = 41
(2204H) = 42
Steps for ASCII to Binary code conversion :
If ASCII code is less than 3A H then 30 H is subtracted from the number
to get its Binary Equivalent.
If the number is between 41 H and 5A H then 37 H is subtracted to get
the binary equivalent of the letter A-F.
EX:
41 H (ASCII) = 41 H - 37 H
= 04 H (BINARY)
Steps for BCD to HEX code conversion :
1) We get the value from the user.
2) Then we take the Most Significant Digit (MSD).
3) We multiply MSD by 10, using repeated addition.
4) Then we add the Least Significant Digit (LSD) to the result obtained
in previous step.
5) And finally the value is stored in the next memory location.
LXI H,0030H : Get the BCD number
MOV A,M : Initialize the memory Pointer
ADD A : Value in accumulator is doubled
MOV B,A : Value in accumulator is moved to register B
ADD A : Value in accumulator is doubled again
ADD A : Value in accumulator is doubled again
ADD B : Value in Register B is added to accumulator
(A is 10 x MSD of the BCD stored at 0030H)
INX H : Point to LSD
ADD M : LSD is added to accumulator
INX H Next location is pointed
MOV M,A : Value obtained is stored here
HLT : Terminate the program
INPUT :
0030 H : 02 H
0031 H : 09 H
OUTPUT :
0032 H : 1D H
Steps for HEX to BCD code conversion :
1) We get the HEX number from user.
2) Then shift the hexadecimal number to C register.
3) We perform repeated addition for C number of times.
4) And adjust for BCD count in each step.
5) Now the BCD value obtained is stored in memory.
LXI H,0030H : Get the HEX number
MOV C,M : Shift the number to C register
LOOP1: ADI 01H : Start a loop of repeated addition for C times
DAA : Adjust for BCD count
JNC LOOP2 : Start another loop for Higher order number
INR D
LOOP2: DCR C : Decrease C till it reaches Zero
JNZ LOOP1
STA 0051H : Store the Lower order here
MOV A,D : Move the Higher order value to accumulator
STA 0050H : Store the Higher order here
HLT
INPUT :
0030 H : 1D H
OUTPUT :
0050 H : 02 H
0051 H : 09 H
• The seven segment LCD display is used
for displaying the results in a
microprocessor based system.
• In such cases we need to convert the
results in the seven segment code.
• Such conversion can be obtained with
a look-up table.
0 3F
1 06
2 5B
3 4F
4 66
5 6D
6 7D
7 07
8 7F
9 6F
LXI H, 6200H : Initialize lookup table pointer
LXI D, 6000H : Initialize source memory pointer
LXI B, 7000H : Initialize destination memory pointer
BACK: LDAX D : Get the number
MOV L, A : A point to the 7-segment code
MOV A, M : Get the 7-segment code
STAX B : Store the result at destination memory location
INX D : Increment source memory pointer
INX B : Increment destination memory pointer
MOV A, C
CPI O5H : Check for last number
JNZ BACK : If not repeat
HLT : End of program
THANKYOU

More Related Content

PPTX
Bcd and ascii arithmetic instructions
PPT
8085 MICROPROCESSOR
PPS
Block diagram-of-8085
PPSX
Fixed point and floating-point numbers
PDF
Assembler directives and basic steps ALP of 8086
PPT
Types of instructions
PPT
Data transfer instruction set of 8085 micro processor
PDF
The 8051 microcontroller and embedded systems using assembly and c 2nd-ed
Bcd and ascii arithmetic instructions
8085 MICROPROCESSOR
Block diagram-of-8085
Fixed point and floating-point numbers
Assembler directives and basic steps ALP of 8086
Types of instructions
Data transfer instruction set of 8085 micro processor
The 8051 microcontroller and embedded systems using assembly and c 2nd-ed

What's hot (20)

PPTX
SHLD and LHLD instruction
PPTX
Combinational Circuits & Sequential Circuits
PPTX
Combinational circuits
PDF
Encoder & Decoder
PPT
Adc interfacing
PPTX
Architecture of 8085 microprocessor
PPT
adder and subtractor
PPTX
Chapter 5: Cominational Logic with MSI and LSI
PPTX
Parity Generator and Parity Checker
PPT
Multipliers in VLSI
PPTX
8257 DMA Controller
PPTX
Interfacing memory with 8086 microprocessor
PPTX
Digital electronics logic families
PPTX
MULTIPLEXER
PPT
Arithmetic Logic Unit (ALU)
PPTX
8051 MICROCONTROLLER ARCHITECTURE.pptx
PPT
Programming with 8085
PPTX
Synchronous Counter
PPTX
SHLD and LHLD instruction
Combinational Circuits & Sequential Circuits
Combinational circuits
Encoder & Decoder
Adc interfacing
Architecture of 8085 microprocessor
adder and subtractor
Chapter 5: Cominational Logic with MSI and LSI
Parity Generator and Parity Checker
Multipliers in VLSI
8257 DMA Controller
Interfacing memory with 8086 microprocessor
Digital electronics logic families
MULTIPLEXER
Arithmetic Logic Unit (ALU)
8051 MICROCONTROLLER ARCHITECTURE.pptx
Programming with 8085
Synchronous Counter
Ad

Similar to Code Conversion in 8085 Microprocessor (20)

PDF
MIC PROJECT.pdf
PPTX
Programming Techniques.pptx
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
PDF
Coal 17 - arithematic operation in Assembly Programming
RTF
Microprocessor File
PPTX
Module 2 (1).pptx
PPTX
Mod-2.pptx
PPT
Instruction set of 8086
PPT
Chapter7.2-mikroprocessor
PPTX
Class2
PPTX
6_2018_11_23!09_24_56_PM (1).pptx
PDF
PDF
Microprocessor Part 3
DOC
Information sheet/Kertas Penerangan
PPT
Binary numbers
PDF
chapter 7 Logic, shift and rotate instructions
PDF
Assembly language 8086 intermediate
PDF
Instruction set-of-8086
PPT
An instruction is a binary pattern designed inside a microprocessor to perfor...
PPT
Microprocessor 8086 PPT1.4 instruction set.ppt
MIC PROJECT.pdf
Programming Techniques.pptx
Binary and hex input/output (in 8086 assembuly langyage)
Coal 17 - arithematic operation in Assembly Programming
Microprocessor File
Module 2 (1).pptx
Mod-2.pptx
Instruction set of 8086
Chapter7.2-mikroprocessor
Class2
6_2018_11_23!09_24_56_PM (1).pptx
Microprocessor Part 3
Information sheet/Kertas Penerangan
Binary numbers
chapter 7 Logic, shift and rotate instructions
Assembly language 8086 intermediate
Instruction set-of-8086
An instruction is a binary pattern designed inside a microprocessor to perfor...
Microprocessor 8086 PPT1.4 instruction set.ppt
Ad

More from MOHIT AGARWAL (8)

PPTX
Firewalls and packet filters
PPTX
Abstract Class & Abstract Method in Core Java
PPTX
Distance Vector & Link state Routing Algorithm
PPTX
Static Data Members and Member Functions
PPT
Modes Of Transfer in Input/Output Organization
PPTX
Critical Section in Operating System
PPTX
Newton raphson method
PPTX
Communication with Artificial intelligence
Firewalls and packet filters
Abstract Class & Abstract Method in Core Java
Distance Vector & Link state Routing Algorithm
Static Data Members and Member Functions
Modes Of Transfer in Input/Output Organization
Critical Section in Operating System
Newton raphson method
Communication with Artificial intelligence

Recently uploaded (20)

PDF
Performance, energy consumption and costs: a comparative analysis of automati...
PPTX
22ME926Introduction to Business Intelligence and Analytics, Advanced Integrat...
PDF
B461227.pdf American Journal of Multidisciplinary Research and Review
PPTX
L1111-Important Microbial Mechanisms.pptx
PPTX
Software-Development-Life-Cycle-SDLC.pptx
PDF
August 2025 Top read articles in International Journal of Database Managemen...
PDF
Introduction to Machine Learning -Basic concepts,Models and Description
PPT
Basics Of Pump types, Details, and working principles.
PDF
CBCN cam bien cong nghiep bach khoa da năng
PDF
THE PEDAGOGICAL NEXUS IN TEACHING ELECTRICITY CONCEPTS IN THE GRADE 9 NATURAL...
PPTX
ARCHITECTURE AND PROGRAMMING OF EMBEDDED SYSTEMS
PDF
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
PDF
1.-fincantieri-investor-presentation2.pdf
PPTX
quantum theory on the next future in.pptx
PPT
Module_1_Lecture_1_Introduction_To_Automation_In_Production_Systems2023.ppt
PPTX
Unit IILATHEACCESSORSANDATTACHMENTS.pptx
PDF
CB Công Nghiệp Slide .dh bách khoa đà nẵng
PDF
IAE-V2500 Engine for Airbus Family 319/320
PDF
Recent Trends in Network Security - 2025
PDF
V2500 Owner and Operatore Guide for Airbus
Performance, energy consumption and costs: a comparative analysis of automati...
22ME926Introduction to Business Intelligence and Analytics, Advanced Integrat...
B461227.pdf American Journal of Multidisciplinary Research and Review
L1111-Important Microbial Mechanisms.pptx
Software-Development-Life-Cycle-SDLC.pptx
August 2025 Top read articles in International Journal of Database Managemen...
Introduction to Machine Learning -Basic concepts,Models and Description
Basics Of Pump types, Details, and working principles.
CBCN cam bien cong nghiep bach khoa da năng
THE PEDAGOGICAL NEXUS IN TEACHING ELECTRICITY CONCEPTS IN THE GRADE 9 NATURAL...
ARCHITECTURE AND PROGRAMMING OF EMBEDDED SYSTEMS
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
1.-fincantieri-investor-presentation2.pdf
quantum theory on the next future in.pptx
Module_1_Lecture_1_Introduction_To_Automation_In_Production_Systems2023.ppt
Unit IILATHEACCESSORSANDATTACHMENTS.pptx
CB Công Nghiệp Slide .dh bách khoa đà nẵng
IAE-V2500 Engine for Airbus Family 319/320
Recent Trends in Network Security - 2025
V2500 Owner and Operatore Guide for Airbus

Code Conversion in 8085 Microprocessor

  • 1. MADE BY MOHIT AGARWAL – (161080107026) 5TH SEM COMPUTER
  • 2. Code conversion allows user to translate a number that is representated using one coding system to other coding system. The code conversion involves operations like : 1) Binary to BCD 2) BCD to Binary 3) BCD to Hex 4) Hex to BCD 5) BCD to Seven Segment 6) Binary to ASCII 7) ASCII to Binary
  • 3. The microprocessor understands the binary/hex number system. To convert BCD number into its binary equivalent we need to use the principle of positional weighting in a given number. EXAMPLE : (2 Digit BCD to Binary) 60 = 6 x 0A H + 0 60 = 3C H + 0 60 = 3C H
  • 4. LDA 2200H : Get the BCD number MOV B, A : Save it ANI OFH : Mask most significant four bits MOV C, A : Save unpacked BCD 1 in C register MOV A, B : Get BCD again ANI FOH : Mask least significant four bits RRC : Convert most significant four bits into unpacked BCD 2 RRC RRC RRC MOV B, A : Save unpacked BCD 2 in B register XRA A : Clear accumulator (sum = 0) MVI D, 0AH : Set D as a multiplier of 10 SUM:ADD D : Add 10 until (B) = 0 DCR B : Decrement BCD2 by one JNZ SUM : Is multiplication complete? If not, go back and add again ADD C : Add BCD 1 STA 2300H : Store the result HLT : Terminate program execution INPUT : 2200 H : 60 H OUTPUT : 2300 H : 3C H
  • 5. The microprocessor processes data in binary form but data that is displayed is in BCD form. Hence, we require to convert the Binary data to BCD. The series of operations to be performed is represented here using a flowchart.
  • 6. Source Program: LXI SP, 27FFH : Initialize stack pointer LDA 6000H : Get the binary number in accumulator CALL SUBROUTINE : Call subroutine HLT : Terminate program execution Subroutine to convert binary number into its equivalent BCD number: PUSH B : Save BC register pair contents PUSH D : Save DE register pair contents MVI B, 64H : Load divisor decimal 100 in B register MVI C, 0AH : Load divisor decimal 10 in C register MVI D, 00H : Initialize Digit 1 MVI E, 00H : Initialize Digit 2
  • 7. STEP1:CMP B : Check if number < Decimal 100 JC STEP 2 : if yes go to step 2 SUB B : Subtract decimal 100 INR E : update quotient JMP STEP 1 : go to step 1 STEP2:CMP C : Check if number < Decimal 10 JC STEP 3 : if yes go to step 3 SUB C : Subtract decimal 10 INR D : Update quotient JMP STEP 2 : Continue division by 10 STEP3:STA 6100H : Store Digit 0 MOV A, D : Get Digit 1 STA 6101H : Store Digit 1 MOV A, E : Get Digit 2 STA 6102H : Store Digit 2 POP D : Restore DE register pair POP B : Restore BC register pair RET : Return to main program INPUT : 3040 H : 8A H OUTPUT : 3041 H : 08 H 3042 H : 03 H 3043 H : 01 H
  • 8. The ASCII (American Standard Code for Information Interchange) is used for communication purposes. Hence, it is necessary to convert Binary number to its ASCII equivalent.
  • 9. Source program: LXI SP, 27FFH : Initialize stack pointer LXI H, 2000H : Source memory pointer LXI D, 2200H : Destination memory pointer MVI C, O5H : Initialize the counter BACK: MOV A, M : Get the number CALL ASCII : Call subroutine ASCII STAX D : Store result INX H : Increment source memory pointer INX D : Increment destination memory pointer DCR C : Decrement count by 1 CJNZ : If not zero, repeat HLT : Stop program execution a
  • 10. Subroutine ASCII: ASCII:CPI, OAH : Check if number is OAR JNC NEXT : If yes go to next otherwise continue ADI 30H JMP LAST NEXT:ADI 37H LAST:RET : Return to main program INPUT : (2000H) = 1 (2001H) = 2 (2002H) = 9 (2003H) = A (2004H) = B OUTPUT : (2200H) = 31 (2201H) = 32 (2202H) = 39 (2203H) = 41 (2204H) = 42
  • 11. Steps for ASCII to Binary code conversion : If ASCII code is less than 3A H then 30 H is subtracted from the number to get its Binary Equivalent. If the number is between 41 H and 5A H then 37 H is subtracted to get the binary equivalent of the letter A-F. EX: 41 H (ASCII) = 41 H - 37 H = 04 H (BINARY)
  • 12. Steps for BCD to HEX code conversion : 1) We get the value from the user. 2) Then we take the Most Significant Digit (MSD). 3) We multiply MSD by 10, using repeated addition. 4) Then we add the Least Significant Digit (LSD) to the result obtained in previous step. 5) And finally the value is stored in the next memory location.
  • 13. LXI H,0030H : Get the BCD number MOV A,M : Initialize the memory Pointer ADD A : Value in accumulator is doubled MOV B,A : Value in accumulator is moved to register B ADD A : Value in accumulator is doubled again ADD A : Value in accumulator is doubled again ADD B : Value in Register B is added to accumulator (A is 10 x MSD of the BCD stored at 0030H) INX H : Point to LSD ADD M : LSD is added to accumulator INX H Next location is pointed MOV M,A : Value obtained is stored here HLT : Terminate the program INPUT : 0030 H : 02 H 0031 H : 09 H OUTPUT : 0032 H : 1D H
  • 14. Steps for HEX to BCD code conversion : 1) We get the HEX number from user. 2) Then shift the hexadecimal number to C register. 3) We perform repeated addition for C number of times. 4) And adjust for BCD count in each step. 5) Now the BCD value obtained is stored in memory.
  • 15. LXI H,0030H : Get the HEX number MOV C,M : Shift the number to C register LOOP1: ADI 01H : Start a loop of repeated addition for C times DAA : Adjust for BCD count JNC LOOP2 : Start another loop for Higher order number INR D LOOP2: DCR C : Decrease C till it reaches Zero JNZ LOOP1 STA 0051H : Store the Lower order here MOV A,D : Move the Higher order value to accumulator STA 0050H : Store the Higher order here HLT INPUT : 0030 H : 1D H OUTPUT : 0050 H : 02 H 0051 H : 09 H
  • 16. • The seven segment LCD display is used for displaying the results in a microprocessor based system. • In such cases we need to convert the results in the seven segment code. • Such conversion can be obtained with a look-up table. 0 3F 1 06 2 5B 3 4F 4 66 5 6D 6 7D 7 07 8 7F 9 6F
  • 17. LXI H, 6200H : Initialize lookup table pointer LXI D, 6000H : Initialize source memory pointer LXI B, 7000H : Initialize destination memory pointer BACK: LDAX D : Get the number MOV L, A : A point to the 7-segment code MOV A, M : Get the 7-segment code STAX B : Store the result at destination memory location INX D : Increment source memory pointer INX B : Increment destination memory pointer MOV A, C CPI O5H : Check for last number JNZ BACK : If not repeat HLT : End of program

Editor's Notes

  • #19: You can use this slide as your opening or closing slide. Should you choose to use it as a closing, make sure you review the main points of your presentation. One creative way to do that is by adding animations to the various graphics on a slide. This slide has 4 different graphics, and, when you view the slideshow, you will see that you can click to reveal the next graphic. Similarly, as you review the main topics in your presentation, you may want each point to show up when you are addressing that topic. Add animation to images and graphics: Select your image or graphic. Click on the Animations tab. Choose from the options. The animation for this slide is “Split”. The drop-down menu in the Animation section gives even more animations you can use. If you have multiple graphics or images, you will see a number appear next to it that notes the order of the animations. Note: You will want to choose the animations carefully. You do not want to make your audience dizzy from your presentation.