1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 19:38:05 +11:00

recipes/sms/romasm: make zasm's memory usage fit the SMS

This commit is contained in:
Virgil Dupras 2019-07-23 16:50:19 -04:00
parent af0b6231ca
commit 1c6a7caeae
5 changed files with 43 additions and 22 deletions

View File

@ -44,9 +44,25 @@
; FS_HANDLE_SIZE
; BLOCKDEV_SIZE
; *** Variables ***
#include "user.h"
; *** Overridable consts ***
; 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
.equ ZASM_LREG_MAXCNT 0x40
; 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
.equ ZASM_REG_BUFSZ 0x1000
; Size of the names buffer for the local context registry
.equ ZASM_LREG_BUFSZ 0x200
; ******
#include "err.h"
.org USER_CODE
@ -69,4 +85,3 @@ jp zasmMain
#include "zasm/symbol.asm"
.equ ZASM_RAMSTART SYM_RAMEND
#include "zasm/main.asm"

View File

@ -5,28 +5,18 @@
; Local labels during the "official" first pass are ignored. To register them
; in the global registry during that pass would be wasteful in terms of memory.
;
; What we don instead is set up a separate register for them and have a "second
; What we do instead is set up a separate register for them and have a "second
; first pass" whenever we encounter a new context. That is, we wipe the local
; registry, parse the code until the next global symbol (or EOF), then rewind
; and continue second pass as usual.
; *** Constants ***
; Maximum number of symbols we can have in the global and consts registry
.equ SYM_MAXCOUNT 0xff
; Maximum number of symbols we can have in the local registry
.equ SYM_LOC_MAXCOUNT 0x40
; Size of each record in registry
.equ SYM_RECSIZE 3
; 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
.equ SYM_BUFSIZE 0x1000
.equ SYM_REGSIZE SYM_BUFSIZE+1+SYM_MAXCOUNT*SYM_RECSIZE
.equ SYM_REGSIZE ZASM_REG_BUFSZ+1+ZASM_REG_MAXCNT*SYM_RECSIZE
; Size of the names buffer for the local context registry
.equ SYM_LOC_BUFSIZE 0x200
.equ SYM_LOC_REGSIZE SYM_LOC_BUFSIZE+1+SYM_LOC_MAXCOUNT*SYM_RECSIZE
.equ SYM_LOC_REGSIZE ZASM_LREG_BUFSZ+1+ZASM_LREG_MAXCNT*SYM_RECSIZE
; *** Variables ***
; A registry has three parts: record count (byte) record list and names pool.
@ -53,16 +43,16 @@
; records list of the register and then the max record count.
SYM_GLOBAL_REGISTRY:
.dw SYM_GLOB_REG, SYM_GLOB_REG+SYM_BUFSIZE
.db SYM_MAXCOUNT
.dw SYM_GLOB_REG, SYM_GLOB_REG+ZASM_REG_BUFSZ
.db ZASM_REG_MAXCNT
SYM_LOCAL_REGISTRY:
.dw SYM_LOC_REG, SYM_LOC_REG+SYM_LOC_BUFSIZE
.db SYM_LOC_MAXCOUNT
.dw SYM_LOC_REG, SYM_LOC_REG+ZASM_LREG_BUFSZ
.db ZASM_LREG_MAXCNT
SYM_CONST_REGISTRY:
.dw SYM_CONST_REG, SYM_CONST_REG+SYM_BUFSIZE
.db SYM_MAXCOUNT
.dw SYM_CONST_REG, SYM_CONST_REG+ZASM_REG_BUFSZ
.db ZASM_REG_MAXCNT
; *** Code ***

View File

@ -8,6 +8,12 @@
.equ ED_BUF_MAXLINES 0x100
.equ ED_BUF_PADMAXLEN 0x800
; Make zasm fit in SMS's memory
.equ ZASM_REG_MAXCNT 0x80
.equ ZASM_LREG_MAXCNT 0x10
.equ ZASM_REG_BUFSZ 0x800
.equ ZASM_LREG_BUFSZ 0x100
; *** JUMP TABLE ***
.equ strncmp 0x03
.equ addDE 0x06

View File

@ -1,4 +1,9 @@
.equ RAMSTART 0x4000
.equ ZASM_REG_MAXCNT 0xff
.equ ZASM_LREG_MAXCNT 0x40
.equ ZASM_REG_BUFSZ 0x1000
.equ ZASM_LREG_BUFSZ 0x200
jp test
#include "core.asm"

View File

@ -1,4 +1,9 @@
.equ RAMSTART 0x4000
.equ ZASM_REG_MAXCNT 0xff
.equ ZASM_LREG_MAXCNT 0x40
.equ ZASM_REG_BUFSZ 0x1000
.equ ZASM_LREG_BUFSZ 0x200
jp test
#include "core.asm"