From:
conv_high, mid and low contain the converted BCD components of a single $byte; the_val is the input value containing the hexidecimal value to be converted. #hundreds = #100 #tens = #10 #ones = #1 bcd_conv clr conv_low zero out temp storage for new conversion clr conv_mid clr conv_high hun stc ;set carry flag for test sub the_val,#hundreds ;subtract and check flag jnc ten ; if =0, done with hundreds conversion inc conv_high ;carry is set, so inc high bcd byte jmp hun ;check again to see if over 200 in value ten clc ;clear carry first (carryx) add the_val,#hundreds ;need to correct for underrun first ten_a stc ;set carry flag for test sub the_val,#tens ;subtract and check flag jnc one ; if =0, done with tens conversion inc conv_mid ;carry is set, so inc middle bcd byte jmp ten_a ;check again to see if any more 10s value one clc ;clear carry first (carryx) add the_val,#tens ;correct for underrun but in tens now. one_a stc ;set carry flag for test sub the_val,#ones ;subtract and check flag jnc ascii_correct ;if =0, done with 1s conversion-prepare for ascii inc conv_low ;carry is set, so inc low bcd byte jmp one_a ;check again to see if any 1s left in value ascii_correct clc ;adds $30 to each bcd digit for correct output to lcd add conv_high,#$30 ;now should display on lcd correctly clc ;since carryx, clear c add conv_mid,#$30 clc add conv_low,#$30 clc ;house cleaning clear the carry clz ;clear the zero flag
Questions:
hehe, I see my code was posted (8bit to BCD unpacked 3 digits)James Newton replies: You still get credit for finding the code, recognizing its value, translating it to the SX and, most important, sharing it! THANK YOU!
and it's nice for the ego trip, but I converted from an old
listing I found for the 8031 (I thought I mentioned that in
the posting?). There is nothing new under the sun, and the old
saying that 95% of all code is just borrowed is true.
I had originally registered as I believe,as wunnerful2@qwest.net
but don't quote me. I was in a war with screwest.net before
they sold themselves to msn, and lost (royally trashed with
dsl, and my dedicated modem at the CO being redirected to the
highest paying INC!). Yeah I know, I'm whining and should get to the point- hehee, I don't remember my log in password,
and to boot, which of the last 2 or 3 email addresses I used
to log in with (wunnerful1@cox.net presently).
If you need more info, let me know. Haven't used the SX for
a project for the last few years (the one using the posted
code was for a 16x2 readoutof oil pressure, water temp ect.
for a GL1500). Thinking about doing a fuel injection system
for an old Harley shovelhead, since the SX is fast enough
to do the job...just wondering about external mem addressing,
since internal mem can't hold the type of map required for
such.
Eric Swendson
You can recover your passcode just by registering again (use only your email address if you are pressed for time) and it will be emailed to you.
I (we) ALWAYS need more info! (GRIN) Send everything you can, PLEASE!
Thanks for all your support Eric, you have been a great help to this community.