[comp.sys.handhelds] HP48: to/from hexadecimal string program

akcs.dnickel@hpcvbbs.UUCP (Derek S. Nickel) (02/24/91)

Included in this posting are two simple routines, ->HEX and HEX->.
These routines are very similar to Bill Wickes' ->ASC and ASC->, in fact
they are stripped-down versions of ->ASC and ASC->.

The differences are:

* No checksums are involved.  This means you can 'create' objects
  without having to figure out the checksum.

* No line-feeds.  This means you don't have to figure out where they
  go.

* Because no checksums are needed, be careful!  Actually providing a
  checksum can cause a Memory Lost - maybe not imeadiatly, but soon
  after Garbage Collection.

* Do not include line-feeds, they can/will cause problems.

* For the most part these routines are for creating fairly small
  objects, but can be used for larger objects.

* Also: these routines are for 'development'.  When you're all done
  building your program/object, use ->ASC to post it (please!)

* Any other differences are totally a figment of you imagination.

Contained below are Voyager listings and ->ASC strings for these
routines.

        Derek S. Nickel

------------------------------------------------------------
80000: ; *** ->HEX ***
80000: 02D9D ! Program
80005: 1592D ; Clear current command and verify DEPTH >= 1
8000A: 03188 ; Internal DUP
8000F: 05944 ; Internal BYTES (non-ROM objects) -> (2:System
Binary,1:Binary Integer)
80014: 03244 ; Internal DROP
80019: 055DF ; ""
8001E: 032C2 ; Internal OVER
80023: 03E6F ; Internal multiply by 2 (1:System Binary)
80028: 61C1C ; allocate nibbles (2:sized object,1:System Binary)
8002D: 03223 ; Internal SWAP
80032: 02DCC ! Code
80037: 00065 ! 101 nibbles (next RPL at 8009C)
8003C: 8F14660    GOSBVL 06641          ; MC: pop stk1 (System Binary)
                                        ; into A.A
80043: CC         A=A-1  A
80045: 8FB9760    GOSBVL 0679B          ; MC: save D0,D1,B,D (uses
                                        ; C,D0), clear carry
8004C: D8         B=A    A
8004E: 143        A=DAT1 A
80051: 130        D0=A
80054: 169        D0=D0+ 10
80057: 174        D1=D1+ 5
8005A: 143        A=DAT1 A
8005D: 131        D1=A
80060: AE2        C=0    B
80063: 15F0       C=DAT1 1
80067: 8082103    LAHEX  30             ! "0"
8006E: A62        C=C+A  B
80071: 8082193    LAHEX  39             ! "9"
80078: 9EEC0      ?A>=C  B
  GOYES  80087
8007D: 8082170    LAHEX  07             ! "."
80084: A62        C=C+A  B
80087: 14C        DAT0=C B
8008A: 161        D0=D0+ 2
8008D: 170        D1=D1+ 1
80090: CD         B=B-1  A
80092: 5DC        GONC   80060
80095: 8D34150    GOVLNG 05143          ; MC: restore D,B,D1,D0 (C=D0),
                                        ; clear carry and continue RPL
 . . . . . . ! End of Code
8009C: 60F9B ; drop level two object
800A1: 0312B ! End Marker

%%HP: T(3)A(R)F(.);
"D9D20D2951881304495044230FD5502C230F6E30C1C1632230CCD20560008F14
660CC8FB9760D8143130169174143131AE215F08082103A6280821939EEC0808
2170A6214C161170CD5DC8D34150B9F06B2130D91B"

------------------------------------------------------------
80000: ; *** HEX-> ***
80000: 02D9D ! Program
80005: 1592D ; Clear current command and verify DEPTH >= 1
8000A: 18FB2 ; Check arguments for type
8000F: 0400D ; <3h>
80014: 02D9D ! Program
80019: 03188 ; Internal DUP
8001E: 05636 ; Internal SIZE (bytes) (1:String) -> System Binary
80023: 055DF ; ""
80028: 032C2 ; Internal OVER
8002D: 61C1C ; allocate nibbles (2:sized object,1:System Binary)
80032: 03223 ; Internal SWAP
80037: 02DCC ! Code
8003C: 00070 ! 112 nibbles (next RPL at 800AC)
80041: 8F14660    GOSBVL 06641          ; MC: pop stk1 (System Binary)
                                        ; into A.A
80048: CC         A=A-1  A
8004A: 8FB9760    GOSBVL 0679B          ; MC: save D0,D1,B,D (uses
                                        ; C,D0), clear carry
80051: D8         B=A    A
80053: 143        A=DAT1 A
80056: 130        D0=A
80059: 169        D0=D0+ 10
8005C: 132        AD0EX
8005F: 130        D0=A
80062: 141        DAT1=A A
80065: 174        D1=D1+ 5
80068: 143        A=DAT1 A
8006B: 131        D1=A
8006E: 179        D1=D1+ 10
80071: AE2        C=0    B
80074: 14F        C=DAT1 B
80077: 8082103    LAHEX  30             ! "0"
8007E: B62        C=C-A  B
80081: 8082190    LAHEX  09             ! "."
80088: 9EEB0      ?A>=C  B
  GOYES  80096
8008D: 808207     LAHEX  7
80093: B62        C=C-A  B
80096: 15C0       DAT0=C 1
8009A: 160        D0=D0+ 1
8009D: 171        D1=D1+ 2
800A0: CD         B=B-1  A
800A2: 5EC        GONC   80071
800A5: 8D34150    GOVLNG 05143          ; MC: restore D,B,D1,D0 (C=D0),
                                        ; clear carry and continue RPL
 . . . . . . ! End of Code
800AC: 60F9B ; drop level two object
800B1: 0312B ! End Marker
800B6: 0312B ! End Marker

%%HP: T(3)A(R)F(.);
"D9D20D29512BF81D0040D9D208813063650FD5502C230C1C1632230CCD200700
08F14660CC8FB9760D8143130169132130141174143131179AE214F8082103B6
280821909EEB0808207B6215C0160171CD5EC8D34150B9F06B2130B21308086"