[comp.sys.handhelds] Internal Argument Checking

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

In article <41777@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. 
Cloos) writes:

> Back in September, someone posted the addresses of routines you can
> SYSEVAL to convert strings to names and visa-versa.  As I understood
> it, these addresses did no argument checking.  .............. 
> 
> There is one oddity here I would like to note  ..............
> ......... the prefixed machine routine at <#18FB2h> checks whatever is
> on stack in level one (better be something there :) to see if its TYPE 
> is appropriate to your program.  The format is:
>
> 18FB2 : cck for type
> nnnnn : <xh> where x is the short integer at address #nnnnnh
>
> Now, PRG\-> used the short int <8h> to check for a program; this
> matches the user language (usrlang) TYPE command's output when given a
> program.  Similarly, I used <9h> for an algebraic as the TYPE of an
> algebraic is 9.  For S\->N I tried to use <2h>, as the TYPE of a
> string is 2.  This did not work; it turns out that you have to use
> <3h> with the routine at #18FB2h to check for a string.  <2h> will
> check for a complex number.  <1h> tests for a real.  <5h> does test
> for a list, and it turns out that <4h> will test for any array, real
> or complex, 1D or 2D, and given the internal structure of the arrays,
> I'd assume it would accept arrays of strings, etc., as well.
>

Internal types for some objects differ from that of those which the TYPE
command returns (page 97 of the reference manual).  Perhaps not everyone
saw the TYPE RPL disassembly recently posted by Jan Brittenson.  While
not all of the conversions are apparent, most of them can be determined
with out having to disassemble and study the machine code.  In order to
alleviate any further confusion, I'm posting some of the more frequently
used types internally along with several prefixed machine routines used
to check arguments.  Lastly, I've included two routines that exemplify a
multiple argument checking application.

Rick Grevelle


                     Internal Object Type Numbers

      Stack Object            Type Number            ROM Address

        Any                	<0h>		   	#3FEFh
        Real number        	<1h>		   	#3FF9h
	Complex number	   	<2h>		   	#4003h
	String		    	<3h>			#400Dh
	Real array		<4h>			#4017h
	Complex array		<4h>			#4017h
	List			<5h>			#4021h
	Global name		<6h>			#402Bh
	Local name		<7h>			#4035h
	Program			<8h>			#403Fh
	Algebraic		<9h>			#4049h
	Algebraic/Global	<Ah>			#4053h
	Binary integer		<Bh>			#405Dh
	Graphics object		<Ch>			#4067h
	Tagged object		<Dh>			#4071h
	Unit object		<Eh>			#407Bh
	XLIB name		<Fh>			#4085h
	

                       
                          ROM  Checking Routines
        	 	

        	Address	  	    Routine Description
	
	         18A68		checks for 3 stack arguments
	         18A8D		checks for 2 stack arguments
		 18AB2		checks for 1 stack argument
		 18B7A		checks for 5 stack arguments
		 18B9F		checks for 4 stack arguments
		 18F9D		checks stack arguments type 
		 18FA9		checks stack arguments type
		 18FB2		checks stack arguments type

	 

							
PSERS

02D9D	begin_RPL
18F8D	need_2_stack arguments
18FA9	check_2_arguments_for_type_
64C70	<56h>_list(2)_global(1)
02D9D	begin_RPL
549CC	list_{ 'dvar }_(local name)
074D0	store_local_variable(s)_1{locals}2any...nany
054AF   list->
03FF9	short_integer_<1h>
073F7	start_n(2)_to_n(1)_1short2short
03223	swap
549DB	'dvar  (local name)
07221	current loop count
18DBF   short_integer->real
1B02D	^
1ADEE	*
1AB67	+
07334	next
0312B	end RPL
0312B	end RPL


CPSERS
(BYTES: #7350h 157.5)


%%HP: T(1)A(D)F(.);
\<<
 # 18FA918A8D02D9Dh
 # D0549CC02D9D64C7h
 # 3F703FF9054AF074h
 # 7221549DB0322307h
 # 1ADEE1B02D18DBF0h
 # B0312B073341AB67h
 # 312h 1 6
 START # 5193h
  SYSEVAL
 NEXT # 4003h
 SYSEVAL # 62B9Ch
 SYSEVAL 
\>>


PSERS  (reqires ASC\->)

%%HP: T(1)A(D)F(.);
"D9D20D8A819AF8107C46D9D20CC9450D470FA4509FF307F37032230BD9451227
 0FBD81D20B1EEDA176BA143370B2130B213097C6"%%HP: T(1)A(D)F(.);


PCOEF

02D9D	begin RPL
18A68	need_3_stack_arguments
18F9D	check_3_arguments_for_type_
65008	<A61h>_algebraic/name(3)_global(2)_real(1)
02D9D	begin_RPL
18CEA	real->short_integer
03223	swap
549CC	list_{ 'dvar }_(local name)
074D0	store_local_variable(s)
59373	polynomial->coefficients
03188	dup
03E2D	add_2_1short
0400D	short_integer_<2h>
073F7	start_n(2)_to_n(1)_1short2short
07221	current_loop_count
03223	roll
07334	next
05459	->list
0312B	end RPL
0312B	end RPL


CPCOEF
(BYTES: #7350h 157.5)

\<<
 # 818F9D18A6802D9Dh
 # 2318CEA02D9D6500h
 # 373074D0549CC032h
 # 400D03E2D0318859h
 # 332507221073F70h
 # B054590733403223h
 # 312B0312h 1 6
 START # 5193h
  SYSEVAL
 NEXT # 4003h
 SYSEVAL # 62B9Ch
 SYSEVAL
\>>


PCOEF (requires ASC\->)

%%HP: T(1)A(D)F(.);
"D9D2086A81D9F8180056D9D20AEC8132230CC9450D4703739588130D2E30D004
 07F3701227052330322304337095450B2130B213083C9"