ND-100 Status Flags
This article is a stub. You can improve NDWiki by expanding it. |
The ND-100 status register (STS) bits
Page Table Modus
Bit 0: PTM, Page Table Mode
Rounding Indicator
Bit 1: TG, rounding indicator for floating point operations
One Bit Accumulator
Bit 2: K, one bit accumulator
Error Indicator
Bit 3: Z, error indicator
Dynamic Overflow Indicator
Bit 4: Q', dynamic overflow indicator
Static overflow Indicator
Bit 5: O, static overflow indicator
Carry Indicator
Bit 6: C, carry indicator
The carry indicator is set/reset by add/subtract instructions like ADD, SUB, RADD, RSUB, AAA, AAX, AAT, AAB, but also by RMPY and RDIV. It is both set/reset and used by add with carry, RADD ADC.
How the carry flag is set on addition is well defined, but there are different ways of setting carry on subtraction. Norsk Data uses a method which can most easily be explained as follows: All addition and subtraction is done by a three-way adder, and the carry flag is set if a carry occurs from the sign bit position of the adder.
Example 1:
Addition (using a 4-bit word for simplicity): Add 4 and 1:
0100 0001 0 ----- 0101
Carry not set.
Example 2:
Add 12 and 5:
1100 0101 0 ----- 10001
Carry set.
Example 3:
Subtraction: One common method for subtracting binary values is to add the first value to the two's complement of the second value. Norsk Data instead performs subtraction by adding the first value to the one's complement of the second value, plus one:
Subtract 0 from 4:
0100 1111 1 ----- 10100
Carry set.
The answer is thus 4, as expected, and carry flag set. This gives a different result than if subtraction had been done via two's complement addition:
0100 0000 ----- 0100
Carry not set (this is not the ND method).
The three-way Norsk Data adder can be managed explicity with the RADD instruction, which has modifiers like AD1 (add one), or ADC (add carry), and CM (One's complement). AD1 and ADC cannot be used at the same time, either one of them can set the single bit third operand of the adder.
The carry flag as set by ND on subtraction is exactly inverted compared to how the carry flag is set on Intel x86 by its 'sub' instructions. 1-0 sets carry on ND but resets it on x86. The ND-500 carry flag behaves the same way as the Nord-10/ND-100, as can be seen explicitly by its TEST instruction which always sets carry (the ND-500 TEST instruction is an "N minus 0" operation, i.e. test against zero).
Multi-shift Link Indicator
Bit 7: M, multi-shift link indicator
Program Level Indicator
Bits 8-11: PL, program level indicator
N-100
Bit 12: N-100, ND-100 indicator
Extended Address Mode
Bit 13: SEXI, extended address mode indicator
Memory Management On Indicator
Bit 14: PONI, memory management on indicator
Interrupt System On Indicator
Bit 15: IONI, interrupt system on indicator
References
- Norsk Data Document ND–06.014.02 ND-100 REFERENCE MANUAL
- Norsk Data Document ND–06.029.01 ND-110 Instruction Set
- Norsk Data Document ND–05.009.3 NORD-500 REFERENCE MANUAL