C string to bcd1/4/2023 Let's take an example to understand the process of converting a binary number into BCD Example 1: (11110) 2ġ. We will convert the decimal number into BCD.First, we will convert the binary number into decimal.There are the following steps to convert the binary number to BCD: So, the LSB and MSB of the decimal numbers are represented as its binary numbers. In BCD code, each digit of the decimal number is represented as its equivalent binary number. The BCD stands for Binary Coded Decimal Number. (5AH + 4) = 5EH.Next → ← prev Binary to BCD code conversionīCD code plays an important role in digital circuits. If the number is 94, then it is multiplying 0AH with 9. Then adding the second digit with the result to get the number. We are just multiplying the digit of 10 th place of the BCD number with 0AH. Here no additional loops are needed to do the task. We can do the same thing using some other logic also. So at the end, we are getting the output from register R3. In each iteration the value of R3 is incremented by 1, this is acting like a counter. By using this decimal value, we can compare with the number stored inR2. After increasing the value of A, DA A instruction is executed to convert the value to decimal. But these flags are needed to use DA A instruction for decimal adjusting. The reason behind it is the INCinstruction does not affect the CY and AC flags. We can use the INC A instruction to increment the value, but in this case, the value is incremented by using ADDA, #01H. So we are just increasing the value of A by 01H. The accumulator (A) and register R3 is set to 00H at first. By this value, we can compare while executing the loop. We are just taking the number from the memory. MOVA,R3 Move R3 to Store A content to the memory location pointed by R0 MOVR0,#30H Point the destination location INCR3 Increase R3 to keep track of the hex valueĬJNEA,02H,LOOP Run the loop until A = R2 Program MOVR0,#20H Initialize the address of the the data from an address, which is stored in R0ĭAA Decimal Adjust of the accumulator content The program converts the binary value ofD5H to BCD value 213D. After converting, the results will be stored at 30H. The BCD number is stored at location 20H. In this problem, we will see how to convert 8-bit BCD number to its Binary (Hexadecimal)equivalent.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |