Created
May 5, 2012 05:18
-
-
Save Benabik/2599989 to your computer and use it in GitHub Desktop.
PACT assembly musings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" | |
.end | |
.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" | |
.end | |
.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 | |
.end | |
# 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 | |
loop: | |
lt i, zero, done | |
say hello | |
sub i, one | |
goto loop | |
done: | |
end | |
.end | |
# 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