mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add more test coverage for RGBASM (#1256)
This also fixes two bugs: `-1 >>> 32` was -1 not 0, and `macro_FreeArgs` should have been called but wasn't.
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
#define DEFAULT_CHARMAP_NAME "main"
|
#define DEFAULT_CHARMAP_NAME "main"
|
||||||
|
|
||||||
struct Charmap *charmap_New(char const *name, char const *baseName);
|
struct Charmap *charmap_New(char const *name, char const *baseName);
|
||||||
void charmap_Delete(struct Charmap *charmap);
|
|
||||||
void charmap_Set(char const *name);
|
void charmap_Set(char const *name);
|
||||||
void charmap_Push(void);
|
void charmap_Push(void);
|
||||||
void charmap_Pop(void);
|
void charmap_Pop(void);
|
||||||
|
|||||||
@@ -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_AbsWordGroup(uint8_t const *s, size_t length);
|
||||||
void sect_AbsLongGroup(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_Skip(uint32_t skip, bool ds);
|
||||||
void sect_String(char const *s);
|
|
||||||
void sect_RelByte(struct Expression *expr, uint32_t pcShift);
|
void sect_RelByte(struct Expression *expr, uint32_t pcShift);
|
||||||
void sect_RelBytes(uint32_t n, struct Expression *exprs, size_t size);
|
void sect_RelBytes(uint32_t n, struct Expression *exprs, size_t size);
|
||||||
void sect_RelWord(struct Expression *expr, uint32_t pcShift);
|
void sect_RelWord(struct Expression *expr, uint32_t pcShift);
|
||||||
|
|||||||
@@ -117,8 +117,6 @@ uint32_t sym_GetConstantSymValue(struct Symbol const *sym);
|
|||||||
uint32_t sym_GetConstantValue(char const *symName);
|
uint32_t sym_GetConstantValue(char const *symName);
|
||||||
// Find a symbol by exact name, bypassing expansion checks
|
// Find a symbol by exact name, bypassing expansion checks
|
||||||
struct Symbol *sym_FindExactSymbol(char const *symName);
|
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
|
// Find a symbol, possibly scoped, by name
|
||||||
struct Symbol *sym_FindScopedSymbol(char const *symName);
|
struct Symbol *sym_FindScopedSymbol(char const *symName);
|
||||||
// Find a scoped symbol by name; do not return `@` or `_NARG` when they have no value
|
// Find a scoped symbol by name; do not return `@` or `_NARG` when they have no value
|
||||||
|
|||||||
@@ -104,12 +104,6 @@ struct Charmap *charmap_New(char const *name, char const *baseName)
|
|||||||
return charmap;
|
return charmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void charmap_Delete(struct Charmap *charmap)
|
|
||||||
{
|
|
||||||
free(charmap->name);
|
|
||||||
free(charmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void charmap_Set(char const *name)
|
void charmap_Set(char const *name)
|
||||||
{
|
{
|
||||||
struct Charmap **charmap = (struct Charmap **)hash_GetNode(charmaps, name);
|
struct Charmap **charmap = (struct Charmap **)hash_GetNode(charmaps, name);
|
||||||
|
|||||||
@@ -272,8 +272,10 @@ bool yywrap(void)
|
|||||||
|
|
||||||
lexer_DeleteState(context->lexerState);
|
lexer_DeleteState(context->lexerState);
|
||||||
// Restore args if a macro (not REPT) saved them
|
// 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);
|
macro_UseNewArgs(contextStack->macroArgs);
|
||||||
|
}
|
||||||
// Free the file stack node
|
// Free the file stack node
|
||||||
if (!context->fileInfo->referenced)
|
if (!context->fileInfo->referenced)
|
||||||
free(context->fileInfo);
|
free(context->fileInfo);
|
||||||
|
|||||||
@@ -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
|
// Output a relocatable byte. Checking will be done to see if it
|
||||||
// is an absolute value in disguise.
|
// is an absolute value in disguise.
|
||||||
void sect_RelByte(struct Expression *expr, uint32_t pcShift)
|
void sect_RelByte(struct Expression *expr, uint32_t pcShift)
|
||||||
|
|||||||
@@ -173,15 +173,6 @@ struct Symbol *sym_FindExactSymbol(char const *symName)
|
|||||||
return (struct Symbol *)hash_GetElement(symbols, 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)
|
struct Symbol *sym_FindScopedSymbol(char const *symName)
|
||||||
{
|
{
|
||||||
char const *localName = strchr(symName, '.');
|
char const *localName = strchr(symName, '.');
|
||||||
|
|||||||
@@ -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
|
// Repeat the easy cases here to avoid INT_MIN funny business
|
||||||
if (amount == 0)
|
if (amount == 0)
|
||||||
return value;
|
return value;
|
||||||
if (value == 0 || amount <= -32)
|
if (value == 0 || amount < -31)
|
||||||
return 0;
|
return 0;
|
||||||
if (amount > 31)
|
if (amount > 31)
|
||||||
return (value < 0) ? -1 : 0;
|
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
|
// Repeat the easy cases here to avoid INT_MIN funny business
|
||||||
if (amount == 0)
|
if (amount == 0)
|
||||||
return value;
|
return value;
|
||||||
if (value == 0 || amount <= -32)
|
if (value == 0 || amount < -31 || amount > 31)
|
||||||
return 0;
|
return 0;
|
||||||
if (amount > 31)
|
|
||||||
return (value < 0) ? -1 : 0;
|
|
||||||
if (amount < 0)
|
if (amount < 0)
|
||||||
return op_shift_left(value, -amount);
|
return op_shift_left(value, -amount);
|
||||||
|
|
||||||
|
|||||||
1
test/asm/assert-fatal.asm
Normal file
1
test/asm/assert-fatal.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
assert fatal, 2 + 2 == 5, "there are four lights"
|
||||||
2
test/asm/assert-fatal.err
Normal file
2
test/asm/assert-fatal.err
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FATAL: assert-fatal.asm(1):
|
||||||
|
Assertion failed: there are four lights
|
||||||
@@ -1 +1 @@
|
|||||||
assert @ || 1
|
assert (@) || 1
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ REDEF \1 = 0
|
|||||||
REDEF \1 = 0
|
REDEF \1 = 0
|
||||||
PRINTLN \1
|
PRINTLN \1
|
||||||
|
|
||||||
|
REDEF \1 EQU 0
|
||||||
|
REDEF \1 EQU 0
|
||||||
|
PRINTLN \1
|
||||||
|
|
||||||
REDEF \1 EQUS "hello"
|
REDEF \1 EQUS "hello"
|
||||||
REDEF \1 EQUS "hello"
|
REDEF \1 EQUS "hello"
|
||||||
PRINTLN \1
|
PRINTLN \1
|
||||||
|
|||||||
@@ -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
|
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
|
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 <command-line>
|
'__UTC_YEAR__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined as non-EQUS at <command-line>
|
||||||
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 <command-line>
|
'__UTC_YEAR__' already defined as non-EQUS at <command-line>
|
||||||
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
|
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
|
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 <command-line>
|
'__ISO_8601_UTC__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
'__ISO_8601_UTC__' already defined as constant at <command-line>
|
||||||
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 <command-line>
|
||||||
|
error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(26):
|
||||||
|
'__ISO_8601_UTC__' already defined as non-EQU at <command-line>
|
||||||
|
error: builtin-overwrite.asm(37) -> builtin-overwrite.asm::tickle(29):
|
||||||
Built-in symbol '__ISO_8601_UTC__' cannot be redefined
|
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
|
Built-in symbol '__ISO_8601_UTC__' cannot be redefined
|
||||||
error: Assembly aborted (24 errors)!
|
error: Assembly aborted (28 errors)!
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ $7C5
|
|||||||
$7C5
|
$7C5
|
||||||
$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
|
1989-04-21T12:34:56Z
|
||||||
1989-04-21T12:34:56Z
|
1989-04-21T12:34:56Z
|
||||||
|
|||||||
@@ -21,3 +21,6 @@ SECTION "test", ROM0
|
|||||||
|
|
||||||
; This uses 'foo' by deriving another charmap from it.
|
; This uses 'foo' by deriving another charmap from it.
|
||||||
newcharmap bar, foo
|
newcharmap bar, foo
|
||||||
|
|
||||||
|
; This is an error because 'eggs' does not exist.
|
||||||
|
newcharmap spam, eggs
|
||||||
|
|||||||
3
test/asm/charmap-inheritance.err
Normal file
3
test/asm/charmap-inheritance.err
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
error: charmap-inheritance.asm(26):
|
||||||
|
Base charmap 'eggs' doesn't exist
|
||||||
|
error: Assembly aborted (1 error)!
|
||||||
9
test/asm/crlf.asm
Normal file
9
test/asm/crlf.asm
Normal file
@@ -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!")
|
||||||
16
test/asm/def-scoped.asm
Normal file
16
test/asm/def-scoped.asm
Normal file
@@ -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 "..."
|
||||||
7
test/asm/def-scoped.err
Normal file
7
test/asm/def-scoped.err
Normal file
@@ -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)!
|
||||||
3
test/asm/diff-marks.asm
Normal file
3
test/asm/diff-marks.asm
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
SECTION "test", ROM0
|
||||||
|
- ld a, 0
|
||||||
|
+ xor a
|
||||||
5
test/asm/diff-marks.err
Normal file
5
test/asm/diff-marks.err
Normal file
@@ -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)!
|
||||||
@@ -22,9 +22,9 @@ MACRO test_mod
|
|||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
MACRO test_each_mod
|
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)
|
test_mod -(\1), -(\2)
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ MACRO test_pow
|
|||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
MACRO test_each_pow
|
MACRO test_each_pow
|
||||||
test_pow (\1), (\2)
|
test_pow +(\1), +(\2)
|
||||||
test_pow -(\1), (\2)
|
test_pow -(\1), +(\2)
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
test_each_mod 0, 1
|
test_each_mod 0, 1
|
||||||
|
|||||||
1
test/asm/fail.asm
Normal file
1
test/asm/fail.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
fail "oops"
|
||||||
2
test/asm/fail.err
Normal file
2
test/asm/fail.err
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FATAL: fail.asm(1):
|
||||||
|
oops
|
||||||
8
test/asm/invalid-instructions.asm
Normal file
8
test/asm/invalid-instructions.asm
Normal file
@@ -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
|
||||||
17
test/asm/invalid-instructions.err
Normal file
17
test/asm/invalid-instructions.err
Normal file
@@ -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)!
|
||||||
17
test/asm/invalid-numbers.asm
Normal file
17
test/asm/invalid-numbers.asm
Normal file
@@ -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
|
||||||
|
|
||||||
19
test/asm/invalid-numbers.err
Normal file
19
test/asm/invalid-numbers.err
Normal file
@@ -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)!
|
||||||
@@ -15,6 +15,7 @@ ENDM
|
|||||||
test -(v 3)**(v 4) == (v -81)
|
test -(v 3)**(v 4) == (v -81)
|
||||||
test (v 1) << (v 30) == (v $4000_0000)
|
test (v 1) << (v 30) == (v $4000_0000)
|
||||||
test (v 2)**(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
|
||||||
assert DIV(-5.0, 2.0) == -2.5
|
assert DIV(-5.0, 2.0) == -2.5
|
||||||
|
|||||||
2
test/asm/modzero-instr.asm
Normal file
2
test/asm/modzero-instr.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
ld a, 1 % 0
|
||||||
2
test/asm/modzero-instr.err
Normal file
2
test/asm/modzero-instr.err
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FATAL: modzero-instr.asm(2):
|
||||||
|
Modulo by zero
|
||||||
1
test/asm/negative-exponent.asm
Normal file
1
test/asm/negative-exponent.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
assert 1 ** -1 == 1 ; mathematically yes, technically no
|
||||||
2
test/asm/negative-exponent.err
Normal file
2
test/asm/negative-exponent.err
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FATAL: negative-exponent.asm(1):
|
||||||
|
Exponentiation by negative power
|
||||||
9
test/asm/purge-multiple.asm
Normal file
9
test/asm/purge-multiple.asm
Normal file
@@ -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
|
||||||
@@ -19,5 +19,7 @@ ENDM
|
|||||||
item 9
|
item 9
|
||||||
println LENGTH_SQUARES, SQUARES_1, SQUARES_2, SQUARES_3
|
println LENGTH_SQUARES, SQUARES_1, SQUARES_2, SQUARES_3
|
||||||
|
|
||||||
|
REDEF NEW EQU 7
|
||||||
|
|
||||||
DEF N EQUS "X"
|
DEF N EQUS "X"
|
||||||
REDEF N EQU 42
|
REDEF N EQU 42
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
error: redef-equ.asm(23):
|
error: redef-equ.asm(25):
|
||||||
'N' already defined as non-EQU at redef-equ.asm(22)
|
'N' already defined as non-EQU at redef-equ.asm(24)
|
||||||
error: Assembly aborted (1 error)!
|
error: Assembly aborted (1 error)!
|
||||||
|
|||||||
@@ -19,5 +19,7 @@ ENDM
|
|||||||
list FOO, 1, A, 2, B
|
list FOO, 1, A, 2, B
|
||||||
PRINTLN "{FOO}"
|
PRINTLN "{FOO}"
|
||||||
|
|
||||||
|
REDEF NEW EQUS "NEW"
|
||||||
|
|
||||||
DEF N EQU 42
|
DEF N EQU 42
|
||||||
REDEF N EQUS "X"
|
REDEF N EQUS "X"
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
error: redef-equs.asm(23):
|
error: redef-equs.asm(25):
|
||||||
'N' already defined as non-EQUS at redef-equs.asm(22)
|
'N' already defined as non-EQUS at redef-equs.asm(24)
|
||||||
error: Assembly aborted (1 error)!
|
error: Assembly aborted (1 error)!
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ section "test", ROM0[0]
|
|||||||
test -4 >> 2
|
test -4 >> 2
|
||||||
test -1 >> -9001
|
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
|
||||||
test $DEADBEEF >>> 1
|
test $DEADBEEF >>> 1
|
||||||
|
|
||||||
|
|||||||
@@ -24,5 +24,19 @@ warning: shift.asm(25) -> shift.asm::test(8): [-Wshift]
|
|||||||
Shifting right negative value -1
|
Shifting right negative value -1
|
||||||
warning: shift.asm(25) -> shift.asm::test(8): [-Wshift-amount]
|
warning: shift.asm(25) -> shift.asm::test(8): [-Wshift-amount]
|
||||||
Shifting right by negative amount -9001
|
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
|
Shifting right negative value -559038737
|
||||||
|
|||||||
@@ -10,5 +10,13 @@
|
|||||||
-4 >> 1 = $FFFFFFFE
|
-4 >> 1 = $FFFFFFFE
|
||||||
-4 >> 2 = $FFFFFFFF
|
-4 >> 2 = $FFFFFFFF
|
||||||
-1 >> -9001 = $0
|
-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 = $EF56DF77
|
||||||
$DEADBEEF >>> 1 = $6F56DF77
|
$DEADBEEF >>> 1 = $6F56DF77
|
||||||
|
|||||||
Binary file not shown.
@@ -8,6 +8,8 @@ DEF N = 112
|
|||||||
DEF FMT EQUS "X"
|
DEF FMT EQUS "X"
|
||||||
PRINTLN STRFMT("\tdb %#03{s:FMT} %% 26\t; %#03{FMT}", N, N % 26)
|
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\""
|
DEF TEMPLATE EQUS "\"%s are %s\\n\""
|
||||||
PRINT STRFMT(TEMPLATE, "roses", "red")
|
PRINT STRFMT(TEMPLATE, "roses", "red")
|
||||||
PRINT STRFMT(TEMPLATE, "violets", "blue")
|
PRINT STRFMT(TEMPLATE, "violets", "blue")
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
error: strfmt.asm(14):
|
error: strfmt.asm(16):
|
||||||
Formatting number as type 's'
|
Formatting number as type 's'
|
||||||
error: strfmt.asm(14):
|
error: strfmt.asm(16):
|
||||||
STRFMT: 1 unformatted argument(s)
|
STRFMT: 1 unformatted argument(s)
|
||||||
error: strfmt.asm(22):
|
|
||||||
STRFMT: Illegal '%' at end of format string
|
|
||||||
error: strfmt.asm(24):
|
error: strfmt.asm(24):
|
||||||
STRFMT: Invalid format spec for argument 1
|
STRFMT: Illegal '%' at end of format string
|
||||||
error: strfmt.asm(26):
|
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
|
STRFMT: Not enough arguments for format spec, got: 1, need: 3
|
||||||
error: Assembly aborted (5 errors)!
|
error: Assembly aborted (5 errors)!
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
Hello world! I am 15 years old today!
|
Hello world! I am 15 years old today!
|
||||||
signed -000000042 == unsigned 4294967254
|
signed -000000042 == unsigned 4294967254
|
||||||
db $70 % 26 ; $08
|
db $70 % 26 ; $08
|
||||||
|
42 = $2a = %101010 = &52 != 42.00000
|
||||||
roses are red
|
roses are red
|
||||||
violets are blue
|
violets are blue
|
||||||
void are 0
|
void are 0
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ def s equs "hello"
|
|||||||
println "<{#-10s:s}> <{10s:s}>"
|
println "<{#-10s:s}> <{10s:s}>"
|
||||||
|
|
||||||
macro foo
|
macro foo
|
||||||
println "<{\1}>"
|
println "\1 <{\1}>"
|
||||||
endm
|
endm
|
||||||
|
|
||||||
foo -6d:n ; space is trimmed
|
foo -6d:n ; space is trimmed
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
<4294967254> <-42> <&000037777777726>
|
<4294967254> <-42> <&000037777777726>
|
||||||
<3.14159> <-00123> <-123.0455932617>
|
<3.14159> <-00123> <-123.0455932617>
|
||||||
<hello > < hello>
|
<hello > < hello>
|
||||||
<300 >
|
-6d:n <300 >
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ for Q, 2, 31
|
|||||||
if Q > 2 ; can't represent 0.125 in Q.2
|
if Q > 2 ; can't represent 0.125 in Q.2
|
||||||
assert tan(0.125) == 1.0
|
assert tan(0.125) == 1.0
|
||||||
assert atan(1.0) == 0.125
|
assert atan(1.0) == 0.125
|
||||||
|
assert atan2(1.0, 1.0) == 0.125
|
||||||
else
|
else
|
||||||
assert tan(0.0) == 0.0
|
assert tan(0.0) == 0.0
|
||||||
assert atan(0.0) == 0.0
|
assert atan(0.0) == 0.0
|
||||||
|
assert atan2(0.0, 1.0) == 0.0
|
||||||
endc
|
endc
|
||||||
endr
|
endr
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
MACRO between
|
MACRO between
|
||||||
assert (\1) <= (\2) && (\2) <= (\3)
|
assert (\2) >= (\1) && (\2) <= (\3)
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
between 0, __UTC_YEAR__, 9999 ; Y10K problem...
|
between 0, __UTC_YEAR__, 9999 ; Y10K problem...
|
||||||
|
|||||||
@@ -169,12 +169,16 @@ ENDM
|
|||||||
|
|
||||||
ld [hl+],a
|
ld [hl+],a
|
||||||
ld [hli],a
|
ld [hli],a
|
||||||
|
ldi [hl],a
|
||||||
ld [hl-],a
|
ld [hl-],a
|
||||||
ld [hld],a
|
ld [hld],a
|
||||||
|
ldd [hl],a
|
||||||
ld a,[hl+]
|
ld a,[hl+]
|
||||||
ld a,[hli]
|
ld a,[hli]
|
||||||
|
ldi a,[hl]
|
||||||
ld a,[hl-]
|
ld a,[hl-]
|
||||||
ld a,[hld]
|
ld a,[hld]
|
||||||
|
ldd a,[hl]
|
||||||
|
|
||||||
; Jumps and Subroutines
|
; Jumps and Subroutines
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user