README.md

July 24, 2025 ยท View on GitHub

OSMX64 is a 64-bit multi-core SoC architecture designed to be fast, efficient, and low-cost.

Registers

Registers store data which can be accessed at any time. These include special registers for

NameSizePurpose
x064 bitsRead-only, always 0
x1-x1564 bitsGeneral purpose, read-write
f0-f732 bitsIEEE 754 single-precision number
d0-d764 bitsIEEE 754 double-precision number
v0-v7512 bitsSIMD vector data
pc64 bitsProgram counter, 0 on startup
sp64 bitsStack pointer
fp64 bitsFrame pointer
ptp64 bitsPage tree pointer

The link registers are for storing specific return addresses from a subroutine

NameSizePurpose
blr64 bitsBranch Link Register
ilr64 bitsInterrupt Link Register

When calling a subroutine, it will need to know where to return to when the execution finishes. To achieve this, we use the branch link register (BLR). In situations where an interrupt has occurred on the system, the CPU would need to know where to return to from the interrupt context, in cases such as this, we'd use the Interrupt Link Register (ILR).

Internal Registers

Only accessed by the CPU for certain instructions. Cannot be directly read/written.

NameSizePurpose
rp64 bitsReturn pointer for branches
ins64 bitsCurrent instruction at pc

Special Registers

OSMX64 provides "special" control registers that may vary depending on the chip revision. These registers typically include chip-specific mode/control bits to configure the processor for certain modes of operations, etc. These registers cannot be accessed via the "mov" instruction and instead rely on independent wrs/rrs (i.e., special register write / special register read) instructions.

Common Special Registers

NameSizePurpose
SR_STATE64 bitsProcessor state bits

SR_STATE

BitMeaningPurpose
0ReservedMust be zero
1SupervisorSupervisor mode enable
2CarryArithmetic carry flag
3-31Reserved (must be 0)Must be zero

Supervisor bit

The supervisor bit may only be writable in a privileged mode of execution and is therefore readonly in user contexts (writes ignored). It may be unset by system software to transition the processor into a user context. This bit may only transition from a 0 to a 1 during an interrupt/trap, therefore manually writing a 1 to this bit is ignored by the processor.

Carry bit

Indicates whether an arithmetic operation has resulted in a carry/borrow.

Instructions

Special Register Access

Special registers are identified with a 16-bit Special Register ID (SRID) and can be accessed through two special instructions.

MnemonicEffect
wrs srid: r/imm, val: rSREGS[srid] = val
rrs dest: r, srid: r/immdest = SREGS[srid]

Bitwise Instructions

Bitwise logic operations can write to all registers except v0-v7, x0 and pc. Can read from all registers except v0-v7.

MnemonicEffect
and dst: r, reg: r, val: r/immdst = dst & val
or dst: r, reg: r, val: r/immdst = dst | val
xor dst: r, reg: r, val: r/immdst = dst ^ val
mrob dst: r: mask [bit]: immFill byte of 'dst' with 'mask'
mrow dst: r: mask [bit]: immFill word of 'dst' with 'mask'
mrod dst: r: mask [bit]: immFill dword of 'dst' with 'mask'
mroq dst: r: mask [bit]: immFill qword of 'dst' with 'mask'

Example

/* Set x1 to 5 */
mov x1, #5
/* Ands x1 (which equals 5) with 1 */
and x1, x1, #1
/* x1 now equals 1 */

Data Movement Instructions

MnemonicEffect
mov dst: r, src: r/immdst = src
stb src: r, [dst: r/m, offset: r/imm]1-byte store to memory at dst
stw src: r, [dst: r/m, offset: r/imm]2-byte store to memory at dst
std src: r, [dst: r/m, offset: r/imm]4-byte store to memory at dst
stq src: r, [dst: r/m, offset: r/imm]8-byte store to memory at dst
ldb dst: r, [src: r/m, offset: r/imm]1-byte load from memory at src
ldw dst: r, [src: r/m, offset: r/imm]2-byte load from memory at src
ldd dst: r, [src: r/m, offset: r/imm]4-byte load from memory at src
ldq dst: r, [src: r/m, offset: r/imm]8-byte load from memory at src

Example

/* Set x1 to 7 */
mov x1, #7

/* Write to memory pointed by sp */
stq x1, [sp]

/* Write to memory pointed by sp + 8 */
stq x1, [sp, #8]

/* Write to memory pointed by sp + x2 */
mov x2, #16
stq x1, [sp, x2]

Arithmetic Instructions

Arithmetic operations can write to all registers except v0-v7, x0 and pc. Can read from all registers except v0-v7.

MnemonicEffect
add dst: r, val: r/immdst = dst + val
sub dst: r, val: r/immdst = dst - val
mul dst: r, val: r/immdst = dst * val
div dst: r, val: r/immdst = dst / val
inc dst: rdst = dst + 1
dec dst: rdst = dst - 1

Example

/* Set x1 to 5 */
mov x1, #5
/* Increment x1 */
inc x1
/* x1 now equals 6 */

Control Flow Instructions

Control flow instructions are used to control which instructions the CPU executes, allowing for the concept of procedures and conditional execution.

MnemonicEffect
hltExecution halted
br dst: rpc = dst
brl dst: rrp = pc + size of opcode, then pc = dst
bretpc = rp
beq a: r/m, b: r/m/imm, dst: r/m/immIff a = b, pc = dst
bne a: r/m, b: r/m/imm, dst: r/m/immIff a != b, pc = dst
blt a: r/m, b: r/m/imm, dst: r/m/immIff a < b, pc = dst
bgt a: r/m, b: r/m/imm, dst: r/m/immIff a > b, pc = dst
ble a: r/m, b: r/m/imm, dst: r/m/immIff a <= b, pc = dst
bge a: r/m, b: r/m/imm, dst: r/m/immIff a >= b, pc = dst

Example

/* Subtract x2 from x1 */
sub x1, x1, x2
beq x1, #0, zero
mov x1, #2
zero:
mov x1, #3
/* Iff x1 - x2 = 0, x1 equals 3 */
/* Iff x1 - x1 != 0, x1 equals 2 */

Opcode list

  • NOP: 0x00
  • ADD: 0x01
  • SUB: 0x02
  • MUL: 0x03
  • DIV: 0x04
  • INC: 0x05
  • DEC: 0x06
  • OR: 0x07
  • XOR: 0x08
  • AND: 0x09
  • NOT: 0x0A
  • SLL: 0x0B
  • SRL: 0x0C
  • MOV_IMM: 0x0D
  • HLT: 0x0E
  • BR: 0x0F
  • MROB: 0x10
  • MROW: 0x11
  • MROD: 0x12
  • MROQ: 0x13

Copyright (c) 2024 Quinn Stephens and Ian Marco Moffett. All rights reserved.