In the process of working on a new Driver Tutorial for the ESPBasic Series I am looking today to implement some Decimal-to-BCD and BCD-to-Decimal subroutines.
What I have done so far:
1. BCD-to-Decimal subroutine:
[DEC]2. Decimal-to-BCD subroutine:
hv = val >> 4
hl = val and 15
val = hv*10 + hl
wait
[BCD]
d = int( val / 10 )
d1 = d * 10
d2 = val - d1
val = d*16 + d2
wait
3. Test Program
let val = 96
textbox val
button "To DEC", [DEC]
button "To BCD", [BCD]
wprint "<br><br>"
button " Exit ", [TestExit]
wait
[TestExit]
end
If you have any other idea please feel free to share it, looking forward to see smarter solutions that that. I'm sure they are!
Happy breadboarding,
TJ.
No comments:
Post a Comment