mirror of https://github.com/mlaux/gb6.git
successfully generates a "return 0xffff" instruction on 68k and testable on mac
This commit is contained in:
parent
d69a3b35f1
commit
ce66b5ba3a
|
@ -17,3 +17,8 @@ add_application(Emulator
|
|||
lcd_mac.c
|
||||
resources.r
|
||||
)
|
||||
|
||||
add_application(CompilerTest
|
||||
compiler68k.c
|
||||
CONSOLE
|
||||
)
|
|
@ -2,8 +2,11 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_MPROTECT
|
||||
#include <sys/mman.h> // mprotect
|
||||
#include <unistd.h> // getpagesize
|
||||
#endif
|
||||
|
||||
// A -> D0
|
||||
// BC -> D1
|
||||
|
@ -64,13 +67,12 @@ struct basic_block *compile_block(uint16_t src_address, uint8_t *gb_code)
|
|||
}
|
||||
}
|
||||
|
||||
bblock->length = 6;
|
||||
bblock->code[0] = 0xb8; // mov eax, 1234h
|
||||
bblock->code[1] = 0x34;
|
||||
bblock->code[2] = 0x12;
|
||||
bblock->code[3] = 0x00;
|
||||
bblock->code[4] = 0x00;
|
||||
bblock->code[5] = 0xc3; // ret
|
||||
bblock->length = 4;
|
||||
// bblock->code[0] = 0xc3;
|
||||
bblock->code[0] = 0x70; // moveq #$ff, d0
|
||||
bblock->code[1] = 0xff;
|
||||
bblock->code[2] = 0x4e; // rts
|
||||
bblock->code[3] = 0x75;
|
||||
|
||||
return bblock;
|
||||
}
|
||||
|
@ -114,6 +116,7 @@ void run_all(uint8_t *gb_code)
|
|||
}
|
||||
|
||||
// for testing...
|
||||
#ifdef USE_MPROTECT
|
||||
page_size = getpagesize();
|
||||
ret = mprotect(
|
||||
(void *) ((uint64_t) bblock & ~(page_size - 1)),
|
||||
|
@ -124,7 +127,13 @@ void run_all(uint8_t *gb_code)
|
|||
perror("mprotect");
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
// __builtin___clear_cache(bblock, bblock + sizeof *bblock);
|
||||
asm("":::"memory");
|
||||
jump_target = ((uint16_t (*)()) bblock->code)();
|
||||
if (jump_target == 0xffff) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,5 +161,7 @@ int main(int argc, char *argv[])
|
|||
free(data);
|
||||
}
|
||||
|
||||
while(1);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -85,13 +85,13 @@ void Render(void)
|
|||
SetPort(g_wp);
|
||||
// CopyBits(&offscreenBmp, &g_wp->portBits, &offscreenRect, &offscreenRect, srcCopy, NULL);
|
||||
|
||||
EraseRect(&g_wp->portRect);
|
||||
MoveTo(10, 180);
|
||||
char debug[128];
|
||||
double ms = execTime / 600.0;
|
||||
sprintf(debug, "10000 in %d ticks, %.2f ms per instruction", execTime, ms);
|
||||
C2PStr(debug);
|
||||
DrawString(debug);
|
||||
// EraseRect(&g_wp->portRect);
|
||||
// MoveTo(10, 180);
|
||||
// char debug[128];
|
||||
// double ms = execTime / 600.0;
|
||||
// sprintf(debug, "10000 in %d ticks, %.2f ms per instruction", execTime, ms);
|
||||
// C2PStr(debug);
|
||||
// DrawString(debug);
|
||||
}
|
||||
|
||||
// 417 ticks
|
||||
|
@ -121,7 +121,7 @@ void StartEmulation(void)
|
|||
emulationOn = 1;
|
||||
}
|
||||
|
||||
bool LoadRom(StrFileName fileName, short vRefNum)
|
||||
bool LoadRom(Str255 fileName, short vRefNum)
|
||||
{
|
||||
int err;
|
||||
short fileNo;
|
||||
|
|
|
@ -37,8 +37,4 @@
|
|||
#define EMULATION_PREFERENCES 4
|
||||
#define EMULATION_KEY_MAPPINGS 5
|
||||
|
||||
typedef unsigned char bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
cc -DUSE_MPROTECT -o compiler system6/compiler68k.c
|
Loading…
Reference in New Issue