??? 10/15/06 11:42 Modified: 10/15/06 11:51 Read: times |
#126479 - What is the question? Responding to: ???'s previous message |
You tell us that the routine is supposed to convert hex to bcd. How are we supposed to know what it does? There are no comments on what the code is doing so we would have to analyse it. It would probably be faster to write the code from scratch to do what you want. Nevertheless, what have you done apart from stare at the code for two hours? Have you tried to break it down piece by piece to understand what it is actually doing?
For example: mov B,#16 MOV B,#10 MOV A,R2 DIV AB MOV R3,B ; The first two lines are suspicious - what value does it want in B? 16 or 10? At a guess, if it wants to convert a value to BCD one would suggest the value be 10 - this value being the last loaded into B actually wins. It then goes onto divide the value in R2 by 10 and puts the result in R3. Please don't think that just because we are experienced that we can decipher a piece of code just be merely looking at it briefly - what if the code is defective? This all takes time and what is the net result? Would you have learned anything from this? I would suggest you break down the code into little chunks like above and write a brief comment and what it does. After a couple of iterations, you should see a picture emerge. You could also try the code in a simulator and run it step by step and see what is actually happening. Also, I doubt that it actually converts hex values - hex is merely a representation of the value as base16, the value itself is stored in memory as a series of '1's and '0's - it can be represented as a base16 or base10 etc..but as such, it is not stored as hex. A better description is that it might convert the byte value to a bcd representation, or word value etc... |
Topic | Author | Date |
Meaning of this coding | 01/01/70 00:00 | |
What is the question? | 01/01/70 00:00 | |
dodgy stuff | 01/01/70 00:00 | |
why not![]() | 01/01/70 00:00 |