diff --git a/include/asm/charmap.hpp b/include/asm/charmap.hpp index 0e60e77a..ba49c029 100644 --- a/include/asm/charmap.hpp +++ b/include/asm/charmap.hpp @@ -9,7 +9,6 @@ #define DEFAULT_CHARMAP_NAME "main" struct Charmap *charmap_New(char const *name, char const *baseName); -void charmap_Delete(struct Charmap *charmap); void charmap_Set(char const *name); void charmap_Push(void); void charmap_Pop(void); diff --git a/include/asm/section.hpp b/include/asm/section.hpp index a6547c66..17d39945 100644 --- a/include/asm/section.hpp +++ b/include/asm/section.hpp @@ -60,7 +60,6 @@ void sect_AbsByteGroup(uint8_t const *s, size_t length); void sect_AbsWordGroup(uint8_t const *s, size_t length); void sect_AbsLongGroup(uint8_t const *s, size_t length); void sect_Skip(uint32_t skip, bool ds); -void sect_String(char const *s); void sect_RelByte(struct Expression *expr, uint32_t pcShift); void sect_RelBytes(uint32_t n, struct Expression *exprs, size_t size); void sect_RelWord(struct Expression *expr, uint32_t pcShift); diff --git a/include/asm/symbol.hpp b/include/asm/symbol.hpp index e6a785ed..6d477322 100644 --- a/include/asm/symbol.hpp +++ b/include/asm/symbol.hpp @@ -117,8 +117,6 @@ uint32_t sym_GetConstantSymValue(struct Symbol const *sym); uint32_t sym_GetConstantValue(char const *symName); // Find a symbol by exact name, bypassing expansion checks struct Symbol *sym_FindExactSymbol(char const *symName); -// Find a symbol by exact name; may not be scoped, produces an error if it is -struct Symbol *sym_FindUnscopedSymbol(char const *symName); // Find a symbol, possibly scoped, by name struct Symbol *sym_FindScopedSymbol(char const *symName); // Find a scoped symbol by name; do not return `@` or `_NARG` when they have no value diff --git a/src/asm/charmap.cpp b/src/asm/charmap.cpp index fbd654c0..d82b6282 100644 --- a/src/asm/charmap.cpp +++ b/src/asm/charmap.cpp @@ -104,12 +104,6 @@ struct Charmap *charmap_New(char const *name, char const *baseName) return charmap; } -void charmap_Delete(struct Charmap *charmap) -{ - free(charmap->name); - free(charmap); -} - void charmap_Set(char const *name) { struct Charmap **charmap = (struct Charmap **)hash_GetNode(charmaps, name); diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index 107f1e9e..230d09b5 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -272,8 +272,10 @@ bool yywrap(void) lexer_DeleteState(context->lexerState); // Restore args if a macro (not REPT) saved them - if (context->fileInfo->type == NODE_MACRO) + if (context->fileInfo->type == NODE_MACRO) { + macro_FreeArgs(macro_GetCurrentArgs()); macro_UseNewArgs(contextStack->macroArgs); + } // Free the file stack node if (!context->fileInfo->referenced) free(context->fileInfo); diff --git a/src/asm/section.cpp b/src/asm/section.cpp index f822fd08..88624b66 100644 --- a/src/asm/section.cpp +++ b/src/asm/section.cpp @@ -677,18 +677,6 @@ void sect_Skip(uint32_t skip, bool ds) } } -// Output a NULL terminated string (excluding the NULL-character) -void sect_String(char const *s) -{ - if (!checkcodesection()) - return; - if (!reserveSpace(strlen(s))) - return; - - while (*s) - writebyte(*s++); -} - // Output a relocatable byte. Checking will be done to see if it // is an absolute value in disguise. void sect_RelByte(struct Expression *expr, uint32_t pcShift) diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp index c7acc5ed..546ae5dd 100644 --- a/src/asm/symbol.cpp +++ b/src/asm/symbol.cpp @@ -173,15 +173,6 @@ struct Symbol *sym_FindExactSymbol(char const *symName) return (struct Symbol *)hash_GetElement(symbols, symName); } -struct Symbol *sym_FindUnscopedSymbol(char const *symName) -{ - if (strchr(symName, '.')) { - error("Expected non-scoped symbol name, not \"%s\"\n", symName); - return NULL; - } - return sym_FindExactSymbol(symName); -} - struct Symbol *sym_FindScopedSymbol(char const *symName) { char const *localName = strchr(symName, '.'); diff --git a/src/opmath.cpp b/src/opmath.cpp index df283363..bf19dff8 100644 --- a/src/opmath.cpp +++ b/src/opmath.cpp @@ -60,7 +60,7 @@ int32_t op_shift_right(int32_t value, int32_t amount) // Repeat the easy cases here to avoid INT_MIN funny business if (amount == 0) return value; - if (value == 0 || amount <= -32) + if (value == 0 || amount < -31) return 0; if (amount > 31) return (value < 0) ? -1 : 0; @@ -84,10 +84,8 @@ int32_t op_shift_right_unsigned(int32_t value, int32_t amount) // Repeat the easy cases here to avoid INT_MIN funny business if (amount == 0) return value; - if (value == 0 || amount <= -32) + if (value == 0 || amount < -31 || amount > 31) return 0; - if (amount > 31) - return (value < 0) ? -1 : 0; if (amount < 0) return op_shift_left(value, -amount); diff --git a/test/asm/assert-fatal.asm b/test/asm/assert-fatal.asm new file mode 100644 index 00000000..7cef3161 --- /dev/null +++ b/test/asm/assert-fatal.asm @@ -0,0 +1 @@ +assert fatal, 2 + 2 == 5, "there are four lights" diff --git a/test/asm/assert-fatal.err b/test/asm/assert-fatal.err new file mode 100644 index 00000000..37d7c949 --- /dev/null +++ b/test/asm/assert-fatal.err @@ -0,0 +1,2 @@ +FATAL: assert-fatal.asm(1): + Assertion failed: there are four lights diff --git a/test/asm/assert@-no-sect.asm b/test/asm/assert@-no-sect.asm index 7df8df79..7ddbb2b1 100644 --- a/test/asm/assert@-no-sect.asm +++ b/test/asm/assert@-no-sect.asm @@ -1 +1 @@ -assert @ || 1 +assert (@) || 1 diff --git a/test/asm/builtin-overwrite.asm b/test/asm/builtin-overwrite.asm index 9f096339..2dc15d04 100644 --- a/test/asm/builtin-overwrite.asm +++ b/test/asm/builtin-overwrite.asm @@ -22,6 +22,10 @@ REDEF \1 = 0 REDEF \1 = 0 PRINTLN \1 +REDEF \1 EQU 0 +REDEF \1 EQU 0 +PRINTLN \1 + REDEF \1 EQUS "hello" REDEF \1 EQUS "hello" PRINTLN \1 diff --git a/test/asm/builtin-overwrite.err b/test/asm/builtin-overwrite.err index eb073cdb..1f77abd3 100644 --- a/test/asm/builtin-overwrite.err +++ b/test/asm/builtin-overwrite.err @@ -1,49 +1,57 @@ -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(5): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(5): Built-in symbol '__UTC_YEAR__' cannot be purged -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(6): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(6): Built-in symbol '__UTC_YEAR__' cannot be purged -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(9): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(9): '__UTC_YEAR__' already defined at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(10): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(10): '__UTC_YEAR__' already defined at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(13): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(13): '__UTC_YEAR__' already defined as constant at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(14): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(14): '__UTC_YEAR__' already defined as constant at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(17): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(17): '__UTC_YEAR__' already defined at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(18): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(18): '__UTC_YEAR__' already defined at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(21): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(21): '__UTC_YEAR__' already defined as constant at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(22): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(22): '__UTC_YEAR__' already defined as constant at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(25): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(25): + Built-in symbol '__UTC_YEAR__' cannot be redefined +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(26): + Built-in symbol '__UTC_YEAR__' cannot be redefined +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(29): '__UTC_YEAR__' already defined as non-EQUS at -error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(26): +error: builtin-overwrite.asm(36) -> builtin-overwrite.asm::tickle(30): '__UTC_YEAR__' already defined as non-EQUS at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(5): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(5): Built-in symbol '__ISO_8601_UTC__' cannot be purged -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(6): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(6): Built-in symbol '__ISO_8601_UTC__' cannot be purged -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(9): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(9): '__ISO_8601_UTC__' already defined at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(10): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(10): '__ISO_8601_UTC__' already defined at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(13): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(13): '__ISO_8601_UTC__' already defined as constant at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(14): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(14): '__ISO_8601_UTC__' already defined as constant at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(17): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(17): '__ISO_8601_UTC__' already defined at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(18): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(18): '__ISO_8601_UTC__' already defined at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(21): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(21): '__ISO_8601_UTC__' already defined as constant at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(22): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(22): '__ISO_8601_UTC__' already defined as constant at -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(25): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(25): + '__ISO_8601_UTC__' already defined as non-EQU at +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(26): + '__ISO_8601_UTC__' already defined as non-EQU at +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(29): Built-in symbol '__ISO_8601_UTC__' cannot be redefined -error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(26): +error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(30): Built-in symbol '__ISO_8601_UTC__' cannot be redefined -error: Assembly aborted (24 errors)! +error: Assembly aborted (28 errors)! diff --git a/test/asm/builtin-overwrite.out b/test/asm/builtin-overwrite.out index f0170b04..8f12a6c9 100644 --- a/test/asm/builtin-overwrite.out +++ b/test/asm/builtin-overwrite.out @@ -4,6 +4,8 @@ $7C5 $7C5 $7C5 $7C5 +$7C5 +1989-04-21T12:34:56Z 1989-04-21T12:34:56Z 1989-04-21T12:34:56Z 1989-04-21T12:34:56Z diff --git a/test/asm/charmap-inheritance.asm b/test/asm/charmap-inheritance.asm index eab9c12f..fca6a92f 100644 --- a/test/asm/charmap-inheritance.asm +++ b/test/asm/charmap-inheritance.asm @@ -21,3 +21,6 @@ SECTION "test", ROM0 ; This uses 'foo' by deriving another charmap from it. newcharmap bar, foo + + ; This is an error because 'eggs' does not exist. + newcharmap spam, eggs diff --git a/test/asm/charmap-inheritance.err b/test/asm/charmap-inheritance.err new file mode 100644 index 00000000..2bc3ba51 --- /dev/null +++ b/test/asm/charmap-inheritance.err @@ -0,0 +1,3 @@ +error: charmap-inheritance.asm(26): + Base charmap 'eggs' doesn't exist +error: Assembly aborted (1 error)! diff --git a/test/asm/crlf.asm b/test/asm/crlf.asm new file mode 100644 index 00000000..29d41be0 --- /dev/null +++ b/test/asm/crlf.asm @@ -0,0 +1,9 @@ +; This file is encoded with DOS CR+LF line endings! + +DEF s EQUS "Hello, \ +world!" +assert !strcmp("{s}", "Hello, world!") + +DEF t EQUS """Hello, +world!""" +assert !strcmp("{t}", "Hello,\nworld!") diff --git a/test/asm/def-scoped.asm b/test/asm/def-scoped.asm new file mode 100644 index 00000000..c67fb1bc --- /dev/null +++ b/test/asm/def-scoped.asm @@ -0,0 +1,16 @@ +SECTION "test", ROM0 + +; this is okay... +Label: +Label.local: + +; ...but these are not + +DEF n EQU 1 +DEF n.local EQU 2 + +DEF x = 1 +DEF x.local = 2 + +DEF s EQUS "..." +DEF s.local EQUS "..." diff --git a/test/asm/def-scoped.err b/test/asm/def-scoped.err new file mode 100644 index 00000000..ac3a412e --- /dev/null +++ b/test/asm/def-scoped.err @@ -0,0 +1,7 @@ +error: def-scoped.asm(10): + syntax error, unexpected local identifier, expecting identifier +error: def-scoped.asm(13): + syntax error, unexpected local identifier, expecting identifier +error: def-scoped.asm(16): + syntax error, unexpected local identifier, expecting identifier +error: Assembly aborted (3 errors)! diff --git a/test/asm/diff-marks.asm b/test/asm/diff-marks.asm new file mode 100644 index 00000000..ed74a16f --- /dev/null +++ b/test/asm/diff-marks.asm @@ -0,0 +1,3 @@ +SECTION "test", ROM0 +- ld a, 0 ++ xor a diff --git a/test/asm/diff-marks.err b/test/asm/diff-marks.err new file mode 100644 index 00000000..741e6d9e --- /dev/null +++ b/test/asm/diff-marks.err @@ -0,0 +1,5 @@ +error: diff-marks.asm(2): + syntax error, unexpected - at the beginning of the line (is it a leftover diff mark?) +error: diff-marks.asm(3): + syntax error, unexpected + at the beginning of the line (is it a leftover diff mark?) +error: Assembly aborted (2 errors)! diff --git a/test/asm/div-mod.asm b/test/asm/div-mod.asm index 2ef3f0d0..2103429d 100644 --- a/test/asm/div-mod.asm +++ b/test/asm/div-mod.asm @@ -22,9 +22,9 @@ MACRO test_mod ENDM MACRO test_each_mod - test_mod (\1), (\2) - test_mod (\1), -(\2) - test_mod -(\1), (\2) + test_mod +(\1), +(\2) + test_mod +(\1), -(\2) + test_mod -(\1), +(\2) test_mod -(\1), -(\2) ENDM @@ -38,8 +38,8 @@ MACRO test_pow ENDM MACRO test_each_pow - test_pow (\1), (\2) - test_pow -(\1), (\2) + test_pow +(\1), +(\2) + test_pow -(\1), +(\2) ENDM test_each_mod 0, 1 diff --git a/test/asm/fail.asm b/test/asm/fail.asm new file mode 100644 index 00000000..132c44a7 --- /dev/null +++ b/test/asm/fail.asm @@ -0,0 +1 @@ +fail "oops" diff --git a/test/asm/fail.err b/test/asm/fail.err new file mode 100644 index 00000000..da33aef7 --- /dev/null +++ b/test/asm/fail.err @@ -0,0 +1,2 @@ +FATAL: fail.asm(1): + oops diff --git a/test/asm/invalid-instructions.asm b/test/asm/invalid-instructions.asm new file mode 100644 index 00000000..3ed9580f --- /dev/null +++ b/test/asm/invalid-instructions.asm @@ -0,0 +1,8 @@ +SECTION "invalid", ROM0[$10000] + ld [hl], [hl] + ld a, [$00ff+c] + ld b, [c] + ld b, [bc] + ld b, [$4000] + bit 8, a + rst $40 diff --git a/test/asm/invalid-instructions.err b/test/asm/invalid-instructions.err new file mode 100644 index 00000000..eb2663bd --- /dev/null +++ b/test/asm/invalid-instructions.err @@ -0,0 +1,17 @@ +error: invalid-instructions.asm(1): + Address $10000 is not 16-bit +error: invalid-instructions.asm(2): + LD [HL],[HL] not a valid instruction +error: invalid-instructions.asm(3): + Expected constant expression equal to $FF00 for "$ff00+c" +error: invalid-instructions.asm(4): + Destination operand must be A +error: invalid-instructions.asm(5): + Destination operand must be A +error: invalid-instructions.asm(6): + Destination operand must be A +error: invalid-instructions.asm(7): + Immediate value must be 3-bit +error: invalid-instructions.asm(8): + Invalid address $40 for RST +error: Assembly aborted (8 errors)! diff --git a/test/asm/invalid-numbers.asm b/test/asm/invalid-numbers.asm new file mode 100644 index 00000000..cb0c033c --- /dev/null +++ b/test/asm/invalid-numbers.asm @@ -0,0 +1,17 @@ +; no digits +def x = $ +def x = ` + +; too large +def x = 9_876_543_210 +def x = $f_0000_0000 +def x = &400_0000_0000 +def x = %1_00000000_00000000_00000000_00000000 +def x = 65537.0q16 + +; no precision suffix +def x = 3.14q + +; invalid precision suffix +def x = 3.14q40 + diff --git a/test/asm/invalid-numbers.err b/test/asm/invalid-numbers.err new file mode 100644 index 00000000..fbd67c11 --- /dev/null +++ b/test/asm/invalid-numbers.err @@ -0,0 +1,19 @@ +error: invalid-numbers.asm(2): + Invalid integer constant, no digits after '$' +error: invalid-numbers.asm(3): + Invalid graphics constant, no digits after '`' +warning: invalid-numbers.asm(6): [-Wlarge-constant] + Integer constant is too large +warning: invalid-numbers.asm(7): [-Wlarge-constant] + Integer constant is too large +warning: invalid-numbers.asm(8): [-Wlarge-constant] + Integer constant is too large +warning: invalid-numbers.asm(9): [-Wlarge-constant] + Integer constant is too large +warning: invalid-numbers.asm(10): [-Wlarge-constant] + Magnitude of fixed-point constant is too large +error: invalid-numbers.asm(13): + Invalid fixed-point constant, no significant digits after 'q' +error: invalid-numbers.asm(16): + Fixed-point constant precision must be between 1 and 31 +error: Assembly aborted (4 errors)! diff --git a/test/asm/math.asm b/test/asm/math.asm index d56a2f46..b189fca8 100644 --- a/test/asm/math.asm +++ b/test/asm/math.asm @@ -15,6 +15,7 @@ ENDM test -(v 3)**(v 4) == (v -81) test (v 1) << (v 30) == (v $4000_0000) test (v 2)**(v 30) == (v $4000_0000) + test (v 37)/(v 2) == (v 18) assert DIV(5.0, 2.0) == 2.5 assert DIV(-5.0, 2.0) == -2.5 diff --git a/test/asm/modzero-instr.asm b/test/asm/modzero-instr.asm new file mode 100644 index 00000000..7fdd6c19 --- /dev/null +++ b/test/asm/modzero-instr.asm @@ -0,0 +1,2 @@ +SECTION "sec", ROM0 + ld a, 1 % 0 diff --git a/test/asm/modzero-instr.err b/test/asm/modzero-instr.err new file mode 100644 index 00000000..d99f2413 --- /dev/null +++ b/test/asm/modzero-instr.err @@ -0,0 +1,2 @@ +FATAL: modzero-instr.asm(2): + Modulo by zero diff --git a/test/asm/negative-exponent.asm b/test/asm/negative-exponent.asm new file mode 100644 index 00000000..7ed9110f --- /dev/null +++ b/test/asm/negative-exponent.asm @@ -0,0 +1 @@ +assert 1 ** -1 == 1 ; mathematically yes, technically no diff --git a/test/asm/negative-exponent.err b/test/asm/negative-exponent.err new file mode 100644 index 00000000..f49e2648 --- /dev/null +++ b/test/asm/negative-exponent.err @@ -0,0 +1,2 @@ +FATAL: negative-exponent.asm(1): + Exponentiation by negative power diff --git a/test/asm/purge-multiple.asm b/test/asm/purge-multiple.asm new file mode 100644 index 00000000..43330969 --- /dev/null +++ b/test/asm/purge-multiple.asm @@ -0,0 +1,9 @@ +SECTION "s", ROM0 +u:: +def v = 0 +def w equ 1 +def x equs "2" +MACRO y +ENDM +; purge many symbols at once to test parser reallocation +PURGE u, v, w, x, y diff --git a/test/asm/redef-equ.asm b/test/asm/redef-equ.asm index 012cdd64..ccf254da 100644 --- a/test/asm/redef-equ.asm +++ b/test/asm/redef-equ.asm @@ -19,5 +19,7 @@ ENDM item 9 println LENGTH_SQUARES, SQUARES_1, SQUARES_2, SQUARES_3 +REDEF NEW EQU 7 + DEF N EQUS "X" REDEF N EQU 42 diff --git a/test/asm/redef-equ.err b/test/asm/redef-equ.err index 6ad6aff0..50e1b699 100644 --- a/test/asm/redef-equ.err +++ b/test/asm/redef-equ.err @@ -1,3 +1,3 @@ -error: redef-equ.asm(23): - 'N' already defined as non-EQU at redef-equ.asm(22) +error: redef-equ.asm(25): + 'N' already defined as non-EQU at redef-equ.asm(24) error: Assembly aborted (1 error)! diff --git a/test/asm/redef-equs.asm b/test/asm/redef-equs.asm index 6b662ef5..aad65c57 100644 --- a/test/asm/redef-equs.asm +++ b/test/asm/redef-equs.asm @@ -19,5 +19,7 @@ ENDM list FOO, 1, A, 2, B PRINTLN "{FOO}" +REDEF NEW EQUS "NEW" + DEF N EQU 42 REDEF N EQUS "X" diff --git a/test/asm/redef-equs.err b/test/asm/redef-equs.err index 22b981b6..502d64ac 100644 --- a/test/asm/redef-equs.err +++ b/test/asm/redef-equs.err @@ -1,3 +1,3 @@ -error: redef-equs.asm(23): - 'N' already defined as non-EQUS at redef-equs.asm(22) +error: redef-equs.asm(25): + 'N' already defined as non-EQUS at redef-equs.asm(24) error: Assembly aborted (1 error)! diff --git a/test/asm/shift.asm b/test/asm/shift.asm index c4e9b2b7..7b782a2f 100644 --- a/test/asm/shift.asm +++ b/test/asm/shift.asm @@ -24,6 +24,16 @@ section "test", ROM0[0] test -4 >> 2 test -1 >> -9001 + test 100 << -2 + test 1 >> -2 + + test 100 >>> 16 + test 100 >>> -16 + test 100 >>> 32 + test 100 >>> -32 + test -100 >>> 32 + test -100 >>> -32 + test $DEADBEEF >> 1 test $DEADBEEF >>> 1 diff --git a/test/asm/shift.err b/test/asm/shift.err index db23d16e..5743f1e6 100644 --- a/test/asm/shift.err +++ b/test/asm/shift.err @@ -24,5 +24,19 @@ warning: shift.asm(25) -> shift.asm::test(8): [-Wshift] Shifting right negative value -1 warning: shift.asm(25) -> shift.asm::test(8): [-Wshift-amount] Shifting right by negative amount -9001 -warning: shift.asm(27) -> shift.asm::test(8): [-Wshift] +warning: shift.asm(27) -> shift.asm::test(8): [-Wshift-amount] + Shifting left by negative amount -2 +warning: shift.asm(28) -> shift.asm::test(8): [-Wshift-amount] + Shifting right by negative amount -2 +warning: shift.asm(31) -> shift.asm::test(8): [-Wshift-amount] + Shifting right by negative amount -16 +warning: shift.asm(32) -> shift.asm::test(8): [-Wshift-amount] + Shifting right by large amount 32 +warning: shift.asm(33) -> shift.asm::test(8): [-Wshift-amount] + Shifting right by negative amount -32 +warning: shift.asm(34) -> shift.asm::test(8): [-Wshift-amount] + Shifting right by large amount 32 +warning: shift.asm(35) -> shift.asm::test(8): [-Wshift-amount] + Shifting right by negative amount -32 +warning: shift.asm(37) -> shift.asm::test(8): [-Wshift] Shifting right negative value -559038737 diff --git a/test/asm/shift.out b/test/asm/shift.out index 9a5b3a7d..d9140076 100644 --- a/test/asm/shift.out +++ b/test/asm/shift.out @@ -10,5 +10,13 @@ -4 >> 1 = $FFFFFFFE -4 >> 2 = $FFFFFFFF -1 >> -9001 = $0 +100 << -2 = $19 +1 >> -2 = $4 +100 >>> 16 = $0 +100 >>> -16 = $640000 +100 >>> 32 = $0 +100 >>> -32 = $0 +-100 >>> 32 = $0 +-100 >>> -32 = $0 $DEADBEEF >> 1 = $EF56DF77 $DEADBEEF >>> 1 = $6F56DF77 diff --git a/test/asm/shift.out.bin b/test/asm/shift.out.bin index 03e55714..6762c150 100644 Binary files a/test/asm/shift.out.bin and b/test/asm/shift.out.bin differ diff --git a/test/asm/strfmt.asm b/test/asm/strfmt.asm index 0e7c9a8f..d4263090 100644 --- a/test/asm/strfmt.asm +++ b/test/asm/strfmt.asm @@ -8,6 +8,8 @@ DEF N = 112 DEF FMT EQUS "X" PRINTLN STRFMT("\tdb %#03{s:FMT} %% 26\t; %#03{FMT}", N, N % 26) +PRINTLN STRFMT("%d = %#x = %#b = %#o != %f", 42, 42, 42, 42, 42.0) + DEF TEMPLATE EQUS "\"%s are %s\\n\"" PRINT STRFMT(TEMPLATE, "roses", "red") PRINT STRFMT(TEMPLATE, "violets", "blue") diff --git a/test/asm/strfmt.err b/test/asm/strfmt.err index c8947eb2..af9a6376 100644 --- a/test/asm/strfmt.err +++ b/test/asm/strfmt.err @@ -1,11 +1,11 @@ -error: strfmt.asm(14): +error: strfmt.asm(16): Formatting number as type 's' -error: strfmt.asm(14): +error: strfmt.asm(16): STRFMT: 1 unformatted argument(s) -error: strfmt.asm(22): - STRFMT: Illegal '%' at end of format string error: strfmt.asm(24): - STRFMT: Invalid format spec for argument 1 + STRFMT: Illegal '%' at end of format string error: strfmt.asm(26): + STRFMT: Invalid format spec for argument 1 +error: strfmt.asm(28): STRFMT: Not enough arguments for format spec, got: 1, need: 3 error: Assembly aborted (5 errors)! diff --git a/test/asm/strfmt.out b/test/asm/strfmt.out index 0640f476..30884f81 100644 --- a/test/asm/strfmt.out +++ b/test/asm/strfmt.out @@ -1,6 +1,7 @@ Hello world! I am 15 years old today! signed -000000042 == unsigned 4294967254 db $70 % 26 ; $08 +42 = $2a = %101010 = &52 != 42.00000 roses are red violets are blue void are 0 diff --git a/test/asm/string-formatting.asm b/test/asm/string-formatting.asm index aeed5d11..12bdd1aa 100644 --- a/test/asm/string-formatting.asm +++ b/test/asm/string-formatting.asm @@ -10,7 +10,7 @@ def s equs "hello" println "<{#-10s:s}> <{10s:s}>" macro foo - println "<{\1}>" + println "\1 <{\1}>" endm foo -6d:n ; space is trimmed diff --git a/test/asm/string-formatting.out b/test/asm/string-formatting.out index a27663a9..4d7d175b 100644 --- a/test/asm/string-formatting.out +++ b/test/asm/string-formatting.out @@ -2,4 +2,4 @@ <4294967254> <-42> <&000037777777726> <3.14159> <-00123> <-123.0455932617> < hello> -<300 > +-6d:n <300 > diff --git a/test/asm/trigonometry.asm b/test/asm/trigonometry.asm index e9669fcd..2a16ef59 100644 --- a/test/asm/trigonometry.asm +++ b/test/asm/trigonometry.asm @@ -13,9 +13,11 @@ for Q, 2, 31 if Q > 2 ; can't represent 0.125 in Q.2 assert tan(0.125) == 1.0 assert atan(1.0) == 0.125 + assert atan2(1.0, 1.0) == 0.125 else assert tan(0.0) == 0.0 assert atan(0.0) == 0.0 + assert atan2(0.0, 1.0) == 0.0 endc endr diff --git a/test/asm/utc-time.asm b/test/asm/utc-time.asm index 38c56ae6..19b662ee 100644 --- a/test/asm/utc-time.asm +++ b/test/asm/utc-time.asm @@ -1,5 +1,5 @@ MACRO between - assert (\1) <= (\2) && (\2) <= (\3) + assert (\2) >= (\1) && (\2) <= (\3) ENDM between 0, __UTC_YEAR__, 9999 ; Y10K problem... diff --git a/test/link/all-instructions.asm b/test/link/all-instructions.asm index 3c181e3d..3cbb6526 100644 --- a/test/link/all-instructions.asm +++ b/test/link/all-instructions.asm @@ -169,12 +169,16 @@ ENDM ld [hl+],a ld [hli],a + ldi [hl],a ld [hl-],a ld [hld],a + ldd [hl],a ld a,[hl+] ld a,[hli] + ldi a,[hl] ld a,[hl-] ld a,[hld] + ldd a,[hl] ; Jumps and Subroutines diff --git a/test/link/all-instructions.out.bin b/test/link/all-instructions.out.bin index ddd5cdaf..c2623fec 100644 Binary files a/test/link/all-instructions.out.bin and b/test/link/all-instructions.out.bin differ