4 ms·
> "Test condition, decrement, and branch". All in one instruction The Z80 had that too - DJNZ (Decrement and Jump if Not Zero). Standard way of writing loops.
by Doctor_Fegg 4y ago
> "Test condition, decrement, and branch". All in one instruction
The Z80 had that too - DJNZ (Decrement and Jump if Not Zero). Standard way of writing loops.
- drfuchs 4y agoThe IBM 360 had BCT back in 1964. Rumor had it that it was created for Fortran DO statements (“for-loops”), but IBM’s compiler never emitted it. “The BCT instruction subtracts 1 from the value of the contents of the target register specified in the first argument. If the value in the target register after the subtraction is zero, no branch occurs. Otherwise the program branches to the specified address.”
- ataylor284_ 4y agoThe 8080 lacked this, but even though the 8086 was more or less based on the 8080, this probably inspired the 8086 LOOPNZ instruction. Same idea, hardcoded to use the CX register instead of B on the Z80. The unoffical nicknames for the AX, BX, CX, DX were accumulator, base, count, and data. CX was used for the count for all looping and string move instructions. Similarly, BX was special purpose for indirect operations and AX/DX for certain logic and arithmetic instructions.
- bonzini 4y agoAX/CX/DX/BX (in machine code this is the order from 000 to 011) were intended as equivalent to AF/BC/DE/HL.
- tom_ 4y agoDJNZ only does the decrement and branch if zero part. That's implicit in DBcc, which also initially checks the condition and is equivalent to NOP when true.
- classichasclass 4y agoPowerPC bdnz says hi, though it is restricted to one special purpose register (CTR, the counter).