Skip to content

Processor Details

Charles Howard edited this page Oct 4, 2017 · 4 revisions

Registers

The redstone processor has four one byte general purpose registers:

  • a General Purpose Register
  • b General Purpose Register
  • c General Purpose Register
  • d General Purpose Register

along with four port registers:

  • pf Front Port
  • pb Back Port
  • pl Left Port
  • pr Right Port

that can be used to read or write to the four ports of the processor. Only the least significant bit is used when decided to power or not power the respective port.

I/O Ports

There are two additional registers, ports and adc that are used to control the mode of the ports. For more details about the ports refer to the I/O Ports Guide.

Flags

  • Z Zero Flag, set when the previous instruction yields a zero value
  • C Carry Flag, set when the previous instruction yields a value too large for the register
  • F Fault Flag, set when processor has a fault condition (e.g. divide by zero)
  • S Sleep Flag, set when the processor is in sleep mode

Supported Number Formats

Supported commands

  • MOV a, b Move
  • ADD a, b Add
  • SUB a, b Subtract
  • AND a, b Bitwise AND
  • OR a, b Bitwise OR
  • XOR a, b Bitwise XOR
  • NOT a Bitwise NOT
  • MUL a Multiply (with the a register)
  • DIV a Divide (with the a register)
  • JMP label Jump
  • JZ label Jump if Zero
  • JNZ label Jump if not Zero
  • JC Jump if Carry
  • JNC Jump if not Carry
  • DJNZ Decrement register, jump if not Zero
  • CALL label Call Subroutine
  • RET Return from a Subroutine
  • CMP a, b Compare (zero if same)
  • SHL a Shift Left
  • SHR a Shift Right
  • SAL Arithmetic Shift Left
  • SAR Arithmetic Shift Right
  • ROR Rotate Right
  • ROL Rotate Left
  • PUSH a Push to Stack
  • POP a Pop from Stack
  • NOP No Operation
  • INC a Increment by 1
  • DEC a Decrement by 1
  • CLZ Clear Zero Flag
  • CLC Clear Carry Flag
  • SEZ Set Zero Flag
  • SEC Set Carry Flag
  • HLT Halt the Processor
  • WFE Wait for Event (experimental)

Larger Programs

The book and quill can only have 14 lines per page with a limited space for each line. It can hold up to 50 pages, however, allow larger programs to be written when split up onto different pages. While all pages are merged together when a book and quill is loaded into a redstone processor, it is a good idea to treat each page separately and reference them as subroutines using the call and ret instructions.