From alonzo@microsoft.UUCP Thu Aug 16 13:14:21 1990 From: alonzo@microsoft.UUCP (Alonzo GARIEPY) Newsgroups: comp.sys.handhelds Subject: Machine Code Version of Hexify Date: 14 Aug 90 19:23:25 GMT Reply-To: alonzo@microsoft.UUCP (Alonzo GARIEPY) Organization: Microsoft Corp., Redmond WA I am posting this for Rick Grevelle, who doesn't have direct access to net news. The following is a machine code version of HEXIFY. It takes a string of hexadecimal digits and converts them into an object. This routine can be used as a replacement for the HEXIFY in my HP28S Processor Notes, or in conjunction with Rick's improved version of same. This posting is only for those who have some understanding of the information in the notes. The code will also work on the HP48, with the minor modifications noted in the comments (changing the value of two object prologs and CHEXIFY if necessary). alonzo -------------------------------------------------------- From: Rick Grevelle Newsgroups: comp.sys.handhelds Subject: Machine Code Version of Hexify #00000: #143 move.a @d1,a #00003: #132 swap.a a,d0 #00006: #100 move.w a,r0 #00009: #146 move.a @d0,c #0000c: #06 push.a c #0000e: #dd swap.a b,c #00010: #10a move.w c,r2 #00013: #164 add.a #5,d0 #00016: #142 move.a @d0,a #00019: #d6 move.a a,c #0001b: #136 swap.a c,d0 #0001e: #164 add.a #5,d0 #00021: #c2 add.a a,c #00023: #da move.a c,a #00025: #136 swap.a c,d0 #00028: #819f2 srb.a c #0002d: #06 push.a c #0002f: #137 swap.a c,d1 #00032: #109 move.w c,r1 #00035: #34e4a20 move.p5 #02a4e,c ; HP48: #02a2c #0003c: #8a527 brne.a b,c,abort #00041: #1c5 sub.a #6,d1 #00044: #4c6 brcs abort #00047: #133 swap.a a,d1 #0004a: #dc swap.a a,b #0004c: loop: #0004c: #1c0 sub.a #1,d1 #0004f: #181 sub.a #2,d0 #00052: #14a move.b @d0,a #00055: #3114 move.p2 #41,c #00059: #9eed1 brle.b c,a,alpha #0005e: #3103 move.p2 #30,c #00062: #b6a sub.b c,a #00065: #4b4 brcs abort #00068: #3190 move.p2 #09,c #0006c: #9e624 brlt.b c,a,abort #00071: #1510 move.p a,@d1 #00075: #6910 jump.3 next #00079: alpha: #00079: #b6a sub.b c,a #0007c: #3150 move.p2 #05,c #00080: #9e6e2 brlt.b c,a,abort #00085: #30a move.p1 #a,c #00088: #a0a add.p c,a #0008b: #1510 move.p a,@d1 #0008f: next: #0008f: #cd dec.a b #00091: #5ab brcc loop #00094: result: #00094: #1c4 sub.a #5,d1 #00097: #07 pop.a c #00099: #145 move.a c,@d1 #0009c: #1c4 sub.a #5,d1 #0009f: #07 pop.a c #000a1: #145 move.a c,@d1 #000a4: #111 move.w r1,a #000a7: #133 swap.a a,d1 #000aa: #141 move.a a,@d1 #000ad: #6900 jump.3 exit #000b1: abort: #000b1: #111 move.w r1,a #000b4: #133 swap.a a,d1 #000b7: exit: #000b7: #112 move.w r2,a #000ba: #dc swap.a a,b #000bc: #110 move.w r0,a #000bf: #132 swap.a a,d0 #000c2: #142 move.a @d0,a #000c5: #164 add.a #5,d0 #000c8: #808c jump.a @a NOTE: I've included a program, CHEXIFY, which will create a version of HEXIFY that alleviates the above caveats. The following program works only on the HP 28S. It creates a program on the stack, which can then be stored in 'HEXIFY' and used to create any further machine code programs. CHEXIFY[9BA9] << << "" + A >> 4 # DD60641001231341h # 616316D241461A01h # 1602F918631AD2C4h # 25A802A4E4390173h # 10C1CD3316C45C17h # 131DEE94113A4118h # 26E909134B4A6B30h # 0513A6B019601514h # C0151A0AA032E6E9h # 04C1541704C1BA5Dh # 0961413311115417h # 1011CD2113311110h # C80846124123h 48 STWS #0h OR 64 STWS 1 12 START # 3B82h SYSEVAL NEXT # 7195h SYSEVAL # 44A4h SYSEVAL # 7F77h SYSEVAL # 3F41h SYSEVAL # 3EEBh SYSEVAL >> If you would rather have HEXIFY produce a CODE object every time instead of requiring an object address argument then make these three changes: Note: the addresses that appear before a colon, below, are for reference, and will change with these modifications. They are not used except by the code itself. i) Delete the instruction #0000c: #06 push.a c ii) Replace the instruction #0009f: #07 pop.a c with #0009f: #3469C20 move.p5 #02c96,c ; HP48: #02dcc iii) Adjust the following branch addresses by 5 nibbles #0003c: #8a527 brne.a b,c,abort #00044: #4c6 brcs abort #00065: #4b4 brcs abort #0006c: #9e624 brlt.b c,a,abort #00080: #9e6e2 brlt.b c,a,abort to #0003c: #8a577 brne.a b,c,abort #00044: #417 brcs abort #00065: #405 brcs abort #0006c: #9e674 brlt.b c,a,abort #00080: #9e633 brlt.b c,a,abort These changes have to be reflected in the data of the CHEXIFY program. You can figure out where to make the modifications. Caveats ------- i) If level 1 does not contain a string the program simply aborts. ii) Each character is checked only as it is processed by the code loop. If at any point the routine encounters invalid code, it aborts, leaving the unfinished result on the stack. iii) Never use this routine on a copy of a string called to the stack that's stored in a variable without first making the stack copy unique. (i.e. "" + ) iv) Once the initial checking is complete, any errors will leave the string only partially converted. Rick Grevelle uunet!tamuts.tamu.edu!n242df From John.Matthews@comp.vuw.ac.nz Wed Aug 22 10:11:39 1990 From: John.Matthews@comp.vuw.ac.nz (John Matthews) Newsgroups: comp.sys.handhelds Subject: Date: 19 Aug 90 21:10:51 GMT Reply-To: tribble@comp.vuw.ac.nz (John Matthews) Organization: Dept. of Comp. Sci., Victoria Uni. of Wellington, New Zealand. RE: Article 1981 of comp.sys.handhelds: Subject: Machine Code Version of Hexify From: alonzo@microsoft.UUCP (Alonzo GARIEPY) Date: 14 Aug 90 19:23:25 GMT Reply-To: alonzo@microsoft.UUCP (Alonzo GARIEPY) Organization: Microsoft Corp., Redmond WA >I am posting this for Rick Grevelle, who doesn't have direct access >to net news. >The following is a machine code version of HEXIFY. It takes a string >of hexadecimal digits and converts them into an object. >This routine can be used as a replacement for the HEXIFY in my HP28S >Processor Notes, or in conjunction with Rick's improved version of same. >This posting is only for those who have some understanding of the >information in the notes. >The code will also work on the HP48, with the minor modifications noted >in the comments (changing the value of two object prologs and CHEXIFY if >necessary). >alonzo >-------------------------------------------------------- >From: Rick Grevelle >Newsgroups: comp.sys.handhelds >Subject: Machine Code Version of Hexify >#00000: #143 move.a @d1,a >#00003: #132 swap.a a,d0 >#00006: #100 move.w a,r0 >#00009: #146 move.a @d0,c >#0000c: #06 push.a c >#0000e: #dd swap.a b,c >#00010: #10a move.w c,r2 >#00013: #164 add.a #5,d0 >#00016: #142 move.a @d0,a >#00019: #d6 move.a a,c >#0001b: #136 swap.a c,d0 >#0001e: #164 add.a #5,d0 >#00021: #c2 add.a a,c >#00023: #da move.a c,a >#00025: #136 swap.a c,d0 >#00028: #819f2 srb.a c >#0002d: #06 push.a c >#0002f: #137 swap.a c,d1 >#00032: #109 move.w c,r1 >#00035: #34e4a20 move.p5 #02a4e,c ; HP48: #02a2c >#0003c: #8a527 brne.a b,c,abort >#00041: #1c5 sub.a #6,d1 >#00044: #4c6 brcs abort >#00047: #133 swap.a a,d1 >#0004a: #dc swap.a a,b >#0004c: loop: >#0004c: #1c0 sub.a #1,d1 >#0004f: #181 sub.a #2,d0 >#00052: #14a move.b @d0,a >#00055: #3114 move.p2 #41,c >#00059: #9eed1 brle.b c,a,alpha >#0005e: #3103 move.p2 #30,c >#00062: #b6a sub.b c,a >#00065: #4b4 brcs abort >#00068: #3190 move.p2 #09,c >#0006c: #9e624 brlt.b c,a,abort >#00071: #1510 move.p a,@d1 >#00075: #6910 jump.3 next >#00079: alpha: >#00079: #b6a sub.b c,a >#0007c: #3150 move.p2 #05,c >#00080: #9e6e2 brlt.b c,a,abort >#00085: #30a move.p1 #a,c >#00088: #a0a add.p c,a >#0008b: #1510 move.p a,@d1 >#0008f: next: >#0008f: #cd dec.a b >#00091: #5ab brcc loop >#00094: result: >#00094: #1c4 sub.a #5,d1 >#00097: #07 pop.a c >#00099: #145 move.a c,@d1 >#0009c: #1c4 sub.a #5,d1 >#0009f: #07 pop.a c >#000a1: #145 move.a c,@d1 >#000a4: #111 move.w r1,a >#000a7: #133 swap.a a,d1 >#000aa: #141 move.a a,@d1 >#000ad: #6900 jump.3 exit >#000b1: abort: >#000b1: #111 move.w r1,a >#000b4: #133 swap.a a,d1 >#000b7: exit: >#000b7: #112 move.w r2,a >#000ba: #dc swap.a a,b >#000bc: #110 move.w r0,a >#000bf: #132 swap.a a,d0 >#000c2: #142 move.a @d0,a >#000c5: #164 add.a #5,d0 >#000c8: #808c jump.a @a ----- There is a bug in the above program, which causes it not to to behave quite like Alonzo's Hexify program. Bug: It does not handle Odd length strings. In Alonzo's Hexify, the Step size of 2, combined with the string SUB function, pads the string out to the correct (even) length. Even length strings work fine, odd strings corrupt the contained programs. Here is a slight fix to the CHexify program to correct this. >>NOTE: I've included a program, CHEXIFY, which will create a >> version of HEXIFY that alleviates the above caveats. >>The following program works only on the HP 28S. It creates a program on >>the stack, which can then be stored in 'HEXIFY' and used to create any >>further machine code programs. Only the sub program and following offset (and the checksum) have been changed, the rest is Ricks. CHEXIFY[C343] << << DUP SIZE IF 2 MOD THEN "0" ELSE "" END + A >> 12 # DD60641001231341h # 616316D241461A01h # 1602F918631AD2C4h # 25A802A4E4390173h # 10C1CD3316C45C17h # 131DEE94113A4118h # 26E909134B4A6B30h # 0513A6B019601514h # C0151A0AA032E6E9h # 04C1541704C1BA5Dh # 0961413311115417h # 1011CD2113311110h # C80846124123h 48 STWS #0h OR 64 STWS 1 12 START # 3B82h SYSEVAL NEXT # 7195h SYSEVAL # 44A4h SYSEVAL # 7F77h SYSEVAL # 3F41h SYSEVAL # 3EEBh SYSEVAL >> >If you would rather have HEXIFY produce a CODE object every time instead of >requiring an object address argument then make these three changes: > > Note: the addresses that appear before a colon, below, are for > reference, and will change with these modifications. They > are not used except by the code itself. > >i) Delete the instruction > #0000c: #06 push.a c > >ii) Replace the instruction > #0009f: #07 pop.a c > with > #0009f: #3469C20 move.p5 #02c96,c ; HP48: #02dcc > >iii) Adjust the following branch addresses by 5 nibbles > > #0003c: #8a527 brne.a b,c,abort > #00044: #4c6 brcs abort > #00065: #4b4 brcs abort > #0006c: #9e624 brlt.b c,a,abort > #00080: #9e6e2 brlt.b c,a,abort > to > #0003c: #8a577 brne.a b,c,abort > #00044: #417 brcs abort > #00065: #405 brcs abort > #0006c: #9e674 brlt.b c,a,abort > #00080: #9e633 brlt.b c,a,abort > >These changes have to be reflected in the data of the CHEXIFY program. >You can figure out where to make the modifications. > >Caveats >------- >i) If level 1 does not contain a string the program simply aborts. > >ii) Each character is checked only as it is processed by the code > loop. If at any point the routine encounters invalid code, it > aborts, leaving the unfinished result on the stack. > >iii) Never use this routine on a copy of a string called to the stack > that's stored in a variable without first making the stack copy > unique. (i.e. "" + ) > >iv) Once the initial checking is complete, any errors will leave the > string only partially converted. > >Rick Grevelle >uunet!tamuts.tamu.edu!n242df John Matthews tribble@comp.vuw.ac.nz Victoria University of Wellington, New Zealand (That's in the Southern Hemisphere)