??? 06/23/11 11:31 Read: times Msg Score: +2 +2 Good Answer/Helpful |
#182713 - Fundamental Issue Here Responding to: ???'s previous message |
I believe that the fundamental issue at hand here is that the OP is quite able to use the Windows Calculator program to convert 12345610 to 1E24016 but at the same time has not internalized at all how the calculator works inside.
All too often we also see here a large amount of confusion between "representation" of a number and "storage format" of a number. Is that a factor here too? It may be and thus the problem of conversion seems like a huge complex hurdle to a newcomer when in reality the problem at hand is one of back to basics working with nuts and bolts. The request here came for "assembly code". There is no question that it takes some work to implement the number representation conversions in assembler code. If working in C code this problem is reduced to one very similar to playing with the Windows Calculator. And when doing so one completely misses out on what is going on inside the library code that gets linked onto the program. Presumably the OP intends the initial 6-digit representation of the number to be stored in some type of string. That could be as ASCII digits in a string or packed BCD in some three bytes with individual nibbles representing 0 to 9 values. One also could guess that the output hexadecimal representation would be in some sort of string format as well....likely an ASCII type thing that can be displayed somehow. Conversion would entail, for this problem, putting in place some generic 32-bit integer arithmetic routines that would include add, subtract, multiply, and divide. Then the input decimal string can be converted to 32-bit binary by iterating through each digit in the string from the left side and iteratively perform multiplies of the accumulating result by 10 and adding on the current digits value. Conversion of the resulting 32-bit binary value to hexadecimal is as simple as unpacking each 4-bit nibble of the value and converting the 0 to 15 value of the nibble to 0-9/A-F as the hexadecimal representation of the nibble. As Andy Neil has been known to say from time to time...... "it's not rocket science". Michael Karas |
Topic | Author | Date |
BCD TO HEXA IN ASSEMBLY | 01/01/70 00:00 | |
Think about it | 01/01/70 00:00 | |
School task | 01/01/70 00:00 | |
RE: Do you think you would even understand the code? | 01/01/70 00:00 | |
Fundamental Issue Here | 01/01/70 00:00 | |
Conversion vs Representation - and meaning of "BCD" | 01/01/70 00:00 | |
bcdtohex code in assembly | 01/01/70 00:00 | |
hardly | 01/01/70 00:00 | |
How to *usefully* post code | 01/01/70 00:00 | |
1 month later, and an identical post appears on Keil | 01/01/70 00:00 |