Shop OBEX P1 Docs P2 Docs Learn Events
Hex > Dec — Parallax Forums

Hex > Dec

GMWGMW Posts: 2
edited 2005-12-27 20:37 in General Discussion
··
·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

  • NateNate Posts: 154
    edited 2005-12-27 18:33
    (This answer is for SASM, not SX/B)

    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
  • John R.John R. Posts: 1,376
    edited 2005-12-27 18:37
    Not at home, so I can't check, but:

    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
  • NateNate Posts: 154
    edited 2005-12-27 19:07
    My previous post was for assembly (SASM).

    Nate
  • KiwiKiwi Posts: 85
    edited 2005-12-27 19:41
    to get the hunderds Dec and unit from a byte 0..255

    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
  • KiwiKiwi Posts: 85
    edited 2005-12-27 19:42
    sorry for the bad layout
  • Lord SteveLord Steve Posts: 206
    edited 2005-12-27 20:37
    So why don't you edit your layout?
Sign In or Register to comment.