Processor Commands - retrotruestory/M1DEV GitHub Wiki

Processor Commands

Here are several processor commands, their binary notation, and examples of their construction and application:

Load Command:
Syntax: ld.8/16 <dest>, [<source>]
Binary Notation:
The command might be structured as follows:
[OP: 4 bits][Dest: 3 bits][Mode: 3 bits][Immediate/Data: 8/16 bits]

Example:

Command: ld.8 A, #u16(DP)
This command loads an 8-bit value from the address specified by the Data Pointer (DP) into register A.
Example Binary: 0010 001 010 00000001
(Where 0010 is the opcode for load, 001 represents register A, and the rest is the immediate value.)

Subtraction Command:

Syntax: sub.8/16 A, [Operand]
Binary Notation:
The structure can be:
[OP: 4 bits][Dest Reg: 3 bits][Mode: 3 bits][Immediate/Data: 8/16 bits]

Example:

Command: sub.16 A, #i16_exti8
This command subtracts a 16-bit sign-extended immediate value from register A.
Example Binary: 0100 001 011 00000010

Branch Command:

Syntax: br.[condition] d16
Binary Notation:
Format may look like: [OP: 4 bits][Cond: 4 bits][Address: 8 bits]

Example:

Command: br.eq #d16
This instructs the processor to branch to the specified 16-bit address if the zero flag is set.
Example Binary: 0110 0001 10101010

System Call Command:

Syntax: syscall u8
Binary Notation:
Structure: [OP: 4 bits][Reserved: 2 bits][Syscall Number: 8 bits]

Example:

Command: syscall #sys_num8
This performs a system call using the specified 8-bit system call number.
Example Binary: 1000 0001 00011010

Write Code Page Table Entry Command:

Syntax: wcpte A, (B)
Binary Notation:
Typical format: [OP: 4 bits][Source Reg: 3 bits][Destination Reg: 3 bits][Extra Flags/Offset: 6 bits]

Example:

Command: wcpte A, (B)
This writes a code page table entry for the address in register B.
Example Binary: 1010 001 010 001101
⚠️ **GitHub.com Fallback** ⚠️