HP 42S: Difference between revisions

6 bytes added ,  08:34, 25 March 2022
m
no edit summary
No edit summary
mNo edit summary
Line 28: Line 28:
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, specifically, the hardware XM flag used for this error is not cleared explicitly in software but seems to rely on a hardware operation to reset. 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, specifically, the hardware XM flag used for this error is not cleared explicitly in software but seems to rely on a hardware operation to reset. 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 the first register.
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 to hex. 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 126: Line 126:
## Navigate to memory address 40300 using Up/Down, Divide/Multiply, Substract/Add keys, note the leftmost value should be "7"
## Navigate to memory address 40300 using Up/Down, Divide/Multiply, Substract/Add keys, note the leftmost value should be "7"
## Write one nybble using keyboard (0h-9h) and top row keys (Ah-Fh) to set desired speed, linearlly scaling with 7h as normal speed. ON key cannot be pressed starting from this step.
## Write one nybble using keyboard (0h-9h) and top row keys (Ah-Fh) to set desired speed, linearlly scaling with 7h as normal speed. ON key cannot be pressed starting from this step.
## Navigate to memory address 00000, see step 1.2. then press "." (decimal point) to execute from that location. "Machine Reset" should appear.
## Navigate to memory address 00000 (see step 1.2). then press "." (decimal point) to execute from that location. "Machine Reset" should appear.
## Verify machine speed has been modified using BEEP command.
## Verify machine speed has been modified using BEEP command.
# Use Bug 2 (see Known Bugs) to automate setting of this mode (applicable to A revision):
# Use Bug 2 (see Known Bugs) to automate setting of this mode (applicable to A revision):
Line 132: Line 132:
## Shift+Backspace (CLEAR) then choose "REGS", deleting the variable matrix.
## Shift+Backspace (CLEAR) then choose "REGS", deleting the variable matrix.
## Press Sigma+ (A key), "Invalid Type" error should appear.
## Press Sigma+ (A key), "Invalid Type" error should appear.
## key in 16248, then RCL IND STX (keystrokes: RCL, "." (decimal point), A, "." (decimal point), B). This will recall the nybble at address (16248+184) x 16=40300 which we just modified.
## key in 16248, then RCL IND STX (keystrokes: RCL, "." (decimal point), A, "." (decimal point), B). This will recall the nybble at address (16248+184) x 16 = 40300h which we just modified.
## STO "FAST", store the value we just retrieved for future use in variable "FAST".
## STO "FAST", store the value we just retrieved for future use in variable "FAST".
## Create a program as listed below, optionally named "FAST":<syntaxhighlight lang="text" line="1" start="00">
## Create a program as listed below, optionally named "FAST":<syntaxhighlight lang="text" line="1" start="00">
Line 144: Line 144:
SF 25
SF 25
SIGMA+
SIGMA+
8124              # indirect pointer for indirect STO to write to, correspond to memory 40300h
8124              # indirect pointer for indirect STO to write to, (8124x2+184)x16=40300h
X<> "FAST"        # swaps stack X and "FAST", this is the nybble data we edited earlier
X<> "FAST"        # swaps stack X and "FAST", this is the nybble data we edited earlier
STO IND "FAST"    # indirectly store to patch memory 40300h
STO IND "FAST"    # indirectly store to patch memory 40300h
60

edits