SRC = .
OBJS = asdata.o asexpr.o aslex.o aslist.o asmain.o asout.o \
assubr.o assym.o z80adr.o z80ext.o z80mch.o z80pst.o
-BINS = as$E
+BINS = $(TOPDIR)/bin/as-gbz80$E
+CFLAGS += -DINDEXLIB -DMLH_MAP -DGAMEBOY -DUNIX -DSDK
CFLAGS += -funsigned-char -ggdb
LDFLAGS += -lm
*/
VOID
-main(argc, argv)
-char *argv[];
+main(int argc, char **argv)
{
register char *p;
register c, i;
OBJS = lkarea.o lkdata.o lkeval.o lkhead.o lkihx.o lklex.o \
lklibr.o lklist.o lkmain.o lkrloc.o lks19.o lksym.o \
lkgb.o lkgg.o
-BINS = link$E
+BINS = $(TOPDIR)/bin/link-gbz80$E
+CFLAGS += -DINDEXLIB -DMLH_MAP -DGAMEBOY -DUNIX -DSDK -DSDK_VERSION_STRING="\"3.0.0\"" -DTARGET_STRING="\"gbz80\""
CFLAGS += -funsigned-char -DUNIX
all: $(BINS)
#ifdef GAMEBOY
char *default_basep[] = {
"_CODE=0x0200",
- "_BSS=0xC0A0",
+ "_DATA=0xC0A0",
NULL
};
TTYPE(tree) = TETYPE(tree) =
tree->opval.val->type = tree->opval.val->sym->type =
tree->opval.val->etype = tree->opval.val->sym->etype =
- copyLinkChain(intType);
+ copyLinkChain(INTTYPE);
}
else {
int debug : 1 ; /* generate extra debug info */
int stackOnData:1 ; /* stack after data segment */
int noregparms: 1 ; /* do not pass parameters in registers */
- char *peep_file ; /* additional rules for peep hole */
+ int c1mode : 1 ; /* Act like c1 - no pre-proc, asm or link */
+ char *peep_file ; /* additional rules for peep hole */
+ char *out_name ; /* Asm output name for c1 mode */
char *calleeSaves[128]; /* list of functions using callee save */
char *excludeRegs[32] ; /* registers excluded from saving */
if (options.debug)
cdbStructBlock (0,cdbFile);
- /* create the interrupt vector table */
- createInterruptVect ((vFile = tmpfile ()));
+ vFile = tmpfile();
+ /* PENDING: this isnt the best place but it will do */
+ if (port->general.glue_up_main) {
+ /* create the interrupt vector table */
+ createInterruptVect (vFile);
+ }
+
addSetHead(&tmpfileSet,vFile);
/* emit code for the all the variables declared */
/* now put it all together into the assembler file */
/* create the assembler file name */
- sprintf (buffer, srcFileName);
- strcat (buffer, ".asm");
+
+ if (!options.c1mode) {
+ sprintf (buffer, srcFileName);
+ strcat (buffer, ".asm");
+ }
+ else {
+ strcpy(buffer, options.out_name);
+ }
+
if (!(asmFile = fopen (buffer, "w"))) {
werror (E_FILE_OPEN_ERR, buffer);
exit (1);
/* print the global variables in this module */
printPublics (asmFile);
-
/* copy the sfr segment */
fprintf (asmFile, "%s", iComments2);
/* if the min is not zero then we no make it zero */
if (min) {
cond = geniCodeSubtract(cond,operandFromLit(min));
- setOperandType(cond,ucharType);
+ setOperandType(cond, UCHARTYPE);
}
/* now create the jumptable */
case GETHBIT:
{
operand *op = geniCodeUnary (geniCodeRValue(left,FALSE),tree->opval.op);
- setOperandType(op,ucharType);
+ setOperandType(op, UCHARTYPE);
return op;
}
case '>' :
#define OPTION_VERSION "-version"
#define OPTION_STKAFTRDATA "-stack-after-data"
#define OPTION_PREPROC_ONLY "-preprocessonly"
+#define OPTION_C1_MODE "-c1mode"
#define OPTION_HELP "-help"
#define OPTION_CALLEE_SAVES "-callee-saves"
#define OPTION_NOREGPARMS "-noregparms"
}
/* otherwise depending on the file type */
- if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0) {
+ if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0 || options.c1mode) {
/* source file name : not if we already have a
source file */
if (srcFileName) {
}
+static void _processC1Arg(char *s)
+{
+ if (srcFileName) {
+ if (options.out_name) {
+ werror(W_TOO_MANY_SRC,s);
+ return;
+ }
+ options.out_name = strdup(s);
+ }
+ else {
+ processFile(s);
+ }
+}
+
static void _addToList(const char **list, const char *str)
{
/* This is the bad way to do things :) */
continue;
}
+ if (strcmp(&argv[i][1],OPTION_C1_MODE) == 0) {
+ options.c1mode = 1;
+ continue;
+ }
+
if (strcmp(&argv[i][1],OPTION_DUMP_ALL) == 0) {
options.dump_rassgn =
/* these are undocumented options */
/* if preceded by '/' then turn off certain optmizations, used
for debugging only these are also the legacy options from
- version 1.xx will be removed gradually */
- if ( *argv[i] == '/') {
+ version 1.xx will be removed gradually.
+ It may be an absolute filename.
+ */
+ if ( *argv[i] == '/' && strlen(argv[i]) < 3) {
switch (argv[i][1]) {
case 'p':
if (!port->parseOption(&argc, argv, &i)) {
/* no option must be a filename */
- processFile(argv[i]);
+ if (options.c1mode)
+ _processC1Arg(argv[i]);
+ else
+ processFile(argv[i]);
}
}
preOutName = NULL;
- /* if using external stack define the macro */
- if ( options.useXstack )
- _addToList(preArgv, "-DSDCC_USE_XSTACK");
-
- /* set the macro for stack autos */
- if ( options.stackAuto )
- _addToList(preArgv, "-DSDCC_STACK_AUTO");
+ if (!options.c1mode) {
+ /* if using external stack define the macro */
+ if ( options.useXstack )
+ _addToList(preArgv, "-DSDCC_USE_XSTACK");
+
+ /* set the macro for stack autos */
+ if ( options.stackAuto )
+ _addToList(preArgv, "-DSDCC_STACK_AUTO");
- /* set the macro for large model */
- switch(options.model)
- {
- case MODEL_LARGE:
- _addToList(preArgv, "-DSDCC_MODEL_LARGE");
- break;
- case MODEL_SMALL:
- _addToList(preArgv, "-DSDCC_MODEL_SMALL");
- break;
- case MODEL_FLAT24:
- _addToList(preArgv, "-DSDCC_MODEL_FLAT24");
- break;
- default:
- werror(W_UNKNOWN_MODEL, __FILE__, __LINE__);
- break;
- }
+ /* set the macro for large model */
+ switch(options.model)
+ {
+ case MODEL_LARGE:
+ _addToList(preArgv, "-DSDCC_MODEL_LARGE");
+ break;
+ case MODEL_SMALL:
+ _addToList(preArgv, "-DSDCC_MODEL_SMALL");
+ break;
+ case MODEL_FLAT24:
+ _addToList(preArgv, "-DSDCC_MODEL_FLAT24");
+ break;
+ default:
+ werror(W_UNKNOWN_MODEL, __FILE__, __LINE__);
+ break;
+ }
- /* add port (processor information to processor */
- sprintf(procDef,"-DSDCC_%s",port->target);
- _addToList(preArgv,procDef);
+ /* add port (processor information to processor */
+ sprintf(procDef,"-DSDCC_%s",port->target);
+ _addToList(preArgv,procDef);
- if (!preProcOnly)
- preOutName = strdup(tmpnam(NULL));
+ if (!preProcOnly)
+ preOutName = strdup(tmpnam(NULL));
- _buildCmdLine(buffer, argv, _preCmd, fullSrcFileName,
- preOutName, srcFileName, preArgv);
+ _buildCmdLine(buffer, argv, _preCmd, fullSrcFileName,
+ preOutName, srcFileName, preArgv);
- if (my_system(argv[0], argv)) {
- unlink (preOutName);
- perror("Cannot exec Preprocessor");
- exit(1);
- }
+ if (my_system(argv[0], argv)) {
+ unlink (preOutName);
+ perror("Cannot exec Preprocessor");
+ exit(1);
+ }
- if (preProcOnly)
- exit(0);
+ if (preProcOnly)
+ exit(0);
+ }
+ else {
+ preOutName = fullSrcFileName;
+ }
- yyin = fopen(preOutName,"r");
+ yyin = fopen(preOutName, "r");
if (yyin == NULL) {
perror("Preproc file not found\n");
exit(1);
parseCmdLine(argc,argv);
/* if no input then printUsage & exit */
- if (!srcFileName && !nrelFiles) {
+ if ((!options.c1mode && !srcFileName && !nrelFiles) || (options.c1mode && !srcFileName && !options.out_name)) {
printUsage();
exit(0);
}
if (!fatalError) {
glue();
- assemble(envp);
+ if (!options.c1mode)
+ assemble(envp);
}
}
if (!options.cc_only &&
!fatalError &&
!noAssemble &&
+ !options.c1mode &&
(srcFileName || nrelFiles))
linkEdit (envp);
if (yyin && yyin != stdin)
fclose(yyin);
- if (preOutName) {
+ if (preOutName && !options.c1mode) {
unlink(preOutName);
free(preOutName);
}
symbol *func;
link *type = operandType(IC_RIGHT(ic));
int linenno = ic->lineno;
+ int bwd, su;
ip = ic->next ;
/* remove it from the iCode */
remiCodeFromeBBlock (ebp,ic);
/* depending on the type */
- if (checkType(type,charType) == 1)
- func = __char2fs ;
- else
- if (checkType(type,ucharType) == 1)
- func = __uchar2fs;
- else
- if (checkType(type,intType) == 1)
- func = __int2fs;
- else
- if (checkType(type,uintType) == 1)
- func = __uint2fs ;
- else
- if (checkType(type,longType) == 1)
- func = __long2fs;
- else
- func = __ulong2fs ;
+ for (bwd = 0; bwd < 3; bwd++) {
+ for (su = 0; su < 2; su++) {
+ if (checkType(type, __multypes[bwd][su]) == 1) {
+ func = __conv[0][bwd][su];
+ goto found;
+ }
+ }
+ }
+ assert(0);
+ found:
/* if float support routines NOT compiled as reentrant */
if (! options.float_rent) {
symbol *func;
link *type = operandType(IC_LEFT(ic));
int lineno = ic->lineno ;
+ int bwd, su;
ip = ic->next ;
/* remove it from the iCode */
remiCodeFromeBBlock (ebp,ic);
/* depending on the type */
- if (checkType(type,charType) == 1)
- func = __fs2char ;
- else
- if (checkType(type,ucharType) == 1)
- func = __fs2uchar;
- else
- if (checkType(type,intType) == 1)
- func = __fs2int;
- else
- if (checkType(type,uintType) == 1)
- func = __fs2uint ;
- else
- if (checkType(type,longType) == 1)
- func = __fs2long;
- else
- func = __fs2ulong ;
+ for (bwd = 0; bwd < 3; bwd++) {
+ for (su = 0; su < 2; su++) {
+ if (checkType(type, __multypes[bwd][su]) == 1) {
+ func = __conv[1][bwd][su];
+ goto found;
+ }
+ }
+ }
+ assert(0);
+ found:
/* if float support routines NOT compiled as reentrant */
if (! options.float_rent) {
/*-----------------------------------------------------------------*/
static void convilong (iCode *ic, eBBlock *ebp, link *type, int op)
{
- symbol *func;
+ symbol *func = NULL;
iCode *ip = ic->next;
iCode *newic ;
int lineno = ic->lineno;
-
+ int bwd;
+ int su;
remiCodeFromeBBlock (ebp,ic);
/* depending on the type */
- if (checkType(type,intType) == 1)
- func = (op == '*' ? __mulsint :
- (op == '%' ? __modsint :__divsint));
- else
- if (checkType(type,uintType) == 1)
- func = (op == '*' ? __muluint :
- (op == '%' ? __moduint : __divuint));
- else
- if (checkType(type,longType) == 1)
- func = (op == '*' ? __mulslong :
- (op == '%' ? __modslong : __divslong));
- else
- func = (op == '*'? __mululong :
- (op == '%' ? __modulong : __divulong));
-
+ for (bwd = 0; bwd < 3; bwd++) {
+ for (su = 0; su < 2; su++) {
+ if (checkType(type, __multypes[bwd][su]) == 1) {
+ if (op == '*')
+ func = __muldiv[0][bwd][su];
+ else if (op == '/')
+ func = __muldiv[1][bwd][su];
+ else if (op == '%')
+ func = __muldiv[2][bwd][su];
+ else
+ assert(0);
+ goto found;
+ }
+ }
+ }
+ assert(0);
+ found:
/* if int & long support routines NOT compiled as reentrant */
if (! options.intlong_rent) {
/* first one */
if (ic->op == '*' || ic->op == '/' || ic->op == '%' ) {
link *type = operandType(IC_LEFT(ic));
- if (IS_INTEGRAL(type) && getSize(type) > 1)
+ if (IS_INTEGRAL(type) && getSize(type) > port->muldiv.native_below)
convilong (ic,ebbs[i],type,ic->op);
}
}
symbol *__fslteq;
symbol *__fsgt ;
symbol *__fsgteq;
-symbol *__fs2uchar;
-symbol *__fs2uint ;
-symbol *__fs2ulong;
-symbol *__fs2char;
-symbol *__fs2int ;
-symbol *__fs2long;
-symbol *__long2fs;
-symbol *__ulong2fs;
-symbol *__int2fs;
-symbol *__uint2fs;
-symbol *__char2fs;
-symbol *__uchar2fs;
-symbol *__muluint;
-symbol *__mulsint;
-symbol *__divuint;
-symbol *__divsint;
-symbol *__mululong;
-symbol *__mulslong;
-symbol *__divulong;
-symbol *__divslong;
-symbol *__moduint;
-symbol *__modsint;
-symbol *__modulong;
-symbol *__modslong;
-
-link *charType ;
-link *intType ;
+
+/* Dims: mul/div/mod, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
+symbol *__muldiv[3][3][2];
+/* Dims: BYTE/WORD/DWORD SIGNED/UNSIGNED */
+link *__multypes[3][2];
+/* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
+symbol *__conv[2][3][2];
+
link *floatType;
-link *longType ;
-link *ucharType ;
-link *uintType ;
-link *ulongType ;
/*-----------------------------------------------------------------*/
/* initCSupport - create functions for C support routines */
/*-----------------------------------------------------------------*/
void initCSupport ()
{
- charType = newCharLink();
- intType = newIntLink();
+ const char *smuldivmod[] = {
+ "mul", "div", "mod"
+ };
+ const char *sbwd[] = {
+ "char", "int", "long"
+ };
+ const char *ssu[] = {
+ "s", "u"
+ };
+
+ int bwd, su, muldivmod, tofrom;
+
floatType= newFloatLink();
- longType = newLongLink();
- ucharType = copyLinkChain(charType);
- SPEC_USIGN(ucharType) = 1;
- ulongType = copyLinkChain(longType);
- SPEC_USIGN(ulongType) = 1;
- uintType = copyLinkChain(intType);
- SPEC_USIGN(uintType) = 1;
+ for (bwd = 0; bwd < 3; bwd++) {
+ link *l;
+ switch (bwd) {
+ case 0:
+ l = newCharLink();
+ break;
+ case 1:
+ l = newIntLink();
+ break;
+ case 2:
+ l = newLongLink();
+ break;
+ default:
+ assert(0);
+ }
+ __multypes[bwd][0] = l;
+ __multypes[bwd][1] = copyLinkChain(l);
+ SPEC_USIGN(__multypes[bwd][1]) = 1;
+ }
__fsadd = funcOfType ("__fsadd", floatType, floatType, 2, options.float_rent);
__fssub = funcOfType ("__fssub", floatType, floatType, 2, options.float_rent);
__fsmul = funcOfType ("__fsmul", floatType, floatType, 2, options.float_rent);
__fsdiv = funcOfType ("__fsdiv", floatType, floatType, 2, options.float_rent);
- __fseq = funcOfType ("__fseq", charType, floatType, 2, options.float_rent);
- __fsneq = funcOfType ("__fsneq", charType, floatType, 2, options.float_rent);
- __fslt = funcOfType ("__fslt", charType, floatType, 2, options.float_rent);
- __fslteq= funcOfType ("__fslteq", charType, floatType, 2, options.float_rent);
- __fsgt = funcOfType ("__fsgt", charType, floatType, 2, options.float_rent);
- __fsgteq= funcOfType ("__fsgteq", charType, floatType, 2, options.float_rent);
-
- __fs2uchar = funcOfType ("__fs2uchar",ucharType,floatType,1, options.float_rent);
- __fs2uint = funcOfType ("__fs2uint",uintType,floatType,1, options.float_rent);
- __fs2ulong = funcOfType ("__fs2ulong",ulongType,floatType,1, options.float_rent);
- __fs2char = funcOfType ("__fs2char",charType,floatType,1, options.float_rent);
- __fs2int = funcOfType ("__fs2int",intType,floatType,1, options.float_rent);
- __fs2long = funcOfType ("__fs2long",longType,floatType,1, options.float_rent);
-
- __long2fs = funcOfType ("__long2fs",floatType,longType,1, options.float_rent);
- __ulong2fs = funcOfType ("__ulong2fs",floatType,ulongType,1, options.float_rent);
- __int2fs = funcOfType ("__int2fs",floatType,intType,1, options.float_rent);
- __uint2fs = funcOfType ("__uint2fs",floatType,uintType,1, options.float_rent);
- __char2fs = funcOfType ("__char2fs",floatType,charType,1, options.float_rent);
- __uchar2fs = funcOfType ("__uchar2fs",floatType,ucharType,1, options.float_rent);
-
- __muluint = funcOfType ("_muluint",uintType,uintType,2,options.intlong_rent);
- __mulsint = funcOfType ("_mulsint",intType,intType,2,options.intlong_rent);
- __divuint = funcOfType ("_divuint",uintType,uintType,2,options.intlong_rent);
- __divsint = funcOfType ("_divsint",intType,intType,2,options.intlong_rent);
- __moduint = funcOfType ("_moduint",uintType,uintType,2,options.intlong_rent);
- __modsint = funcOfType ("_modsint",intType,intType,2,options.intlong_rent);
-
- __mululong = funcOfType ("_mululong",ulongType,ulongType,2,options.intlong_rent);
- __mulslong = funcOfType ("_mulslong",longType,longType,2,options.intlong_rent);
- __divulong = funcOfType ("_divulong",ulongType,ulongType,2,options.intlong_rent);
- __divslong = funcOfType ("_divslong",longType,longType,2,options.intlong_rent);
- __modulong = funcOfType ("_modulong",ulongType,ulongType,2,options.intlong_rent);
- __modslong = funcOfType ("_modslong",longType,longType,2,options.intlong_rent);
-
+ __fseq = funcOfType ("__fseq", CHARTYPE, floatType, 2, options.float_rent);
+ __fsneq = funcOfType ("__fsneq", CHARTYPE, floatType, 2, options.float_rent);
+ __fslt = funcOfType ("__fslt", CHARTYPE, floatType, 2, options.float_rent);
+ __fslteq= funcOfType ("__fslteq", CHARTYPE, floatType, 2, options.float_rent);
+ __fsgt = funcOfType ("__fsgt", CHARTYPE, floatType, 2, options.float_rent);
+ __fsgteq= funcOfType ("__fsgteq", CHARTYPE, floatType, 2, options.float_rent);
+
+ for (tofrom = 0; tofrom < 2; tofrom++) {
+ for (bwd = 0; bwd < 3; bwd++) {
+ for (su = 0; su < 2; su++) {
+ if (tofrom) {
+ sprintf(buffer, "__fs2%s%s", ssu[su], sbwd[bwd]);
+ __conv[tofrom][bwd][su] = funcOfType(buffer, __multypes[bwd][su], floatType, 2, options.float_rent);
+ }
+ else {
+ sprintf(buffer, "__%s%s2fs", ssu[su], sbwd[bwd]);
+ __conv[tofrom][bwd][su] = funcOfType(buffer, floatType, __multypes[bwd][su], 2, options.float_rent);
+ }
+ }
+ }
+ }
+
+ for (muldivmod = 0; muldivmod < 3; muldivmod++) {
+ for (bwd = 0; bwd < 3; bwd++) {
+ for (su = 0; su < 2; su++) {
+ sprintf(buffer, "_%s%s%s",
+ smuldivmod[muldivmod],
+ ssu[su],
+ sbwd[bwd]);
+ __muldiv[muldivmod][bwd][su] = funcOfType(buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
+ }
+ }
+ }
}
extern symbol *__fslteq;
extern symbol *__fsgt ;
extern symbol *__fsgteq;
-extern symbol *__fs2uchar;
-extern symbol *__fs2uint ;
-extern symbol *__fs2ulong;
-extern symbol *__fs2char;
-extern symbol *__fs2int ;
-extern symbol *__fs2long;
-extern symbol *__long2fs;
-extern symbol *__ulong2fs;
-extern symbol *__int2fs;
-extern symbol *__uint2fs;
-extern symbol *__char2fs;
-extern symbol *__uchar2fs;
-extern symbol *__muluint;
-extern symbol *__mulsint;
-extern symbol *__divuint;
-extern symbol *__divsint;
-extern symbol *__mululong;
-extern symbol *__mulslong;
-extern symbol *__divulong;
-extern symbol *__divslong;
-extern symbol *__moduint;
-extern symbol *__modsint;
-extern symbol *__modulong;
-extern symbol *__modslong;
-extern link *charType ;
-extern link *intType ;
+/* Dims: mul/div/mod, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
+extern symbol *__muldiv[3][3][2];
+/* Dims: BYTE/WORD/DWORD SIGNED/UNSIGNED */
+extern link *__multypes[3][2];
+/* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
+extern symbol *__conv[2][3][2];
+
+#define CHARTYPE __multypes[0][0]
+#define INTTYPE __multypes[1][0]
+#define UCHARTYPE __multypes[0][1]
+
extern link *floatType;
-extern link *longType ;
-extern link *ucharType ;
-extern link *uintType ;
-extern link *ulongType ;
#include "SDCCval.h"
PORT mcs51_port = {
"mcs51",
"MCU 8051", /* Target name */
+ {
+ TRUE, /* Emit glue around main */
+ },
{
_asmCmd,
"-plosgffc", /* Options with debug */
/** Target name string, used for --help */
const char *target_name;
+ struct {
+ /** TRUE if all types of glue functions should be inseted into
+ the file that also defines main.
+ We dont want this in cases like the z80 where the startup
+ code is provided by a seperate module.
+ */
+ bool glue_up_main;
+ } general;
+
/* assembler related information */
struct {
/** Command to run and arguments (eg as-z80) */
/** One more than the smallest
mul/div operation the processor can do nativley
Eg if the processor has an 8 bit mul, nativebelow is 2 */
- int nativebelow;
+ int native_below;
} muldiv;
/** Called once the processor target has been selected.
$(AWK) -f ../SDCCpeeph.awk peeph-gbz80.def > peeph-gbz80.rul
main.o: main.c peeph.rul
-gbz80.o: gbz80.o peeph-gbz80.rul
+gbz80.o: gbz80.c peeph-gbz80.rul
include clean.mk
PORT gbz80_port = {
"gbz80",
"Gameboy Z80-like", /* Target name */
+ {
+ FALSE,
+ },
{
_asmCmd,
"-plosgff", /* Options with debug */
toBoolean(left);
emitcode(_shortJP, "nz," LABEL_STR,tlbl->key+100);
toBoolean(right);
- emitcode("", LABEL_STR,tlbl->key+100);
+ emitcode("", LABEL_STR ":",tlbl->key+100);
outBitAcc(result);
}
return 0;
}
+/*-----------------------------------------------------------------*/
+/* jmpTrueOrFalse - */
+/*-----------------------------------------------------------------*/
+static void jmpTrueOrFalse (iCode *ic, symbol *tlbl)
+{
+ // ugly but optimized by peephole
+ if(IC_TRUE(ic)){
+ symbol *nlbl = newiTempLabel(NULL);
+ emitcode("jp", LABEL_STR, nlbl->key+100);
+ emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitcode("jp",LABEL_STR,IC_TRUE(ic)->key+100);
+ emitcode("", LABEL_STR ":",nlbl->key+100);
+ }
+ else{
+ emitcode("jp", LABEL_STR, IC_FALSE(ic)->key+100);
+ emitcode("", LABEL_STR ":",tlbl->key+100);
+ }
+ ic->generated = 1;
+}
+
/*-----------------------------------------------------------------*/
/* genAnd - code for and */
/*-----------------------------------------------------------------*/
// if(left & literal)
else{
if(ifx)
-#if 0
jmpTrueOrFalse(ifx, tlbl);
-#else
- assert(0);
-#endif
goto release ;
}
}
while (size--) {
char *l = aopGet(AOP(right),offset,FALSE);
if (isRegOrLit(AOP(right)) && !IS_GB) {
- emitcode("ld", "(%s),%s", l);
+ emitcode("ld", "(%s),%s", ptr, l);
}
else {
MOVA(l);
PORT z80_port = {
"z80",
"Zilog Z80", /* Target name */
+ {
+ FALSE,
+ },
{
_asmCmd,
"-plosgff", /* Options with debug */
# Simple Makefile for dhrystone and sdcc
-CC = /home/michaelh/projects/sdcc/bin/sdcc
+PROC = gbz80
+PORT = gb
+
+CC = /home/michaelh/projects/gbdk-support/lcc/lcc
# -DNOENUM is here to make the results more predictable
-CFLAGS = -mgbz80 -v --dumpall
-CFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM -DBROKEN_SDCC=0 -DHZ=100
-LIBDIR = /home/michaelh/projects/sdcc/device/lib/gbz80/
-LD = link-gb
-AS = as-gb
+CFLAGS =
+CFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM
+LIBDIR = /home/michaelh/projects/gbdk-lib/build/
+LD = link-$(PROC)
+LDFLAGS = -v
+AS = as-$(PROC)
OBJ = dhry.o
all: dhry
dhry: $(OBJ)
- $(LD) -n -- -z -m -k$(LIBDIR) -lz80.lib \
- -b_CODE=0x200 dhry.gb $(LIBDIR)crt0.o $(OBJ)
-# cat dhry.ihx | ../../makebin/makebin > dhry.rom
+ $(CC) -o dhry.gb dhry.o
native:
gcc -g -O2 -DREG= -DNOSTRUCTASSIGN -DNOENUM -o dhry dhry.c
-.c.o:
- $(CC) $(CFLAGS) $<
-
dhry.c:
clean:
#include <string.h>
/** For printf */
#include <stdio.h>
-
-/** Returns the current device time in ticks. Check HZ in the Makefile
- as well - HZ ticks = 1 second.
-*/
-unsigned _clock(void);
+/** For clock() */
+#include <time.h>
/** Print the number of t-states this program has been executing for.
Optional :)
Boolean Func_2 (char *Str_1_Par_Ref, char *Str_2_Par_Ref);
Boolean Func_3 (Enumeration Enum_Par_Val);
-#if SDCC
-int _main(void)
-#else
int main(void)
-#endif
{
One_Fifty Int_1_Loc;
REG One_Fifty Int_2_Loc;
REG int Number_Of_Runs;
unsigned runTime;
- // printf("[dhry]\n");
+ printf("[dhry]\n");
Next_Ptr_Glob = &_r[0];
Ptr_Glob = &_r[1];
/* 32766 is the highest value for a 16 bitter */
Number_Of_Runs = 32766;
- runTime = _clock();
+ runTime = clock();
/* Main test loop */
for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) {
printf("Run_Index = %d\n", Run_Index);
- runTime = _clock() - runTime;
+ runTime = clock() - runTime;
printf ("Execution ends\n");
printf ("\n");
printf ("\n");
printf("Time: %u ticks\n", runTime);
- printf("Dhrystones/s = %u\n", Number_Of_Runs / (runTime/HZ));
+ printf("Dhrystones/s = %u\n", Number_Of_Runs / (runTime/CLOCKS_PER_SEC));
printf("MIPS = d/s/1757 = (sigh, need floats...)\n");
_printTStates();
}
Int_Loc = *Int_Par_Ref + 10;
do {
- DPRINTF(("1\n"));
+ DPRINTF(("1"));
/* executed once */
if (Ch_1_Glob == 'A')
/* then, executed */
{
- DPRINTF(("2\n"));
+ DPRINTF(("2"));
Int_Loc -= 1;
*Int_Par_Ref = Int_Loc - Int_Glob;
Enum_Loc = Ident_1;
} /* if */
- DPRINTF(("3\n"));
+ DPRINTF(("3"));
} while (Enum_Loc != Ident_1); /* true */
DPRINTF(("Proc_2 done.\n"));
} /* Proc_2 */