projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A better fix for bug#661910
[fw/sdcc]
/
src
/
z80
/
main.c
diff --git
a/src/z80/main.c
b/src/z80/main.c
index 2c172e5c585fdf375c0f8f2da488166fb827946c..8c6cadf142eab93c7784472d9896112fc9c67706 100644
(file)
--- a/
src/z80/main.c
+++ b/
src/z80/main.c
@@
-41,12
+41,19
@@
static char _gbz80_defaultRules[] =
Z80_OPTS z80_opts;
Z80_OPTS z80_opts;
+static OPTION _z80_options[] =
+ {
+ { 0, "--callee-saves-bc", &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
+ { 0, NULL }
+ };
+
typedef enum
{
/* Must be first */
ASM_TYPE_ASXXXX,
ASM_TYPE_RGBDS,
typedef enum
{
/* Must be first */
ASM_TYPE_ASXXXX,
ASM_TYPE_RGBDS,
- ASM_TYPE_ISAS
+ ASM_TYPE_ISAS,
+ ASM_TYPE_Z80ASM
}
ASM_TYPE;
}
ASM_TYPE;
@@
-180,15
+187,10
@@
static void
_gbz80_rgblink (void)
{
FILE *lnkfile;
_gbz80_rgblink (void)
{
FILE *lnkfile;
- const char *sz;
-
int i;
int i;
- sz = srcFileName;
- if (!sz)
- sz = "a";
/* first we need to create the <filename>.lnk file */
/* first we need to create the <filename>.lnk file */
- sprintf (scratchFileName, "%s.lnk",
sz
);
+ sprintf (scratchFileName, "%s.lnk",
dstFileName
);
if (!(lnkfile = fopen (scratchFileName, "w")))
{
werror (E_FILE_OPEN_ERR, scratchFileName);
if (!(lnkfile = fopen (scratchFileName, "w")))
{
werror (E_FILE_OPEN_ERR, scratchFileName);
@@
-197,8
+199,7
@@
_gbz80_rgblink (void)
fprintf (lnkfile, "[Objects]\n");
fprintf (lnkfile, "[Objects]\n");
- if (srcFileName)
- fprintf (lnkfile, "%s.o\n", sz);
+ fprintf (lnkfile, "%s.o\n", dstFileName);
for (i = 0; i < nrelFiles; i++)
fprintf (lnkfile, "%s\n", relFiles[i]);
for (i = 0; i < nrelFiles; i++)
fprintf (lnkfile, "%s\n", relFiles[i]);
@@
-209,11
+210,11
@@
_gbz80_rgblink (void)
fprintf (lnkfile, "%s\n", libFiles[i]);
fprintf (lnkfile, "%s\n", libFiles[i]);
- fprintf (lnkfile, "\n[Output]\n" "%s.gb",
sz
);
+ fprintf (lnkfile, "\n[Output]\n" "%s.gb",
dstFileName
);
fclose (lnkfile);
fclose (lnkfile);
- buildCmdLine (buffer,port->linker.cmd,
sz
, NULL, NULL, NULL);
+ buildCmdLine (buffer,port->linker.cmd,
dstFileName
, NULL, NULL, NULL);
/* call the linker */
if (my_system (buffer))
{
/* call the linker */
if (my_system (buffer))
{
@@
-269,6
+270,13
@@
_parseOptions (int *pargc, char **argv, int *i)
_G.asmType = ASM_TYPE_ISAS;
return TRUE;
}
_G.asmType = ASM_TYPE_ISAS;
return TRUE;
}
+ else if (!strcmp (argv[*i], "--asm=z80asm"))
+ {
+ port->assembler.externGlobal = TRUE;
+ asm_addTree (&_z80asm_z80);
+ _G.asmType = ASM_TYPE_ISAS;
+ return TRUE;
+ }
}
}
return FALSE;
}
}
return FALSE;
@@
-302,8
+310,11
@@
_setValues(void)
setMainValue ("z80outext", ".ihx");
}
setMainValue ("z80outext", ".ihx");
}
+ setMainValue ("stdobjdstfilename" , "{dstfilename}{objext}");
+ setMainValue ("stdlinkdstfilename", "{dstfilename}{z80outext}");
+
setMainValue ("z80extraobj", joinn (relFiles, nrelFiles));
setMainValue ("z80extraobj", joinn (relFiles, nrelFiles));
-
+
sprintf (buffer, "-b_CODE=0x%04X -b_DATA=0x%04X", options.code_loc, options.data_loc);
setMainValue ("z80bases", buffer);
}
sprintf (buffer, "-b_CODE=0x%04X -b_DATA=0x%04X", options.code_loc, options.data_loc);
setMainValue ("z80bases", buffer);
}
@@
-322,7
+333,6
@@
_finaliseOptions (void)
static void
_setDefaultOptions (void)
{
static void
_setDefaultOptions (void)
{
- options.genericPtr = 1; /* default on */
options.nopeep = 0;
options.stackAuto = 1;
options.mainreturn = 1;
options.nopeep = 0;
options.stackAuto = 1;
options.mainreturn = 1;
@@
-433,13
+443,13
@@
_hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
"{bindir}{sep}link-{port} -n -c -- {z80bases} -m -j" \
" {z80libspec}" \
" {z80extralibfiles} {z80extralibpaths}" \
"{bindir}{sep}link-{port} -n -c -- {z80bases} -m -j" \
" {z80libspec}" \
" {z80extralibfiles} {z80extralibpaths}" \
- " {z80outputtypeflag} {
srcfilename}{z80outext
}" \
+ " {z80outputtypeflag} {
linkdstfilename
}" \
" {z80crt0}" \
" {z80crt0}" \
- " {
src
filename}{objext}" \
- " {z80extraobj}"
+ " {
dst
filename}{objext}" \
+ " {z80extraobj}"
#define ASMCMD \
#define ASMCMD \
- "{bindir}{sep}as-{port} -plosgff {
srcfilename}{objext} {src
filename}{asmext}"
+ "{bindir}{sep}as-{port} -plosgff {
objdstfilename} {dst
filename}{asmext}"
/* Globals */
PORT z80_port =
/* Globals */
PORT z80_port =
@@
-447,6
+457,7
@@
PORT z80_port =
TARGET_ID_Z80,
"z80",
"Zilog Z80", /* Target name */
TARGET_ID_Z80,
"z80",
"Zilog Z80", /* Target name */
+ NULL, /* Processor name */
{
FALSE,
MODEL_MEDIUM | MODEL_SMALL,
{
FALSE,
MODEL_MEDIUM | MODEL_SMALL,
@@
-502,12
+513,14
@@
PORT z80_port =
"_",
_z80_init,
_parseOptions,
"_",
_z80_init,
_parseOptions,
+ _z80_options,
_finaliseOptions,
_setDefaultOptions,
z80_assignRegisters,
_getRegName,
_keywords,
0, /* no assembler preamble */
_finaliseOptions,
_setDefaultOptions,
z80_assignRegisters,
_getRegName,
_keywords,
0, /* no assembler preamble */
+ NULL, /* no genAssemblerEnd */
0, /* no local IVT generation code */
0, /* no genXINIT code */
_reset_regparm,
0, /* no local IVT generation code */
0, /* no genXINIT code */
_reset_regparm,
@@
-537,6
+550,7
@@
PORT gbz80_port =
TARGET_ID_GBZ80,
"gbz80",
"Gameboy Z80-like", /* Target name */
TARGET_ID_GBZ80,
"gbz80",
"Gameboy Z80-like", /* Target name */
+ NULL,
{
FALSE,
MODEL_MEDIUM | MODEL_SMALL,
{
FALSE,
MODEL_MEDIUM | MODEL_SMALL,
@@
-548,7
+562,8
@@
PORT gbz80_port =
"-plosgff", /* Options with debug */
"-plosgff", /* Options without debug */
0,
"-plosgff", /* Options with debug */
"-plosgff", /* Options without debug */
0,
- ".asm"
+ ".asm",
+ NULL /* no do_assemble function */
},
{
NULL,
},
{
NULL,
@@
-592,12
+607,14
@@
PORT gbz80_port =
"_",
_gbz80_init,
_parseOptions,
"_",
_gbz80_init,
_parseOptions,
+ _z80_options,
_finaliseOptions,
_setDefaultOptions,
z80_assignRegisters,
_getRegName,
_keywords,
0, /* no assembler preamble */
_finaliseOptions,
_setDefaultOptions,
z80_assignRegisters,
_getRegName,
_keywords,
0, /* no assembler preamble */
+ NULL, /* no genAssemblerEnd */
0, /* no local IVT generation code */
0, /* no genXINIT code */
_reset_regparm,
0, /* no local IVT generation code */
0, /* no genXINIT code */
_reset_regparm,