Unearthing my 1996 windowed OS in machine code for Am29000 homebrew computer
Thread
Unofficial Hacker News client; not affiliated with Y Combinator.
Unearthing my 1996 windowed OS in machine code for Am29000 homebrew computer
Unofficial Hacker News client; not affiliated with Y Combinator.
Joker_vD · · focus · HN ↗
Pretty much the only use of "reversed subtraction" instruction on a 3-operand machine is to implement NEG (subtract from immediate zero) and NOT (subtract from immediate -1, which Am29000 can't actually do since it zero-extends the immediates)... but NOT is usually not a very useful operation on its own anyway, especially when you have an actual ANDN instruction (most of the uses of ~ in C are of "var &= ~mask" or "expr & ~mask" variety) and a whole slew of NAND/NOR/XNOR instructions as well. Oh, and also, if you know for sure that your value is either 1 or 0, you can logically negate it by subtracting it from immediate 1.
On the other hand, on a 2-operand machine "SUBR reg, reg" is a surprisingly useful instruction.
ronsor · · focus · HN ↗