https://github.com/ksherlock/mdbasicxx
MD-BASIC++
https://github.com/ksherlock/mdbasicxx
appleii applesoft basic mdbasic
Last synced: 2 months ago
JSON representation
MD-BASIC++
- Host: GitHub
- URL: https://github.com/ksherlock/mdbasicxx
- Owner: ksherlock
- Created: 2017-08-03T01:35:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T18:00:26.000Z (over 2 years ago)
- Last Synced: 2025-02-23T02:35:33.959Z (2 months ago)
- Topics: appleii, applesoft, basic, mdbasic
- Language: Ruby
- Size: 36.1 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MD-BASIC++
A pre-processor for MD-BASIC.
## Roadmap:
### Mini Assembler
Generates appropriate `DATA` or `& POKE` (AmperWorks) statements.
#### Example
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
returnoutput (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
returnoutput (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#### Directives
.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)##### Data Directives
.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.#### Address Modes
`<`, `|`, 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.#### Expressions
##### Terminals{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##### Unary Operators
+ - ^ ~
_n.b._: Unary ^ is right shift 16.
##### Binary Operators
+ - * / % & | ^ >> <<
_n.b._: Binary operations use same precedence as `C`. Parenthesis are not supported within expressions.
### More command-line flags
-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