Encoding
The bit-string instructions are format II instructions with opcode 0x1F: the first halfword is 011111 00000 sub(5), so the instruction is two bytes long and has no register operand in the encoding; the 5-bit field is the sub-opcode.
Sub-opcodes 0x04 to 0x07 and 0x10 to 0x1F are undefined (the Mednafen core raises the invalid-opcode exception for them): the decoder shows them as illegal.
Bit 3 of the sub-opcode separates the two kinds: set means a bitwise operation between two strings, clear means a search.
The operand registers
The operands are in fixed registers, which is why r26 to r30 are set aside by the compilers. From memory of the NEC manual (not checked against a source read):
| Register | Holds |
|---|---|
r30 | the word address of the source string |
r29 | the word address of the destination string (for a search: the bit offset found) |
r28 | the bit offset of the destination within its word |
r27 | the bit offset of the source within its word |
r26 | the length of the string in bits |
The viewer lists r26 to r30 as read and written by every bit-string instruction (a search reads r26 r27 r30 and writes r26 r27 r29 r30); the instruction updates them as it goes and can be interrupted and restarted. The Mednafen core, as read, adds clock counts per 16-bit half-word of memory touched; they are not listed here.
The instructions
| Mnemonic | Sub-opcode | Operation |
|---|---|---|
SCH0BSU | 0x00 | Search the bit string upward (towards higher addresses) for a 0 bit |
SCH0BSD | 0x01 | Search downward for a 0 bit |
SCH1BSU | 0x02 | Search upward for a 1 bit |
SCH1BSD | 0x03 | Search downward for a 1 bit |
ORBSU | 0x08 | destination = destination OR source |
ANDBSU | 0x09 | destination = destination AND source |
XORBSU | 0x0A | destination = destination XOR source |
MOVBSU | 0x0B | destination = source (copy) |
ORNBSU | 0x0C | destination = destination OR NOT source |
ANDNBSU | 0x0D | destination = destination AND NOT source |
XORNBSU | 0x0E | destination = destination XOR NOT source |
NOTBSU | 0x0F | destination = NOT source |
The operations run upward from the given bit offsets. The Mednafen source as read names the search direction by bit 0 of the sub-opcode (set: downward) and the bit searched for by bit 1 (set: a 1 bit). The flags are not stated in the sources read, so the decoder lists none.
Not described
See the status page: the register roles above, what a search leaves in the registers, the flags and the clock counts are not confirmed.