mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d81d128a04 | ||
|
|
d067f31678 | ||
|
|
d02294505c | ||
|
|
eb4bbb3e0b | ||
|
|
2ab10a95e4 | ||
|
|
bc60b85785 | ||
|
|
9d0203a4ee | ||
|
|
a18b65de21 | ||
|
|
1c47ffcce8 | ||
|
|
60c3a7e2f3 | ||
|
|
5702995978 | ||
|
|
483d94f88b | ||
|
|
9b4d16b0d8 | ||
|
|
a3e95f99d2 | ||
|
|
e3a31d7e59 | ||
|
|
d9f5ce339a |
3
LICENSE
3
LICENSE
@@ -21,5 +21,8 @@ under the ISC license; see the source file for the text of the license.
|
|||||||
extern/err.c is derived from the Musl C library, http://www.musl-libc.org,
|
extern/err.c is derived from the Musl C library, http://www.musl-libc.org,
|
||||||
and is released under the MIT license.
|
and is released under the MIT license.
|
||||||
|
|
||||||
|
extern/reallocarray.c is derived from the OpenBSD Project,
|
||||||
|
http://www.openbsd.org, and is released under the ISC license.
|
||||||
|
|
||||||
extern/strl.c is derived from the OpenBSD Project, http://www.openbsd.org,
|
extern/strl.c is derived from the OpenBSD Project, http://www.openbsd.org,
|
||||||
and is released under the BSD license.
|
and is released under the BSD license.
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -85,7 +85,7 @@ src/asm/asmy.h: src/asm/asmy.c
|
|||||||
# install instructions instead.
|
# install instructions instead.
|
||||||
mingw:
|
mingw:
|
||||||
$Qenv PATH=/usr/local/mingw32/bin:/bin:/usr/bin:/usr/local/bin \
|
$Qenv PATH=/usr/local/mingw32/bin:/bin:/usr/bin:/usr/local/bin \
|
||||||
make CC=gcc CFLAGS="-I/usr/local/mingw32/include \
|
make WARNFLAGS= CC=gcc CFLAGS="-I/usr/local/mingw32/include \
|
||||||
-D__progname=\\\"\\\" \
|
-D__progname=\\\"\\\" \
|
||||||
${CFLAGS}"
|
${CFLAGS}"
|
||||||
$Qmv rgbasm rgbasm.exe
|
$Qmv rgbasm rgbasm.exe
|
||||||
|
|||||||
2
README
2
README
@@ -53,6 +53,6 @@ this variable. Defaults to @.
|
|||||||
Installing RGBDS (Windows)
|
Installing RGBDS (Windows)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
Windows builds are available here: http://anthony.bentley.name/rgbds/
|
Windows builds are available here: https://github.com/bentley/rgbds/releases
|
||||||
|
|
||||||
Copy the .exe files to C:\Windows\ or similar.
|
Copy the .exe files to C:\Windows\ or similar.
|
||||||
|
|||||||
10
include/extern/reallocarray.h
vendored
Normal file
10
include/extern/reallocarray.h
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef EXTERN_REALLOCARRAY_H
|
||||||
|
#define EXTERN_REALLOCARRAY_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef REALLOCARRAY_IN_LIBC
|
||||||
|
#define reallocarray rgbds_reallocarray
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -992,8 +992,16 @@ const : T_ID { $$ = sym_GetConstantValue($1); }
|
|||||||
| const T_OP_SHL const { $$ = $1 << $3; }
|
| const T_OP_SHL const { $$ = $1 << $3; }
|
||||||
| const T_OP_SHR const { $$ = $1 >> $3; }
|
| const T_OP_SHR const { $$ = $1 >> $3; }
|
||||||
| const T_OP_MUL const { $$ = $1 * $3; }
|
| const T_OP_MUL const { $$ = $1 * $3; }
|
||||||
| const T_OP_DIV const { $$ = $1 / $3; }
|
| const T_OP_DIV const {
|
||||||
| const T_OP_MOD const { $$ = $1 % $3; }
|
if ($3 == 0)
|
||||||
|
fatalerror("division by zero");
|
||||||
|
$$ = $1 / $3;
|
||||||
|
}
|
||||||
|
| const T_OP_MOD const {
|
||||||
|
if ($3 == 0)
|
||||||
|
fatalerror("division by zero");
|
||||||
|
$$ = $1 % $3;
|
||||||
|
}
|
||||||
| T_OP_ADD const %prec NEG { $$ = +$2; }
|
| T_OP_ADD const %prec NEG { $$ = +$2; }
|
||||||
| T_OP_SUB const %prec NEG { $$ = -$2; }
|
| T_OP_SUB const %prec NEG { $$ = -$2; }
|
||||||
| T_OP_NOT const %prec NEG { $$ = 0xFFFFFFFF^$2; }
|
| T_OP_NOT const %prec NEG { $$ = 0xFFFFFFFF^$2; }
|
||||||
@@ -1065,7 +1073,7 @@ section:
|
|||||||
}
|
}
|
||||||
} else if ($4 == SECT_WRAMX) {
|
} else if ($4 == SECT_WRAMX) {
|
||||||
if ($8 >= 1 && $8 <= 7) {
|
if ($8 >= 1 && $8 <= 7) {
|
||||||
out_NewAbsSection($2, $4, -1, $8);
|
out_NewAbsSection($2, $4, -1, $8 - 1);
|
||||||
} else {
|
} else {
|
||||||
yyerror("WRAMX bank value $%x out of range (1 to 7)", $8);
|
yyerror("WRAMX bank value $%x out of range (1 to 7)", $8);
|
||||||
}
|
}
|
||||||
@@ -1102,7 +1110,7 @@ section:
|
|||||||
} else if ($4 == SECT_WRAMX) {
|
} else if ($4 == SECT_WRAMX) {
|
||||||
if ($6 >= 0 && $6 < 0x10000) {
|
if ($6 >= 0 && $6 < 0x10000) {
|
||||||
if ($11 >= 1 && $11 <= 7) {
|
if ($11 >= 1 && $11 <= 7) {
|
||||||
out_NewAbsSection($2, $4, $6, $11);
|
out_NewAbsSection($2, $4, $6, $11 - 1);
|
||||||
} else {
|
} else {
|
||||||
yyerror("WRAMX bank value $%x out of range (1 to 7)", $11);
|
yyerror("WRAMX bank value $%x out of range (1 to 7)", $11);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,24 +440,30 @@ checkcodesection(SLONG size)
|
|||||||
errx(1, "Section '%s' cannot contain code or data (not a "
|
errx(1, "Section '%s' cannot contain code or data (not a "
|
||||||
"ROM0 or ROMX)", pCurrentSection->pzName);
|
"ROM0 or ROMX)", pCurrentSection->pzName);
|
||||||
}
|
}
|
||||||
if (pCurrentSection->nPC + size <= MAXSECTIONSIZE) {
|
if (pCurrentSection->nPC + size > MAXSECTIONSIZE) {
|
||||||
|
/*
|
||||||
|
* N.B.: This check is not sufficient to ensure the section
|
||||||
|
* will fit, because there can be multiple sections of this
|
||||||
|
* type. The definitive check must be done at the linking
|
||||||
|
* stage.
|
||||||
|
*/
|
||||||
|
errx(1, "Section '%s' is too big (old size %d + %d > %d)",
|
||||||
|
pCurrentSection->pzName, pCurrentSection->nPC, size,
|
||||||
|
MAXSECTIONSIZE);
|
||||||
|
}
|
||||||
if (((pCurrentSection->nPC % SECTIONCHUNK) >
|
if (((pCurrentSection->nPC % SECTIONCHUNK) >
|
||||||
((pCurrentSection->nPC + size) % SECTIONCHUNK))
|
((pCurrentSection->nPC + size) % SECTIONCHUNK)) &&
|
||||||
&& (pCurrentSection->nType == SECT_ROM0
|
(pCurrentSection->nType == SECT_ROM0 ||
|
||||||
|| pCurrentSection->nType == SECT_ROMX)) {
|
pCurrentSection->nType == SECT_ROMX)) {
|
||||||
if ((pCurrentSection->tData =
|
pCurrentSection->tData = realloc(pCurrentSection->tData,
|
||||||
(UBYTE *) realloc(pCurrentSection->tData,
|
((pCurrentSection->nPC + size) / SECTIONCHUNK + 1) *
|
||||||
((pCurrentSection->nPC +
|
SECTIONCHUNK);
|
||||||
size) / SECTIONCHUNK +
|
|
||||||
1) * SECTIONCHUNK)) != NULL) {
|
if (pCurrentSection->tData == NULL) {
|
||||||
return;
|
err(1, "Could not expand section");
|
||||||
} else
|
}
|
||||||
fatalerror
|
|
||||||
("Not enough memory to expand section");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else
|
|
||||||
errx(1, "Section '%s' is too big", pCurrentSection->pzName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
38
src/extern/reallocarray.c
vendored
Normal file
38
src/extern/reallocarray.c
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
|
||||||
|
* if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
|
||||||
|
*/
|
||||||
|
#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
|
||||||
|
|
||||||
|
void *
|
||||||
|
rgbds_reallocarray(void *optr, size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
|
||||||
|
nmemb > 0 && SIZE_MAX / nmemb < size) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return realloc(optr, size * nmemb);
|
||||||
|
}
|
||||||
46
src/extern/strlcat.c
vendored
46
src/extern/strlcat.c
vendored
@@ -1,7 +1,7 @@
|
|||||||
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
|
/* $OpenBSD: strlcat.c,v 1.14 2015/01/15 03:54:12 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -20,36 +20,36 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
* Appends src to string dst of size dsize (unlike strncat, dsize is the
|
||||||
* full size of dst, not space left). At most siz-1 characters
|
* full size of dst, not space left). At most dsize-1 characters
|
||||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
* will be copied. Always NUL terminates (unless dsize <= strlen(dst)).
|
||||||
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
* Returns strlen(src) + MIN(dsize, strlen(initial dst)).
|
||||||
* If retval >= siz, truncation occurred.
|
* If retval >= siz, truncation occurred.
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t
|
||||||
rgbds_strlcat(char *dst, const char *src, size_t siz)
|
rgbds_strlcat(char *dst, const char *src, size_t dsize)
|
||||||
{
|
{
|
||||||
char *d = dst;
|
const char *odst = dst;
|
||||||
const char *s = src;
|
const char *osrc = src;
|
||||||
size_t n = siz;
|
size_t n = dsize;
|
||||||
size_t dlen;
|
size_t dlen;
|
||||||
|
|
||||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
/* Find the end of dst and adjust bytes left but don't go past end. */
|
||||||
while (n-- != 0 && *d != '\0')
|
while (n-- != 0 && *dst != '\0')
|
||||||
d++;
|
dst++;
|
||||||
dlen = d - dst;
|
dlen = dst - odst;
|
||||||
n = siz - dlen;
|
n = dsize - dlen;
|
||||||
|
|
||||||
if (n == 0)
|
if (n-- == 0)
|
||||||
return(dlen + strlen(s));
|
return(dlen + strlen(src));
|
||||||
while (*s != '\0') {
|
while (*src != '\0') {
|
||||||
if (n != 1) {
|
if (n != 0) {
|
||||||
*d++ = *s;
|
*dst++ = *src;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
s++;
|
src++;
|
||||||
}
|
}
|
||||||
*d = '\0';
|
*dst = '\0';
|
||||||
|
|
||||||
return(dlen + (s - src)); /* count does not include NUL */
|
return(dlen + (src - osrc)); /* count does not include NUL */
|
||||||
}
|
}
|
||||||
|
|||||||
37
src/extern/strlcpy.c
vendored
37
src/extern/strlcpy.c
vendored
@@ -1,7 +1,7 @@
|
|||||||
/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
|
/* $OpenBSD: strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -20,32 +20,31 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy src to string dst of size siz. At most siz-1 characters
|
* Copy string src to buffer dst of size dsize. At most dsize-1
|
||||||
* will be copied. Always NUL terminates (unless siz == 0).
|
* chars will be copied. Always NUL terminates (unless dsize == 0).
|
||||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
* Returns strlen(src); if retval >= dsize, truncation occurred.
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t
|
||||||
rgbds_strlcpy(char *dst, const char *src, size_t siz)
|
rgbds_strlcpy(char *dst, const char *src, size_t dsize)
|
||||||
{
|
{
|
||||||
char *d = dst;
|
const char *osrc = src;
|
||||||
const char *s = src;
|
size_t nleft = dsize;
|
||||||
size_t n = siz;
|
|
||||||
|
|
||||||
/* Copy as many bytes as will fit */
|
/* Copy as many bytes as will fit. */
|
||||||
if (n != 0) {
|
if (nleft != 0) {
|
||||||
while (--n != 0) {
|
while (--nleft != 0) {
|
||||||
if ((*d++ = *s++) == '\0')
|
if ((*dst++ = *src++) == '\0')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
/* Not enough room in dst, add NUL and traverse rest of src. */
|
||||||
if (n == 0) {
|
if (nleft == 0) {
|
||||||
if (siz != 0)
|
if (dsize != 0)
|
||||||
*d = '\0'; /* NUL-terminate dst */
|
*dst = '\0'; /* NUL-terminate dst */
|
||||||
while (*s++)
|
while (*src++)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(s - src - 1); /* count does not include NUL */
|
return(src - osrc - 1); /* count does not include NUL */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ AssignSRAMSections(void)
|
|||||||
if ((org = area_AllocSRAMAnyBank(pSection->nByteSize)) != -1) {
|
if ((org = area_AllocSRAMAnyBank(pSection->nByteSize)) != -1) {
|
||||||
pSection->nOrg = org & 0xFFFF;
|
pSection->nOrg = org & 0xFFFF;
|
||||||
pSection->nBank = org >> 16;
|
pSection->nBank = org >> 16;
|
||||||
|
pSection->nBank += BANK_SRAM;
|
||||||
pSection->oAssigned = 1;
|
pSection->oAssigned = 1;
|
||||||
DOMAXSBANK(pSection->nBank);
|
DOMAXSBANK(pSection->nBank);
|
||||||
} else {
|
} else {
|
||||||
@@ -343,6 +344,7 @@ AssignWRAMSections(void)
|
|||||||
if ((org = area_AllocWRAMAnyBank(pSection->nByteSize)) != -1) {
|
if ((org = area_AllocWRAMAnyBank(pSection->nByteSize)) != -1) {
|
||||||
pSection->nOrg = org & 0xFFFF;
|
pSection->nOrg = org & 0xFFFF;
|
||||||
pSection->nBank = org >> 16;
|
pSection->nBank = org >> 16;
|
||||||
|
pSection->nBank += BANK_WRAMX - 1;
|
||||||
pSection->oAssigned = 1;
|
pSection->oAssigned = 1;
|
||||||
DOMAXWBANK(pSection->nBank);
|
DOMAXWBANK(pSection->nBank);
|
||||||
} else {
|
} else {
|
||||||
@@ -557,8 +559,8 @@ AssignSections(void)
|
|||||||
* bank are hardcoded.
|
* bank are hardcoded.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (pSection->nBank >= 1
|
if (pSection->nBank >= 0
|
||||||
&& pSection->nBank <= 7) {
|
&& pSection->nBank <= 6) {
|
||||||
pSection->nBank +=
|
pSection->nBank +=
|
||||||
BANK_WRAMX;
|
BANK_WRAMX;
|
||||||
if (area_AllocAbs
|
if (area_AllocAbs
|
||||||
|
|||||||
@@ -53,19 +53,36 @@ MapfileInitBank(SLONG bank)
|
|||||||
{
|
{
|
||||||
if (mf) {
|
if (mf) {
|
||||||
currentbank = bank;
|
currentbank = bank;
|
||||||
if (bank == 0)
|
if (bank == BANK_ROM0)
|
||||||
fprintf(mf, "Bank #0 (HOME):\n");
|
fprintf(mf, "ROM Bank #0 (HOME):\n");
|
||||||
else if (bank < BANK_WRAM0)
|
else if (bank < BANK_WRAM0)
|
||||||
fprintf(mf, "Bank #%ld:\n", bank);
|
fprintf(mf, "ROM Bank #%ld:\n", bank);
|
||||||
else if (bank == BANK_WRAM0)
|
else if (bank == BANK_WRAM0)
|
||||||
fprintf(mf, "WRAM0:\n");
|
fprintf(mf, "WRAM Bank #0:\n");
|
||||||
|
else if (bank < BANK_VRAM)
|
||||||
|
fprintf(mf, "WRAM Bank #%ld:\n", bank - BANK_WRAMX + 1);
|
||||||
else if (bank == BANK_HRAM)
|
else if (bank == BANK_HRAM)
|
||||||
fprintf(mf, "HRAM:\n");
|
fprintf(mf, "HRAM:\n");
|
||||||
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
|
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
|
||||||
fprintf(mf, "VRAM Bank #%ld:\n", bank - BANK_VRAM);
|
fprintf(mf, "VRAM Bank #%ld:\n", bank - BANK_VRAM);
|
||||||
|
else if (bank < MAXBANKS)
|
||||||
|
fprintf(mf, "SRAM Bank #%ld:\n", bank - BANK_SRAM);
|
||||||
}
|
}
|
||||||
if (sf) {
|
if (sf) {
|
||||||
sfbank = (bank >= 1 && bank <= 511) ? bank : 0;
|
if (bank < BANK_WRAM0)
|
||||||
|
sfbank = bank;
|
||||||
|
else if (bank == BANK_WRAM0)
|
||||||
|
sfbank = 0;
|
||||||
|
else if (bank < BANK_VRAM)
|
||||||
|
sfbank = bank - BANK_WRAMX + 1;
|
||||||
|
else if (bank == BANK_HRAM)
|
||||||
|
sfbank = 0;
|
||||||
|
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
|
||||||
|
sfbank = bank - BANK_VRAM;
|
||||||
|
else if (bank < MAXBANKS)
|
||||||
|
sfbank = bank - BANK_SRAM;
|
||||||
|
else
|
||||||
|
sfbank = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ Output(void)
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
for (i = 256; i < MAXBANKS; i += 1) {
|
for (i = BANK_WRAM0; i < MAXBANKS; i++) {
|
||||||
struct sSection *pSect;
|
struct sSection *pSect;
|
||||||
MapfileInitBank(i);
|
MapfileInitBank(i);
|
||||||
pSect = pSections;
|
pSect = pSections;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "extern/err.h"
|
#include "extern/err.h"
|
||||||
|
#include "link/assign.h"
|
||||||
#include "link/mylink.h"
|
#include "link/mylink.h"
|
||||||
#include "link/symbol.h"
|
#include "link/symbol.h"
|
||||||
#include "link/main.h"
|
#include "link/main.h"
|
||||||
@@ -53,18 +54,28 @@ getsymvalue(SLONG symid)
|
|||||||
SLONG
|
SLONG
|
||||||
getsymbank(SLONG symid)
|
getsymbank(SLONG symid)
|
||||||
{
|
{
|
||||||
|
SLONG nBank;
|
||||||
|
|
||||||
switch (pCurrentSection->tSymbols[symid]->Type) {
|
switch (pCurrentSection->tSymbols[symid]->Type) {
|
||||||
case SYM_IMPORT:
|
case SYM_IMPORT:
|
||||||
return (sym_GetBank(pCurrentSection->tSymbols[symid]->pzName));
|
nBank = sym_GetBank(pCurrentSection->tSymbols[symid]->pzName);
|
||||||
break;
|
break;
|
||||||
case SYM_EXPORT:
|
case SYM_EXPORT:
|
||||||
case SYM_LOCAL:
|
case SYM_LOCAL:
|
||||||
return (pCurrentSection->tSymbols[symid]->pSection->nBank);
|
nBank = pCurrentSection->tSymbols[symid]->pSection->nBank;
|
||||||
//return (pCurrentSection->nBank);
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
|
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nBank >= BANK_WRAMX && nBank <= (BANK_WRAMX+6))
|
||||||
|
return nBank - BANK_WRAMX + 1;
|
||||||
|
if (nBank >= BANK_VRAM && nBank <= (BANK_VRAM+1))
|
||||||
|
return nBank - BANK_VRAM;
|
||||||
|
if (nBank >= BANK_SRAM && nBank <= (BANK_SRAM+3))
|
||||||
|
return nBank - BANK_SRAM;
|
||||||
|
|
||||||
|
return nBank;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLONG
|
SLONG
|
||||||
|
|||||||
2
test/asm/bank-noexist.asm
Normal file
2
test/asm/bank-noexist.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
db BANK(noexist)
|
||||||
2
test/asm/bank-noexist.out
Normal file
2
test/asm/bank-noexist.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: bank-noexist.asm(2) :
|
||||||
|
'noexist' not defined
|
||||||
2
test/asm/divzero-instr.asm
Normal file
2
test/asm/divzero-instr.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
ld a, 1/0
|
||||||
2
test/asm/divzero-instr.out
Normal file
2
test/asm/divzero-instr.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: divzero-instr.asm(2) :
|
||||||
|
division by zero
|
||||||
1
test/asm/divzero-section-bank.asm
Normal file
1
test/asm/divzero-section-bank.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SECTION "sec", ROMX[$/0]
|
||||||
2
test/asm/divzero-section-bank.out
Normal file
2
test/asm/divzero-section-bank.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: divzero-section-bank.asm(1) :
|
||||||
|
division by zero
|
||||||
1
test/asm/macro-@.asm
Normal file
1
test/asm/macro-@.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
foo @bar
|
||||||
2
test/asm/macro-@.out
Normal file
2
test/asm/macro-@.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: macro-@.asm(1) -> @(-1) :
|
||||||
|
Macro '@' not defined
|
||||||
BIN
test/asm/null-in-macro.asm
Normal file
BIN
test/asm/null-in-macro.asm
Normal file
Binary file not shown.
0
test/asm/null-in-macro.out
Normal file
0
test/asm/null-in-macro.out
Normal file
6
test/asm/test.sh
Normal file
6
test/asm/test.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
fname=$(mktemp)
|
||||||
|
|
||||||
|
for i in *.asm; do
|
||||||
|
../../rgbasm $i >$fname 2>&1
|
||||||
|
diff -u $fname ${i%.asm}.out
|
||||||
|
done
|
||||||
3
test/asm/undefined-dot.asm
Normal file
3
test/asm/undefined-dot.asm
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
foo:
|
||||||
|
add sp, .
|
||||||
2
test/asm/undefined-dot.out
Normal file
2
test/asm/undefined-dot.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: undefined-dot.asm(3) :
|
||||||
|
'.' not defined
|
||||||
36
test/link/ram-bank-numbers.asm
Normal file
36
test/link/ram-bank-numbers.asm
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
; this should generate a rom consisting of the following bytes:
|
||||||
|
; 01 02 03 04 05 06 07 00 01 02 03 00 01
|
||||||
|
|
||||||
|
section "x",rom0
|
||||||
|
db bank(w1),bank(w2),bank(w3),bank(w4),bank(w5),bank(w6),bank(w7)
|
||||||
|
db bank(s0),bank(s1),bank(s2),bank(s3)
|
||||||
|
db bank(v0),bank(v1)
|
||||||
|
|
||||||
|
section "wa",wramx,bank[1]
|
||||||
|
w1:
|
||||||
|
section "wb",wramx,bank[2]
|
||||||
|
w2:
|
||||||
|
section "wc",wramx,bank[3]
|
||||||
|
w3:
|
||||||
|
section "wd",wramx,bank[4]
|
||||||
|
w4:
|
||||||
|
section "we",wramx,bank[5]
|
||||||
|
w5:
|
||||||
|
section "wf",wramx,bank[6]
|
||||||
|
w6:
|
||||||
|
section "wg",wramx,bank[7]
|
||||||
|
w7:
|
||||||
|
|
||||||
|
section "sa",sram,bank[0]
|
||||||
|
s0:
|
||||||
|
section "sb",sram,bank[1]
|
||||||
|
s1:
|
||||||
|
section "sc",sram,bank[2]
|
||||||
|
s2:
|
||||||
|
section "sd",sram,bank[3]
|
||||||
|
s3:
|
||||||
|
|
||||||
|
section "v00",vram,bank[0]
|
||||||
|
v0:
|
||||||
|
section "v01",vram,bank[1]
|
||||||
|
v1:
|
||||||
Reference in New Issue
Block a user