Question: Decimal 4.6 Example 4.11 illustrates an algorithm to convert from binary to BCD, using the decimal addition. The example converts an 8-bit binary number. Modify
Decimal 4.6 Example 4.11 illustrates an algorithm to convert from binary to BCD, using the decimal addition. The example converts an 8-bit binary number. Modify the algorithm to convert 16-bit binary numbers, and store the result in memory. Example 4.11 Binary to BCD conversion: Let us convert an 8-bit binary encoding into its equivalent BCD encoding. Since the largest decimal equivalent of an 8-bit umber is 255, one 16-bit register suffices for the result. Recall that babe...hibo 27+1.2+ + b 2 + bo hay A little algebraic exercise shows that the right hand decimal expression can be Transformed into the so called nested multiplication form (2x0+b)x2+6)x2+bs) X 2+ba) x2+b)x2+b)x2+b)x2+by Therefore, the power expansion in decimal fons can be calculated by eight iterations of operations of the form 2X+C, as expressed with the following sequence: A = 2 x 0+ Az = 2 x A, + bi Ay= 2 x A2+bs As = 2 x A+ lalala (a) RT LSB of Resina DODO DE DOUDODO rab R6 10 DDD dadd R1 R7 D HbRO dadd RTR ab RS O dadd R.RO ab RG dadid RT RT DO RO 10 dad RT.RU ab RG 1 dadd RTR 0 ab Rod dadd RTR RE 0 dood RT.RT DE GOOOOOOOOOOOO Dodaolellele IEEEHORS ROMA (b) NUMB: mob MOOS.RS mov O R7 mov R15 LOOP: dadd RT RT doc R15 ja LOOP 4.17 turting the binary HD con (1010101b-213) a Sequence of steps in loop excluding counter, baby code for the loop As Result 2 x A+ bo The decimal 2X+C can be realized with dadd provided that the carry flag is the appropriate it. The bits can be extracted into the carry by le rollings using rla. b. Assuming that the result is written in register R7 and the number of interest is stored as the least significanbyte of R6, pseudocode for the above sequence is: Initialize R70 Iterate 8 times: Roll left LSB of R6 ela. R6) 2xR7.C in decimal (dadd 17) Figure 4.17 illustrates as an example the conversion of 11010101 and the code for executing the algorithm Decimal 4.6 Example 4.11 illustrates an algorithm to convert from binary to BCD, using the decimal addition. The example converts an 8-bit binary number. Modify the algorithm to convert 16-bit binary numbers, and store the result in memory. Example 4.11 Binary to BCD conversion: Let us convert an 8-bit binary encoding into its equivalent BCD encoding. Since the largest decimal equivalent of an 8-bit umber is 255, one 16-bit register suffices for the result. Recall that babe...hibo 27+1.2+ + b 2 + bo hay A little algebraic exercise shows that the right hand decimal expression can be Transformed into the so called nested multiplication form (2x0+b)x2+6)x2+bs) X 2+ba) x2+b)x2+b)x2+b)x2+by Therefore, the power expansion in decimal fons can be calculated by eight iterations of operations of the form 2X+C, as expressed with the following sequence: A = 2 x 0+ Az = 2 x A, + bi Ay= 2 x A2+bs As = 2 x A+ lalala (a) RT LSB of Resina DODO DE DOUDODO rab R6 10 DDD dadd R1 R7 D HbRO dadd RTR ab RS O dadd R.RO ab RG dadid RT RT DO RO 10 dad RT.RU ab RG 1 dadd RTR 0 ab Rod dadd RTR RE 0 dood RT.RT DE GOOOOOOOOOOOO Dodaolellele IEEEHORS ROMA (b) NUMB: mob MOOS.RS mov O R7 mov R15 LOOP: dadd RT RT doc R15 ja LOOP 4.17 turting the binary HD con (1010101b-213) a Sequence of steps in loop excluding counter, baby code for the loop As Result 2 x A+ bo The decimal 2X+C can be realized with dadd provided that the carry flag is the appropriate it. The bits can be extracted into the carry by le rollings using rla. b. Assuming that the result is written in register R7 and the number of interest is stored as the least significanbyte of R6, pseudocode for the above sequence is: Initialize R70 Iterate 8 times: Roll left LSB of R6 ela. R6) 2xR7.C in decimal (dadd 17) Figure 4.17 illustrates as an example the conversion of 11010101 and the code for executing the algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
