X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fz80%2Fmain.c;h=7e589c0790cbd80f7242a478672b2a9a8513684d;hb=e29becd95456cf7510a45c41af35bee5fa362ba8;hp=cbf52a6d58176c9e839fad27191b2fd278f2d38c;hpb=29664046339501e0cb6b77286ea02a51e9acd266;p=fw%2Fsdcc diff --git a/src/z80/main.c b/src/z80/main.c index cbf52a6d..7e589c07 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -46,7 +46,13 @@ Z80_OPTS z80_opts; static OPTION _z80_options[] = { { 0, "--callee-saves-bc", &z80_opts.calleeSavesBC, "Force a called function to always save BC" }, - { 80, "--portmode", &z80_opts.port_mode, "Determine PORT I/O mode (z80/z180)" }, + { 0, "--portmode=", NULL, "Determine PORT I/O mode (z80/z180)" }, + { 0, NULL } + }; + +static OPTION _gbz80_options[] = + { + { 0, "--callee-saves-bc", &z80_opts.calleeSavesBC, "Force a called function to always save BC" }, { 0, NULL } }; @@ -75,6 +81,8 @@ static char *_keywords[] = "banked", "at", //.p.t.20030714 adding support for 'sfr at ADDR' construct "_naked", //.p.t.20030714 adding support for '_naked' functions + "critical", + "interrupt", NULL }; @@ -105,13 +113,13 @@ _gbz80_init (void) } static void -_reset_regparm () +_reset_regparm (void) { _G.regParams = 0; } static int -_reg_parm (sym_link * l) +_reg_parm (sym_link * l, bool reentrant) { if (options.noRegParams) { @@ -133,12 +141,17 @@ _reg_parm (sym_link * l) static int _process_pragma (const char *sz) { - if( startsWith( sz, "bank=" )) + if( startsWith( sz, "bank=" ) || startsWith( sz, "bank " )) { char buffer[128]; - strcpy (buffer, sz + 5); + + if (sz[4]=='=') + werror(W_DEPRECATED_PRAGMA, "bank="); + + strncpy (buffer, sz + 5, sizeof (buffer)); + buffer[sizeof (buffer) - 1 ] = '\0'; chomp (buffer); - if (isdigit (buffer[0])) + if (isdigit ((unsigned char)buffer[0])) { } @@ -146,12 +159,13 @@ _process_pragma (const char *sz) { strcpy (buffer, "HOME"); } - if (isdigit (buffer[0])) + if (isdigit ((unsigned char)buffer[0])) { /* Arg was a bank number. Handle in an ASM independent way. */ char num[128]; - strcpy (num, sz + 5); + strncpy (num, sz + 5, sizeof (num)); + num[sizeof (num) -1] = '\0'; chomp (num); switch (_G.asmType) @@ -174,11 +188,15 @@ _process_pragma (const char *sz) code->sname = gbz80_port.mem.code_name; return 0; } - else if( startsWith( sz, "portmode=" )) + else if( startsWith( sz, "portmode=" ) || startsWith( sz, "portmode " )) { /*.p.t.20030716 - adding pragma to manipulate z80 i/o port addressing modes */ char bfr[128]; - strcpy( bfr, sz + 9 ); + if (sz[8]=='=') + werror(W_DEPRECATED_PRAGMA, "portmode="); + + strncpy( bfr, sz + 9, sizeof (bfr)); + bfr[sizeof (bfr) - 1] = '\0'; chomp( bfr ); if ( !strcmp( bfr, "z80" )){ z80_opts.port_mode = 80; } @@ -294,6 +312,19 @@ _parseOptions (int *pargc, char **argv, int *i) return TRUE; } } + else if (!strncmp (argv[*i], "--portmode=", 11)) + { + if (!strcmp (argv[*i], "--portmode=z80")) + { + z80_opts.port_mode = 80; + return TRUE; + } + else if (!strcmp (argv[*i], "--portmode=z180")) + { + z80_opts.port_mode = 180; + return TRUE; + } + } } return FALSE; } @@ -567,12 +598,15 @@ PORT z80_port = /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */ 1, 2, 2, 4, 2, 2, 2, 1, 4, 4 }, + /* tags for generic pointers */ + { 0x00, 0x40, 0x60, 0x80 }, /* far, near, xstack, code */ { "XSEG", "STACK", "CODE", "DATA", "ISEG", + NULL, /* pdata */ "XSEG", "BSEG", "RSEG", @@ -582,6 +616,7 @@ PORT z80_port = "HOME", NULL, /* xidata */ NULL, /* xinit */ + NULL, /* const_name */ NULL, NULL, 1 @@ -594,10 +629,24 @@ PORT z80_port = { 0, 2 }, + { + z80_emitDebuggerSymbol + }, + { + 255, /* maxCount */ + 3, /* sizeofElement */ + /* The rest of these costs are bogus. They approximate */ + /* the behavior of src/SDCCicode.c 1.207 and earlier. */ + {4,4,4}, /* sizeofMatchJump[] */ + {0,0,0}, /* sizeofRangeCompare[] */ + 0, /* sizeofSubtract */ + 3, /* sizeofDispatch */ + }, "_", _z80_init, _parseOptions, _z80_options, + NULL, _finaliseOptions, _setDefaultOptions, z80_assignRegisters, @@ -607,6 +656,7 @@ PORT z80_port = NULL, /* no genAssemblerEnd */ 0, /* no local IVT generation code */ 0, /* no genXINIT code */ + NULL, /* genInitStartup */ _reset_regparm, _reg_parm, _process_pragma, @@ -667,12 +717,15 @@ PORT gbz80_port = /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */ 1, 2, 2, 4, 2, 2, 2, 1, 4, 4 }, + /* tags for generic pointers */ + { 0x00, 0x40, 0x60, 0x80 }, /* far, near, xstack, code */ { "XSEG", "STACK", "CODE", "DATA", "ISEG", + NULL, /* pdata */ "XSEG", "BSEG", "RSEG", @@ -682,6 +735,7 @@ PORT gbz80_port = "HOME", NULL, /* xidata */ NULL, /* xinit */ + NULL, /* const_name */ NULL, NULL, 1 @@ -694,10 +748,24 @@ PORT gbz80_port = { 0, 2 }, + { + z80_emitDebuggerSymbol + }, + { + 255, /* maxCount */ + 3, /* sizeofElement */ + /* The rest of these costs are bogus. They approximate */ + /* the behavior of src/SDCCicode.c 1.207 and earlier. */ + {4,4,4}, /* sizeofMatchJump[] */ + {0,0,0}, /* sizeofRangeCompare[] */ + 0, /* sizeofSubtract */ + 3, /* sizeofDispatch */ + }, "_", _gbz80_init, _parseOptions, - _z80_options, + _gbz80_options, + NULL, _finaliseOptions, _setDefaultOptions, z80_assignRegisters, @@ -707,6 +775,7 @@ PORT gbz80_port = NULL, /* no genAssemblerEnd */ 0, /* no local IVT generation code */ 0, /* no genXINIT code */ + NULL, /* genInitStartup */ _reset_regparm, _reg_parm, _process_pragma,