HP Calculator Enthusiast
Conditional tests take wrong branches
« on: Jan 6th, 2015, 11:51pm »
I am using version 2.1.0.036 of the emulator. Load this "minimum value" program:
x><y (x exchange y)
With default calculator settings it will work as expected. For example, 5 ENTER 8 GSB A results in the minimum value of 5. But set 4-bit unsigned math (4 WSIZE UNSGN) and it returns the wrong answer of 8. The real HP-16C gives the right answer of 5.
My guess is that the 8 conditional tests ("Conditional Tests" on p88 of my April 1982 manual) do not correctly account for all complement modes. There is a caveat in the manual on p88 saying "in 1's comp -0 = +0" that shows the implementation of the tests takes into account 2's comp, 1's comp, or unsigned. Likely in this case 8 (unsigned 1000) gets interpreted as -8 (2's comp 1000) and as such is less than 5. I found this working on a program that involves 4-bit unsigned registers to hold BCD digits.