A pre-processor for MD-BASIC.
Generates appropriate DATA
or & POKE
(AmperWorks) statements.
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
.poke ; use & POKE
label .equ expr
.export label [, label ...] ; export label (as #define)
.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 [on | off] ; string dextral character inverted
.msb [on | off] ; string most significant bit
.str string [, string ...] ; string data
.pstr string [, string ...] ; pascal string data
n.b.: .str
and .pstr
accept a list of strings ("like this") or expressions (which will save as bytes).
The .msb
and .dci
settings only apply to double-quoted strings.
<
, |
, 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' ; 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