Note: all mnemonics in this group end with letter "F" indicating "Fiksni zarez" arithmetic. However, this is only true for addition, subtraction and negation. Multiplication and division assume that the "point" is fixed to the right of least significant bit - that is that the numbers are integer.
SABF - adds parameter to the accumulator
ODUF - subtracts the parameter from the accumulator
MNOF - Multiples the accumulator with the parameter
ODU - subtracts the parameter from the accumulator
MNO - Multiples the accumulator with the parameter
DEL - Divides the accumulator by the parameter
PZA - Changes the sign of the accumulator
Bitwise/logical
KON - performs logical AND with the parameter and the accumulator and stores the result in the accumulator
DIS - performs logical OR with the parameter and the accumulator and stores the result in the accumulator
NEG - performs logical NOT on the content of the accumulator
Note: above operations are all bitwise. Their names imply that they are purely logical operations but they can be explained as if they operate on vectors of bits and separately apply logical operations on each pair of bits.
The NAR 2 assembly language syntax was designed to be straightforward and easy to parse. Each program line may contain up to one instruction specified as follows:
Sample code: aum X1, p, 0 mua n, 1 aum 15 pir X1, p, n, 1 mua X1, p, n, 0 oduf n, 1 oduf X2, p, n, 0
Addressing modes
With four address mode selection bits, NAR 2 instructions can specify 16 different addressing modes but not all make sense in all instructions. In the following table:
Note 1: "N" flag has no effect on jump instructions, as the processor can not jump into a specified value, but only to a memory address.
Multi-level memory indirect
NAR 2 supports multi-level memory indirect addressing mode. The location is first chosen by "looking" at P and R flags. Then, if I flag is detected, a 32-bit word is loaded from the memory location calculated so far and the calculation is restarted. Thus, the following program, if loaded at memory location 0 and executed: mua I, 0 ; Memory-Into-Accumulator, Indirect, from location 0 ... will freeze NAR 2 in an infinite address calculation loop:
"I, 0" specifies that the actual address is to be loaded from memory location 0
"I, 0" specifies that the actual address is to be loaded from memory location 0
Memory location 0 is loaded. It reads "I, 0" again
"I, 0" specifies that the actual address is to be loaded from memory location 0
Memory location 0 is loaded. It reads "I, 0" again
...
Note that: mua R, I, 0 ; Memory-Into-Accumulator, Relative, Indirect, from location BN+0 seems more generic, but this depends on when BN register value is incremented/changed. The question of treatment of "N" flag in presence of I flag is open as the situation is somewhat ambiguous—that is, whether or not to honour the flag value specified in the original instruction or the one in the indirectly specified address leads to a conflict. The table above presents the first case to show different addressing modes achievable this way.
NAR 2 has instructions to initialize the value of particular index register. However, it does not have special instructions to read values index registers. This is achieved by using indexed and immediate addressing mode flags, such as: mua Xi, P, N, n ; Memory-Into-Accumulator, Indexed, Immediate, 0 ... which essentially puts Xi+n into accumulator. For n=0, this turns into a "load index register value into accumulator" instruction.