8 bit signed to LED's
I am starting to write a assembly program for a mc68hc12. I will be reading a 8
bit signed number into PortA and outputting the results to 7 segment LED's, common anode. I will be using Port P to output the segments and PortCan to control the LED's displayed. I assume I need 4 LED's, 1 for the sign and 3 LEDs for the max number of 128. How would I go about pulling the data in from a port and then displaying the number on a set of LED's? Is there a straight forward way to do the signed number conversion using a lookup table or do I need to go through a more in depth conversion algorithm? I'm not sure how to handle the input number once I read it from PORTA, should I store it in memory or work with it directly. I am new to assembly programming so pardon the simple questions, how would I pull off the digits of the inputed number to convert? Thanks 
Re: 8 bit signed to LED's
Quote:

Re: 8 bit signed to LED's
Quote:
s there a straight forward way to do the signed number conversion using a lookup table or do I need to go through a more in depth conversion algorithm?  
Re: 8 bit signed to LED's
I don't see the point of Clayton's posts.
Easiest way if you've got the space is a 3*256byte lookup table (3*256, because if you have 3 7segment displays plus a sign, that's 22 bits, which will fit into 3 bytes). (You can generate the table with a quick C program on your PC.) You could do it with less space and more code: let's say X is the signed byte. First determine the sign (look at bit 7), then negate X if it's negative. Then modulo X by 10 to get the least significant decimal digit and divide X by 10. If it's zero then you can bail out early. Otherwise modulo X by 10 to get the second least significant decimal digit, divide X by 10 again and what's left should be the final digit. So suppose you have X=123. Step 1: sign=1, X=123 Step 2: LSD=3 (because 123 mod 10 is 3), X=12. If you have a function that will divide by 10 and give you the dividend and remainder (i.e. input 123, output 12 and 3) then that would be useful here. Step 3: 2LSD=2, X=1 Then you can use a 10byte lookup table to convert 09 to the respective 7segment bits, which will depend on the wiring. Counting clockwise from the topmost LED with the last one in the middle, 0 would be 01111110, 1 would be 00110000, 2 would be 01101101 etc. Code:
One way of numbering the LEDs: 
All times are GMT +5.5. The time now is 14:21. 