Hex > Dec
GMW
Posts: 2
··
·Is there a way to take·the hex number in one of the register and convert
·it to decimal so one might serial it out to Hyper terminal?
·
·
····················· Thank you, Gary
·Is there a way to take·the hex number in one of the register and convert
·it to decimal so one might serial it out to Hyper terminal?
·
·
····················· Thank you, Gary
Comments
Since the SX only works in binary format, I am assuming that what you are really saying is that you have a register that has a number that can be expressed as a hex number (eg: register holds %11111111 which is equal to $FF which is equal to 255)·
To output this number to Hyperterminal you would need to send the ASCII charactors '2' then '5' then '5'.· So, first·subtract 100 from the·register, and count how many times you can do this without getting a result less than 100.· That is your 100's count.
Then subtract 10 from the register, and count how many times you can do this without getting a result less than 10.· That is you 10's count.
The remainder is your 1's count.
Now send the 100, 10 and 1's count to a serial out routine.··Remember you must convert to ASCII (Add $30).
Nate
I "assume" there is a SEROUT command in SX/Basic too (with similar features).
What about assembly?
(Beating orginal poster to the punch on follow up, and curious for myself.)
Begin Edit:
Ignore this post, it was a reply to a response referencing "regular" basic STAMP code that was deleted.
I'm leaving this in place as some of the following·posts reference this post.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
Post Edited (John R.) : 12/27/2005 8:35:55 PM GMT
Nate
mov backup2,backup1
hunderd sub backup1,#100
sc
jmp decimal
inc honderd
mov backup2,backup1
jmp hunderd
decimal mov backup1,backup2
decimall sub backup1,#10
sc
jmp unit
inc tiental
mov backup2,backup1
jmp decimall
unit mov backup1,backup2
mov eenheden,backup1
add eenheden,#48
add tiental,#48
add honderd,#48