X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fz80%2Fmain.c;h=adc65c09523d7af462524f90be140ae759f9db78;hb=d08e6df2202ed3f19b681221b502dedb3c6c8a28;hp=64984af6b6bf5e15c93731835d7e324591863925;hpb=f1be544d8fcb3ff37000939b9739e427f65f3a91;p=fw%2Fsdcc diff --git a/src/z80/main.c b/src/z80/main.c index 64984af6..adc65c09 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -37,6 +37,7 @@ #define OPTION_CALLEE_SAVES_BC "--callee-saves-bc" #define OPTION_PORTMODE "--portmode=" #define OPTION_ASM "--asm=" +#define OPTION_NO_STD_CRT0 "--no-std-crt0" static char _z80_defaultRules[] = @@ -56,20 +57,22 @@ Z80_OPTS z80_opts; static OPTION _z80_options[] = { { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" }, - { 0, OPTION_PORTMODE, NULL, "Determine PORT I/O mode (z80/z180)" }, - { 0, OPTION_ASM, NULL, "Define assembler name (rgbds/asxxxx/isas/z80asm)" }, - { 0, OPTION_CODE_SEG, NULL, " use this name for the code segment" }, - { 0, OPTION_CONST_SEG, NULL, " use this name for the const segment" }, + { 0, OPTION_PORTMODE, NULL, "Determine PORT I/O mode (z80/z180)" }, + { 0, OPTION_ASM, NULL, "Define assembler name (rgbds/asxxxx/isas/z80asm)" }, + { 0, OPTION_CODE_SEG, &options.code_seg, " use this name for the code segment", CLAT_STRING }, + { 0, OPTION_CONST_SEG, &options.const_seg, " use this name for the const segment", CLAT_STRING }, + { 0, OPTION_NO_STD_CRT0, &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"}, { 0, NULL } }; static OPTION _gbz80_options[] = { - { 0, OPTION_BO, NULL, " use code bank " }, - { 0, OPTION_BA, NULL, " use data bank " }, + { 0, OPTION_BO, NULL, " use code bank " }, + { 0, OPTION_BA, NULL, " use data bank " }, { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" }, - { 0, OPTION_CODE_SEG, NULL, " use this name for the code segment" }, - { 0, OPTION_CONST_SEG, NULL, " use this name for the const segment" }, + { 0, OPTION_CODE_SEG, &options.code_seg, " use this name for the code segment", CLAT_STRING }, + { 0, OPTION_CONST_SEG, &options.const_seg, " use this name for the const segment", CLAT_STRING }, + { 0, OPTION_NO_STD_CRT0, &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"}, { 0, NULL } }; @@ -109,11 +112,8 @@ extern PORT z80_port; #include "mappings.i" static builtins _z80_builtins[] = { - /* Disabled for now. - { "__builtin_strcpy", "v", 2, {"cg*", "cg*" } }, - { "__builtin_memcpy", "cg*", 3, {"cg*", "cg*", "ui" } }, - */ - { NULL , NULL,0, {NULL}} + { "__builtin_memcpy", "vg*", 3, {"vg*", "vg*", "ui" } }, + { NULL , NULL, 0, {NULL}} }; static void @@ -460,18 +460,6 @@ _parseOptions (int *pargc, char **argv, int *i) return TRUE; } } - else if (!strcmp (argv[*i], OPTION_CODE_SEG)) - { - if (options.code_seg) Safe_free(options.code_seg); - options.code_seg = Safe_strdup(getStringArg (OPTION_CODE_SEG, argv, i, *pargc)); - return TRUE; - } - else if (!strcmp (argv[*i], OPTION_CONST_SEG)) - { - if (options.const_seg) Safe_free(options.const_seg); - options.const_seg = Safe_strdup(getStringArg (OPTION_CONST_SEG, argv, i, *pargc)); - return TRUE; - } } return FALSE; } @@ -535,7 +523,7 @@ _setValues(void) if (IS_GB) { - setMainValue ("z80outputtypeflag", "-z"); + setMainValue ("z80outputtypeflag", "-Z"); setMainValue ("z80outext", ".gb"); } else @@ -596,7 +584,7 @@ _setDefaultOptions (void) optimize.loopInduction = 1; } -/* Mangaling format: +/* Mangling format: _fun_policy_params where: policy is the function policy @@ -607,7 +595,7 @@ _setDefaultOptions (void) where: r is 'r' for reentrant, 's' for static functions s is 'c' for callee saves, 'r' for caller saves - p is 'p' for profiling on, 'x' for profiling off + f is 'f' for profiling on, 'x' for profiling off examples: rr - reentrant, caller saves params format: @@ -623,7 +611,7 @@ _mangleSupportFunctionName(char *original) sprintf(buffer, "%s_rr%s_%s", original, options.profile ? "f" : "x", - options.noRegParams ? "s" : "bds" + options.noRegParams ? "s" : "bds" /* MB: but the library only has hds variants ??? */ ); return Safe_strdup(buffer); @@ -658,9 +646,16 @@ _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right) } else if ( IS_LITERAL (right)) { - test = left; + test = right; val = OP_VALUE (IC_RIGHT (ic)); } + /* 8x8 unsigned multiplication code is shorter than + call overhead for the multiplication routine. */ + else if ( IS_CHAR (right) && IS_UNSIGNED (right) && + IS_CHAR (left) && IS_UNSIGNED(left) && !IS_GB) + { + return TRUE; + } else { return FALSE; @@ -723,23 +718,28 @@ PORT z80_port = MODEL_MEDIUM | MODEL_SMALL, MODEL_SMALL }, - { + { /* Assembler */ NULL, ASMCMD, - "-plosgff", /* Options with debug */ + "-plosgffc", /* Options with debug */ "-plosgff", /* Options without debug */ 0, ".asm" }, - { + { /* Linker */ NULL, LINKCMD, NULL, ".o", 1 }, - { - _z80_defaultRules + { /* Peephole optimizer */ + _z80_defaultRules, + 0, + 0, + 0, + 0, + z80notUsed }, { /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */ @@ -824,7 +824,7 @@ PORT z80_port = 0, /* leave == */ TRUE, /* Array initializer support. */ 0, /* no CSE cost estimation yet */ - _z80_builtins, /* no builtin functions */ + _z80_builtins, /* builtin functions */ GPOINTER, /* treat unqualified pointers as "generic" pointers */ 1, /* reset labelKey to 1 */ 1, /* globals & local static allowed */ @@ -847,7 +847,7 @@ PORT gbz80_port = { NULL, ASMCMD, - "-plosgff", /* Options with debug */ + "-plosgffc", /* Options with debug */ "-plosgff", /* Options without debug */ 0, ".asm",