MIDI-OX User Forum (http://www.midiox.com/cgi-bin/yabb/YaBB.pl)
HP16C Emulator >> HP16C Bug Reports >> Conditional tests take wrong branches
(Message started by: RickN on Jan 6th, 2015, 11:51pm)

Title: Conditional tests take wrong branches
Post by RickN on Jan 6th, 2015, 11:51pm
I am using version 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.

Title: Re: Conditional tests take wrong branches
Post by Jamie OConnell on Jan 21st, 2015, 12:22pm
Thanks for the report!  I will look into it.

MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB 2000-2003. All Rights Reserved.