2019-05-20 02:57:59 +10:00
|
|
|
; zasm
|
|
|
|
;
|
|
|
|
; Reads input from specified blkdev ID, assemble the binary in two passes and
|
|
|
|
; spit the result in another specified blkdev ID.
|
|
|
|
;
|
|
|
|
; We don't buffer the whole source in memory, so we need our input blkdev to
|
|
|
|
; support Seek so we can read the file a second time. So, for input, we need
|
2019-10-31 07:59:35 +11:00
|
|
|
; GetB and Seek.
|
2019-05-20 02:57:59 +10:00
|
|
|
;
|
2019-10-31 07:59:35 +11:00
|
|
|
; For output, we only need PutB. Output doesn't start until the second pass.
|
2019-05-20 02:57:59 +10:00
|
|
|
;
|
|
|
|
; The goal of the second pass is to assign values to all symbols so that we
|
|
|
|
; can have forward references (instructions referencing a label that happens
|
|
|
|
; later).
|
|
|
|
;
|
|
|
|
; Labels and constants are both treated the same way, that is, they can be
|
|
|
|
; forward-referenced in instructions. ".equ" directives, however, are evaluated
|
|
|
|
; during the first pass so forward references are not allowed.
|
|
|
|
;
|
|
|
|
; *** Requirements ***
|
|
|
|
; strncmp
|
|
|
|
; upcase
|
|
|
|
; findchar
|
|
|
|
; blkSel
|
2019-06-05 10:45:01 +10:00
|
|
|
; blkSet
|
2019-05-20 02:57:59 +10:00
|
|
|
; fsFindFN
|
|
|
|
; fsOpen
|
2019-10-31 07:59:35 +11:00
|
|
|
; fsGetB
|
|
|
|
; _blkGetB
|
|
|
|
; _blkPutB
|
2019-06-05 01:53:02 +10:00
|
|
|
; _blkSeek
|
|
|
|
; _blkTell
|
2019-06-20 01:42:39 +10:00
|
|
|
; printstr
|
2020-02-24 10:52:25 +11:00
|
|
|
; printcrlf
|
2019-05-20 02:57:59 +10:00
|
|
|
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "user.h"
|
2019-07-24 06:50:19 +10:00
|
|
|
|
|
|
|
; *** Overridable consts ***
|
2019-10-07 06:42:09 +11:00
|
|
|
; NOTE: These limits below are designed to be *just* enough for zasm to assemble
|
|
|
|
; itself. Considering that this app is Collapse OS' biggest app, it's safe to
|
|
|
|
; assume that it will be enough for many many use cases. If you need to compile
|
|
|
|
; apps with lots of big symbols, you'll need to adjust these.
|
|
|
|
; With these default settings, zasm runs with less than 0x1800 bytes of RAM!
|
|
|
|
|
2019-07-24 06:50:19 +10:00
|
|
|
; Maximum number of symbols we can have in the global and consts registry
|
|
|
|
.equ ZASM_REG_MAXCNT 0xff
|
|
|
|
|
|
|
|
; Maximum number of symbols we can have in the local registry
|
2019-10-07 06:42:09 +11:00
|
|
|
.equ ZASM_LREG_MAXCNT 0x20
|
2019-07-24 06:50:19 +10:00
|
|
|
|
|
|
|
; Size of the symbol name buffer size. This is a pool. There is no maximum name
|
|
|
|
; length for a single symbol, just a maximum size for the whole pool.
|
|
|
|
; Global labels and consts have the same buf size
|
2019-10-07 06:42:09 +11:00
|
|
|
.equ ZASM_REG_BUFSZ 0x700
|
2019-07-24 06:50:19 +10:00
|
|
|
|
|
|
|
; Size of the names buffer for the local context registry
|
2019-10-07 06:42:09 +11:00
|
|
|
.equ ZASM_LREG_BUFSZ 0x100
|
2019-07-24 06:50:19 +10:00
|
|
|
|
|
|
|
; ******
|
|
|
|
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "err.h"
|
2019-11-14 12:38:06 +11:00
|
|
|
.inc "ascii.h"
|
2019-11-16 07:37:49 +11:00
|
|
|
.inc "blkdev.h"
|
|
|
|
.inc "fs.h"
|
2019-05-20 02:57:59 +10:00
|
|
|
jp zasmMain
|
|
|
|
|
2019-11-15 01:55:31 +11:00
|
|
|
.inc "core.asm"
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/const.asm"
|
|
|
|
.inc "lib/util.asm"
|
2019-11-23 06:45:12 +11:00
|
|
|
.inc "lib/ari.asm"
|
2019-11-16 07:37:49 +11:00
|
|
|
.inc "lib/parse.asm"
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/util.asm"
|
2019-05-20 02:57:59 +10:00
|
|
|
.equ IO_RAMSTART USER_RAMSTART
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/io.asm"
|
2019-05-20 02:57:59 +10:00
|
|
|
.equ TOK_RAMSTART IO_RAMEND
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/tok.asm"
|
2019-07-26 04:02:04 +10:00
|
|
|
.equ INS_RAMSTART TOK_RAMEND
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/instr.asm"
|
2019-07-26 04:02:04 +10:00
|
|
|
.equ DIREC_RAMSTART INS_RAMEND
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/directive.asm"
|
|
|
|
.inc "zasm/parse.asm"
|
2019-11-19 07:52:07 +11:00
|
|
|
.equ EXPR_PARSE parseNumberOrSymbol
|
|
|
|
.inc "lib/expr.asm"
|
2019-05-20 02:57:59 +10:00
|
|
|
.equ SYM_RAMSTART DIREC_RAMEND
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/symbol.asm"
|
2019-05-20 02:57:59 +10:00
|
|
|
.equ ZASM_RAMSTART SYM_RAMEND
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/main.asm"
|
2019-11-16 02:33:13 +11:00
|
|
|
USER_RAMSTART:
|