Assembler in GNU as syntax, objdump-style disassembly, UCASE$ and LCASE$
The monitor's assembler takes GNU as directives (.org, .equ, .byte, .half, .word, .ascii, .string, .space, .align, .balign ...), # comments, 0x/0b numbers, '\n' constants, . for the current address, << >> ^ ~, %hi/%lo and the FP CSR short forms; the old ORG/DB/EQU/0FFH forms remain as aliases. The disassembler prints lower case and 0x hex as objdump does. The monitor is built with -msave-restore and puts .rodata first, to fit its ROM. BASIC gains UCASE$ and LCASE$. Manual, README and tests updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
25c8286cf2
commit
fa4752fd7a
16 files changed
+7921
-7615
No files matched your search
Binary file not shown.
+11
-3
@@ -198,7 +198,7 @@ enum {
|
||||
T_DO, T_LOOP, T_WHILE, T_UNTIL, T_EXIT, T_ELSE, T_SELECT, T_CASE,
|
||||
T_OPTION, T_PI, T_ANGLE, T_DEG, T_RAD, T_ASIN, T_ACOS, T_SEC, T_CSC, T_COT,
|
||||
T_SINH, T_COSH, T_TANH, T_ASINH, T_ACOSH, T_ATANH, T_LOG10, T_LOG2, T_CEIL,
|
||||
T_IP, T_FP, T_ROUND, T_TRUNCATE, T_MOD, T_MIN, T_MAX, T_FACT, T_LAST
|
||||
T_IP, T_FP, T_ROUND, T_TRUNCATE, T_MOD, T_MIN, T_MAX, T_FACT, T_UCASES, T_LCASES, T_LAST
|
||||
};
|
||||
_Static_assert(T_LAST <= 0x100, "too many keywords for a byte");
|
||||
|
||||
@@ -213,7 +213,7 @@ static const char *const kw[] = {
|
||||
"DO", "LOOP", "WHILE", "UNTIL", "EXIT", "ELSE", "SELECT", "CASE",
|
||||
"OPTION", "PI", "ANGLE", "DEG", "RAD", "ASIN", "ACOS", "SEC", "CSC", "COT",
|
||||
"SINH", "COSH", "TANH", "ASINH", "ACOSH", "ATANH", "LOG10", "LOG2", "CEIL",
|
||||
"IP", "FP", "ROUND", "TRUNCATE", "MOD", "MIN", "MAX", "FACT"
|
||||
"IP", "FP", "ROUND", "TRUNCATE", "MOD", "MIN", "MAX", "FACT", "UCASE$", "LCASE$"
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------- memory */
|
||||
@@ -684,7 +684,7 @@ static u8 is_str_start(void)
|
||||
{
|
||||
u8 c = peekc();
|
||||
if (c == '"' || c == T_CHRS || c == T_STRS || c == T_LEFTS || c == T_RIGHTS || c == T_MIDS ||
|
||||
c == T_DATES)
|
||||
c == T_DATES || c == T_UCASES || c == T_LCASES)
|
||||
return 1;
|
||||
return is_alpha(c) && tp[1] == '$';
|
||||
}
|
||||
@@ -1107,6 +1107,14 @@ static void str_prim(char *out)
|
||||
out[0] = to_int(expr());
|
||||
out[1] = 0;
|
||||
break;
|
||||
case T_UCASES: /* only A-Z and a-z change */
|
||||
case T_LCASES: {
|
||||
char *p;
|
||||
sexpr(out);
|
||||
for (p = out; *p; p++)
|
||||
if (c == T_UCASES ? *p >= 'a' && *p <= 'z' : *p >= 'A' && *p <= 'Z') *p ^= 32;
|
||||
break;
|
||||
}
|
||||
case T_STRS: {
|
||||
float v = expr();
|
||||
out[0] = ' ';
|
||||
|
||||
+1158
-1158
File diff suppressed because it is too large.
Load diff
+18
-1
@@ -18,9 +18,11 @@ def main():
|
||||
b = te.Basic()
|
||||
errors = 0
|
||||
|
||||
def check(what, ok):
|
||||
def check(what, ok, out=""):
|
||||
nonlocal errors
|
||||
print(("PASS " if ok else "FAIL ") + what)
|
||||
if not ok and out:
|
||||
print(out)
|
||||
errors += not ok
|
||||
|
||||
def run(prog):
|
||||
@@ -64,6 +66,21 @@ def main():
|
||||
b.type(b"A, B" + CR)
|
||||
check("LINE INPUT into an element", "<A, B>" in "\n".join(l.rstrip() for l in b.screen_text().display))
|
||||
|
||||
out = run('''
|
||||
10 A$ = "Hello, World! 123"
|
||||
20 PRINT UCASE$(A$); "|"; LCASE$(A$); "|"; LCASE$(UCASE$("mIxEd"))
|
||||
30 B$ = CHR$(64) + CHR$(91) + CHR$(96) + CHR$(123) + CHR$(224)
|
||||
40 PRINT (UCASE$(B$) = B$); (LCASE$(B$) = B$); LEN(UCASE$("")); ASC(LCASE$("Z"))
|
||||
50 DIM N$(1): N$(1) = "abc": PRINT UCASE$(N$(1) + "d")
|
||||
''')
|
||||
check("UCASE$ and LCASE$", "HELLO, WORLD! 123|hello, world! 123|mixed" in out, out)
|
||||
check("only A-Z and a-z change", "-1 -1 0 122" in out, out)
|
||||
check("UCASE$ of an expression", "ABCD" in out, out)
|
||||
b.type(b"LIST 20" + CR)
|
||||
check("LIST spells UCASE$ and LCASE$",
|
||||
'20 PRINT UCASE$(A$); "|"; LCASE$(A$); "|"; LCASE$(UCASE$("mIxEd"))' in
|
||||
"\n".join(l.rstrip() for l in b.screen_text().display))
|
||||
|
||||
out = run('10 DIM Q$(2): Q$(3) = "X"')
|
||||
check("subscript out of range", "SUBSCRIPT" in out.upper())
|
||||
out = run('10 DIM Z$(300)')
|
||||
|
||||
Reference in new issue
Block a user