8085 program to convert an 8 bit number into Grey number Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite - Binary to/from Gray Code Problem - Write an assembly language program in 8085 which convert an 8 bit number into grey number Example - Assumption - 8 bit number (input) is stored at memory location 2050 and output to be stored at memory location 3050. Algorithm - Load the content of memory location 2050 in AccumulatorReset carry flag i.e. CY = 0Rotate the contents of Accumulator right by 1 bit with carry and perform xor operation with initial value of inputStore the result at memory location 3050 Program - MEMORY ADDRESSMNEMONICSCOMMENT2000LDA 2050A <- M[2050]2003MOV B, AB <- A2004STCCY = 12005CMCCY <- complement of CY2006RARRotate 1 bit right with carry2007XRA BA <- A XOR B2008STA 3050M[3050] <- A200BHLTEnd of program Explanation - LDA 2050 loads the content of memory location 2050 in accumulatorMOV B, A transfers the content of register A in register BSTC sets the carry flag i.e. CY becomes 1CMC complements the carry flag i.e. CY becomes 0RAR rotate the content of accumulator by 1 bit along with carry flagXRA B performs the xor operation in values of register A and register B and store the result in ASTA 3050 stores the value of accumulator in memory location 3050HLT stops executing the program and halts any further executionAdvantages:Reduced error rate: Gray code can reduce the error rate when transmitting or storing data, since only one bit changes between adjacent values. This can be useful in applications where errors must be minimized, such as in digital communications. Improved accuracy: Gray code can improve the accuracy of position or distance measurements, since small changes in position result in small changes in the Gray code value. Used in digital electronics: Gray code is commonly used in digital electronics, particularly in applications such as rotary encoders or optical sensors. Disadvantages:Limited range: Gray code has a limited range compared to binary code, which can make it unsuitable for certain applications where a wide range of values is required. Non-intuitive ordering: As mentioned earlier, the ordering of Gray code values may be non-intuitive, making it more difficult for humans to understand or interpret them. Complex conversion: Converting between binary and Gray code can be more complex than converting between binary and other number systems, which can make it more difficult to work with Gray code values. Comment More infoAdvertise with us Next Article 8085 program to convert binary numbers to gray A AmishTandon Follow Improve Article Tags : Computer Organization & Architecture system-programming microprocessor Similar Reads 8085 program to convert 8 bit BCD number into ASCII Code Problem â Write an assembly-level language program to convert 8-bit BCD number to its respective ASCII Code. Assumptions - Starting address of program: 2000 Input memory location: 2050 Output memory location: 3050 and 3051 ASCII Code for Digits 0 â 9 Example - Algorithm -  Input the content of 20 3 min read 8086 program to convert 8 bit BCD number into ASCII Code Problem â Write an assembly language program in 8086 microprocessor to convert 8-bit BCD number to its respective ASCII Code. Assumption â Starting address of the program: 400 Input memory location: 2000 Output memory location: 3000 Example : Input: DATA: 98H in memory location 2000Output:DATA: 38H 2 min read 8085 program to convert binary numbers to gray Prerequisite - Binary to/from Gray Code Problem â Write an assembly language program in 8085 microprocessor to convert binary numbers to gray. Example - Algorithm â Set the Carry Flag (CY) to 0.Load the data from address 2050 in A.Move the data of A(accumulator) into register B.Rotate the bits of A 2 min read 8086 program to convert a 16 bit decimal number to binary Problem: We are given a 16 bit decimal number we have to print the number in binary format Examples: Input: d1 = 16 Output: 10000 Input: d1 = 7 Output: 111 Explanation: Load the value stored into registerDivide the value by 2 to convert it to binaryPush the remainder into the stackIncrease the count 2 min read 8086 program to convert a 16 bit Decimal number to Octal Problem: We are given a 16 bit decimal number we have to print the number in octal format. Examples: Input: d1 = 16 Output:20 Input: d1 = 123 Output: 173 Explanation: Load the value stored into register Divide the value by 8 to convert it to octal Push the remainder into the stack Increase the count 2 min read 8086 program to convert 8 bit ASCII to BCD number Problem - Write a program to convert ASCII to BCD 8-bit number where the starting address is 2000 and the number is stored at 2050 memory address and store result in 3050 memory address. Example-Input : location: 2050 Data : 37Output : location: 3050 Data : 07 Algorithm â Move value at [2050] into A 1 min read Like