From: James M. Prange on
Correction:

I wrote:

<snip>


> My code detects the models in the order 48SX/S,
> 48GX/G/G+, 50g, 48gII, 49G, thus the least code is actually
> executed for a 48SX/S and the most for a 49G.

Make that:

My code detects the models in the order 48SX/S, 48GX/G/G+, 50g,
49g+, 48gII, 49G, thus the least code is actually executed for a
48SX/S and the most for a 49G.

<snip>

--
Regards,
James

From: Veli-Pekka Nousiainen on
"James M. Prange" <jmprange(a)i-is.com> wrote in message
news:15053$459729dd$4267ebcc$28875(a)123.NET...
X
> Veli-Pekka, should I post my code now?

> Actually, I'm a bit disappointed that this mini-challenge doesn't
> seem to have generated much interest.

> Surely being able to determine which hardware a program is running
> on can be useful, and this demonstrates that the current models
> can be distinguished even by UserRPL source code. One could branch
> to run different code depending on the model, or simply error out
> with a user-defined error string like "wrong model" if it's run on
> a model that it's not intended for.

So the Bronze goes to Tim "Joker" Wessman
and you release your code and we'll see who is titled to GOLD & Silver
:-(

> As far as I know, the easiest way to determine the ROM version on
> the 48SX/S is \<< #30794h SYSEVAL \>> (SysRPL VERSTRING command),
> which returns a string of the form "HPHP48-x", where x is the ROM
> version letter from A through J on a 48SX/S or K through R on a
> 48GX/G/G+ (but note that some versions were never released).

Well one could have that on an *expanded* version
which gives the distinguist version also, SYSEVAL accepted
no challange anymore...just acatemic interest

Both versions (the expanded, too) should go to the
www.hpcalc.org
in the Programming section of both 48 and 49:
The code is _exactly_ the same for all models
*and* UserRPL compatible.





From: James M. Prange on
Veli-Pekka Nousiainen wrote:
> "James M. Prange" <jmprange(a)i-is.com> wrote in message
> news:15053$459729dd$4267ebcc$28875(a)123.NET...
> X
>> Veli-Pekka, should I post my code now?
>
>> Actually, I'm a bit disappointed that this mini-challenge doesn't
>> seem to have generated much interest.
>
>> Surely being able to determine which hardware a program is running
>> on can be useful, and this demonstrates that the current models
>> can be distinguished even by UserRPL source code. One could branch
>> to run different code depending on the model, or simply error out
>> with a user-defined error string like "wrong model" if it's run on
>> a model that it's not intended for.
>
> So the Bronze goes to Tim "Joker" Wessman
> and you release your code and we'll see who is titled to GOLD & Silver
> :-(

Okay, here's my current program:


%%HP: T(3)F(.); @ ASCII transfer header.
@ Program for determining model.
@ Arguments: None
@ Returns:
@ 0 for 48SX/S
@ 1 for 48GX/G/G+
@ 2. for 49G
@ 3. for 49g+
@ 4. for 48gII
@ 5. for 50g
@ For 49 series, download or enter in exact mode.
@ Results from the BYTES command:
@ 48SX/S:
@ Checksum: # 1C81h
@ Size: 234.5
@ 48GX/G/G+:
@ Checksum: # 8C3Ah
@ Size: 226.5
@ 49 series:
@ Checksum: # 6B95h
@ Size: 203.5
@ Approximate execution times in seconds:
@ Average of 10 trials each model.
@ 48SX: .1961
@ 48GX: .1772
@ 49G (ROM 2.09): .6417
@ 49g+ (ROM 2.09): .1827
@ 48gII (Emulated, ROM 2.09): .3221
@ 50g (Emulated, ROM 2.09): .1416
@ Approximate Time*Bytes values:
@ 48SX: 45.98
@ 48GX: 40.13
@ 49G (ROM 2.09): 130.6
@ 49g+ (ROM 2.09): 37.18
@ 48gII (Emulated, ROM 2.09): 65.54
@ 50g (Emulated, ROM 2.09): 28.81
\<< @
RCLF @ Get current flags, leave on stack.
-55 SF @ Force last arguments off.
64 STWS @ Force wordsize.
"'LQ'" @
IFERR @
STR\-> @ STR\-> compiles "'LQ'" to global name on 48SX/S,
@ but errors out on other models.
THEN @ Not 48SX/X.
CASE @
NOVAL TYPE 14 == @ NOVAL is type 19 on 49 series.
THEN @
1. @ 48GX/G/G+.
END @
VERSION @
DROP @ Discard the Copyright string.
11 11 SUB "5" == @ will be "4" for 48gII or 49G.
THEN @
5. @ 50g.
END @
LCD\-> @
SIZE @
SWAP DROP @ Discard width.
#50h == @ #50h on 49g+ or 50g, otherwise #40h.
THEN @
3. @ 49g+
END @
1. @
IFERR @
PVARS @ 1. PVARS errors out on 48gII, works on other 49
@ series.
THEN @
4. @ 48gII
ELSE @
DROP2 @ Discard port variable list and
@ available port capacity.
2. @ 49G
END @ End of "inner" IFERR structure.
END @ End of CASE structure.
ELSE @
DROP @ Discard 'LQ'.
0. @ 48SX/S.
END @ End of "outer" IFERR structure.
SWAP @ Move flags list down to level 1.
STOF @ Restore original flags.
\>> @


My earlier version differed in that it didn't include 64 STWS and
used "'NOVAL'" instead of "'LQ'".

Comments, bug reports, or suggestions for improvement are welcome.

>> As far as I know, the easiest way to determine the ROM version on
>> the 48SX/S is \<< #30794h SYSEVAL \>> (SysRPL VERSTRING command),
>> which returns a string of the form "HPHP48-x", where x is the ROM
>> version letter from A through J on a 48SX/S or K through R on a
>> 48GX/G/G+ (but note that some versions were never released).
>
> Well one could have that on an *expanded* version
> which gives the distinguist version also, SYSEVAL accepted
> no challange anymore...just acatemic interest
>
> Both versions (the expanded, too) should go to the
> www.hpcalc.org

Well, maybe, but as John noted, often a shorter test, such as for
the screen size, the availability of a "mass storage" port, or
which I/O ports are available, will suffice.

> in the Programming section of both 48 and 49:
> The code is _exactly_ the same for all models
> *and* UserRPL compatible.

Well, the *source code* is the same for all models, so will work
from an "ASCII" ("Text") transfer, but it will compile to 3
different program objects, depending on whether it's entered on a
48SX/S, a 48GX/G/G+, or a 49 series, thus binary transfers from
one of these groups to another won't work.

It seems to me that developing a version that would compile to
exactly the same program object on all models would be quite a
task, but for all I know, it may be possible.

--
Regards,
James

From: John H Meyers on
On Sun, 31 Dec 2006 05:05:53 -0600, per James M. Prange:

NOVAL TYPE 14 == @ NOVAL is type 19 on 49 series.

Why not eliminate the chance of a variable
(or even a library command) named NOVAL, e.g.:

DUP SIZE 3 < @ Flag list is shorter on 48 series

Actually, if you want to rely on NOVAL,
"{NOVAL" STR\-> 1 GET TYPE yields:
48G[X] ==> 14
49... ==> 19
48S[X] ==> 6

So you wouldn't need another "'LQ'" STR\->

But just to warn of the potential for being fooled,
all of the above are only *probable* results -- why?

Consider that although VARS is generally a command,
I have a *variable* (type 6) named VARS in my 48G[X]
(for a 50-fold speed increase :),
others have a ROMPTR (type 14) named VARS in their 48GX
(same reason, when HACK library is installed),
and the same can actually occur with any name at all,
so likewise nothing is guaranteed about NOVAL.

Another (very minor):

11 11 SUB "5" == @ 11 DUP is 8 bytes shorter

It's not inconceivable that one "Code" object might actually
be devised to work on all series and models, using only addresses
in a range which is the same on all of these; I would also
not mind if it returned more than one result, such as:

ROM series for entry points (0/1 for 48 vs 49),
keyboard (0/1/2/3 for 48S/48G/49G/later)
screen dimensions (perhaps a sublist), etc.,
all returned in one list would be okay (and expandable),
which are individually more important results
for any programs that could use such generalized tests.

More optional results?

o Highest port number?

o [nominate, petition, vote (early and often :)]

[r->] [OFF]
From: Veli-Pekka Nousiainen on
"James M. Prange" <jmprange(a)i-is.com> wrote in message
news:e024e$45979995$4267eaf1$10204(a)123.NET...
X
>> So the Bronze goes to Tim "Joker" Wessman
>> and you release your code and we'll see who is titled to GOLD & Silver
X
>> Both versions (the expanded, too) should go to the
>> www.hpcalc.org
>
> Well, maybe, but as John noted, often a shorter test, such as for
> the screen size, the availability of a "mass storage" port, or
> which I/O ports are available, will suffice.
>
>> in the Programming section of both 48 and 49:
>> The code is _exactly_ the same for all models
>> *and* UserRPL compatible.
>
> Well, the *source code* is the same for all models, so will work
> from an "ASCII" ("Text") transfer, but it will compile to 3
> different program objects, depending on whether it's entered on a
> 48SX/S, a 48GX/G/G+, or a 49 series, thus binary transfers from
> one of these groups to another won't work.


Source code compatibility on an interpreted language is enough, IMO

I think that the purpose was
1) to show off some programming skills
2) to show that it's possible in UserRPL and benefit on it
eg. the final code will find it's way to the
www.hpcalc.org