‹ BackHN Continuity

Thread

Unearthing my 1996 windowed OS in machine code for Am29000 homebrew computer

130 points · 31 comments · nanochess

  1. Joker_vD · · focus · HN ↗
    > The subtraction instruction has a set with reversed operands, so we have SUB, SUBU, SUBS, SUBC, SUBCU, SUBCS, but also SUBR, SUBRU, SUBRS, SUBRC, SUBRCU, SUBRCS.

    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.

    1. ronsor · · focus · HN ↗
      The BIOS originates from an era where most or all of the OS software was burned to a ROM on the computer. Then disks arrived and we wanted more, but we didn't want the OS to implement drivers for every hardware configuration. There wasn't enough room. Then there was enough room and it turned out BIOS functions mostly sucked.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.