TX-2 / TX-2-simulator

Simulator for the pioneering TX-2 computer
https://tx-2.github.io/
MIT License
21 stars 2 forks source link

Unsigned arithmetic doesn't implement TX-2 carry scheme #113

Open jamesyoungman opened 1 year ago

jamesyoungman commented 1 year ago

Describe the bug The Unsigned36Bit type has a checked_add method which performs addition. But the semantics of this addition more-or-less match Rust's addition semantics. But on the TX-2 there are 4 overflow bits, end-around carry and so on. This will mean that implemeting the ADD instruction with checked_add will fail to handle a number of corner cases. Similarly for the handling of addition in the assembler.

To Reproduce See (e.g.) examples 4 and 5 for the ADD instruction (page 3-59 of the Users Handbook). They detail carry behaviour that checked_add doesn't do.

Presumably the assembler is supposed to be performing arithemetic in configuration 0, but there's still the end-around carry to consider even for that case.

Expected behavior TBH this requires a better understanding of the operation of ADD in the TX-2 than I have right now.