Commit Graph

298 Commits

Author SHA1 Message Date
Anthony J. Bentley a3e95f99d2 rgbasm: Fix a division by zero in section address specifiers. 2015-01-27 04:56:42 -07:00
Anthony J. Bentley e3a31d7e59 Correct test output for divzero-section-bank. 2015-01-27 04:48:25 -07:00
Anthony J. Bentley d9f5ce339a Add some basic regression tests.
Most cause crashes. Only macro-@ works correctly; the others need to
be fixed.
2015-01-27 04:33:38 -07:00
Anthony J. Bentley 361f1ac50b Work around a crash when '@' is interpreted as a macro name. v0.2.2 2015-01-22 21:12:57 -07:00
Anthony J. Bentley 4f8cf84ed4 rgbasm: improve (some) pathological spacing. 2015-01-22 21:09:10 -07:00
Anthony J. Bentley c75b9d4d55 Makefile: don't expand variables in a non-POSIXish way. 2015-01-22 20:42:27 -07:00
Anthony J. Bentley cd2af0204e rgbasm: Save some horizontal space in main.c. 2015-01-22 20:33:07 -07:00
yenatch 91241b44da rgbasm: bump MAXMACROARGS up to 256 from 9 2015-01-19 23:28:09 -08:00
Anthony J. Bentley 1d174f37da rgbasm: Convert oDontExpandStrings to bool. 2015-01-07 23:52:22 -07:00
Anthony J. Bentley 2777044f70 Delete some unused functions. 2015-01-07 23:39:00 -07:00
Anthony J. Bentley e5e64b8cec rgbasm: trim ludicrously redundant comments. 2015-01-07 23:36:08 -07:00
Anthony J. Bentley 8534f3a148 Unify usage strings/functions across programs.
The funny spacing is to make it easier to keep to 80 characters/line.
2015-01-07 23:13:18 -07:00
Anthony J. Bentley bdc6401eba rgbfix: deal with options and arguments in the right order. 2015-01-07 23:07:09 -07:00
Anthony J. Bentley 21d0b402d3 Don't unnecessarily initialize variables. 2015-01-07 22:59:06 -07:00
Anthony J. Bentley a305649557 rgbasm: Print usage if no filename is given after flags. 2015-01-07 22:44:28 -07:00
Anthony J. Bentley 3b0e207036 Pass -Wimplicit (implicit + implicit-function-declaration) by default. 2015-01-07 18:43:16 -07:00
Anthony J. Bentley 83eddb4c4e Merge branch 'haltnop' of https://github.com/stag019/rgbds 2015-01-07 16:47:10 -07:00
Anthony J. Bentley 57997756b6 Merge branch 'symmapfix' of https://github.com/stag019/rgbds 2015-01-07 16:36:37 -07:00
stag019 ab66b28fdf yacc_pre is no longer needed, since all the files were merged into one. 2015-01-03 06:57:07 -05:00
stag019 116569f54d Fix for mapfiles and symfiles. Before, you couldn't define a mapfile unless you also defined a symfile. If you did, it would segfault. 2015-01-01 01:20:29 -05:00
stag019 2b839fec37 Use the options parameter provided for command line options. Specifically, for haltnop. 2014-12-31 13:29:24 -05:00
Anthony J. Bentley 513d451710 Tweak path for stdnoreturn.h header. v0.2.1 2014-12-31 03:21:46 -07:00
Anthony J. Bentley 9399ba36f9 Check for standards‐compliant platforms first in stdnoreturn.h. 2014-12-31 03:20:14 -07:00
Anthony J. Bentley ef3a486845 Request POSIX 2008 for strdup(). 2014-12-31 03:18:01 -07:00
stag019 f0e5c5ccc8 Cross-compiler noreturn support. 2014-12-31 04:11:06 -05:00
stag019 9b4959cb75 Implement round, ceil, and floor math functions. 2014-12-17 01:30:19 -05:00
stag019 dca82e6d95 Fix DEF() automatically converting string EQUS. 2014-11-07 16:42:55 -05:00
stag019 871c5ed360 We aren't kidding ourselves anymore. This is a Gameboy assembler, not any sort of generic assembler. 2014-11-07 16:36:03 -05:00
Anthony J. Bentley 635014b74d On Clang, error on implicit function declaration by default. 2014-11-06 21:54:49 -07:00
Anthony J. Bentley 7ad634febd Don’t assign to self. 2014-11-06 21:42:40 -07:00
Anthony J. Bentley 1e1339467e Use POSIX 2001 as the base standard. 2014-11-06 21:39:36 -07:00
Anthony J. Bentley 9e24c26468 Specify _Noreturn in the err family prototypes. 2014-11-06 21:36:27 -07:00
Anthony J. Bentley c1213f536b Merge branch 'master' of https://github.com/stag019/rgbds v0.2.0 2014-11-04 17:36:45 -07:00
Anthony J. Bentley 82de716454 Mark error functions as _Noreturn. 2014-11-04 17:30:00 -07:00
stag019 a64d725a8d The actual way the macro bug should have been fixed. 2014-11-04 18:09:22 -05:00
stag019 80e2129f22 Merge https://github.com/bentley/rgbds
Conflicts:
	include/lib/types.h
	src/asm/symbol.c
2014-11-02 01:00:20 -05:00
stag019 af70f03933 A few more small changes to charmap.c. 2014-10-31 19:01:21 -04:00
stag019 004bc2e50e Fix a few charmap bugs maybe? 2014-10-31 10:48:54 -04:00
Christophe Staïesse 25efb00769 fix a bug in the lexer involving double quote escaping and semicolons
The bug showed up when a semicolon was located anywhere after \".

These three test cases are syntaxically correct but didn't compile:

1)
SECTION "HOME", HOME
	db "\";"

2)
SECTION "HOME", HOME
	db "\""
	nop
	;

3)
SECTION "HOME", HOME
	db "\"" ;

The problem was located in yy_create_buffer(). Basicaly, this function loads an
entire source file, uniformizes EOL terminators and filters out comments without
touching literal strings.

However, bounds of literal strings were wrongly guessed because \" was
interpreted as two characters (and so the double quote was not escaped).

In test 1, the string terminates early and so ;" is filtered out as it was a
comment and so the assembler complains of an unterminated string.
In test 2 and 3, the string is in fact interpreted as two strings, the second
one terminates at EOF in these cases and so comments are not filtered out and
that makes the assembler complains.

A special case must be taken into account:

4)
SECTION "HOME", HOME
	db "\\" ;

So we need to ignore \\ as well.

Note that there is still a problem left: in yy_create_buffer() a string may
span multiple lines but not in the lexer. However in this case I think the lexer
would quit at the first newline so there should be nothing to worry about.
2014-10-10 16:50:11 +02:00
Anthony J. Bentley c6c7b99fad PATH_MAX is not exactly portable. Hack around it for now. v0.1.2 2014-10-10 03:48:52 -06:00
Anthony J. Bentley e28d8384fb Merge branch 'fix-makefile' of https://github.com/chastai/rgbds 2014-10-06 02:01:21 -06:00
Anthony J. Bentley 27a350eaab Merge branch 'fix-uniquearg-segfault' of https://github.com/chastai/rgbds 2014-10-06 01:55:19 -06:00
Anthony J. Bentley cd8d895c1b Style. 2014-10-06 01:54:03 -06:00
Christophe Staïesse 4577a01c68 Fix out of bounds array access on invalid macro arg references
A reference to an invalid macro argument (\ not followed by a digit
between 1 and 9) will cause an access outside of the bounds of the
currentmacroargs array in sym_FindMacroArg().

Macro arg references are processed in two places:

In CopyMacroArg(): called when scanning tokens between "", {} and
arguments of a macro call. The only problem here is that it accepts \0
as valid and so calls sym_FindMacroArg with a invalid value.

In PutMacroArg(): called by the lexer automata when it encounters a
token matching \\[0-9]? (in other cases than above). So not only it
accepts \0 but also \ alone.
  Memo: In setuplex(), a rule is defined with a regex composed of up to
    three ranges of chars and takes the form:
      [FirstRange]
      or [FirstRange][SecondRange]?
      or [FirstRange]([SecondRange][Range]*)?
    On scanning, when several rules match, the first longuest one is
    choosen.

Regression test:
1)
SECTION "HOME", HOME
	db "\0"

2)
SECTION "HOME", HOME
	db \A

3)
SECTION "HOME", HOME
	db \
2014-10-05 18:15:37 +02:00
Christophe Staïesse 6758387668 Add assertion to symFindMacroArg() to debug oob array access 2014-10-05 18:13:07 +02:00
Christophe Staïesse 424702b272 Fix bug: rgbasm segfault when \@ is used outside a macro
The problem occurs when \@ is accessed outside the definition of a
macro and is not between "" or {}, or when it is used in an argument of
a macro call, i.e. when the access is processed by PutUniqueArg().

PutUniqueArg(), puts back the string value of \@ to the lexer's buffer
(to substitute \@ by the unique label string).
When \@ is not defined, sym_FindMacroArg(-1) returns NULL, which
yyunputstr() doesn't expect and crashes.

Solution:
Generate an error when \@ is not defined.

Regression test:

SECTION "HOME", HOME
        ld a,\@

Will segfault.
On the fixed version, it will return an error as \@ is not available.
2014-10-05 13:32:18 +02:00
Christophe Staïesse 191f98a008 Fix incorrect dependencies in Makefile 2014-10-05 11:37:11 +02:00
Anthony J. Bentley 00de7674af Now that install dirs are created, this error is unlikely to occur. v0.1.1 2014-10-03 15:17:49 -06:00
Anthony J. Bentley 32fa032a62 Makefile: Create install directories if they don’t exist. 2014-10-03 15:14:40 -06:00
Anthony J. Bentley 73e44cb803 Fix dependencies for Yacc files. Improve Makefile POSIX compliance.
Parallel building issue pointed out by murphm8 and chastai.
2014-09-26 15:27:52 -06:00