Toolchain for assembly and compilation of new code for FM10000 Instruction Processor Boot State Machine
Go to file
DataHoarder 5d9ed3cd82
continuous-integration/drone Build is running Details
continuous-integration/drone/push Build is failing Details
Fixed AsValue and AsIndirect
2021-08-06 00:14:58 +02:00
asm Fix PCIE_SERDES_CTRL registers 2021-08-06 00:06:15 +02:00
src Fixed AsValue and AsIndirect 2021-08-06 00:14:58 +02:00
.drone.jsonnet Update CI to Debian bullseye 2021-08-05 16:01:18 +02:00
.gitignore WIP: Initial commit, working basic assembler 2020-12-31 22:06:52 +01:00
CMakeLists.txt Add DEBUG flags to CMakeLists.txt 2021-08-03 19:21:25 +02:00
COPYING WIP: Initial commit, working basic assembler 2020-12-31 22:06:52 +01:00
README.md Update README to include extra features 2021-08-04 01:49:40 +02:00

README.md

rrcc (Red Rock Canyon Compiler)

Toolchain for assembly and compilation of new code for FM10000 Instruction Processor Boot State Machine

NOTE: This is a Work In Progress project

Requirements

  • cmake >= 3.13
  • g++ (GCC C++) or clang
  • make

Compilation

  • $ mkdir build && cd build
  • $ cmake ../ && make
  • An executable named ./rrc-as should now exist.
  • Feel free to move the executable to your desired installation directory, resources have been embedded.

rrc-as

Assembler and linker, kind-of 2-Pass. Quite loose token syntax defined in Token.h. A quite-more-than-working educational implementation.

Contains extensions to original FM10000 Instruction set. Here are some of them:

  • Automatic selection of Immediate/Register instructions: No need to hardcode them, best pick will be selected.
  • Call Stack, Frame & Stack pointers: You have full access to a stack, POP/PUSH/GET/PUT and more!
    • PUSH <R> [N=1] / PUSH <V>, [..., Vn], POP <R> [N=1], POPI [N=1], POPP (to be deprecated): Add/remove from stack.
    • GET, PUT: In-place stack data handling.
    • Uses BSM_ADDR_OFFSET[2] as frame pointer.
    • Uses BSM_ADDR_OFFSET[3] as stack pointer.
  • Call/FastCall system: For easy calling of other functions, and passing/returning values.
    • CALL <LOC>, FASTCALL <LOC> [P1, P2, ..., Pn]
    • RET [V]
    • Uses stack system.
  • Scratch reservation system: Statically allocate scratch space and assert other code does not use it.
  • Aliases / Offsets / shifts in-place: Stop hardcoding all your parameters!
  • Shorthand aliases for instructions: For directly using AND / ADD / BEQ / BNE and more.
    • ADD, OR, AND, SUB, SHL, SHR, SAR
    • BNE, BEQ, PNE, PEQ
  • Extended instructions virtually: Some instructions did not allow registers on them.
    • SET <R>, <V>, <M>: Now registers allowed in all operands, with offsets.
    • MOV <R>, <V>, [...Vn]: Automatically select between WRITE and COPY depending on operands. Allows multi-word.
    • TODO: branch instructions to allow registers.
  • New virtual instructions: Several new mathematical and bitwise operations added:
    • XOR <R>, <A, <B>: implemented via a ^ b = a + b - (a & b) - (a & b) in four native instructions. TODO: handle offsets.
    • NOT <R>, <A>: implemented via ~a = 0xFFFFFFFF - a in one or three native instructions, depending on offsets.
  • Basic stdlib functions: Adds some must-have complex operations, and other quality of life ones.
    • std_multiply <A> <B>: Multiply two integers. Implemented with shift + add multiplication.
    • std_divide <A> <B>: Divide two integers, get quotient and remainder. Implemented with shift + add division.
    • Definition of standard value return registers.
    • Definition of standard ephemeral registers.
  • Bitfield creation: Parametrized bitfield shifts and mask creation.
    • .bitfield REGISTER.Field <bitShift> [bitSize]

Usage

  • $ rrc-as version
  • $ rrc-as code.asm [code2.asm ...] output.bin
  • The function named entrypoint will be called by init asm
  • Multiple asm files can be specified. They are interpreted from first in arguments to last.
  • You can call functions across files, as they will be linked together when used.
  • Directive resolution occurs at parsing time, so while you can override values it does not affect previously parsed files.
  • Directives like .constant, .reserve, .bitfield, etc. are passed to the next files.
  • These files will be automatically included in front every time:

Usage example

Check out the rrc-open-firmware project for an in-depth look at the assembly and usage. Do note it uses its own rrcc tagged version.

License

  • BSD-3-Clause
  • See COPYING for the full license.