o
odin.langpkg.dev
packages / library / pino

pino

6031103library

A tiny stack based virtual machine written in Odin

No license · updated 9 months ago

Pino

A tiny stack-based virtual machine.

Bytecode

The lowest level of programming Pino is on the bytecode level. For this we have a simple assembler like language, inspired by 6502 assembly. Here's an example of computing the first 14 digits of the Fibonacci sequence.

  pshb $0    ; (-- 0)
  pshb $1    ; (0 -- 0 1)
loop:
  ovr       ; (0 1 -- 0 1 0)
  ovr       ; (0 1 0 -- 0 1 0 1)
  add       ; (0 1 0 1 -- 0 1 1)
  dup       ; (0 1 1 -- 0 1 1 1)
  pshb 233  ; are we at 233?
  cmp       ;
  bne loop  ; nope, go back
  brk       ; end execution

Tasks

Milestone: 0.3.0 "Debugger"

  • epic: debugger support [emulator]

Milestone: 0.2.0 "Strings"

  • epic: support for strings [vm] [compiler]

Milestone: 0.1.0 "Hello, World!"

  • fix: word-width x and y coordinates
  • feat: support for for data blocks and variables [compiler]
  • feat: support for drawing sprites [vm] [emulator]
  • refactor: proper literal handling [scanner]
  • refactor: use proper allocators [compiler] [emulator]
  • chore: clean up code using Karl's book as guidance [compiler] [emulator]
  • feat: proper compiler errors [compiler]
  • refactor: rename LIT to PSH and DRP to POP [compiler]
  • fix: decimal parsing
  • feat: support for drawing basic shapes [vm] [emulator]
  • feat: support for comments [compiler]
  • feat: support for text output [vm]
  • feat: compile program file (assy) into binary (rom) [compiler]
  • feat: run rom file [emulator]

Memory Map

Console

FF00 CHROUT

Print a character to standard output.

(c --)

c = ascii code for character to print

BGNDRW Begin drawing (0xFF10)

Begin drawing procedures. Must be called before drawing. End drawing with ENDDRW.

ENDDRW End drawing (0xFF11)

End drawing procedures.

PIXOUT Draw a pixel to the screen (0xFF12)

Draw a pixel to the screen using the specified color.

(x y color --)

x = x coordinate y = y coordinate color = color from palette

LINOUT Draw line (0xFF13)

Draw a line to the screen using specified color.

(x1 y1 x2 y2 color --)

x1 = starting x coordinate y1 = starting y coordinate x2 = ending x coordinate y2 = ending y coordinate color = color from palette

TXTOUT Draw character to screen (0xFF14)

Draw a character with predefined font to the screen.

(char x y color --)

char = ascii code for character being drawn x = x coordinate y = y coordinate color = color from palette

PALETTE (0xFF20 - 0xFFA0

Color palette of 32 colors, in rgba format. The color codes themselves are not used, instead you use the index relative to the base address of 0xFF20.