Commit Graph

487 Commits

Author SHA1 Message Date
AntonioND
14fea5f659 Merge pull request #119 from Ben10do/add-end-checks
Verify that IFs, REPTs and MACROs are terminated
2017-02-26 21:49:22 +00:00
AntonioND
1e16a0ff85 Merge pull request #121 from TwitchPlaysPokemon/master
Fix WRAM0 symbols returning bank 512 to BANK() expression in linker
2017-02-26 21:45:53 +00:00
Roger
7adf1dd502 Convert README to markdown 2017-02-25 16:15:05 -05:00
Anthony J. Bentley
0588e42520 Link to HTML documentation from the manpage. 2017-02-23 21:09:32 -07:00
Anthony J. Bentley
2eb748278b Move HTML docs to a different repo. 2017-02-23 21:07:11 -07:00
Ben10do
1ab93a194e Implement ALIGN keyword in rgbasm
The ALIGN keyword specifies the number of bits that should be zero at the start of a section. It works in a simliar fashion to BANK.
2017-02-23 15:00:57 +00:00
Ben10do
1b05c43b97 Implement byte alignment in section assingment
Yay, more refactoring of the section assignment… This version of the linker will allocate sections by their alignment, and then by their size (largest first, in both cases).

In future, this may be improved by using dense packing (as suggested by #83).
2017-02-19 22:43:45 +00:00
Ben10do
e4cbf773f6 Add alignment of sections to objects
Aligned sections can now be created with out_NewAlignedSection(). This information is stored in created object files, and read by the linker.

The names of each section are also included in the object file, enabling potential improvements to error messages in the future.
2017-02-19 22:35:32 +00:00
Ben10do
b07c04cd74 Implement a malloc-based readasciiz()
Instead of reading into a pre-sized buffer, this function now uses malloc to create a buffer, and resizes it if necessary.

This reduces the risk of memory issues if a long string (< 255 chars) was encountered.
2017-02-19 22:20:21 +00:00
Ben10do
9be7c4c849 Remove duplicate documentation of -E
Remove Sanqui’s documentation of the -E argument to rgbasm, in favour of bentley’s better-worded one.
2017-02-07 11:05:35 +00:00
scnorton
6d1c60b0a6 Contiguous WRAM 2017-02-06 16:31:57 -05:00
PikalaxALT
c485ad94f2 Fix WRAM0 symbols returning bank 512 to BANK() expression in linker 2017-02-06 08:38:07 -05:00
PikalaxALT
998cfe1bdd 16-bank SRAM 2017-02-06 08:27:32 -05:00
Anthony J. Bentley
5ee058f217 Merge branch 'linker-refactor-assign' of https://github.com/Ben10do/rgbds 2017-02-05 23:24:13 -07:00
Ben10do
38372c59ed Verify that IFs, REPTs and MACROs are terminated
Ensure that IF constructs, REPT blocks, and MACRO defintions are terminated with ENDC, ENDR, or ENDM respectively. If they are not, print an error and stop assembly.

As well as aiding a forgetful programmer, this reduces the risk of memory problems if the file ends less than four bytes after the block starts.
2017-02-02 16:27:53 +00:00
Ben10do
420ea638a7 Refactor section assignment in linker
Deduplicates and generalises a lot of code in assign.c:

- Replace area_AllocAbs*AnyBank() with area_AllocAbsAnyBank() function
that accepts a section type parameter
- Replace area_Alloc*AnyBank() with area_AllocAnyBank()
- Replace FindLargest*() with FindLargestSection()
- Replace Assign*Sections() with AssignBankedSections()
- Add VerifyAndSetBank(), which enables bank checks (and addition with
BANK_*) to be centralised
- Refactor the initialisation of AssignSections(), removing some magic
numbers and only setting MaxAvail[i] once
- Overhaul the duplicated cases throughout AssignSections()
2017-01-27 08:56:36 +00:00
Ben10do
951c9b66f4 Don't segfault on null bytes in REPTs and MACROs
Previously, the copyrept() and copymacro() functions would halt their
first loop (in which they determine the length of the block)
prematurely,  causing an underflow when setting len, eventually causing
memory issues.

Whilst this doesn’t solve the len underflow entirely (e.g. if the file
ends immediately without an ENDR/ENDM), it should help with this exact
scenario of null bytes (as #50).
2017-01-26 22:01:03 +00:00
Ben10do
0a66e14307 Fix division by zero crashes in instructions
Previously, rgbasm could crash with a floating point exception if an
instruction includes a division or modulo by 0. Fixes #49.
2017-01-26 21:32:06 +00:00
Ben10do
b40c567aee Add ldi a, [hl] and ldd a, [hl] instructions
These are equivalent to ld a, [hl+] and ld a, [hl-] respectively.
2017-01-26 16:55:00 +00:00
Anthony J. Bentley
547abfefc1 Merge branch 'fatal-error-noreturn' of https://github.com/Ben10do/rgbds 2017-01-25 00:47:25 -07:00
Ben10do
06f0472f81 Emit a single error when using BANK incorrectly
Previously, if BANK is used when defining a section that’s not ROMX,
WRMAX, SRAM or VRAM, a second error message would appear, e.g. “(null)
bank value $1 out of range $5d to $0”.

This would appear due to the usage of uninitialised variables. This
change ensures that the uninitialised variables are not accessed when
using an invalid section.

This also silences compiler warnings about usage of uninitialised
variables.
2017-01-24 11:50:18 +00:00
Ben10do
defd4f589e Add noreturn attribute to fatalerror()
Should silence compiler warnings that expect fatalerror() to return.
2017-01-24 11:38:26 +00:00
Anthony J. Bentley
dc4a98048d Simplify string copy by using strlcpy(). 2017-01-24 01:26:55 -07:00
Anthony J. Bentley
efaa6d9ff7 Add .gitignore. 2017-01-24 01:19:16 -07:00
Anthony J. Bentley
ab19dab899 Merge branch 'include-cli' of https://github.com/AntonioND/rgbds 2017-01-24 01:18:28 -07:00
Ben10do
e86a70d2cb Fix the name of the GNUmakefile
GNU make actually looks for ‘GNUmakefile’, not ‘GNUMakefile’.

Consequently, GNU make would erroneously attempt to use the standard
makefile, instead of the GNU-specific one. This would cause an error
when attempting to import png.h, due to PNGFLAGS not being correctly
set.
2017-01-23 23:46:44 +00:00
AntonioND
a91187d8dc Increase number of include paths through CLI
Increase number of include paths that can be passed through the
command line interface. The previous number, 16, is only good enough
for small projects. 128 is still an arbitrary number, but it is harder
to reach.
2017-01-22 23:08:10 +00:00
AntonioND
0b5e074591 Output error messages for command line includes
The code that adds an include path to the array of paths doesn't check
the lenght of the path (which can cause overflows because of strcpy).

It doesn't check if the max number of paths has been reached, either.

This patch adds error messages for such cases, giving the user more
information than before and crashing the assembly instead of
continuing and failing when it can't find a file to include.
2017-01-22 23:04:50 +00:00
Anthony J. Bentley
f8531ed410 Add a thin wrapper makefile for GNU Make.
GNU Make 3.x doesn't support the "!=" syntax for shell assignment,
although 4.x does, BSD Makes do, and it has been submitted to POSIX
for possible inclusion in the standard. Unfortunately, GNU Make 3.x
is still in common use, so provide an alternative makefile (GNU Make
reads "GNUmakefile" instead of "Makefile" by default) that sets the
variables and then reuses the rest of the default Makefile.
2016-12-16 23:23:37 -07:00
Francisco Requena
0a8401741d Fixes rgbgfx linkage issues with old libpng (pre 1.4.2) 2016-12-17 04:04:45 +01:00
Anthony J. Bentley
a079a69b7c Add a note about installing libpng. 2016-10-22 14:13:19 -06:00
Anthony J. Bentley
d86cb41972 Rename png.h to makepng.h, to avoid conflicts with libpng's png.h. 2016-10-22 14:03:14 -06:00
yenatch
95cd960b3b Fix the order of flags when including libpng.
This apparently does matter.
2016-10-11 21:54:18 -06:00
Anthony J. Bentley
bed43d2530 Document rgbasm -E. 2016-09-05 02:46:59 -06:00
Anthony J. Bentley
c02b04f7d2 Merge branch 'export-all-2' of https://github.com/Sanqui/rgbds 2016-09-05 02:43:23 -06:00
Anthony J. Bentley
2339f0fbae Merge branch 'an/fix-gfx-prefix' of https://github.com/AntonioND/rgbds 2016-09-05 02:35:24 -06:00
Anthony J. Bentley
6e0aca47d4 Declare string uppercase/lowercase functions unconditionally.
Avoid naming them str*(), because such names are reserved by ISO C.
2016-09-05 01:41:39 -06:00
Anthony J. Bentley
a8c603a7e8 Removed the wrong pkg-config. 2016-09-05 01:41:39 -06:00
Anthony J. Bentley
97a31c8fc0 Remove duplicate PKG_CONFIG. 2016-09-05 01:34:17 -06:00
Anthony J. Bentley
c3c31138dd Add rgbgfx. 2016-09-05 01:29:45 -06:00
AntonioND
fbb825af3b Fix GB graphics prefix output
The output of using the prefix '`' was inverted: The MSB was placed
before the LSB. Now, the LSB are placed first, allowing a direct copy
to VRAM.
2016-07-01 19:54:48 +01:00
Sanqui
280ca83acd Fix opening nonexistent overlay files 2016-03-28 20:47:47 +02:00
Sanqui
2e9c68f8c3 Add overlay file option to rgblink (-O)
This option takes a file and places fixed sections on top of it.
Should prove useful for patches and partial disassemblies.
2016-03-28 01:02:05 +02:00
Anthony J. Bentley
330a39596c Instead of blindly trusting the first byte, decode UTF-8 safely. 2016-01-28 23:16:42 -07:00
Anthony J. Bentley
e241137508 KNF. 2016-01-28 23:05:25 -07:00
Sanqui
deb44eaeef Merge branch 'master' into HEAD 2015-10-13 22:37:25 +02:00
Sanqui
338c176b37 Add -E option to rgbds, allows exporting all labels by default 2015-10-13 22:35:02 +02:00
yenatch
1a15ee5363 Increase the length of charmaps. 2015-10-13 08:46:29 -07:00
Anthony J. Bentley
2ea2e47231 Avoid a pointless strcpy(). 2015-10-05 23:58:00 -06:00
Anthony J. Bentley
31294d6d9d rgbasm: refactor bank range checking, and bump the SRAM limit.
This doesn’t affect rgblink, which still needs work.
2015-10-05 17:14:24 -06:00