diff options
author | Michael Pavone <pavone@retrodev.com> | 2019-04-07 00:06:29 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2019-04-07 00:06:29 -0700 |
commit | 376bef93cfadf5d0f778ac887500ee8d5d70fbcc (patch) | |
tree | cf003a31f4362bf3484e6bee1608a7ceae0f507b | |
parent | d8e444e15c16fc80e513c43e99dbb33c30f72a51 (diff) |
Get 64-bit builds working for Windows target
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | gen_x86.c | 10 | ||||
-rw-r--r-- | gen_x86.h | 7 | ||||
-rw-r--r-- | m68k_core_x86.c | 7 | ||||
-rw-r--r-- | z80_to_x86.c | 2 |
5 files changed, 32 insertions, 13 deletions
@@ -10,16 +10,8 @@ BUNDLED_LIBZ:=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/gz zlib/gzwrite.o zlib/infback.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o ifeq ($(OS),Windows) -ifndef SDL2_PREFIX -SDL2_PREFIX:="sdl/i686-w64-mingw32" -endif -ifndef GLEW_PREFIX -GLEW_PREFIX:=glew -endif -ifndef GLEW32S_LIB -GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/Win32/glew32s.lib -endif +GLEW_PREFIX:=glew MEM:=mem_win.o TERMINAL:=terminal_win.o FONT:=nuklear_ui/font_win.o @@ -29,9 +21,16 @@ SO:=dll CPU:=i686 ifeq ($(CPU),i686) CC:=i686-w64-mingw32-gcc-win32 +WINDRES:=i686-w64-mingw32-windres +GLUDIR:=Win32 +SDL2_PREFIX:="sdl/i686-w64-mingw32" else CC:=x86_64-w64-mingw32-gcc-win32 +WINDRES:=x86_64-w64-mingw32-windres +SDL2_PREFIX:="sdl/x86_64-w64-mingw32" +GLUDIR:=x64 endif +GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/$(GLUDIR)/glew32s.lib CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration LDFLAGS:=-lm -lmingw32 -lws2_32 -mwindows ifneq ($(MAKECMDGOALS),libblastem.dll) @@ -365,7 +364,7 @@ vos_prog_info : vos_prog_info.o vos_program_module.o %.bin : %.sz8 vasmz80_mot -Fbin -spaces -o $@ $< res.o : blastem.rc - i686-w64-mingw32-windres blastem.rc res.o + $(WINDRES) blastem.rc res.o arrow.tiles : arrow.png cursor.tiles : cursor.png @@ -2111,7 +2111,12 @@ uint32_t prep_args(code_info *code, uint32_t num_args, va_list args) } #ifdef X86_64 uint32_t stack_args = 0; +#ifdef _WIN32 + //Microsoft is too good for the ABI that everyone else uses on x86-64 apparently + uint8_t abi_regs[] = {RCX, RDX, R8, R9}; +#else uint8_t abi_regs[] = {RDI, RSI, RDX, RCX, R8, R9}; +#endif int8_t reg_swap[R15+1]; uint32_t usage = 0; memset(reg_swap, -1, sizeof(reg_swap)); @@ -2153,6 +2158,11 @@ uint32_t prep_args(code_info *code, uint32_t num_args, va_list args) push_r(code, arg_arr[i]); } free(arg_arr); +#if defined(X86_64) && defined(_WIN32) + sub_ir(code, 32, RSP, SZ_PTR); + code->stack_off += 32; + adjust += 32; +#endif return stack_args * sizeof(void *) + adjust; } @@ -63,6 +63,13 @@ enum { #ifdef X86_64 #define SZ_PTR SZ_Q #define MAX_INST_LEN 14 +#ifdef _WIN32 +#define FIRST_ARG_REG RCX +#define SECOND_ARG_REG RDX +#else +#define FIRST_ARG_REG RDI +#define SECOND_ARG_REG RSI +#endif #else #define SZ_PTR SZ_D #define MAX_INST_LEN 11 diff --git a/m68k_core_x86.c b/m68k_core_x86.c index a0a6f06..6455e70 100644 --- a/m68k_core_x86.c +++ b/m68k_core_x86.c @@ -2658,8 +2658,11 @@ void init_m68k_opts(m68k_options * opts, memmap_chunk * memmap, uint32_t num_chu opts->start_context = (start_fun)code->cur; save_callee_save_regs(code); #ifdef X86_64 - if (opts->gen.scratch2 != RDI) { - mov_rr(code, RDI, opts->gen.scratch2, SZ_PTR); + if (opts->gen.scratch2 != FIRST_ARG_REG) { + mov_rr(code, FIRST_ARG_REG, opts->gen.scratch2, SZ_PTR); + } + if (opts->gen.context_reg != SECOND_ARG_REG) { + mov_rr(code, SECOND_ARG_REG, opts->gen.context_reg, SZ_PTR); } #else mov_rdispr(code, RSP, 20, opts->gen.scratch2, SZ_D); diff --git a/z80_to_x86.c b/z80_to_x86.c index c263e56..9c77674 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -3601,7 +3601,7 @@ void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t tmp_stack_off = code->stack_off; save_callee_save_regs(code); #ifdef X86_64 - mov_rr(code, RDI, options->gen.context_reg, SZ_PTR); + mov_rr(code, FIRST_ARG_REG, options->gen.context_reg, SZ_PTR); #else mov_rdispr(code, RSP, 5 * sizeof(int32_t), options->gen.context_reg, SZ_PTR); #endif |