msbasic/macros.s

79 lines
1.7 KiB
ArmAsm
Raw Permalink Normal View History

2008-10-11 07:15:19 +00:00
; htasc - set the hi bit on the last byte of a string for termination
2008-10-12 19:18:33 +00:00
; (by Tom Greene)
2008-10-11 07:15:19 +00:00
.macro htasc str
.repeat .strlen(str)-1,I
.byte .strat(str,I)
.endrep
.byte .strat(str,.strlen(str)-1) | $80
.endmacro
2008-10-12 19:04:31 +00:00
2008-10-12 19:18:33 +00:00
; For every token, a byte gets put into segment "DUMMY".
; This way, we count up with every token. The DUMMY segment
; doesn't get linked into the binary.
2008-10-12 19:50:23 +00:00
.macro init_token_tables
.segment "VECTORS"
TOKEN_ADDRESS_TABLE:
.segment "KEYWORDS"
TOKEN_NAME_TABLE:
2008-10-12 19:18:33 +00:00
.segment "DUMMY"
DUMMY_START:
2008-10-12 19:04:31 +00:00
.endmacro
2008-10-12 19:18:33 +00:00
; optionally define token symbol
; count up token number
2008-10-12 19:04:31 +00:00
.macro define_token token
.segment "DUMMY"
.ifnblank token
token := <(*-DUMMY_START)+$80
.endif
2008-10-12 19:18:33 +00:00
.res 1; count up in any case
2008-10-12 19:04:31 +00:00
.endmacro
2008-10-12 19:18:33 +00:00
; lay down a keyword, optionally define a token symbol
2008-10-12 19:04:31 +00:00
.macro keyword key, token
.segment "KEYWORDS"
htasc key
define_token token
.endmacro
2008-10-12 19:18:33 +00:00
; lay down a keyword and an address (RTS style),
; optionally define a token symbol
.macro keyword_rts key, vec, token
.segment "VECTORS"
.word vec-1
keyword key, token
.endmacro
2008-10-12 19:04:31 +00:00
2008-10-12 19:18:33 +00:00
; lay down a keyword and an address,
; optionally define a token symbol
.macro keyword_addr key, vec, token
.segment "VECTORS"
.addr vec
keyword key, token
2008-10-12 19:04:31 +00:00
.endmacro
2008-10-12 19:18:33 +00:00
2008-10-12 20:17:43 +00:00
.macro count_tokens
.segment "DUMMY"
NUM_TOKENS := <(*-DUMMY_START)
.endmacro
2008-10-13 00:44:36 +00:00
.macro init_error_table
.segment "ERROR"
ERROR_MESSAGES:
.endmacro
.macro define_error error, msg
.segment "ERROR"
error := <(*-ERROR_MESSAGES)
htasc msg
.endmacro
2008-10-12 20:17:43 +00:00
2008-10-12 19:18:33 +00:00
;---------------------------------------------
; set the MSB of every byte of a string
.macro asc80 str
.repeat .strlen(str),I
.byte .strat(str,I)+$80
.endrep
.endmacro