Skip to content

Plan: the ND-5000 '87 extension instructions

This lists the work that remains. What is done is not listed. The instructions, their opcodes, the counts and the manual text are in ND-5000 '87 extension instructions; that page is generated, and its status column shows how far the data is.

What is still unknown, and who or what can settle it, is in ND-5000 '87 extension: what is still needed. The steps below that depend on those answers (NCPLC, SEND, RECVE, WHOLE, TOSSP, RHOLE, AMODB) wait for them.

What is wrong today

Measured on 30 October 2026, after the data and tool changes:

  • In docs/instructions/instructions.json and in nd500-as and nd500-dis, 23 of the 25 '87 instructions are present. AMODB and RHOLE are not (see "Not proven").
  • The emulator (src/cpu/nd500_instructions.c) has a table row, a dispatch entry and a handler for CLINIT and CLREAD (src/cpu/instructions/SYSTEM/Clock.c), REXT and WEXT (src/cpu/instructions/SYSTEM/Wext.c), DDIRT at 0xFE1E and 0xFFFA, CAD, PLCCN (src/cpu/instructions/SYSTEM/Plccn.c) and ENTIER (src/cpu/instructions/FLOAT_MATH/Entier.c). It has no row, no dispatch entry and no handler for NCPLC, SEND, RECVE, WHOLE and TOSSP. An opcode without a handler raises the illegal instruction trap.
  • The emulator's table is a separate file from the data and was not made by nd500-opcodes (its output format differs), so it needs its own rows.

Step 1 - the tools (found 30 October 2026)

The source of all the nd500-* tools is the repository the pcc-nd500 repository (remote RetroCoreLabs/pcc-nd500, local branch main is 2 commits ahead of origin). One table feeds the others:

Tool Source folder under src/ of the pcc-nd500 repository Where its instruction knowledge is
nd500-as (assembler) nd500-as/ instrtab.h, codetab.h, oprndtab.h - the master tables
nd500-opcodes nd500-opcodes/ reads the assembler tables and writes instructions.json, C, C# (Instructionset.Init.cs) and the disassembler header; the installed program counts 538 entries, not 1078
nd500-dis (disassembler) nd500-dis/ nd500_instructions.h, written by nd500-opcodes -f disasm (its header says DO NOT EDIT)
nd500-dump, nd500-ld, nd500-cc/cc1/cc2/cpp, nd500-mkfs, nd500-mkproto, nd500-splitseg, nd500-symorder nd500-*/ not checked whether any of them has an instruction table; the dump, ld and cc2 programs contain no svers/rphs text, so probably not

So the 13 instructions (and the DDIRT correction) go into the assembler tables first, then nd500-opcodes is rebuilt and its outputs regenerated. Still to find out from files, before any change:

  1. Why the installed nd500-opcodes says 538 entries while docs/instructions/instructions.json has 1078 (a newer build, or a different tool).
  2. Where src/cpu/nd500_instructions.c in this repository comes from (nd500-opcodes -f c or something else); it has no generator in this repository.
  3. How the assembler tables are written (by hand, or generated), and whether the docs folder of nd500-as says how to add an instruction.
  4. Opcodes of AMODB and ENTIER are in the manual (sections 10.36 and 10.37): AMODB 0xFFBC to 0xFFC7 (BY, H, W, four registers each; the manual's hex column has the misprint FFCOH for 0xFFC0, the octal column 177700B is right) and ENTIER 0xFDC7 (F) and 0xFDC8 (D). The earlier "not read" was a fault in tools/gen_87_extension_doc.py (it took the manual's table of contents entry instead of the section); fixed. Still to be confirmed against the microcode.
  5. DDIRT: 0xFE1E or 0xFFFA? Check the manual page, the microcode decode and the existing handler src/cpu/instructions/SYSTEM/ DDIRT file and its tests.
  6. Whether the other nd500-* tools need anything (a linker or dump that prints mnemonics, the C compiler back end emitting these instructions).

What the checks found (30 October 2026)

Sources searched: the ND-500 Reference Manual, every other manual and source file in NDInsight, and the ND-5000 microcode with RetroCore's opcode table for it. Only the manual gives opcodes. NDInsight has no other document that does, and RetroCore's table is rebuilt from the manual and the microcode label names, so it is no second source for the opcode values. The microcode proves that a routine with the right name exists.

Group Instructions Decision
Opcode from the manual (octal and hex columns agree) and a microcode routine of that name exists SEND 0xB6, RECVE 0xB7, REXT 0xFFE8-0xFFEB, WEXT 0xFFEC-0xFFEF, WHOLE 0xFE9D, CLINIT 0xFF1E, CLREAD 0xFF1F, PLCCN 0xFFFD, NCPLC 0xFFFE, TOSSP 0xFE9F, ENTIER 0xFDC7 and 0xFDC8 Added to the tables
No microcode routine RHOLE 0xFE9E Not added. The ND-5000 microcode has no RHOLE label and no entry for 0xFE9E.
Manual only, the microcode sends it to the illegal-instruction stub AMODB 0xFFBC-0xFFC7 Not added until the behaviour on the ND-5000 is known
Conflict DDIRT: manual 0xFFFA; data and assembler 0xFE1E Both map to the microcode routine DCDUMP. 0xFE1E is tied to chapter 12 of the ND-5000 Microprogram Guide. So 0xFE1E stays and 0xFFFA is added as a second encoding of the same instruction.

Not proven - to take up with the original CPU designer

Written down because a table entry that cannot be proven is not guessed. Each item says what is known and what is only inferred. Where an item is open, the tools carry the best-supported value and the item stays here until someone who designed the instruction answers.

  1. RHOLE (manual 0xFE9E). The ND-5000 microcode (MICRO-5800-B30) has no RHOLE routine and no entry for that opcode, and NDInsight calls its existence open. Question: does RHOLE exist, and is 0xFE9E right? Not in the tools.
  2. AMODB (manual 0xFFBC to 0xFFC7). The microcode sends every one of these opcodes to its illegal-instruction stub. Question: is AMODB executed in hardware or by trap handling, and on which microcode version? Not in the tools.
  3. DDIRT. The assembler tables (from the NDIX-C assembler) have 0xFE1E; the manual has 0xFFFA; the microcode runs the same routine (DCDUMP) for both. The tools accept both when disassembling and assemble 0xFE1E. Question: which is the real encoding, or are both valid?
  4. Operand rules of the 11 added instructions. The manual gives the format line and the access (read or write) of each operand. The assembler needs more: which addressing modes are allowed, and the operand size. These were copied from the nearest existing instruction with the same format (the instruction named for each in the worksheet), not read from a source. Question: do these instructions accept every general addressing mode, including constants and pre-indexed, for the read operand? For WHOLE: is the operand form the same as SMOVE's string descriptor? For REXT and WEXT: is the device operand a word, any mode?
  5. SEND and RECVE register. The manual shows only W1. The assembler now refuses other registers. Question: is W2 to W4 undefined, or is it just not documented?
  6. TOSSP spelling. The manual's format reads TOSSP := <operand>, the code table TOSSP. The tools use tossp:= like tos:= and cad:=.
  7. Classes (SYSTEM, IO, FLOAT_MATH, MOVE) are chosen by the name rules in nd500-opcodes and are this project's grouping, not the manual's.
  8. Privileged. Which of the 25 are privileged is only what the manual's text says (CLINIT, REXT, SCNTXT and others); instructions where the manual is silent are listed as "not stated".
  9. RIOM, operand 2 (found 1 November 2026). The manual's format is H RIOM <ND-100 addr/r/W>,<buffer/w/H>,<no of halfwords>: operand 2 is written. The assembler table (oprnd_tab entry "riom" in src/nd500-as/oprndtab.h of pcc-nd500, from the NDIX-C assembler) lets it be any general operand, including a constant, and nd500-opcodes therefore reports it as a read operand with 10 modes. instructions.json still has the manual's reading (write, 4 modes). The table was not changed. Question: does the vendor assembler really accept a constant there?
  10. RPHS and WPHS operand template (found 1 November 2026). instructions.json and the emulator table use the general-operand template 0x0001FFE8, which matches the manual's <domain number/r/W>. The assembler table has 0x0003FFE8, which also allows a direct operand, as it does for LCNTXT, SCNTXT, LREGBL and SREGBL. Question: which one does the hardware decode?
  11. PLCCN operand count (found 1 November 2026). The manual and the NDIX-C assembler tables give two operands (source descriptor, destination descriptor). The 1986 PLANC-500 assembler assembles W PLCCN only with three general operands. Question: is there a third operand, what is it, and does the emulator's two-operand decoding of 0xFFFD read the right number of bytes?

Findings from reading the microcode (30 October 2026)

Read from the symbolic listing of MICRO-5800-B30 (line numbers are lines of that listing). Where a point is marked "not settled", the listing does not decide it and no handler may guess it.

Instruction Manual Microcode Settled Not settled
PLCCN (0xFFFD) N = u-l+1, "a + 1 -> A" N = u-l+1 and a negative N becomes 0; A = a + (lower bound times the element size, 4 for W). So "a + 1" in the manual is probably "a + l" (lines 13160 to 13175) Both operands are addresses of descriptors in memory; Z = (N = 0), S = sign of N Byte offsets of the source words; other status bits; no overflow test exists
NCPLC (0xFFFE) a = A, l = 0, u = N-1, "if u-l+1 < 0, 0 -> N" a = A, l = 0, u = N-1; the clamp to 0 is applied to u (lines 13271 to 13288) Z = (u = 0) Whether N = 0 gives u = 0 or u = -1; other status bits
ENTIER (0xFDC7, 0xFDC8) floor of the source; Z, S, O floor (negative non-integer: truncated value minus 1); O comes from the hardware conversion; the destination is written even on overflow (lines 35584 to 35620) The rounding rule The value written on overflow; how Z and S are saved; NaN and denormal input
TOSSP (0xFE9F) operand -> TOS, stack overflow trap if operand greater than B.SP The routine compares the operand with a word read from memory (probably B.SP) as an unsigned subtract and takes the trap when there is no carry; it appears to store the saved status word in the TOS slot, not the operand (lines 15730 to 15766) Entry exists Whether this is a microcode quirk or a misreading; the trap value stored
SEND (0xB6), RECVE (0xB7), WHOLE (0xFE9D) traps PV and IOV, status bits unaffected All three use tables in shared physical memory set up by the nucleus (START_MESS + 88); without them every call ends with I1 = 0x8215 (0o101025) and K = 1. Errors are returned as codes in I1 with K = 1 and no trap is raised (codes 0x8202 not a message, 0x820C no access, 0x8206 outside the source, 0x8204 illegal number, 0x8213 timeout, 0x821A port closed, 0x821B illegal). RECVE also loads I2 and sets K when a message arrives; an empty queue does not block. WHOLE chooses read, write or insert from the hole number in word 0, not from the opcode (lines 7384 to 8294) That the manual's trap list and "unaffected" status bits do not match the microcode Message and port entry layouts; who fills the nucleus table; the final K on success of SEND

Consequence for the emulator: NCPLC, TOSSP, SEND, RECVE and WHOLE keep raising the illegal instruction trap until the unsettled points are answered, or until Ronny decides to accept the best-supported reading. A wrong handler would hide the difference from a real machine.

PLCCN and ENTIER have handlers for the settled parts only (Ronny's decision, 30 October 2026): N = u-l+1 clamped to 0 and A = a + 4*l for PLCCN, floor for ENTIER. Still open and marked in the header comment of each handler: the byte offsets inside the PLANC and ND-500 descriptors, which value S takes in PLCCN, the value written by ENTIER on overflow (clamped for now), and the status bits after an overflow. Tests: test/test_plccn_entier.c.

Measured with an assembler made by Norsk Data (1 November 2026)

PLANC-500 version G ("JUNE 9, 1986") is a Norsk Data compiler with an ND-500 assembler built in: a source line starting with $* is assembled as ND-500 instructions. It was run inside nd500x (MODE script, COMPILE), and the bytes were read from the :NRF it wrote with tools/nrfdump.py. Four probe sources were compiled (one $* line per instruction). Its date is before the manual's June 1987, so a mnemonic it does not know says nothing about the hardware.

What was tried Result
RPHS, WPHS with a variable and with a constant Accepted. Bytes FF F5 C4 <address of n> and FF F5 05; FF F4 for WPHS. The opcodes match the manual, and the operand is a general operand with an address code byte.
H RIOM with a variable, and with a constant as operand 2 Both accepted, opcode FE 76. So this assembler does allow a constant as the buffer operand (plan item 9). That shows what the assembler accepts, not what the hardware does with it.
W1 REXT, W2 REXT, W1 WEXT, W4 WEXT, with a variable and with a constant Accepted. Opcodes FF E8, FF E9, FF EC, FF EF, as in the manual (REXT FFE8 + n-1, WEXT FFEC + n-1).
W PLCCN Opcode FF FD, as in the manual, but this assembler wants THREE operands: W PLCCN n,m,k and W PLCCN n,m,5 assemble (FF FD followed by three general operands); one operand is "MISSING OPERAND(S)". The manual (and the NDIX-C tables) say two. Open: what the third operand is, and whether the 1987 instruction has it.
ENTIER, CLINIT, CLREAD, SEND, RECVE, WHOLE, TOSSP, NCPLC, DDIRT, RHOLE, AMODB "OPERATION NOT RECOGNIZED".

Consequence: REXT, WEXT, RPHS and WPHS are now confirmed by two independent sources (manual and a Norsk Data assembler). The operand rules of the others cannot be checked this way. PLCCN has a new open question (item 11 above).

Step 2 - decide the order

The 14 fall into four groups by what they need. Ronny decides whether all four groups are done, and in which order.

Group Instructions Needs
A. plain CPU work AMODB, ENTIER, PLCCN, NCPLC, TOSSP, CAD operand decoding, arithmetic, descriptor formats from the manual, domain registers (CAD)
B. local clock CLINIT, CLREAD the existing clock code src/cpu/instructions/SYSTEM/Clock.c; the manual says what the clock does
C. nucleus memory RHOLE, WHOLE privileged (PIA bit) and the memory management model
D. other CPUs and devices SEND, RECVE, REXT, WEXT ports between CPUs and external devices; depends on the ND-5000 / octobus model in the emulator

For any instruction whose behaviour is not yet emulated, the first version raises the trap the manual names for it. Nothing is silently ignored.

Step 3 - the data

Order matters, because each file is made from the one before it:

  1. Assembler tables (instrtab.h, codetab.h, oprndtab.h in nd500-as of the pcc-nd500 repository). These are the master. They carry no "generated" marker, so they are edited by hand in the style of their neighbours. They have to say which instructions are '87 extension (a new column or flag per instruction), because the later files cannot know it otherwise.
  2. nd500-opcodes reads those tables. It gets a new field extension ("87" or empty) on every entry in the JSON, C and C# outputs and in the disassembler header.
  3. Regenerate instructions.json (and the copy in this repository), Instructionset.Init.cs and nd500-dis/nd500_instructions.h. Never edit them by hand.

For each of the 13 instructions the table entry has the fields the neighbouring entries have (opcode, mnemonic, class, data type prefixes, operand count and templates, allowed modes), with operand types from the manual's "Format" line and opcodes from its code table (the octal column; the hex column has misprints, for example FF7CC for SCPUNO). The class is one of the existing 13. Then tools/gen_87_extension_doc.py counts from the extension field and fails if it disagrees with the manual's '87 labels.

Rule for every table entry: proof before it goes in

No entry is added to the assembler tables from memory or by analogy. For each of the 13 instructions (and the DDIRT correction), every field is written down with its source before the table is touched, in a worksheet kept next to this plan:

Field Source that must agree
opcode the manual's octal column, the manual's hex column (a mismatch is a misprint to explain, not to guess), and the ND-5000 microcode decode where it is readable
operand count and types the manual's "Format" line, compared with an existing instruction that has the same format
operand access (read, write) the manual's "Operation" line
class the class of the nearest existing instruction, named in the worksheet
privileged the manual's "Privileged instruction" text

Then, after the entry is in:

  1. Assemble one line per instruction; the bytes must equal the manual's opcode plus the operand bytes worked out by hand from the addressing mode rules.
  2. Disassemble those bytes; the text must match the line.
  3. Run the existing 1078 entries through before and after: the old entries must be byte-for-byte unchanged (diff of the generated JSON), only the new ones and DDIRT differ.
  4. Anything not proven by at least two independent sources is not added; it stays on the list as unproven.

The checking is done by script and by reading the sources, not left to Ronny. The tables are edited only when every row of the worksheet agrees between its sources; a row that disagrees stops that instruction.

Step 4 - the emulator

For each instruction:

  1. Information-table row and dispatch entry in src/cpu/nd500_instructions.c (via its generator if there is one).
  2. Handler src/cpu/instructions/<CLASS>/<FunctionName>.c, K&R-free ordinary C11, no Unicode in comments. Prototypes are produced by mkptypes at build time.
  3. Privileged instructions raise IIC when the PIA status bit is reset, using the existing helper in src/cpu/instruction_helpers.c.
  4. Data status bits and trap conditions exactly as the manual lists them for that instruction, not copied from a similar instruction.

Step 5 - the tools (assembler, disassembler, the rest)

All in src/ of the pcc-nd500 repository (a separate repository from this one):

  • nd500-as: add the 13 mnemonics and their operand forms to its tables; correct DDIRT if Step 1, question 5 shows 0xFFFA. Mnemonics are lower case.
  • nd500-opcodes: rebuild, then regenerate nd500-dis/nd500_instructions.h, instructions.json and Instructionset.Init.cs from it; never edit the generated files.
  • nd500-dis: rebuild with the new header; the 13 opcodes must print their mnemonic and operands instead of ???.
  • Other nd500-* tools: check each one (Step 1, question 7); change only the ones that have an instruction table or print mnemonics.
  • Install the rebuilt tools where the old ones are (Ronny's call; the old assembler is kept as nd500-as.before-2026-10-14).
  • Round trip for every '87 instruction: assemble, disassemble, compare with the manual's opcode. Entries in this repository's test/disasm_tests.c and the src/disasm of this repository (a second disassembler) follow.

Step 6 - tests

  • A C test per instruction in the style of test/test_rphs_wphs.c: opcode, operand forms, result, status bits, traps.
  • Entries in test/disasm_tests.c.
  • A script check that every opcode the manual labels '87 has a dispatch entry: tools/gen_87_extension_doc.py --check keeps the page current, and a second check compares its opcode list with the dispatch table.
  • Meaning of each instruction is checked against the ND-5000 microcode where it is readable, since the C# emulator is not a reference.

Step 7 - documents and counts

  • One page per new instruction in docs/instructions/asm/, written from the manual under docs/instructions/DOCUMENTATION_STANDARDS.md; class pages in docs/instruction-reference/.
  • Regenerate the '87 page (its status column changes) and the all-instructions index.
  • Numbers that are written into scripts or pages and change with the data: tools/gen_isa_figures.py (asserts 241, 1078, 244 one-byte and 834 two-byte entries and prints them in the figures), tools/gen_opcode_matrix.py (asserts 1078 and a list of shared opcodes), README.md, CLAUDE.md, docs/INSTRUCTION-SET-OVERVIEW.md.
  • Opcode matrix (tools/gen_opcode_matrix.py): "'87 extension" as a choice in the filter, next to the class and data type choices, combinable with them; it dims every other cell and shows the hit count on the map tabs like the other filters. The popup of a cell says "ND-5000 '87 extension" when it is one. The counts for ND-500 base and for '87 are shown on the page. The data comes from the extension field.

Step 8 - records

  • A line in docs/SYNC-BACKLOG.md for every commit that changes CPU behaviour.
  • The C# emulator was checked on 2 November 2026 and now has PLCCN, ENTIER and DDIRT at 0xFFFA; the ledger is in docs/SYNC-BACKLOG.md. Still open: a numbered item in the shared C# note $ND500_TESTDATA/retrocore-mon-fixes.md for what the C# side does not yet have (NCPLC, SEND, RECVE, WHOLE, TOSSP).