return aop;
}
+#if 0
if (IS_GB) {
/* if it is in direct space */
if (IN_DIRSPACE(space)) {
return aop;
}
}
+#endif
/* only remaining is far space */
/* in which case DPTR gets the address */
- sym->aop = aop = newAsmop(AOP_IY);
- if (!IS_GB)
+ if (IS_GB)
+ sym->aop = aop = newAsmop(AOP_HL);
+ else {
+ sym->aop = aop = newAsmop(AOP_IY);
emitcode ("ld","iy,#%s ; a", sym->rname);
+ }
aop->size = getSize(sym->type);
aop->aopu.aop_dir = sym->rname;
case AOP_REG:
return aop->aopu.aop_reg[offset]->name;
+ case AOP_HL:
+ emitcode("ld", "hl,#%s+%d", aop->aopu.aop_dir, offset);
+ sprintf(s, "(hl)");
+ ALLOC_ATOMIC(rs, strlen(s)+1);
+ strcpy(rs,s);
+ return rs;
+
case AOP_IY:
sprintf(s,"%d(iy)", offset);
ALLOC_ATOMIC(rs,strlen(s)+1);
else
emitcode("ld", "%d(iy),%s", offset, s);
break;
-
+
+ case AOP_HL:
+ assert(IS_GB);
+ if (!strcmp(s, "(hl)")) {
+ emitcode("ld", "a,(hl)");
+ s = "a";
+ }
+ emitcode("ld", "hl,#%s+%d", aop->aopu.aop_dir, offset);
+ emitcode("ld", "(hl),%s", s);
+ break;
+
case AOP_STK:
if (IS_GB) {
if (!strcmp("(hl)", s)) {
static bool requiresHL(asmop *aop)
{
switch (aop->type) {
+ case AOP_DIR:
+ case AOP_HL:
case AOP_STK:
return TRUE;
default:
static void fetchHL(asmop *aop)
{
if (IS_GB && requiresHL(aop)) {
- emitcode("ld", "a,%s", aopGet(aop, 0, FALSE));
- emitcode("ld", "h,%s", aopGet(aop, 1, FALSE));
+ aopGet(aop, 0, FALSE);
+ emitcode("ld", "a,(hl+)");
+ emitcode("ld", "h,(hl)");
emitcode("ld", "l,a");
}
else {
size = AOP_SIZE(IC_LEFT(ic));
if ((size == 2) && ((l = aopGetWord(AOP(IC_LEFT(ic)), 0)))) {
+ if (IS_GB) {
+ emitcode("ld", "de,%s", l);
+ }
+ else {
emitcode("ld", "hl,%s", l);
+ }
}
else {
while (size--) {
MOVA(aopGet(AOP(right),offset,FALSE));
emitcode("or","a,%s ; 7",
aopGet(AOP(left),offset,FALSE));
- aopPut(AOP(result),"a ; 8",0);
+ aopPut(AOP(result),"a ; 8", offset);
}
}
}
{
int size, offset ;
link *retype = getSpec(operandType(right));
+ const char *ptr = "hl";
aopOp(result,ic,FALSE);
aopOp(right,ic,FALSE);
+ if (IS_GB)
+ ptr = "de";
+
/* Handle the exceptions first */
if (isPair(AOP(result)) && (AOP_SIZE(right)==1)) {
/* Just do it */
/* if this is remateriazable */
if (AOP_TYPE(result) == AOP_IMMD) {
emitcode("", "; Error 2");
- emitcode("ld", "hl,%s", aopGet(AOP(result), 0, TRUE));
+ emitcode("ld", "%s,%s", ptr, aopGet(AOP(result), 0, TRUE));
}
else { /* we need to get it byte by byte */
- /* PENDING: do this better */
- fetchHL(AOP(result));
+ if (IS_GB) {
+ emitcode("ld", "e,%s", aopGet(AOP(result), 0, TRUE));
+ emitcode("ld", "d,%s", aopGet(AOP(result), 1, TRUE));
+ }
+ else {
+ /* PENDING: do this better */
+ fetchHL(AOP(result));
+ }
}
}
/* so hl know contains the address */
while (size--) {
char *l = aopGet(AOP(right),offset,FALSE);
-
- if (isRegOrLit(AOP(right))) {
- emitcode("ld", "(hl),%s", l);
+ if (isRegOrLit(AOP(right)) && !IS_GB) {
+ emitcode("ld", "(%s),%s", l);
}
else {
MOVA(l);
- emitcode("ld", "(hl),a", offset);
+ emitcode("ld", "(%s),a", ptr, offset);
}
if (size) {
- emitcode("inc", "hl");
+ emitcode("inc", ptr);
}
offset++;
}
if (sym->onStack) {
/* if it has an offset then we need to compute it */
if (IS_GB) {
- emitcode("lda", "hl,%d+%d(sp)", sym->stack, _spoffset);
+ emitcode("lda", "hl,%d+%d+%d(sp)", sym->stack, _pushed, _spoffset);
emitcode("ld", "d,h");
emitcode("ld", "e,l");
aopPut(AOP(IC_RESULT(ic)), "e", 0);
# Simple Makefile for dhrystone and sdcc
-CC = /home/michaelh/projects/sdcc/bin/sdcc
+#CC = /home/michaelh/projects/sdcc/bin/sdcc
# -DNOENUM is here to make the results more predictable
-CFLAGS = -mgbz80 -v --dumpall
+#CFLAGS = -mgbz80 -v --dumpall
+CC = lcc-gb
+CFLAGS = -int16 -DSDCC=1 -v
CFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM -DBROKEN_SDCC=0 -DHZ=100
-LIBDIR = /home/michaelh/projects/sdcc/device/lib/z80/
-LD = link-z80
+LIBDIR = /home/michaelh/projects/sdcc/device/lib/gbz80/
+LD = link-gb
+AS = as-gb
OBJ = dhry.o
all: dhry
dhry: $(OBJ)
- $(LD) -n -- -i -m -k$(LIBDIR) -lz80.lib \
- -b_CODE=0x200 dhry.ihx $(LIBDIR)crt0.o $(OBJ)
- cat dhry.ihx | ../../makebin/makebin > dhry.rom
+ $(LD) -n -- -z -m -k$(LIBDIR) -lz80.lib \
+ -b_CODE=0x200 dhry.gb $(LIBDIR)crt0.o $(OBJ)
+# cat dhry.ihx | ../../makebin/makebin > dhry.rom
native:
gcc -g -O2 -DREG= -DNOSTRUCTASSIGN -DNOENUM -o dhry dhry.c
.c.o:
$(CC) $(CFLAGS) $<
-dhry.c: $(CC)
+dhry.c:
clean:
rm -r *~ dhry
+dhry.o: dhry.c
+ /usr/lib/SDK/gbz80-gb/2.1.0/bin/cpp -DINT_16_BITS -D__STDC__=1 -DZ80 -DGB -DGAMEBOY -D__LCC__ -DSDCC=1 -DREG= -DNOSTRUCTASSIGN -DNOENUM -DBROKEN_SDCC=0 -DHZ=100 -I/usr/lib/sdcc/include dhry.c dhry.i
+ /usr/lib/SDK/gbz80-gb/2.1.0/bin/rcc -target=gbz80/int16 -optimize -v dhry.i dhry.asm
+ $(AS) -plosff dhry.o dhry.asm
\ No newline at end of file