HP 42S: Difference between revisions

907 bytes added ,  11:11, 3 February 2022
Memory layout WIP
(2 known bugs for HP-42s.)
(Memory layout WIP)
Line 26: Line 26:
The first HP-42s bug relates to the COMB (combination) and PERM (permutation) instructions. Nominally these two instructions calculates C(y,x) = y!/(x!*(y-x)!) and P(y,x) = y!/(y-x)!. Since factorial is strictly positive, an input of x<y correctly raises "Invalid Data" error. However this error flag is not correctly cleared, for example when using x<>y and executing the respective command again, and will require an arbitrary arithmetic operation to correctly clear (for example 0 +). This bug has been reported in all revisions except some mid-serial-range revision A machines, and is believed to be a software-hardware interfacing issue. A simple workaround is to always to prepend the command with x<y? x<>y (check if x<y and swap if true).
The first HP-42s bug relates to the COMB (combination) and PERM (permutation) instructions. Nominally these two instructions calculates C(y,x) = y!/(x!*(y-x)!) and P(y,x) = y!/(y-x)!. Since factorial is strictly positive, an input of x<y correctly raises "Invalid Data" error. However this error flag is not correctly cleared, for example when using x<>y and executing the respective command again, and will require an arbitrary arithmetic operation to correctly clear (for example 0 +). This bug has been reported in all revisions except some mid-serial-range revision A machines, and is believed to be a software-hardware interfacing issue. A simple workaround is to always to prepend the command with x<y? x<>y (check if x<y and swap if true).


The second HP-42s bug is far more interesting: All register values are stored in a matrix called "REGS" on HP-42s. If one were to delete this matrix and then execute a statistic input (i.e. CLV "REGS" then Sigma+), forcing an "Invalid Type" error, RCL and STO in this state will, instead of recalling and storing to registers, directly read from and write to memory. The memory location RCL will read from is calculated as (RegisterNbr + 184) x 16 converted to hexadecimal, and the location STO will write to is (RegisterNbr x 2 + 184) x 16. Sometimes the offset is also reported as +183 which is due to how resgister on HP-42s is numbered from 00 to 99 and up to the value in SIZE. In that case R00 would count as register 1.
The second HP-42s bug is far more interesting: All register values are stored in a matrix called "REGS" on HP-42s. If one were to delete this matrix and then execute a statistic input (i.e. CLV "REGS" then Sigma+), forcing an "Invalid Type" error, RCL and STO in this state will, instead of recalling and storing to registers, directly read from and write to memory. The memory location RCL will read from is calculated as (RegisterNbr + 184) x 16 converted to hexadecimal, and the location STO will write to is (RegisterNbr x 2 + 184) x 16. Sometimes the offset is also reported as +183 which is due to how resgister on HP-42s is numbered from 00 to 99 and up to the value in SIZE. In that case R00 would count as the first register.


== Hardware Mods ==
== Hardware Mods ==
Line 34: Line 34:
<nowiki>*</nowiki>note: the top row of keys are customarily labeled A-F from left to right.
<nowiki>*</nowiki>note: the top row of keys are customarily labeled A-F from left to right.


HP 42s has two resets: Master reset which puts the calculator back to "factory condition", clearing all memory with On+A+F and Machine reset with On+C which interrupts any program, clears certain flags and sets the calculator into a state ready to receive user input again. As with the HP 27S and HP 17B, the self test is triggered with On+D. On the first screen of the self test routine hitting backspace (<-) will put the calculator in debugger. In this state the Up/Down keys, Divide/Multiply keys, Add/Substraction keys can be used to increment or decrement the current memory address by 1000,100 and 1 nybble(s) respectively.
HP 42s has two resets: Master reset which puts the calculator back to "factory condition", clearing all memory with On+A+F and Machine reset with On+C which interrupts any program, clears certain flags and sets the calculator into a state ready to receive user input again.  
 
As with the HP 27S and HP 17B, the self test is triggered with On+D.
 
On the first screen of the self test routine hitting backspace (<-) will put the calculator in debugger. In this state the Up/Down keys, Divide/Multiply keys, Add/Substraction keys can be used to increment or decrement the current memory address by 1000,100 and 1 nybble(s) respectively. Number keys, and A-F keys will key in (replace) the current memory address with the hexadecimal value 0-9 and A-F and move by 1 nybble forward. Backspace key will refresh the debugger and . (decimal point) key executes from this memory location. the COS key will move the memory address by 10 nybbles and print the memory at that location to IR, which can be then received by a HP-48 using INPRT to [https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=266 dump the ROM].
 
== Memory Layout ==
Due to having its ROM dumped and emulators developed (and many exploration prior) the memory layout of the HP-42s is generally well know:
{| class="wikitable"
|+
!Address Start (hex)
!Address End (hex)
!Content
!Note
|-
|00000
|1FFFF
|ROM
|
|-
|40000
|4020C
|Display
|Column 0, 66, 1, 67 ........ 64, 130, 65 with 4 nybbles per column for 16 pixels, 131 columns in total.
|-
|
|
|
|
|}
60

edits