return to main page

Programing hints, tricks and gotchas for the 1401

Comparisons
Ken Shirriff < ken.shirriff@gmail.com > wrote Jan 24, 2015
... One question: what's the best way to deal with signed vs unsigned numbers? The signs keep messing things up for me, e.g. comparisons don't work like I'd expect: 1 is higher than -2 which is higher than -1 which is higher than +0. Is there a trick to using signs without going crazy? (And is there a way to stop infinite loops without killing ROPE?)


Paul Laughton < paul.laughton@gmail.com > wrote January 24, 2015
... The 1401 Tiny Basic source code has some good examples of how to do compares on 1401 signed numbers.
Open the code in an editor and search for "XLT" That code does the Less Than (<) compare. It is followed by XEQU (=) and XGT (>), The code compares two variables, NV1 and NV2.


Michael Albaugh < m.e.albaugh@gmail.com > wrote January 24, 2015
While I heartily acknowledge that the situation is unlikely to arise unless you are a "whale" wagering in Zimbabwe Dollars, you might want to toss a BAV in there. One of the nice things about (someŽof) the older machines (lost in some of the new ones) is a "sticky" Overflow flag.

> Thus I avoided the complexities of Compare. I admit that I am not sure what happens when -0 is subtracted from -0. The answer might be -0, which could send me to LOSING when breaking even.

I just tried -0 - -0 (on the simulator) and got a perfectly cromulent -0, which BM was happy to consider "negative". This was pretty much what I expected.

Testing on an actual 1401 is left as an exercise to (someone).

JOB TEST OF 1401 -0 HANDLING.
* ASSEMBLE WITH COMMAND
* AUTOCODER -L MZTEST.LIS -O MZTEST.OBJ -BV MZTEST.AC
CTL 6111
ORG 333
* GENERATE -0. HECK, GENERATE TWO.
MZGEN ZS @0@,MIN#3
ZS @0@,SUB#3
* SUBTRACT -0 FROM -0.
S SUB,MIN
MZ BM MZ,MIN
PZ B PZ
END MZGEN

return to main page