dbrotz ca6149abcf Fix signed integer overflow issues
It seemed that the consensus in our discussions of signed integer
overflow, which invokes undefined behavior in C, was that integer
arithmetic should be two's complement and there should be no warning for
overflows. I have implemented that by converting values to unsigned types
when appropriate. These changes will mostly preserve existing behavior,
except for a few cases that were being handled incorrectly before.

The case of dividing INT_MIN by -1 previously resulted in a CPU
exception and program termination. Now, that case is detected and results
in a warning and a value of INT_MIN.

Similarly, INT_MIN % -1 would have resulted in a CPU exception. Since this
is a mathematically valid operation with a result of 0, it now simply
gives that result without a warning.

I noticed that in rpn.c, there were attempts in certain operation handlers
to validate the nVal members of the source expressions even when the
expressions may have been relocatable expressions with meaningless numbers
for the nVal member. This could have caused spurious errors/warnings, so I
made those handlers confirm that isReloc is false before validating nVal.

Also, integer constants that are too large now result in a warning. The
post-conversion values have not been changed, in order to preserve
backward compatibility.
2019-07-04 16:27:31 -07:00
2019-06-04 13:23:33 +02:00
2019-07-04 16:27:31 -07:00
2019-07-04 16:27:31 -07:00
2019-05-31 08:26:53 -07:00
2019-05-31 08:26:53 -07:00
2019-05-10 00:16:27 +01:00
2019-02-14 18:03:28 -05:00

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
RGBDS
=====

RGBDS (Rednex Game Boy Development System) is a free assembler/linker package
for the Game Boy and Game Boy Color. It consists of:

- rgbasm (assembler)
- rgblink (linker)
- rgbfix (checksum/header fixer)
- rgbgfx (PNGtoGame Boy graphics converter)

This is a fork of the original RGBDS which aims to make the programs more like
other UNIX tools.

This toolchain is maintained on `GitHub <https://github.com/rednex/rgbds>`__.

The documentation of this toolchain can be viewed online
`here <https://rednex.github.io/rgbds/>`__, it is generated from the man pages
found in this repository.

1. Installing RGBDS
-------------------

1.1 Windows
~~~~~~~~~~~

Windows builds are available in the releases page on GitHub:

::

    https://github.com/rednex/rgbds/releases

Copy the ``.exe`` files to ``C:\Windows\`` or similar.

If you require the latest version in development, it should be possible to
compile RGBDS with MinGW or Cygwin by following the instructions to build it on
UNIX systems.

1.2 macOS
~~~~~~~~~

You can build RGBDS by following the instructions below. However, if you would
prefer not to build RGBDS yourself, you may also install it using
`Homebrew <http://brew.sh/>`__.

To install the latest release, use:

.. code:: sh

    brew install rgbds

To install RGBDS with all of the current changes in development (as seen on the
``master`` branch on GitHub), use:

.. code:: sh

    brew install rgbds --HEAD
    
1.3 Arch Linux
~~~~~~~~~~~~~~

To install RGBDS through the AUR run

.. code:: sh

    yaourt -S rgbds

1.4 Other UNIX-like systems
~~~~~~~~~~~~~~~~~~~~~~~~~~~

No official binaries of RGBDS are distributed for these systems, you must follow
the simple instructions below to compile and install it.

2. Building RGBDS from source
-----------------------------

RGBDS can be built in UNIX-like systems by following the instructions below.

2.1 Dependencies
~~~~~~~~~~~~~~~~

RGBDS requires yacc, flex, libpng and pkg-config to be installed.

On macOS, install the latter two with `Homebrew <http://brew.sh/>`__:

.. code:: sh

    brew install libpng pkg-config

On other Unixes, use the built-in package manager. For example, on Debian or
Ubuntu:

.. code:: sh

    sudo apt-get install byacc flex pkg-config libpng-dev

You can test if libpng and pkg-config are installed by running ``pkg-config
--cflags libpng``: if the output is a path, then you're good, and if it outputs
an error then you need to install them via a package manager.

2.2 Build process
~~~~~~~~~~~~~~~~~

To build the programs, run in your terminal:

.. code:: sh

    make

Then, to install the compiled programs and manual pages, run (with appropriate
privileges, e.g, with ``sudo``):

.. code:: sh

    make install

After installation, you can read the manuals with the ``man`` command. E.g.,

.. code:: sh

    man 7 rgbds

There are some variables in the Makefile that can be redefined by the user. The
variables described below can affect installation behavior when given on the
make command line. For example, to install RGBDS in your home directory instead
of systemwide, run the following:

.. code:: sh

    make install PREFIX=$HOME

To do a verbose build, run:

.. code:: sh

    make Q=

This is the complete list of user-defined variables:

- ``PREFIX``: Location where RGBDS will be installed. Defaults to
  ``/usr/local``.

- ``bindir``: Location where the binaries will be installed. Defaults to
  ``${PREFIX}/bin``.

- ``mandir``: Location where the manpages will be installed. Defaults to
  ``${PREFIX}/man``.

- ``DESTDIR``: This is prepended to all paths during the installation. It is
  mainly used for packaging.

- ``Q``: Whether to quiet the build or not. To make the build more verbose,
  clear this variable. Defaults to ``@``.

- ``STRIP``: Whether to strip the installed binaries of debug symbols or not.
  Defaults to ``-s``.

- ``BINMODE``: Permissions of the installed binaries. Defaults to ``555``.

- ``MANMODE``: Permissions of the installed manpages. Defaults to ``444``.

- ``CHECKPATCH``: Path of the script ``checkpatch.pl`` of the Linux kernel.
  Defaults to ``../linux/scripts/checkpatch.pl``.

3 History
---------

- Around 1997, Carsten Sorensen (AKA SurfSmurf) writes ASMotor as a
  general-purpose assembler/linker system for DOS/Win32

- Around 1999, Justin Lloyd (AKA Otaku no Zoku) adapts ASMotor to read and
  produce GBZ80 assembly/machine code, and releases this version as RGBDS.

- 2009, Vegard Nossum adapts the code to be more UNIX-like and releases
  this version as rgbds-linux on
  `GitHub <https://github.com/vegard/rgbds-linux>`__.

- 2010, Anthony J. Bentley forks that repository. The fork becomes the reference
  implementation of rgbds.

- 2017, Bentley's repository is moved to a neutral name.

- 2018, codebase relicensed under the MIT license.
Description
Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color
Readme MIT 18 MiB
Languages
C++ 68%
Assembly 18%
Shell 6.8%
Yacc 5%
CMake 1%
Other 1%