HP Forums

Full Version: Do nothing at $20005 (HP-42S Assembly programming)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi!

I have recently started to look at the possibility to program the HP-42S in Saturn Assembly. One of the first tasks I have been been trying to achieve is to return safely to the RPN context from the language ROM area, called by the XFCN (therefore the subject of this posting: "Do nothing at $20005").

The snippet below seems to work fine in Emu42 (I have also tested it on a rev A HP-42S with the 2 x 32K RAM upgrade as suggested by Nelson M Sicuro), but is this the correct way to do this?

* Language ROM Detect Constant
CON(5) #5AC3F
* Return to RPN context, drop one stack level
A=C A
C=RSTK
C=A A
A=DAT0 A
D0=D0+ 5
* Rev A = 10D5F, Rev C = 10DE1
GOVLNG #10D5F

Or just entered directly into the monitor:

20000: F3CA5DA07D61421648DF5D01 (Rev A)
20000: F3CA5DA07D61421648D1ED01 (Rev C)

Best regards,


Erik Ehrling (Sweden)


Homepage:http://www.hp42s.com

Hello Erik,

Don't do anything except GOVLNG #10DE1 (or #10D5F) because D0 points to the next byte of the instruction and not to the next RPL address! In the case of XFCN (and all instructions from this category), D0 points to the first byte of the alpha argument.

For example, if you execute XFCN "ABCDEF", D0 points to F7 F1 41 42 43 44 45 46 sequence of bytes. You don't have to restore D0 or manipulate (drop anything from) the return stack in your code because the firmware will do this for you.

BTW, I am usually returning with GOVLNG #15D8A (Rev C) which is the same as =xNEXT (#10DE1) but it enables stack lifting as well.

Best regards.