A pre-processor for MD-BASIC.
Generates appropriate DATA or & POKE (AmperWorks) statements.
It can also generate a binary payload appended to the end of the file
(.inline). In inline mode, .org is not allowed (or necessary); the
org will be calculated based on the file size.
input:
function1:
for i = F_START to F_END
read x
poke i,x
next i
call $300
return
#asm
.org $300
.export f_start, f_end
f_start
lda #0
rts
f_end .equ *-1
#endasm
function2:
#asm
.org $300
.poke
lda #0
rts
#endasm
call $300
return
output (before MD-BASIC):
' generated by mdbasic++ 0.0.3
#define __MDBASICXX__
#define __DATE__ "Aug 11 2017"
#define __TIME__ "23:38:14"
#define F_START 768
#define F_END 770
function1:
for i = F_START to F_END
read x
poke i,x
next i
call $300
return
DATA 169,0,96
function2:
& POKE 768,169,0,96
call $300
return
output (after MD-BASIC):
1 FOR A = 768 TO 770: READ B: POKE A,B: NEXT A: CALL 768: RETURN : DATA 169,0,96
2 & POKE 768,169,0,96: CALL 768: RETURN
.machine [6502 | 65c02 | 65816] ; specify machine (default 6502)
.org expr ; set origin
.long [mx] ; '816 - assume long m or x
.short [mx] ; '816 - assume short m or x
.data ; use DATA (default)
.poke ; use & POKE
.inline ; generate a binary blob at the end of file
label .equ expr
.export label [, label ...] ; export label (as #define)
label .export ; define and export label
.db expr [, expr ...] ; 8-bit data
.dw expr [, expr ...] ; 16-bit data
.da expr [, expr ...] ; 24-bit data
.dl expr [, expr ...] ; 32-bit data
.dci string [, string ...] ; dextral character inverted string
.str string [, string ...] ; string
.pstr string [, string ...] ; pascal string
n.b.: .str, .pstr, and .dci accept a list of strings ("like this",'or this') or expressions (which will generate bytes).
For .pstr, the length prefix is the length of all strings and expressions. For .dci, only the last byte of the last string
(or expression) is inverted.
<, |, and > are address mode selectors, not unary operators. If no address mode is explicitly
specified, the Mini Assembler will default to absolute address mode. If the operand size can be
determined (i.e., an integer constant or symbol value is known), it will default to zp, absolute, or
absolute long based on the operand size.
{basic-expression} ; inserted as-is. only valid with .poke
symbol ; symbol
%10 ; binary integer
10 ; decimal integer
$10 ; hexadecimal integer
0x10 ; hexadecimal integer
'10' ; low-ascii string (or character constant)
"10" ; high-ascii string (or character constant)
+ - ^ ~
n.b.: Unary ^ is right shift 16.
+ - * / % & | ^ >> <<
n.b.: Binary operations use same precedence as C. Parenthesis are not supported within expressions.
-D macroname[=value] Define a macro
-E Pre-processor only
-S Decompile generated code
-I directory Specify include path (not yet ....)
-o outfile Specify outfile
-O level Specify optimization level (0,1,2)
-v, --verbose Be verbose
-V, --version Display version
--[no-]declare Require declarations
--[no-]progress Print progress
--[no-]summary Print summary
--[no-]xref Print Cross References
-h, --help Display help information