SPINE-64

x86-64 Intel Assembly Language

SPINE-64 is a custom assembly language that compiles to x86-64 binary. It is the assembly layer of the ThOS stack, sitting beneath Ground which sits beneath Thorn.

Readable syntax, not x86 syntax. Clean mnemonics, English-style keywords.


The Stack

  • Thorn — userland / apps
  • Ground — systems C-like language (not yet built)
  • SPINE-64 — assembly
  • x86-64 — bare metal

Registers

  • ret / rax — return value / accumulator
  • r1 / rbx — general purpose
  • cnt / rcx — counter
  • dta / rdx — second return value
  • src / rsi — source
  • dst / rdi — destination
  • r2r9 — general purpose
  • m1, m2 — reserved for processes (kernel cannot touch)

Special registers (compiler managed):

  • stp / rsp — stack top pointer
  • sbp / rbp — stack base pointer
  • sip / rip — stack instruction pointer

Flags

  • carry — set if unsigned overflow
  • overflow — set if signed overflow
  • zero — set if result is exactly 0

Size Specifiers

Appended to memory instructions with dot notation:

  • .1 — 1 byte
  • .2 — 2 bytes
  • .4 — 4 bytes
  • .8 — 8 bytes

Example: move.4 ret [0x1000]

Modules

  • module code — all code goes here
  • module data — all initialized data goes here
  • module reserve — all uninitialized data goes here

Alias

Registers can be aliased for readability:

alias reg myCounter

Instructions

Data Movement: move, push, pop, lma (load memory address), swap, movesx (move + sign extend), movezx (move + zero extend)

Arithmetic: add, sub, mul, smul (signed multiply), div, sdiv (signed divide), inc, dec, neg, awc (add with carry), swb (subtract with borrow)

Bitwise: and, or, xor, not, shl, shr, asr, rotl, rotr, racl, racr

Comparison and Jump: cmp with operators: ==, !=, >=, <=, >, <go label

Functions: fn funcname / fn global funcname / raw fn funcnamecall, return, extern

Loops: loop ... end

System: syscall, nope (nop), halt, ioff, ion, pr, pw, int, reti

Addressing Modes

  • [0x1000] — fixed address
  • [r1] — address in register
  • [r1 + 8] — base + fixed offset
  • [r1 + r2] — base + register offset
  • [r1 + r2 * 4] — base + scaled index
  • [r1 + r2 * 4 + 16] — base + scaled index + offset

Example

module data
    message "hello world" 0
    count 0 4

module reserve
    buffer 1024

module code
    fn global main
    start
        lma src message
        move cnt 11
        loop
        start
            move.1 ret [src]
            inc src
            dec cnt
            cmp cnt == 0 go done
        end
        done:
            halt
    end

Binary Output

  • Bootloader — flat binary (raw bytes, no header)
  • Kernel and userland — ELF format