From 9727ec419720c93884939bd077d41a989b7ff51e Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 10 Mar 2025 03:32:55 -0400 Subject: listamsb: support functions for int tokens. --- listamsb.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/listamsb.c b/listamsb.c index a3614c6..3b9726f 100644 --- a/listamsb.c +++ b/listamsb.c @@ -558,8 +558,7 @@ int crunch_line(void) { return codelen; } -/* only called during decrunching. - only handles one-byte tokens (only has to). */ +/* only called during decrunching. */ void expand_token(int ext, unsigned char t, unsigned char *buf) { const char *result; @@ -582,6 +581,33 @@ void expand_token(int ext, unsigned char t, unsigned char *buf) { strcpy((char *)buf, result); } +int read_token(void) { + int tok = read_prog_byte(); + if(tok == 0xff) { + tok <<= 8; + tok |= read_prog_byte(); + } + return tok; +} + +int token_is_extended(int tok) { + return tok > 0xff; +} + +int append_token(int tok, char *buf, int len) { + if(token_is_extended(tok)) { + buf[len++] = 0xff; + buf[len++] = tok; + } else { + buf[len++] = tok; + } + return len; +} + +void token2text(int tok, unsigned char *buf) { + return expand_token(token_is_extended(tok), tok & 0xff, buf); +} + /* only called during decrunching. the tokenizer in AMSB requires spaces to separate keywords and variables/numbers. "IF A THEN 100" really needs the spaces -- cgit v1.2.3