Skip to content

FrameFX Documentation v1.0

Kirby0Louise edited this page May 18, 2022 · 7 revisions

FrameFX Registers, Flags and Misc v1.0

Address Registers - A0, A1, A2, A3, A4, A5, A6, A7

Data Registers - D0, D1, D2, D3, D4, D5, D6, D7

Flags - N/A, N/A, N/A, Zero (Z), Negative (N), Carry (C), Overflow (V); Program Counter (PC)

Address Space Layout

  • 0x0000000 - 0x07FFFFF: Work RAM
  • 0x0800000 - 0x0FFFFFF: Program RAM (your compiled shader gets loaded here)

FrameFX Opcode Table v1.0

Math

Mnemonic Hex Length Syntax Details
ADD $01 6 ADD address, register Adds the value at the address specified to the target register
ADDI $02 6 ADDI value, register Adds the value specified to the target register
ADDR $03 3 ADDR register, register Adds the register specified to the target register
SUB $04 6 SUB address, register Subtracts the value at the address specified from the target register
SUBI $05 6 SUBI value, register Subtracts the value specified from the target register
SUBR $06 3 SUBR register, register Subtracts the register specified from the target register
MUL $07 6 MUL address, register Multiplies the value at the address specified to the target register
MULI $08 6 MULI value, register Multiplies the value specified to the target register
MULR $09 3 MULR register, register Multiplies the register specified to the target register
DIV $0A 6 DIV address, register Divides the register specified by the value at the address specified
DIVI $0B 6 DIVI value, register Divides the register specified by the value specified
DIVR $0C 3 DIVR value, register Divides the register specified by the register specified

Moving Data Around

Mnemonic Hex Length Syntax Details
MOV $0D 6 MOV address, register Copies the value at the address specified to the target register
MOVI $0E 6 MOVI value, register Copies the value specified to the target register
MOVR $0F 3 MOVR register, register Copies the register specified to the target register
MOVAA $10 9 MOVAA address, address Copies the value at the address specified to the target address
MOVIA $11 9 MOVIA value, address Copies the value specified to the target address
MOVRA $12 6 MOVRA register, address Copies the register specified to the target address

Bit Manipulation

Mnemonic Hex Length Syntax Details
AND $13 6 AND address, register Logical ANDs the value at the address specified to the target register
ANDI $14 6 ANDI value, register Logical ANDs the value specified to the target register
ANDR $15 3 ANDR register, register Logical ANDs the register specified to the target register
NOT $16 5 NOT address Inverts the contents of the specified address
NOTR $17 2 NOTR register Inverts the contents of the specified register
OR $18 6 OR address, register Logical ORs the value at the address specified to the target register
ORI $19 6 ORI value, register Logical ORs the value specified to the target register
ORR $1A 3 ORR register, register Logical ORs the register specified to the target register
XOR $1B 6 XOR address, register Logical XORs the value at the address specified to the target register
XORI $1C 6 XORI value, register Logical XORs the value specified to the target register
XORR $1D 3 XORR register, register Logical XORs the register specified to the target register
LSL $1E 6 LSL address, amount Logically shifts left the value at the address specified by the amount specified places
LSLR $1F 3 LSL register, amount Logically shifts left the register specified by the amount specified places
LSR $20 6 LSR address, amount Logically shifts right the value at the address specified by the amount specified places
LSRR $21 3 LSRR register, amount Logically shifts right the register specified by the amount specified places
ROL $22 6 ROL address, amount Rotates left the value at the specified address by the amount specified places
ROLR $23 3 ROLR register, amount Rotates left the register specified by the amount specified places
ROR $24 6 ROR address, amount Rotates right the value at the specified address by the amount specified places
RORR $25 3 RORR register, amount Rotates right the register specified by the amount specified places

Branching and Program Flow Control

Mnemonic Hex Length Syntax Details
JMP $26 5 JMP address Unconditional jump by signed offset at the address specified
JMPI $27 5 JMPI offset Unconditional jump by signed offset
JSR $28 5 JSR address Unconditional subroutine jump by signed offset at the address specified
JSRI $29 5 JSRI offset Unconditional subroutine jump by signed offset
BRAZ $2A 5 BRAZ value Branch to subroutine at PC + signed offset at the address specified if Zero flag is set
BRAN $2B 5 BRAN value Branch to subroutine at PC + signed offset at the address specified if Negative flag is set
BRAC $2C 5 BRAC value Branch to subroutine at PC + signed offset at the address specified if Carry flag is set
BRAV $2D 5 BRAV value Branch to subroutine at PC + signed offset at the address specified if Overflow flag is set
RTS $2E 1 RTS Returns from the current subroutine

Comparison

Mnemonic Hex Length Syntax Details
CMP $2F 6 CMP address, register Compares the value at the specified address with the specified register by subtracting the two and setting the proper flags. The result is NOT saved to the target register
CMPI $30 6 CMP value, register Compares the value specified with the specified register by subtracting the two and setting the proper flags. The result is NOT saved to the target register
CMPR $31 3 CMP register, register Compares the register specified with the specified register by subtracting the two and setting the proper flags. The result is NOT saved to the target register

Reading and Writing to Frame Buffer

Mnemonic Hex Length Syntax Details
GETPIX $32 6 GETPIX address, register Gets the RGBA value of a pixel from the frame buffer using coordinates at the address specified and stores it in the register specified. The first two bytes of the address specify the X coordinate, the second two bytes specify the Y coordinate
GETPIXI $33 6 GETPIXI value, register Gets the RGBA value of a pixel from the frame buffer using coordinates specified and stores it in the register specified. The first two bytes of the address specify the X coordinate, the second two bytes specify the Y coordinate
GETPIXR $34 3 GETPIXR register, register Gets the RGBA value of a pixel from the frame buffer register specified and stores it in the register specified. The first two bytes of the address specify the X coordinate, the second two bytes specify the Y coordinate
SETPIX $35 9 SETPIX address, address Sets the RGBA value of a pixel to the frame buffer using coordinates at the address specified using the data at address specified. The first two bytes of the address specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXI $36 9 SETPIXI address, value Sets the RGBA value of a pixel to the frame buffer using coordinates at the address specified using the data specified. The first two bytes of the address specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXR $37 6 SETPIXR address, register Sets the RGBA value of a pixel to the frame buffer using coordinates at the address specified using the register specified. The first two bytes of the address specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXIA $38 9 SETPIXIA value, address Sets the RGBA value of a pixel to the frame buffer using coordinates specified using the data at address specified. The first two bytes of the data specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXII $39 9 SETPIXII value, value Sets the RGBA value of a pixel to the frame buffer using coordinates specified using the data specified. The first two bytes of the data specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXIR $3A 6 SETPIXIR value, register Sets the RGBA value of a pixel to the frame buffer using coordinates specified using the register specified. The first two bytes of the data specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXRA $3B 6 SETPIXRA register, address Sets the RGBA value of a pixel to the frame buffer using the register specified and the data at the address specified. The first two bytes of the register specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXRI $3C 6 SETPIXRI register, value Sets the RGBA value of a pixel to the frame buffer using the register specified and the data specified. The first two bytes of the register specify the X coordinate, the second two bytes specify the Y coordinate
SETPIXRR $3D 3 SETPIXRR register, register Sets the RGBA value of a pixel to the frame buffer using the register specified and register specified. The first two bytes of the register specify the X coordinate, the second two bytes specify the Y coordinate