diff --git a/src/386.c b/src/386.c index 7f2455c..8a03cc4 100644 --- a/src/386.c +++ b/src/386.c @@ -2,11 +2,13 @@ #include #include #include "ibm.h" +#include "386.h" #include "x86.h" #include "x87.h" #include "mem.h" #include "cpu.h" #include "fdc.h" +#include "pic.h" #include "timer.h" #include "386_common.h" @@ -231,7 +233,7 @@ void exec386(int cycs) /* testr[8]=flags;*/ // oldcs2=oldcs; // oldpc2=oldpc; -opcode_realstart: + oldcs=CS; cpu_state.oldpc = cpu_state.pc; oldcpl=CPL; @@ -242,7 +244,6 @@ dontprint=0; cpu_state.ea_seg = &_ds; cpu_state.ssegs = 0; -opcodestart: fetchdat = fastreadl(cs + cpu_state.pc); if (!cpu_state.abrt) diff --git a/src/386.h b/src/386.h index b3c6d16..d78be84 100644 --- a/src/386.h +++ b/src/386.h @@ -1,2 +1,15 @@ extern void cpu_386_flags_extract(); extern void cpu_386_flags_rebuild(); + +void pmodeint(int num, int soft); +void loadcscall(uint16_t seg); +void loadcsjmp(uint16_t seg, uint32_t oxpc); +void pmoderetf(int is32, uint16_t off); +void pmodeiret(int is32); +void x86_int_sw(int num); + +int divl(uint32_t val); +int idivl(int32_t val); + +int rep386(int fv); + diff --git a/src/386_common.h b/src/386_common.h index 37d467f..bbcfaa0 100644 --- a/src/386_common.h +++ b/src/386_common.h @@ -13,6 +13,7 @@ extern uint16_t ea_rseg; #define writememl(s,a,v) if (writelookup2[(uint32_t)((s)+(a))>>12]==-1 || (s)==0xFFFFFFFF || (((s)+(a))&0xFFF)>0xFFC) writememll(s,a,v); else *(uint32_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v #define writememq(s,a,v) if (writelookup2[(uint32_t)((s)+(a))>>12]==-1 || (s)==0xFFFFFFFF || (((s)+(a))&0xFFF)>0xFF8) writememql(s,a,v); else *(uint64_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v +int checkio(int port); #define check_io_perm(port) if (!IOPLp || (eflags&VM_FLAG)) \ { \ @@ -75,7 +76,7 @@ static inline uint8_t fastreadb(uint32_t a) return *((uint8_t *)&pccache2[a]); t = getpccache(a); if (cpu_state.abrt) - return; + return 0; pccache = a >> 12; pccache2 = t; return *((uint8_t *)&pccache2[a]); @@ -94,7 +95,7 @@ static inline uint16_t fastreadw(uint32_t a) if ((a>>12)==pccache) return *((uint16_t *)&pccache2[a]); t = getpccache(a); if (cpu_state.abrt) - return; + return 0; pccache = a >> 12; pccache2 = t; diff --git a/src/386_dynarec.c b/src/386_dynarec.c index 4951ccd..09894dd 100644 --- a/src/386_dynarec.c +++ b/src/386_dynarec.c @@ -2,6 +2,7 @@ #include #include #include "ibm.h" +#include "386.h" #include "x86.h" #include "x86_ops.h" #include "x87.h" @@ -9,6 +10,7 @@ #include "codegen.h" #include "cpu.h" #include "fdc.h" +#include "pic.h" #include "timer.h" #include "386_common.h" @@ -261,7 +263,6 @@ void x86_int_sw(int num) void x86illegal() { - uint16_t addr; // pclog("x86 illegal %04X %08X %04X:%08X %02X\n",msw,cr0,CS,pc,opcode); // if (output) @@ -363,7 +364,6 @@ int rep386(int fv) uint8_t temp2; uint16_t tempw,tempw2,of; uint32_t ipc = cpu_state.oldpc;//pc-1; - uint32_t oldds; uint32_t rep32 = cpu_state.op32; uint32_t templ,templ2; int tempz; @@ -1376,7 +1376,6 @@ void exec386_dynarec(int cycs) cpu_state.ea_seg = &_ds; cpu_state.ssegs = 0; - opcodestart: fetchdat = fastreadl(cs + cpu_state.pc); // if (!fetchdat) // fatal("Dead with cache off\n"); @@ -1509,7 +1508,6 @@ inrecomp=0; } else if (valid_block && !cpu_state.abrt) { - uint32_t start_page = cpu_state.pc >> 12; uint32_t start_pc = cpu_state.pc; // pclog("Hash %08x %i\n", codeblock_hash_pc[HASH(cs + pc)], codeblock_page_dirty[(cs + pc) >> 12]); @@ -1532,7 +1530,6 @@ inrecomp=0; cpu_state.ea_seg = &_ds; cpu_state.ssegs = 0; - opcodestart_compile: fetchdat = fastreadl(cs + cpu_state.pc); // if (fetchdat == 0xffffffff) // fatal("Dead ffffffff\n"); @@ -1592,7 +1589,6 @@ inrecomp=0; else if (!cpu_state.abrt) { /*Mark block but do not recompile*/ - uint32_t start_page = cpu_state.pc >> 12; uint32_t start_pc = cpu_state.pc; // pclog("Hash %08x %i\n", codeblock_hash_pc[HASH(cs + pc)], codeblock_page_dirty[(cs + pc) >> 12]); diff --git a/src/386_dynarec_ops.c b/src/386_dynarec_ops.c index be66040..bef86c8 100644 --- a/src/386_dynarec_ops.c +++ b/src/386_dynarec_ops.c @@ -1,10 +1,12 @@ #include "ibm.h" #include "cpu.h" +#include "386.h" #include "x86.h" #include "x86_ops.h" #include "x87.h" #include "x86_flags.h" #include "mem.h" +#include "pic.h" #include "codegen.h" #define CPU_BLOCK_END() cpu_block_end = 1 diff --git a/src/808x.c b/src/808x.c index c7f12c0..80d5973 100644 --- a/src/808x.c +++ b/src/808x.c @@ -9,9 +9,12 @@ 4 clocks - fetch mod/rm 2 clocks - fetch opcode 1 2 clocks - execute 2 clocks - fetch opcode 2 etc*/ +#include #include #include "ibm.h" +#include "x86_ops.h" +#include "codegen.h" #include "cpu.h" #include "keyboard.h" #include "mem.h" @@ -19,6 +22,7 @@ #include "pic.h" #include "timer.h" #include "x86.h" +#include "x87.h" int xt_cpu_multi; int nmi = 0; @@ -93,7 +97,6 @@ void writememl(uint32_t s, uint32_t a, uint32_t v) } -void dumpregs(); uint16_t oldcs; int oldcpl; @@ -436,12 +439,6 @@ static inline void seteaw(uint16_t val) } } -#define getr8(r) ((r & 4) ? cpu_state.regs[r & 3].b.h : cpu_state.regs[r & 3].b.l) - -#define setr8(r,v) if (r & 4) cpu_state.regs[r & 3].b.h = v; \ - else cpu_state.regs[r & 3].b.l = v; - - /*Flags*/ uint8_t znptable8[256]; uint16_t znptable16[65536]; @@ -500,7 +497,7 @@ int indump = 0; void dumpregs() { - int c,d=0,e=0,ff; + int c,d=0,e=0; #ifndef RELEASE_BUILD FILE *f; if (indump) return; @@ -647,7 +644,6 @@ void resetx86() makeznptable(); resetreadlookup(); makemod1table(); - resetmcr(); FETCHCLEAR(); x87_reset(); cpu_set_edx(); @@ -2782,8 +2778,8 @@ void execx86(int cycs) c--; cycles-=4; } - if (temp) flags|=C_FLAG; - else flags&=~C_FLAG; + if (templ) flags|=C_FLAG; + else flags&=~C_FLAG; seteaw(tempw); if ((flags&C_FLAG)^(tempw>>15)) flags|=V_FLAG; else flags&=~V_FLAG; diff --git a/src/Makefile.mingw b/src/Makefile.mingw index bed9086..039ca1a 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -2,7 +2,7 @@ VPATH = . dosbox resid-fp CPP = g++.exe CC = gcc.exe WINDRES = windres.exe -CFLAGS = -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign +CFLAGS = -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign -Wall -Werror -fno-strict-aliasing OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o ali1429.o amstrad.o cdrom-ioctl.o cdrom-iso.o \ codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86.o compaq.o config.o cpu.o dac.o \ device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o headland.o i430lx.o i430fx.o \ diff --git a/src/Makefile.mingw64 b/src/Makefile.mingw64 index c0eb41d..4b4984c 100644 --- a/src/Makefile.mingw64 +++ b/src/Makefile.mingw64 @@ -2,7 +2,7 @@ VPATH = . dosbox resid-fp CPP = g++.exe CC = gcc.exe WINDRES = windres.exe -CFLAGS = -O3 -fomit-frame-pointer -msse2 +CFLAGS = -O3 -fomit-frame-pointer -msse2 -Wall -Werror -fno-strict-aliasing OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o ali1429.o amstrad.o cdrom-ioctl.o cdrom-iso.o \ codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86-64.o compaq.o config.o cpu.o dac.o \ device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o headland.o i430lx.o i430fx.o \ diff --git a/src/ali1429.c b/src/ali1429.c index 8c22573..388ab48 100644 --- a/src/ali1429.c +++ b/src/ali1429.c @@ -42,9 +42,7 @@ static void ali1429_recalc() } void ali1429_write(uint16_t port, uint8_t val, void *priv) -{ - int c; - +{ if (!(port & 1)) ali1429_index = val; else diff --git a/src/ali1429.h b/src/ali1429.h index ad950d6..101b336 100644 --- a/src/ali1429.h +++ b/src/ali1429.h @@ -1 +1,2 @@ void ali1429_init(); +void ali1429_reset(); diff --git a/src/amstrad.c b/src/amstrad.c index 0c208ab..4c5cdf9 100644 --- a/src/amstrad.c +++ b/src/amstrad.c @@ -1,4 +1,6 @@ +#include #include "ibm.h" +#include "dac.h" #include "io.h" #include "keyboard.h" #include "lpt.h" diff --git a/src/cdrom-ioctl.c b/src/cdrom-ioctl.c index 2558849..2d4f176 100644 --- a/src/cdrom-ioctl.c +++ b/src/cdrom-ioctl.c @@ -29,7 +29,6 @@ static ATAPI ioctl_atapi; static uint32_t last_block = 0; static uint32_t cdrom_capacity = 0; -static int ioctl_inited = 0; static char ioctl_path[8]; void ioctl_close(void); static HANDLE hIOCTL; @@ -235,7 +234,7 @@ static int ioctl_ready(void) // pclog("Ready? %i\n",cdrom_drive); if (!cdrom_drive) return 0; ioctl_open(0); - temp=DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,<oc,sizeof(ltoc),&size,NULL); + temp=DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,<oc,sizeof(ltoc),(LPDWORD)&size,NULL); ioctl_close(); if (!temp) return 0; @@ -275,7 +274,7 @@ static int ioctl_get_last_block(unsigned char starttrack, int msf, int maxlen, i ioctl_cd_state = CD_STOPPED; ioctl_open(0); - DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,&lbtoc,sizeof(lbtoc),&size,NULL); + DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,&lbtoc,sizeof(lbtoc),(LPDWORD)&size,NULL); ioctl_close(); tocvalid = 1; for (c = 0; c <= lbtoc.LastTrack; c++) @@ -295,7 +294,7 @@ static int ioctl_medium_changed(void) CDROM_TOC ltoc; if (!cdrom_drive) return 0; /* This will be handled by the not ready handler instead. */ ioctl_open(0); - temp=DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,<oc,sizeof(ltoc),&size,NULL); + temp=DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,<oc,sizeof(ltoc),(LPDWORD)&size,NULL); ioctl_close(); if (!temp) return 0; /* Drive empty, a not ready handler matter, not disc change. */ @@ -331,7 +330,7 @@ static uint8_t ioctl_getcurrentsubchannel(uint8_t *b, int msf) insub.Format = IOCTL_CDROM_CURRENT_POSITION; ioctl_open(0); - DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_Q_CHANNEL,&insub,sizeof(insub),&sub,sizeof(sub),&size,NULL); + DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_Q_CHANNEL,&insub,sizeof(insub),&sub,sizeof(sub),(LPDWORD)&size,NULL); ioctl_close(); if (ioctl_cd_state == CD_PLAYING || ioctl_cd_state == CD_PAUSED) @@ -413,7 +412,7 @@ static void ioctl_eject(void) if (!cdrom_drive) return; ioctl_cd_state = CD_STOPPED; ioctl_open(0); - DeviceIoControl(hIOCTL,IOCTL_STORAGE_EJECT_MEDIA,NULL,0,NULL,0,&size,NULL); + DeviceIoControl(hIOCTL,IOCTL_STORAGE_EJECT_MEDIA,NULL,0,NULL,0,(LPDWORD)&size,NULL); ioctl_close(); } @@ -423,7 +422,7 @@ static void ioctl_load(void) if (!cdrom_drive) return; ioctl_cd_state = CD_STOPPED; ioctl_open(0); - DeviceIoControl(hIOCTL,IOCTL_STORAGE_LOAD_MEDIA,NULL,0,NULL,0,&size,NULL); + DeviceIoControl(hIOCTL,IOCTL_STORAGE_LOAD_MEDIA,NULL,0,NULL,0,(LPDWORD)&size,NULL); ioctl_close(); cdrom_capacity = ioctl_get_last_block(0, 0, 4096, 0); } @@ -441,7 +440,6 @@ static int ioctl_readsector(uint8_t *b, int sector) LARGE_INTEGER pos; BOOL status; long size; - int c; if (!cdrom_drive) return -1; @@ -453,7 +451,7 @@ static int ioctl_readsector(uint8_t *b, int sector) pos.QuadPart=sector*2048; ioctl_open(0); SetFilePointer(hIOCTL,pos.LowPart,&pos.HighPart,FILE_BEGIN); - status = ReadFile(hIOCTL,b,2048,&size,NULL); + status = ReadFile(hIOCTL,b,2048,(LPDWORD)&size,NULL); ioctl_close(); /*If the read failed, try again using SPTI*/ @@ -497,14 +495,6 @@ static int ioctl_readsector(uint8_t *b, int sector) return !status; } -static void lba_to_msf(uint8_t *buf, int lba) -{ - lba += 150; - buf[0] = (lba / 75) / 60; - buf[1] = (lba / 75) % 60; - buf[2] = lba % 75; -} - static int is_track_audio(uint32_t pos) { int c; @@ -539,17 +529,15 @@ static int ioctl_is_track_audio(uint32_t pos, int ismsf) static void ioctl_readsector_raw(uint8_t *b, int sector) { - LARGE_INTEGER pos; long size; - uint32_t temp; + if (!cdrom_drive) return; if (ioctl_cd_state == CD_PLAYING) return; ioctl_cd_state = CD_STOPPED; - pos.QuadPart=sector*2048; ioctl_open(0); - DeviceIoControl(hIOCTL, IOCTL_CDROM_RAW_READ, NULL, 0, b, 1, &size, NULL); + DeviceIoControl(hIOCTL, IOCTL_CDROM_RAW_READ, NULL, 0, b, 1, (LPDWORD)&size, NULL); ioctl_close(); } @@ -562,7 +550,7 @@ static int ioctl_readtoc(unsigned char *b, unsigned char starttrack, int msf, in if (!cdrom_drive) return 0; ioctl_cd_state = CD_STOPPED; ioctl_open(0); - DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,&toc,sizeof(toc),&size,NULL); + DeviceIoControl(hIOCTL,IOCTL_CDROM_READ_TOC, NULL,0,&toc,sizeof(toc),(LPDWORD)&size,NULL); ioctl_close(); tocvalid=1; // pclog("Read TOC done! %i\n",single); @@ -628,7 +616,7 @@ static int ioctl_readtoc_session(unsigned char *b, int msf, int maxlen) uint32_t temp; CDROM_READ_TOC_EX toc_ex; CDROM_TOC_SESSION_DATA toc; - if (!cdrom_drive) return; + if (!cdrom_drive) return 0; ioctl_cd_state = CD_STOPPED; memset(&toc_ex,0,sizeof(toc_ex)); memset(&toc,0,sizeof(toc)); @@ -668,9 +656,7 @@ static int ioctl_readtoc_raw(unsigned char *b, int maxlen) { int len=4; int size; - uint32_t temp; int i; - int BytesRead = 0; CDROM_READ_TOC_EX toc_ex; CDROM_TOC_FULL_TOC_DATA toc; if (!cdrom_drive) return 0; @@ -715,7 +701,7 @@ static uint32_t ioctl_size() static int ioctl_status() { - if (!(ioctl_ready) && (cdrom_drive <= 0)) + if (!(ioctl_ready()) && (cdrom_drive <= 0)) return CD_STATUS_EMPTY; switch(ioctl_cd_state) @@ -727,12 +713,12 @@ static int ioctl_status() case CD_STOPPED: return CD_STATUS_STOPPED; } + return CD_STATUS_STOPPED; } void ioctl_reset() { CDROM_TOC ltoc; - int temp; long size; if (!cdrom_drive) @@ -742,7 +728,7 @@ void ioctl_reset() } ioctl_open(0); - temp = DeviceIoControl(hIOCTL, IOCTL_CDROM_READ_TOC, NULL, 0, <oc, sizeof(ltoc), &size, NULL); + DeviceIoControl(hIOCTL, IOCTL_CDROM_READ_TOC, NULL, 0, <oc, sizeof(ltoc), (LPDWORD)&size, NULL); ioctl_close(); toc = ltoc; diff --git a/src/cdrom-ioctl.h b/src/cdrom-ioctl.h index aa1c0d5..4d4a8f4 100644 --- a/src/cdrom-ioctl.h +++ b/src/cdrom-ioctl.h @@ -8,5 +8,7 @@ extern int ioctl_open(char d); extern void ioctl_reset(); extern void ioctl_close(); void ioctl_set_drive(char d); +void ioctl_audio_callback(int16_t *output, int len); +void ioctl_audio_stop(); #endif /* ! CDROM_IOCTL_H */ diff --git a/src/cdrom-iso.c b/src/cdrom-iso.c index 98f3bb7..220b073 100644 --- a/src/cdrom-iso.c +++ b/src/cdrom-iso.c @@ -15,8 +15,6 @@ void iso_close(void); static FILE *iso_image = NULL; static int iso_changed = 0; -static uint32_t iso_cd_pos = 0, iso_cd_end = 0; - void iso_audio_callback(int16_t *output, int len) { memset(output, 0, len * 2); @@ -28,12 +26,6 @@ void iso_audio_stop() pclog("iso_audio_stop stub\n"); } -static int get_track_nr(uint32_t pos) -{ - pclog("get_track_nr stub\n"); - return 0; -} - static void iso_playaudio(uint32_t pos, uint32_t len, int ismsf) { pclog("iso_playaudio stub\n"); @@ -118,7 +110,6 @@ static void lba_to_msf(uint8_t *buf, int lba) static void iso_readsector_raw(uint8_t *b, int sector) { - uint32_t temp; if (!cdrom_drive) return; fseek(iso_image, sector*2048, SEEK_SET); fread(b+16, 2048, 1, iso_image); diff --git a/src/cdrom-null.c b/src/cdrom-null.c index af8d7a5..5ba7320 100644 --- a/src/cdrom-null.c +++ b/src/cdrom-null.c @@ -59,8 +59,9 @@ static void null_load(void) { } -static void null_readsector(uint8_t *b, int sector) +static int null_readsector(uint8_t *b, int sector) { + return 0; } static void null_readsector_raw(uint8_t *b, int sector) diff --git a/src/codegen.h b/src/codegen.h index 7c336b5..e715915 100644 --- a/src/codegen.h +++ b/src/codegen.h @@ -249,6 +249,7 @@ void codegen_block_init(uint32_t phys_addr); void codegen_block_remove(); void codegen_block_start_recompile(codeblock_t *block); void codegen_block_end_recompile(codeblock_t *block); +void codegen_block_end(); void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_pc, uint32_t old_pc); void codegen_generate_seg_restore(); void codegen_set_op32(); @@ -308,7 +309,7 @@ static inline void addbyte(uint8_t val) static inline void addword(uint16_t val) { - *(uint16_t *)&codeblock[block_current].data[block_pos] = val; + *(uint16_t *)(void *)&codeblock[block_current].data[block_pos] = val; block_pos += 2; if (block_pos >= BLOCK_MAX) { diff --git a/src/codegen_ops_arith.h b/src/codegen_ops_arith.h index 50fba1f..57c5e8e 100644 --- a/src/codegen_ops_arith.h +++ b/src/codegen_ops_arith.h @@ -2,15 +2,15 @@ static uint32_t ropINC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin { int host_reg; - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); host_reg = LOAD_REG_W(opcode & 7); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_W(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); codegen_flags_changed = 1; @@ -21,15 +21,15 @@ static uint32_t ropINC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin { int host_reg; - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); host_reg = LOAD_REG_L(opcode & 7); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); codegen_flags_changed = 1; @@ -40,15 +40,15 @@ static uint32_t ropDEC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin { int host_reg; - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); host_reg = LOAD_REG_W(opcode & 7); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_W(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); codegen_flags_changed = 1; @@ -59,15 +59,15 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin { int host_reg; - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); host_reg = LOAD_REG_L(opcode & 7); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); codegen_flags_changed = 1; @@ -93,12 +93,12 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_CHECK_WRITE(target_seg); \ dst_reg = MEM_LOAD_ADDR_EA_B_NO_ABRT(target_seg); \ } \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \ src_reg = LOAD_REG_B((fetchdat >> 3) & 7); \ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg); \ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg); \ + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg); \ + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg); \ op ## _HOST_REG_B(dst_reg, src_reg); \ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg); \ + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg); \ if (writeback) \ { \ if ((fetchdat & 0xc0) == 0xc0) \ @@ -133,12 +133,12 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_CHECK_WRITE_W(target_seg); \ dst_reg = MEM_LOAD_ADDR_EA_W_NO_ABRT(target_seg); \ } \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \ src_reg = LOAD_REG_W((fetchdat >> 3) & 7); \ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg); \ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg); \ + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg); \ + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg); \ op ## _HOST_REG_W(dst_reg, src_reg); \ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg); \ + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg); \ if (writeback) \ { \ if ((fetchdat & 0xc0) == 0xc0) \ @@ -173,12 +173,12 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_CHECK_WRITE_L(target_seg); \ dst_reg = MEM_LOAD_ADDR_EA_L_NO_ABRT(target_seg); \ } \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \ src_reg = LOAD_REG_L((fetchdat >> 3) & 7); \ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg); \ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg); \ + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg); \ + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg); \ op ## _HOST_REG_L(dst_reg, src_reg); \ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg); \ + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg); \ if (writeback) \ { \ if ((fetchdat & 0xc0) == 0xc0) \ @@ -215,11 +215,11 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin } \ \ dst_reg = LOAD_REG_B((fetchdat >> 3) & 7); \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg); \ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \ + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg); \ + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg); \ op ## _HOST_REG_B(dst_reg, src_reg); \ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg); \ + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg); \ if (writeback) STORE_REG_B_RELEASE(dst_reg); \ else RELEASE_REG(dst_reg); \ RELEASE_REG(src_reg); \ @@ -244,11 +244,11 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin } \ \ dst_reg = LOAD_REG_W((fetchdat >> 3) & 7); \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg); \ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \ + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg); \ + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg); \ op ## _HOST_REG_W(dst_reg, src_reg); \ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg); \ + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg); \ if (writeback) STORE_REG_W_RELEASE(dst_reg); \ else RELEASE_REG(dst_reg); \ RELEASE_REG(src_reg); \ @@ -273,11 +273,11 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin } \ \ dst_reg = LOAD_REG_L((fetchdat >> 3) & 7); \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg); \ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \ + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg); \ + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg); \ op ## _HOST_REG_L(dst_reg, src_reg); \ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg); \ + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg); \ if (writeback) STORE_REG_L_RELEASE(dst_reg); \ else RELEASE_REG(dst_reg); \ RELEASE_REG(src_reg); \ @@ -308,11 +308,11 @@ static uint32_t ropCMP_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u } dst_reg = LOAD_REG_B((fetchdat >> 3) & 7); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg); dst_reg = CMP_HOST_REG_B(dst_reg, src_reg); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg); RELEASE_REG(dst_reg); RELEASE_REG(src_reg); @@ -336,11 +336,11 @@ static uint32_t ropCMP_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u } dst_reg = LOAD_REG_W((fetchdat >> 3) & 7); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg); dst_reg = CMP_HOST_REG_W(dst_reg, src_reg); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg); RELEASE_REG(dst_reg); RELEASE_REG(src_reg); @@ -364,11 +364,11 @@ static uint32_t ropCMP_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u } dst_reg = LOAD_REG_L((fetchdat >> 3) & 7); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg); dst_reg = CMP_HOST_REG_L(dst_reg, src_reg); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg); RELEASE_REG(dst_reg); RELEASE_REG(src_reg); @@ -392,12 +392,12 @@ static uint32_t ropCMP_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, dst_reg = 0; } - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); src_reg = LOAD_REG_B((fetchdat >> 3) & 7); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg); dst_reg = CMP_HOST_REG_B(dst_reg, src_reg); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg); RELEASE_REG(dst_reg); RELEASE_REG(src_reg); @@ -420,12 +420,12 @@ static uint32_t ropCMP_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, dst_reg = 0; } \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); src_reg = LOAD_REG_W((fetchdat >> 3) & 7); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg); dst_reg = CMP_HOST_REG_W(dst_reg, src_reg); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg); RELEASE_REG(dst_reg); RELEASE_REG(src_reg); @@ -448,12 +448,12 @@ static uint32_t ropCMP_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, dst_reg = 0; } - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); src_reg = LOAD_REG_L((fetchdat >> 3) & 7); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg); dst_reg = CMP_HOST_REG_L(dst_reg, src_reg); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg); RELEASE_REG(dst_reg); RELEASE_REG(src_reg); @@ -466,11 +466,11 @@ static uint32_t ropADD_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, { int host_reg = LOAD_REG_B(REG_AL); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_B(host_reg, fetchdat & 0xff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD8); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD8); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_B_RELEASE(host_reg); codegen_flags_changed = 1; @@ -480,11 +480,11 @@ static uint32_t ropADD_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, { int host_reg = LOAD_REG_W(REG_AX); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xffff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); codegen_flags_changed = 1; @@ -494,12 +494,12 @@ static uint32_t ropADD_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 { int host_reg = LOAD_REG_L(REG_EAX); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); fetchdat = fastreadl(cs + op_pc); ADD_HOST_REG_IMM(host_reg, fetchdat); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); codegen_flags_changed = 1; @@ -510,11 +510,11 @@ static uint32_t ropCMP_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, { int host_reg = LOAD_REG_B(REG_AL); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_B(host_reg, fetchdat & 0xff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); codegen_flags_changed = 1; @@ -524,11 +524,11 @@ static uint32_t ropCMP_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, { int host_reg = LOAD_REG_W(REG_AX); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xffff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); codegen_flags_changed = 1; @@ -538,12 +538,12 @@ static uint32_t ropCMP_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 { int host_reg = LOAD_REG_L(REG_EAX); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); fetchdat = fastreadl(cs + op_pc); host_reg = CMP_HOST_REG_IMM_L(host_reg, fetchdat); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); codegen_flags_changed = 1; @@ -554,11 +554,11 @@ static uint32_t ropSUB_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, { int host_reg = LOAD_REG_B(REG_AL); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_B(host_reg, fetchdat & 0xff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_B_RELEASE(host_reg); codegen_flags_changed = 1; @@ -568,11 +568,11 @@ static uint32_t ropSUB_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, { int host_reg = LOAD_REG_W(REG_AX); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xffff); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); codegen_flags_changed = 1; @@ -582,12 +582,12 @@ static uint32_t ropSUB_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 { int host_reg = LOAD_REG_L(REG_EAX); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); fetchdat = fastreadl(cs + op_pc); SUB_HOST_REG_IMM(host_reg, fetchdat); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); codegen_flags_changed = 1; @@ -598,7 +598,7 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ { int host_reg; uint32_t imm; - x86seg *target_seg; + x86seg *target_seg = NULL; if ((fetchdat & 0x30) == 0x10) return 0; @@ -629,38 +629,38 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ switch (fetchdat & 0x38) { case 0x00: /*ADD*/ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_B(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD8); break; case 0x08: /*OR*/ OR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); break; case 0x20: /*AND*/ AND_HOST_REG_IMM(host_reg, imm | 0xffffff00); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); break; case 0x28: /*SUB*/ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_B(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); break; case 0x30: /*XOR*/ XOR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); break; case 0x38: /*CMP*/ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_B(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); break; } - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -684,7 +684,7 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { int host_reg; uint32_t imm; - x86seg *target_seg; + x86seg *target_seg = NULL; if ((fetchdat & 0x30) == 0x10) return 0; @@ -715,38 +715,38 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 switch (fetchdat & 0x38) { case 0x00: /*ADD*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_W(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16); break; case 0x08: /*OR*/ OR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); break; case 0x20: /*AND*/ AND_HOST_REG_IMM(host_reg, imm | 0xffff0000); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); break; case 0x28: /*SUB*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_W(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); break; case 0x30: /*XOR*/ XOR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); break; case 0x38: /*CMP*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_W(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); break; } - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -769,7 +769,7 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { int host_reg; uint32_t imm; - x86seg *target_seg; + x86seg *target_seg = NULL; if ((fetchdat & 0x30) == 0x10) return 0; @@ -799,38 +799,38 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 switch (fetchdat & 0x38) { case 0x00: /*ADD*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32); break; case 0x08: /*OR*/ OR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); break; case 0x20: /*AND*/ AND_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); break; case 0x28: /*SUB*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); break; case 0x30: /*XOR*/ XOR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); break; case 0x38: /*CMP*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_L(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); break; } - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -854,7 +854,7 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { int host_reg; uint32_t imm; - x86seg *target_seg; + x86seg *target_seg = NULL; if ((fetchdat & 0x30) == 0x10) return 0; @@ -888,38 +888,38 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 switch (fetchdat & 0x38) { case 0x00: /*ADD*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_W(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16); break; case 0x08: /*OR*/ OR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); break; case 0x20: /*AND*/ AND_HOST_REG_IMM(host_reg, imm | 0xffff0000); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); break; case 0x28: /*SUB*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_W(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); break; case 0x30: /*XOR*/ XOR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); break; case 0x38: /*CMP*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_W(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); break; } - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -942,7 +942,7 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { int host_reg; uint32_t imm; - x86seg *target_seg; + x86seg *target_seg = NULL; if ((fetchdat & 0x30) == 0x10) return 0; @@ -976,38 +976,38 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 switch (fetchdat & 0x38) { case 0x00: /*ADD*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32); break; case 0x08: /*OR*/ OR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); break; case 0x20: /*AND*/ AND_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); break; case 0x28: /*SUB*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); break; case 0x30: /*XOR*/ XOR_HOST_REG_IMM(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); break; case 0x38: /*CMP*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_L(host_reg, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); break; } - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) diff --git a/src/codegen_ops_fpu.h b/src/codegen_ops_fpu.h index 70da3dd..de7cf4c 100644 --- a/src/codegen_ops_fpu.h +++ b/src/codegen_ops_fpu.h @@ -491,7 +491,7 @@ static uint32_t ropFSTSW_AX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u int host_reg; FP_ENTER(); - host_reg = LOAD_VAR_W(&cpu_state.npxs); + host_reg = LOAD_VAR_W((uintptr_t)&cpu_state.npxs); STORE_REG_TARGET_W_RELEASE(host_reg, REG_AX); return op_pc; diff --git a/src/codegen_ops_jump.h b/src/codegen_ops_jump.h index 63fdbb0..d2271cf 100644 --- a/src/codegen_ops_jump.h +++ b/src/codegen_ops_jump.h @@ -75,16 +75,16 @@ static uint32_t ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 return op_pc+1; } -static int BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static void BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { - CALL_FUNC(CF_SET); + CALL_FUNC((uintptr_t)CF_SET); if (not) TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); else TEST_NONZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); } -static int BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { int host_reg; @@ -122,7 +122,7 @@ static int BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not break; case FLAGS_UNKNOWN: - CALL_FUNC(ZF_SET); + CALL_FUNC((uintptr_t)ZF_SET); if (not) TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); else @@ -131,25 +131,25 @@ static int BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not } } -static int BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static void BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { - CALL_FUNC(VF_SET); + CALL_FUNC((uintptr_t)VF_SET); if (not) TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); else TEST_NONZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); } -static int BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static void BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { - CALL_FUNC(PF_SET); + CALL_FUNC((uintptr_t)PF_SET); if (not) TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); else TEST_NONZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); } -static int BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { int host_reg; @@ -204,7 +204,7 @@ static int BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not break; case FLAGS_UNKNOWN: - CALL_FUNC(NF_SET); + CALL_FUNC((uintptr_t)NF_SET); if (not) TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt); else diff --git a/src/codegen_ops_misc.h b/src/codegen_ops_misc.h index 242a8c8..1ccbcff 100644 --- a/src/codegen_ops_misc.h +++ b/src/codegen_ops_misc.h @@ -27,13 +27,13 @@ static uint32_t ropSTI(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32 static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int host_reg; if ((fetchdat & 0x30) != 0x00) return 0; - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); if ((fetchdat & 0xc0) == 0xc0) host_reg = LOAD_REG_B(fetchdat & 7); @@ -50,18 +50,18 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ switch (fetchdat & 0x38) { case 0x00: /*INC*/ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_B(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC8); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC8); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); break; case 0x08: /*DEC*/ - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_B(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC8); - STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC8); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); break; } @@ -79,14 +79,14 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ static uint32_t codegen_temp; static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int host_reg; if ((fetchdat & 0x30) != 0x00 && (fetchdat & 0x08)) return 0; if ((fetchdat & 0x30) == 0x00) - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); if ((fetchdat & 0xc0) == 0xc0) host_reg = LOAD_REG_W(fetchdat & 7); @@ -111,11 +111,11 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint switch (fetchdat & 0x38) { case 0x00: /*INC*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM_W(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0xc0) == 0xc0) STORE_REG_W_RELEASE(host_reg); else @@ -126,11 +126,11 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint codegen_flags_changed = 1; return op_pc + 1; case 0x08: /*DEC*/ - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM_W(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC16); - STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC16); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0xc0) == 0xc0) STORE_REG_W_RELEASE(host_reg); else @@ -168,17 +168,18 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint SP_MODIFY(-2); return op_pc + 1; } + return 0; } static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int host_reg; if ((fetchdat & 0x30) != 0x00 && (fetchdat & 0x08)) return 0; if ((fetchdat & 0x30) == 0x00) - CALL_FUNC(flags_rebuild_c); + CALL_FUNC((uintptr_t)flags_rebuild_c); if ((fetchdat & 0xc0) == 0xc0) host_reg = LOAD_REG_L(fetchdat & 7); @@ -203,11 +204,11 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint switch (fetchdat & 0x38) { case 0x00: /*INC*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); ADD_HOST_REG_IMM(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0xc0) == 0xc0) STORE_REG_L_RELEASE(host_reg); else @@ -218,11 +219,11 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint codegen_flags_changed = 1; return op_pc + 1; case 0x08: /*DEC*/ - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); SUB_HOST_REG_IMM(host_reg, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1); - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC32); - STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1); + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC32); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0xc0) == 0xc0) STORE_REG_L_RELEASE(host_reg); else @@ -260,4 +261,5 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint SP_MODIFY(-4); return op_pc + 1; } + return 0; } diff --git a/src/codegen_ops_mov.h b/src/codegen_ops_mov.h index 9934f87..61fcd0f 100644 --- a/src/codegen_ops_mov.h +++ b/src/codegen_ops_mov.h @@ -512,22 +512,22 @@ static uint32_t ropMOV_w_seg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, switch (fetchdat & 0x38) { case 0x00: /*ES*/ - host_reg = LOAD_VAR_WL(&ES); + host_reg = LOAD_VAR_WL((uintptr_t)&ES); break; case 0x08: /*CS*/ - host_reg = LOAD_VAR_WL(&CS); + host_reg = LOAD_VAR_WL((uintptr_t)&CS); break; case 0x18: /*DS*/ - host_reg = LOAD_VAR_WL(&DS); + host_reg = LOAD_VAR_WL((uintptr_t)&DS); break; case 0x10: /*SS*/ - host_reg = LOAD_VAR_WL(&SS); + host_reg = LOAD_VAR_WL((uintptr_t)&SS); break; case 0x20: /*FS*/ - host_reg = LOAD_VAR_WL(&FS); + host_reg = LOAD_VAR_WL((uintptr_t)&FS); break; case 0x28: /*GS*/ - host_reg = LOAD_VAR_WL(&GS); + host_reg = LOAD_VAR_WL((uintptr_t)&GS); break; default: return 0; diff --git a/src/codegen_ops_shift.h b/src/codegen_ops_shift.h index b786ab9..75d024f 100644 --- a/src/codegen_ops_shift.h +++ b/src/codegen_ops_shift.h @@ -13,29 +13,29 @@ reg = MEM_LOAD_ADDR_EA_ ## size ## _NO_ABRT(target_seg); \ if (immediate) count = fastreadb(cs + op_pc + 1) & 0x1f; \ } \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, count); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, count); \ \ - res_store((uint32_t)&cpu_state.flags_op1, reg); \ + res_store((uintptr_t)&cpu_state.flags_op1, reg); \ \ switch (fetchdat & 0x38) \ { \ case 0x20: case 0x30: /*SHL*/ \ SHL_ ## size ## _IMM(reg, count); \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SHL ## size2); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SHL ## size2); \ break; \ \ case 0x28: /*SHR*/ \ SHR_ ## size ## _IMM(reg, count); \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SHR ## size2); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SHR ## size2); \ break; \ \ case 0x38: /*SAR*/ \ SAR_ ## size ## _IMM(reg, count); \ - STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SAR ## size2); \ + STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SAR ## size2); \ break; \ } \ \ - res_store((uint32_t)&cpu_state.flags_res, reg); \ + res_store((uintptr_t)&cpu_state.flags_res, reg); \ if ((fetchdat & 0xc0) == 0xc0) \ STORE_REG_ ## size ## _RELEASE(reg); \ else \ @@ -46,7 +46,7 @@ static uint32_t ropC0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int count; int reg; @@ -59,7 +59,7 @@ static uint32_t ropC0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ } static uint32_t ropC1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int count; int reg; @@ -72,7 +72,7 @@ static uint32_t ropC1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } static uint32_t ropC1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int count; int reg; @@ -86,7 +86,7 @@ static uint32_t ropC1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 static uint32_t ropD0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int count = 1; int reg; @@ -99,7 +99,7 @@ static uint32_t ropD0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ } static uint32_t ropD1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int count = 1; int reg; @@ -112,7 +112,7 @@ static uint32_t ropD1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } static uint32_t ropD1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - x86seg *target_seg; + x86seg *target_seg = NULL; int count = 1; int reg; diff --git a/src/codegen_ops_stack.h b/src/codegen_ops_stack.h index d25e133..3ea27d3 100644 --- a/src/codegen_ops_stack.h +++ b/src/codegen_ops_stack.h @@ -85,8 +85,6 @@ static uint32_t ropPUSH_imm_b32(uint8_t opcode, uint32_t fetchdat, uint32_t op_3 static uint32_t ropPOP_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int host_reg; - STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); LOAD_STACK_TO_EA(0); MEM_LOAD_ADDR_EA_W(&_ss); @@ -97,8 +95,6 @@ static uint32_t ropPOP_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin } static uint32_t ropPOP_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int host_reg; - STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); LOAD_STACK_TO_EA(0); MEM_LOAD_ADDR_EA_L(&_ss); @@ -110,8 +106,6 @@ static uint32_t ropPOP_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin static uint32_t ropRET_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int host_reg; - STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); LOAD_STACK_TO_EA(0); MEM_LOAD_ADDR_EA_W(&_ss); @@ -122,8 +116,6 @@ static uint32_t ropRET_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin } static uint32_t ropRET_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int host_reg; - STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); LOAD_STACK_TO_EA(0); MEM_LOAD_ADDR_EA_L(&_ss); @@ -136,7 +128,6 @@ static uint32_t ropRET_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin static uint32_t ropRET_imm_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { uint16_t offset = fetchdat & 0xffff; - int host_reg; STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); LOAD_STACK_TO_EA(0); @@ -149,7 +140,6 @@ static uint32_t ropRET_imm_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, static uint32_t ropRET_imm_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { uint16_t offset = fetchdat & 0xffff; - int host_reg; STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); LOAD_STACK_TO_EA(0); @@ -254,8 +244,6 @@ ROP_PUSH_SEG(SS) #define ROP_POP_SEG(seg, rseg) \ static uint32_t ropPOP_ ## seg ## _16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ { \ - int host_reg; \ - \ STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); \ LOAD_STACK_TO_EA(0); \ MEM_LOAD_ADDR_EA_W(&_ss); \ @@ -266,8 +254,6 @@ static uint32_t ropPOP_ ## seg ## _16(uint8_t opcode, uint32_t fetchdat, uint32_ } \ static uint32_t ropPOP_ ## seg ## _32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ { \ - int host_reg; \ - \ STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); \ LOAD_STACK_TO_EA(0); \ MEM_LOAD_ADDR_EA_W(&_ss); \ diff --git a/src/codegen_ops_x86-64.h b/src/codegen_ops_x86-64.h index a1f993a..76f142c 100644 --- a/src/codegen_ops_x86-64.h +++ b/src/codegen_ops_x86-64.h @@ -1,6 +1,7 @@ /*Register allocation : R8-R15 - emulated registers */ +#include #define HOST_REG_XMM_START 0 #define HOST_REG_XMM_END 7 @@ -20,7 +21,7 @@ static inline int find_host_xmm_reg() fatal("Out of host XMM regs!\n"); return c; } -static void call(codeblock_t *block, uintptr_t func) +static inline void call(codeblock_t *block, uintptr_t func) { uintptr_t diff = func - (uintptr_t)&block->data[block_pos + 5]; @@ -42,7 +43,7 @@ static void call(codeblock_t *block, uintptr_t func) } } -static void call_long(uintptr_t func) +static inline void call_long(uintptr_t func) { codegen_reg_loaded[0] = codegen_reg_loaded[1] = codegen_reg_loaded[2] = codegen_reg_loaded[3] = 0; codegen_reg_loaded[4] = codegen_reg_loaded[5] = codegen_reg_loaded[6] = codegen_reg_loaded[7] = 0; @@ -54,7 +55,7 @@ static void call_long(uintptr_t func) addbyte(0xd0); } -static void load_param_1_32(codeblock_t *block, uint32_t param) +static inline void load_param_1_32(codeblock_t *block, uint32_t param) { #if WIN64 addbyte(0xb9); /*MOVL $fetchdat,%ecx*/ @@ -63,7 +64,7 @@ static void load_param_1_32(codeblock_t *block, uint32_t param) #endif addlong(param); } -static void load_param_1_reg_32(int reg) +static inline void load_param_1_reg_32(int reg) { #if WIN64 if (reg & 8) @@ -77,7 +78,8 @@ static void load_param_1_reg_32(int reg) addbyte(0xc0 | REG_EDI | (reg << 3)); #endif } -static void load_param_1_64(codeblock_t *block, uint64_t param) +#if 0 +static inline void load_param_1_64(codeblock_t *block, uint64_t param) { addbyte(0x48); #if WIN64 @@ -87,8 +89,9 @@ static void load_param_1_64(codeblock_t *block, uint64_t param) #endif addquad(param); } +#endif -static void load_param_2_32(codeblock_t *block, uint32_t param) +static inline void load_param_2_32(codeblock_t *block, uint32_t param) { #if WIN64 addbyte(0xba); /*MOVL $fetchdat,%edx*/ @@ -97,7 +100,7 @@ static void load_param_2_32(codeblock_t *block, uint32_t param) #endif addlong(param); } -static void load_param_2_reg_32(int reg) +static inline void load_param_2_reg_32(int reg) { #if WIN64 if (reg & 8) @@ -111,7 +114,7 @@ static void load_param_2_reg_32(int reg) addbyte(0xc0 | REG_ESI | (reg << 3)); #endif } -static void load_param_2_64(codeblock_t *block, uint64_t param) +static inline void load_param_2_64(codeblock_t *block, uint64_t param) { addbyte(0x48); #if WIN64 @@ -122,7 +125,7 @@ static void load_param_2_64(codeblock_t *block, uint64_t param) addquad(param); } -static void load_param_3_reg_32(int reg) +static inline void load_param_3_reg_32(int reg) { if (reg & 8) { @@ -149,7 +152,7 @@ static void load_param_3_reg_32(int reg) #endif } } -static void load_param_3_reg_64(int reg) +static inline void load_param_3_reg_64(int reg) { if (reg & 8) { @@ -177,7 +180,7 @@ static void load_param_3_reg_64(int reg) } } -static void CALL_FUNC(uintptr_t func) +static inline void CALL_FUNC(uintptr_t func) { codegen_reg_loaded[0] = codegen_reg_loaded[1] = codegen_reg_loaded[2] = codegen_reg_loaded[3] = 0; codegen_reg_loaded[4] = codegen_reg_loaded[5] = codegen_reg_loaded[6] = codegen_reg_loaded[7] = 0; @@ -189,11 +192,11 @@ static void CALL_FUNC(uintptr_t func) addbyte(0xd0); } -static void RELEASE_REG(int host_reg) +static inline void RELEASE_REG(int host_reg) { } -static int LOAD_REG_B(int reg) +static inline int LOAD_REG_B(int reg) { int host_reg = reg & 3; // host_reg_mapping[host_reg] = reg; @@ -213,7 +216,7 @@ static int LOAD_REG_B(int reg) return host_reg | 8; } -static int LOAD_REG_W(int reg) +static inline int LOAD_REG_W(int reg) { int host_reg = reg; // host_reg_mapping[host_reg] = reg; @@ -230,7 +233,7 @@ static int LOAD_REG_W(int reg) return host_reg | 8; } -static int LOAD_REG_L(int reg) +static inline int LOAD_REG_L(int reg) { int host_reg = reg; // host_reg_mapping[host_reg] = reg; @@ -248,7 +251,7 @@ static int LOAD_REG_L(int reg) return host_reg | 8; } -static int LOAD_REG_IMM(uint32_t imm) +static inline int LOAD_REG_IMM(uint32_t imm) { int host_reg = REG_EBX; @@ -258,7 +261,7 @@ static int LOAD_REG_IMM(uint32_t imm) return host_reg; } -static void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) +static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) { int dest_reg = LOAD_REG_L(guest_reg & 3) & 7; @@ -359,7 +362,7 @@ static void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) } } } -static void STORE_REG_TARGET_W_RELEASE(int host_reg, int guest_reg) +static inline void STORE_REG_TARGET_W_RELEASE(int host_reg, int guest_reg) { int dest_reg = LOAD_REG_L(guest_reg & 7) & 7; @@ -387,7 +390,7 @@ static void STORE_REG_TARGET_W_RELEASE(int host_reg, int guest_reg) addbyte(cpu_state_offset(regs[guest_reg & 7].w)); } } -static void STORE_REG_TARGET_L_RELEASE(int host_reg, int guest_reg) +static inline void STORE_REG_TARGET_L_RELEASE(int host_reg, int guest_reg) { if (host_reg & 8) { @@ -410,7 +413,7 @@ static void STORE_REG_TARGET_L_RELEASE(int host_reg, int guest_reg) } } -static void STORE_REG_B_RELEASE(int host_reg) +static inline void STORE_REG_B_RELEASE(int host_reg) { if (host_reg & 0x10) { @@ -428,7 +431,7 @@ static void STORE_REG_B_RELEASE(int host_reg) addbyte(cpu_state_offset(regs[host_reg & 7].b)); } } -static void STORE_REG_W_RELEASE(int host_reg) +static inline void STORE_REG_W_RELEASE(int host_reg) { addbyte(0x66); /*MOVW [reg],host_reg*/ addbyte(0x44); @@ -436,7 +439,7 @@ static void STORE_REG_W_RELEASE(int host_reg) addbyte(0x45 | ((host_reg & 7) << 3)); addbyte(cpu_state_offset(regs[host_reg & 7].w)); } -static void STORE_REG_L_RELEASE(int host_reg) +static inline void STORE_REG_L_RELEASE(int host_reg) { addbyte(0x44); /*MOVL [reg],host_reg*/ addbyte(0x89); @@ -444,7 +447,7 @@ static void STORE_REG_L_RELEASE(int host_reg) addbyte(cpu_state_offset(regs[host_reg & 7].l)); } -static void STORE_IMM_REG_B(int reg, uint8_t val) +static inline void STORE_IMM_REG_B(int reg, uint8_t val) { if (reg & 4) { @@ -476,7 +479,7 @@ static void STORE_IMM_REG_B(int reg, uint8_t val) addbyte(cpu_state_offset(regs[reg & 7].b)); } } -static void STORE_IMM_REG_W(int reg, uint16_t val) +static inline void STORE_IMM_REG_W(int reg, uint16_t val) { addbyte(0x66); /*MOVW reg, imm*/ addbyte(0x41); @@ -488,7 +491,7 @@ static void STORE_IMM_REG_W(int reg, uint16_t val) addbyte(0x45 | (reg << 3)); addbyte(cpu_state_offset(regs[reg & 7].w)); } -static void STORE_IMM_REG_L(int reg, uint32_t val) +static inline void STORE_IMM_REG_L(int reg, uint32_t val) { addbyte(0x41); /*MOVL reg, imm*/ addbyte(0xb8 | reg); @@ -499,7 +502,7 @@ static void STORE_IMM_REG_L(int reg, uint32_t val) addbyte(cpu_state_offset(regs[reg & 7].l)); } -static void STORE_IMM_ADDR_L(uintptr_t addr, uint32_t val) +static inline void STORE_IMM_ADDR_L(uintptr_t addr, uint32_t val) { if (addr >= (uintptr_t)&cpu_state && addr < ((uintptr_t)&cpu_state)+0x100) { @@ -533,7 +536,7 @@ static void STORE_IMM_ADDR_L(uintptr_t addr, uint32_t val) static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) { int mod = (fetchdat >> 6) & 3; - int reg = (fetchdat >> 3) & 7; +// int reg = (fetchdat >> 3) & 7; int rm = fetchdat & 7; if (!mod && rm == 6) @@ -655,7 +658,7 @@ static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, int stack_offset) { int mod = (fetchdat >> 6) & 3; - int reg = (fetchdat >> 3) & 7; +// int reg = (fetchdat >> 3) & 7; int rm = fetchdat & 7; uint32_t new_eaaddr; @@ -847,7 +850,7 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u return op_ea_seg; } -static x86seg *FETCH_EA(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, uint32_t op_32) +static inline x86seg *FETCH_EA(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, uint32_t op_32) { if (op_32 & 0x200) return FETCH_EA_32(op_ea_seg, fetchdat, op_ssegs, op_pc, 0); @@ -856,7 +859,7 @@ static x86seg *FETCH_EA(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint -static void CHECK_SEG_READ(x86seg *seg) +static inline void CHECK_SEG_READ(x86seg *seg) { /*Segments always valid in real/V86 mode*/ if (!(cr0 & 1) || (eflags & VM_FLAG)) @@ -872,7 +875,7 @@ static void CHECK_SEG_READ(x86seg *seg) addbyte(0x83); /*CMP seg->base, -1*/ addbyte(0x3c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); addbyte(-1); } else @@ -890,7 +893,7 @@ static void CHECK_SEG_READ(x86seg *seg) seg->checked = 1; } -static void CHECK_SEG_WRITE(x86seg *seg) +static inline void CHECK_SEG_WRITE(x86seg *seg) { /*Segments always valid in real/V86 mode*/ if (!(cr0 & 1) || (eflags & VM_FLAG)) @@ -906,7 +909,7 @@ static void CHECK_SEG_WRITE(x86seg *seg) addbyte(0x83); /*CMP seg->base, -1*/ addbyte(0x3c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); addbyte(-1); } else @@ -924,12 +927,12 @@ static void CHECK_SEG_WRITE(x86seg *seg) seg->checked = 1; } -static void CHECK_SEG_LIMITS(x86seg *seg, int end_offset) +static inline void CHECK_SEG_LIMITS(x86seg *seg, int end_offset) { if (IS_32_ADDR(&seg->base)) { addbyte(0xb8 | REG_ESI); /*MOV ESI, &addr*/ - addlong((uint32_t)seg); + addlong((uint32_t)(uintptr_t)seg); } else { @@ -960,14 +963,14 @@ static void CHECK_SEG_LIMITS(x86seg *seg, int end_offset) } } -static void MEM_LOAD_ADDR_EA_B(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_B(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -993,7 +996,7 @@ static void MEM_LOAD_ADDR_EA_B(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -1018,24 +1021,24 @@ static void MEM_LOAD_ADDR_EA_B(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemb386l); + call_long((uintptr_t)readmemb386l); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); /*done:*/ } -static void MEM_LOAD_ADDR_EA_W(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_W(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1066,7 +1069,7 @@ static void MEM_LOAD_ADDR_EA_W(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -1095,31 +1098,31 @@ static void MEM_LOAD_ADDR_EA_W(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemwl); + call_long((uintptr_t)readmemwl); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); /*done:*/ } -static void MEM_LOAD_ADDR_EA_W_OFFSET(x86seg *seg, int offset) +static inline void MEM_LOAD_ADDR_EA_W_OFFSET(x86seg *seg, int offset) { addbyte(0x83); /*ADD EAX, offset*/ addbyte(0xc0); addbyte(offset); MEM_LOAD_ADDR_EA_W(seg); } -static void MEM_LOAD_ADDR_EA_L(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_L(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1150,7 +1153,7 @@ static void MEM_LOAD_ADDR_EA_L(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -1178,24 +1181,24 @@ static void MEM_LOAD_ADDR_EA_L(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemll); + call_long((uintptr_t)readmemll); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); /*done:*/ } -static void MEM_LOAD_ADDR_EA_Q(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_Q(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1226,7 +1229,7 @@ static void MEM_LOAD_ADDR_EA_Q(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -1255,10 +1258,10 @@ static void MEM_LOAD_ADDR_EA_Q(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemql); + call_long((uintptr_t)readmemql); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); @@ -1266,26 +1269,26 @@ static void MEM_LOAD_ADDR_EA_Q(x86seg *seg) /*done:*/ } -static void MEM_LOAD_ADDR_IMM_B(x86seg *seg, uint32_t addr) +static inline void MEM_LOAD_ADDR_IMM_B(x86seg *seg, uint32_t addr) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_LOAD_ADDR_EA_B(seg); } -static void MEM_LOAD_ADDR_IMM_W(x86seg *seg, uint32_t addr) +static inline void MEM_LOAD_ADDR_IMM_W(x86seg *seg, uint32_t addr) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_LOAD_ADDR_EA_W(seg); } -static void MEM_LOAD_ADDR_IMM_L(x86seg *seg, uint32_t addr) +static inline void MEM_LOAD_ADDR_IMM_L(x86seg *seg, uint32_t addr) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_LOAD_ADDR_EA_L(seg); } -static void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) { if (host_reg & 0x10) { @@ -1314,7 +1317,7 @@ static void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1340,7 +1343,7 @@ static void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -1376,24 +1379,24 @@ static void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); load_param_3_reg_32(host_reg); - call_long(writememb386l); + call_long((uintptr_t)writememb386l); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); /*done:*/ } -static void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1424,7 +1427,7 @@ static void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -1466,24 +1469,24 @@ static void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); load_param_3_reg_32(host_reg); - call_long(writememwl); + call_long((uintptr_t)writememwl); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); /*done:*/ } -static void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1514,7 +1517,7 @@ static void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -1554,24 +1557,24 @@ static void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); load_param_3_reg_32(host_reg); - call_long(writememll); + call_long((uintptr_t)writememll); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); /*done:*/ } -static void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) +static inline void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -1602,7 +1605,7 @@ static void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -1643,10 +1646,10 @@ static void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); load_param_3_reg_64(host_reg); - call_long(writememql); + call_long((uintptr_t)writememql); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); @@ -1654,26 +1657,26 @@ static void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) /*done:*/ } -static void MEM_STORE_ADDR_IMM_B(x86seg *seg, uint32_t addr, int host_reg) +static inline void MEM_STORE_ADDR_IMM_B(x86seg *seg, uint32_t addr, int host_reg) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_STORE_ADDR_EA_B(seg, host_reg); } -static void MEM_STORE_ADDR_IMM_W(x86seg *seg, uint32_t addr, int host_reg) +static inline void MEM_STORE_ADDR_IMM_W(x86seg *seg, uint32_t addr, int host_reg) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_STORE_ADDR_EA_W(seg, host_reg); } -static void MEM_STORE_ADDR_IMM_L(x86seg *seg, uint32_t addr, int host_reg) +static inline void MEM_STORE_ADDR_IMM_L(x86seg *seg, uint32_t addr, int host_reg) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_STORE_ADDR_EA_L(seg, host_reg); } -static void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) +static inline void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) { int temp_reg = REG_ECX; @@ -1703,7 +1706,7 @@ static void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) { addbyte(0x89); /*MOV addr, temp_reg*/ addbyte(0x45 | (temp_reg << 3)); - addbyte((uint32_t)addr - (uint32_t)&cpu_state - 128); + addbyte((uint32_t)addr - (uint32_t)(uintptr_t)&cpu_state - 128); } else if (IS_32_ADDR(addr)) { @@ -1721,7 +1724,7 @@ static void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) addbyte(0x06 | (temp_reg << 3)); } } -static void STORE_HOST_REG_ADDR_WL(uintptr_t addr, int host_reg) +static inline void STORE_HOST_REG_ADDR_WL(uintptr_t addr, int host_reg) { int temp_reg = REG_ECX; @@ -1737,7 +1740,7 @@ static void STORE_HOST_REG_ADDR_WL(uintptr_t addr, int host_reg) { addbyte(0x89); /*MOV addr, temp_reg*/ addbyte(0x45 | (temp_reg << 3)); - addbyte((uint32_t)addr - (uint32_t)&cpu_state - 128); + addbyte((uint32_t)addr - (uint32_t)(uintptr_t)&cpu_state - 128); } else if (IS_32_ADDR(addr)) { @@ -1755,7 +1758,7 @@ static void STORE_HOST_REG_ADDR_WL(uintptr_t addr, int host_reg) addbyte(0x06 | (temp_reg << 3)); } } -static void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) +static inline void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) { if (addr >= (uintptr_t)&cpu_state && addr < ((uintptr_t)&cpu_state)+0x100) { @@ -1764,7 +1767,7 @@ static void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) addbyte(0x44); addbyte(0x89); addbyte(0x45 | ((host_reg & 7) << 3)); - addbyte((uint32_t)addr - (uint32_t)&cpu_state - 128); + addbyte((uint32_t)addr - (uint32_t)(uintptr_t)&cpu_state - 128); } else if (IS_32_ADDR(addr)) { @@ -1789,7 +1792,7 @@ static void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) addbyte(0x06 | ((host_reg & 7) << 3)); } } -static void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) +static inline void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) { if (addr >= (uintptr_t)&cpu_state && addr < ((uintptr_t)&cpu_state)+0x100) { @@ -1797,7 +1800,7 @@ static void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) addbyte(0x44); addbyte(0x89); /*MOVL [addr],host_reg*/ addbyte(0x45 | ((host_reg & 7) << 3)); - addbyte((uint32_t)addr - (uint32_t)&cpu_state - 128); + addbyte((uint32_t)addr - (uint32_t)(uintptr_t)&cpu_state - 128); } else if (IS_32_ADDR(addr)) { @@ -1821,7 +1824,7 @@ static void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) } } -static void AND_HOST_REG_B(int dst_reg, int src_reg) +static inline void AND_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -1944,7 +1947,7 @@ static void AND_HOST_REG_B(int dst_reg, int src_reg) } } } -static void AND_HOST_REG_W(int dst_reg, int src_reg) +static inline void AND_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -1974,7 +1977,7 @@ static void AND_HOST_REG_W(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void AND_HOST_REG_L(int dst_reg, int src_reg) +static inline void AND_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2000,7 +2003,7 @@ static void AND_HOST_REG_L(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void AND_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void AND_HOST_REG_IMM(int host_reg, uint32_t imm) { if (host_reg & 0x10) { @@ -2021,7 +2024,7 @@ static void AND_HOST_REG_IMM(int host_reg, uint32_t imm) } } -static int TEST_HOST_REG_B(int dst_reg, int src_reg) +static inline int TEST_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & 8) { @@ -2036,7 +2039,7 @@ static int TEST_HOST_REG_B(int dst_reg, int src_reg) return dst_reg & ~0x10; } -static int TEST_HOST_REG_W(int dst_reg, int src_reg) +static inline int TEST_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & 8) { @@ -2051,7 +2054,7 @@ static int TEST_HOST_REG_W(int dst_reg, int src_reg) return dst_reg; } -static int TEST_HOST_REG_L(int dst_reg, int src_reg) +static inline int TEST_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & 8) { @@ -2066,7 +2069,7 @@ static int TEST_HOST_REG_L(int dst_reg, int src_reg) return dst_reg; } -static int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) { if (host_reg & 8) { @@ -2092,7 +2095,7 @@ static int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) return host_reg; } -static void OR_HOST_REG_B(int dst_reg, int src_reg) +static inline void OR_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2214,7 +2217,7 @@ static void OR_HOST_REG_B(int dst_reg, int src_reg) } } } -static void OR_HOST_REG_W(int dst_reg, int src_reg) +static inline void OR_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2244,7 +2247,7 @@ static void OR_HOST_REG_W(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void OR_HOST_REG_L(int dst_reg, int src_reg) +static inline void OR_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2270,7 +2273,7 @@ static void OR_HOST_REG_L(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void OR_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void OR_HOST_REG_IMM(int host_reg, uint32_t imm) { if (host_reg & 0x10) { @@ -2296,7 +2299,7 @@ static void OR_HOST_REG_IMM(int host_reg, uint32_t imm) // fatal("OR to bad register\n"); } -static void XOR_HOST_REG_B(int dst_reg, int src_reg) +static inline void XOR_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2418,7 +2421,7 @@ static void XOR_HOST_REG_B(int dst_reg, int src_reg) } } } -static void XOR_HOST_REG_W(int dst_reg, int src_reg) +static inline void XOR_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2448,7 +2451,7 @@ static void XOR_HOST_REG_W(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void XOR_HOST_REG_L(int dst_reg, int src_reg) +static inline void XOR_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2474,7 +2477,7 @@ static void XOR_HOST_REG_L(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void XOR_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void XOR_HOST_REG_IMM(int host_reg, uint32_t imm) { if (host_reg & 0x10) { @@ -2500,7 +2503,7 @@ static void XOR_HOST_REG_IMM(int host_reg, uint32_t imm) // fatal("XOR to bad register\n"); } -static void ADD_HOST_REG_B(int dst_reg, int src_reg) +static inline void ADD_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2594,7 +2597,7 @@ static void ADD_HOST_REG_B(int dst_reg, int src_reg) else fatal("!(dst_reg & src_reg & 8)\n"); } -static void ADD_HOST_REG_W(int dst_reg, int src_reg) +static inline void ADD_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2620,7 +2623,7 @@ static void ADD_HOST_REG_W(int dst_reg, int src_reg) else fatal("!(dst_reg & src_reg & 8)\n"); } -static void ADD_HOST_REG_L(int dst_reg, int src_reg) +static inline void ADD_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2644,7 +2647,7 @@ static void ADD_HOST_REG_L(int dst_reg, int src_reg) fatal("!(dst_reg & src_reg & 8)\n"); } -static void SUB_HOST_REG_B(int dst_reg, int src_reg) +static inline void SUB_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2768,7 +2771,7 @@ static void SUB_HOST_REG_B(int dst_reg, int src_reg) // fatal("!(dst_reg & src_reg & 8) subb %i %i\n", dst_reg, src_reg); } -static void SUB_HOST_REG_W(int dst_reg, int src_reg) +static inline void SUB_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2798,7 +2801,7 @@ static void SUB_HOST_REG_W(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); } } -static void SUB_HOST_REG_L(int dst_reg, int src_reg) +static inline void SUB_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & src_reg & 8) { @@ -2825,7 +2828,7 @@ static void SUB_HOST_REG_L(int dst_reg, int src_reg) } } -static int CMP_HOST_REG_B(int dst_reg, int src_reg) +static inline int CMP_HOST_REG_B(int dst_reg, int src_reg) { if (dst_reg & 8) { @@ -2840,7 +2843,7 @@ static int CMP_HOST_REG_B(int dst_reg, int src_reg) return dst_reg & ~0x10; } -static int CMP_HOST_REG_W(int dst_reg, int src_reg) +static inline int CMP_HOST_REG_W(int dst_reg, int src_reg) { if (dst_reg & 8) { @@ -2855,7 +2858,7 @@ static int CMP_HOST_REG_W(int dst_reg, int src_reg) return dst_reg; } -static int CMP_HOST_REG_L(int dst_reg, int src_reg) +static inline int CMP_HOST_REG_L(int dst_reg, int src_reg) { if (dst_reg & 8) { @@ -2871,7 +2874,7 @@ static int CMP_HOST_REG_L(int dst_reg, int src_reg) return dst_reg; } -static void ADD_HOST_REG_IMM_B(int host_reg, uint8_t imm) +static inline void ADD_HOST_REG_IMM_B(int host_reg, uint8_t imm) { if (host_reg & 0x10) { @@ -2891,7 +2894,7 @@ static void ADD_HOST_REG_IMM_B(int host_reg, uint8_t imm) addbyte(imm); } } -static void ADD_HOST_REG_IMM_W(int host_reg, uint16_t imm) +static inline void ADD_HOST_REG_IMM_W(int host_reg, uint16_t imm) { addbyte(0x66); /*ADDW host_reg, imm*/ if (host_reg & 8) @@ -2900,7 +2903,7 @@ static void ADD_HOST_REG_IMM_W(int host_reg, uint16_t imm) addbyte(0xC0 | (host_reg & 7)); addword(imm); } -static void ADD_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void ADD_HOST_REG_IMM(int host_reg, uint32_t imm) { if (host_reg & 8) addbyte(0x41); @@ -2909,7 +2912,7 @@ static void ADD_HOST_REG_IMM(int host_reg, uint32_t imm) addlong(imm); } -static void SUB_HOST_REG_IMM_B(int host_reg, uint8_t imm) +static inline void SUB_HOST_REG_IMM_B(int host_reg, uint8_t imm) { if (host_reg & 0x10) { @@ -2929,7 +2932,7 @@ static void SUB_HOST_REG_IMM_B(int host_reg, uint8_t imm) addbyte(imm); } } -static void SUB_HOST_REG_IMM_W(int host_reg, uint16_t imm) +static inline void SUB_HOST_REG_IMM_W(int host_reg, uint16_t imm) { addbyte(0x66); /*SUBW host_reg, imm*/ if (host_reg & 8) @@ -2938,7 +2941,7 @@ static void SUB_HOST_REG_IMM_W(int host_reg, uint16_t imm) addbyte(0xE8 | (host_reg & 7)); addword(imm); } -static void SUB_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void SUB_HOST_REG_IMM(int host_reg, uint32_t imm) { if (host_reg & 8) addbyte(0x41); @@ -2947,7 +2950,7 @@ static void SUB_HOST_REG_IMM(int host_reg, uint32_t imm) addlong(imm); } -static int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) +static inline int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) { if (host_reg & 8) { @@ -2962,7 +2965,7 @@ static int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) return host_reg;// & ~0x10; } -static int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) +static inline int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) { if (host_reg & 8) { @@ -2977,7 +2980,7 @@ static int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) return host_reg; } -static int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) +static inline int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) { if (host_reg & 8) { @@ -2993,13 +2996,13 @@ static int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) return host_reg; } -static void LOAD_STACK_TO_EA(int off) +static inline void LOAD_STACK_TO_EA(int off) { if (stack32) { addbyte(0x8b); /*MOVL EAX,[ESP]*/ addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_ESP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].l)); if (off) { addbyte(0x83); /*ADD EAX, off*/ @@ -3012,7 +3015,7 @@ static void LOAD_STACK_TO_EA(int off) addbyte(0x0f); /*MOVZX EAX,W[ESP]*/ addbyte(0xb7); addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_ESP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].w)); if (off) { addbyte(0x66); /*ADD AX, off*/ @@ -3021,13 +3024,13 @@ static void LOAD_STACK_TO_EA(int off) } } } -static void LOAD_EBP_TO_EA(int off) +static inline void LOAD_EBP_TO_EA(int off) { if (stack32) { addbyte(0x8b); /*MOVL EAX,[EBP]*/ addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_EBP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_EBP].l)); if (off) { addbyte(0x83); /*ADD EAX, off*/ @@ -3040,7 +3043,7 @@ static void LOAD_EBP_TO_EA(int off) addbyte(0x0f); /*MOVZX EAX,W[EBP]*/ addbyte(0xb7); addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_BP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_BP].l)); if (off) { addbyte(0x66); /*ADD AX, off*/ @@ -3050,7 +3053,7 @@ static void LOAD_EBP_TO_EA(int off) } } -static void SP_MODIFY(int off) +static inline void SP_MODIFY(int off) { if (stack32) { @@ -3058,14 +3061,14 @@ static void SP_MODIFY(int off) { addbyte(0x83); /*ADD [ESP], off*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].l)); addbyte(off); } else { addbyte(0x81); /*ADD [ESP], off*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].l)); addlong(off); } } @@ -3076,7 +3079,7 @@ static void SP_MODIFY(int off) addbyte(0x66); /*ADD [SP], off*/ addbyte(0x83); addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].w)); addbyte(off); } else @@ -3084,13 +3087,13 @@ static void SP_MODIFY(int off) addbyte(0x66); /*ADD [SP], off*/ addbyte(0x81); addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].w)); addword(off); } } } -static void TEST_ZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_ZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) { addbyte(0x66); /*CMPW host_reg, 0*/ if (host_reg & 8) @@ -3102,19 +3105,19 @@ static void TEST_ZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static void TEST_ZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_ZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) { if (host_reg & 8) addbyte(0x41); @@ -3125,20 +3128,20 @@ static void TEST_ZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static void TEST_NONZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_NONZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) { addbyte(0x66); /*CMPW host_reg, 0*/ if (host_reg & 8) @@ -3150,19 +3153,19 @@ static void TEST_NONZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) { if (host_reg & 8) addbyte(0x41); @@ -3173,20 +3176,20 @@ static void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static inline void BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { uint8_t *jump1; @@ -3194,20 +3197,20 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no { addbyte(0x83); /*CMP flags_res, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(flags_res)); + addbyte((uint8_t)cpu_state_offset(flags_res)); addbyte(0); addbyte(0x74); /*JZ +*/ } else { - CALL_FUNC(ZF_SET); + CALL_FUNC((uintptr_t)ZF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x75); /*JNZ +*/ } jump1 = &codeblock[block_current].data[block_pos]; addbyte(0); - CALL_FUNC(CF_SET); + CALL_FUNC((uintptr_t)CF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); if (not) @@ -3220,13 +3223,13 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc+pc_offset+offset); if (timing_bt) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(timing_bt); } addbyte(0xe9); /*JMP end*/ @@ -3235,15 +3238,15 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; } -static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static inline void BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { - CALL_FUNC(NF_SET); + CALL_FUNC((uintptr_t)NF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE BL*/ addbyte(0x95); addbyte(0xc3); - CALL_FUNC(VF_SET); + CALL_FUNC((uintptr_t)VF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE AL*/ @@ -3258,46 +3261,46 @@ static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not addbyte(7+5+(timing_bt ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc+pc_offset+offset); if (timing_bt) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(timing_bt); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static inline void BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { uint8_t *jump1; if (codegen_flags_changed && cpu_state.flags_op != FLAGS_UNKNOWN) { addbyte(0x83); /*CMP flags_res, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(flags_res)); + addbyte((uint8_t)cpu_state_offset(flags_res)); addbyte(0); addbyte(0x74); /*JZ +*/ } else { - CALL_FUNC(ZF_SET); + CALL_FUNC((uintptr_t)ZF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x75); /*JNZ +*/ } jump1 = &codeblock[block_current].data[block_pos]; addbyte(0); - CALL_FUNC(NF_SET); + CALL_FUNC((uintptr_t)NF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE BL*/ addbyte(0x95); addbyte(0xc3); - CALL_FUNC(VF_SET); + CALL_FUNC((uintptr_t)VF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE AL*/ @@ -3314,13 +3317,13 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc+pc_offset+offset); if (timing_bt) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(timing_bt); } addbyte(0xe9); /*JMP end*/ @@ -3329,7 +3332,7 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; } -static int LOAD_VAR_W(uintptr_t addr) +static inline int LOAD_VAR_W(uintptr_t addr) { int host_reg = REG_EBX; @@ -3360,11 +3363,11 @@ static int LOAD_VAR_W(uintptr_t addr) return host_reg; } -static int LOAD_VAR_WL(uintptr_t addr) +static inline int LOAD_VAR_WL(uintptr_t addr) { return LOAD_VAR_W(addr); } -static int LOAD_VAR_L(uintptr_t addr) +static inline int LOAD_VAR_L(uintptr_t addr) { int host_reg = REG_EBX; @@ -3393,7 +3396,7 @@ static int LOAD_VAR_L(uintptr_t addr) return host_reg; } -static int COPY_REG(int src_reg) +static inline int COPY_REG(int src_reg) { if (src_reg & 8) addbyte(0x44); @@ -3403,7 +3406,7 @@ static int COPY_REG(int src_reg) return REG_ECX | (src_reg & 0x10); } -static int LOAD_HOST_REG(int host_reg) +static inline int LOAD_HOST_REG(int host_reg) { if (host_reg & 8) addbyte(0x44); @@ -3413,7 +3416,7 @@ static int LOAD_HOST_REG(int host_reg) return REG_EBX | (host_reg & 0x10); } -static int ZERO_EXTEND_W_B(int reg) +static inline int ZERO_EXTEND_W_B(int reg) { if (reg & 0x10) { @@ -3435,7 +3438,7 @@ static int ZERO_EXTEND_W_B(int reg) return REG_EAX; } -static int ZERO_EXTEND_L_B(int reg) +static inline int ZERO_EXTEND_L_B(int reg) { if (reg & 0x10) { @@ -3457,7 +3460,7 @@ static int ZERO_EXTEND_L_B(int reg) return REG_EAX; } -static int ZERO_EXTEND_L_W(int reg) +static inline int ZERO_EXTEND_L_W(int reg) { if (reg & 8) addbyte(0x41); @@ -3468,7 +3471,7 @@ static int ZERO_EXTEND_L_W(int reg) return REG_EAX; } -static int SIGN_EXTEND_W_B(int reg) +static inline int SIGN_EXTEND_W_B(int reg) { if (reg & 0x10) { @@ -3490,7 +3493,7 @@ static int SIGN_EXTEND_W_B(int reg) return REG_EAX; } -static int SIGN_EXTEND_L_B(int reg) +static inline int SIGN_EXTEND_L_B(int reg) { if (reg & 0x10) { @@ -3512,7 +3515,7 @@ static int SIGN_EXTEND_L_B(int reg) return REG_EAX; } -static int SIGN_EXTEND_L_W(int reg) +static inline int SIGN_EXTEND_L_W(int reg) { if (reg & 8) addbyte(0x41); @@ -3523,7 +3526,7 @@ static int SIGN_EXTEND_L_W(int reg) return REG_EAX; } -static void SHL_B_IMM(int reg, int count) +static inline void SHL_B_IMM(int reg, int count) { if (reg & 0x10) { @@ -3546,7 +3549,7 @@ static void SHL_B_IMM(int reg, int count) addbyte(count); } } -static void SHL_W_IMM(int reg, int count) +static inline void SHL_W_IMM(int reg, int count) { addbyte(0x66); /*SHL reg, count*/ if (reg & 8) @@ -3555,7 +3558,7 @@ static void SHL_W_IMM(int reg, int count) addbyte(0xc0 | (reg & 7) | 0x20); addbyte(count); } -static void SHL_L_IMM(int reg, int count) +static inline void SHL_L_IMM(int reg, int count) { if (reg & 8) addbyte(0x41); @@ -3563,7 +3566,7 @@ static void SHL_L_IMM(int reg, int count) addbyte(0xc0 | (reg & 7) | 0x20); addbyte(count); } -static void SHR_B_IMM(int reg, int count) +static inline void SHR_B_IMM(int reg, int count) { if (reg & 0x10) { @@ -3586,7 +3589,7 @@ static void SHR_B_IMM(int reg, int count) addbyte(count); } } -static void SHR_W_IMM(int reg, int count) +static inline void SHR_W_IMM(int reg, int count) { addbyte(0x66); /*SHR reg, count*/ if (reg & 8) @@ -3595,7 +3598,7 @@ static void SHR_W_IMM(int reg, int count) addbyte(0xc0 | (reg & 7) | 0x28); addbyte(count); } -static void SHR_L_IMM(int reg, int count) +static inline void SHR_L_IMM(int reg, int count) { if (reg & 8) addbyte(0x41); @@ -3603,7 +3606,7 @@ static void SHR_L_IMM(int reg, int count) addbyte(0xc0 | (reg & 7) | 0x28); addbyte(count); } -static void SAR_B_IMM(int reg, int count) +static inline void SAR_B_IMM(int reg, int count) { if (reg & 0x10) { @@ -3626,7 +3629,7 @@ static void SAR_B_IMM(int reg, int count) addbyte(count); } } -static void SAR_W_IMM(int reg, int count) +static inline void SAR_W_IMM(int reg, int count) { addbyte(0x66); /*SAR reg, count*/ if (reg & 8) @@ -3635,7 +3638,7 @@ static void SAR_W_IMM(int reg, int count) addbyte(0xc0 | (reg & 7) | 0x38); addbyte(count); } -static void SAR_L_IMM(int reg, int count) +static inline void SAR_L_IMM(int reg, int count) { if (reg & 8) addbyte(0x41); @@ -3644,7 +3647,7 @@ static void SAR_L_IMM(int reg, int count) addbyte(count); } -static void NEG_HOST_REG_B(int reg) +static inline void NEG_HOST_REG_B(int reg) { if (reg & 0x10) { @@ -3667,7 +3670,7 @@ static void NEG_HOST_REG_B(int reg) addbyte(0xd8 | (reg & 7)); } } -static void NEG_HOST_REG_W(int reg) +static inline void NEG_HOST_REG_W(int reg) { addbyte(0x66); if (reg & 8) @@ -3675,7 +3678,7 @@ static void NEG_HOST_REG_W(int reg) addbyte(0xf7); addbyte(0xd8 | (reg & 7)); } -static void NEG_HOST_REG_L(int reg) +static inline void NEG_HOST_REG_L(int reg) { if (reg & 8) addbyte(0x41); @@ -3684,7 +3687,7 @@ static void NEG_HOST_REG_L(int reg) } -static void FP_ENTER() +static inline void FP_ENTER() { if (codegen_fpu_entered) return; @@ -3700,7 +3703,7 @@ static void FP_ENTER() { addbyte(0x48); /*MOV RAX, &cr0*/ addbyte(0xb8 | REG_EAX); - addquad(&cr0); + addquad((uint64_t)&cr0); addbyte(0xf6); /*TEST [RAX], 0xc*/ addbyte(0 | (REG_EAX << 3)); addbyte(0x0c); @@ -3709,21 +3712,21 @@ static void FP_ENTER() addbyte(7+5+12+5); addbyte(0xC7); /*MOVL [oldpc],op_old_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(oldpc)); + addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(op_old_pc); load_param_1_32(&codeblock[block_current], 7); - CALL_FUNC(x86_int); + CALL_FUNC((uintptr_t)x86_int); addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); codegen_fpu_entered = 1; } -static void FP_FXCH(int reg) +static inline void FP_FXCH(int reg) { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); addbyte(0x83); /*ADD EAX, reg*/ @@ -3734,7 +3737,7 @@ static void FP_FXCH(int reg) addbyte(0x8b); addbyte(0x54); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x83); /*AND EAX, 7*/ addbyte(0xe0); addbyte(0x07); @@ -3742,65 +3745,65 @@ static void FP_FXCH(int reg) addbyte(0x8b); addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x48); /*MOV ST[RAX*8], RDX*/ addbyte(0x89); addbyte(0x54); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x48); /*MOV ST[RBX*8], RCX*/ addbyte(0x89); addbyte(0x4c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV CL, tag[EAX]*/ addbyte(0x4c); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(0x8a); /*MOV DL, tag[EBX]*/ addbyte(0x54); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(0x88); /*MOV tag[EBX], CL*/ addbyte(0x4c); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(0x88); /*MOV tag[EAX], DL*/ addbyte(0x54); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(0x48); /*MOV RDX, MM[RBX*8]*/ addbyte(0x8b); addbyte(0x54); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x48); /*MOV RCX, MM[RAX*8]*/ addbyte(0x8b); addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x48); /*MOV MM[RAX*8], RDX*/ addbyte(0x89); addbyte(0x54); addbyte(0xc5); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x48); /*MOV MM[RBX*8], RCX*/ addbyte(0x89); addbyte(0x4c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); reg = reg; } -static void FP_FLD(int reg) +static inline void FP_FLD(int reg) { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); if (reg) @@ -3826,7 +3829,7 @@ static void FP_FLD(int reg) addbyte(0x8b); addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x83); /*AND EBX, 7*/ addbyte(0xe3); addbyte(0x07); @@ -3834,45 +3837,45 @@ static void FP_FLD(int reg) addbyte(0x8b); addbyte(0x54); addbyte(0xc5); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x8a); /*MOV AL, [tag+EAX]*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(0x48); /*MOV ST[EBX*8], RCX*/ addbyte(0x89); addbyte(0x4c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x48); /*MOV ST_i64[EBX*8], RDX*/ addbyte(0x89); addbyte(0x54); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x88); /*MOV [tag+EBX], AL*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(0x89); /*MOV [TOP], EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } -static void FP_FST(int reg) +static inline void FP_FST(int reg) { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x48); /*MOV RCX, ST[EAX*8]*/ addbyte(0x8b); addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV BL, [tag+EAX]*/ addbyte(0x5c); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); if (reg) { @@ -3888,22 +3891,22 @@ static void FP_FST(int reg) addbyte(0x89); addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x88); /*MOV [tag+EAX], BL*/ addbyte(0x5c); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); } -static void FP_POP() +static inline void FP_POP() { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xc6); /*MOVB tag[EAX], 3*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(3); addbyte(0x83); /*ADD AL, 1*/ addbyte(0xc0); @@ -3913,17 +3916,17 @@ static void FP_POP() addbyte(7); addbyte(0x89); /*MOV [TOP], EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } -static void FP_POP2() +static inline void FP_POP2() { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xc6); /*MOVB tag[EAX], 3*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(3); addbyte(0x83); /*ADD AL, 2*/ addbyte(0xc0); @@ -3933,14 +3936,14 @@ static void FP_POP2() addbyte(7); addbyte(0x89); /*MOV [TOP], EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } -static void FP_LOAD_S() +static inline void FP_LOAD_S() { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x66); /*MOVD XMM0, EAX*/ addbyte(0x0f); addbyte(0x6e); @@ -3959,24 +3962,24 @@ static void FP_LOAD_S() addbyte(0xc0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x66); /*MOVQ [ST+EBX*8], XMM0*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); } -static void FP_LOAD_D() +static inline void FP_LOAD_D() { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(0x01); @@ -3988,24 +3991,24 @@ static void FP_LOAD_D() addbyte(0xc0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x48); /*MOVQ [ST+EBX*8], RAX*/ addbyte(0x89); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); } -static void FP_LOAD_IW() +static inline void FP_LOAD_IW() { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x0f); /*MOVSX EAX, AX*/ addbyte(0xbf); addbyte(0xc0); @@ -4023,24 +4026,24 @@ static void FP_LOAD_IW() addbyte(0xc0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x66); /*MOVQ [ST+EBX*8], XMM0*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); } -static void FP_LOAD_IL() +static inline void FP_LOAD_IL() { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(0x01); @@ -4055,24 +4058,24 @@ static void FP_LOAD_IL() addbyte(0xc0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x66); /*MOVQ [ST+EBX*8], XMM0*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); } -static void FP_LOAD_IQ() +static inline void FP_LOAD_IQ() { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(0x01); @@ -4091,10 +4094,10 @@ static void FP_LOAD_IQ() addbyte(0x89); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x0f); /*SETE AL*/ addbyte(0x94); addbyte(0xc0); @@ -4103,20 +4106,20 @@ static void FP_LOAD_IQ() addbyte(0xd6); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0c); /*OR AL, TAG_UINT64*/ addbyte(TAG_UINT64); addbyte(0x88); /*MOV [tag+EBX], AL*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); } -static void FP_LOAD_IMM_Q(uint64_t v) +static inline void FP_LOAD_IMM_Q(uint64_t v) { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(0x01); @@ -4126,28 +4129,28 @@ static void FP_LOAD_IMM_Q(uint64_t v) addbyte(0xc7); /*MOV ST[EBP+EBX*8], v*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addlong(v & 0xffffffff); addbyte(0xc7); /*MOV ST[EBP+EBX*8]+4, v*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST) + 4); + addbyte((uint8_t)cpu_state_offset(ST) + 4); addlong(v >> 32); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xc6); /*MOV [tag+EBX], (v ? 0 : 1)*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(v ? 0 : 1); } -static void FP_FCHS() +static inline void FP_FCHS() { addbyte(0x8b); /*MOV EAX, TOP*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xf2); /*SUBSD XMM0, XMM0*/ addbyte(0x0f); addbyte(0x5c); @@ -4157,25 +4160,25 @@ static void FP_FCHS() addbyte(0x5c); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EAX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xf2); /*MOVSD ST[EAX*8], XMM0*/ addbyte(0x0f); addbyte(0x11); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } -static int FP_LOAD_REG(int reg) +static inline int FP_LOAD_REG(int reg) { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -4190,7 +4193,7 @@ static int FP_LOAD_REG(int reg) addbyte(0x7e); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xf2); /*CVTSD2SS XMM0, XMM0*/ addbyte(0x0f); addbyte(0x5a); @@ -4202,11 +4205,11 @@ static int FP_LOAD_REG(int reg) return REG_EBX; } -static void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) +static inline void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -4220,11 +4223,11 @@ static void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) addbyte(0x8b); addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); *host_reg1 = REG_EBX; } -static int64_t x87_fround(double b) +static inline int64_t x87_fround(double b) { int64_t a, c; @@ -4246,15 +4249,17 @@ static int64_t x87_fround(double b) case 3: /*Chop*/ return (int64_t)b; } + + return 0; } -static int FP_LOAD_REG_INT_W(int reg) +static inline int FP_LOAD_REG_INT_W(int reg) { addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EAX, reg*/ @@ -4269,22 +4274,22 @@ static int FP_LOAD_REG_INT_W(int reg) addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); - CALL_FUNC(x87_fround); + CALL_FUNC((uintptr_t)x87_fround); addbyte(0x93); /*XCHG EBX, EAX*/ return REG_EBX; } -static int FP_LOAD_REG_INT(int reg) +static inline int FP_LOAD_REG_INT(int reg) { addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EAX, reg*/ @@ -4299,22 +4304,22 @@ static int FP_LOAD_REG_INT(int reg) addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); - CALL_FUNC(x87_fround); + CALL_FUNC((uintptr_t)x87_fround); addbyte(0x93); /*XCHG EBX, EAX*/ return REG_EBX; } -static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) +static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) { addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EAX, reg*/ @@ -4334,7 +4339,7 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x8b); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x48); /*XCHG RBX, RAX*/ addbyte(0x93); @@ -4347,7 +4352,7 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0xf6); /*TEST TAG[EAX], TAG_UINT64*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(TAG_UINT64); addbyte(0x74); /*JZ +*/ @@ -4357,7 +4362,7 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x8b); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0xeb); /*JMP done*/ addbyte(6+12); @@ -4367,9 +4372,9 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); - CALL_FUNC(x87_fround); + CALL_FUNC((uintptr_t)x87_fround); addbyte(0x48); /*XCHG RBX, RAX*/ addbyte(0x93); @@ -4384,11 +4389,11 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) #define FPU_SUB 2 #define FPU_SUBR 3 -static void FP_OP_REG(int op, int dst, int src) +static inline void FP_OP_REG(int op, int dst, int src) { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); if (dst) @@ -4412,7 +4417,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x80); /*AND tag[EAX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(~TAG_UINT64); if (op == FPU_DIVR || op == FPU_SUBR) { @@ -4421,7 +4426,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x7e); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } else { @@ -4430,7 +4435,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } switch (op) { @@ -4440,7 +4445,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x58); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); break; case FPU_DIV: addbyte(0xf2); /*DIVSD XMM0, ST[RBX*8]*/ @@ -4448,7 +4453,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x5e); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); break; case FPU_DIVR: addbyte(0xf2); /*DIVSD XMM0, ST[RAX*8]*/ @@ -4456,7 +4461,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x5e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); break; case FPU_MUL: addbyte(0xf2); /*MULSD XMM0, ST[RBX*8]*/ @@ -4464,7 +4469,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x59); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); break; case FPU_SUB: addbyte(0xf2); /*SUBSD XMM0, ST[RBX*8]*/ @@ -4472,7 +4477,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x5c); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); break; case FPU_SUBR: addbyte(0xf2); /*SUBSD XMM0, ST[RAX*8]*/ @@ -4480,7 +4485,7 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0x5c); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); break; } addbyte(0x66); /*MOVQ [RSI+RAX*8], XMM0*/ @@ -4488,24 +4493,24 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0xd6); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } -static void FP_OP_MEM(int op) +static inline void FP_OP_MEM(int op) { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xf3); /*MOVQ XMM0, ST[RAX*8]*/ addbyte(0x0f); addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EAX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x05); - addbyte(cpu_state_offset(tag)); + addbyte((uint8_t)cpu_state_offset(tag)); addbyte(~TAG_UINT64); switch (op) @@ -4554,7 +4559,7 @@ static void FP_OP_MEM(int op) addbyte(0xd6); addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } else { @@ -4563,11 +4568,11 @@ static void FP_OP_MEM(int op) addbyte(0xd6); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } -static void FP_OP_S(int op) +static inline void FP_OP_S(int op) { addbyte(0x66); /*MOVD XMM1, EAX*/ addbyte(0x0f); @@ -4579,7 +4584,7 @@ static void FP_OP_S(int op) addbyte(0xc9); FP_OP_MEM(op); } -static void FP_OP_D(int op) +static inline void FP_OP_D(int op) { addbyte(0x66); /*MOVQ XMM1, RAX*/ addbyte(0x48); @@ -4621,7 +4626,7 @@ static void FP_OP_D(int op) addbyte(0x08); } } -static void FP_OP_IW(int op) +static inline void FP_OP_IW(int op) { addbyte(0x0f); /*MOVSX EAX, AX*/ addbyte(0xbf); @@ -4632,7 +4637,7 @@ static void FP_OP_IW(int op) addbyte(0xc8); FP_OP_MEM(op); } -static void FP_OP_IL(int op) +static inline void FP_OP_IL(int op) { addbyte(0xf2); /*CVTSI2SD XMM1, EAX*/ addbyte(0x0f); @@ -4646,11 +4651,11 @@ static void FP_OP_IL(int op) #define C2 (1<<10) #define C3 (1<<14) -static void FP_COMPARE_REG(int dst, int src) +static inline void FP_COMPARE_REG(int dst, int src) { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); if (src || dst) @@ -4665,7 +4670,7 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0x8a); /*MOV CL, [npxs+1]*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); // addbyte(0xdb); /*FCLEX*/ // addbyte(0xe2); addbyte(0x80); /*AND CL, ~(C0|C2|C3)*/ @@ -4679,13 +4684,13 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0x7e); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x66); /*COMISD XMM0, ST[RAX*8]*/ addbyte(0x0f); addbyte(0x2f); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } else { @@ -4694,13 +4699,13 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x66); /*COMISD XMM0, ST[RBX*8]*/ addbyte(0x0f); addbyte(0x2f); addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } addbyte(0x9f); /*LAHF*/ @@ -4711,18 +4716,18 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0xe1); addbyte(0x88); /*MOV [npxs+1], CL*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } -static void FP_COMPARE_MEM() +static inline void FP_COMPARE_MEM() { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x8a); /*MOV CL, [npxs+1]*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); // addbyte(0xdb); /*FCLEX*/ // addbyte(0xe2); addbyte(0xf3); /*MOVQ XMM0, ST[RAX*8]*/ @@ -4730,7 +4735,7 @@ static void FP_COMPARE_MEM() addbyte(0x7e); addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND CL, ~(C0|C2|C3)*/ addbyte(0xe1); addbyte((~(C0|C2|C3)) >> 8); @@ -4746,9 +4751,9 @@ static void FP_COMPARE_MEM() addbyte(0xe1); addbyte(0x88); /*MOV [npxs+1], CL*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } -static void FP_COMPARE_S() +static inline void FP_COMPARE_S() { addbyte(0x66); /*MOVD XMM1, EAX*/ addbyte(0x0f); @@ -4760,7 +4765,7 @@ static void FP_COMPARE_S() addbyte(0xc9); FP_COMPARE_MEM(); } -static void FP_COMPARE_D() +static inline void FP_COMPARE_D() { addbyte(0x66); /*MOVQ XMM1, RAX*/ addbyte(0x48); @@ -4769,7 +4774,7 @@ static void FP_COMPARE_D() addbyte(0xc8); FP_COMPARE_MEM(); } -static void FP_COMPARE_IW() +static inline void FP_COMPARE_IW() { addbyte(0x0f); /*MOVSX EAX, AX*/ addbyte(0xbf); @@ -4780,7 +4785,7 @@ static void FP_COMPARE_IW() addbyte(0xc8); FP_COMPARE_MEM(); } -static void FP_COMPARE_IL() +static inline void FP_COMPARE_IL() { addbyte(0xf2); /*CVTSI2SD XMM1, EAX*/ addbyte(0x0f); @@ -4789,11 +4794,11 @@ static void FP_COMPARE_IL() FP_COMPARE_MEM(); } -static void UPDATE_NPXC(int reg) +static inline void UPDATE_NPXC(int reg) { } -static void SET_BITS(uintptr_t addr, uint32_t val) +static inline void SET_BITS(uintptr_t addr, uint32_t val) { if (IS_32_ADDR(addr)) { @@ -4834,7 +4839,7 @@ static void SET_BITS(uintptr_t addr, uint32_t val) } } -static void CLEAR_BITS(uintptr_t addr, uint32_t val) +static inline void CLEAR_BITS(uintptr_t addr, uint32_t val) { if (IS_32_ADDR(addr)) { @@ -4878,7 +4883,7 @@ static void CLEAR_BITS(uintptr_t addr, uint32_t val) #define LOAD_Q_REG_1 REG_EAX #define LOAD_Q_REG_2 REG_EDX -static void MMX_ENTER() +static inline void MMX_ENTER() { if (codegen_mmx_entered) return; @@ -4895,7 +4900,7 @@ static void MMX_ENTER() { addbyte(0x48); /*MOV RAX, &cr0*/ addbyte(0xb8 | REG_EAX); - addquad(&cr0); + addquad((uint64_t)&cr0); addbyte(0xf6); /*TEST [RAX], 0xc*/ addbyte(0 | (REG_EAX << 3)); addbyte(0x0c); @@ -4904,10 +4909,10 @@ static void MMX_ENTER() addbyte(7+5+12+5); addbyte(0xC7); /*MOVL [oldpc],op_old_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(oldpc)); + addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(op_old_pc); load_param_1_32(&codeblock[block_current], 7); - CALL_FUNC(x86_int); + CALL_FUNC((uintptr_t)x86_int); addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); @@ -4916,35 +4921,35 @@ static void MMX_ENTER() addbyte(0xc0); addbyte(0xc6); /*MOV ISMMX, 1*/ addbyte(0x45); - addbyte(cpu_state_offset(ismmx)); + addbyte((uint8_t)cpu_state_offset(ismmx)); addbyte(1); addbyte(0x89); /*MOV TOP, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV tag, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x89); /*MOV tag+4, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[4])); + addbyte((uint8_t)cpu_state_offset(tag[4])); codegen_mmx_entered = 1; } extern int mmx_ebx_ecx_loaded; -static int LOAD_MMX_D(int guest_reg) +static inline int LOAD_MMX_D(int guest_reg) { int host_reg = REG_EBX; addbyte(0x8b); /*MOV EBX, reg*/ addbyte(0x44 | (host_reg << 3)); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); return host_reg; } -static void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) +static inline void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) { int host_reg = REG_EBX; @@ -4955,11 +4960,11 @@ static void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) addbyte(0x8b); /*MOV RBX, reg*/ addbyte(0x44 | ((host_reg & 7) << 3)); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].q)); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); *host_reg1 = host_reg; } -static int LOAD_MMX_Q_MMX(int guest_reg) +static inline int LOAD_MMX_Q_MMX(int guest_reg) { int dst_reg = find_host_xmm_reg(); host_reg_xmm_mapping[dst_reg] = 100; @@ -4969,12 +4974,12 @@ static int LOAD_MMX_Q_MMX(int guest_reg) addbyte(0x7e); addbyte(0x44 | ((dst_reg & 7) << 3)); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].q)); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); return dst_reg; } -static int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) +static inline int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) { int dst_reg = find_host_xmm_reg(); host_reg_xmm_mapping[dst_reg] = 100; @@ -4991,21 +4996,21 @@ static int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) return dst_reg; } -static void STORE_MMX_LQ(int guest_reg, int host_reg1) +static inline void STORE_MMX_LQ(int guest_reg, int host_reg1) { addbyte(0xC7); /*MOVL [reg],0*/ addbyte(0x44); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].l[1])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[1])); addlong(0); if (host_reg1 & 8) addbyte(0x44); addbyte(0x89); /*MOVL [reg],host_reg*/ addbyte(0x44 | ((host_reg1 & 7) << 3)); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); } -static void STORE_MMX_Q(int guest_reg, int host_reg1, int host_reg2) +static inline void STORE_MMX_Q(int guest_reg, int host_reg1, int host_reg2) { if (host_reg1 & 8) addbyte(0x4c); @@ -5014,20 +5019,20 @@ static void STORE_MMX_Q(int guest_reg, int host_reg1, int host_reg2) addbyte(0x89); /*MOV [reg],host_reg*/ addbyte(0x44 | ((host_reg1 & 7) << 3)); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); } -static void STORE_MMX_Q_MMX(int guest_reg, int host_reg) +static inline void STORE_MMX_Q_MMX(int guest_reg, int host_reg) { addbyte(0x66); /*MOVQ [guest_reg],host_reg*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x44 | (host_reg << 3)); addbyte(0x25); - addbyte(cpu_state_offset(MM[guest_reg].q)); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); } #define MMX_x86_OP(name, opcode) \ -static void MMX_ ## name(int dst_reg, int src_reg) \ +static inline void MMX_ ## name(int dst_reg, int src_reg) \ { \ addbyte(0x66); /*op dst_reg, src_reg*/ \ addbyte(0x0f); \ @@ -5080,7 +5085,7 @@ MMX_x86_OP(PMULLW, 0xd5); MMX_x86_OP(PMULHW, 0xe5); MMX_x86_OP(PMADDWD, 0xf5); -static void MMX_PACKSSWB(int dst_reg, int src_reg) +static inline void MMX_PACKSSWB(int dst_reg, int src_reg) { addbyte(0x66); /*PACKSSWB dst_reg, src_reg*/ addbyte(0x0f); @@ -5092,7 +5097,7 @@ static void MMX_PACKSSWB(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x08); } -static void MMX_PACKUSWB(int dst_reg, int src_reg) +static inline void MMX_PACKUSWB(int dst_reg, int src_reg) { addbyte(0x66); /*PACKUSWB dst_reg, src_reg*/ addbyte(0x0f); @@ -5104,7 +5109,7 @@ static void MMX_PACKUSWB(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x08); } -static void MMX_PACKSSDW(int dst_reg, int src_reg) +static inline void MMX_PACKSSDW(int dst_reg, int src_reg) { addbyte(0x66); /*PACKSSDW dst_reg, src_reg*/ addbyte(0x0f); @@ -5116,7 +5121,7 @@ static void MMX_PACKSSDW(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x08); } -static void MMX_PUNPCKHBW(int dst_reg, int src_reg) +static inline void MMX_PUNPCKHBW(int dst_reg, int src_reg) { addbyte(0x66); /*PUNPCKLBW dst_reg, src_reg*/ addbyte(0x0f); @@ -5128,7 +5133,7 @@ static void MMX_PUNPCKHBW(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x0e); } -static void MMX_PUNPCKHWD(int dst_reg, int src_reg) +static inline void MMX_PUNPCKHWD(int dst_reg, int src_reg) { addbyte(0x66); /*PUNPCKLWD dst_reg, src_reg*/ addbyte(0x0f); @@ -5140,7 +5145,7 @@ static void MMX_PUNPCKHWD(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x0e); } -static void MMX_PUNPCKHDQ(int dst_reg, int src_reg) +static inline void MMX_PUNPCKHDQ(int dst_reg, int src_reg) { addbyte(0x66); /*PUNPCKLDQ dst_reg, src_reg*/ addbyte(0x0f); @@ -5153,7 +5158,7 @@ static void MMX_PUNPCKHDQ(int dst_reg, int src_reg) addbyte(0x0e); } -static void MMX_PSRLW_imm(int dst_reg, int amount) +static inline void MMX_PSRLW_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRLW dst_reg, amount*/ addbyte(0x0f); @@ -5161,7 +5166,7 @@ static void MMX_PSRLW_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x10); addbyte(amount); } -static void MMX_PSRAW_imm(int dst_reg, int amount) +static inline void MMX_PSRAW_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRAW dst_reg, amount*/ addbyte(0x0f); @@ -5169,7 +5174,7 @@ static void MMX_PSRAW_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x20); addbyte(amount); } -static void MMX_PSLLW_imm(int dst_reg, int amount) +static inline void MMX_PSLLW_imm(int dst_reg, int amount) { addbyte(0x66); /*PSLLW dst_reg, amount*/ addbyte(0x0f); @@ -5178,7 +5183,7 @@ static void MMX_PSLLW_imm(int dst_reg, int amount) addbyte(amount); } -static void MMX_PSRLD_imm(int dst_reg, int amount) +static inline void MMX_PSRLD_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRLD dst_reg, amount*/ addbyte(0x0f); @@ -5186,7 +5191,7 @@ static void MMX_PSRLD_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x10); addbyte(amount); } -static void MMX_PSRAD_imm(int dst_reg, int amount) +static inline void MMX_PSRAD_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRAD dst_reg, amount*/ addbyte(0x0f); @@ -5194,7 +5199,7 @@ static void MMX_PSRAD_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x20); addbyte(amount); } -static void MMX_PSLLD_imm(int dst_reg, int amount) +static inline void MMX_PSLLD_imm(int dst_reg, int amount) { addbyte(0x66); /*PSLLD dst_reg, amount*/ addbyte(0x0f); @@ -5203,7 +5208,7 @@ static void MMX_PSLLD_imm(int dst_reg, int amount) addbyte(amount); } -static void MMX_PSRLQ_imm(int dst_reg, int amount) +static inline void MMX_PSRLQ_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRLQ dst_reg, amount*/ addbyte(0x0f); @@ -5211,7 +5216,7 @@ static void MMX_PSRLQ_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x10); addbyte(amount); } -static void MMX_PSRAQ_imm(int dst_reg, int amount) +static inline void MMX_PSRAQ_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRAQ dst_reg, amount*/ addbyte(0x0f); @@ -5219,7 +5224,7 @@ static void MMX_PSRAQ_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x20); addbyte(amount); } -static void MMX_PSLLQ_imm(int dst_reg, int amount) +static inline void MMX_PSLLQ_imm(int dst_reg, int amount) { addbyte(0x66); /*PSLLQ dst_reg, amount*/ addbyte(0x0f); @@ -5229,14 +5234,14 @@ static void MMX_PSLLQ_imm(int dst_reg, int amount) } -static void SAVE_EA() +static inline void SAVE_EA() { addbyte(0x89); /*MOV [ESP+0x24], EAX*/ addbyte(0x44); addbyte(0x24); addbyte(0x24); } -static void LOAD_EA() +static inline void LOAD_EA() { addbyte(0x8b); /*MOV EAX, [ESP+0x24]*/ addbyte(0x44); @@ -5246,7 +5251,7 @@ static void LOAD_EA() #define MEM_CHECK_WRITE_B MEM_CHECK_WRITE -static void MEM_CHECK_WRITE(x86seg *seg) +static inline void MEM_CHECK_WRITE(x86seg *seg) { uint8_t *jump1, *jump2, *jump3; @@ -5257,7 +5262,7 @@ static void MEM_CHECK_WRITE(x86seg *seg) addbyte(0x8b); /*MOV ESI, seg->base*/ addbyte(0x34); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5276,7 +5281,7 @@ static void MEM_CHECK_WRITE(x86seg *seg) addbyte(0x83); /*CMP cr0, 0*/ addbyte(0x3c); addbyte(0x25); - addlong((uint32_t)&cr0); + addlong((uint32_t)(uintptr_t)&cr0); addbyte(0); } else @@ -5310,7 +5315,7 @@ static void MEM_CHECK_WRITE(x86seg *seg) addbyte(0x83); /*CMP writelookup2[RDI*8],-1*/ addbyte(0x3c); addbyte(0xfd); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); addbyte(-1); } else @@ -5343,18 +5348,18 @@ static void MEM_CHECK_WRITE(x86seg *seg) // addbyte(0x6a); /*PUSH 1*/ // addbyte(1); // addbyte(0x57); /*PUSH EDI*/ - call(&codeblock[block_current], mmutranslatereal); + call(&codeblock[block_current], (uintptr_t)mmutranslatereal); // addbyte(0x48); /*ADD ESP, 8*/ // addbyte(0x83); // addbyte(0xc4); // addbyte(8); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); - addlong((uintptr_t)&codeblock[block_current].data[BLOCK_EXIT_OFFSET] - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); + addlong((uintptr_t)&codeblock[block_current].data[BLOCK_EXIT_OFFSET] - ((uintptr_t)(&codeblock[block_current].data[block_pos]) + 4)); // addbyte(0xc3); /*RET*/ *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; *jump2 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump2 - 1; @@ -5366,7 +5371,7 @@ static void MEM_CHECK_WRITE(x86seg *seg) LOAD_EA(); } -static void MEM_CHECK_WRITE_W(x86seg *seg) +static inline void MEM_CHECK_WRITE_W(x86seg *seg) { uint8_t *jump1, *jump2, *jump3, *jump4; int jump_pos; @@ -5378,7 +5383,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) addbyte(0x8b); /*MOV ESI, seg->base*/ addbyte(0x34); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5397,7 +5402,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) addbyte(0x83); /*CMP cr0, 0*/ addbyte(0x3c); addbyte(0x25); - addlong((uint32_t)&cr0); + addlong((uint32_t)(uintptr_t)&cr0); addbyte(0); } else @@ -5438,7 +5443,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) addbyte(0x83); /*CMP writelookup2[RDI*8],-1*/ addbyte(0x3c); addbyte(0xfd); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); addbyte(-1); } else @@ -5459,7 +5464,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) addbyte(0x83); /*CMP writelookup2[RSI*8],-1*/ addbyte(0x3c); addbyte(0xfd); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); addbyte(-1); } else @@ -5479,17 +5484,17 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) jump_pos = block_pos; load_param_1_reg_32(REG_EBX); load_param_2_32(&codeblock[block_current], 1); - call(&codeblock[block_current], mmutranslatereal); + call(&codeblock[block_current], (uintptr_t)mmutranslatereal); addbyte(0x83); /*ADD EBX, 1*/ addbyte(0xc3); addbyte(1); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); - addlong((uintptr_t)&codeblock[block_current].data[BLOCK_EXIT_OFFSET] - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); + addlong((uintptr_t)&codeblock[block_current].data[BLOCK_EXIT_OFFSET] - ((uintptr_t)(&codeblock[block_current].data[block_pos]) + 4)); /*If bits 0-11 of the address are now 0 then this crosses a page, so loop back*/ addbyte(0xf7); /*TEST $fff, EBX*/ addbyte(0xc3); @@ -5503,7 +5508,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) LOAD_EA(); } -static void MEM_CHECK_WRITE_L(x86seg *seg) +static inline void MEM_CHECK_WRITE_L(x86seg *seg) { uint8_t *jump1, *jump2, *jump3, *jump4; int jump_pos; @@ -5515,7 +5520,7 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) addbyte(0x8b); /*MOV ESI, seg->base*/ addbyte(0x34); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5534,7 +5539,7 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) addbyte(0x83); /*CMP cr0, 0*/ addbyte(0x3c); addbyte(0x25); - addlong((uint32_t)&cr0); + addlong((uint32_t)(uintptr_t)&cr0); addbyte(0); } else @@ -5575,7 +5580,7 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) addbyte(0x83); /*CMP writelookup2[RDI*8],-1*/ addbyte(0x3c); addbyte(0xfd); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); addbyte(-1); } else @@ -5596,7 +5601,7 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) addbyte(0x83); /*CMP writelookup2[RSI*8],-1*/ addbyte(0x3c); addbyte(0xfd); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); addbyte(-1); } else @@ -5616,17 +5621,17 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) jump_pos = block_pos; load_param_1_reg_32(REG_EBX); load_param_2_32(&codeblock[block_current], 1); - call(&codeblock[block_current], mmutranslatereal); + call(&codeblock[block_current], (uintptr_t)mmutranslatereal); addbyte(0x83); /*ADD EBX, 3*/ addbyte(0xc3); addbyte(3); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); - addlong((uintptr_t)&codeblock[block_current].data[BLOCK_EXIT_OFFSET] - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); + addlong((uintptr_t)&codeblock[block_current].data[BLOCK_EXIT_OFFSET] - ((uintptr_t)(&codeblock[block_current].data[block_pos]) + 4)); /*If bits 0-11 of the address are now 0 then this crosses a page, so loop back*/ addbyte(0xf7); /*TEST $ffc, EBX*/ addbyte(0xc3); @@ -5640,14 +5645,14 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) LOAD_EA(); } -static int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) +static inline int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5673,7 +5678,7 @@ static int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -5698,7 +5703,7 @@ static int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemb386l); + call_long((uintptr_t)readmemb386l); addbyte(0x89); /*MOV ECX, EAX*/ addbyte(0xc1); /*done:*/ @@ -5707,14 +5712,14 @@ static int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) return REG_ECX; } -static int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) +static inline int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5745,7 +5750,7 @@ static int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -5774,7 +5779,7 @@ static int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemwl); + call_long((uintptr_t)readmemwl); addbyte(0x89); /*MOV ECX, EAX*/ addbyte(0xc1); /*done:*/ @@ -5783,14 +5788,14 @@ static int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) return REG_ECX; } -static int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) +static inline int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL ECX, seg->base*/ addbyte(0x0c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5821,7 +5826,7 @@ static int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)readlookup2); + addlong((uint32_t)(uintptr_t)readlookup2); } else { @@ -5849,7 +5854,7 @@ static int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) /*slowpath:*/ load_param_1_reg_32(REG_ECX); load_param_2_reg_32(REG_EAX); - call_long(readmemll); + call_long((uintptr_t)readmemll); addbyte(0x89); /*MOV ECX, EAX*/ addbyte(0xc1); /*done:*/ @@ -5859,7 +5864,7 @@ static int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) return REG_ECX; } -static void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) { if (host_reg & 0x10) { @@ -5888,7 +5893,7 @@ static void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) addbyte(0x8b); /*MOVL EBX, seg->base*/ addbyte(0x1c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5914,7 +5919,7 @@ static void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -5950,17 +5955,17 @@ static void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) load_param_3_reg_32(host_reg); load_param_1_reg_32(REG_EBX); load_param_2_reg_32(REG_EAX); - call_long(writememb386l); + call_long((uintptr_t)writememb386l); /*done:*/ } -static void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL EBX, seg->base*/ addbyte(0x1c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -5991,7 +5996,7 @@ static void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -6033,17 +6038,17 @@ static void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) load_param_3_reg_32(host_reg); load_param_1_reg_32(REG_EBX); load_param_2_reg_32(REG_EAX); - call_long(writememwl); + call_long((uintptr_t)writememwl); /*done:*/ } -static void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) { if (IS_32_ADDR(&seg->base)) { addbyte(0x8b); /*MOVL EBX, seg->base*/ addbyte(0x1c); addbyte(0x25); - addlong((uint32_t)&seg->base); + addlong((uint32_t)(uintptr_t)&seg->base); } else { @@ -6074,7 +6079,7 @@ static void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) addbyte(0x8b); addbyte(0x34); addbyte(0xf5); - addlong((uint32_t)writelookup2); + addlong((uint32_t)(uintptr_t)writelookup2); } else { @@ -6114,18 +6119,18 @@ static void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) load_param_3_reg_32(host_reg); load_param_1_reg_32(REG_EBX); load_param_2_reg_32(REG_EAX); - call_long(writememll); + call_long((uintptr_t)writememll); /*done:*/ } -static void LOAD_SEG(int host_reg, void *seg) +static inline void LOAD_SEG(int host_reg, void *seg) { load_param_2_64(&codeblock[block_current], (uint64_t)seg); load_param_1_reg_32(host_reg); - CALL_FUNC(loadseg); + CALL_FUNC((uintptr_t)loadseg); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); diff --git a/src/codegen_ops_x86.h b/src/codegen_ops_x86.h index 9584a4d..3581f6e 100644 --- a/src/codegen_ops_x86.h +++ b/src/codegen_ops_x86.h @@ -35,14 +35,15 @@ static inline int find_host_xmm_reg() return c; } -static void STORE_IMM_ADDR_B(uintptr_t addr, uint8_t val) +#if 0 +static inline void STORE_IMM_ADDR_B(uintptr_t addr, uint8_t val) { addbyte(0xC6); /*MOVB [addr],val*/ addbyte(0x05); addlong(addr); addbyte(val); } -static void STORE_IMM_ADDR_W(uintptr_t addr, uint16_t val) +static inline void STORE_IMM_ADDR_W(uintptr_t addr, uint16_t val) { addbyte(0x66); /*MOVW [addr],val*/ addbyte(0xC7); @@ -50,7 +51,8 @@ static void STORE_IMM_ADDR_W(uintptr_t addr, uint16_t val) addlong(addr); addword(val); } -static void STORE_IMM_ADDR_L(uintptr_t addr, uint32_t val) +#endif +static inline void STORE_IMM_ADDR_L(uintptr_t addr, uint32_t val) { if (addr >= (uintptr_t)&cpu_state && addr < ((uintptr_t)&cpu_state)+0x100) { @@ -68,33 +70,33 @@ static void STORE_IMM_ADDR_L(uintptr_t addr, uint32_t val) } } -static void STORE_IMM_REG_B(int reg, uint8_t val) +static inline void STORE_IMM_REG_B(int reg, uint8_t val) { addbyte(0xC6); /*MOVB [addr],val*/ addbyte(0x45); if (reg & 4) - addbyte(cpu_state_offset(regs[reg & 3].b.h)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 3].b.h)); else - addbyte(cpu_state_offset(regs[reg & 3].b.l)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 3].b.l)); addbyte(val); } -static void STORE_IMM_REG_W(int reg, uint16_t val) +static inline void STORE_IMM_REG_W(int reg, uint16_t val) { addbyte(0x66); /*MOVW [addr],val*/ addbyte(0xC7); addbyte(0x45); - addbyte(cpu_state_offset(regs[reg & 7].w)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 7].w)); addword(val); } -static void STORE_IMM_REG_L(int reg, uint32_t val) +static inline void STORE_IMM_REG_L(int reg, uint32_t val) { addbyte(0xC7); /*MOVL [addr],val*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[reg & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 7].l)); addlong(val); } -static int LOAD_REG_B(int reg) +static inline int LOAD_REG_B(int reg) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = reg; @@ -103,13 +105,13 @@ static int LOAD_REG_B(int reg) addbyte(0xb6); addbyte(0x45 | (host_reg << 3)); if (reg & 4) - addbyte(cpu_state_offset(regs[reg & 3].b.h)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 3].b.h)); else - addbyte(cpu_state_offset(regs[reg & 3].b.l)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 3].b.l)); return host_reg; } -static int LOAD_REG_W(int reg) +static inline int LOAD_REG_W(int reg) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = reg; @@ -117,23 +119,23 @@ static int LOAD_REG_W(int reg) addbyte(0x0f); /*MOVZX W[reg],host_reg*/ addbyte(0xb7); addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(regs[reg & 7].w)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 7].w)); return host_reg; } -static int LOAD_REG_L(int reg) +static inline int LOAD_REG_L(int reg) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = reg; addbyte(0x8b); /*MOVL host_reg,[reg]*/ addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(regs[reg & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[reg & 7].l)); return host_reg; } -static int LOAD_VAR_W(uintptr_t addr) +static inline int LOAD_VAR_W(uintptr_t addr) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 0; @@ -145,7 +147,7 @@ static int LOAD_VAR_W(uintptr_t addr) return host_reg; } -static int LOAD_VAR_WL(uintptr_t addr) +static inline int LOAD_VAR_WL(uintptr_t addr) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 0; @@ -157,7 +159,7 @@ static int LOAD_VAR_WL(uintptr_t addr) return host_reg; } -static int LOAD_VAR_L(uintptr_t addr) +static inline int LOAD_VAR_L(uintptr_t addr) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 0; @@ -169,7 +171,7 @@ static int LOAD_VAR_L(uintptr_t addr) return host_reg; } -static int LOAD_REG_IMM(uint32_t imm) +static inline int LOAD_REG_IMM(uint32_t imm) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 0; @@ -181,7 +183,7 @@ static int LOAD_REG_IMM(uint32_t imm) return host_reg; } -static int LOAD_HOST_REG(int host_reg) +static inline int LOAD_HOST_REG(int host_reg) { int new_host_reg = find_host_reg(); host_reg_mapping[new_host_reg] = 0; @@ -192,64 +194,64 @@ static int LOAD_HOST_REG(int host_reg) return new_host_reg; } -static void STORE_REG_B_RELEASE(int host_reg) +static inline void STORE_REG_B_RELEASE(int host_reg) { addbyte(0x88); /*MOVB [reg],host_reg*/ addbyte(0x45 | (host_reg << 3)); if (host_reg_mapping[host_reg] & 4) - addbyte(cpu_state_offset(regs[host_reg_mapping[host_reg] & 3].b.h)); + addbyte((uint8_t)cpu_state_offset(regs[host_reg_mapping[host_reg] & 3].b.h)); else - addbyte(cpu_state_offset(regs[host_reg_mapping[host_reg] & 3].b.l)); + addbyte((uint8_t)cpu_state_offset(regs[host_reg_mapping[host_reg] & 3].b.l)); host_reg_mapping[host_reg] = -1; } -static void STORE_REG_W_RELEASE(int host_reg) +static inline void STORE_REG_W_RELEASE(int host_reg) { addbyte(0x66); /*MOVW [reg],host_reg*/ addbyte(0x89); addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(regs[host_reg_mapping[host_reg]].w)); + addbyte((uint8_t)cpu_state_offset(regs[host_reg_mapping[host_reg]].w)); host_reg_mapping[host_reg] = -1; } -static void STORE_REG_L_RELEASE(int host_reg) +static inline void STORE_REG_L_RELEASE(int host_reg) { addbyte(0x89); /*MOVL [reg],host_reg*/ addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(regs[host_reg_mapping[host_reg]].l)); + addbyte((uint8_t)cpu_state_offset(regs[host_reg_mapping[host_reg]].l)); host_reg_mapping[host_reg] = -1; } -static void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) +static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) { addbyte(0x88); /*MOVB [guest_reg],host_reg*/ addbyte(0x45 | (host_reg << 3)); if (guest_reg & 4) - addbyte(cpu_state_offset(regs[guest_reg & 3].b.h)); + addbyte((uint8_t)cpu_state_offset(regs[guest_reg & 3].b.h)); else - addbyte(cpu_state_offset(regs[guest_reg & 3].b.l)); + addbyte((uint8_t)cpu_state_offset(regs[guest_reg & 3].b.l)); host_reg_mapping[host_reg] = -1; } -static void STORE_REG_TARGET_W_RELEASE(int host_reg, int guest_reg) +static inline void STORE_REG_TARGET_W_RELEASE(int host_reg, int guest_reg) { addbyte(0x66); /*MOVW [guest_reg],host_reg*/ addbyte(0x89); addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(regs[guest_reg & 7].w)); + addbyte((uint8_t)cpu_state_offset(regs[guest_reg & 7].w)); host_reg_mapping[host_reg] = -1; } -static void STORE_REG_TARGET_L_RELEASE(int host_reg, int guest_reg) +static inline void STORE_REG_TARGET_L_RELEASE(int host_reg, int guest_reg) { addbyte(0x89); /*MOVL [guest_reg],host_reg*/ addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(regs[guest_reg & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[guest_reg & 7].l)); host_reg_mapping[host_reg] = -1; } -static void RELEASE_REG(int host_reg) +static inline void RELEASE_REG(int host_reg) { host_reg_mapping[host_reg] = -1; } -static void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) +static inline void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) { if (addr >= (uintptr_t)&cpu_state && addr < ((uintptr_t)&cpu_state)+0x100) { @@ -266,7 +268,7 @@ static void STORE_HOST_REG_ADDR_W(uintptr_t addr, int host_reg) addlong(addr); } } -static void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) +static inline void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) { if (addr >= (uintptr_t)&cpu_state && addr < ((uintptr_t)&cpu_state)+0x100) { @@ -284,29 +286,29 @@ static void STORE_HOST_REG_ADDR(uintptr_t addr, int host_reg) #define STORE_HOST_REG_ADDR_BL STORE_HOST_REG_ADDR #define STORE_HOST_REG_ADDR_WL STORE_HOST_REG_ADDR -static void ADD_HOST_REG_B(int dst_reg, int src_reg) +static inline void ADD_HOST_REG_B(int dst_reg, int src_reg) { addbyte(0x00); /*ADDB dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void ADD_HOST_REG_W(int dst_reg, int src_reg) +static inline void ADD_HOST_REG_W(int dst_reg, int src_reg) { addbyte(0x66); /*ADDW dst_reg, src_reg*/ addbyte(0x01); addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void ADD_HOST_REG_L(int dst_reg, int src_reg) +static inline void ADD_HOST_REG_L(int dst_reg, int src_reg) { addbyte(0x01); /*ADDL dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void ADD_HOST_REG_IMM_B(int host_reg, uint8_t imm) +static inline void ADD_HOST_REG_IMM_B(int host_reg, uint8_t imm) { addbyte(0x80); /*ADDB host_reg, imm*/ addbyte(0xC0 | host_reg); addbyte(imm); } -static void ADD_HOST_REG_IMM_W(int host_reg, uint16_t imm) +static inline void ADD_HOST_REG_IMM_W(int host_reg, uint16_t imm) { if (imm < 0x80 || imm >= 0xff80) { @@ -323,7 +325,7 @@ static void ADD_HOST_REG_IMM_W(int host_reg, uint16_t imm) addword(imm); } } -static void ADD_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void ADD_HOST_REG_IMM(int host_reg, uint32_t imm) { if (imm < 0x80 || imm >= 0xffffff80) { @@ -341,12 +343,12 @@ static void ADD_HOST_REG_IMM(int host_reg, uint32_t imm) #define AND_HOST_REG_B AND_HOST_REG_L #define AND_HOST_REG_W AND_HOST_REG_L -static void AND_HOST_REG_L(int dst_reg, int src_reg) +static inline void AND_HOST_REG_L(int dst_reg, int src_reg) { addbyte(0x21); /*ANDL dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void AND_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void AND_HOST_REG_IMM(int host_reg, uint32_t imm) { if (imm < 0x80 || imm >= 0xffffff80) { @@ -361,25 +363,25 @@ static void AND_HOST_REG_IMM(int host_reg, uint32_t imm) addlong(imm); } } -static int TEST_HOST_REG_B(int dst_reg, int src_reg) +static inline int TEST_HOST_REG_B(int dst_reg, int src_reg) { AND_HOST_REG_B(dst_reg, src_reg); return dst_reg; } -static int TEST_HOST_REG_W(int dst_reg, int src_reg) +static inline int TEST_HOST_REG_W(int dst_reg, int src_reg) { AND_HOST_REG_W(dst_reg, src_reg); return dst_reg; } -static int TEST_HOST_REG_L(int dst_reg, int src_reg) +static inline int TEST_HOST_REG_L(int dst_reg, int src_reg) { AND_HOST_REG_L(dst_reg, src_reg); return dst_reg; } -static int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) { AND_HOST_REG_IMM(host_reg, imm); @@ -388,12 +390,12 @@ static int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) #define OR_HOST_REG_B OR_HOST_REG_L #define OR_HOST_REG_W OR_HOST_REG_L -static void OR_HOST_REG_L(int dst_reg, int src_reg) +static inline void OR_HOST_REG_L(int dst_reg, int src_reg) { addbyte(0x09); /*ORL dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void OR_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void OR_HOST_REG_IMM(int host_reg, uint32_t imm) { if (imm < 0x80 || imm >= 0xffffff80) { @@ -409,46 +411,46 @@ static void OR_HOST_REG_IMM(int host_reg, uint32_t imm) } } -static void NEG_HOST_REG_B(int reg) +static inline void NEG_HOST_REG_B(int reg) { addbyte(0xf6); addbyte(0xd8 | reg); } -static void NEG_HOST_REG_W(int reg) +static inline void NEG_HOST_REG_W(int reg) { addbyte(0x66); addbyte(0xf7); addbyte(0xd8 | reg); } -static void NEG_HOST_REG_L(int reg) +static inline void NEG_HOST_REG_L(int reg) { addbyte(0xf7); addbyte(0xd8 | reg); } -static void SUB_HOST_REG_B(int dst_reg, int src_reg) +static inline void SUB_HOST_REG_B(int dst_reg, int src_reg) { addbyte(0x28); /*SUBB dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void SUB_HOST_REG_W(int dst_reg, int src_reg) +static inline void SUB_HOST_REG_W(int dst_reg, int src_reg) { addbyte(0x66); /*SUBW dst_reg, src_reg*/ addbyte(0x29); addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void SUB_HOST_REG_L(int dst_reg, int src_reg) +static inline void SUB_HOST_REG_L(int dst_reg, int src_reg) { addbyte(0x29); /*SUBL dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void SUB_HOST_REG_IMM_B(int host_reg, uint8_t imm) +static inline void SUB_HOST_REG_IMM_B(int host_reg, uint8_t imm) { addbyte(0x80); /*SUBB host_reg, imm*/ addbyte(0xE8 | host_reg); addbyte(imm); } -static void SUB_HOST_REG_IMM_W(int host_reg, uint16_t imm) +static inline void SUB_HOST_REG_IMM_W(int host_reg, uint16_t imm) { if (imm < 0x80 || imm >= 0xff80) { @@ -465,7 +467,7 @@ static void SUB_HOST_REG_IMM_W(int host_reg, uint16_t imm) addword(imm); } } -static void SUB_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void SUB_HOST_REG_IMM(int host_reg, uint32_t imm) { if (imm < 0x80 || imm >= 0xffffff80) { @@ -481,37 +483,37 @@ static void SUB_HOST_REG_IMM(int host_reg, uint32_t imm) } } -static int CMP_HOST_REG_B(int dst_reg, int src_reg) +static inline int CMP_HOST_REG_B(int dst_reg, int src_reg) { SUB_HOST_REG_B(dst_reg, src_reg); return dst_reg; } -static int CMP_HOST_REG_W(int dst_reg, int src_reg) +static inline int CMP_HOST_REG_W(int dst_reg, int src_reg) { SUB_HOST_REG_W(dst_reg, src_reg); return dst_reg; } -static int CMP_HOST_REG_L(int dst_reg, int src_reg) +static inline int CMP_HOST_REG_L(int dst_reg, int src_reg) { SUB_HOST_REG_L(dst_reg, src_reg); return dst_reg; } -static int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) +static inline int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) { SUB_HOST_REG_IMM_B(host_reg, imm); return host_reg; } -static int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) +static inline int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) { SUB_HOST_REG_IMM_W(host_reg, imm); return host_reg; } -static int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) +static inline int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) { SUB_HOST_REG_IMM(host_reg, imm); @@ -520,12 +522,12 @@ static int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) #define XOR_HOST_REG_B XOR_HOST_REG_L #define XOR_HOST_REG_W XOR_HOST_REG_L -static void XOR_HOST_REG_L(int dst_reg, int src_reg) +static inline void XOR_HOST_REG_L(int dst_reg, int src_reg) { addbyte(0x31); /*XORL dst_reg, src_reg*/ addbyte(0xc0 | dst_reg | (src_reg << 3)); } -static void XOR_HOST_REG_IMM(int host_reg, uint32_t imm) +static inline void XOR_HOST_REG_IMM(int host_reg, uint32_t imm) { if (imm < 0x80 || imm >= 0xffffff80) { @@ -541,64 +543,64 @@ static void XOR_HOST_REG_IMM(int host_reg, uint32_t imm) } } -static void CALL_FUNC(void *dest) +static inline void CALL_FUNC(uintptr_t dest) { addbyte(0xE8); /*CALL*/ - addlong(((uint8_t *)dest - (uint8_t *)(&codeblock[block_current].data[block_pos + 4]))); + addlong(((uintptr_t)dest - (uintptr_t)(&codeblock[block_current].data[block_pos + 4]))); } -static void SHL_B_IMM(int reg, int count) +static inline void SHL_B_IMM(int reg, int count) { addbyte(0xc0); /*SHL reg, count*/ addbyte(0xc0 | reg | 0x20); addbyte(count); } -static void SHL_W_IMM(int reg, int count) +static inline void SHL_W_IMM(int reg, int count) { addbyte(0x66); /*SHL reg, count*/ addbyte(0xc1); addbyte(0xc0 | reg | 0x20); addbyte(count); } -static void SHL_L_IMM(int reg, int count) +static inline void SHL_L_IMM(int reg, int count) { addbyte(0xc1); /*SHL reg, count*/ addbyte(0xc0 | reg | 0x20); addbyte(count); } -static void SHR_B_IMM(int reg, int count) +static inline void SHR_B_IMM(int reg, int count) { addbyte(0xc0); /*SHR reg, count*/ addbyte(0xc0 | reg | 0x28); addbyte(count); } -static void SHR_W_IMM(int reg, int count) +static inline void SHR_W_IMM(int reg, int count) { addbyte(0x66); /*SHR reg, count*/ addbyte(0xc1); addbyte(0xc0 | reg | 0x28); addbyte(count); } -static void SHR_L_IMM(int reg, int count) +static inline void SHR_L_IMM(int reg, int count) { addbyte(0xc1); /*SHR reg, count*/ addbyte(0xc0 | reg | 0x28); addbyte(count); } -static void SAR_B_IMM(int reg, int count) +static inline void SAR_B_IMM(int reg, int count) { addbyte(0xc0); /*SAR reg, count*/ addbyte(0xc0 | reg | 0x38); addbyte(count); } -static void SAR_W_IMM(int reg, int count) +static inline void SAR_W_IMM(int reg, int count) { addbyte(0x66); /*SAR reg, count*/ addbyte(0xc1); addbyte(0xc0 | reg | 0x38); addbyte(count); } -static void SAR_L_IMM(int reg, int count) +static inline void SAR_L_IMM(int reg, int count) { addbyte(0xc1); /*SAR reg, count*/ addbyte(0xc0 | reg | 0x38); @@ -606,7 +608,7 @@ static void SAR_L_IMM(int reg, int count) } -static void CHECK_SEG_READ(x86seg *seg) +static inline void CHECK_SEG_READ(x86seg *seg) { /*Segments always valid in real/V86 mode*/ if (!(cr0 & 1) || (eflags & VM_FLAG)) @@ -627,7 +629,7 @@ static void CHECK_SEG_READ(x86seg *seg) seg->checked = 1; } -static void CHECK_SEG_WRITE(x86seg *seg) +static inline void CHECK_SEG_WRITE(x86seg *seg) { /*Segments always valid in real/V86 mode*/ if (!(cr0 & 1) || (eflags & VM_FLAG)) @@ -648,7 +650,7 @@ static void CHECK_SEG_WRITE(x86seg *seg) seg->checked = 1; } -static void CHECK_SEG_LIMITS(x86seg *seg, int end_offset) +static inline void CHECK_SEG_LIMITS(x86seg *seg, int end_offset) { addbyte(0x3b); /*CMP EAX, seg->limit_low*/ addbyte(0x05); @@ -673,7 +675,7 @@ static void CHECK_SEG_LIMITS(x86seg *seg, int end_offset) } } -static void MEM_LOAD_ADDR_EA_B(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_B(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -683,7 +685,7 @@ static void MEM_LOAD_ADDR_EA_B(x86seg *seg) host_reg_mapping[0] = 8; } -static int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) +static inline int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -695,7 +697,7 @@ static int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) return REG_ECX; } -static void MEM_LOAD_ADDR_EA_W(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_W(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -705,7 +707,7 @@ static void MEM_LOAD_ADDR_EA_W(x86seg *seg) host_reg_mapping[0] = 8; } -static void MEM_LOAD_ADDR_EA_W_OFFSET(x86seg *seg, int offset) +static inline void MEM_LOAD_ADDR_EA_W_OFFSET(x86seg *seg, int offset) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -718,7 +720,7 @@ static void MEM_LOAD_ADDR_EA_W_OFFSET(x86seg *seg, int offset) host_reg_mapping[0] = 8; } -static int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) +static inline int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -730,7 +732,7 @@ static int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) return REG_ECX; } -static void MEM_LOAD_ADDR_EA_L(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_L(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -741,7 +743,7 @@ static void MEM_LOAD_ADDR_EA_L(x86seg *seg) host_reg_mapping[0] = 8; } -static int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) +static inline int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -754,7 +756,7 @@ static int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) return REG_ECX; } -static void MEM_LOAD_ADDR_EA_Q(x86seg *seg) +static inline void MEM_LOAD_ADDR_EA_Q(x86seg *seg) { addbyte(0x8b); /*MOVL EDX, seg->base*/ addbyte(0x05 | (REG_EDX << 3)); @@ -765,26 +767,26 @@ static void MEM_LOAD_ADDR_EA_Q(x86seg *seg) host_reg_mapping[0] = 8; } -static void MEM_LOAD_ADDR_IMM_B(x86seg *seg, uint32_t addr) +static inline void MEM_LOAD_ADDR_IMM_B(x86seg *seg, uint32_t addr) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_LOAD_ADDR_EA_B(seg); } -static void MEM_LOAD_ADDR_IMM_W(x86seg *seg, uint32_t addr) +static inline void MEM_LOAD_ADDR_IMM_W(x86seg *seg, uint32_t addr) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_LOAD_ADDR_EA_W(seg); } -static void MEM_LOAD_ADDR_IMM_L(x86seg *seg, uint32_t addr) +static inline void MEM_LOAD_ADDR_IMM_L(x86seg *seg, uint32_t addr) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_LOAD_ADDR_EA_L(seg); } -static void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) { addbyte(0x8b); /*MOVL ESI, seg->base*/ addbyte(0x05 | (REG_ESI << 3)); @@ -797,7 +799,7 @@ static void MEM_STORE_ADDR_EA_B(x86seg *seg, int host_reg) addbyte(0xe8); /*CALL mem_store_addr_ea_b*/ addlong(mem_store_addr_ea_b - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) { addbyte(0x8b); /*MOVL ESI, seg->base*/ addbyte(0x05 | (REG_ESI << 3)); @@ -810,7 +812,7 @@ static void MEM_STORE_ADDR_EA_B_NO_ABRT(x86seg *seg, int host_reg) addbyte(0xe8); /*CALL mem_store_addr_ea_b_no_abrt*/ addlong(mem_store_addr_ea_b_no_abrt - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) { addbyte(0x8b); /*MOVL ESI, seg->base*/ addbyte(0x05 | (REG_ESI << 3)); @@ -823,7 +825,7 @@ static void MEM_STORE_ADDR_EA_W(x86seg *seg, int host_reg) addbyte(0xe8); /*CALL mem_store_addr_ea_w*/ addlong(mem_store_addr_ea_w - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) { addbyte(0x8b); /*MOVL ESI, seg->base*/ addbyte(0x05 | (REG_ESI << 3)); @@ -836,7 +838,7 @@ static void MEM_STORE_ADDR_EA_W_NO_ABRT(x86seg *seg, int host_reg) addbyte(0xe8); /*CALL mem_store_addr_ea_w_no_abrt*/ addlong(mem_store_addr_ea_w_no_abrt - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) { addbyte(0x8b); /*MOVL ESI, seg->base*/ addbyte(0x05 | (REG_ESI << 3)); @@ -849,7 +851,7 @@ static void MEM_STORE_ADDR_EA_L(x86seg *seg, int host_reg) addbyte(0xe8); /*CALL mem_store_addr_ea_l*/ addlong(mem_store_addr_ea_l - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) +static inline void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) { addbyte(0x8b); /*MOVL ESI, seg->base*/ addbyte(0x05 | (REG_ESI << 3)); @@ -862,7 +864,7 @@ static void MEM_STORE_ADDR_EA_L_NO_ABRT(x86seg *seg, int host_reg) addbyte(0xe8); /*CALL mem_store_addr_ea_l_no_abrt*/ addlong(mem_store_addr_ea_l_no_abrt - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) +static inline void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) { if (host_reg != REG_EBX) { @@ -881,19 +883,19 @@ static void MEM_STORE_ADDR_EA_Q(x86seg *seg, int host_reg, int host_reg2) addlong(mem_store_addr_ea_q - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); } -static void MEM_STORE_ADDR_IMM_B(x86seg *seg, uint32_t addr, int host_reg) +static inline void MEM_STORE_ADDR_IMM_B(x86seg *seg, uint32_t addr, int host_reg) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_STORE_ADDR_EA_B(seg, host_reg); } -static void MEM_STORE_ADDR_IMM_L(x86seg *seg, uint32_t addr, int host_reg) +static inline void MEM_STORE_ADDR_IMM_L(x86seg *seg, uint32_t addr, int host_reg) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); MEM_STORE_ADDR_EA_L(seg, host_reg); } -static void MEM_STORE_ADDR_IMM_W(x86seg *seg, uint32_t addr, int host_reg) +static inline void MEM_STORE_ADDR_IMM_W(x86seg *seg, uint32_t addr, int host_reg) { addbyte(0xb8); /*MOV EAX, addr*/ addlong(addr); @@ -901,10 +903,10 @@ static void MEM_STORE_ADDR_IMM_W(x86seg *seg, uint32_t addr, int host_reg) } -static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) +static inline x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) { int mod = (fetchdat >> 6) & 3; - int reg = (fetchdat >> 3) & 7; +// int reg = (fetchdat >> 3) & 7; int rm = fetchdat & 7; if (!mod && rm == 6) { @@ -964,11 +966,11 @@ static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u return op_ea_seg; } -static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, int stack_offset) +static inline x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, int stack_offset) { uint32_t new_eaaddr; int mod = (fetchdat >> 6) & 3; - int reg = (fetchdat >> 3) & 7; +// int reg = (fetchdat >> 3) & 7; int rm = fetchdat & 7; if (rm == 4) @@ -990,13 +992,13 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u { addbyte(0x8b); /*MOVL EAX, regs[sib&7].l*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[sib & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); } break; case 1: addbyte(0x8b); /*MOVL EAX, regs[sib&7].l*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[sib & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); addbyte(0x83); /*ADDL EAX, imm8*/ addbyte(0xc0 | REG_EAX); addbyte((int8_t)(rmdat >> 16)); @@ -1008,7 +1010,7 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u addlong(new_eaaddr); addbyte(0x03); /*ADDL EAX, regs[sib&7].l*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[sib & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); (*op_pc) += 4; break; } @@ -1035,20 +1037,20 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u case 0: addbyte(0x03); /*ADDL EAX, regs[sib&7].l*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); break; case 1: - addbyte(0x8B); addbyte(0x45 | (REG_EDI << 3)); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL EDI, reg*/ + addbyte(0x8B); addbyte(0x45 | (REG_EDI << 3)); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL EDI, reg*/ addbyte(0x01); addbyte(0xc0 | REG_EAX | (REG_EDI << 3)); /*ADDL EAX, EDI*/ addbyte(0x01); addbyte(0xc0 | REG_EAX | (REG_EDI << 3)); /*ADDL EAX, EDI*/ break; case 2: - addbyte(0x8B); addbyte(0x45 | (REG_EDI << 3)); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL EDI, reg*/ + addbyte(0x8B); addbyte(0x45 | (REG_EDI << 3)); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL EDI, reg*/ addbyte(0xC1); addbyte(0xE0 | REG_EDI); addbyte(2); /*SHL EDI, 2*/ addbyte(0x01); addbyte(0xc0 | REG_EAX | (REG_EDI << 3)); /*ADDL EAX, EDI*/ break; case 3: - addbyte(0x8B); addbyte(0x45 | (REG_EDI << 3)); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL EDI reg*/ + addbyte(0x8B); addbyte(0x45 | (REG_EDI << 3)); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL EDI reg*/ addbyte(0xC1); addbyte(0xE0 | REG_EDI); addbyte(3); /*SHL EDI, 3*/ addbyte(0x01); addbyte(0xc0 | REG_EAX | (REG_EDI << 3)); /*ADDL EAX, EDI*/ break; @@ -1067,7 +1069,7 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u } addbyte(0x8b); /*MOVL EAX, regs[rm].l*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[rm].l)); + addbyte((uint8_t)cpu_state_offset(regs[rm].l)); cpu_state.eaaddr = cpu_state.regs[rm].l; if (mod) { @@ -1092,7 +1094,7 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u return op_ea_seg; } -static x86seg *FETCH_EA(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, uint32_t op_32) +static inline x86seg *FETCH_EA(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, uint32_t op_32) { if (op_32 & 0x200) return FETCH_EA_32(op_ea_seg, fetchdat, op_ssegs, op_pc, 0); @@ -1100,13 +1102,13 @@ static x86seg *FETCH_EA(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint } -static void LOAD_STACK_TO_EA(int off) +static inline void LOAD_STACK_TO_EA(int off) { if (stack32) { addbyte(0x8b); /*MOVL EAX,[ESP]*/ addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_ESP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].l)); if (off) { addbyte(0x83); /*ADD EAX, off*/ @@ -1119,7 +1121,7 @@ static void LOAD_STACK_TO_EA(int off) addbyte(0x0f); /*MOVZX EAX,W[ESP]*/ addbyte(0xb7); addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_ESP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].w)); if (off) { addbyte(0x66); /*ADD AX, off*/ @@ -1129,13 +1131,13 @@ static void LOAD_STACK_TO_EA(int off) } } -static void LOAD_EBP_TO_EA(int off) +static inline void LOAD_EBP_TO_EA(int off) { if (stack32) { addbyte(0x8b); /*MOVL EAX,[EBP]*/ addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_EBP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_EBP].l)); if (off) { addbyte(0x83); /*ADD EAX, off*/ @@ -1148,7 +1150,7 @@ static void LOAD_EBP_TO_EA(int off) addbyte(0x0f); /*MOVZX EAX,W[EBP]*/ addbyte(0xb7); addbyte(0x45 | (REG_EAX << 3)); - addbyte(cpu_state_offset(regs[REG_EBP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_EBP].w)); if (off) { addbyte(0x66); /*ADD AX, off*/ @@ -1158,7 +1160,7 @@ static void LOAD_EBP_TO_EA(int off) } } -static void SP_MODIFY(int off) +static inline void SP_MODIFY(int off) { if (stack32) { @@ -1166,14 +1168,14 @@ static void SP_MODIFY(int off) { addbyte(0x83); /*ADD [ESP], off*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].l)); addbyte(off); } else { addbyte(0x81); /*ADD [ESP], off*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].l)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].l)); addlong(off); } } @@ -1184,7 +1186,7 @@ static void SP_MODIFY(int off) addbyte(0x66); /*ADD [SP], off*/ addbyte(0x83); addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].w)); addbyte(off); } else @@ -1192,14 +1194,14 @@ static void SP_MODIFY(int off) addbyte(0x66); /*ADD [SP], off*/ addbyte(0x81); addbyte(0x45); - addbyte(cpu_state_offset(regs[REG_ESP].w)); + addbyte((uint8_t)cpu_state_offset(regs[REG_ESP].w)); addword(off); } } } -static void TEST_ZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_ZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) { addbyte(0x66); /*CMPW host_reg, 0*/ addbyte(0x83); @@ -1209,19 +1211,19 @@ static void TEST_ZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static void TEST_ZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_ZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) { addbyte(0x83); /*CMPW host_reg, 0*/ addbyte(0xc0 | 0x38 | host_reg); @@ -1230,20 +1232,20 @@ static void TEST_ZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static void TEST_NONZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_NONZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) { addbyte(0x66); /*CMPW host_reg, 0*/ addbyte(0x83); @@ -1253,19 +1255,19 @@ static void TEST_NONZERO_JUMP_W(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) +static inline void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) { addbyte(0x83); /*CMPW host_reg, 0*/ addbyte(0xc0 | 0x38 | host_reg); @@ -1274,30 +1276,30 @@ static void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_cycles) addbyte(7+5+(taken_cycles ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(new_pc); if (taken_cycles) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(taken_cycles); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static inline void BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { case FLAGS_SUB8: addbyte(0x8a); /*MOV AL, flags_op1*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x3a); /*CMP AL, flags_op2*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x76); /*JBE*/ else @@ -1307,11 +1309,11 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no addbyte(0x66); /*MOV AX, flags_op1*/ addbyte(0x8b); addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x66); /*CMP AX, flags_op2*/ addbyte(0x3b); addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x76); /*JBE*/ else @@ -1320,10 +1322,10 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no case FLAGS_SUB32: addbyte(0x8b); /*MOV EAX, flags_op1*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x3b); /*CMP EAX, flags_op2*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x76); /*JBE*/ else @@ -1335,13 +1337,13 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no { addbyte(0x83); /*CMP flags_res, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(flags_res)); + addbyte((uint8_t)cpu_state_offset(flags_res)); addbyte(0); addbyte(0x74); /*JZ +*/ } else { - CALL_FUNC(ZF_SET); + CALL_FUNC((uintptr_t)ZF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x75); /*JNZ +*/ @@ -1350,7 +1352,7 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no addbyte(5+2+2+7+5+(timing_bt ? 4 : 0)); else addbyte(5+2+2); - CALL_FUNC(CF_SET); + CALL_FUNC((uintptr_t)CF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); if (not) @@ -1362,30 +1364,30 @@ static int BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int no addbyte(7+5+(timing_bt ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc+pc_offset+offset); if (timing_bt) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(timing_bt); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static inline void BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { case FLAGS_SUB8: addbyte(0x8a); /*MOV AL, flags_op1*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x3a); /*CMP AL, flags_op2*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x7c); /*JL*/ else @@ -1395,11 +1397,11 @@ static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not addbyte(0x66); /*MOV AX, flags_op1*/ addbyte(0x8b); addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x66); /*CMP AX, flags_op2*/ addbyte(0x3b); addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x7c); /*JL*/ else @@ -1408,10 +1410,10 @@ static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not case FLAGS_SUB32: addbyte(0x8b); /*MOV EAX, flags_op1*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x3b); /*CMP EAX, flags_op2*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x7c); /*JL*/ else @@ -1419,13 +1421,13 @@ static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not break; default: - CALL_FUNC(NF_SET); + CALL_FUNC((uintptr_t)NF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE BL*/ addbyte(0x95); addbyte(0xc3); - CALL_FUNC(VF_SET); + CALL_FUNC((uintptr_t)VF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE AL*/ @@ -1442,30 +1444,30 @@ static int BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, int not addbyte(7+5+(timing_bt ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc+pc_offset+offset); if (timing_bt) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(timing_bt); } addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); } -static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) +static inline void BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { case FLAGS_SUB8: addbyte(0x8a); /*MOV AL, flags_op1*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x3a); /*CMP AL, flags_op2*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x7e); /*JLE*/ else @@ -1475,11 +1477,11 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no addbyte(0x66); /*MOV AX, flags_op1*/ addbyte(0x8b); addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x66); /*CMP AX, flags_op2*/ addbyte(0x3b); addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x7e); /*JLE*/ else @@ -1488,10 +1490,10 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no case FLAGS_SUB32: addbyte(0x8b); /*MOV EAX, flags_op1*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op1)); + addbyte((uint8_t)cpu_state_offset(flags_op1)); addbyte(0x3b); /*CMP EAX, flags_op2*/ addbyte(0x45); - addbyte(cpu_state_offset(flags_op2)); + addbyte((uint8_t)cpu_state_offset(flags_op2)); if (not) addbyte(0x7e); /*JLE*/ else @@ -1503,13 +1505,13 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no { addbyte(0x83); /*CMP flags_res, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(flags_res)); + addbyte((uint8_t)cpu_state_offset(flags_res)); addbyte(0); addbyte(0x74); /*JZ +*/ } else { - CALL_FUNC(ZF_SET); + CALL_FUNC((uintptr_t)ZF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x75); /*JNZ +*/ @@ -1519,13 +1521,13 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no else addbyte(5+2+3+5+2+3+2+2); - CALL_FUNC(NF_SET); + CALL_FUNC((uintptr_t)NF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE BL*/ addbyte(0x95); addbyte(0xc3); - CALL_FUNC(VF_SET); + CALL_FUNC((uintptr_t)VF_SET); addbyte(0x85); /*TEST EAX,EAX*/ addbyte(0xc0); addbyte(0x0f); /*SETNE AL*/ @@ -1542,13 +1544,13 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no addbyte(7+5+(timing_bt ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc+pc_offset+offset); if (timing_bt) { addbyte(0x83); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addbyte(timing_bt); } addbyte(0xe9); /*JMP end*/ @@ -1556,7 +1558,7 @@ static int BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset, int no } -static void FP_ENTER() +static inline void FP_ENTER() { if (codegen_fpu_entered) return; @@ -1569,7 +1571,7 @@ static void FP_ENTER() addbyte(7+7+5+5); addbyte(0xC7); /*MOVL [oldpc],op_old_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(oldpc)); + addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(op_old_pc); addbyte(0xc7); /*MOV [ESP], 7*/ addbyte(0x04); @@ -1583,7 +1585,7 @@ static void FP_ENTER() codegen_fpu_entered = 1; } -static void FP_FLD(int reg) +static inline void FP_FLD(int reg) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -1591,38 +1593,38 @@ static void FP_FLD(int reg) addbyte(0x0f); addbyte(0x7e); addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0xf3); /*MOVQ XMM1, MM[reg][EBP]*/ addbyte(0x0f); addbyte(0x7e); addbyte(0x4d); - addbyte(cpu_state_offset(MM[(cpu_state.TOP + reg) & 7].q)); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP + reg) & 7].q)); addbyte(0x66); /*MOVQ ST[-1][EBP], XMM0*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); addbyte(0x8a); /*MOV AL, tag[reg][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); addbyte(0x66); /*MOVQ MM[-1][EBP], XMM1*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x4d); - addbyte(cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q)); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q)); addbyte(0x88); /*MOV tag[-1][EBP], AL*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); } else { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); if (reg) @@ -1647,46 +1649,46 @@ static void FP_FLD(int reg) addbyte(0xdd); /*FLD [ST+EAX*8]*/ addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x83); /*AND EBX, 7*/ addbyte(0xe3); addbyte(0x07); addbyte(0x8b); /*MOV EDX, [ST_i64+EAX]*/ addbyte(0x54); addbyte(0xc5); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x8b); /*MOV ECX, [ST_i64+4+EAX]*/ addbyte(0x4c); addbyte(0xc5); - addbyte(cpu_state_offset(MM)+4); + addbyte((uint8_t)cpu_state_offset(MM)+4); addbyte(0x8a); /*MOV AL, [tag+EAX]*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x88); /*MOV [tag+EBX], AL*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x89); /*MOV [ST_i64+EBX], EDX*/ addbyte(0x54); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x89); /*MOV [ST_i64+EBX+4], ECX*/ addbyte(0x4c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)+4); + addbyte((uint8_t)cpu_state_offset(MM)+4); addbyte(0x89); /*MOV [TOP], EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } } -static void FP_FST(int reg) +static inline void FP_FST(int reg) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -1694,32 +1696,32 @@ static void FP_FST(int reg) addbyte(0x0f); addbyte(0x7e); addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x8a); /*MOV AL, tag[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(0x66); /*MOVQ ST[reg][EBP], XMM0*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); addbyte(0x88); /*MOV tag[reg][EBP], AL*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); } else { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xdd); /*FLD [ST+EAX*8]*/ addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV BL, [tag+EAX]*/ addbyte(0x5c); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); if (reg) { @@ -1734,15 +1736,15 @@ static void FP_FST(int reg) addbyte(0xdd); /*FSTP [ST+EAX*8]*/ addbyte(0x5c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x88); /*MOV [tag+EAX], BL*/ addbyte(0x5c); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); } } -static void FP_FXCH(int reg) +static inline void FP_FXCH(int reg) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -1750,60 +1752,60 @@ static void FP_FXCH(int reg) addbyte(0x0f); addbyte(0x7e); addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0xf3); /*MOVQ XMM1, ST[reg][EBP]*/ addbyte(0x0f); addbyte(0x7e); addbyte(0x4d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); addbyte(0x66); /*MOVQ ST[reg][EBP], XMM0*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); addbyte(0xf3); /*MOVQ XMM2, MM[0][EBP]*/ addbyte(0x0f); addbyte(0x7e); addbyte(0x55); - addbyte(cpu_state_offset(MM[cpu_state.TOP].q)); + addbyte((uint8_t)cpu_state_offset(MM[cpu_state.TOP].q)); addbyte(0x66); /*MOVQ ST[0][EBP], XMM1*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x4d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0xf3); /*MOVQ XMM3, MM[reg][EBP]*/ addbyte(0x0f); addbyte(0x7e); addbyte(0x5d); - addbyte(cpu_state_offset(MM[(cpu_state.TOP + reg) & 7].q)); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP + reg) & 7].q)); addbyte(0x66); /*MOVQ MM[reg][EBP], XMM2*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x55); - addbyte(cpu_state_offset(MM[(cpu_state.TOP + reg) & 7].q)); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP + reg) & 7].q)); addbyte(0x8a); /*MOV AL, tag[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(0x66); /*MOVQ MM[0][EBP], XMM3*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x5d); - addbyte(cpu_state_offset(MM[cpu_state.TOP].q)); + addbyte((uint8_t)cpu_state_offset(MM[cpu_state.TOP].q)); addbyte(0x8a); /*MOV AH, tag[reg][EBP]*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); addbyte(0x88); /*MOV tag[reg][EBP], AL*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP + reg) & 7])); addbyte(0x88); /*MOV tag[0][EBP], AH*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); } else { addbyte(0x8b); /*MOV EAX, [TOP]*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); addbyte(0x83); /*ADD EAX, reg*/ @@ -1813,38 +1815,38 @@ static void FP_FXCH(int reg) addbyte(0xdd); /*FLD [ST+EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x83); /*AND EAX, 7*/ addbyte(0xe0); addbyte(0x07); addbyte(0xdd); /*FLD [ST+EAX*8]*/ addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xdd); /*FSTP [ST+EAX*8]*/ addbyte(0x5c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV CL, tag[EAX]*/ addbyte(0x4c); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x8a); /*MOV DL, tag[EBX]*/ addbyte(0x54); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x88); /*MOV tag[EBX], CL*/ addbyte(0x4c); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x88); /*MOV tag[EAX], DL*/ addbyte(0x54); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0xbe); /*MOVL ESI, ST_int64*/ addlong((uintptr_t)cpu_state.MM); addbyte(0x8b); /*MOV ECX, ST_int64[EAX*8]*/ @@ -1879,7 +1881,7 @@ static void FP_FXCH(int reg) } -static void FP_LOAD_S() +static inline void FP_LOAD_S() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -1893,22 +1895,22 @@ static void FP_LOAD_S() addbyte(0x24); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0x0f); /*SETE tag[reg][EBP]*/ addbyte(0x94); addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); addbyte(0xdd); /*FSTP ST[reg][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); block_current = block_current; } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -1925,44 +1927,44 @@ static void FP_LOAD_S() addbyte(0xc0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); } } -static void FP_LOAD_D() +static inline void FP_LOAD_D() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0x89); /*MOV ST[reg][EBP], EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); addbyte(0x09); /*OR EAX, EDX*/ addbyte(0xd0); addbyte(0x89); /*MOV ST[reg][EBP]+4, EDX*/ addbyte(0x55); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7]) + 4); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7]) + 4); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0x0f); /*SETE tag[reg][EBP]*/ addbyte(0x94); addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -1986,19 +1988,19 @@ static void FP_LOAD_D() addbyte(0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); } } -static void FP_LOAD_IW() +static inline void FP_LOAD_IW() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2014,21 +2016,21 @@ static void FP_LOAD_IW() addbyte(0x24); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0x0f); /*SETE tag[reg][EBP]*/ addbyte(0x94); addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); addbyte(0xdd); /*FSTP ST[reg][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -2046,19 +2048,19 @@ static void FP_LOAD_IW() addbyte(0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); } } -static void FP_LOAD_IL() +static inline void FP_LOAD_IL() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2072,21 +2074,21 @@ static void FP_LOAD_IL() addbyte(0x24); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0x0f); /*SETE tag[reg][EBP]*/ addbyte(0x94); addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); addbyte(0xdd); /*FSTP ST[reg][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -2104,54 +2106,54 @@ static void FP_LOAD_IL() addbyte(0); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0f); /*SETE [tag+EBX]*/ addbyte(0x94); addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); } } -static void FP_LOAD_IQ() +static inline void FP_LOAD_IQ() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0x89); /*MOV MM[reg][EBP], EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q)); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q)); addbyte(0x09); /*OR EAX, EDX*/ addbyte(0xd0); addbyte(0x89); /*MOV MM[reg][EBP]+4, EDX*/ addbyte(0x55); - addbyte(cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q) + 4); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q) + 4); addbyte(0x0f); /*SETE AL*/ addbyte(0x94); addbyte(0xc0); addbyte(0xdf); /*FILDq MM[reg][EBP]*/ addbyte(0x6d); - addbyte(cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q)); + addbyte((uint8_t)cpu_state_offset(MM[(cpu_state.TOP - 1) & 7].q)); addbyte(0x0c); /*OR AL, TAG_UINT64*/ addbyte(TAG_UINT64); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0x88); /*MOV tag[reg][EBP], AL*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); addbyte(0xdd); /*FSTP ST[reg][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(1); @@ -2161,65 +2163,65 @@ static void FP_LOAD_IQ() addbyte(0x89); /*MOV [ST_i64+EBX*8], EAX*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x09); /*OR EAX, EDX*/ addbyte(0xd0); addbyte(0x89); /*MOV [ST_i64+4+EBX*8], EDX*/ addbyte(0x54); addbyte(0xdd); - addbyte(cpu_state_offset(MM)+4); + addbyte((uint8_t)cpu_state_offset(MM)+4); addbyte(0x83); /*CMP EAX, 0*/ addbyte(0xf8); addbyte(0); addbyte(0xdf); /*FILDl [ST_i64+EBX*8]*/ addbyte(0x6c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0x0f); /*SETE AL*/ addbyte(0x94); addbyte(0xc0); addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x0c); /*OR AL, TAG_UINT64*/ addbyte(TAG_UINT64); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x88); /*MOV [tag+EBX], AL*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); } } -static void FP_LOAD_IMM_Q(uint64_t v) +static inline void FP_LOAD_IMM_Q(uint64_t v) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xc7); /*MOV ST[reg][EBP], v*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7])); addlong(v & 0xffffffff); addbyte(0xc7); /*MOV ST[reg][EBP]+4, v*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP - 1) & 7]) + 4); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP - 1) & 7]) + 4); addlong(v >> 32); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP - 1) & 7); addbyte(0xc6); /*MOVB tag[reg][EBP], 1:0*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP - 1) & 7])); addbyte(v ? 0 : 1); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(1); @@ -2229,37 +2231,37 @@ static void FP_LOAD_IMM_Q(uint64_t v) addbyte(0xc7); /*MOV ST[EBP+EBX*8], v*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addlong(v & 0xffffffff); addbyte(0xc7); /*MOV ST[EBP+EBX*8]+4, v*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST) + 4); + addbyte((uint8_t)cpu_state_offset(ST) + 4); addlong(v >> 32); addbyte(0xc6); /*MOVB tag[reg][EBP], 1:0*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(v ? 0 : 1); addbyte(0x89); /*MOV TOP, EBX*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } } -static int FP_LOAD_REG(int reg) +static inline int FP_LOAD_REG(int reg) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xdd); /*FLD ST[reg][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -2272,7 +2274,7 @@ static int FP_LOAD_REG(int reg) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } addbyte(0xd9); /*FSTP [ESP]*/ addbyte(0x1c); @@ -2284,19 +2286,19 @@ static int FP_LOAD_REG(int reg) return REG_EBX; } -static void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) +static inline void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xdd); /*FLD ST[reg][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + reg) & 7])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -2309,7 +2311,7 @@ static void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } addbyte(0xdd); /*FSTP [ESP]*/ addbyte(0x1c); @@ -2326,11 +2328,11 @@ static void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) *host_reg2 = REG_ECX; } -static int FP_LOAD_REG_INT_W(int reg) +static inline int FP_LOAD_REG_INT_W(int reg) { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -2343,28 +2345,28 @@ static int FP_LOAD_REG_INT_W(int reg) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xd9); /*FLDCW cpu_state.new_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); addbyte(0xdb); /*FISTP [ESP]*/ addbyte(0x1c); addbyte(0x24); addbyte(0xd9); /*FLDCW cpu_state.old_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(old_npxc)); + addbyte((uint8_t)cpu_state_offset(old_npxc)); addbyte(0x8b); /*MOV EBX, [ESP]*/ addbyte(0x1c); addbyte(0x24); return REG_EBX; } -static int FP_LOAD_REG_INT(int reg) +static inline int FP_LOAD_REG_INT(int reg) { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -2377,28 +2379,28 @@ static int FP_LOAD_REG_INT(int reg) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xd9); /*FLDCW cpu_state.new_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); addbyte(0xdb); /*FISTP [ESP]*/ addbyte(0x1c); addbyte(0x24); addbyte(0xd9); /*FLDCW cpu_state.old_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(old_npxc)); + addbyte((uint8_t)cpu_state_offset(old_npxc)); addbyte(0x8b); /*MOV EBX, [ESP]*/ addbyte(0x1c); addbyte(0x24); return REG_EBX; } -static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) +static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); if (reg) { addbyte(0x83); /*ADD EBX, reg*/ @@ -2416,11 +2418,11 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x8b); /*MOV ECX, [ST_i64+EBX*8]*/ addbyte(0x4c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)+4); + addbyte((uint8_t)cpu_state_offset(MM)+4); addbyte(0x8b); /*MOV EBX, [ST_i64+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); return; } @@ -2428,7 +2430,7 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0xf6); /*TEST TAG[EBX], TAG_UINT64*/ addbyte(0x44); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(TAG_UINT64); addbyte(0x74); /*JZ +*/ addbyte(4+4+2); @@ -2436,11 +2438,11 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x8b); /*MOV ECX, [ST_i64+EBX*8]*/ addbyte(0x4c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)+4); + addbyte((uint8_t)cpu_state_offset(MM)+4); addbyte(0x8b); /*MOV EBX, [ST_i64+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(MM)); + addbyte((uint8_t)cpu_state_offset(MM)); addbyte(0xeb); /*JMP done*/ addbyte(4+3+3+3+3+4); @@ -2448,17 +2450,17 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xd9); /*FLDCW cpu_state.new_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); addbyte(0xdf); /*FISTPQ [ESP]*/ addbyte(0x3c); addbyte(0x24); addbyte(0xd9); /*FLDCW cpu_state.old_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(old_npxc)); + addbyte((uint8_t)cpu_state_offset(old_npxc)); addbyte(0x8b); /*MOV EBX, [ESP]*/ addbyte(0x1c); addbyte(0x24); @@ -2471,28 +2473,28 @@ static void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) *host_reg2 = REG_ECX; } -static void FP_POP() +static inline void FP_POP() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xc6); /*MOVB tag[0][EBP], 3*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(3); addbyte(0xc6); /*MOVB TOP[EBP], (TOP-1) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP + 1) & 7); } else { addbyte(0x8b); /*MOV EAX, TOP*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xc6); /*MOVB tag[EAX], 3*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(3); addbyte(0x04); /*ADD AL, 1*/ addbyte(1); @@ -2500,35 +2502,35 @@ static void FP_POP() addbyte(7); addbyte(0x88); /*MOV TOP, AL*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } } -static void FP_POP2() +static inline void FP_POP2() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xc6); /*MOVB tag[0][EBP], 3*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(3); addbyte(0xc6); /*MOVB tag[1][EBP], 3*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[(cpu_state.TOP+1)&7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP+1)&7])); addbyte(3); addbyte(0xc6); /*MOVB TOP[EBP], (TOP+2) & 7*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte((cpu_state.TOP + 2) & 7); } else { addbyte(0x8b); /*MOV EAX, TOP*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xc6); /*MOVB tag[EAX], 3*/ addbyte(0x44); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(3); addbyte(0x04); /*ADD AL, 2*/ addbyte(2); @@ -2536,7 +2538,7 @@ static void FP_POP2() addbyte(7); addbyte(0x88); /*MOV TOP, AL*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); } } @@ -2547,7 +2549,7 @@ static void FP_POP2() #define FPU_SUB 0x20 #define FPU_SUBR 0x28 -static void FP_OP_S(int op) +static inline void FP_OP_S(int op) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2556,34 +2558,34 @@ static void FP_OP_S(int op) addbyte(0x24); addbyte(0xdd); /*FLD ST[dst][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x80); /*AND tag[dst][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(~TAG_UINT64); addbyte(0xd8); /*FADD [ESP]*/ addbyte(0x04 | op); addbyte(0x24); addbyte(0xdd); /*FSTP ST[dst][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EBX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xd8); /*FADD [ESP]*/ addbyte(0x04 | op); @@ -2591,10 +2593,10 @@ static void FP_OP_S(int op) addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } -static void FP_OP_D(int op) +static inline void FP_OP_D(int op) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2609,33 +2611,33 @@ static void FP_OP_D(int op) { addbyte(0xd9); /*FLDCW cpu_state.new_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); } addbyte(0xdd); /*FLD ST[dst][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x80); /*AND tag[dst][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(~TAG_UINT64); addbyte(0xdc); /*FADD [ESP]*/ addbyte(0x04 | op); addbyte(0x24); addbyte(0xdd); /*FSTP ST[dst][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); if (((cpu_state.npxc >> 10) & 3) && op == FPU_ADD) { addbyte(0xd9); /*FLDCW cpu_state.old_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(old_npxc)); + addbyte((uint8_t)cpu_state_offset(old_npxc)); } } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -2643,7 +2645,7 @@ static void FP_OP_D(int op) { addbyte(0xd9); /*FLDCW cpu_state.new_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); } addbyte(0x89); /*MOV [ESP+4], EDX*/ addbyte(0x54); @@ -2652,11 +2654,11 @@ static void FP_OP_D(int op) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EBX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xdc); /*FADD [ESP]*/ addbyte(0x04 | op); @@ -2664,16 +2666,16 @@ static void FP_OP_D(int op) addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); if (((cpu_state.npxc >> 10) & 3) && op == FPU_ADD) { addbyte(0xd9); /*FLDCW cpu_state.old_npxc*/ addbyte(0x6d); - addbyte(cpu_state_offset(old_npxc)); + addbyte((uint8_t)cpu_state_offset(old_npxc)); } } } -static void FP_OP_IW(int op) +static inline void FP_OP_IW(int op) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2683,34 +2685,34 @@ static void FP_OP_IW(int op) addbyte(0x24); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x80); /*AND tag[0][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(~TAG_UINT64); addbyte(0xde); /*FADD [ESP]*/ addbyte(0x04 | op); addbyte(0x24); addbyte(0xdd); /*FSTP ST[0][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EBX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xde); /*FADD [ESP]*/ addbyte(0x04 | op); @@ -2718,10 +2720,10 @@ static void FP_OP_IW(int op) addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } -static void FP_OP_IL(int op) +static inline void FP_OP_IL(int op) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2730,34 +2732,34 @@ static void FP_OP_IL(int op) addbyte(0x24); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x80); /*AND tag[0][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(~TAG_UINT64); addbyte(0xda); /*FADD [ESP]*/ addbyte(0x04 | op); addbyte(0x24); addbyte(0xdd); /*FSTP ST[0][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EBX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xda); /*FADD [ESP]*/ addbyte(0x04 | op); @@ -2765,10 +2767,11 @@ static void FP_OP_IL(int op) addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } -static void FP_OP_IQ(int op) +#if 0 +static inline void FP_OP_IQ(int op) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2781,23 +2784,23 @@ static void FP_OP_IQ(int op) addbyte(0x04); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x80); /*AND tag[0][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(~TAG_UINT64); addbyte(0xdc); /*FADD [ESP]*/ addbyte(0x04 | op); addbyte(0x24); addbyte(0xdd); /*FSTP ST[0][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -2808,11 +2811,11 @@ static void FP_OP_IQ(int op) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EBX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xdc); /*FADD [ESP]*/ addbyte(0x04 | op); @@ -2820,16 +2823,16 @@ static void FP_OP_IQ(int op) addbyte(0xdd); /*FSTP [ST+EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } - +#endif #define C0 (1<<8) #define C1 (1<<9) #define C2 (1<<10) #define C3 (1<<14) -static void FP_COMPARE_S() +static inline void FP_COMPARE_S() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2838,10 +2841,10 @@ static void FP_COMPARE_S() addbyte(0x24); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -2859,23 +2862,23 @@ static void FP_COMPARE_S() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -2893,10 +2896,10 @@ static void FP_COMPARE_S() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } } -static void FP_COMPARE_D() +static inline void FP_COMPARE_D() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2909,10 +2912,10 @@ static void FP_COMPARE_D() addbyte(0x04); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -2930,13 +2933,13 @@ static void FP_COMPARE_D() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); @@ -2947,10 +2950,10 @@ static void FP_COMPARE_D() addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -2968,10 +2971,10 @@ static void FP_COMPARE_D() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } } -static void FP_COMPARE_IW() +static inline void FP_COMPARE_IW() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -2981,10 +2984,10 @@ static void FP_COMPARE_IW() addbyte(0x24); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -3002,23 +3005,23 @@ static void FP_COMPARE_IW() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -3036,10 +3039,10 @@ static void FP_COMPARE_IW() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } } -static void FP_COMPARE_IL() +static inline void FP_COMPARE_IL() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { @@ -3048,10 +3051,10 @@ static void FP_COMPARE_IL() addbyte(0x24); addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -3069,23 +3072,23 @@ static void FP_COMPARE_IL() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } else { addbyte(0x8b); /*MOV EBX, TOP*/ addbyte(0x5d); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV [ESP], EAX*/ addbyte(0x04); addbyte(0x24); addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x8a); /*MOV BL, [npxs+1]*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND BL, ~(C0|C2|C3)*/ @@ -3103,33 +3106,33 @@ static void FP_COMPARE_IL() addbyte(0xe3); addbyte(0x88); /*MOV [npxs+1], BL*/ addbyte(0x5d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } } -static void FP_OP_REG(int op, int dst, int src) +static inline void FP_OP_REG(int op, int dst, int src) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xdd); /*FLD ST[dst][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + dst) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + dst) & 7])); addbyte(0xdc); /*FADD ST[src][EBP]*/ addbyte(0x45 | op); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + src) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + src) & 7])); addbyte(0x80); /*AND tag[dst][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[(cpu_state.TOP + dst) & 7])); + addbyte((uint8_t)cpu_state_offset(tag[(cpu_state.TOP + dst) & 7])); addbyte(~TAG_UINT64); addbyte(0xdd); /*FSTP ST[dst][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + dst) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + dst) & 7])); } else { addbyte(0x8b); /*MOV EAX, TOP*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); if (src || dst) @@ -3147,62 +3150,62 @@ static void FP_OP_REG(int op, int dst, int src) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EBX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x1d); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xdc); /*FADD ST[EAX*8]*/ addbyte(0x44 | op); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xdd); /*FSTP ST[EBX*8]*/ addbyte(0x5c); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } else { addbyte(0xdd); /*FLD [ESI+EAX*8]*/ addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EAX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xdc); /*FADD ST[EBX*8]*/ addbyte(0x44 | op); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xdd); /*FSTP ST[EAX*8]*/ addbyte(0x5c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } } -static void FP_COMPARE_REG(int dst, int src) +static inline void FP_COMPARE_REG(int dst, int src) { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0x8a); /*MOV CL, [npxs+1]*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0xdd); /*FLD ST[dst][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + dst) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + dst) & 7])); addbyte(0x80); /*AND CL, ~(C0|C2|C3)*/ addbyte(0xe1); addbyte((~(C0|C2|C3)) >> 8); addbyte(0xdc); /*FCOMP ST[src][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[(cpu_state.TOP + src) & 7])); + addbyte((uint8_t)cpu_state_offset(ST[(cpu_state.TOP + src) & 7])); addbyte(0xdf); /*FSTSW AX*/ addbyte(0xe0); addbyte(0x80); /*AND AH, (C0|C2|C3)*/ @@ -3212,13 +3215,13 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0xe1); addbyte(0x88); /*MOV [npxs+1], CL*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } else { addbyte(0x8b); /*MOV EAX, TOP*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV EBX, EAX*/ addbyte(0xc3); if (src || dst) @@ -3233,7 +3236,7 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0x8a); /*MOV CL, [npxs+1]*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); addbyte(0xdb); /*FCLEX*/ addbyte(0xe2); addbyte(0x80); /*AND CL, ~(C0|C2|C3)*/ @@ -3245,22 +3248,22 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xdc); /*FCOMP ST[EAX*8]*/ addbyte(0x44 | 0x18); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } else { addbyte(0xdd); /*FLD [ESI+EAX*8]*/ addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0xdc); /*FCOMP ST[EBX*8]*/ addbyte(0x44 | 0x18); addbyte(0xdd); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } addbyte(0xdf); /*FSTSW AX*/ @@ -3272,57 +3275,57 @@ static void FP_COMPARE_REG(int dst, int src) addbyte(0xe1); addbyte(0x88); /*MOV [npxs+1], CL*/ addbyte(0x4d); - addbyte(cpu_state_offset(npxs) + 1); + addbyte((uint8_t)cpu_state_offset(npxs) + 1); } } -static void FP_FCHS() +static inline void FP_FCHS() { if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) { addbyte(0xdd); /*FLD ST[0][EBP]*/ addbyte(0x45); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); addbyte(0xd9); /*FCHS*/ addbyte(0xe0); addbyte(0x80); /*AND tag[dst][EBP], ~TAG_UINT64*/ addbyte(0x65); - addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(tag[cpu_state.TOP])); addbyte(~TAG_UINT64); addbyte(0xdd); /*FSTP ST[dst][EBP]*/ addbyte(0x5d); - addbyte(cpu_state_offset(ST[cpu_state.TOP])); + addbyte((uint8_t)cpu_state_offset(ST[cpu_state.TOP])); } else { addbyte(0x8b); /*MOV EAX, TOP*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0xdd); /*FLD [ESI+EAX*8]*/ addbyte(0x44); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); addbyte(0x80); /*AND tag[EAX], ~TAG_UINT64*/ addbyte(0x64); addbyte(0x05); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(~TAG_UINT64); addbyte(0xd9); /*FCHS*/ addbyte(0xe0); addbyte(0xdd); /*FSTP ST[EAX*8]*/ addbyte(0x5c); addbyte(0xc5); - addbyte(cpu_state_offset(ST)); + addbyte((uint8_t)cpu_state_offset(ST)); } } -static void UPDATE_NPXC(int reg) +static inline void UPDATE_NPXC(int reg) { addbyte(0x66); /*AND cpu_state.new_npxc, ~0xc00*/ addbyte(0x81); addbyte(0x65); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); addword(~0xc00); if (reg) { @@ -3340,24 +3343,24 @@ static void UPDATE_NPXC(int reg) addbyte(0x66); /*OR cpu_state.new_npxc, reg*/ addbyte(0x09); addbyte(0x45 | (reg << 3)); - addbyte(cpu_state_offset(new_npxc)); + addbyte((uint8_t)cpu_state_offset(new_npxc)); } -static int ZERO_EXTEND_W_B(int reg) +static inline int ZERO_EXTEND_W_B(int reg) { addbyte(0x0f); /*MOVZX regl, regb*/ addbyte(0xb6); addbyte(0xc0 | reg | (reg << 3)); return reg; } -static int ZERO_EXTEND_L_B(int reg) +static inline int ZERO_EXTEND_L_B(int reg) { addbyte(0x0f); /*MOVZX regl, regb*/ addbyte(0xb6); addbyte(0xc0 | reg | (reg << 3)); return reg; } -static int ZERO_EXTEND_L_W(int reg) +static inline int ZERO_EXTEND_L_W(int reg) { addbyte(0x0f); /*MOVZX regl, regw*/ addbyte(0xb7); @@ -3365,21 +3368,21 @@ static int ZERO_EXTEND_L_W(int reg) return reg; } -static int SIGN_EXTEND_W_B(int reg) +static inline int SIGN_EXTEND_W_B(int reg) { addbyte(0x0f); /*MOVSX regl, regb*/ addbyte(0xbe); addbyte(0xc0 | reg | (reg << 3)); return reg; } -static int SIGN_EXTEND_L_B(int reg) +static inline int SIGN_EXTEND_L_B(int reg) { addbyte(0x0f); /*MOVSX regl, regb*/ addbyte(0xbe); addbyte(0xc0 | reg | (reg << 3)); return reg; } -static int SIGN_EXTEND_L_W(int reg) +static inline int SIGN_EXTEND_L_W(int reg) { addbyte(0x0f); /*MOVSX regl, regw*/ addbyte(0xbf); @@ -3387,12 +3390,12 @@ static int SIGN_EXTEND_L_W(int reg) return reg; } -static int COPY_REG(int src_reg) +static inline int COPY_REG(int src_reg) { return src_reg; } -static void SET_BITS(uintptr_t addr, uint32_t val) +static inline void SET_BITS(uintptr_t addr, uint32_t val) { if (val & ~0xff) { @@ -3409,7 +3412,7 @@ static void SET_BITS(uintptr_t addr, uint32_t val) addbyte(val); } } -static void CLEAR_BITS(uintptr_t addr, uint32_t val) +static inline void CLEAR_BITS(uintptr_t addr, uint32_t val) { if (val & ~0xff) { @@ -3430,7 +3433,7 @@ static void CLEAR_BITS(uintptr_t addr, uint32_t val) #define LOAD_Q_REG_1 REG_EAX #define LOAD_Q_REG_2 REG_EDX -static void MMX_ENTER() +static inline void MMX_ENTER() { if (codegen_mmx_entered) return; @@ -3443,7 +3446,7 @@ static void MMX_ENTER() addbyte(7+7+5+5); addbyte(0xC7); /*MOVL [oldpc],op_old_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(oldpc)); + addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(op_old_pc); addbyte(0xc7); /*MOV [ESP], 7*/ addbyte(0x04); @@ -3458,35 +3461,35 @@ static void MMX_ENTER() addbyte(0xc0); addbyte(0xc6); /*MOV ISMMX, 1*/ addbyte(0x45); - addbyte(cpu_state_offset(ismmx)); + addbyte((uint8_t)cpu_state_offset(ismmx)); addbyte(1); addbyte(0x89); /*MOV TOP, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(TOP)); + addbyte((uint8_t)cpu_state_offset(TOP)); addbyte(0x89); /*MOV tag, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[0])); + addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x89); /*MOV tag+4, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(tag[4])); + addbyte((uint8_t)cpu_state_offset(tag[4])); codegen_mmx_entered = 1; } extern int mmx_ebx_ecx_loaded; -static int LOAD_MMX_D(int guest_reg) +static inline int LOAD_MMX_D(int guest_reg) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 100; addbyte(0x8b); /*MOV EBX, reg*/ addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); return host_reg; } -static int LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) +static inline void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) { if (!mmx_ebx_ecx_loaded) { @@ -3502,12 +3505,12 @@ static int LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) addbyte(0x8b); /*MOV EBX, reg*/ addbyte(0x45 | ((*host_reg1) << 3)); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); addbyte(0x8b); /*MOV ECX, reg+4*/ addbyte(0x45 | ((*host_reg2) << 3)); - addbyte(cpu_state_offset(MM[guest_reg].l[1])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[1])); } -static int LOAD_MMX_Q_MMX(int guest_reg) +static inline int LOAD_MMX_Q_MMX(int guest_reg) { int dst_reg = find_host_xmm_reg(); host_reg_xmm_mapping[dst_reg] = guest_reg; @@ -3516,12 +3519,12 @@ static int LOAD_MMX_Q_MMX(int guest_reg) addbyte(0x0f); addbyte(0x7e); addbyte(0x45 | (dst_reg << 3)); - addbyte(cpu_state_offset(MM[guest_reg].q)); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); return dst_reg; } -static int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) +static inline int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) { int dst_reg = find_host_xmm_reg(); host_reg_xmm_mapping[dst_reg] = 100; @@ -3542,36 +3545,36 @@ static int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) return dst_reg; } -static void STORE_MMX_LQ(int guest_reg, int host_reg1) +static inline void STORE_MMX_LQ(int guest_reg, int host_reg1) { addbyte(0xC7); /*MOVL [reg],0*/ addbyte(0x45); - addbyte(cpu_state_offset(MM[guest_reg].l[1])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[1])); addlong(0); addbyte(0x89); /*MOVL [reg],host_reg*/ addbyte(0x45 | (host_reg1 << 3)); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); } -static void STORE_MMX_Q(int guest_reg, int host_reg1, int host_reg2) +static inline void STORE_MMX_Q(int guest_reg, int host_reg1, int host_reg2) { addbyte(0x89); /*MOVL [reg],host_reg*/ addbyte(0x45 | (host_reg1 << 3)); - addbyte(cpu_state_offset(MM[guest_reg].l[0])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); addbyte(0x89); /*MOVL [reg],host_reg*/ addbyte(0x45 | (host_reg2 << 3)); - addbyte(cpu_state_offset(MM[guest_reg].l[1])); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[1])); } -static void STORE_MMX_Q_MMX(int guest_reg, int host_reg) +static inline void STORE_MMX_Q_MMX(int guest_reg, int host_reg) { addbyte(0x66); /*MOVQ [guest_reg],host_reg*/ addbyte(0x0f); addbyte(0xd6); addbyte(0x45 | (host_reg << 3)); - addbyte(cpu_state_offset(MM[guest_reg].q)); + addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); } #define MMX_x86_OP(name, opcode) \ -static void MMX_ ## name(int dst_reg, int src_reg) \ +static inline void MMX_ ## name(int dst_reg, int src_reg) \ { \ addbyte(0x66); /*op dst_reg, src_reg*/ \ addbyte(0x0f); \ @@ -3624,7 +3627,7 @@ MMX_x86_OP(PMULLW, 0xd5); MMX_x86_OP(PMULHW, 0xe5); MMX_x86_OP(PMADDWD, 0xf5); -static void MMX_PACKSSWB(int dst_reg, int src_reg) +static inline void MMX_PACKSSWB(int dst_reg, int src_reg) { addbyte(0x66); /*PACKSSWB dst_reg, src_reg*/ addbyte(0x0f); @@ -3636,7 +3639,7 @@ static void MMX_PACKSSWB(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x08); } -static void MMX_PACKUSWB(int dst_reg, int src_reg) +static inline void MMX_PACKUSWB(int dst_reg, int src_reg) { addbyte(0x66); /*PACKUSWB dst_reg, src_reg*/ addbyte(0x0f); @@ -3648,7 +3651,7 @@ static void MMX_PACKUSWB(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x08); } -static void MMX_PACKSSDW(int dst_reg, int src_reg) +static inline void MMX_PACKSSDW(int dst_reg, int src_reg) { addbyte(0x66); /*PACKSSDW dst_reg, src_reg*/ addbyte(0x0f); @@ -3660,7 +3663,7 @@ static void MMX_PACKSSDW(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x08); } -static void MMX_PUNPCKHBW(int dst_reg, int src_reg) +static inline void MMX_PUNPCKHBW(int dst_reg, int src_reg) { addbyte(0x66); /*PUNPCKLBW dst_reg, src_reg*/ addbyte(0x0f); @@ -3672,7 +3675,7 @@ static void MMX_PUNPCKHBW(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x0e); } -static void MMX_PUNPCKHWD(int dst_reg, int src_reg) +static inline void MMX_PUNPCKHWD(int dst_reg, int src_reg) { addbyte(0x66); /*PUNPCKLWD dst_reg, src_reg*/ addbyte(0x0f); @@ -3684,7 +3687,7 @@ static void MMX_PUNPCKHWD(int dst_reg, int src_reg) addbyte(0xc0 | (dst_reg << 3) | dst_reg); addbyte(0x0e); } -static void MMX_PUNPCKHDQ(int dst_reg, int src_reg) +static inline void MMX_PUNPCKHDQ(int dst_reg, int src_reg) { addbyte(0x66); /*PUNPCKLDQ dst_reg, src_reg*/ addbyte(0x0f); @@ -3697,7 +3700,7 @@ static void MMX_PUNPCKHDQ(int dst_reg, int src_reg) addbyte(0x0e); } -static void MMX_PSRLW_imm(int dst_reg, int amount) +static inline void MMX_PSRLW_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRLW dst_reg, amount*/ addbyte(0x0f); @@ -3705,7 +3708,7 @@ static void MMX_PSRLW_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x10); addbyte(amount); } -static void MMX_PSRAW_imm(int dst_reg, int amount) +static inline void MMX_PSRAW_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRAW dst_reg, amount*/ addbyte(0x0f); @@ -3713,7 +3716,7 @@ static void MMX_PSRAW_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x20); addbyte(amount); } -static void MMX_PSLLW_imm(int dst_reg, int amount) +static inline void MMX_PSLLW_imm(int dst_reg, int amount) { addbyte(0x66); /*PSLLW dst_reg, amount*/ addbyte(0x0f); @@ -3722,7 +3725,7 @@ static void MMX_PSLLW_imm(int dst_reg, int amount) addbyte(amount); } -static void MMX_PSRLD_imm(int dst_reg, int amount) +static inline void MMX_PSRLD_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRLD dst_reg, amount*/ addbyte(0x0f); @@ -3730,7 +3733,7 @@ static void MMX_PSRLD_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x10); addbyte(amount); } -static void MMX_PSRAD_imm(int dst_reg, int amount) +static inline void MMX_PSRAD_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRAD dst_reg, amount*/ addbyte(0x0f); @@ -3738,7 +3741,7 @@ static void MMX_PSRAD_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x20); addbyte(amount); } -static void MMX_PSLLD_imm(int dst_reg, int amount) +static inline void MMX_PSLLD_imm(int dst_reg, int amount) { addbyte(0x66); /*PSLLD dst_reg, amount*/ addbyte(0x0f); @@ -3747,7 +3750,7 @@ static void MMX_PSLLD_imm(int dst_reg, int amount) addbyte(amount); } -static void MMX_PSRLQ_imm(int dst_reg, int amount) +static inline void MMX_PSRLQ_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRLQ dst_reg, amount*/ addbyte(0x0f); @@ -3755,7 +3758,7 @@ static void MMX_PSRLQ_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x10); addbyte(amount); } -static void MMX_PSRAQ_imm(int dst_reg, int amount) +static inline void MMX_PSRAQ_imm(int dst_reg, int amount) { addbyte(0x66); /*PSRAQ dst_reg, amount*/ addbyte(0x0f); @@ -3763,7 +3766,7 @@ static void MMX_PSRAQ_imm(int dst_reg, int amount) addbyte(0xc0 | dst_reg | 0x20); addbyte(amount); } -static void MMX_PSLLQ_imm(int dst_reg, int amount) +static inline void MMX_PSLLQ_imm(int dst_reg, int amount) { addbyte(0x66); /*PSLLQ dst_reg, amount*/ addbyte(0x0f); @@ -3773,14 +3776,14 @@ static void MMX_PSLLQ_imm(int dst_reg, int amount) } -static void SAVE_EA() +static inline void SAVE_EA() { addbyte(0x89); /*MOV [ESP+12], EAX*/ addbyte(0x44); addbyte(0x24); addbyte(12); } -static void LOAD_EA() +static inline void LOAD_EA() { addbyte(0x8b); /*MOV EAX, [ESP+12]*/ addbyte(0x44); @@ -3789,7 +3792,7 @@ static void LOAD_EA() } #define MEM_CHECK_WRITE_B MEM_CHECK_WRITE -static void MEM_CHECK_WRITE(x86seg *seg) +static inline void MEM_CHECK_WRITE(x86seg *seg) { CHECK_SEG_WRITE(seg); addbyte(0x8b); /*MOVL ESI, seg->base*/ @@ -3799,7 +3802,7 @@ static void MEM_CHECK_WRITE(x86seg *seg) addlong(mem_check_write - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); LOAD_EA(); } -static void MEM_CHECK_WRITE_W(x86seg *seg) +static inline void MEM_CHECK_WRITE_W(x86seg *seg) { CHECK_SEG_WRITE(seg); addbyte(0x8b); /*MOVL ESI, seg->base*/ @@ -3809,7 +3812,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) addlong(mem_check_write_w - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); LOAD_EA(); } -static void MEM_CHECK_WRITE_L(x86seg *seg) +static inline void MEM_CHECK_WRITE_L(x86seg *seg) { CHECK_SEG_WRITE(seg); addbyte(0x8b); /*MOVL ESI, seg->base*/ @@ -3820,7 +3823,7 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) LOAD_EA(); } -static void LOAD_SEG(int host_reg, void *seg) +static inline void LOAD_SEG(int host_reg, void *seg) { addbyte(0xc7); /*MOV [ESP+4], seg*/ addbyte(0x44); @@ -3830,10 +3833,10 @@ static void LOAD_SEG(int host_reg, void *seg) addbyte(0x89); /*MOV [ESP], host_reg*/ addbyte(0x04 | (host_reg << 3)); addbyte(0x24); - CALL_FUNC(loadseg); + CALL_FUNC((uintptr_t)loadseg); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE end*/ addbyte(0x85); diff --git a/src/codegen_timing_486.c b/src/codegen_timing_486.c index 160c16c..c88f9ca 100644 --- a/src/codegen_timing_486.c +++ b/src/codegen_timing_486.c @@ -254,7 +254,7 @@ static uint8_t last_prefix; static inline int COUNT(int *c, int op_32) { if ((uintptr_t)c <= 10000) - return (int)c; + return (int)(uintptr_t)c; if (((uintptr_t)c & ~0xffff) == (-1 & ~0xffff)) { if (op_32 & 0x100) diff --git a/src/codegen_timing_686.c b/src/codegen_timing_686.c index b606578..efe7917 100644 --- a/src/codegen_timing_686.c +++ b/src/codegen_timing_686.c @@ -855,7 +855,7 @@ void codegen_timing_686_prefix(uint8_t prefix, uint32_t fetchdat) void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32) { - int *timings; + uint32_t *timings; int mod3 = ((fetchdat & 0xc0) == 0xc0); int bit8 = !(opcode & 1); diff --git a/src/codegen_timing_pentium.c b/src/codegen_timing_pentium.c index 436f385..0fbf5e6 100644 --- a/src/codegen_timing_pentium.c +++ b/src/codegen_timing_pentium.c @@ -888,7 +888,7 @@ void codegen_timing_pentium_prefix(uint8_t prefix, uint32_t fetchdat) void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32) { - int *timings; + uint32_t *timings; int mod3 = ((fetchdat & 0xc0) == 0xc0); int bit8 = !(opcode & 1); diff --git a/src/codegen_timing_winchip.c b/src/codegen_timing_winchip.c index a61a5b2..160650e 100644 --- a/src/codegen_timing_winchip.c +++ b/src/codegen_timing_winchip.c @@ -254,7 +254,7 @@ static uint8_t last_prefix; static inline int COUNT(int *c, int op_32) { if ((uintptr_t)c <= 10000) - return (int)c; + return (int)(uintptr_t)c; if (((uintptr_t)c & ~0xffff) == (-1 & ~0xffff)) { if (op_32 & 0x100) diff --git a/src/codegen_x86-64.c b/src/codegen_x86-64.c index 70bdc51..d421c7f 100644 --- a/src/codegen_x86-64.c +++ b/src/codegen_x86-64.c @@ -61,7 +61,6 @@ static int last_ssegs; void codegen_init() { - int c; #ifdef __linux__ void *start; size_t len; @@ -251,7 +250,6 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) void codegen_block_init(uint32_t phys_addr) { codeblock_t *block; - int has_evicted = 0; page_t *page = &pages[phys_addr >> 12]; if (!page->block) @@ -292,7 +290,6 @@ void codegen_block_init(uint32_t phys_addr) void codegen_block_start_recompile(codeblock_t *block) { - int has_evicted = 0; page_t *page = &pages[block->phys >> 12]; if (!page->block) @@ -475,14 +472,14 @@ void codegen_block_end_recompile(codeblock_t *block) { addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addlong((uint32_t)codegen_block_cycles); } if (codegen_block_ins) { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x45); - addbyte(cpu_state_offset(cpu_recomp_ins)); + addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); } #if 0 @@ -529,29 +526,6 @@ void codegen_flush() return; } -static int opcode_conditional_jump[256] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /*00*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*30*/ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*40*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*50*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*60*/ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*90*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*a0*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*b0*/ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*d0*/ - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*e0*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*f0*/ -}; - static int opcode_modrm[256] = { 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*00*/ @@ -611,13 +585,13 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, { addbyte(0xC7); /*MOVL $0,(ssegs)*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); addlong((fetchdat >> 8) & 0xffff); (*op_pc) += 2; } else { - int base_reg, index_reg; + int base_reg = 0, index_reg = 0; switch (cpu_rm) { @@ -721,7 +695,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, } addbyte(0x89); /*MOV eaaddr, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); if (mod1seg[cpu_rm] == &ss && !op_ssegs) op_ea_seg = &_ss; @@ -876,7 +850,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, addbyte(0x89); /*MOV eaaddr, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); } else { @@ -887,7 +861,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); addlong(new_eaaddr); (*op_pc) += 4; return op_ea_seg; @@ -918,14 +892,14 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, } addbyte(0x89); /*MOV eaaddr, EAX*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); } else { addbyte(0x44); /*MOV eaaddr, base_reg*/ addbyte(0x89); addbyte(0x45 | (base_reg << 3)); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); } } return op_ea_seg; @@ -1093,17 +1067,17 @@ generate_call: codegen_timing_opcode(opcode, fetchdat, op_32); if ((op_table == x86_dynarec_opcodes && - ((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 || + ((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 || (opcode & 0xfe) == 0xca || (opcode & 0xfc) == 0xcc || (opcode & 0xfc) == 0xe8 || - (opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30))) || - (op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80)))) + (opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30)))) || + (op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80))) { /*Opcode is likely to cause block to exit, update cycle count*/ if (codegen_block_cycles) { addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addlong((uint32_t)codegen_block_cycles); codegen_block_cycles = 0; } @@ -1111,7 +1085,7 @@ generate_call: { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x45); - addbyte(cpu_state_offset(cpu_recomp_ins)); + addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); codegen_block_ins = 0; } @@ -1152,7 +1126,7 @@ generate_call: last_ssegs = op_ssegs; addbyte(0xC6); /*MOVB $0,(ssegs)*/ addbyte(0x45); - addbyte(cpu_state_offset(ssegs)); + addbyte((uint8_t)cpu_state_offset(ssegs)); addbyte(op_ssegs); } //#if 0 @@ -1171,7 +1145,7 @@ generate_call: addbyte(0xC7); /*MOVL $rm | mod | reg,(rm_mod_reg_data)*/ addbyte(0x45); - addbyte(cpu_state_offset(rm_data.rm_mod_reg_data)); + addbyte((uint8_t)cpu_state_offset(rm_data.rm_mod_reg_data)); addlong(cpu_rm | (cpu_mod << 8) | (cpu_reg << 16)); op_pc += pc_off; @@ -1187,25 +1161,25 @@ generate_call: // last_ea_seg = op_ea_seg; addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/ addbyte(0x45); - addbyte(cpu_state_offset(ea_seg)); - addlong((uint32_t)op_ea_seg); + addbyte((uint8_t)cpu_state_offset(ea_seg)); + addlong((uint32_t)(uintptr_t)op_ea_seg); } addbyte(0xC7); /*MOVL [pc],new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc + pc_off); addbyte(0xC7); /*MOVL $old_pc,(oldpc)*/ addbyte(0x45); - addbyte(cpu_state_offset(oldpc)); + addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(old_pc); if (op_32 != last_op32) { last_op32 = op_32; addbyte(0xC7); /*MOVL $use32,(op32)*/ addbyte(0x45); - addbyte(cpu_state_offset(op32)); + addbyte((uint8_t)cpu_state_offset(op32)); addlong(op_32); } @@ -1219,7 +1193,7 @@ generate_call: addbyte(0x85); /*OR %eax, %eax*/ addbyte(0xc0); addbyte(0x0F); addbyte(0x85); /*JNZ 0*/ - addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4])); + addlong((uint32_t)(uintptr_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(uintptr_t)(&block->data[block_pos + 4])); // call(block, codegen_debug); diff --git a/src/codegen_x86-64.h b/src/codegen_x86-64.h index f90c72f..ed1b50a 100644 --- a/src/codegen_x86-64.h +++ b/src/codegen_x86-64.h @@ -17,7 +17,7 @@ enum OP_RET = 0xc3 }; -#define NR_HOST_REGS 3 +#define NR_HOST_REGS 4 extern int host_reg_mapping[NR_HOST_REGS]; #define NR_HOST_XMM_REGS 7 extern int host_reg_xmm_mapping[NR_HOST_XMM_REGS]; diff --git a/src/codegen_x86.c b/src/codegen_x86.c index 5d7df81..b9893ba 100644 --- a/src/codegen_x86.c +++ b/src/codegen_x86.c @@ -80,7 +80,7 @@ uint32_t mem_check_write_l; static uint32_t gen_MEM_LOAD_ADDR_EA_B() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -115,7 +115,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B() addbyte(8); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*MOVZX EAX, AL*/ addbyte(0xb6); @@ -130,7 +130,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B() static uint32_t gen_MEM_LOAD_ADDR_EA_W() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -172,7 +172,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W() addbyte(8); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*MOVZX EAX, AX*/ addbyte(0xb7); @@ -187,7 +187,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W() static uint32_t gen_MEM_LOAD_ADDR_EA_L() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -228,7 +228,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L() addbyte(8); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -240,7 +240,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L() static uint32_t gen_MEM_LOAD_ADDR_EA_Q() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -285,7 +285,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_Q() addbyte(8); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -297,7 +297,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_Q() static uint32_t gen_MEM_STORE_ADDR_EA_B() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ @@ -333,7 +333,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B() addbyte(12); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -345,7 +345,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B() static uint32_t gen_MEM_STORE_ADDR_EA_W() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ @@ -389,7 +389,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W() addbyte(12); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -401,7 +401,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W() static uint32_t gen_MEM_STORE_ADDR_EA_L() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ @@ -444,7 +444,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L() addbyte(12); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -456,7 +456,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L() static uint32_t gen_MEM_STORE_ADDR_EA_Q() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = EBX/ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EDX, ESI*/ @@ -504,7 +504,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_Q() addbyte(16); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -517,7 +517,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_Q() static char gen_MEM_LOAD_ADDR_EA_B_NO_ABRT_err[] = "gen_MEM_LOAD_ADDR_EA_B_NO_ABRT aborted\n"; static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -553,7 +553,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT() #ifndef RELEASE_BUILD addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); #endif addbyte(0x0f); /*MOVZX ECX, AL*/ @@ -568,7 +568,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT() addbyte(0xc7); /*MOV [ESP], gen_MEM_LOAD_ADDR_EA_B_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); - addlong(gen_MEM_LOAD_ADDR_EA_B_NO_ABRT_err); + addlong((uint32_t)gen_MEM_LOAD_ADDR_EA_B_NO_ABRT_err); addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ @@ -579,7 +579,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT() static char gen_MEM_LOAD_ADDR_EA_W_NO_ABRT_err[] = "gen_MEM_LOAD_ADDR_EA_W_NO_ABRT aborted\n"; static uint32_t gen_MEM_LOAD_ADDR_EA_W_NO_ABRT() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -622,7 +622,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W_NO_ABRT() #ifndef RELEASE_BUILD addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); #endif addbyte(0x0f); /*MOVZX ECX, AX*/ @@ -637,7 +637,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W_NO_ABRT() addbyte(0xc7); /*MOV [ESP], gen_MEM_LOAD_ADDR_EA_W_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); - addlong(gen_MEM_LOAD_ADDR_EA_W_NO_ABRT_err); + addlong((uint32_t)gen_MEM_LOAD_ADDR_EA_W_NO_ABRT_err); addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ @@ -648,7 +648,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W_NO_ABRT() static char gen_MEM_LOAD_ADDR_EA_L_NO_ABRT_err[] = "gen_MEM_LOAD_ADDR_EA_L_NO_ABRT aborted\n"; static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); @@ -692,7 +692,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT() #ifndef RELEASE_BUILD addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x75); /*JNE mem_abrt_rout*/ addbyte(1); @@ -705,7 +705,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT() addbyte(0xc7); /*MOV [ESP], gen_MEM_LOAD_ADDR_EA_L_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); - addlong(gen_MEM_LOAD_ADDR_EA_L_NO_ABRT_err); + addlong((uint32_t)gen_MEM_LOAD_ADDR_EA_L_NO_ABRT_err); addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ @@ -716,7 +716,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT() static char gen_MEM_STORE_ADDR_EA_B_NO_ABRT_err[] = "gen_MEM_STORE_ADDR_EA_B_NO_ABRT aborted\n"; static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ @@ -753,7 +753,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT() #ifndef RELEASE_BUILD addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x75); /*JNE mem_abrt_rout*/ addbyte(1); @@ -763,7 +763,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT() addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_B_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); - addlong(gen_MEM_STORE_ADDR_EA_B_NO_ABRT_err); + addlong((uint32_t)gen_MEM_STORE_ADDR_EA_B_NO_ABRT_err); addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ @@ -774,7 +774,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT() static char gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err[] = "gen_MEM_STORE_ADDR_EA_W_NO_ABRT aborted\n"; static uint32_t gen_MEM_STORE_ADDR_EA_W_NO_ABRT() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ @@ -819,7 +819,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W_NO_ABRT() #ifndef RELEASE_BUILD addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x75); /*JNE mem_abrt_rout*/ addbyte(1); @@ -829,7 +829,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W_NO_ABRT() addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); - addlong(gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err); + addlong((uint32_t)gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err); addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ @@ -840,7 +840,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W_NO_ABRT() static char gen_MEM_STORE_ADDR_EA_L_NO_ABRT_err[] = "gen_MEM_STORE_ADDR_EA_L_NO_ABRT aborted\n"; static uint32_t gen_MEM_STORE_ADDR_EA_L_NO_ABRT() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ @@ -884,17 +884,17 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L_NO_ABRT() #ifndef RELEASE_BUILD addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x75); /*JNE mem_abrt_rout*/ addbyte(1); #endif addbyte(0xc3); /*RET*/ #ifndef RELEASE_BUILD - addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err*/ + addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_L_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); - addlong(gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err); + addlong((uint32_t)gen_MEM_STORE_ADDR_EA_L_NO_ABRT_err); addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ @@ -904,7 +904,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L_NO_ABRT() static uint32_t gen_MEM_CHECK_WRITE() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*seg = ESI, addr = EAX*/ @@ -949,7 +949,7 @@ static uint32_t gen_MEM_CHECK_WRITE() addbyte(8); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -966,7 +966,7 @@ static uint32_t gen_MEM_CHECK_WRITE() static uint32_t gen_MEM_CHECK_WRITE_W() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*seg = ESI, addr = EAX*/ @@ -1030,7 +1030,7 @@ static uint32_t gen_MEM_CHECK_WRITE_W() addbyte(1); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -1048,7 +1048,7 @@ static uint32_t gen_MEM_CHECK_WRITE_W() static uint32_t gen_MEM_CHECK_WRITE_L() { - uint32_t addr = &codeblock[block_current].data[block_pos]; + uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; /*seg = ESI, addr = EAX*/ @@ -1112,7 +1112,7 @@ static uint32_t gen_MEM_CHECK_WRITE_L() addbyte(3); addbyte(0x80); /*CMP abrt, 0*/ addbyte(0x7d); - addbyte(cpu_state_offset(abrt)); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(0); addbyte(0x0f); /*JNE mem_abrt_rout*/ addbyte(0x85); @@ -1130,7 +1130,6 @@ static uint32_t gen_MEM_CHECK_WRITE_L() void codegen_init() { - int c; #ifdef __linux__ void *start; size_t len; @@ -1161,7 +1160,7 @@ void codegen_init() block_current = BLOCK_SIZE; block_pos = 0; - mem_abrt_rout = &codeblock[block_current].data[block_pos]; + mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x83); /*ADDL $16+4,%esp*/ addbyte(0xC4); addbyte(0x10+4); @@ -1171,39 +1170,39 @@ void codegen_init() addbyte(0x5b); /*POP EDX*/ addbyte(0xC3); /*RET*/ block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_l = gen_MEM_LOAD_ADDR_EA_L(); + mem_load_addr_ea_l = (uint32_t)gen_MEM_LOAD_ADDR_EA_L(); block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_w = gen_MEM_LOAD_ADDR_EA_W(); + mem_load_addr_ea_w = (uint32_t)gen_MEM_LOAD_ADDR_EA_W(); block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_b = gen_MEM_LOAD_ADDR_EA_B(); + mem_load_addr_ea_b = (uint32_t)gen_MEM_LOAD_ADDR_EA_B(); block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_q = gen_MEM_LOAD_ADDR_EA_Q(); + mem_load_addr_ea_q = (uint32_t)gen_MEM_LOAD_ADDR_EA_Q(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_l = gen_MEM_STORE_ADDR_EA_L(); + mem_store_addr_ea_l = (uint32_t)gen_MEM_STORE_ADDR_EA_L(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_w = gen_MEM_STORE_ADDR_EA_W(); + mem_store_addr_ea_w = (uint32_t)gen_MEM_STORE_ADDR_EA_W(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_b = gen_MEM_STORE_ADDR_EA_B(); + mem_store_addr_ea_b = (uint32_t)gen_MEM_STORE_ADDR_EA_B(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_q = gen_MEM_STORE_ADDR_EA_Q(); + mem_store_addr_ea_q = (uint32_t)gen_MEM_STORE_ADDR_EA_Q(); block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_b_no_abrt = gen_MEM_LOAD_ADDR_EA_B_NO_ABRT(); + mem_load_addr_ea_b_no_abrt = (uint32_t)gen_MEM_LOAD_ADDR_EA_B_NO_ABRT(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_b_no_abrt = gen_MEM_STORE_ADDR_EA_B_NO_ABRT(); + mem_store_addr_ea_b_no_abrt = (uint32_t)gen_MEM_STORE_ADDR_EA_B_NO_ABRT(); block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_w_no_abrt = gen_MEM_LOAD_ADDR_EA_W_NO_ABRT(); + mem_load_addr_ea_w_no_abrt = (uint32_t)gen_MEM_LOAD_ADDR_EA_W_NO_ABRT(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_w_no_abrt = gen_MEM_STORE_ADDR_EA_W_NO_ABRT(); + mem_store_addr_ea_w_no_abrt = (uint32_t)gen_MEM_STORE_ADDR_EA_W_NO_ABRT(); block_pos = (block_pos + 15) & ~15; - mem_load_addr_ea_l_no_abrt = gen_MEM_LOAD_ADDR_EA_L_NO_ABRT(); + mem_load_addr_ea_l_no_abrt = (uint32_t)gen_MEM_LOAD_ADDR_EA_L_NO_ABRT(); block_pos = (block_pos + 15) & ~15; - mem_store_addr_ea_l_no_abrt = gen_MEM_STORE_ADDR_EA_L_NO_ABRT(); + mem_store_addr_ea_l_no_abrt = (uint32_t)gen_MEM_STORE_ADDR_EA_L_NO_ABRT(); block_pos = (block_pos + 15) & ~15; - mem_check_write = gen_MEM_CHECK_WRITE(); + mem_check_write = (uint32_t)gen_MEM_CHECK_WRITE(); block_pos = (block_pos + 15) & ~15; - mem_check_write_w = gen_MEM_CHECK_WRITE_W(); + mem_check_write_w = (uint32_t)gen_MEM_CHECK_WRITE_W(); block_pos = (block_pos + 15) & ~15; - mem_check_write_l = gen_MEM_CHECK_WRITE_L(); + mem_check_write_l = (uint32_t)gen_MEM_CHECK_WRITE_L(); asm( "fstcw %0\n" @@ -1371,7 +1370,6 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) void codegen_block_init(uint32_t phys_addr) { codeblock_t *block; - int has_evicted = 0; page_t *page = &pages[phys_addr >> 12]; if (!page->block) @@ -1412,7 +1410,6 @@ void codegen_block_init(uint32_t phys_addr) void codegen_block_start_recompile(codeblock_t *block) { - int has_evicted = 0; page_t *page = &pages[block->phys >> 12]; if (!page->block) @@ -1569,14 +1566,14 @@ void codegen_block_end_recompile(codeblock_t *block) { addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addlong(codegen_block_cycles); } if (codegen_block_ins) { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x45); - addbyte(cpu_state_offset(cpu_recomp_ins)); + addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); } #if 0 @@ -1616,29 +1613,6 @@ void codegen_flush() return; } -static int opcode_conditional_jump[256] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /*00*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*30*/ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*40*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*50*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*60*/ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*90*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*a0*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*b0*/ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*d0*/ - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*e0*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*f0*/ -}; - static int opcode_modrm[256] = { 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*00*/ @@ -1698,7 +1672,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, { addbyte(0xC7); /*MOVL $0,(ssegs)*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); addlong((fetchdat >> 8) & 0xffff); (*op_pc) += 2; } @@ -1770,7 +1744,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, { addbyte(0x8b); /*MOVL regs[sib&7].l, %eax*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[sib & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); } break; case 1: @@ -1779,7 +1753,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, addlong(new_eaaddr); addbyte(0x03); /*ADDL regs[sib&7].l, %eax*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[sib & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); (*op_pc)++; break; case 2: @@ -1788,7 +1762,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, addlong(new_eaaddr); addbyte(0x03); /*ADDL regs[sib&7].l, %eax*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[sib & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); (*op_pc) += 4; break; } @@ -1806,20 +1780,20 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, case 0: addbyte(0x03); /*ADDL regs[sib&7].l, %eax*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); + addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); break; case 1: - addbyte(0x8B); addbyte(0x5D); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/ + addbyte(0x8B); addbyte(0x5D); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/ addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/ addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/ break; case 2: - addbyte(0x8B); addbyte(0x5D); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/ + addbyte(0x8B); addbyte(0x5D); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/ addbyte(0xC1); addbyte(0xE3); addbyte(2); /*SHL $2,%ebx*/ addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/ break; case 3: - addbyte(0x8B); addbyte(0x5D); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/ + addbyte(0x8B); addbyte(0x5D); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/ addbyte(0xC1); addbyte(0xE3); addbyte(3); /*SHL $2,%ebx*/ addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/ break; @@ -1835,14 +1809,14 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/ addbyte(0x45); - addbyte(cpu_state_offset(eaaddr)); + addbyte((uint8_t)cpu_state_offset(eaaddr)); addlong(new_eaaddr); (*op_pc) += 4; return op_ea_seg; } addbyte(0x8b); /*MOVL regs[sib&7].l, %eax*/ addbyte(0x45); - addbyte(cpu_state_offset(regs[cpu_rm].l)); + addbyte((uint8_t)cpu_state_offset(regs[cpu_rm].l)); // addbyte(0xa1); /*MOVL regs[cpu_rm].l, %eax*/ // addlong((uint32_t)&cpu_state.regs[cpu_rm].l); cpu_state.eaaddr = cpu_state.regs[cpu_rm].l; @@ -2032,19 +2006,19 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t generate_call: codegen_timing_opcode(opcode, fetchdat, op_32); - + if ((op_table == x86_dynarec_opcodes && - ((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 || + ((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 || (opcode & 0xfe) == 0xca || (opcode & 0xfc) == 0xcc || (opcode & 0xfc) == 0xe8 || - (opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30))) || - (op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80)))) + (opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30)))) || + (op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80))) { /*Opcode is likely to cause block to exit, update cycle count*/ if (codegen_block_cycles) { addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); - addbyte(cpu_state_offset(_cycles)); + addbyte((uint8_t)cpu_state_offset(_cycles)); addlong(codegen_block_cycles); codegen_block_cycles = 0; } @@ -2052,7 +2026,7 @@ generate_call: { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x45); - addbyte(cpu_state_offset(cpu_recomp_ins)); + addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); codegen_block_ins = 0; } @@ -2094,7 +2068,7 @@ generate_call: addbyte(0xC6); /*MOVB [ssegs],op_ssegs*/ addbyte(0x45); - addbyte(cpu_state_offset(ssegs)); + addbyte((uint8_t)cpu_state_offset(ssegs)); addbyte(op_pc + pc_off); } @@ -2113,7 +2087,7 @@ generate_call: addbyte(0xC7); /*MOVL $rm | mod | reg,(rm_mod_reg_data)*/ addbyte(0x45); - addbyte(cpu_state_offset(rm_data.rm_mod_reg_data)); + addbyte((uint8_t)cpu_state_offset(rm_data.rm_mod_reg_data)); addlong(cpu_rm | (cpu_mod << 8) | (cpu_reg << 16)); op_pc += pc_off; @@ -2129,18 +2103,18 @@ generate_call: last_ea_seg = op_ea_seg; addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/ addbyte(0x45); - addbyte(cpu_state_offset(ea_seg)); + addbyte((uint8_t)cpu_state_offset(ea_seg)); addlong((uint32_t)op_ea_seg); } addbyte(0xC7); /*MOVL pc,new_pc*/ addbyte(0x45); - addbyte(cpu_state_offset(pc)); + addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc + pc_off); addbyte(0xC7); /*MOVL $old_pc,(oldpc)*/ addbyte(0x45); - addbyte(cpu_state_offset(oldpc)); + addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(old_pc); if (op_32 != last_op32) @@ -2148,7 +2122,7 @@ generate_call: last_op32 = op_32; addbyte(0xC7); /*MOVL $use32,(op32)*/ addbyte(0x45); - addbyte(cpu_state_offset(op32)); + addbyte((uint8_t)cpu_state_offset(op32)); addlong(op_32); } diff --git a/src/codegen_x86.h b/src/codegen_x86.h index da128d5..c01608e 100644 --- a/src/codegen_x86.h +++ b/src/codegen_x86.h @@ -17,7 +17,7 @@ enum OP_RET = 0xc3 }; -#define NR_HOST_REGS 3 +#define NR_HOST_REGS 4 extern int host_reg_mapping[NR_HOST_REGS]; #define NR_HOST_XMM_REGS 7 extern int host_reg_xmm_mapping[NR_HOST_XMM_REGS]; diff --git a/src/config.c b/src/config.c index f396cef..20e9df4 100644 --- a/src/config.c +++ b/src/config.c @@ -1,6 +1,7 @@ #include #include #include +#include "ibm.h" #include "config.h" char config_file_default[256]; @@ -278,7 +279,6 @@ char *config_get_string(char *head, char *name, char *def) { section_t *section; entry_t *entry; - int value; section = find_section(head); diff --git a/src/cpu.h b/src/cpu.h index 3a15684..4a5a679 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -125,6 +125,7 @@ uint8_t cyrix_read(uint16_t addr, void *priv); extern int is8086; +void cpu_CPUID(); void cpu_RDMSR(); void cpu_WRMSR(); @@ -137,5 +138,7 @@ extern int isa_cycles; #define ISA_CYCLES(x) ((x * isa_cycles) >> ISA_CYCLES_SHIFT) void cpu_update_waitstates(); +void cpu_set(); +void cpu_set_edx(); #endif diff --git a/src/dac.c b/src/dac.c index 44f79df..b24561b 100644 --- a/src/dac.c +++ b/src/dac.c @@ -1,4 +1,5 @@ #include "ibm.h" +#include "dac.h" uint8_t dac,dac2; uint8_t dacctrl; diff --git a/src/dac.h b/src/dac.h new file mode 100644 index 0000000..b873cf6 --- /dev/null +++ b/src/dac.h @@ -0,0 +1,3 @@ +void writedac(uint16_t addr, uint8_t val); +void writedacctrl(uint16_t addr, uint8_t val); +uint8_t readdacfifo(); diff --git a/src/device.c b/src/device.c index b2737c8..65526d5 100644 --- a/src/device.c +++ b/src/device.c @@ -100,7 +100,7 @@ void device_force_redraw() } } -char *device_add_status_info(char *s, int max_len) +void device_add_status_info(char *s, int max_len) { int c; diff --git a/src/device.h b/src/device.h index 60be150..03241f0 100644 --- a/src/device.h +++ b/src/device.h @@ -39,7 +39,7 @@ void device_close_all(); int device_available(device_t *d); void device_speed_changed(); void device_force_redraw(); -char *device_add_status_info(char *s, int max_len); +void device_add_status_info(char *s, int max_len); int device_get_config_int(char *name); char *device_get_config_string(char *name); diff --git a/src/disc.c b/src/disc.c index f9664eb..f4ccb2b 100644 --- a/src/disc.c +++ b/src/disc.c @@ -152,7 +152,7 @@ void disc_poll() int disc_get_bitcell_period(int rate) { - int bit_rate; + int bit_rate = 0; switch (rate) { diff --git a/src/disc.h b/src/disc.h index ab6ab72..a0214e4 100644 --- a/src/disc.h +++ b/src/disc.h @@ -5,7 +5,7 @@ typedef struct void (*writesector)(int drive, int sector, int track, int side, int density, int sector_size); void (*readaddress)(int drive, int track, int side, int density); void (*format)(int drive, int track, int side, int density, uint8_t fill); - uint8_t (*hole)(int drive); + int (*hole)(int drive); void (*stop)(); void (*poll)(); } DRIVE; diff --git a/src/disc_fdi.c b/src/disc_fdi.c index 893a5c1..498a623 100644 --- a/src/disc_fdi.c +++ b/src/disc_fdi.c @@ -107,7 +107,6 @@ void fdi_close(int drive) void fdi_seek(int drive, int track) { - int c; int density; if (!fdi[drive].f) @@ -141,7 +140,7 @@ void fdi_seek(int drive, int track) else { memset(fdi[drive].track_data[1][density], 0, 65536); - fdi[drive].tracklen[1][density] = fdi[drive].tracklen[1][density] = 10000; + fdi[drive].tracklen[1][density] = fdi[drive].trackindex[1][density] = 10000; } } } @@ -332,11 +331,6 @@ void fdi_poll() if (readidpoll) { fdi_sectordat[5 - pollbytesleft] = decodefm(fdi_buffer); - if (fdi_inreadaddr && !fdc_sectorid)// && pollbytesleft > 1) - { -// rpclog("inreadaddr - %02X\n", fdi_sectordat[5 - pollbytesleft]); - fdc_data(fdi_sectordat[5 - pollbytesleft]); - } if (!pollbytesleft) { // pclog("Header over %i,%i %i,%i\n", fdi_sectordat[0], fdi_sectordat[2], fdi_track, fdi_sector); @@ -354,15 +348,9 @@ void fdi_poll() // exit(-1); inreadop = 0; if (fdi_inreadaddr) - { -// rpclog("inreadaddr - %02X\n", fdi_sector); -// fdc_data(fdi_sector); - if (fdc_sectorid) - fdc_sectorid(fdi_sectordat[0], fdi_sectordat[1], fdi_sectordat[2], fdi_sectordat[3], fdi_sectordat[4], fdi_sectordat[5]); - else - fdc_finishread(); - } - else fdc_headercrcerror(); + fdc_sectorid(fdi_sectordat[0], fdi_sectordat[1], fdi_sectordat[2], fdi_sectordat[3], fdi_sectordat[4], fdi_sectordat[5]); + else + fdc_headercrcerror(); return; } // pclog("Sector %i,%i %i,%i\n", fdi_sectordat[0], fdi_sectordat[2], fdi_track, fdi_sector); @@ -375,10 +363,7 @@ void fdi_poll() } if (fdi_inreadaddr) { - if (fdc_sectorid) - fdc_sectorid(fdi_sectordat[0], fdi_sectordat[1], fdi_sectordat[2], fdi_sectordat[3], fdi_sectordat[4], fdi_sectordat[5]); - else - fdc_finishread(); + fdc_sectorid(fdi_sectordat[0], fdi_sectordat[1], fdi_sectordat[2], fdi_sectordat[3], fdi_sectordat[4], fdi_sectordat[5]); fdi_inreadaddr = 0; } } diff --git a/src/disc_img.c b/src/disc_img.c index 88c7546..206eaae 100644 --- a/src/disc_img.c +++ b/src/disc_img.c @@ -318,7 +318,7 @@ void img_seek(int drive, int track) int side; int current_xdft = img[drive].xdf_type - 1; - uint8_t sectors_fat, effective_sectors, sector_gap; /* Needed for XDF */ + uint8_t sectors_fat, effective_sectors; /* Needed for XDF */ if (!img[drive].f) return; @@ -351,7 +351,7 @@ void img_seek(int drive, int track) { sectors_fat = xdf_track0[current_xdft][0]; effective_sectors = xdf_track0[current_xdft][1]; - sector_gap = xdf_track0[current_xdft][2]; +// sector_gap = xdf_track0[current_xdft][2]; if (!track) { diff --git a/src/disc_sector.c b/src/disc_sector.c index ac01fab..8aad435 100644 --- a/src/disc_sector.c +++ b/src/disc_sector.c @@ -1,6 +1,7 @@ #include "ibm.h" #include "disc.h" #include "disc_sector.h" +#include "fdc.h" #include "fdd.h" /*Handling for 'sector based' image formats (like .IMG) as opposed to 'stream based' formats (eg .FDI)*/ diff --git a/src/dma.c b/src/dma.c index 58270f6..faed5db 100644 --- a/src/dma.c +++ b/src/dma.c @@ -5,6 +5,7 @@ #include "io.h" #include "mem.h" #include "video.h" +#include "x86.h" static uint8_t dmaregs[16]; static uint8_t dma16regs[16]; @@ -121,7 +122,7 @@ void dma_write(uint16_t addr, uint8_t val, void *priv) static uint8_t dma_ps2_read(uint16_t addr, void *priv) { - uint8_t temp; + uint8_t temp = 0xff; switch (addr) { diff --git a/src/dosbox/dbopl.cpp b/src/dosbox/dbopl.cpp index 73026f2..df0fc87 100644 --- a/src/dosbox/dbopl.cpp +++ b/src/dosbox/dbopl.cpp @@ -883,6 +883,9 @@ Channel* Channel::BlockTemplate( Chip* chip, Bit32u samples, Bit32s* output ) { return (this + 2); } break; + case sm2Percussion: + case sm3Percussion: + break; } //Init the operators with the the current vibrato and tremolo values Op( 0 )->Prepare( chip ); @@ -954,6 +957,9 @@ Channel* Channel::BlockTemplate( Chip* chip, Bit32u samples, Bit32s* output ) { output[ i * 2 + 0 ] += sample & maskLeft; output[ i * 2 + 1 ] += sample & maskRight; break; + case sm2Percussion: + case sm3Percussion: + break; } } switch( mode ) { diff --git a/src/dosbox/vid_cga_comp.c b/src/dosbox/vid_cga_comp.c index 59c9977..c24f508 100644 --- a/src/dosbox/vid_cga_comp.c +++ b/src/dosbox/vid_cga_comp.c @@ -58,18 +58,11 @@ int video_sharpness; int tandy_mode_control = 0; static bool new_cga = 0; -static bool is_bw = 0; -static bool is_bpp1 = 0; - -static uint8_t comp_pal[256][3]; - -static Bit8u byte_clamp_other(int v) { return v < 0 ? 0 : (v > 255 ? 255 : v); } FILE *df; void update_cga16_color(uint8_t cgamode) { int x; - Bit32u x2; if (!new_cga) { min_v = chroma_multiplexer[0] + intensity[0]; diff --git a/src/fdc.c b/src/fdc.c index 7988846..3714324 100644 --- a/src/fdc.c +++ b/src/fdc.c @@ -3,6 +3,7 @@ #include "ibm.h" #include "disc.h" +#include "disc_sector.h" #include "dma.h" #include "fdd.h" #include "io.h" @@ -94,7 +95,6 @@ void fdc_reset() void fdc_reset_fifo_buf() { - int i = 0; memset(fdc.fifobuf, 0, 16); fdc.fifobufpos = 0; } @@ -304,6 +304,8 @@ static int fdc_get_densel(int drive) case 2: return fdc.densel_polarity ? 0 : 1; } + + return 0; } static void fdc_rate(int drive) diff --git a/src/fdc37c665.c b/src/fdc37c665.c index 46cf1a2..4220c37 100644 --- a/src/fdc37c665.c +++ b/src/fdc37c665.c @@ -36,7 +36,7 @@ void fdc37c665_write(uint16_t port, uint8_t val, void *priv) } else { - uint16_t com3_addr, com4_addr; + uint16_t com3_addr = 0, com4_addr = 0; fdc37c665_regs[fdc37c665_curreg] = val; // pclog("Write superIO %02x %02x %04x(%08x):%08x\n", fdc37c665_curreg, val, CS, cs, pc); diff --git a/src/fdd.c b/src/fdd.c index 7d978a1..7092f70 100644 --- a/src/fdd.c +++ b/src/fdd.c @@ -78,12 +78,8 @@ int fdd_swap = 0; void fdd_seek(int drive, int track_diff) { - int old_track; - drive ^= fdd_swap; - old_track = fdd[drive].track; - fdd[drive].track += track_diff; if (fdd[drive].track < 0) diff --git a/src/fdi2raw.c b/src/fdi2raw.c index f2ac8e7..8dfd819 100644 --- a/src/fdi2raw.c +++ b/src/fdi2raw.c @@ -1813,16 +1813,16 @@ static void fdi2_celltiming (FDI *fdi, uint32_t totalavg, int bitoffset, uae_u16 static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache) { - uae_u8 *p1, *d; + uae_u8 *p1; uae_u32 *p2; uae_u32 *avgp, *minp = 0, *maxp = 0; uae_u8 *idxp = 0; uae_u32 maxidx, totalavg, weakbits; int i, j, len, pulses, indexoffset; int avg_free, min_free = 0, max_free = 0, idx_free; - int idx_off1, idx_off2, idx_off3; + int idx_off1 = 0, idx_off2 = 0, idx_off3 = 0; - d = fdi->track_dst; +// d = fdi->track_dst; p1 = fdi->track_src; pulses = get_u32 (p1); if (!pulses) diff --git a/src/hdd_esdi.c b/src/hdd_esdi.c index 28205e2..db708ec 100644 --- a/src/hdd_esdi.c +++ b/src/hdd_esdi.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "ibm.h" diff --git a/src/i430fx.c b/src/i430fx.c index c5936fe..5b7cf7f 100644 --- a/src/i430fx.c +++ b/src/i430fx.c @@ -1,8 +1,11 @@ #include #include "ibm.h" +#include "io.h" +#include "keyboard_at.h" #include "mem.h" #include "pci.h" +#include "x86.h" #include "i430fx.h" diff --git a/src/i430lx.c b/src/i430lx.c index 3cfbc22..1f6a874 100644 --- a/src/i430lx.c +++ b/src/i430lx.c @@ -1,8 +1,11 @@ #include #include "ibm.h" +#include "io.h" +#include "keyboard_at.h" #include "mem.h" #include "pci.h" +#include "x86.h" #include "i430lx.h" diff --git a/src/ibm.h b/src/ibm.h index 97ea810..c64f71a 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -539,3 +539,23 @@ void resetpc_cad(); extern int start_in_fullscreen; extern int window_w, window_h, window_x, window_y, window_remember; + +void get_executable_name(char *s, int size); + +void startblit(); +void endblit(); + +void set_window_title(char *s); + +void updatewindowsize(int x, int y); + +void initpc(int argc, char *argv[]); +void runpc(); +void closepc(); +void resetpc(); +void resetpchard(); +void speedchanged(); + +void saveconfig(); + +#define UNUSED(x) (void)x diff --git a/src/ide.c b/src/ide.c index c42ee7e..766a683 100644 --- a/src/ide.c +++ b/src/ide.c @@ -1111,7 +1111,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) uint8_t readide(int ide_board, uint16_t addr) { IDE *ide = &ide_drives[cur_ide[ide_board]]; - uint8_t temp; + uint8_t temp = 0xff; uint16_t tempw; addr|=0x80; @@ -1784,8 +1784,6 @@ static uint32_t atapi_event_status(IDE *ide, uint8_t *buffer) return 8; } -static int changed_status = 0; - void atapi_cmd_error(IDE *ide, uint8_t sensekey, uint8_t asc) { ide->error = (sensekey << 4); @@ -1994,9 +1992,9 @@ static void atapicommand(int ide_board) break; case GPCMD_MECHANISM_STATUS: /*0xbd*/ - len=(idebufferb[7]<<16)|(idebufferb[8]<<8)|idebufferb[9]; + alloc_length = (idebufferb[7]<<16)|(idebufferb[8]<<8)|idebufferb[9]; - if (len == 0) + if (alloc_length == 0) fatal("Zero allocation length to MECHANISM STATUS not impl.\n"); atapi_command_send_init(ide, idebufferb[0], 8, alloc_length); @@ -2293,7 +2291,7 @@ static void atapicommand(int ide_board) case GPCMD_GET_EVENT_STATUS_NOTIFICATION: /*0x4a*/ temp_command = idebufferb[0]; - alloc_length = len; + alloc_length = (idebufferb[7]<<16)|(idebufferb[8]<<8)|idebufferb[9]; { struct __attribute__((__packed__)) @@ -2613,7 +2611,7 @@ atapi_out: break; case GPCMD_READ_CDROM_CAPACITY: - atapi_command_send_init(ide, temp_command, 8, 8); + atapi_command_send_init(ide, 0, 8, 8); size = atapi->size(); idebufferb[0] = (size >> 24) & 0xff; idebufferb[1] = (size >> 16) & 0xff; @@ -2629,7 +2627,6 @@ atapi_out: case GPCMD_SEND_DVD_STRUCTURE: default: -bad_atapi_command: ide->atastat = READY_STAT | ERR_STAT; /*CHECK CONDITION*/ ide->error = (SENSE_ILLEGAL_REQUEST << 4) | ABRT_ERR; if (atapi_sense.sensekey == SENSE_UNIT_ATTENTION) diff --git a/src/ide.h b/src/ide.h index 1335a84..ae1ab63 100644 --- a/src/ide.h +++ b/src/ide.h @@ -53,6 +53,9 @@ extern char ide_fn[4][512]; extern int cdrom_channel; +uint32_t atapi_get_cd_channel(int channel); +uint32_t atapi_get_cd_volume(int channel); + #define CDROM_ISO 200 #endif //__IDE__ diff --git a/src/io.c b/src/io.c index 387c391..318575c 100644 --- a/src/io.c +++ b/src/io.c @@ -20,11 +20,20 @@ void io_init() pclog("io_init\n"); for (c = 0; c < 0x10000; c++) { - port_inb[c][0] = port_inw[c][0] = port_inl[c][0] = NULL; - port_outb[c][0] = port_outw[c][0] = port_outl[c][0] = NULL; - port_inb[c][1] = port_inw[c][1] = port_inl[c][1] = NULL; - port_outb[c][1] = port_outw[c][1] = port_outl[c][1] = NULL; - port_priv[c][0] = port_priv[c][1] = NULL; + port_inb[c][0] = NULL; + port_inw[c][0] = NULL; + port_inl[c][0] = NULL; + port_outb[c][0] = NULL; + port_outw[c][0] = NULL; + port_outl[c][0] = NULL; + port_inb[c][1] = NULL; + port_inw[c][1] = NULL; + port_inl[c][1] = NULL; + port_outb[c][1] = NULL; + port_outw[c][1] = NULL; + port_outl[c][1] = NULL; + port_priv[c][0] = NULL; + port_priv[c][1] = NULL; } } diff --git a/src/joystick_ch_flightstick_pro.c b/src/joystick_ch_flightstick_pro.c index 451643c..5016d0e 100644 --- a/src/joystick_ch_flightstick_pro.c +++ b/src/joystick_ch_flightstick_pro.c @@ -8,6 +8,7 @@ static void *ch_flightstick_pro_init() { + return NULL; } static void ch_flightstick_pro_close(void *p) @@ -64,6 +65,7 @@ static int ch_flightstick_pro_read_axis(void *p, int axis) case 3: return joystick_state[0].axis[2]; } + return 0; } static void ch_flightstick_pro_a0_over(void *p) diff --git a/src/joystick_standard.c b/src/joystick_standard.c index ac0e9ba..5965926 100644 --- a/src/joystick_standard.c +++ b/src/joystick_standard.c @@ -8,6 +8,7 @@ static void *joystick_standard_init() { + return NULL; } static void joystick_standard_close(void *p) @@ -80,6 +81,7 @@ static int joystick_standard_read_axis(void *p, int axis) return AXIS_NOT_PRESENT; return joystick_state[1].axis[1]; } + return 0; } static int joystick_standard_read_axis_4button(void *p, int axis) @@ -98,6 +100,7 @@ static int joystick_standard_read_axis_4button(void *p, int axis) case 3: return 0; } + return 0; } static int joystick_standard_read_axis_6button(void *p, int axis) { @@ -115,6 +118,7 @@ static int joystick_standard_read_axis_6button(void *p, int axis) case 3: return joystick_state[0].button[5] ? -32767 : 32768; } + return 0; } static int joystick_standard_read_axis_8button(void *p, int axis) { @@ -140,6 +144,7 @@ static int joystick_standard_read_axis_8button(void *p, int axis) return 32768; return 0; } + return 0; } static void joystick_standard_a0_over(void *p) diff --git a/src/joystick_tm_fcs.c b/src/joystick_tm_fcs.c index e757726..42948d7 100644 --- a/src/joystick_tm_fcs.c +++ b/src/joystick_tm_fcs.c @@ -8,6 +8,7 @@ static void *tm_fcs_init() { + return NULL; } static void tm_fcs_close(void *p) @@ -63,6 +64,7 @@ static int tm_fcs_read_axis(void *p, int axis) return 16384; return 0; } + return 0; } static void tm_fcs_a0_over(void *p) diff --git a/src/keyboard.h b/src/keyboard.h index 10f849b..5d5283c 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -1,5 +1,6 @@ extern void (*keyboard_send)(uint8_t val); extern void (*keyboard_poll)(); +void keyboard_process(); extern int keyboard_scan; extern int pcem_key[272]; diff --git a/src/keyboard_amstrad.c b/src/keyboard_amstrad.c index c6e9555..e7647f4 100644 --- a/src/keyboard_amstrad.c +++ b/src/keyboard_amstrad.c @@ -110,7 +110,7 @@ void keyboard_amstrad_write(uint16_t port, uint8_t val, void *priv) uint8_t keyboard_amstrad_read(uint16_t port, void *priv) { - uint8_t temp; + uint8_t temp = 0xff; // pclog("keyboard_amstrad : read %04X ", port); switch (port) { diff --git a/src/keyboard_at.c b/src/keyboard_at.c index 9976b66..edf2a00 100644 --- a/src/keyboard_at.c +++ b/src/keyboard_at.c @@ -6,6 +6,7 @@ #include "sound.h" #include "sound_speaker.h" #include "timer.h" +#include "x86.h" #include "keyboard.h" #include "keyboard_at.h" diff --git a/src/keyboard_at.h b/src/keyboard_at.h index 93411af..6271e75 100644 --- a/src/keyboard_at.h +++ b/src/keyboard_at.h @@ -3,6 +3,7 @@ void keyboard_at_init_ps2(); void keyboard_at_reset(); void keyboard_at_poll(); void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p); +void keyboard_at_adddata_mouse(uint8_t val); extern int mouse_queue_start, mouse_queue_end; extern int mouse_scan; diff --git a/src/keyboard_olim24.c b/src/keyboard_olim24.c index 9a1e646..e86241d 100644 --- a/src/keyboard_olim24.c +++ b/src/keyboard_olim24.c @@ -1,8 +1,10 @@ +#include #include "ibm.h" #include "io.h" #include "mem.h" #include "mouse.h" #include "pic.h" +#include "pit.h" #include "sound.h" #include "sound_speaker.h" #include "timer.h" @@ -159,7 +161,7 @@ void keyboard_olim24_write(uint16_t port, uint8_t val, void *priv) uint8_t keyboard_olim24_read(uint16_t port, void *priv) { - uint8_t temp; + uint8_t temp = 0xff; // pclog("keyboard_olim24 : read %04X ", port); switch (port) { diff --git a/src/keyboard_pcjr.c b/src/keyboard_pcjr.c index c234ee1..13f443b 100644 --- a/src/keyboard_pcjr.c +++ b/src/keyboard_pcjr.c @@ -4,6 +4,7 @@ #include "mem.h" #include "nmi.h" #include "pic.h" +#include "pit.h" #include "sound.h" #include "sound_sn76489.h" #include "sound_speaker.h" @@ -155,7 +156,7 @@ void keyboard_pcjr_write(uint16_t port, uint8_t val, void *priv) uint8_t keyboard_pcjr_read(uint16_t port, void *priv) { - uint8_t temp; + uint8_t temp = 0xff; // pclog("keyboard_pcjr : read %04X ", port); switch (port) { diff --git a/src/keyboard_xt.c b/src/keyboard_xt.c index b310b46..d7e69bd 100644 --- a/src/keyboard_xt.c +++ b/src/keyboard_xt.c @@ -1,9 +1,12 @@ #include "ibm.h" +#include "device.h" #include "io.h" #include "mem.h" #include "pic.h" +#include "pit.h" #include "sound.h" #include "sound_speaker.h" +#include "tandy_eeprom.h" #include "timer.h" #include "keyboard.h" @@ -99,7 +102,7 @@ void keyboard_xt_write(uint16_t port, uint8_t val, void *priv) uint8_t keyboard_xt_read(uint16_t port, void *priv) { - uint8_t temp; + uint8_t temp = 0xff; // pclog("keyboard_xt : read %04X ", port); switch (port) { diff --git a/src/lpt.c b/src/lpt.c index b7b7d54..5550a98 100644 --- a/src/lpt.c +++ b/src/lpt.c @@ -1,4 +1,5 @@ #include "ibm.h" +#include "dac.h" #include "io.h" #include "lpt.h" @@ -11,11 +12,11 @@ void lpt1_write(uint16_t port, uint8_t val, void *priv) switch (port & 3) { case 0: - writedac(val); + writedac(0,val); lpt1_dat = val; break; case 2: - writedacctrl(val); + writedacctrl(0,val); lpt1_ctrl = val; break; } @@ -39,11 +40,11 @@ void lpt2_write(uint16_t port, uint8_t val, void *priv) switch (port & 3) { case 0: - writedac(val); + writedac(0,val); lpt2_dat = val; break; case 2: - writedacctrl(val); + writedacctrl(0,val); lpt2_ctrl = val; break; } diff --git a/src/mca.c b/src/mca.c index 3c57a7b..ebd8ccb 100644 --- a/src/mca.c +++ b/src/mca.c @@ -15,7 +15,11 @@ void mca_init(int nr_cards) int c; for (c = 0; c < 8; c++) - mca_card_read[c] = mca_card_write[c] = mca_priv[c] = NULL; + { + mca_card_read[c] = NULL; + mca_card_write[c] = NULL; + mca_priv[c] = NULL; + } mca_index = 0; mca_nr_cards = nr_cards; diff --git a/src/mem.c b/src/mem.c index f4c0780..469ebe3 100644 --- a/src/mem.c +++ b/src/mem.c @@ -1534,6 +1534,7 @@ static inline int mem_mapping_read_allowed(uint32_t flags, int state) default: fatal("mem_mapping_read_allowed : bad state %x\n", state); } + return 0; } static inline int mem_mapping_write_allowed(uint32_t flags, int state) @@ -1551,6 +1552,7 @@ static inline int mem_mapping_write_allowed(uint32_t flags, int state) default: fatal("mem_mapping_write_allowed : bad state %x\n", state); } + return 0; } static void mem_mapping_recalc(uint64_t base, uint64_t size) diff --git a/src/mem.h b/src/mem.h index 1e59cdc..060a82b 100644 --- a/src/mem.h +++ b/src/mem.h @@ -166,4 +166,21 @@ extern mem_mapping_t ram_low_mapping; void mem_remap_top_256k(); void mem_remap_top_384k(); +void mem_flush_write_page(uint32_t addr, uint32_t virt); + +void mem_add_bios(); + +void mem_init(); +void mem_resize(); + +void flushmmucache(); +void flushmmucache_nopc(); +void flushmmucache_cr3(); + +void resetreadlookup(); + +void mmu_invalidate(uint32_t addr); + +int loadbios(); + #endif diff --git a/src/mfm_at.c b/src/mfm_at.c index e9f610f..f2099a1 100644 --- a/src/mfm_at.c +++ b/src/mfm_at.c @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -380,7 +381,7 @@ void mfm_writew(uint16_t port, uint16_t val, void *p) uint8_t mfm_read(uint16_t port, void *p) { mfm_t *mfm = (mfm_t *)p; - uint8_t temp; + uint8_t temp = 0xff; switch (port) { diff --git a/src/mfm_xebec.c b/src/mfm_xebec.c index 5f5a788..6a27936 100644 --- a/src/mfm_xebec.c +++ b/src/mfm_xebec.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "ibm.h" diff --git a/src/model.c b/src/model.c index 735bd61..530b58c 100644 --- a/src/model.c +++ b/src/model.c @@ -27,6 +27,8 @@ #include "keyboard_pcjr.h" #include "keyboard_xt.h" #include "lpt.h" +#include "mem.h" +#include "mouse_ps2.h" #include "neat.h" #include "nmi.h" #include "nvr.h" @@ -87,52 +89,52 @@ int AMSTRAD, AT, PCI, TANDY; MODEL models[] = { - {"IBM PC", ROM_IBMPC, "ibmpc", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"IBM XT", ROM_IBMXT, "ibmxt", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"IBM PCjr", ROM_IBMPCJR, "ibmpcjr", { "", cpus_pcjr, "", NULL, "", NULL}, 1, 0, 128, 640, 64, pcjr_init, &pcjr_device}, - {"Generic XT clone", ROM_GENXT, "genxt", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"AMI XT clone", ROM_AMIXT, "amixt", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"DTK XT clone", ROM_DTKXT, "dtk", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"VTech Laser Turbo XT", ROM_LTXT, "ltxt", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"VTech Laser XT3", ROM_LXT3, "lxt3", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"Phoenix XT clone", ROM_PXXT, "pxxt", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"Juko XT clone", ROM_JUKOPC, "jukopc", { "", cpus_8088, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"Tandy 1000", ROM_TANDY, "tandy", { "", cpus_8088, "", NULL, "", NULL}, 1, 0, 128, 640, 128, tandy1k_init, &tandy1000_device}, - {"Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", { "", cpus_8088, "", NULL, "", NULL}, 1, 0, 256, 640, 128, tandy1k_init, &tandy1000hx_device}, - {"Tandy 1000 SL/2", ROM_TANDY1000SL2, "tandy1000sl2", { "", cpus_8086, "", NULL, "", NULL}, 1, 0, 512, 768, 128, tandy1ksl2_init, NULL}, - {"Amstrad PC1512", ROM_PC1512, "pc1512", { "", cpus_pc1512, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, - {"Sinclair PC200", ROM_PC200, "pc200", { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, - {"Euro PC", ROM_EUROPC, "europc", { "", cpus_8086, "", NULL, "", NULL}, 0, 0, 512, 640, 128, europc_init, NULL}, - {"Olivetti M24", ROM_OLIM24, "olivetti_m24", { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_OLIM24, 128, 640, 128, olim24_init, NULL}, - {"Amstrad PC1640", ROM_PC1640, "pc1640", { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, - {"Amstrad PC2086", ROM_PC2086, "pc2086", { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, - {"Amstrad PC3086", ROM_PC3086, "pc3086", { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, - {"IBM AT", ROM_IBMAT, "ibmat", { "", cpus_ibmat, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, - {"Commodore PC 30 III", ROM_CMDPC30, "cmdpc30", { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_ide_init, NULL}, - {"AMI 286 clone", ROM_AMI286, "ami286", { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_neat_init, NULL}, - {"Award 286 clone", ROM_AWARD286, "award286", { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_scat_init, NULL}, - {"DELL System 200", ROM_DELL200, "dells200", { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, - {"IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibmps1es", { "", cpus_ps1_m2011, "", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, ps1_m2011_init, NULL}, - {"IBM PS/2 Model 30-286", ROM_IBMPS2_M30_286, "ibmps2_m30_286", { "", cpus_ps2_m30_286, "", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, ps2_m30_286_init, NULL}, - {"IBM PS/2 Model 50", ROM_IBMPS2_M50, "ibmps2_m50", { "", cpus_ps2_m30_286, "", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2|MODEL_MCA, 1, 16, 1, ps2_model_50_init, NULL}, - {"IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC}, 1, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 16, 1, ps1_m2121_init, NULL}, - {"Compaq Deskpro 386", ROM_DESKPRO_386, "deskpro386", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, MODEL_AT, 1, 15, 1, deskpro386_init, NULL}, - {"IBM PS/2 Model 55SX", ROM_IBMPS2_M55SX, "ibmps2_m55sx", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC}, 1, MODEL_AT|MODEL_PS2|MODEL_MCA, 1, 8, 1, ps2_model_55sx_init, NULL}, - {"Acer 386SX25/N", ROM_ACER386, "acer386", { "Intel", cpus_acer, "", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 16, 1, at_acer386sx_init, NULL}, - {"DTK 386SX clone", ROM_DTK386, "dtk386", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_neat_init, NULL}, + {"IBM PC", ROM_IBMPC, "ibmpc", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"IBM XT", ROM_IBMXT, "ibmxt", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"IBM PCjr", ROM_IBMPCJR, "ibmpcjr", { {"", cpus_pcjr}, {"", NULL}, {"", NULL}}, 1, 0, 128, 640, 64, pcjr_init, &pcjr_device}, + {"Generic XT clone", ROM_GENXT, "genxt", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"AMI XT clone", ROM_AMIXT, "amixt", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"DTK XT clone", ROM_DTKXT, "dtk", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"VTech Laser Turbo XT", ROM_LTXT, "ltxt", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"VTech Laser XT3", ROM_LXT3, "lxt3", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"Phoenix XT clone", ROM_PXXT, "pxxt", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"Juko XT clone", ROM_JUKOPC, "jukopc", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, xt_init, NULL}, + {"Tandy 1000", ROM_TANDY, "tandy", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 1, 0, 128, 640, 128, tandy1k_init, &tandy1000_device}, + {"Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, 1, 0, 256, 640, 128, tandy1k_init, &tandy1000hx_device}, + {"Tandy 1000 SL/2", ROM_TANDY1000SL2, "tandy1000sl2", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 1, 0, 512, 768, 128, tandy1ksl2_init, NULL}, + {"Amstrad PC1512", ROM_PC1512, "pc1512", { {"", cpus_pc1512}, {"", NULL}, {"", NULL}}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, + {"Sinclair PC200", ROM_PC200, "pc200", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, + {"Euro PC", ROM_EUROPC, "europc", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 0, 0, 512, 640, 128, europc_init, NULL}, + {"Olivetti M24", ROM_OLIM24, "olivetti_m24", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 1, MODEL_OLIM24, 128, 640, 128, olim24_init, NULL}, + {"Amstrad PC1640", ROM_PC1640, "pc1640", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, + {"Amstrad PC2086", ROM_PC2086, "pc2086", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, + {"Amstrad PC3086", ROM_PC3086, "pc3086", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, + {"IBM AT", ROM_IBMAT, "ibmat", { {"", cpus_ibmat}, {"", NULL}, {"", NULL}}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, + {"Commodore PC 30 III", ROM_CMDPC30, "cmdpc30", { {"", cpus_286}, {"", NULL}, {"", NULL}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_ide_init, NULL}, + {"AMI 286 clone", ROM_AMI286, "ami286", { {"", cpus_286}, {"", NULL}, {"", NULL}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_neat_init, NULL}, + {"Award 286 clone", ROM_AWARD286, "award286", { {"", cpus_286}, {"", NULL}, {"", NULL}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_scat_init, NULL}, + {"DELL System 200", ROM_DELL200, "dells200", { {"", cpus_286}, {"", NULL}, {"", NULL}}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, + {"IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibmps1es", { {"", cpus_ps1_m2011}, {"", NULL}, {"", NULL}}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, ps1_m2011_init, NULL}, + {"IBM PS/2 Model 30-286", ROM_IBMPS2_M30_286, "ibmps2_m30_286", { {"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, ps2_m30_286_init, NULL}, + {"IBM PS/2 Model 50", ROM_IBMPS2_M50, "ibmps2_m50", { {"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}}, 1, MODEL_AT|MODEL_PS2|MODEL_MCA, 1, 16, 1, ps2_model_50_init, NULL}, + {"IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", { {"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}}, 1, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 16, 1, ps1_m2121_init, NULL}, + {"Compaq Deskpro 386", ROM_DESKPRO_386, "deskpro386", { {"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}}, 0, MODEL_AT, 1, 15, 1, deskpro386_init, NULL}, + {"IBM PS/2 Model 55SX", ROM_IBMPS2_M55SX, "ibmps2_m55sx", { {"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}}, 1, MODEL_AT|MODEL_PS2|MODEL_MCA, 1, 8, 1, ps2_model_55sx_init, NULL}, + {"Acer 386SX25/N", ROM_ACER386, "acer386", { {"Intel", cpus_acer}, {"", NULL}, {"", NULL}}, 1, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 16, 1, at_acer386sx_init, NULL}, + {"DTK 386SX clone", ROM_DTK386, "dtk386", { {"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 16, 1, at_neat_init, NULL}, /* {"Phoenix 386 clone", ROM_PX386, { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC}, 0, MODEL_AT, 1, 16, 1, at_init, NULL},*/ - {"Amstrad MegaPC", ROM_MEGAPC, "megapc", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC}, 1, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 16, 1, at_wd76c10_init, NULL}, - {"AMI 386SX clone", ROM_AMI386SX, "ami386", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_headland_init, NULL}, - {"MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_opti495_init, NULL}, - {"AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_opti495_init, NULL}, - {"AMI 486 clone", ROM_AMI486, "ami486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_ali1429_init, NULL}, - {"AMI WinBIOS 486", ROM_WIN486, "win486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_ali1429_init, NULL}, + {"Amstrad MegaPC", ROM_MEGAPC, "megapc", { {"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}}, 1, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 16, 1, at_wd76c10_init, NULL}, + {"AMI 386SX clone", ROM_AMI386SX, "ami386", { {"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_headland_init, NULL}, + {"MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", { {"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_opti495_init, NULL}, + {"AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", { {"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_opti495_init, NULL}, + {"AMI 486 clone", ROM_AMI486, "ami486", { {"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_ali1429_init, NULL}, + {"AMI WinBIOS 486", ROM_WIN486, "win486", { {"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_ali1429_init, NULL}, /* {"AMI WinBIOS 486 PCI", ROM_PCI486, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, 1, 1, 256, 1, at_um8881f_init},*/ - {"Award SiS 496/497", ROM_SIS496, "sis496", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_sis496_init, NULL}, - {"Intel Premiere/PCI", ROM_REVENGE, "revenge", { "Intel", cpus_Pentium5V, "", NULL, "", NULL}, 0, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 128, 1, at_batman_init, NULL}, - {"Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "Cyrix", cpus_6x86}, 0, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 128, 1, at_endeavor_init, NULL}, - {"Award 430VX PCI", ROM_430VX, "430vx", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86}, 0, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 256, 1, at_i430vx_init, NULL}, - {"", -1, "", {"", 0, "", 0, "", 0}, 0,0,0, 0} + {"Award SiS 496/497", ROM_SIS496, "sis496", { {"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}}, 0, MODEL_AT|MODEL_HAS_IDE, 1, 256, 1, at_sis496_init, NULL}, + {"Intel Premiere/PCI", ROM_REVENGE, "revenge", { {"Intel", cpus_Pentium5V}, {"", NULL}, {"", NULL}}, 0, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 128, 1, at_batman_init, NULL}, + {"Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", { {"Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"Cyrix", cpus_6x86}}, 0, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 128, 1, at_endeavor_init, NULL}, + {"Award 430VX PCI", ROM_430VX, "430vx", { {"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"Cyrix", cpus_6x86}}, 0, MODEL_AT|MODEL_PS2|MODEL_HAS_IDE, 1, 256, 1, at_i430vx_init, NULL}, + {"", -1, "", {{"", 0}, {"", 0}, {"", 0}}, 0,0,0, 0} }; int model_count() @@ -348,7 +350,7 @@ void ps2_m30_286_init() dma16_init(); ide_init(); keyboard_at_init(); - mouse_ps2_init(); +// mouse_ps2_init(); nvr_init(); pic2_init(); ps2board_init(); @@ -365,7 +367,7 @@ static void ps2_common_init() ide_init(); keyboard_at_init(); keyboard_at_init_ps2(); - mouse_ps2_init(); +// mouse_ps2_init(); nvr_init(); pic2_init(); diff --git a/src/mouse.h b/src/mouse.h index 43e9685..216ed73 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -19,7 +19,7 @@ typedef struct char name[80]; void *(*init)(); void (*close)(void *p); - uint8_t (*poll)(int x, int y, int z, int b, void *p); + void (*poll)(int x, int y, int z, int b, void *p); int type; } mouse_t; diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index 0783a01..1603cd9 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -1,3 +1,4 @@ +#include #include "ibm.h" #include "keyboard_at.h" #include "mouse.h" diff --git a/src/mouse_serial.c b/src/mouse_serial.c index f1dfea1..9964153 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -1,3 +1,4 @@ +#include #include "ibm.h" #include "mouse.h" #include "pic.h" @@ -46,7 +47,7 @@ void mouse_serial_poll(int x, int y, int z, int b, void *p) } } -void mouse_serial_rcr(SERIAL *serial, void *p) +void mouse_serial_rcr(struct SERIAL *serial, void *p) { mouse_serial_t *mouse = (mouse_serial_t *)p; @@ -68,7 +69,7 @@ void mousecallback(void *p) void *mouse_serial_init() { - mouse_serial_t *mouse = (mouse_t *)malloc(sizeof(mouse_serial_t)); + mouse_serial_t *mouse = (mouse_serial_t *)malloc(sizeof(mouse_serial_t)); memset(mouse, 0, sizeof(mouse_serial_t)); mouse->serial = &serial1; diff --git a/src/nmi.c b/src/nmi.c index 5b82053..1128b9b 100644 --- a/src/nmi.c +++ b/src/nmi.c @@ -1,4 +1,5 @@ #include "ibm.h" +#include "io.h" #include "nmi.h" int nmi_mask; diff --git a/src/nvr.h b/src/nvr.h index 30b7b4b..c04289f 100644 --- a/src/nvr.h +++ b/src/nvr.h @@ -4,5 +4,7 @@ extern int enable_sync; extern int nvr_dosave; -void time_get(char *nvrram); +void loadnvr(); +void savenvr(); +void nvr_recalc(); diff --git a/src/pc.c b/src/pc.c index 15aab5d..07395a7 100644 --- a/src/pc.c +++ b/src/pc.c @@ -15,6 +15,7 @@ #include "cdrom-null.h" #include "config.h" #include "cpu.h" +#include "disc_fdi.h" #include "dma.h" #include "fdc.h" #include "fdd.h" @@ -22,24 +23,29 @@ #include "sound_gus.h" #include "ide.h" #include "keyboard.h" +#include "keyboard_at.h" #include "model.h" #include "mouse.h" #include "nvr.h" #include "pic.h" #include "pit.h" #include "plat-joystick.h" +#include "plat-keyboard.h" +#include "plat-midi.h" #include "plat-mouse.h" #include "serial.h" #include "sound.h" #include "sound_cms.h" #include "sound_opl.h" #include "sound_sb.h" +#include "sound_speaker.h" #include "sound_ssi2001.h" #include "timer.h" #include "vid_voodoo.h" #include "video.h" #include "amstrad.h" #include "hdd.h" +#include "x86.h" int window_w, window_h, window_x, window_y, window_remember; @@ -115,8 +121,7 @@ void pollmouse() pollmouse_delay = 2; mouse_poll_host(); mouse_get_mickeys(&x, &y, &z); - if (mouse_poll) - mouse_poll(x, y, z, mouse_buttons); + mouse_poll(x, y, z, mouse_buttons); // if (mousecapture) position_mouse(64,64); } diff --git a/src/pci.c b/src/pci.c index ab8926a..73b455a 100644 --- a/src/pci.c +++ b/src/pci.c @@ -59,6 +59,7 @@ uint8_t pci_read(uint16_t port, void *priv) return 0xff; } + return 0xff; } void pci_type2_write(uint16_t port, uint8_t val, void *priv); @@ -134,7 +135,11 @@ void pci_init(int type, int min_card, int max_card) } for (c = 0; c < 32; c++) - pci_card_read[c] = pci_card_write[c] = pci_priv[c] = NULL; + { + pci_card_read[c] = NULL; + pci_card_write[c] = NULL; + pci_priv[c] = NULL; + } pci_min_card = min_card; pci_max_card = max_card; diff --git a/src/pic.c b/src/pic.c index 78d40ee..26918f3 100644 --- a/src/pic.c +++ b/src/pic.c @@ -1,6 +1,8 @@ #include "ibm.h" #include "io.h" #include "pic.h" +#include "pit.h" +#include "video.h" int output; int intclear; diff --git a/src/pic.h b/src/pic.h index bb6786b..e386313 100644 --- a/src/pic.h +++ b/src/pic.h @@ -7,3 +7,4 @@ void picintlevel(uint16_t num); void picintc(uint16_t num); uint8_t picinterrupt(); void picclear(int num); +void dumppic(); diff --git a/src/pit.c b/src/pit.c index 2d7f776..c6e96f8 100644 --- a/src/pit.c +++ b/src/pit.c @@ -7,10 +7,12 @@ #include "ibm.h" #include "cpu.h" +#include "device.h" #include "dma.h" #include "io.h" #include "pic.h" #include "pit.h" +#include "sound_speaker.h" #include "timer.h" #include "video.h" #include "model.h" @@ -455,7 +457,7 @@ uint8_t pit_read(uint16_t addr, void *p) { PIT *pit = (PIT *)p; int t; - uint8_t temp; + uint8_t temp = 0xff; cycles -= (int)PITCONST; // printf("Read PIT %04X ",addr); switch (addr&3) diff --git a/src/plat-midi.h b/src/plat-midi.h index ccdd212..5dbe59d 100644 --- a/src/plat-midi.h +++ b/src/plat-midi.h @@ -1,3 +1,5 @@ void midi_init(); void midi_close(); void midi_write(uint8_t val); +int midi_get_num_devs(); +void midi_get_dev_name(int num, char *s); diff --git a/src/ps1.c b/src/ps1.c index d790a29..72fa773 100644 --- a/src/ps1.c +++ b/src/ps1.c @@ -1,8 +1,12 @@ #include "ibm.h" +#include "cpu.h" +#include "io.h" #include "mem.h" #include "ps1.h" #include "rom.h" #include "lpt.h" +#include "serial.h" +#include "x86.h" static rom_t ps1_high_rom; static uint8_t ps1_92, ps1_94, ps1_102, ps1_103, ps1_104, ps1_105, ps1_190; diff --git a/src/ps2.c b/src/ps2.c index 9b78c15..18b0ed7 100644 --- a/src/ps2.c +++ b/src/ps2.c @@ -1,8 +1,10 @@ #include "ibm.h" +#include "io.h" +#include "lpt.h" #include "mem.h" #include "ps2.h" #include "rom.h" -#include "lpt.h" +#include "serial.h" static uint8_t ps2_92, ps2_94, ps2_102, ps2_103, ps2_104, ps2_105, ps2_190; diff --git a/src/ps2_mca.c b/src/ps2_mca.c index f453c92..6517664 100644 --- a/src/ps2_mca.c +++ b/src/ps2_mca.c @@ -1,9 +1,13 @@ #include "ibm.h" +#include "cpu.h" +#include "io.h" +#include "lpt.h" +#include "mca.h" #include "mem.h" #include "ps2_mca.h" #include "rom.h" -#include "lpt.h" -#include "mca.h" +#include "serial.h" +#include "x86.h" //static uint8_t ps2_92, ps2_94, ps2_102, ps2_103, ps2_104, ps2_105, ps2_190; @@ -92,6 +96,7 @@ static uint8_t model_50_read(uint16_t port) case 0x107: return ps2.subaddr_hi; } + return 0xff; } static uint8_t model_55sx_read(uint16_t port) @@ -115,6 +120,7 @@ static uint8_t model_55sx_read(uint16_t port) case 0x107: return ps2.subaddr_hi; } + return 0xff; } static void model_50_write(uint16_t port, uint8_t val) diff --git a/src/rom.c b/src/rom.c index 87fc885..abbca06 100644 --- a/src/rom.c +++ b/src/rom.c @@ -1,6 +1,7 @@ #include #include #include "ibm.h" +#include "config.h" #include "mem.h" #include "rom.h" diff --git a/src/rtc.c b/src/rtc.c index 312556a..d1a0515 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -26,9 +26,6 @@ struct int year; } internal_clock; -/* When the RTC was last updated */ -static time_t rtc_set_time = 0; - /* Table for days in each month */ static int rtc_days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; @@ -88,7 +85,7 @@ void rtc_tick() } /* Called when modifying the NVR registers */ -void time_update(char *nvrram, int reg) +void time_update(uint8_t *nvrram, int reg) { int temp; @@ -162,10 +159,8 @@ static void time_internal_set(struct tm *time_var) internal_clock.year = time_var->tm_year + 1900; } -static void time_set_nvrram(char *nvrram, struct tm *cur_time_tm) +static void time_set_nvrram(uint8_t *nvrram, struct tm *cur_time_tm) { - int dow, mon, year; - if (nvrram[RTC_REGB] & RTC_DM) { nvrram[RTC_SECONDS] = cur_time_tm->tm_sec; @@ -208,7 +203,7 @@ static void time_set_nvrram(char *nvrram, struct tm *cur_time_tm) } } -void time_internal_set_nvrram(char *nvrram) +void time_internal_set_nvrram(uint8_t *nvrram) { int temp; @@ -229,7 +224,7 @@ void time_internal_set_nvrram(char *nvrram) internal_clock.year += (nvrram[RTC_REGB] & RTC_DM) ? 1900 : (DCB(nvrram[RTC_CENTURY]) * 100); } -void time_internal_sync(char *nvrram) +void time_internal_sync(uint8_t *nvrram) { struct tm *cur_time_tm; time_t cur_time; @@ -242,7 +237,7 @@ void time_internal_sync(char *nvrram) time_set_nvrram(nvrram, cur_time_tm); } -void time_get(char *nvrram) +void time_get(uint8_t *nvrram) { struct tm cur_time_tm; diff --git a/src/rtc.h b/src/rtc.h index b99728c..1d342e9 100644 --- a/src/rtc.h +++ b/src/rtc.h @@ -168,7 +168,7 @@ enum RTC_RD_BITS }; void rtc_tick(); -void time_update(char *nvrram, int reg); -void time_get(char *nvrram); -void time_internal_set_nvrram(char *nvrram); -void time_internal_sync(char *nvrram); +void time_update(uint8_t *nvrram, int reg); +void time_get(uint8_t *nvrram); +void time_internal_set_nvrram(uint8_t *nvrram); +void time_internal_sync(uint8_t *nvrram); diff --git a/src/scat.c b/src/scat.c index c941550..0089f0a 100644 --- a/src/scat.c +++ b/src/scat.c @@ -1,8 +1,10 @@ /*This is the chipset used in the Award 286 clone model*/ #include "ibm.h" +#include "cpu.h" #include "io.h" -#include "scat.h" #include "mem.h" +#include "scat.h" +#include "x86.h" static uint8_t scat_regs[256]; static int scat_index; @@ -17,7 +19,7 @@ static mem_mapping_t scat_512k_clip_mapping; void scat_shadow_state_update() { - int i, val, val2; + int i, val; // TODO - Segment A000 to BFFF shadow ram enable features and ROM enable features should be implemented later. for (i = 8; i < 24; i++) diff --git a/src/serial.c b/src/serial.c index 4225bf2..5b40691 100644 --- a/src/serial.c +++ b/src/serial.c @@ -120,7 +120,7 @@ void serial_write(uint16_t addr, uint8_t val, void *p) if ((val & 2) && !(serial->mctrl & 2)) { if (serial->rcr_callback) - serial->rcr_callback(serial, serial->rcr_callback_p); + serial->rcr_callback((struct SERIAL *)serial, serial->rcr_callback_p); // pclog("RCR raised! sending M\n"); } serial->mctrl = val; diff --git a/src/serial.h b/src/serial.h index e41603f..748ad07 100644 --- a/src/serial.h +++ b/src/serial.h @@ -27,4 +27,6 @@ typedef struct int recieve_delay; } SERIAL; +void serial_write_fifo(SERIAL *serial, uint8_t dat); + extern SERIAL serial1, serial2; diff --git a/src/sound.c b/src/sound.c index f464591..a092bc2 100644 --- a/src/sound.c +++ b/src/sound.c @@ -3,6 +3,9 @@ #include "ibm.h" #include "device.h" +#include "cdrom-ioctl.h" +#include "ide.h" + #include "filters.h" #include "sound_opl.h" @@ -107,7 +110,7 @@ static struct static int sound_handlers_num; -static int sound_poll_time = 0, sound_get_buffer_time = 0, sound_poll_latch; +static int sound_poll_time = 0, sound_poll_latch; int sound_pos_global = 0; int soundon = 1; diff --git a/src/sound.h b/src/sound.h index e142e40..f5c59a3 100644 --- a/src/sound.h +++ b/src/sound.h @@ -18,3 +18,12 @@ void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r); extern int sound_pos_global; void sound_speed_changed(); + +void sound_init(); +void sound_reset(); + +void initalmain(int argc, char *argv[]); +void inital(); + +void givealbuffer(int32_t *buf); +void givealbuffer_cd(int16_t *buf); diff --git a/src/sound_ad1848.c b/src/sound_ad1848.c index 1addd43..1e9f99a 100644 --- a/src/sound_ad1848.c +++ b/src/sound_ad1848.c @@ -1,8 +1,7 @@ -/*PCem v0.8 by Tom Walker - - AD1848 CODEC emulation (Windows Sound System compatible)*/ - +#include #include "ibm.h" +#include "dma.h" +#include "pic.h" #include "sound.h" #include "sound_ad1848.h" diff --git a/src/sound_ad1848.h b/src/sound_ad1848.h index 546c0ca..5cba0f1 100644 --- a/src/sound_ad1848.h +++ b/src/sound_ad1848.h @@ -33,3 +33,5 @@ void ad1848_write(uint16_t addr, uint8_t val, void *p); void ad1848_update(ad1848_t *ad1848); void ad1848_speed_changed(ad1848_t *ad1848); + +void ad1848_init(ad1848_t *ad1848); diff --git a/src/sound_emu8k.c b/src/sound_emu8k.c index 2ef6795..49d8216 100644 --- a/src/sound_emu8k.c +++ b/src/sound_emu8k.c @@ -6,6 +6,7 @@ #include #include #include "ibm.h" +#include "io.h" #include "device.h" #include "sound.h" #include "sound_emu8k.h" @@ -68,10 +69,10 @@ static inline void EMU8K_WRITE(emu8k_t *emu8k, uint32_t addr, uint16_t val) static int ff = 0; static int voice_count = 0; -uint16_t emu8k_inw(uint32_t addr, void *p) +uint16_t emu8k_inw(uint16_t addr, void *p) { emu8k_t *emu8k = (emu8k_t *)p; - uint16_t ret; + uint16_t ret = 0xffff; /* pclog("emu8k_inw %04X reg=%i voice=%i\n", addr, emu8k->cur_reg, emu8k->cur_voice);*/ addr -= 0x220; @@ -114,7 +115,7 @@ uint16_t emu8k_inw(uint32_t addr, void *p) { case 0: { - uint32_t val = (emu8k->voice[emu8k->cur_voice].ccca & 0xff000000) | (emu8k->voice[emu8k->cur_voice].addr >> 8); +// uint32_t val = (emu8k->voice[emu8k->cur_voice].ccca & 0xff000000) | (emu8k->voice[emu8k->cur_voice].addr >> 8); READ16(addr, emu8k->voice[emu8k->cur_voice].ccca); return ret; } @@ -170,7 +171,7 @@ uint16_t emu8k_inw(uint32_t addr, void *p) { case 0: { - uint32_t val = (emu8k->voice[emu8k->cur_voice].ccca & 0xff000000) | (emu8k->voice[emu8k->cur_voice].addr >> 8); +// uint32_t val = (emu8k->voice[emu8k->cur_voice].ccca & 0xff000000) | (emu8k->voice[emu8k->cur_voice].addr >> 8); READ16(addr, emu8k->voice[emu8k->cur_voice].ccca); return ret; } @@ -254,7 +255,7 @@ uint16_t emu8k_inw(uint32_t addr, void *p) return 0xffff; } -void emu8k_outw(uint32_t addr, uint16_t val, void *p) +void emu8k_outw(uint16_t addr, uint16_t val, void *p) { emu8k_t *emu8k = (emu8k_t *)p; @@ -487,14 +488,14 @@ void emu8k_outw(uint32_t addr, uint16_t val, void *p) } } -uint8_t emu8k_inb(uint32_t addr, void *p) +uint8_t emu8k_inb(uint16_t addr, void *p) { if (addr & 1) return emu8k_inw(addr & ~1, p) >> 1; return emu8k_inw(addr, p) & 0xff; } -void emu8k_outb(uint32_t addr, uint8_t val, void *p) +void emu8k_outb(uint16_t addr, uint8_t val, void *p) { if (addr & 1) emu8k_outw(addr & ~1, val << 8, p); @@ -510,7 +511,6 @@ void emu8k_update(emu8k_t *emu8k) int32_t *buf; int pos; int c; - int32_t out_l = 0, out_r = 0; buf = &emu8k->buffer[emu8k->pos*2]; @@ -526,9 +526,9 @@ void emu8k_update(emu8k_t *emu8k) int32_t voice_l, voice_r; int32_t dat; int lfo1_vibrato, lfo2_vibrato; - int tremolo; +// int tremolo; - tremolo = ((lfotable[(emu8k->voice[c].lfo1_count >> 8) & 4095] * emu8k->voice[c].lfo1_trem) * 4) >> 12; +// tremolo = ((lfotable[(emu8k->voice[c].lfo1_count >> 8) & 4095] * emu8k->voice[c].lfo1_trem) * 4) >> 12; if (freqtable[emu8k->voice[c].pitch] >> 32) dat = EMU8K_READ(emu8k, emu8k->voice[c].addr >> 32); diff --git a/src/sound_mpu401_uart.c b/src/sound_mpu401_uart.c index 8d50f91..b75cfa8 100644 --- a/src/sound_mpu401_uart.c +++ b/src/sound_mpu401_uart.c @@ -1,5 +1,6 @@ #include "ibm.h" #include "io.h" +#include "plat-midi.h" #include "sound_mpu401_uart.h" enum diff --git a/src/sound_pas16.c b/src/sound_pas16.c index 7cc6538..2e6f4be 100644 --- a/src/sound_pas16.c +++ b/src/sound_pas16.c @@ -172,7 +172,7 @@ enum static uint8_t pas16_in(uint16_t port, void *p) { pas16_t *pas16 = (pas16_t *)p; - uint8_t temp; + uint8_t temp = 0xff; /* if (CS == 0xCA53 && pc == 0x3AFC) fatal("here");*/ switch ((port - pas16->base) + 0x388) @@ -490,7 +490,7 @@ static void pas16_pit_out(uint16_t port, uint8_t val, void *p) static uint8_t pas16_pit_in(uint16_t port, void *p) { pas16_t *pas16 = (pas16_t *)p; - uint8_t temp; + uint8_t temp = 0xff; int t = port & 3; // printf("Read PIT %04X ",addr); switch (port & 3) diff --git a/src/sound_ps1.c b/src/sound_ps1.c index 124be66..a7de420 100644 --- a/src/sound_ps1.c +++ b/src/sound_ps1.c @@ -2,6 +2,7 @@ #include "ibm.h" #include "device.h" #include "io.h" +#include "pic.h" #include "sound.h" #include "sound_ps1.h" #include "sound_sn76489.h" diff --git a/src/sound_pssj.c b/src/sound_pssj.c index bda55e7..3ffaaae 100644 --- a/src/sound_pssj.c +++ b/src/sound_pssj.c @@ -100,6 +100,8 @@ static uint8_t pssj_read(uint16_t port, void *p) case 3: return (pssj->freq >> 8) | (pssj->amplitude << 4); } + + return 0xff; } static void pssj_update(pssj_t *pssj) diff --git a/src/sound_sb.c b/src/sound_sb.c index ba43ef4..d4212ca 100644 --- a/src/sound_sb.c +++ b/src/sound_sb.c @@ -3,6 +3,9 @@ #include "device.h" #include "io.h" #include "mca.h" +#include "mem.h" +#include "rom.h" +#include "sound.h" #include "sound_emu8k.h" #include "sound_mpu401_uart.h" #include "sound_opl.h" @@ -107,7 +110,6 @@ static void sb_get_buffer_opl3(int32_t *buffer, int len, void *p) sb_dsp_update(&sb->dsp); for (c = 0; c < len * 2; c += 2) { - int c_emu8k = (((c/2) * 44100) / 48000)*2; int32_t out_l, out_r; out_l = ((sb->opl.buffer[c] * mixer->fm_l) >> 16); @@ -461,7 +463,6 @@ void *sb_15_init() void *sb_mcv_init() { sb_t *sb = malloc(sizeof(sb_t)); - uint16_t addr = device_get_config_int("addr"); memset(sb, 0, sizeof(sb_t)); opl2_init(&sb->opl); diff --git a/src/sound_sb_dsp.c b/src/sound_sb_dsp.c index a1b868b..29dc3f0 100644 --- a/src/sound_sb_dsp.c +++ b/src/sound_sb_dsp.c @@ -950,7 +950,6 @@ void sb_dsp_update(sb_dsp_t *dsp) void sb_dsp_add_status_info(char *s, int max_len, sb_dsp_t *dsp) { char temps[128]; - int len; int freq; if (dsp->sb_timeo < 256) diff --git a/src/sound_sn76489.c b/src/sound_sn76489.c index b7a2a1d..6acb24f 100644 --- a/src/sound_sn76489.c +++ b/src/sound_sn76489.c @@ -185,7 +185,6 @@ void sn76489_init(sn76489_t *sn76489, uint16_t base, uint16_t size, int type, in sn76489->vol[0] = 0; sn76489->vol[1] = sn76489->vol[2] = sn76489->vol[3] = 8; sn76489->stat[0] = sn76489->stat[1] = sn76489->stat[2] = sn76489->stat[3] = 127; - srand(time(NULL)); sn76489->count[0] = 0; sn76489->count[1] = (rand()&0x3FF)<<6; sn76489->count[2] = (rand()&0x3FF)<<6; diff --git a/src/sound_ssi2001.c b/src/sound_ssi2001.c index 00e78d4..ff83041 100644 --- a/src/sound_ssi2001.c +++ b/src/sound_ssi2001.c @@ -1,6 +1,7 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "sound.h" #include "sound_resid.h" diff --git a/src/sound_wss.c b/src/sound_wss.c index 654d168..bd94c38 100644 --- a/src/sound_wss.c +++ b/src/sound_wss.c @@ -10,6 +10,7 @@ #include "dma.h" #include "io.h" #include "pic.h" +#include "sound.h" #include "sound_ad1848.h" #include "sound_opl.h" #include "sound_wss.h" @@ -27,7 +28,7 @@ static int wss_dma[4] = {0, 0, 1, 3}; static int wss_irq[8] = {5, 7, 9, 10, 11, 12, 14, 15}; /*W95 only uses 7-9, others may be wrong*/ -static uint16_t wss_addr[4] = {0x530, 0x604, 0xe80, 0xf40}; +//static uint16_t wss_addr[4] = {0x530, 0x604, 0xe80, 0xf40}; typedef struct wss_t { @@ -78,8 +79,6 @@ static void wss_get_buffer(int32_t *buffer, int len, void *p) void *wss_init() { wss_t *wss = malloc(sizeof(wss_t)); - int c; - double attenuation; memset(wss, 0, sizeof(wss_t)); diff --git a/src/soundopenal.c b/src/soundopenal.c index 03c7d04..639bbcc 100644 --- a/src/soundopenal.c +++ b/src/soundopenal.c @@ -25,7 +25,8 @@ ALvoid alutInit(ALint *argc,ALbyte **argv) ALCdevice *Device; //Open device - Device=alcOpenDevice((ALubyte*)""); +// Device=alcOpenDevice((ALubyte*)""); + Device=alcOpenDevice((void *)""); //Create context(s) Context=alcCreateContext(Device,NULL); //Set active context diff --git a/src/tandy_eeprom.c b/src/tandy_eeprom.c index c49ee5c..a29e272 100644 --- a/src/tandy_eeprom.c +++ b/src/tandy_eeprom.c @@ -1,5 +1,6 @@ #include #include "ibm.h" +#include "io.h" #include "device.h" #include "tandy_eeprom.h" @@ -117,7 +118,7 @@ int tandy_eeprom_read() void *tandy_eeprom_init() { tandy_eeprom_t *eeprom = malloc(sizeof(tandy_eeprom_t)); - FILE *f; + FILE *f = NULL; memset(eeprom, 0, sizeof(tandy_eeprom_t)); @@ -147,7 +148,7 @@ void *tandy_eeprom_init() void tandy_eeprom_close(void *p) { tandy_eeprom_t *eeprom = (tandy_eeprom_t *)p; - FILE *f; + FILE *f = NULL; switch (eeprom->romset) { diff --git a/src/tandy_rom.c b/src/tandy_rom.c index f1fc9cf..becf8d7 100644 --- a/src/tandy_rom.c +++ b/src/tandy_rom.c @@ -1,6 +1,7 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "mem.h" #include "tandy_rom.h" @@ -25,7 +26,7 @@ uint32_t tandy_read_roml(uint32_t addr, void *p) { uint32_t addr2 = (addr & 0xffff) + tandy_rom_offset; // if (!nopageerrors) pclog("tandy_read_roml: %05x %05x %08x\n", addr, addr2, *(uint32_t *)&tandy_rom[addr2]); - return *(uint32_t *)&tandy_rom[addr]; + return *(uint32_t *)&tandy_rom[addr2]; } uint8_t tandy_rom_bank_read(uint16_t port, void *p) diff --git a/src/timer.c b/src/timer.c index 052f072..964e19a 100644 --- a/src/timer.c +++ b/src/timer.c @@ -30,7 +30,6 @@ int timer_start = 0; void timer_process() { int c; - int retry; int process = 0; /*Get actual elapsed time*/ int diff = timer_latch - timer_count; diff --git a/src/vid_ati_mach64.c b/src/vid_ati_mach64.c index dd5de16..35a9060 100644 --- a/src/vid_ati_mach64.c +++ b/src/vid_ati_mach64.c @@ -540,8 +540,8 @@ static void mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val case 0x11e: case 0x11f: WRITE8(addr, mach64->dst_height_width, val); case 0x113: - if ((addr & 0x3ff) == 0x11b || (addr & 0x3ff) == 0x11f || - ((addr & 0x3ff) == 0x113) && !(val & 0x80)) + if (((addr & 0x3ff) == 0x11b || (addr & 0x3ff) == 0x11f || + (addr & 0x3ff) == 0x113) && !(val & 0x80)) { mach64_start_fill(mach64); #ifdef MACH64_DEBUG @@ -797,7 +797,6 @@ static void fifo_thread(void *param) uint64_t start_time = timer_read(); uint64_t end_time; fifo_entry_t *fifo = &mach64->fifo[mach64->fifo_read_idx & FIFO_MASK]; - uint32_t val = fifo->val; switch (fifo->addr_type & FIFO_TYPE) { @@ -828,7 +827,6 @@ static void fifo_thread(void *param) static void mach64_queue(mach64_t *mach64, uint32_t addr, uint32_t val, uint32_t type) { fifo_entry_t *fifo = &mach64->fifo[mach64->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { @@ -850,7 +848,6 @@ static void mach64_queue(mach64_t *mach64, uint32_t addr, uint32_t val, uint32_t void mach64_cursor_dump(mach64_t *mach64) { - svga_t *svga = &mach64->svga; /* pclog("Mach64 cursor :\n"); pclog("Ena = %i X = %i Y = %i Addr = %05X Xoff = %i Yoff = %i\n", svga->hwcursor.ena, svga->hwcursor.x, svga->hwcursor.y, svga->hwcursor.addr, svga->hwcursor.xoff, svga->hwcursor.yoff);*/ } @@ -1127,8 +1124,8 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) while (count) { uint32_t src_dat, dest_dat; - uint32_t host_dat; - int mix; + uint32_t host_dat = 0; + int mix = 0; int dst_x = (mach64->accel.dst_x + mach64->accel.dst_x_start) & 0xfff; int dst_y = (mach64->accel.dst_y + mach64->accel.dst_y_start) & 0xfff; int src_x; @@ -1331,9 +1328,9 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) case OP_LINE: while (count) { - uint32_t src_dat, dest_dat; - uint32_t host_dat; - int mix; + uint32_t src_dat = 0, dest_dat; + uint32_t host_dat = 0; + int mix = 0; int draw_pixel = !(mach64->dst_cntl & DST_POLYGON_EN); if (mach64->accel.source_host) @@ -1869,7 +1866,6 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) } uint16_t mach64_ext_readw(uint32_t addr, void *p) { - mach64_t *mach64 = (mach64_t *)p; uint16_t ret; switch (addr & 0x3ff) { @@ -2232,7 +2228,6 @@ uint8_t mach64_ext_inb(uint16_t port, void *p) } uint16_t mach64_ext_inw(uint16_t port, void *p) { - mach64_t *mach64 = (mach64_t *)p; uint16_t ret; switch (port) { @@ -2254,7 +2249,6 @@ uint16_t mach64_ext_inw(uint16_t port, void *p) } uint32_t mach64_ext_inl(uint16_t port, void *p) { - mach64_t *mach64 = (mach64_t *)p; uint32_t ret; switch (port) { @@ -2380,7 +2374,6 @@ void mach64_ext_outb(uint16_t port, uint8_t val, void *p) } void mach64_ext_outw(uint16_t port, uint16_t val, void *p) { - mach64_t *mach64 = (mach64_t *)p; #ifdef MACH64_DEBUG pclog("mach64_ext_outw : port %04X val %04X\n", port, val); #endif @@ -2400,7 +2393,6 @@ void mach64_ext_outw(uint16_t port, uint16_t val, void *p) } void mach64_ext_outl(uint16_t port, uint32_t val, void *p) { - mach64_t *mach64 = (mach64_t *)p; pclog("mach64_ext_outl : port %04X val %08X\n", port, val); switch (port) { @@ -2507,7 +2499,6 @@ static void mach64_io_set(mach64_t *mach64) uint8_t mach64_pci_read(int func, int addr, void *p) { mach64_t *mach64 = (mach64_t *)p; - svga_t *svga = &mach64->svga; // pclog("Mach64 PCI read %08X\n", addr); @@ -2588,7 +2579,6 @@ void mach64_pci_write(int func, int addr, uint8_t val, void *p) void *mach64gx_init() { - int c; mach64_t *mach64 = malloc(sizeof(mach64_t)); memset(mach64, 0, sizeof(mach64_t)); diff --git a/src/vid_cl5429.c b/src/vid_cl5429.c index 02cdf85..13ff6df 100644 --- a/src/vid_cl5429.c +++ b/src/vid_cl5429.c @@ -258,7 +258,7 @@ void gd5429_recalc_mapping(gd5429_t *gd5429) void gd5429_recalctimings(svga_t *svga) { - gd5429_t *gd5429 = (gd5429_t *)svga->p; +// gd5429_t *gd5429 = (gd5429_t *)svga->p; if (svga->seqregs[7] & 0x01) { @@ -570,8 +570,8 @@ void gd5429_start_blit(uint32_t cpu_dat, int count, void *p) while (count) { - uint8_t src, dst; - int mask; + uint8_t src = 0, dst; + int mask = 0; if (gd5429->blt.mode & 0x04) { @@ -783,7 +783,7 @@ void gd5429_mmio_write(uint32_t addr, uint8_t val, void *p) uint8_t gd5429_mmio_read(uint32_t addr, void *p) { - gd5429_t *gd5429 = (gd5429_t *)p; +// gd5429_t *gd5429 = (gd5429_t *)p; pclog("MMIO read %08X\n", addr); switch (addr & 0xff) diff --git a/src/vid_ega.c b/src/vid_ega.c index 8bc0d6f..bb98784 100644 --- a/src/vid_ega.c +++ b/src/vid_ega.c @@ -540,7 +540,7 @@ void ega_poll(void *p) } if (ega->vc == ega->vsyncstart) { - int wx, wy; + int wx = 0, wy = 0; ega->dispon = 0; // printf("Vsync on at line %i %i\n",displine,vc); ega->stat |= 8; @@ -833,7 +833,6 @@ void ega_init(ega_t *ega) void *ega_standalone_init() { - int c, d, e; ega_t *ega = malloc(sizeof(ega_t)); memset(ega, 0, sizeof(ega_t)); diff --git a/src/vid_ega.h b/src/vid_ega.h index c40190b..1c43184 100644 --- a/src/vid_ega.h +++ b/src/vid_ega.h @@ -71,5 +71,6 @@ void ega_poll(void *p); void ega_recalctimings(struct ega_t *ega); void ega_write(uint32_t addr, uint8_t val, void *p); uint8_t ega_read(uint32_t addr, void *p); +void ega_init(ega_t *ega); extern device_t ega_device; diff --git a/src/vid_et4000.c b/src/vid_et4000.c index dfdde8d..dbcabb5 100644 --- a/src/vid_et4000.c +++ b/src/vid_et4000.c @@ -112,8 +112,6 @@ uint8_t et4000_in(uint16_t addr, void *p) void et4000_recalctimings(svga_t *svga) { - et4000_t *et4000 = (et4000_t *)svga->p; - svga->ma_latch |= (svga->crtc[0x33]&3)<<16; if (svga->crtc[0x35] & 1) svga->vblankstart += 0x400; if (svga->crtc[0x35] & 2) svga->vtotal += 0x400; diff --git a/src/vid_et4000w32.c b/src/vid_et4000w32.c index 75f4dae..5de42be 100644 --- a/src/vid_et4000w32.c +++ b/src/vid_et4000w32.c @@ -475,7 +475,6 @@ static void fifo_thread(void *param) uint64_t start_time = timer_read(); uint64_t end_time; fifo_entry_t *fifo = &et4000->fifo[et4000->fifo_read_idx & FIFO_MASK]; - uint32_t val = fifo->val; switch (fifo->addr_type & FIFO_TYPE) { @@ -517,7 +516,6 @@ static void et4000w32p_wait_fifo_idle(et4000w32p_t *et4000) static void et4000w32p_queue(et4000w32p_t *et4000, uint32_t addr, uint32_t val, uint32_t type) { fifo_entry_t *fifo = &et4000->fifo[et4000->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { diff --git a/src/vid_genius.c b/src/vid_genius.c index 2e73e7c..c6d6202 100644 --- a/src/vid_genius.c +++ b/src/vid_genius.c @@ -2,7 +2,9 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "mem.h" +#include "rom.h" #include "timer.h" #include "video.h" #include "vid_genius.h" @@ -253,7 +255,7 @@ void genius_textline(genius_t *genius, uint8_t background) int x; int w = 80; /* 80 characters across */ int cw = 9; /* Each character is 9 pixels wide */ - uint8_t chr, attr, fg, bg; + uint8_t chr, attr; uint8_t bitmap[2]; int blink, c, row; int drawcursor, cursorline; @@ -376,7 +378,7 @@ void genius_cgaline(genius_t *genius) { int x, c; uint32_t dat; - uint8_t bitmap, ink; + uint8_t ink; uint32_t addr; ink = (genius->genius_control & 0x20) ? 16 : 16+15; @@ -415,7 +417,7 @@ void genius_hiresline(genius_t *genius) { int x, c; uint32_t dat; - uint8_t bitmap, ink; + uint8_t ink; uint32_t addr; ink = (genius->genius_control & 0x20) ? 16 : 16+15; @@ -451,11 +453,8 @@ void genius_hiresline(genius_t *genius) void genius_poll(void *p) { genius_t *genius = (genius_t *)p; - int x, c; - int oldvc; + int x; uint8_t background; - uint16_t dat; - int mode; if (!genius->linepos) { diff --git a/src/vid_hercules.c b/src/vid_hercules.c index 6587d44..d010baa 100644 --- a/src/vid_hercules.c +++ b/src/vid_hercules.c @@ -2,6 +2,7 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "mem.h" #include "timer.h" #include "video.h" @@ -122,7 +123,6 @@ void hercules_poll(void *p) int oldvc; uint8_t chr, attr; uint16_t dat; - int cols[4]; int oldsc; int blink; if (!hercules->linepos) @@ -142,8 +142,6 @@ void hercules_poll(void *p) video_wait_for_buffer(); } hercules->lastline = hercules->displine; - cols[0] = 0; - cols[1] = 7; if ((hercules->ctrl & 2) && (hercules->ctrl2 & 1)) { ca = (hercules->sc & 3) * 0x2000; diff --git a/src/vid_icd2061.c b/src/vid_icd2061.c index b3fea14..30cc50e 100644 --- a/src/vid_icd2061.c +++ b/src/vid_icd2061.c @@ -7,7 +7,7 @@ void icd2061_write(icd2061_t *icd2061, int val) { - int q, p, m, i, a; + int q, p, m, a; if ((val & 1) && !(icd2061->state & 1)) { pclog("ICD2061 write %02X %i %08X %i\n", val, icd2061->unlock, icd2061->data, icd2061->pos); @@ -39,7 +39,6 @@ void icd2061_write(icd2061_t *icd2061, int val) q = (icd2061->data & 0x7f) - 2; m = 1 << ((icd2061->data >> 7) & 0x7); p = ((icd2061->data >> 10) & 0x7f) - 3; - i = (icd2061->data >> 17) & 0xf; pclog("p %i q %i m %i\n", p, q, m); if (icd2061->ctrl & (1 << a)) p <<= 1; diff --git a/src/vid_incolor.c b/src/vid_incolor.c index 87ca813..88df9c2 100644 --- a/src/vid_incolor.c +++ b/src/vid_incolor.c @@ -3,6 +3,7 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "mem.h" #include "timer.h" #include "video.h" @@ -237,7 +238,7 @@ void incolor_write(uint32_t addr, uint8_t val, void *p) unsigned char wmode = incolor->crtc[INCOLOR_CRTC_RWCTRL] & INCOLOR_RWCTRL_WRMODE; unsigned char fg = incolor->crtc[INCOLOR_CRTC_RWCOL] & 0x0F; unsigned char bg = (incolor->crtc[INCOLOR_CRTC_RWCOL] >> 4)&0x0F; - unsigned char w; + unsigned char w = 0; unsigned char vmask; /* Mask of bit within byte */ unsigned char pmask; /* Mask of plane within colour value */ unsigned char latch; @@ -579,9 +580,9 @@ static void incolor_draw_char_ram48(incolor_t *incolor, int x, uint8_t chr, uint { unsigned i; int elg, blk, ul, ol, bld; - unsigned ull, oll, ulc, olc; + unsigned ull, oll, ulc = 0, olc = 0; unsigned val[4]; - unsigned ifg, ibg, cfg, pmask, plane; + unsigned ifg = 0, ibg, cfg, pmask, plane; const unsigned char *fnt; uint32_t fg; int cw = INCOLOR_CW; diff --git a/src/vid_mda.c b/src/vid_mda.c index 912fbb8..a3a7b39 100644 --- a/src/vid_mda.c +++ b/src/vid_mda.c @@ -108,7 +108,6 @@ void mda_poll(void *p) int x, c; int oldvc; uint8_t chr, attr; - int cols[4]; int oldsc; int blink; if (!mda->linepos) @@ -127,8 +126,6 @@ void mda_poll(void *p) video_wait_for_buffer(); } mda->lastline = mda->displine; - cols[0] = 0; - cols[1] = 7; for (x = 0; x < mda->crtc[1]; x++) { chr = mda->vram[(mda->ma << 1) & 0xfff]; diff --git a/src/vid_olivetti_m24.c b/src/vid_olivetti_m24.c index 331aa0b..2cae92c 100644 --- a/src/vid_olivetti_m24.c +++ b/src/vid_olivetti_m24.c @@ -449,7 +449,6 @@ void m24_poll(void *p) void *m24_init() { - int c; m24_t *m24 = malloc(sizeof(m24_t)); memset(m24, 0, sizeof(m24_t)); diff --git a/src/vid_paradise.c b/src/vid_paradise.c index ba78752..dc90657 100644 --- a/src/vid_paradise.c +++ b/src/vid_paradise.c @@ -6,6 +6,7 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "mem.h" #include "rom.h" #include "video.h" diff --git a/src/vid_pc1512.c b/src/vid_pc1512.c index 36548a5..79ac43d 100644 --- a/src/vid_pc1512.c +++ b/src/vid_pc1512.c @@ -163,7 +163,6 @@ static void pc1512_poll(void *p) uint16_t ca = (pc1512->crtc[15] | (pc1512->crtc[14] << 8)) & 0x3fff; int drawcursor; int x, c; - int oldvc; uint8_t chr, attr; uint16_t dat, dat2, dat3, dat4; int cols[4]; @@ -372,7 +371,6 @@ static void pc1512_poll(void *p) { pc1512->maback = pc1512->ma; pc1512->sc = 0; - oldvc = pc1512->vc; pc1512->vc++; pc1512->vc &= 127; @@ -453,7 +451,6 @@ static void pc1512_poll(void *p) static void *pc1512_init() { - int c; pc1512_t *pc1512 = malloc(sizeof(pc1512_t)); memset(pc1512, 0, sizeof(pc1512_t)); diff --git a/src/vid_pcjr.c b/src/vid_pcjr.c index 8452814..0e6b47d 100644 --- a/src/vid_pcjr.c +++ b/src/vid_pcjr.c @@ -4,8 +4,10 @@ #include "device.h" #include "io.h" #include "mem.h" +#include "pic.h" #include "timer.h" #include "video.h" +#include "dosbox/vid_cga_comp.h" #include "vid_pcjr.h" #define PCJR_RGB 0 @@ -170,25 +172,6 @@ void pcjr_recalctimings(pcjr_t *pcjr) pcjr->dispofftime = (int)(_dispofftime * (1 << TIMER_SHIFT)); } - -static int ntsc_col[8][8]= -{ - {0,0,0,0,0,0,0,0}, /*Black*/ - {0,0,1,1,1,1,0,0}, /*Blue*/ - {1,0,0,0,0,1,1,1}, /*Green*/ - {0,0,0,0,1,1,1,1}, /*Cyan*/ - {1,1,1,1,0,0,0,0}, /*Red*/ - {0,1,1,1,1,0,0,0}, /*Magenta*/ - {1,1,0,0,0,0,1,1}, /*Yellow*/ - {1,1,1,1,1,1,1,1} /*White*/ -}; - -/*static int cga4pal[8][4]= -{ - {0,2,4,6},{0,3,5,7},{0,3,4,7},{0,3,4,7}, - {0,10,12,14},{0,11,13,15},{0,11,12,15},{0,11,12,15} -};*/ - void pcjr_poll(void *p) { // int *cgapal=cga4pal[((pcjr->col&0x10)>>2)|((cgamode&4)>>1)|((cgacol&0x20)>>5)]; @@ -200,12 +183,8 @@ void pcjr_poll(void *p) uint8_t chr, attr; uint16_t dat; int cols[4]; - int col; int oldsc; - int y_buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}, y_val, y_tot; - int i_buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}, i_val, i_tot; - int q_buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}, q_val, q_tot; - int r, g, b; + if (!pcjr->linepos) { // cgapal[0]=pcjr->col&15; diff --git a/src/vid_s3.c b/src/vid_s3.c index d8ad94d..52b7e75 100644 --- a/src/vid_s3.c +++ b/src/vid_s3.c @@ -658,7 +658,6 @@ static void fifo_thread(void *param) uint64_t start_time = timer_read(); uint64_t end_time; fifo_entry_t *fifo = &s3->fifo[s3->fifo_read_idx & FIFO_MASK]; - uint32_t val = fifo->val; switch (fifo->addr_type & FIFO_TYPE) { @@ -698,7 +697,6 @@ static void fifo_thread(void *param) static void s3_queue(s3_t *s3, uint32_t addr, uint32_t val, uint32_t type) { fifo_entry_t *fifo = &s3->fifo[s3->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { @@ -1380,7 +1378,7 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat int clip_b = s3->accel.multifunc[3] & 0xfff; int clip_r = s3->accel.multifunc[4] & 0xfff; int vram_mask = (s3->accel.multifunc[0xa] & 0xc0) == 0xc0; - uint32_t mix_mask; + uint32_t mix_mask = 0; uint16_t *vram_w = (uint16_t *)svga->vram; uint32_t *vram_l = (uint32_t *)svga->vram; uint32_t compare = s3->accel.color_cmp; @@ -2224,7 +2222,6 @@ int s3_9fx_available() void *s3_phoenix_trio32_init() { s3_t *s3 = s3_init("roms/86C732P.bin", S3_TRIO32); - svga_t *svga = &s3->svga; s3->id = 0xe1; /*Trio32*/ s3->id_ext = 0x10; @@ -2245,7 +2242,6 @@ int s3_phoenix_trio32_available() void *s3_phoenix_trio64_init() { s3_t *s3 = s3_init("roms/86c764x1.bin", S3_TRIO64); - svga_t *svga = &s3->svga; s3->id = 0xe1; /*Trio64*/ s3->id_ext = s3->id_ext_pci = 0x11; diff --git a/src/vid_s3_virge.c b/src/vid_s3_virge.c index af21315..417e8ff 100644 --- a/src/vid_s3_virge.c +++ b/src/vid_s3_virge.c @@ -18,10 +18,10 @@ static int reg_writes = 0, reg_reads = 0; static int dither[4][4] = { - 0, 4, 1, 5, - 6, 2, 7, 3, - 1, 5, 0, 4, - 7, 3, 6, 2, + {0, 4, 1, 5}, + {6, 2, 7, 3}, + {1, 5, 0, 4}, + {7, 3, 6, 2}, }; #define RB_SIZE 256 @@ -1266,7 +1266,6 @@ static void fifo_thread(void *param) static void s3_virge_queue(virge_t *virge, uint32_t addr, uint32_t val, uint32_t type) { fifo_entry_t *fifo = &virge->fifo[virge->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { @@ -1291,7 +1290,6 @@ static void s3_virge_queue(virge_t *virge, uint32_t addr, uint32_t val, uint32_t static void s3_virge_mmio_write(uint32_t addr, uint8_t val, void *p) { virge_t *virge = (virge_t *)p; - svga_t *svga = &virge->svga; // pclog("New MMIO writeb %08X %02X %04x(%08x):%08x\n", addr, val, CS, cs, pc); reg_writes++; @@ -1870,7 +1868,6 @@ static void s3_virge_mmio_write_l(uint32_t addr, uint32_t val, void *p) static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) { - int cpu_input = (count != -1); uint8_t *vram = virge->svga.vram; uint32_t mono_pattern[64]; int count_mask; @@ -1974,7 +1971,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) { uint32_t src_addr = virge->s3d.src_base + (virge->s3d.src_x * x_mul) + (virge->s3d.src_y * virge->s3d.src_str); uint32_t dest_addr = virge->s3d.dest_base + (virge->s3d.dest_x * x_mul) + (virge->s3d.dest_y * virge->s3d.dest_str); - uint32_t source, dest, pattern; + uint32_t source = 0, dest, pattern; uint32_t out = 0; int update = 1; @@ -2890,6 +2887,9 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 uint32_t dest_offset, z_offset; + dest_offset = s3d_tri->dest_base + (state->y * s3d_tri->dest_str); + z_offset = s3d_tri->z_base + (state->y * s3d_tri->z_str); + if (s3d_tri->cmd_set & CMD_SET_HC) { if (state->y < s3d_tri->clip_t) @@ -2920,9 +2920,6 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 if ((state->y - y_count) < s3d_tri->clip_t) y_count = state->y - s3d_tri->clip_t; } - - dest_offset = s3d_tri->dest_base + (state->y * s3d_tri->dest_str); - z_offset = s3d_tri->z_base + (state->y * s3d_tri->z_str); for (; y_count > 0; y_count--) { @@ -2935,7 +2932,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 xe--; } - if (x != xe && (x_dir > 0 && x < xe) || (x_dir < 0 && x > xe)) + if (x != xe && ((x_dir > 0 && x < xe) || (x_dir < 0 && x > xe))) { uint32_t dest_addr, z_addr; int dx = (x_dir > 0) ? ((31 - ((state->x1-1) >> 15)) & 0x1f) : (((state->x1-1) >> 15) & 0x1f); @@ -3017,7 +3014,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 for (; x != xe; x = (x + x_dir) & 0xfff) { int update = 1; - uint16_t src_z; + uint16_t src_z = 0; _x = x; _y = state->y; if (use_z) @@ -3035,7 +3032,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 if (s3d_tri->cmd_set & CMD_SET_ABC_ENABLE) { uint32_t src_col; - int src_r, src_g, src_b; + int src_r = 0, src_g = 0, src_b = 0; switch (bpp) { @@ -3302,7 +3299,6 @@ static void render_thread(void *param) static void queue_triangle(virge_t *virge) { - int c; // pclog("queue_triangle: read=%i write=%i RB_ENTRIES=%i RB_FULL=%i\n", virge->s3d_read_idx, virge->s3d_write_idx, RB_ENTRIES, RB_FULL); if (RB_FULL) { @@ -3442,18 +3438,18 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) b[x_write+1] = y2 + dB; \ CLAMP(b[x_write+1]); \ \ - r[x_write+2] = y2 + dR; \ + r[x_write+2] = y3 + dR; \ CLAMP(r[x_write+2]); \ - g[x_write+2] = y2 - dG; \ + g[x_write+2] = y3 - dG; \ CLAMP(g[x_write+2]); \ - b[x_write+2] = y2 + dB; \ + b[x_write+2] = y3 + dB; \ CLAMP(b[x_write+2]); \ \ - r[x_write+3] = y2 + dR; \ + r[x_write+3] = y4 + dR; \ CLAMP(r[x_write+3]); \ - g[x_write+3] = y2 - dG; \ + g[x_write+3] = y4 - dG; \ CLAMP(g[x_write+3]); \ - b[x_write+3] = y2 + dB; \ + b[x_write+3] = y4 + dB; \ CLAMP(b[x_write+3]); \ \ x_write = (x_write + 4) & 7; \ @@ -3602,9 +3598,6 @@ static void s3_virge_overlay_draw(svga_t *svga, int displine) int offset = (virge->streams.sec_x - virge->streams.pri_x) + 1; int h_acc = virge->streams.dda_horiz_accumulator; int r[8], g[8], b[8]; - int r_samp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; - int g_samp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; - int b_samp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; int x_size, x_read = 4, x_write = 4; int x; uint32_t *p; diff --git a/src/vid_stg_ramdac.c b/src/vid_stg_ramdac.c index 06f4f03..f099198 100644 --- a/src/vid_stg_ramdac.c +++ b/src/vid_stg_ramdac.c @@ -72,7 +72,7 @@ void stg_ramdac_out(uint16_t addr, uint8_t val, stg_ramdac_t *ramdac, svga_t *sv uint8_t stg_ramdac_in(uint16_t addr, stg_ramdac_t *ramdac, svga_t *svga) { - uint8_t temp; + uint8_t temp = 0xff; //if (CS!=0xC000) pclog("IN RAMDAC %04X %04X:%04X\n",addr,CS,pc); switch (addr) { diff --git a/src/vid_svga.c b/src/vid_svga.c index 2a14e4f..9d62a33 100644 --- a/src/vid_svga.c +++ b/src/vid_svga.c @@ -293,7 +293,6 @@ void svga_recalctimings(svga_t *svga) { double crtcconst; double _dispontime, _dispofftime, disptime; - int hdisp_old; svga->vtotal = svga->crtc[6]; svga->dispend = svga->crtc[0x12]; diff --git a/src/vid_svga.h b/src/vid_svga.h index 8918b2b..438e69f 100644 --- a/src/vid_svga.h +++ b/src/vid_svga.h @@ -119,6 +119,7 @@ extern int svga_init(svga_t *svga, void *p, int memsize, void (*video_out)(uint16_t addr, uint8_t val, void *p), void (*hwcursor_draw)(struct svga_t *svga, int displine), void (*overlay_draw)(struct svga_t *svga, int displine)); +void svga_close(svga_t *svga); extern void svga_recalctimings(svga_t *svga); @@ -148,3 +149,5 @@ void svga_set_override(svga_t *svga, int val); #define RAMDAC_6BIT 0 #define RAMDAC_8BIT 1 void svga_set_ramdac_type(svga_t *svga, int type); + +void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga); diff --git a/src/vid_tandy.c b/src/vid_tandy.c index fb9e2b1..769a098 100644 --- a/src/vid_tandy.c +++ b/src/vid_tandy.c @@ -191,24 +191,6 @@ void tandy_recalctimings(tandy_t *tandy) } -static int ntsc_col[8][8]= -{ - {0,0,0,0,0,0,0,0}, /*Black*/ - {0,0,1,1,1,1,0,0}, /*Blue*/ - {1,0,0,0,0,1,1,1}, /*Green*/ - {0,0,0,0,1,1,1,1}, /*Cyan*/ - {1,1,1,1,0,0,0,0}, /*Red*/ - {0,1,1,1,1,0,0,0}, /*Magenta*/ - {1,1,0,0,0,0,1,1}, /*Yellow*/ - {1,1,1,1,1,1,1,1} /*White*/ -}; - -/*static int cga4pal[8][4]= -{ - {0,2,4,6},{0,3,5,7},{0,3,4,7},{0,3,4,7}, - {0,10,12,14},{0,11,13,15},{0,11,12,15},{0,11,12,15} -};*/ - void tandy_poll(void *p) { // int *cgapal=cga4pal[((tandy->col&0x10)>>2)|((cgamode&4)>>1)|((cgacol&0x20)>>5)]; @@ -222,10 +204,6 @@ void tandy_poll(void *p) int cols[4]; int col; int oldsc; - int y_buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}, y_val, y_tot; - int i_buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}, i_val, i_tot; - int q_buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}, q_val, q_tot; - int r, g, b; if (!tandy->linepos) { // cgapal[0]=tandy->col&15; diff --git a/src/vid_tandysl.c b/src/vid_tandysl.c index 4a1a37f..22f3521 100644 --- a/src/vid_tandysl.c +++ b/src/vid_tandysl.c @@ -686,7 +686,6 @@ static void tandysl_poll(void *p) static void *tandysl_init() { - int c; tandysl_t *tandy = malloc(sizeof(tandysl_t)); memset(tandy, 0, sizeof(tandysl_t)); diff --git a/src/vid_tgui9440.c b/src/vid_tgui9440.c index dc83048..bf8ded1 100644 --- a/src/vid_tgui9440.c +++ b/src/vid_tgui9440.c @@ -4,6 +4,7 @@ #include "device.h" #include "io.h" #include "mem.h" +#include "pci.h" #include "rom.h" #include "thread.h" #include "video.h" @@ -450,7 +451,6 @@ void tgui_hwcursor_draw(svga_t *svga, int displine) uint8_t tgui_pci_read(int func, int addr, void *p) { tgui_t *tgui = (tgui_t *)p; - svga_t *svga = &tgui->svga; // pclog("Trident PCI read %08X\n", addr); @@ -1029,7 +1029,6 @@ static void fifo_thread(void *param) uint64_t start_time = timer_read(); uint64_t end_time; fifo_entry_t *fifo = &tgui->fifo[tgui->fifo_read_idx & FIFO_MASK]; - uint32_t val = fifo->val; switch (fifo->addr_type & FIFO_TYPE) { @@ -1077,7 +1076,6 @@ static void tgui_wait_fifo_idle(tgui_t *tgui) static void tgui_queue(tgui_t *tgui, uint32_t addr, uint32_t val, uint32_t type) { fifo_entry_t *fifo = &tgui->fifo[tgui->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { diff --git a/src/vid_tkd8001_ramdac.c b/src/vid_tkd8001_ramdac.c index d47df85..0c806eb 100644 --- a/src/vid_tkd8001_ramdac.c +++ b/src/vid_tkd8001_ramdac.c @@ -5,9 +5,6 @@ #include "vid_svga.h" #include "vid_tkd8001_ramdac.h" -static int tkd8001_state=0; -static uint8_t tkd8001_ctrl; - void tkd8001_ramdac_out(uint16_t addr, uint8_t val, tkd8001_ramdac_t *ramdac, svga_t *svga) { // pclog("OUT RAMDAC %04X %02X %04X:%04X\n",addr,val,CS,pc); diff --git a/src/vid_voodoo.c b/src/vid_voodoo.c index b4f675a..6cee572 100644 --- a/src/vid_voodoo.c +++ b/src/vid_voodoo.c @@ -1,5 +1,6 @@ #include #include +#include #include "ibm.h" #include "device.h" #include "mem.h" @@ -49,7 +50,6 @@ static int tris = 0; static uint64_t status_time = 0; static uint64_t voodoo_time = 0; static int voodoo_render_time[2] = {0, 0}; -static int voodoo_render_time_old[2] = {0, 0}; typedef union int_float { @@ -989,10 +989,8 @@ static void voodoo_update_ncc(voodoo_t *voodoo, int tmu) for (col = 0; col < 256; col++) { int y = (col >> 4), i = (col >> 2) & 3, q = col & 3; - int _y = (col >> 4), _i = (col >> 2) & 3, _q = col & 3; int i_r, i_g, i_b; int q_r, q_g, q_b; - int r, g, b; y = (voodoo->nccTable[tmu][tbl].y[y >> 2] >> ((y & 3) * 8)) & 0xff; @@ -1103,8 +1101,6 @@ static void voodoo_recalc_tex(voodoo_t *voodoo, int tmu) int width = 256, height = 256; int shift = 8; int lod; - int lod_min = (voodoo->params.tLOD[tmu] >> 2) & 15; - int lod_max = (voodoo->params.tLOD[tmu] >> 8) & 15; uint32_t base = voodoo->params.texBaseAddr[tmu]; int tex_lod = 0; @@ -1493,8 +1489,6 @@ static void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu) { if (voodoo->texture_cache[tmu][c].base != -1) { - int lod_min = (voodoo->texture_cache[tmu][c].tLOD >> 2) & 15; - int lod_max = (voodoo->texture_cache[tmu][c].tLOD >> 8) & 15; int addr_start = voodoo->texture_cache[tmu][c].addr_start; int addr_end = voodoo->texture_cache[tmu][c].addr_end; @@ -1774,7 +1768,6 @@ static inline void tex_read_4(voodoo_state_t *state, voodoo_texture_state_t *tex static inline void voodoo_get_texture(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int tmu, int x) { - rgba_u tex_samples[4]; voodoo_texture_state_t texture_state; int d[4]; int s, t; @@ -1971,7 +1964,7 @@ static inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, v } \ else \ { \ - int fog_r, fog_g, fog_b, fog_a; \ + int fog_r, fog_g, fog_b, fog_a = 0; \ int fog_idx; \ \ if (!(params->fogMode & FOG_ADD)) \ @@ -2092,7 +2085,7 @@ static inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, v do \ { \ int _a; \ - int newdest_r, newdest_g, newdest_b; \ + int newdest_r = 0, newdest_g = 0, newdest_b = 0; \ \ switch (dest_afunc) \ { \ @@ -2247,12 +2240,12 @@ static inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, v #define dither2x2 (params->fbzMode & FBZ_DITHER_2x2) /*Perform texture fetch and blending for both TMUs*/ -static inline voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int x) +static inline void voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int x) { int r,g,b,a; int c_reverse, a_reverse; - int c_reverse1, a_reverse1; - int factor_r, factor_g, factor_b, factor_a; +// int c_reverse1, a_reverse1; + int factor_r = 0, factor_g = 0, factor_b = 0, factor_a = 0; voodoo_tmu_fetch(voodoo, params, state, 1, x); @@ -2266,8 +2259,8 @@ static inline voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *para c_reverse = !tc_reverse_blend; a_reverse = !tca_reverse_blend; } - c_reverse1 = c_reverse; - a_reverse1 = a_reverse; +/* c_reverse1 = c_reverse; + a_reverse1 = a_reverse;*/ if (tc_sub_clocal_1) { switch (tc_mselect_1) @@ -2589,6 +2582,8 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood #ifndef NO_CODEGEN if (voodoo->use_recompiler) voodoo_draw = voodoo_get_block(voodoo, params, state, odd_even); + else + voodoo_draw = NULL; #endif if (voodoo_output) @@ -2658,7 +2653,7 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood state->w += (params->dWdX * dx); if (voodoo_output) - pclog("%08llx %lli %lli\n", state->tmu0_t, state->tmu0_t >> (18+state->lod), (state->tmu0_t + (1 << 17+state->lod)) >> (18+state->lod)); + pclog("%08llx %lli %lli\n", state->tmu0_t, state->tmu0_t >> (18+state->lod), (state->tmu0_t + (1 << (17+state->lod))) >> (18+state->lod)); if (params->fbzMode & 1) { @@ -2717,8 +2712,8 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood if (x2 > x && state->xdir < 0) goto next_line; - state->fb_mem = fb_mem = &voodoo->fb_mem[params->draw_offset + (real_y * voodoo->row_width)]; - state->aux_mem = aux_mem = &voodoo->fb_mem[(params->aux_offset + (real_y * voodoo->row_width)) & voodoo->fb_mask]; + state->fb_mem = fb_mem = (uint16_t *)&voodoo->fb_mem[params->draw_offset + (real_y * voodoo->row_width)]; + state->aux_mem = aux_mem = (uint16_t *)&voodoo->fb_mem[(params->aux_offset + (real_y * voodoo->row_width)) & voodoo->fb_mask]; if (voodoo_output) pclog("%03i: x=%08x x2=%08x xstart=%08x xend=%08x dx=%08x start_x2=%08x\n", state->y, x, x2, state->xstart, state->xend, dx, start_x2); @@ -2750,11 +2745,10 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood int update = 1; uint8_t cother_r, cother_g, cother_b, aother; uint8_t clocal_r, clocal_g, clocal_b, alocal; - int src_r, src_g, src_b, src_a; + int src_r = 0, src_g = 0, src_b = 0, src_a = 0; int msel_r, msel_g, msel_b, msel_a; uint8_t dest_r, dest_g, dest_b, dest_a; uint16_t dat; - uint16_t aux_dat; int sel; int32_t new_depth, w_depth; @@ -3176,7 +3170,6 @@ static void voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_e { voodoo_state_t state; int vertexAy_adjusted; - int vertexBy_adjusted; int vertexCy_adjusted; int dx, dy; @@ -3252,7 +3245,6 @@ static void voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_e state.vertexCx |= 0xffff0000; vertexAy_adjusted = (state.vertexAy+7) >> 4; - vertexBy_adjusted = (state.vertexBy+7) >> 4; vertexCy_adjusted = (state.vertexCy+7) >> 4; if (state.vertexBy - state.vertexAy) @@ -3747,7 +3739,7 @@ static void blit_start(voodoo_t *voodoo) int size_x = ABS(voodoo->bltSizeX), size_y = ABS(voodoo->bltSizeY); int x_dir = (voodoo->bltSizeX > 0) ? 1 : -1; int y_dir = (voodoo->bltSizeY > 0) ? 1 : -1; - int src_x, dst_x; + int dst_x; int src_y = voodoo->bltSrcY & 0x7ff, dst_y = voodoo->bltDstY & 0x7ff; int src_stride = (voodoo->bltCommand & BLTCMD_SRC_TILED) ? ((voodoo->bltSrcXYStride & 0x3f) * 32*2) : (voodoo->bltSrcXYStride & 0xff8); int dst_stride = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstXYStride & 0x3f) * 32*2) : (voodoo->bltDstXYStride & 0xff8); @@ -3899,7 +3891,6 @@ skip_pixel_fill: static void blit_data(voodoo_t *voodoo, uint32_t data) { - uint32_t data_orig = data; int src_bits = 32; uint32_t base_addr = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstBaseAddr & 0x3ff) << 12) : (voodoo->bltDstBaseAddr & 0x3ffff8); uint16_t *dst = (uint16_t *)&voodoo->fb_mem[base_addr + voodoo->blt.dst_y*voodoo->blt.dst_stride]; @@ -3909,8 +3900,8 @@ static void blit_data(voodoo_t *voodoo, uint32_t data) while (src_bits && voodoo->blt.cur_x <= voodoo->blt.size_x) { - int r, g, b; - uint16_t src_dat, dst_dat; + int r = 0, g = 0, b = 0; + uint16_t src_dat = 0, dst_dat; int x = (voodoo->blt.x_dir > 0) ? (voodoo->blt.dst_x + voodoo->blt.cur_x) : (voodoo->blt.dst_x - voodoo->blt.cur_x); int rop = 0; @@ -5248,7 +5239,9 @@ static void voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) rgba8_t colour_data; uint16_t depth_data; uint8_t alpha_data; - int write_mask; + int write_mask = 0; + + colour_data.r = colour_data.g = colour_data.b = colour_data.a = 0; depth_data = voodoo->params.zaColor & 0xffff; alpha_data = voodoo->params.zaColor >> 24; @@ -5318,7 +5311,7 @@ static void voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) if (params->fogMode & FOG_ENABLE) { int32_t z = new_depth << 12; - int32_t w_depth = new_depth; + int64_t w_depth = (int64_t)(int32_t)new_depth; int32_t ia = alpha_data << 12; APPLY_FOG(write_data.r, write_data.g, write_data.b, z, ia, w_depth); @@ -5371,7 +5364,7 @@ static void voodoo_fb_writel(uint32_t addr, uint32_t val, void *p) rgba8_t colour_data[2]; uint16_t depth_data[2]; uint8_t alpha_data[2]; - int write_mask, count = 1; + int write_mask = 0, count = 1; depth_data[0] = depth_data[1] = voodoo->params.zaColor & 0xffff; alpha_data[0] = alpha_data[1] = voodoo->params.zaColor >> 24; @@ -5459,7 +5452,7 @@ static void voodoo_fb_writel(uint32_t addr, uint32_t val, void *p) if (params->fogMode & FOG_ENABLE) { int32_t z = new_depth << 12; - int32_t w_depth = new_depth; + int64_t w_depth = new_depth; int32_t ia = alpha_data[c] << 12; APPLY_FOG(write_data.r, write_data.g, write_data.b, z, ia, w_depth); @@ -5589,7 +5582,6 @@ static void voodoo_wake_timer(void *p) static inline void queue_command(voodoo_t *voodoo, uint32_t addr_type, uint32_t val) { fifo_entry_t *fifo = &voodoo->fifo[voodoo->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { @@ -5854,13 +5846,7 @@ static void voodoo_pixelclock_update(voodoo_t *voodoo) static void voodoo_writel(uint32_t addr, uint32_t val, void *p) { voodoo_t *voodoo = (voodoo_t *)p; - union - { - uint32_t i; - float f; - } tempif; - tempif.i = val; voodoo->wr_count++; addr &= 0xffffff; @@ -6032,7 +6018,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) } } else - voodoo->dac_readdata = voodoo->dac_data[voodoo->dac_readdata]; + voodoo->dac_readdata = voodoo->dac_data[voodoo->dac_readdata & 7]; } else { @@ -6881,7 +6867,6 @@ void voodoo_callback(void *p) if (voodoo->scrfilter && voodoo->scrfilterEnabled) { - int j, offset; uint8_t fil[(voodoo->h_disp) * 3]; /* interleaved 24-bit RGB */ if (voodoo->type == VOODOO_2) diff --git a/src/vid_voodoo_codegen_x86-64.h b/src/vid_voodoo_codegen_x86-64.h index 493dbdb..1e940a7 100644 --- a/src/vid_voodoo_codegen_x86-64.h +++ b/src/vid_voodoo_codegen_x86-64.h @@ -70,7 +70,6 @@ static __m128i xmm_ff_w;// = 0x00ff00ff00ff00ffull; static __m128i xmm_ff_b;// = 0x00000000ffffffffull; static uint32_t zero = 0; -static double const_1_48 = (double)(1ull << 4); static __m128i alookup[257], aminuslookup[256]; static __m128i minus_254;// = 0xff02ff02ff02ff02ull; @@ -161,7 +160,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*MOVZX EAX, logtable[RAX]*/ addbyte(0xb6); addbyte(0x80); - addlong((uint32_t)logtable); + addlong((uint32_t)(uintptr_t)logtable); addbyte(0x09); /*OR EAX, EDX*/ addbyte(0xd0); addbyte(0x03); /*ADD EAX, state->lod*/ @@ -339,7 +338,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x14); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EDX, params->tex_h_mask[ESI]*/ addbyte(0x96); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -353,7 +352,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x1c); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI]*/ addbyte(0x9e); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -400,7 +399,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x04); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x78); /*JS + - clamp on 0*/ addbyte(2+3+2+ 5+5+2); addbyte(0x3b); /*CMP EAX, EBP*/ @@ -501,7 +500,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x49); /*MOV R8, bilinear_lookup*/ addbyte(0xb8); - addquad(bilinear_lookup); + addquad((uintptr_t)bilinear_lookup); addbyte(0x66); /*PUNPCKLBW XMM0, XMM2*/ addbyte(0x0f); @@ -615,7 +614,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x04); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EAX, params->tex_w_mask[ESI+ECX*4]*/ addbyte(0x84); addbyte(0x8e); @@ -642,7 +641,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x1c); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI+ECX*4]*/ addbyte(0x9c); addbyte(0x8e); @@ -1080,7 +1079,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x83); - addlong((uint32_t)&xmm_00_ff_w[0]); + addlong((uint32_t)(uintptr_t)&xmm_00_ff_w[0]); } else if (!tc_reverse_blend_1) { @@ -1089,14 +1088,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM0, xmm_01_w*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)&xmm_01_w); + addlong((uint32_t)(uintptr_t)&xmm_01_w); addbyte(0xf3); /*MOVQ XMM1, XMM2*/ addbyte(0x0f); addbyte(0x7e); @@ -1217,7 +1216,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x33); /*XOR EAX, i_00_ff_w[ECX*4]*/ addbyte(0x04); addbyte(0x8d); - addlong((uint32_t)i_00_ff_w); + addlong((uint32_t)(uintptr_t)i_00_ff_w); } else if (!tc_reverse_blend_1) { @@ -1404,7 +1403,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0xa3); - addlong((uint32_t)&xmm_00_ff_w[0]); + addlong((uint32_t)(uintptr_t)&xmm_00_ff_w[0]); } else if (!tc_reverse_blend) { @@ -1413,14 +1412,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x24); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM4, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong(&xmm_01_w); + addlong((uint32_t)(uintptr_t)&xmm_01_w); addbyte(0xf3); /*MOVQ XMM5, XMM1*/ addbyte(0x0f); addbyte(0x7e); @@ -1488,7 +1487,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x0d); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PACKUSWB XMM0, XMM0*/ @@ -1585,7 +1584,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x33); /*XOR EBX, i_00_ff_w[ECX*4]*/ addbyte(0x1c); addbyte(0x8d); - addlong((uint32_t)i_00_ff_w); + addlong((uint32_t)(uintptr_t)i_00_ff_w); } else if (!tca_reverse_blend) { @@ -2143,14 +2142,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x1c); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM3, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x1c); addbyte(0x25); - addlong(&xmm_01_w); + addlong((uint32_t)(uintptr_t)&xmm_01_w); addbyte(0x66); /*PMULLW XMM0, XMM3*/ addbyte(0x0f); addbyte(0xd5); @@ -2194,7 +2193,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x04); addbyte(0x25); - addlong(&xmm_ff_b); + addlong((uint32_t)(uintptr_t)&xmm_ff_b); } if (params->fogMode & FOG_ENABLE) @@ -2441,7 +2440,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0x49); /*MOV R8, rgb565*/ addbyte(0xb8); - addquad(rgb565); + addquad((uintptr_t)rgb565); addbyte(0x8b); /*MOV EAX, state->x[EDI]*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, x)); @@ -2489,7 +2488,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)(uintptr_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2499,7 +2498,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2529,7 +2528,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2555,7 +2554,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)(uintptr_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2565,7 +2564,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2587,7 +2586,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x7e); addbyte(0x2c); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM0*/ addbyte(0x0f); addbyte(0xf9); @@ -2605,7 +2604,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2633,7 +2632,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(&minus_254); + addlong((uint32_t)(uintptr_t)&minus_254); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2643,7 +2642,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2674,7 +2673,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)(uintptr_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2684,7 +2683,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2714,7 +2713,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2740,7 +2739,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)(uintptr_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2750,7 +2749,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2772,7 +2771,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x7e); addbyte(0x2c); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM6*/ addbyte(0x0f); addbyte(0xf9); @@ -2790,7 +2789,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2842,7 +2841,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0x49); /*MOV R8, dither_rb*/ addbyte(0xb8); - addquad(dither2x2 ? dither_rb2x2 : dither_rb); + addquad(dither2x2 ? (uintptr_t)dither_rb2x2 : (uintptr_t)dither_rb); addbyte(0x4c); /*MOV ESI, real_y (R14)*/ addbyte(0x89); addbyte(0xf6); diff --git a/src/vid_voodoo_codegen_x86.h b/src/vid_voodoo_codegen_x86.h index ed02934..3091ec7 100644 --- a/src/vid_voodoo_codegen_x86.h +++ b/src/vid_voodoo_codegen_x86.h @@ -85,7 +85,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addlong(tmu ? offsetof(voodoo_state_t, tmu1_w) : offsetof(voodoo_state_t, tmu0_w)); addbyte(0xdd); /*FLDq const_1_48*/ addbyte(0x05); - addlong(&const_1_48); + addlong((uint32_t)&const_1_48); addbyte(0xde); /*FDIV ST(1)*/ addbyte(0xf1); addbyte(0xdf); /*FILDq state->tmu0_s*/ @@ -129,7 +129,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*MOVZX EBX, logtable[EBX]*/ addbyte(0xb6); addbyte(0x9b); - addlong(logtable); + addlong((uint32_t)logtable); addbyte(0x09); /*OR EAX, EBX*/ addbyte(0xd8); addbyte(0x03); /*ADD EAX, state->lod*/ @@ -322,7 +322,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*CMOVS EDX, zero*/ addbyte(0x48); addbyte(0x15); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EDX, params->tex_h_mask[ESI]*/ addbyte(0x96); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -335,7 +335,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*CMOVS EBX, zero*/ addbyte(0x48); addbyte(0x1d); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI]*/ addbyte(0x9e); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -379,7 +379,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*CMOVS EAX, zero*/ addbyte(0x48); addbyte(0x05); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x78); /*JS + - clamp on 0*/ addbyte(2+3+2+ 5+5+2); addbyte(0x3b); /*CMP EAX, EBP*/ @@ -489,7 +489,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x81); /*ADD ESI, bilinear_lookup*/ addbyte(0xc6); - addlong(bilinear_lookup); + addlong((uint32_t)bilinear_lookup); addbyte(0x66); /*PMULLW XMM0, bilinear_lookup[ESI]*/ addbyte(0x0f); @@ -592,7 +592,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*CMOVS EAX, zero*/ addbyte(0x48); addbyte(0x05); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EAX, params->tex_w_mask[ESI+ECX*4]*/ addbyte(0x84); addbyte(0x8e); @@ -618,7 +618,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*CMOVS EBX, zero*/ addbyte(0x48); addbyte(0x1d); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI+ECX*4]*/ addbyte(0x9c); addbyte(0x8e); @@ -1392,13 +1392,13 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM4, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x25); - addlong(&xmm_01_w); + addlong((uint32_t)&xmm_01_w); addbyte(0xf3); /*MOVQ XMM5, XMM1*/ addbyte(0x0f); addbyte(0x7e); @@ -1466,7 +1466,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x0d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); } addbyte(0x66); /*PACKUSWB XMM0, XMM0*/ @@ -2121,13 +2121,13 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x1d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM3, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x1d); - addlong(&xmm_01_w); + addlong((uint32_t)&xmm_01_w); addbyte(0x66); /*PMULLW XMM0, XMM3*/ addbyte(0x0f); addbyte(0xd5); @@ -2170,7 +2170,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x05); - addlong(&xmm_ff_b); + addlong((uint32_t)&xmm_ff_b); } //#if 0 // addbyte(0x66); /*MOVD state->out[EDI], XMM0*/ @@ -2459,7 +2459,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x6e); addbyte(0x24); addbyte(0x85); - addlong(rgb565); + addlong((uint32_t)rgb565); addbyte(0x66); /*PUNPCKLBW XMM4, XMM2*/ addbyte(0x0f); addbyte(0x60); @@ -2483,7 +2483,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2547,7 +2547,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2577,7 +2577,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x7e); addbyte(0x2d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM0*/ addbyte(0x0f); addbyte(0xf9); @@ -2621,7 +2621,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xd5); addbyte(0x25); - addlong(&minus_254); + addlong((uint32_t)&minus_254); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2661,7 +2661,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2725,7 +2725,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2755,7 +2755,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x7e); addbyte(0x2d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM6*/ addbyte(0x0f); addbyte(0xf9); @@ -2908,17 +2908,17 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xb6); addbyte(0x9c); addbyte(0x33); - addlong(dither2x2 ? dither_g2x2 : dither_g); + addlong(dither2x2 ? (uint32_t)dither_g2x2 : (uint32_t)dither_g); addbyte(0x0f); /*MOVZX ECX, dither_rb[ECX+ESI]*/ addbyte(0xb6); addbyte(0x8c); addbyte(0x31); - addlong(dither2x2 ? dither_rb2x2 : dither_rb); + addlong(dither2x2 ? (uint32_t)dither_rb2x2 : (uint32_t)dither_rb); addbyte(0x0f); /*MOVZX EAX, dither_rb[EAX+ESI]*/ addbyte(0xb6); addbyte(0x84); addbyte(0x30); - addlong(dither2x2 ? dither_rb2x2 : dither_rb); + addlong(dither2x2 ? (uint32_t)dither_rb2x2 : (uint32_t)dither_rb); addbyte(0xc1); /*SHL EBX, 5*/ addbyte(0xe3); addbyte(5); diff --git a/src/vid_wy700.c b/src/vid_wy700.c index 7f1cb27..df4cfad 100644 --- a/src/vid_wy700.c +++ b/src/vid_wy700.c @@ -2,6 +2,7 @@ #include #include "ibm.h" #include "device.h" +#include "io.h" #include "mem.h" #include "timer.h" #include "video.h" @@ -499,7 +500,7 @@ void wy700_textline(wy700_t *wy700) int x; int w = (wy700->wy700_mode == 0) ? 40 : 80; int cw = (wy700->wy700_mode == 0) ? 32 : 16; - uint8_t chr, attr, fg, bg; + uint8_t chr, attr; uint8_t bitmap[2]; uint8_t *fontbase = &fontdatw[0][0]; int blink, c; @@ -591,7 +592,7 @@ void wy700_cgaline(wy700_t *wy700) { int x, c; uint32_t dat; - uint8_t bitmap, ink; + uint8_t ink = 0; uint16_t addr; uint16_t ma = (wy700->cga_crtc[13] | (wy700->cga_crtc[12] << 8)) & 0x3fff; @@ -651,7 +652,7 @@ void wy700_medresline(wy700_t *wy700) { int x, c; uint32_t dat; - uint8_t bitmap, ink; + uint8_t ink = 0; uint32_t addr; addr = (wy700->displine >> 1) * 80 + 4 * wy700->wy700_base; @@ -709,7 +710,7 @@ void wy700_hiresline(wy700_t *wy700) { int x, c; uint32_t dat; - uint8_t bitmap, ink; + uint8_t ink = 0; uint32_t addr; addr = (wy700->displine >> 1) * 160 + 4 * wy700->wy700_base; @@ -765,10 +766,6 @@ void wy700_hiresline(wy700_t *wy700) void wy700_poll(void *p) { wy700_t *wy700 = (wy700_t *)p; - int x, c; - int oldvc; - uint8_t chr, attr; - uint16_t dat; int mode; if (!wy700->linepos) diff --git a/src/video.h b/src/video.h index 34ffb99..cce4a02 100644 --- a/src/video.h +++ b/src/video.h @@ -85,3 +85,13 @@ extern int vid_resize; void video_wait_for_blit(); void video_wait_for_buffer(); void loadfont(char *s, int format); + +void initvideo(); +void video_init(); +void closevideo(); + +void video_updatetiming(); + +void hline(BITMAP *b, int x1, int y, int x2, uint32_t col); + +void destroy_bitmap(BITMAP *b); diff --git a/src/win-config.c b/src/win-config.c index 7d7acb6..af34d0c 100644 --- a/src/win-config.c +++ b/src/win-config.c @@ -11,6 +11,7 @@ #include "fdd.h" #include "gameport.h" #include "hdd.h" +#include "mem.h" #include "model.h" #include "mouse.h" #include "nvr.h" @@ -143,7 +144,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR char temp_str[256]; HWND h; int c, d; - int rom, gfx, mem, fpu; + int gfx, mem, fpu; int temp_cpu, temp_cpu_m, temp_model; int temp_GAMEBLASTER, temp_GUS, temp_SSI2001, temp_voodoo, temp_sound_card_current; int temp_dynarec; @@ -152,7 +153,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR int temp_joystick_type; int cpu_type; int temp_mouse_type; - int hdd_changed; + int hdd_changed = 0; UDACCEL accel; // pclog("Dialog msg %i %08X\n",message,message); @@ -810,5 +811,5 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR void config_open(HWND hwnd) { - DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, config_dlgproc); + DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, (DLGPROC)config_dlgproc); } diff --git a/src/win-d3d-fs.cc b/src/win-d3d-fs.cc index 74a6444..32aa00d 100644 --- a/src/win-d3d-fs.cc +++ b/src/win-d3d-fs.cc @@ -75,8 +75,6 @@ static CUSTOMVERTEX d3d_verts[] = void d3d_fs_init(HWND h) { int c; - HRESULT hr; - d3d_fs_w = GetSystemMetrics(SM_CXSCREEN); d3d_fs_h = GetSystemMetrics(SM_CYSCREEN); @@ -118,7 +116,7 @@ void d3d_fs_init(HWND h) d3dpp.BackBufferWidth = d3d_fs_w; d3dpp.BackBufferHeight = d3d_fs_h; - hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); + d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); d3d_fs_init_objects(); @@ -142,12 +140,11 @@ static void d3d_fs_close_objects() static void d3d_fs_init_objects() { - HRESULT hr; D3DLOCKED_RECT dr; int y; RECT r; - hr = d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX), + d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX), 0, D3DFVF_XYZRHW | D3DFVF_TEX1, D3DPOOL_MANAGED, @@ -164,7 +161,7 @@ static void d3d_fs_init_objects() for (y = 0; y < 2048; y++) { - uint32_t *p = (uint32_t *)(dr.pBits + (y * dr.Pitch)); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch)); memset(p, 0, 2048 * 4); } @@ -225,16 +222,7 @@ void d3d_fs_reset() void d3d_fs_close() { - if (d3dTexture) - { - d3dTexture->Release(); - d3dTexture = NULL; - } - if (v_buffer) - { - v_buffer->Release(); - v_buffer = NULL; - } + d3d_fs_close_objects(); if (d3ddev) { d3ddev->Release(); @@ -304,7 +292,6 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) VOID* pVoid; D3DLOCKED_RECT dr; RECT window_rect; - uint32_t *p, *src; int yy; double l, t, r, b; @@ -327,7 +314,7 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) fatal("LockRect failed\n"); for (yy = y1; yy < y2; yy++) - memcpy(dr.pBits + ((yy - y1) * dr.Pitch), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); + memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); video_blit_complete(); d3dTexture->UnlockRect(0); @@ -403,7 +390,6 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) VOID* pVoid; D3DLOCKED_RECT dr; RECT window_rect; - uint32_t *p, *src; int xx, yy; double l, t, r, b; @@ -427,7 +413,7 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) for (yy = 0; yy < h; yy++) { - uint32_t *p = (uint32_t *)(dr.pBits + (yy * dr.Pitch)); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (yy * dr.Pitch)); if ((y + yy) >= 0 && (y + yy) < buffer->h) { for (xx = 0; xx < w; xx++) diff --git a/src/win-d3d.cc b/src/win-d3d.cc index c08f887..eda7ef9 100644 --- a/src/win-d3d.cc +++ b/src/win-d3d.cc @@ -70,7 +70,6 @@ static CUSTOMVERTEX d3d_verts[] = void d3d_init(HWND h) { int c; - HRESULT hr; for (c = 0; c < 256; c++) pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2); @@ -95,7 +94,7 @@ void d3d_init(HWND h) d3dpp.BackBufferWidth = 0; d3dpp.BackBufferHeight = 0; - hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); + d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); d3d_init_objects(); @@ -119,12 +118,11 @@ void d3d_close_objects() void d3d_init_objects() { - HRESULT hr; D3DLOCKED_RECT dr; int y; RECT r; - hr = d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX), + d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX), 0, D3DFVF_XYZRHW | D3DFVF_TEX1, D3DPOOL_MANAGED, @@ -141,7 +139,7 @@ void d3d_init_objects() for (y = 0; y < 2048; y++) { - uint32_t *p = (uint32_t *)(dr.pBits + (y * dr.Pitch)); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch)); memset(p, 0, 2048 * 4); } @@ -157,8 +155,6 @@ void d3d_init_objects() void d3d_resize(int x, int y) { - HRESULT hr; - d3dpp.BackBufferWidth = x; d3dpp.BackBufferHeight = y; @@ -230,7 +226,6 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) VOID* pVoid; D3DLOCKED_RECT dr; RECT r; - uint32_t *p, *src; int yy; if (y1 == y2) @@ -250,7 +245,7 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) fatal("LockRect failed\n"); for (yy = y1; yy < y2; yy++) - memcpy(dr.pBits + ((yy - y1) * dr.Pitch), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); + memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); video_blit_complete(); d3dTexture->UnlockRect(0); @@ -312,7 +307,6 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) VOID* pVoid; D3DLOCKED_RECT dr; RECT r; - uint32_t *p, *src; int yy, xx; HRESULT hr = D3D_OK; @@ -334,7 +328,7 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) for (yy = 0; yy < h; yy++) { - uint32_t *p = (uint32_t *)(dr.pBits + (yy * dr.Pitch)); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (yy * dr.Pitch)); if ((y + yy) >= 0 && (y + yy) < buffer->h) { for (xx = 0; xx < w; xx++) diff --git a/src/win-ddraw-fs.cc b/src/win-ddraw-fs.cc index 993c397..e64a849 100644 --- a/src/win-ddraw-fs.cc +++ b/src/win-ddraw-fs.cc @@ -215,7 +215,7 @@ static void ddraw_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h return; } for (yy = y1; yy < y2; yy++) - memcpy(ddsd.lpSurface + (yy * ddsd.lPitch), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); + memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); video_blit_complete(); lpdds_back->Unlock(NULL); @@ -290,7 +290,7 @@ static void ddraw_fs_blit_memtoscreen_8(int x, int y, int w, int h) { if ((y + yy) >= 0 && (y + yy) < buffer->h) { - uint32_t *p = (uint32_t *)(ddsd.lpSurface + (yy * ddsd.lPitch)); + uint32_t *p = (uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)); for (xx = 0; xx < w; xx++) p[xx] = pal_lookup[buffer->line[y + yy][x + xx]]; } diff --git a/src/win-ddraw.cc b/src/win-ddraw.cc index c658a7a..5fdf813 100644 --- a/src/win-ddraw.cc +++ b/src/win-ddraw.cc @@ -172,7 +172,7 @@ static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) for (yy = y1; yy < y2; yy++) { if ((y + yy) >= 0 && (y + yy) < buffer->h) - memcpy(ddsd.lpSurface + (yy * ddsd.lPitch), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); + memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); } video_blit_complete(); lpdds_back->Unlock(NULL); @@ -208,7 +208,7 @@ static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) if (!ddsd.lpSurface) return; for (yy = 8; yy < 14; yy++) { - p = (uint32_t *)(ddsd.lpSurface + (yy * ddsd.lPitch)); + p = (uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)); for (xx = (w - 40); xx < (w - 8); xx++) p[xx] = 0xffffffff; } @@ -253,12 +253,12 @@ static void ddraw_blit_memtoscreen_8(int x, int y, int w, int h) { if ((y + yy) >= 0 && (y + yy) < buffer->h) { - p = (uint32_t *)(ddsd.lpSurface + (yy * ddsd.lPitch)); + p = (uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)); for (xx = 0; xx < w; xx++) p[xx] = pal_lookup[buffer->line[y + yy][x + xx]]; } } - p = (uint32_t *)(ddsd.lpSurface + (4 * ddsd.lPitch)); + p = (uint32_t *)((uintptr_t)ddsd.lpSurface + (4 * ddsd.lPitch)); lpdds_back->Unlock(NULL); video_blit_complete(); @@ -293,7 +293,7 @@ static void ddraw_blit_memtoscreen_8(int x, int y, int w, int h) if (!ddsd.lpSurface) return; for (yy = 8; yy < 14; yy++) { - p = (uint32_t *)(ddsd.lpSurface + (yy * ddsd.lPitch)); + p = (uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)); for (xx = (w - 40); xx < (w - 8); xx++) p[xx] = 0xffffffff; } diff --git a/src/win-deviceconfig.c b/src/win-deviceconfig.c index 8f6b72c..5481269 100644 --- a/src/win-deviceconfig.c +++ b/src/win-deviceconfig.c @@ -6,6 +6,7 @@ #include "ibm.h" #include "config.h" #include "device.h" +#include "plat-midi.h" #include "resources.h" #include "win.h" @@ -26,7 +27,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam device_config_selection_t *selection = config->selection; HWND h = GetDlgItem(hdlg, id); int val_int; - char *val_string; int num; char s[80]; @@ -91,7 +91,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam device_config_selection_t *selection = config->selection; HWND h = GetDlgItem(hdlg, id); int val_int; - char *val_string; switch (config->type) { @@ -151,8 +150,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam { device_config_selection_t *selection = config->selection; HWND h = GetDlgItem(hdlg, id); - int val_int; - char *val_string; switch (config->type) { @@ -224,7 +221,7 @@ void deviceconfig_open(HWND hwnd, device_t *device) *data++ = 8; /*Point*/ data += MultiByteToWideChar(CP_ACP, 0, "MS Sans Serif", -1, data, 50); - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; while (config->type != -1) @@ -272,7 +269,7 @@ void deviceconfig_open(HWND hwnd, device_t *device) data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; /*Static text*/ @@ -293,14 +290,14 @@ void deviceconfig_open(HWND hwnd, device_t *device) data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; y += 20; break; } - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; config++; @@ -326,7 +323,7 @@ void deviceconfig_open(HWND hwnd, device_t *device) data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; item = (DLGITEMTEMPLATE *)data; @@ -348,7 +345,7 @@ void deviceconfig_open(HWND hwnd, device_t *device) config_device = device; - DialogBoxIndirect(hinstance, dlg, hwnd, deviceconfig_dlgproc); + DialogBoxIndirect(hinstance, dlg, hwnd, (DLGPROC)deviceconfig_dlgproc); free(data_block); } diff --git a/src/win-hdconf.c b/src/win-hdconf.c index f135f90..ffeb33c 100644 --- a/src/win-hdconf.c +++ b/src/win-hdconf.c @@ -4,6 +4,7 @@ #undef BITMAP #include "ibm.h" +#include "hdd.h" #include "ide.h" #include "resources.h" #include "win.h" @@ -208,7 +209,7 @@ static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARA sscanf(s, "%i", &hd[0].tracks); h = GetDlgItem(hdlg, IDC_TEXT1); - sprintf(s, "Size : %imb", (((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_type = 0; @@ -243,7 +244,7 @@ static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARA SendMessage(h, WM_SETTEXT, 0, (LPARAM)"17"); h = GetDlgItem(hdlg, IDC_TEXT1); - sprintf(s, "Size : %imb", (((uint64_t)hd_types[hd_type-1].cylinders*hd_types[hd_type-1].heads*17*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((uint64_t)hd_types[hd_type-1].cylinders*hd_types[hd_type-1].heads*17*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); } } @@ -285,7 +286,7 @@ BOOL CALLBACK hdsize_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPar SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); h = GetDlgItem(hdlg, IDC_TEXT1); - sprintf(s, "Size : %imb", ((((uint64_t)hd_new_spt*(uint64_t)hd_new_hpc*(uint64_t)hd_new_cyl)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)((((uint64_t)hd_new_spt*(uint64_t)hd_new_hpc*(uint64_t)hd_new_cyl)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); return TRUE; @@ -337,7 +338,7 @@ BOOL CALLBACK hdsize_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPar sscanf(s, "%i", &hd[0].tracks); h = GetDlgItem(hdlg, IDC_TEXT1); - sprintf(s, "Size : %imb", (((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); return TRUE; } @@ -413,19 +414,19 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[3]); h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd[1].tracks*(uint64_t)hd[1].hpc)*(uint64_t)hd[1].spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[1].tracks*(uint64_t)hd[1].hpc)*(uint64_t)hd[1].spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd[2].tracks*(uint64_t)hd[2].hpc)*(uint64_t)hd[2].spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[2].tracks*(uint64_t)hd[2].hpc)*(uint64_t)hd[2].spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd[3].tracks*(uint64_t)hd[3].hpc)*(uint64_t)hd[3].spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[3].tracks*(uint64_t)hd[3].hpc)*(uint64_t)hd[3].spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); new_cdrom_channel = cdrom_channel; @@ -552,7 +553,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return TRUE; case IDC_CNEW: - if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdNewDlgMfm") : TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) + if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdNewDlgMfm") : TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); sprintf(s, "%i", hd_new_spt); @@ -567,7 +568,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -588,7 +589,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR fclose(f); check_hd_type(sz); - if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdSizeDlgMfm") : TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1) + if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdSizeDlgMfm") : TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); sprintf(s, "%i", hd_new_spt); @@ -603,7 +604,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); h= GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -612,7 +613,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return TRUE; case IDC_DNEW: - if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdNewDlgMfm") : TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) + if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdNewDlgMfm") : TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); sprintf(s, "%i", hd_new_spt); @@ -627,7 +628,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); h= GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -648,7 +649,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR fclose(f); check_hd_type(sz); - if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdSizeDlgMfm") : TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1) + if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdSizeDlgMfm") : TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); sprintf(s, "%i", hd_new_spt); @@ -663,7 +664,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -672,7 +673,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return TRUE; case IDC_ENEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) + if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); sprintf(s, "%i", hd_new_spt); @@ -687,7 +688,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); h= GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -708,7 +709,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR fclose(f); check_hd_type(sz); - if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1) + if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); sprintf(s, "%i", hd_new_spt); @@ -723,7 +724,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -732,7 +733,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return TRUE; case IDC_FNEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) + if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); sprintf(s, "%i", hd_new_spt); @@ -747,7 +748,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); h= GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -768,7 +769,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR fclose(f); check_hd_type(sz); - if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1) + if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1) { h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); sprintf(s, "%i", hd_new_spt); @@ -783,7 +784,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); + sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024); SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); hd_changed = 1; @@ -902,7 +903,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR void hdconf_open(HWND hwnd) { if (hdd_controller_current_is_mfm()) - DialogBox(hinstance, TEXT("HdConfDlgMfm"), hwnd, hdconf_dlgproc); + DialogBox(hinstance, TEXT("HdConfDlgMfm"), hwnd, (DLGPROC)hdconf_dlgproc); else - DialogBox(hinstance, TEXT("HdConfDlg"), hwnd, hdconf_dlgproc); + DialogBox(hinstance, TEXT("HdConfDlg"), hwnd, (DLGPROC)hdconf_dlgproc); } diff --git a/src/win-joystick.cc b/src/win-joystick.cc index dbe5db2..48ed2cc 100644 --- a/src/win-joystick.cc +++ b/src/win-joystick.cc @@ -106,7 +106,6 @@ void joystick_init() DIPROPRANGE joy_axis_range; DIDEVICEINSTANCE device_instance; DIDEVCAPS devcaps; - int d; if (FAILED(lpdi->CreateDevice(joystick_guids[c], &lpdi_joystick_temp, NULL))) fatal("joystick_init : CreateDevice failed\n"); diff --git a/src/win-joystickconfig.c b/src/win-joystickconfig.c index b5371de..48ede2c 100644 --- a/src/win-joystickconfig.c +++ b/src/win-joystickconfig.c @@ -153,7 +153,7 @@ static BOOL CALLBACK joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wPar case WM_INITDIALOG: { HWND h = GetDlgItem(hdlg, IDC_CONFIG_BASE); - int c, d; + int c; int id = IDC_CONFIG_BASE + 2; int joystick = joystick_state[joystick_nr].plat_joystick_nr; @@ -227,8 +227,7 @@ static BOOL CALLBACK joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wPar case IDOK: { HWND h; - int joystick; - int c, d; + int c; int id = IDC_CONFIG_BASE + 2; h = GetDlgItem(hdlg, IDC_CONFIG_BASE); @@ -298,7 +297,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) *data++ = 8; /*Point*/ data += MultiByteToWideChar(CP_ACP, 0, "MS Sans Serif", -1, data, 50); - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; @@ -320,7 +319,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; /*Static text*/ @@ -341,7 +340,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, "Device :", -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; y += 20; @@ -367,7 +366,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; /*Static text*/ @@ -388,7 +387,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; y += 20; @@ -414,7 +413,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; /*Static text*/ @@ -435,7 +434,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; y += 20; @@ -467,7 +466,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; /*Static text*/ @@ -488,7 +487,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; y += 20; @@ -514,7 +513,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50); *data++ = 0; // no creation data - if (((unsigned long)data) & 2) + if (((uintptr_t)data) & 2) data++; item = (DLGITEMTEMPLATE *)data; @@ -536,7 +535,7 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type) // config_device = device; - DialogBoxIndirect(hinstance, dlg, hwnd, joystickconfig_dlgproc); + DialogBoxIndirect(hinstance, dlg, hwnd, (DLGPROC)joystickconfig_dlgproc); free(data_block); } diff --git a/src/win-midi.c b/src/win-midi.c index 227e6da..895df6a 100644 --- a/src/win-midi.c +++ b/src/win-midi.c @@ -1,6 +1,7 @@ #include #include #include "ibm.h" +#include "config.h" #include "plat-midi.h" static int midi_id; @@ -10,9 +11,6 @@ void midi_close(); void midi_init() { - int c; - int n; - MIDIOUTCAPS ocaps; MMRESULT hr; midi_id = config_get_int(NULL, "midi", 0); @@ -64,9 +62,8 @@ static uint8_t midi_sysex_data[1024+2]; static void midi_send_sysex() { MIDIHDR hdr; - int c; - hdr.lpData = midi_sysex_data; + hdr.lpData = (LPSTR)midi_sysex_data; hdr.dwBufferLength = midi_pos; hdr.dwFlags = 0; diff --git a/src/win-status.c b/src/win-status.c index 5bbb911..f60fa2c 100644 --- a/src/win-status.c +++ b/src/win-status.c @@ -98,6 +98,6 @@ static BOOL CALLBACK status_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR void status_open(HWND hwnd) { - status_hwnd = CreateDialog(hinstance, TEXT("StatusDlg"), hwnd, status_dlgproc); + status_hwnd = CreateDialog(hinstance, TEXT("StatusDlg"), hwnd, (DLGPROC)status_dlgproc); ShowWindow(status_hwnd, SW_SHOW); } diff --git a/src/win.c b/src/win.c index d010d6a..7129420 100644 --- a/src/win.c +++ b/src/win.c @@ -17,19 +17,22 @@ #include "cdrom-ioctl.h" #include "cdrom-iso.h" #include "config.h" -#include "video.h" -#include "resources.h" #include "cpu.h" +#include "device.h" +#include "disc.h" +#include "disc_img.h" #include "ide.h" +#include "mem.h" #include "model.h" #include "mouse.h" #include "nvr.h" +#include "resources.h" #include "sound.h" #include "thread.h" -#include "disc.h" -#include "disc_img.h" +#include "video.h" #include "plat-midi.h" +#include "plat-mouse.h" #include "plat-keyboard.h" #include "win.h" @@ -59,12 +62,12 @@ static struct } vid_apis[2][2] = { { - ddraw_init, ddraw_close, NULL, - d3d_init, d3d_close, d3d_resize + {ddraw_init, ddraw_close, NULL}, + {d3d_init, d3d_close, d3d_resize} }, { - ddraw_fs_init, ddraw_fs_close, NULL, - d3d_fs_init, d3d_fs_close, NULL + {ddraw_fs_init, ddraw_fs_close, NULL}, + {d3d_fs_init, d3d_fs_close, NULL} }, }; @@ -119,7 +122,6 @@ void warning(const char *format, ...) void updatewindowsize(int x, int y) { - RECT r; if (vid_resize) return; winsizex=x; winsizey=y; @@ -155,7 +157,6 @@ uint64_t main_time; void mainthread(LPVOID param) { - int t = 0; int frames = 0; DWORD old_time, new_time; @@ -380,7 +381,7 @@ void get_registry_key_map() HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, 1, &hKey) == ERROR_SUCCESS) { - if(RegQueryValueEx(hKey, valueName, NULL, NULL, buf, &bufSize) == ERROR_SUCCESS) + if(RegQueryValueEx(hKey, valueName, NULL, NULL, (LPBYTE)buf, &bufSize) == ERROR_SUCCESS) { UINT32 *bufEx2 = (UINT32 *) buf; int scMapCount = bufEx2[2]; diff --git a/src/win.h b/src/win.h index ca76f58..2c59d47 100644 --- a/src/win.h +++ b/src/win.h @@ -24,6 +24,8 @@ void hdconf_open(HWND hwnd); void config_open(HWND hwnd); +struct device_t; + void deviceconfig_open(HWND hwnd, struct device_t *device); void joystickconfig_open(HWND hwnd, int joy_nr, int type); diff --git a/src/x86.h b/src/x86.h index 9160832..dc60e05 100644 --- a/src/x86.h +++ b/src/x86.h @@ -102,3 +102,12 @@ void x86gpf(char *s, uint16_t error); extern uint16_t zero; extern int x86_was_reset; + +void resetx86(); +void softresetx86(); +void refreshread(); +void dumpregs(); + +void execx86(int cycs); +void exec386(int cycs); +void exec386_dynarec(int cycs); diff --git a/src/x86_flags.h b/src/x86_flags.h index 9481886..3fa9cc5 100644 --- a/src/x86_flags.h +++ b/src/x86_flags.h @@ -68,6 +68,7 @@ static inline int ZF_SET() case FLAGS_UNKNOWN: return flags & Z_FLAG; } + return 0; } static inline int NF_SET() @@ -107,6 +108,7 @@ static inline int NF_SET() case FLAGS_UNKNOWN: return flags & N_FLAG; } + return 0; } static inline int PF_SET() @@ -142,6 +144,7 @@ static inline int PF_SET() case FLAGS_UNKNOWN: return flags & P_FLAG; } + return 0; } static inline int VF_SET() @@ -193,6 +196,7 @@ static inline int VF_SET() case FLAGS_UNKNOWN: return flags & V_FLAG; } + return 0; } static inline int AF_SET() @@ -232,6 +236,7 @@ static inline int AF_SET() case FLAGS_UNKNOWN: return flags & A_FLAG; } + return 0; } static inline int CF_SET() @@ -283,6 +288,7 @@ static inline int CF_SET() case FLAGS_UNKNOWN: return flags & C_FLAG; } + return 0; } //#define ZF_SET() (flags & Z_FLAG) diff --git a/src/x86_ops_bit.h b/src/x86_ops_bit.h index 8fb0bf9..272d22b 100644 --- a/src/x86_ops_bit.h +++ b/src/x86_ops_bit.h @@ -1,6 +1,5 @@ static int opBT_w_r_a16(uint32_t fetchdat) { - int tempc; uint16_t temp; fetch_ea_16(fetchdat); diff --git a/src/x86_ops_call.h b/src/x86_ops_call.h index 85e3f27..bbb5dca 100644 --- a/src/x86_ops_call.h +++ b/src/x86_ops_call.h @@ -61,7 +61,7 @@ static int opCALL_far_w(uint32_t fetchdat) { uint32_t old_cs, old_pc; uint16_t new_cs, new_pc; - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); new_pc = getwordf(); new_cs = getword(); if (cpu_state.abrt) return 1; @@ -77,7 +77,7 @@ static int opCALL_far_l(uint32_t fetchdat) { uint32_t old_cs, old_pc; uint32_t new_cs, new_pc; - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); new_pc = getlong(); new_cs = getword(); if (cpu_state.abrt) return 1; @@ -95,7 +95,7 @@ static int opFF_w_a16(uint32_t fetchdat) { uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); uint16_t temp; @@ -172,7 +172,7 @@ static int opFF_w_a32(uint32_t fetchdat) { uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); uint16_t temp; @@ -250,7 +250,7 @@ static int opFF_l_a16(uint32_t fetchdat) { uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); uint32_t temp; @@ -327,7 +327,7 @@ static int opFF_l_a32(uint32_t fetchdat) { uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); uint32_t temp; diff --git a/src/x86_ops_int.h b/src/x86_ops_int.h index f203c5b..6dbb63a 100644 --- a/src/x86_ops_int.h +++ b/src/x86_ops_int.h @@ -1,6 +1,6 @@ static int opINT3(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3)) { x86gpf(NULL,0); @@ -14,7 +14,7 @@ static int opINT3(uint32_t fetchdat) static int opINT(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); uint8_t temp; /*if (msw&1) pclog("INT %i %i %i\n",cr0&1,eflags&VM_FLAG,IOPL);*/ @@ -64,7 +64,7 @@ static int opINT(uint32_t fetchdat) static int opINTO(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3)) { diff --git a/src/x86_ops_misc.h b/src/x86_ops_misc.h index c3d12e8..5ced32a 100644 --- a/src/x86_ops_misc.h +++ b/src/x86_ops_misc.h @@ -748,7 +748,7 @@ static int opLOADALL(uint32_t fetchdat) return 0; } -static int set_segment_limit(x86seg *s, uint8_t segdat3) +static void set_segment_limit(x86seg *s, uint8_t segdat3) { if ((s->access & 0x18) != 0x10 || !(s->access & (1 << 2))) /*expand-down*/ { @@ -762,7 +762,7 @@ static int set_segment_limit(x86seg *s, uint8_t segdat3) } } -static int loadall_load_segment(uint32_t addr, x86seg *s) +static void loadall_load_segment(uint32_t addr, x86seg *s) { uint32_t attrib = readmeml(0, addr); uint32_t segdat3 = (attrib >> 16) & 0xff; diff --git a/src/x86_ops_pmode.h b/src/x86_ops_pmode.h index 0510717..bfd67c5 100644 --- a/src/x86_ops_pmode.h +++ b/src/x86_ops_pmode.h @@ -49,7 +49,7 @@ static int opARPL_a32(uint32_t fetchdat) static int opLAR_ ## name(uint32_t fetchdat) \ { \ int valid; \ - uint16_t sel, desc; \ + uint16_t sel, desc = 0; \ \ NOTRM \ fetch_ea(fetchdat); \ @@ -99,7 +99,7 @@ opLAR(l_a32, fetch_ea_32, 1, 1) static int opLSL_ ## name(uint32_t fetchdat) \ { \ int valid; \ - uint16_t sel, desc; \ + uint16_t sel, desc = 0; \ \ NOTRM \ fetch_ea(fetchdat); \ diff --git a/src/x86_ops_ret.h b/src/x86_ops_ret.h index 4a0caf0..3a600ce 100644 --- a/src/x86_ops_ret.h +++ b/src/x86_ops_ret.h @@ -44,7 +44,7 @@ static int opRETF_a16(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); CPU_BLOCK_END(); RETF_a16(0); @@ -55,7 +55,7 @@ static int opRETF_a16(uint32_t fetchdat) } static int opRETF_a32(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); CPU_BLOCK_END(); RETF_a32(0); @@ -67,8 +67,8 @@ static int opRETF_a32(uint32_t fetchdat) static int opRETF_a16_imm(uint32_t fetchdat) { - int cycles_old = cycles; uint16_t offset = getwordf(); + int cycles_old = cycles; UNUSED(cycles_old); CPU_BLOCK_END(); RETF_a16(offset); @@ -79,8 +79,8 @@ static int opRETF_a16_imm(uint32_t fetchdat) } static int opRETF_a32_imm(uint32_t fetchdat) { - int cycles_old = cycles; uint16_t offset = getwordf(); + int cycles_old = cycles; UNUSED(cycles_old); CPU_BLOCK_END(); RETF_a32(offset); @@ -92,7 +92,7 @@ static int opRETF_a32_imm(uint32_t fetchdat) static int opIRET_286(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3)) { @@ -137,7 +137,7 @@ static int opIRET_286(uint32_t fetchdat) static int opIRET(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3)) { @@ -182,7 +182,7 @@ static int opIRET(uint32_t fetchdat) static int opIRETD(uint32_t fetchdat) { - int cycles_old = cycles; + int cycles_old = cycles; UNUSED(cycles_old); if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3)) { diff --git a/src/x86seg.c b/src/x86seg.c index bedf39e..69a0ce0 100644 --- a/src/x86seg.c +++ b/src/x86seg.c @@ -6,6 +6,7 @@ #include "mem.h" #include "x86.h" #include "386.h" +#include "386_common.h" #include "cpu.h" /*Controls whether the accessed bit in a descriptor is set when CS is loaded.*/ @@ -30,7 +31,7 @@ void taskswitch286(uint16_t seg, uint16_t *segdat, int is32); void taskswitch386(uint16_t seg, uint16_t *segdat); int output; -void pmodeint(int num, int soft); + /*NOT PRESENT is INT 0B GPF is INT 0D*/ @@ -534,7 +535,6 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc) { uint16_t segdat[4]; uint32_t addr; - int count; uint16_t type,seg2; uint32_t newpc; // pclog("Load CS JMP %04X\n",seg); @@ -638,7 +638,6 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc) cgate16=!cgate32; oldcs=CS; cpu_state.oldpc = cpu_state.pc; - count=segdat[2]&31; if ((DPL < CPL) || (DPL < (seg&3))) { x86gpf(NULL,seg&~3); @@ -843,8 +842,7 @@ void loadcscall(uint16_t seg) uint32_t addr,oldssbase=ss, oaddr; uint32_t newpc; int count; - uint16_t oldcs=CPL; - uint32_t oldss,oldsp,newsp,oldpc, oldsp2; + uint32_t oldss,oldsp,newsp,oldsp2; int type; uint16_t tempw; @@ -957,8 +955,6 @@ void loadcscall(uint16_t seg) if (output) pclog("Callgate %08X\n", cpu_state.pc); cgate32=(type&0x800); cgate16=!cgate32; - oldcs=CS; - oldpc=cpu_state.pc; count=segdat[2]&31; if ((DPL < CPL) || (DPL < (seg&3))) { @@ -1579,8 +1575,7 @@ void pmodeint(int num, int soft) uint32_t oldss,oldsp; int type; uint32_t newsp; - uint16_t seg; - int stack_changed=0; + uint16_t seg=0; int new_cpl; // if (!num) pclog("Pmode int 0 at %04X(%06X):%08X\n",CS,cs,pc); @@ -1702,7 +1697,6 @@ void pmodeint(int num, int soft) case 0x1800: case 0x1900: case 0x1A00: case 0x1B00: /*Non-conforming*/ if (DPL2 #include "ibm.h" #include "device.h" @@ -60,6 +61,8 @@ static uint8_t xtide_read(uint16_t port, void *p) case 0xe: return readide(0, 0x3f6); } + + return 0xff; } static void *xtide_init()