Asm file syntax
Pseudo grammar:
intval: (just number, forget about grammar:)
delimited_string: (any data including newlines ended with '~')
word: (one word - delimiter is space )
label: (word starting with ':')
asmfile: *{asmentry} end_marker
end_marker: '!end'
asmentry: extern_const_def |
fun_def
extern_conts_def: '!constant' const_entry
const_entry: const_type const_arguments
const_type: 'string'
const_arguments: intval |
delimited_string
fun_def: '!funstart' word *{insidefun} '!funend'
insidefun: mnemonic |
label mnemonic
menmonic: word arguments
arguments: (various things depending on mnemonic - see below)
-----
LABEL - word starting with ':'
Normally we are used to labels with : at end, but due to cost of strlen
it is easier to parse them when they are at first place (mudasm isn't
designed to be generated by hand)
It is possible to put many labels at one place.
Examples:
!funstart some_fun
:LABEL1 pushi -5
pushi 5
:flowER :NEXTLABEL :YET_ANOTHER_LABEL eval
jmp a LABEL1
!funend
Labels are valid only in scope of defining fun.
It is allowed to give label which is not used anywhere, but jumping to label
which isn't defined until end of fun will result in error.
---
LOCAL VARIABLES
// have to write help :(
// short for now
!A dword argint1
!A string argstr1
!L dword vint1
!L dword somei
!L string blurp
pushc string Hello world~
popl @blurp #referenced blurp local variable - equals popl 4
movi @vint1 100 #same as pushi 100; popl 2