HP50g -- first foray into assembly lang and sysrpl



Having become reasonably familiar with my new hp50g, and at least
introduced myself to most of the user RPL commands, I thought I should
finally bite the bullet and have a go at some System RPL.

Oddly enough, I was was already fairly familar with Saturn assembly
language; I have owned an HP-71B since about '85 (IIRC) and enjoyed
adding a few extensions to its Forth language. I thought sysrpl
should be fairly easy in comparison. Not so sure now.

Well, enough of my background. On to the background of my questions.

I thought an interesting first challenge would be the old Mastermind
style game, "Cows and Bulls". The vanilla flavour of this game
wouldn't require great speed, but I have a variant where the computer
keeps track of possible candidates. After each of your guesses,
besides telling you so many cows and bulls, it goes through the set
of remaining candidates, eliminating those which wouldn't match this
result and tells you how many candidates remain. For example:

Guesses C B
1274 0 1
3579 1 1
6978 0 1 Possible: 3

(FYI, the remaining candidates are: 1538 3258 6534)

There is clearly quite a bit of processing early on when all 3024
candidates are still valid and a combination of sysrpl and assembly
language seemed to be called for (of course it would be cheating to
use C or ARM!).

At long last, down to my questions:

1. How should I structure shared functions in assembly language?

Having implemented the candidate list as a bitmap (just a grob), I
need one function to clear a bit when a candidate is eliminated
and another to test a bit in order to count candidates after a
guess.

The majority of the code for setting or testing a bit is identical
and I have put that code in a "PixPrep" function which returns
address and mask in registers. This code is included in the
"bmreset" function's CODE block. I have another function,
"bmtest", which calls PixPrep in the guts of "bmreset". This
works -- as long as I store the library in port 0, fails in any
other port -- but it seems dodgy. To make this clearer (maybe),
here is the skeleton:

....
NULLNAME bmtest
::
CODE
GOSUB PixPrep *** Calling inside bmreset NULLNAME block
C=C&A P
....
GOVLNG =PUSH#ALOOP
ENDCODE
;


NULLNAME bmreset
::
CODE
GOSUB PixPrep
C=-C-1 P
....
GOVLNG =GETPTRLOOP
*
* Input grob pix# on stack
* Output
* A[0] Pixel nibble's current value
* C[0] Mask of pixel
* D1 Address of pixel's nibble
* Changed
* B
*
PixPrep
GOSBVL =POP#
GOSBVL =SAVPTR
....
RTN
ENDCODE
;

....

I can see options like passing a function selector on the stack,
but I don't find that particularly appealing. I'd really like
there to be multiple known entry points within one code block.
I've probably missed this somewhere in the documentation.

2. Where is there a clear summary of the syntax differences in the
flavours (HP, MASD, others?) of sysrpl and of assembly language?

I was used to HP's Saturn instruction set and have been using
Debug4x as a development environment for this exercise, but I
would like to get away from the PC (Windows in particular)
and MASD is right there on the calculator.

Besides this, I have been confused from time to time when
tutorials downloaded from hpcalc.org were referring to a
syntax that wasn't available in the other environment. IIRC,
I couldn't find an MASD equivalent of HP's NULLNAME, but I bet
it has one. Also took me a while to work out the need for
FEXTERNAL for entry points introduced by "^".

3. Is there any documentation like the HP-71 IDS for entry points?

I had to poke around with Nosy (which is brilliant) to work out
that POP1% sets decimal mode and calls SAVPTR, both of which need
to be catered for before returning. Something warning me of
significant side-effects would be very welcome.

On the whole, I have been pleased with what I have managed to get to
grips with in the last two weeks. While I've had a 48SX since '92,
I never went beyond user RPL with it; there was paid work to do, and
that was Unix/C, so no time to get into my calculator's intricacies.
Consequently, I have missed out on all the history that has led to the
rather baroque interface that's there today. Pretty daunting to get
a handle on it now, but I don't mind a challenge.

Have fun,

Robert.
--
Robert Swan | No, not the antarctic adventurer.
swan.r.l@xxxxxxxxx | No, not the Canberra porn monger.
| Yes, that's right, the boring one.
.



Relevant Pages

  • Re: HP50g -- first foray into assembly lang and sysrpl
    ... introduced myself to most of the user RPL commands, ... adding a few extensions to its Forth language. ... keeps track of possible candidates. ... How should I structure shared functions in assembly language? ...
    (comp.sys.hp48)
  • Re: HP50g -- first foray into assembly lang and sysrpl
    ... NULLNAME is used for library entry that have no 'name'. ... adding a few extensions to its Forth language. ... keeps track of possible candidates. ...
    (comp.sys.hp48)
  • Its Official: Americans Want English
    ... It's Official: Americans Want English ... and services in any language requested by any recipient of federal ... among the 2008 presidential candidates. ... questions would be asked in Spanish, ...
    (alt.politics.bush)
  • Re: Does a normalized design lead to complex queries?
    ... well as the skills are separated into different tables. ... The language table is defined in a similar way. ... So candidates has attributes: first name, last name, id, DOB, height, ... (that master French OR (Dutch AND German)) ...
    (comp.databases)

Loading