Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PACT assembly musings
# line comments
# must start with a pact directive giving type and version
.pact pbc 0
# enable compiler options
# 2 reasons:
# 1) to allow an extremely basic version to be turned into a C implementation
# 2) to allow experimentation. Most common options probably on by default in
# higher versions
.options alias, var
# Possible options:
# autoend: end a segment when a new one starts
# debug: add debug segment information based on filename
# annotate: add file/line annotations
# var may imply alias
.constants num
0 3.14
1 0
2 1
3 "example.pas"
.alias pi = nc0 # these are file scope
.alias zero = nc1
.alias one = nc2
.constants string
# encoding, string
# " strings have \-encoding
# ' strings only have \' and \\
# hex, base64 strings?
0 utf8 "Hello, World"
1 ascii "main"
2 ascii "line"
.alias hello = sc0
.alias line = sc2
.constants pmc
# type, then type dependent serialization
# For sub: label, name (must be SC#), options (main, tag, subid)
0 Sub main sc1, main
# Print "Hello, World" three times
.sub main # sub "names" are actually labels, referred to in .constants pmc section
.debug sc3 # set the file name for the debug segment
.annotate line, 1 # add an annotation: type, value (type must be sc#, value any constant)
.var i = n # becomes (highest num register used + 1), in this case n0
# also scoped to sub
set i, pi
lt i, zero, done
say hello
sub i, one
goto loop
# aliases, vars, and labels all have same namespace.
# must match [_\w][_\w\d]*
# can't match [insp]c?\d+ (would conflict with register/constants)
# .subs have unique namespace (only used for Sub constants)
# disassembler will output _PC labels for every opcode (_0, _4)
# makes it easy to output jumps
# How do we want to handle integer constants?
# .alias const = 42
# .const const = 42
# This code isn't really PASM, but the highlighting works well.
# vim: expandtab shiftwidth=4 ft=pasm:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.