From comp.sys.handhelds Tue Jan 22 12:03:40 1991 Path: mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!know!news.cs.indiana.edu!msi.umn.edu!noc.MR.NET!gacvx2.gac.edu!hhdist From: CW%APG.PH.UCL.AC.UK@pucc.PRINCETON.EDU Newsgroups: comp.sys.handhelds Subject: Message-ID: <4B9CED9060006598@gacvx2.gac.edu> Date: 22 Jan 91 15:56:50 GMT Lines: 200 To: HANDHELDS@gac.edu Return-path: <@pucc.PRINCETON.EDU:CW@APG.PH.UCL.AC.UK> To: HANDHELDS@gac.edu Via: UK.AC.UCL.PH.APG; 21 JAN 91 12:06:16 GMT Hi everybody, This message contains three bits ,i) an apology ii) an explanation iii) a couple of routines and iv) a thankyou, sorry this massage contains four bits,i) an apology ii) an explanation iii) a couple of routines and iv) a thankyou oh and v), ah damn it, start again, this massage contains five bits, i) an apology ii) an explanation iii) a couple of routines,iv) a thankyou and v) an apology for being so silly at the beginning of this posting. i) I'm sorry I can not put a subject header on my posting because of the software we are using at my end (its hard enough to actually post this). So for the man who wants to know what this is for (I actually think its a very reasonable request) this posting is for HP48SX (the routines were written on a version D machine please let me know if they fail on other versions). ii) It appears that (sorry more waffle) for a while now I have been posting my messages to the wrong place, and not everybody (infact not many people atall I think) have been receiving my messages. I am therefore posting again my two most recent routines. I apologise to anyone receiving these once more, but I'd like them to get onto c.s.h.... Thankyou to Dan Boehlke for informing me of my misdirection and sending back my mail so I can reduce the amount of retyping. It actually means that I have tidied up the presentation a bit. (that the thankyou otu of the way so no part iv) !!) iii) In the latest edition of DATAFILE (the journal of the Handheld and Portable Computer Club) there was an excellent article by Stephen J. Thomas, which inspired me to write these routines for the HP48. The begin and end program markers (<< and >>) are not infact necessary on a completed program that does not need to be edited. They act as markers to tell the calculator not to execute commands as they are entered but rather save them until the whole lot within the markers is used as a program. e.g. If you have an empty stack and press + you get + error: too few arguaments. However if you press 'left-shift' <<>> + ENTER you get the program << + >> on the first level of the stack. The <<>> have prevented the + from being executed immediately. The important thing is that the fact that the + is in a program is not due to it being surrounded by the <<>> but that the object has a prolog header 02d9dh which means it is a program (type 8). If you use ->ASC on << + >> you get "D9D20E163276BA193632B21304710" Which if unthreaded becomes, 02D9D PROGRAM BEGIN (This makes it type 8) 2361E << 1AB67 + 23639 >> 0312B END MARKER (In this case end program) 0147 Checksum Amazingly enough this is equivalent to 02D9D PROGRAM BEGIN 1AB67 + 0312B END FFB5 Checksum Differing only in the fact that you can not edit it (without those markers when you finish the edit the calculator will try to execute the commands immediately) and it takes 5 less bytes. Oh and also on the stack you would no longer see the <<>>. Try "D9D2076BA1B21305BFF" ASC-> you get 1: + If you do TYPE you get 8 which shows it is considered a program. (Note if you do $ + OBJ-> the + on the stack returns type 18 which means it is considered as a built in command) What this all means is that once a program is finished you can remove the <<>> around it and save five bytes. I know this is not alot but used in conjuction with Joseph Horn's PACK routine, it just adds that little extra saving. One day you might be desparate for memory and stripping all the <<>>'s from your programs just might save the day.... Any way I now give a routine, one called STRIP and , aah I give two routines (;-)) one called STRIP which removes the <<>>'s from around any program in level 1 of the stack. And one called DRESS which puts the <<>>'s back on a program object in level 1: just incase you want to edit it later. STRIP is very small small (17.5 bytes) but unstrip is a bit bigger (49), can anybody make it smaller ( I found it was difficult to get the << >> separately on the stack). PROGRAM: STRIP ACTION: 1: Program with <<>> delimiters -> 1: Program without <<>> delimiters eg \<< SIN + \>> STRIP will produce SIN + ROUTINE: << #54afh SYSEVAL @Explode composite object #3e4eh SYSEVAL @Subtract two from SB at level 1 #60f9bh SYSEVAL @Drop level 2 object #5445h SYSEVAL @Build program #60f9bh SYSEVAL @Drop level 2 object >> Check: 5230h In this form it is editible but takes up 87.5 bytes. Type in the above routine and store it in a variable called STRIP. The do 'STRIP' RCL PACK STRIP 'STRIP' STO. STRIP will now look like (pack is Joseph Horns routine) External External External <2d9dh> External External PROGRAM: UNSTRIP ACTION: Program without <<>> delims -> Program with <<>> delims e.g. 1: SIN + becomes 1: << SIN + >> << #54afh SYSEVAL #3e2dh SYSEVAL << >> @empty program delimiters in side program. #54afh SYSEVAL #3244h SYSEVAL #3223h SYSEVAL #611feh SYSEVAL #3defh SYSEVAL #339eh SYSEVAL #3223h SYSEVAL #5445h SYSEVAL >> This does the reverse of the stripper i.e. an unstripped program such as SIN COS + becomes << SIN COS + >> snd you can then edit this normally and then strip it again. in this form it takes 189 bytes and has checksum #9a56h (seeing as theres a lot of sysevals it seems sensible to give this). If you use J.K.Horns Pack routine and my strip routine it reduces to 54 bytes and #7200h as its checksum. WARNING: THESE ROUTINES DO NO ERROR CHECKING THEY BEHAVE ERRATICALLY WHEN ANYTHING OTHER THAN A PROGRAM IS ON LEVEL 1 OF THE STACK. DISCLAIMER: Anything that happens as a result of these routines is not my responsibility. iv) Another thankyou. Thankyou to the people who have so bravely laid down the memory of their calculators in the search for the lost entry point. v) Sorry for being so silly at the beginning of this posting. Regards and enjoy and explore Conrad winchester.