[comp.sys.handhelds] ->PRG & PRG-> RPL Versions

n233dk@tamuts.tamu.edu (Rick Grevelle) (10/11/90)

In article <3464@mindlink.UUCP> a634@mindlink.UUCP (Rob Prior) writes:
>I remember there being a couple of programs for my 28s called PRG-> and ->PRG.
>They functioned as follows:
>
>on the stack:
>
>4:
>3:
>2:
>1:     << RCL DUP PURGE >>          (or whatever)
>
>PRG-> executed would give:
>
>6:                    <<
>5:                   RCL
>4:                   DUP
>3:                 PURGE
>2:                    >>
>1:                     5            (this all being accomplished
>                                     through the use of sysevals)
>
>->PRG would take the stack in part 2 and give you what you started with.  After
>all, we can get all of the symbols (<<, >>, RCL, etc.) onto the stack with
>sysevals.  Is there a way to implement the same programs on the 48sx?  If
>someone could post their solution, it would be muchly appreciated.
>
>Thanks in advance,
>Rob


With all of the machine patching routines that have been posted, I incorrectly
assumed everyone already knew what it was I was doing.  Thanks for asking the
question; eventhough there are apparently those who have yet to see the value
of such a command, I'm quite sure there are others who would like to have this
highly convenient tool at their disposal.  Why HP left this command out of the
OBJ-> command is a mystery to me. 



054AF   list->, algebraic->, program->
05445   ->program
05459   ->list
0546D   ->algebraic


These SYSEVALs do no argument checking and could be potentially dangerous if
misused.  To alleviate this I've included two short routines which will create
versions of ->PRG and PRG-> that will do the necessary argument checking.  For
the reason that these routines are of a relatively short size of, I see no need
for posting an encoded version.  RPL disassemblies are included for clarity.
 


CPRG-> 
(BYTES: #46D6h 82.5) 

%%HP: T(3)A(D)F(.);
\<<
 # F18FB218AB202D9Dh
 # 312B1C9730403h
 # 5193h SYSEVAL
 # 4003h SYSEVAL
 # 62B9Ch SYSEVAL
\>>
 

PRG-> 

02D9D	begin RPL
18AB2   need one argument from stack
18FB2	check one argument for type
0403F   short integer <8h>, program
1C973   program->
0312B   end



C->PRG
(BYTES: #D79h 82.5)  

%%HP: T(3)A(D)F(.);
\<<
 # B0544518C3402D9Dh
 # 312h # 5193h
 SYSEVAL # 4003h
 SYSEVAL 62B9Ch
 SYSEVAL
\>>


->PRG

02D9D   begin RPL
18C34	need n arguments from stack
05445   ->program
0312B   end


For PRG-> I prefer to use the two prefixed machine routines # 18AB2h and 
# 18FB2h, rather than # 18ECEh, for the reason they don't give all of the
added garbage in the error message.  The only disadvantage is it takes
two of them to do what # 18ECEh does alone.

As for as the ->PRG routine is concerned, I've yet to find a more suitable
address for checking in this situation.  The error message it returns will
contain the extraneous information "XLIB 25 45" before the actual message.

One final note; both routines here will be created without their user program
delimiters.  If for some reason this is annoys you, ->PRG and PRG-> can be 
used to to install the missing delimiters.  The two routines can also be used
to remove delimiters from programs as well.  Be carefull though, there are
actually three sets of these delimiters used by the 48, two of which are used
for nesting routines within programs.  You could alter the intended results.


Rick Grevelle

cloos@acsu.buffalo.edu (James H. Cloos) (10/18/90)

In article <8979@helios.TAMU.EDU> Rick Grevelle posts the 2 programs
\->PRG and PRG\->.  He also mentions the addresses of routines to do
\->ALG, plus that the routine used to do PRG\-> also will break up an
algebraic or a list.  We already have LIST\-> and \->LIST, he gave us
PRG\-> anmd \->PRG, so here, based on his routines (to check for args,
etc.) are ALG\-> and \->ALG:

They are in ASC form, in the following directory:

===========CUT==============BEGIN==============
%%HP: T(3)A(R)F(.);
DIR
  ALG\->.ASC
"D9D202BA812BF8194040379C1B2130C3D2"
  \->ALG.ASC
"D9D2043C81D6450B2130474F"
END
-_-_-_-_-_-CUT-_-_-_-_-_-_-_-END-_-_-_-_-_-_-_-

These routines work exactly like those Rick posted; the decomp is:

ALG\->
02D9D	:	::
18AB2	:	need one arg from stack
18FB2	:	check one argument for following type
04049	:	<9h>
1C973	:	program->, algebraic->, list->
0312B	:	;

\->ALG
029D9	:	::
18C34	:	need % n arguments from stack {% n == real_n}
0546D	:	->algebraic
0312B	:	;

Now, in the start of his article, he listed 0x054AF as the address of
the alg,list,prg-> routine, but used 0x1C973 in his programs.  I used
the 0x1C973 as I didn't notice this at first; it does work, though,
with algebraics.

With these, you can easily convert between algebraic and rpn display
formats; this could be helpful in understanding rpn if you don't
already.

(Please backup before playing with, just in case.)

-JimC
--
James H. Cloos, Jr.		Phone:  +1 716 673-1250
cloos@ACSU.Buffalo.EDU		Snail:  PersonalZipCode:  14048-0772, USA
cloos@ub.UUCP