Created
April 9, 2012 00:38
-
-
Save Jarvix/2340557 to your computer and use it in GitHub Desktop.
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
<label>, <name>, <param> must all match: /[A-Za-z_][A-Za-z0-9_]*/ | |
labels, names and parameters can not have names equal to registers and mnemonics. | |
LABELS | |
<label>: | |
!!! NOT :<label> !!!! | |
FILE INCLUSION | |
.include "<relative path>" | |
.include <{relative path to from base path of library}> | |
The base address of the latter is defined by the assembler or an assembler flag. | |
.incbin "<relative path>" | |
BASE ADDRESS REPLACEMENT | |
.org <address> | |
How it works: | |
the address specified here should be used as a base to all compiler-generated addresses. | |
so it MUST be added to the addresses of all labels. | |
MACROS | |
Definition: | |
.macro <name>(<params...>) | |
<code> | |
.end | |
params is a comma separated list of unique (for the macro) identifiers | |
Insert the macro: | |
.ins <name>(<values...>) | |
REPETITIONS | |
.rep <count> | |
<code> | |
.end | |
CONDITIONAL DIRECTIVES | |
.def <name> [<value>] | |
Without <value>, value defaults to 1 | |
.if <expr> | |
.else | |
.end | |
<expr> is <const1> = <const2>. Without <const2>, <const2> defaults to 1. | |
.if 0 => .if 0 = 1 => false | |
.if 1 => .if 1 = 1 => true | |
.if HELLO = 5 => depends on HELLO value | |
.if HELLO => .if HELLO = 1 => depends on HELLO value | |
both defined names (with .def) and numbers are valid for <const>. | |
registers and anything else is not. | |
// 1 when defined, 0 otherwise | |
isdef(<name>) | |
example: | |
.def DEBUG | |
.def HELLO 0x2000 | |
.if isdef(DEBUG) | |
Do something | |
.else | |
.if isdef(HELLO) | |
SET PC, HELLO | |
.end | |
.end | |
==== PARSING | |
case insensitive opcodes and registers | |
"Str" is a string, either prefixed by the length or appended by 0 | |
'c' is a character, nor prefixed or appended. limited to 1 character. character is taken from ASCII charset. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LABELS:
Currently Notch's assembler uses
:
for labels.It is appropriate to use
:
.FILE INCLUSION:
The preprocessor should merge files, for that one need an inclusion command.
It's styled like that: .include
"
"
.BASE ADDRESS REPLACEMENT
Replaces the current address with the given one.
*
is the current address and can be altered with simple arithmetic (plus+
and minus-
).org
MACROS
Macros are placed texts by the preprocessor.
Their parameters are seperated by comma
,
.REPETITIONS
has to be a constant unsigned number.
CONDITIONAL DIRECTIVES
To defining a constant, one use
.def
followed by and the ..def
example:
.def DEBUG
.def HELLO 0x2000