--- uae/src/compiler.c 2018/04/24 16:39:17 1.1.1.2 +++ uae/src/compiler.c 2018/04/24 16:56:52 1.1.1.7 @@ -1,9 +1,9 @@ - /* + /* * UAE - The Un*x Amiga Emulator - * + * * m68k emulation * - * (c) 1995 Bernd Schmidt + * Copyright 1996 Bernd Schmidt */ #include "sysconfig.h" @@ -15,8 +15,6 @@ #include "gui.h" #include "memory.h" #include "custom.h" -#include "machdep/m68k.h" -#include "readcpu.h" #include "newcpu.h" #include "ersatz.h" #include "blitter.h" @@ -31,7 +29,7 @@ char *address_space, *good_address_map; code_execfunc exec_me; -UBYTE nr_bbs_to_run = 1; +uae_u8 nr_bbs_to_run = 1; int nr_bbs_start = 40; static int compile_failure; @@ -39,11 +37,11 @@ static int quiet_compile = 1; int i_want_to_die = 1; static int n_compiled = 0; static int n_max_comp = 99999999; -static CPTR call_only_me = 0; +static uaecptr call_only_me = 0; int patched_syscalls = 0; -static int count_bits(UWORD v) +static int count_bits(uae_u16 v) { int bits = 0; while (v != 0) { @@ -54,12 +52,12 @@ static int count_bits(UWORD v) return bits; } -static UWORD bitswap(UWORD v) +static uae_u16 bitswap(uae_u16 v) { - UWORD newv = 0; - UWORD m1 = 1, m2 = 0x8000; + uae_u16 newv = 0; + uae_u16 m1 = 1, m2 = 0x8000; int i; - + for (i = 0; i < 16; i++) { if (v & m1) newv |= m2; @@ -83,8 +81,8 @@ static struct code_page *first_code_page static struct code_page *new_code_page(void) { struct code_page *ncp; - - ncp = (struct code_page *)mmap(NULL, PAGE_ALLOC_UNIT, + + ncp = (struct code_page *)mmap(NULL, PAGE_ALLOC_UNIT, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE, zerofd, zeroff); zeroff += PAGE_ALLOC_UNIT; @@ -123,7 +121,7 @@ static char *alloc_code(struct hash_bloc { struct code_page *cp; long int allocsize = (ninsns * 32 + PAGE_SUBUNIT-1) & ~(PAGE_SUBUNIT-1); - ULONG allocmask; + uae_u32 allocmask; int allocbits; int j; int last_bit; @@ -132,9 +130,9 @@ static char *alloc_code(struct hash_bloc return NULL; allocbits = (allocsize >> SUBUNIT_ORDER); allocmask = (1 << allocbits) - 1; - + for (cp = first_code_page; cp != NULL; cp = cp->next) { - ULONG thispage_alloc = cp->allocmask; + uae_u32 thispage_alloc = cp->allocmask; for (j = 1; j < (33 - allocbits); j++) { if ((cp->allocmask & (allocmask << j)) == 0) { goto found_page; @@ -147,7 +145,7 @@ static char *alloc_code(struct hash_bloc if (cp == NULL) return NULL; j = 1; - + found_page: /* See whether there is in fact more space for us. If so, allocate all of * it. compile_block() will free everything it didn't need. */ @@ -172,7 +170,7 @@ static void remove_hash_from_lists(struc { h->lru_next->lru_prev = h->lru_prev; h->lru_prev->lru_next = h->lru_next; - + h->next->prev = h->prev; h->prev->next = h->next; } @@ -181,7 +179,7 @@ static void lru_touch(struct hash_entry { h->lru_next->lru_prev = h->lru_prev; h->lru_prev->lru_next = h->lru_next; - + h->lru_next = &lru_first_hash; h->lru_prev = lru_first_hash.lru_prev; h->lru_prev->lru_next = h; @@ -192,7 +190,7 @@ static void lru_untouch(struct hash_entr { h->lru_next->lru_prev = h->lru_prev; h->lru_prev->lru_next = h->lru_next; - + h->lru_prev = &lru_first_hash; h->lru_next = lru_first_hash.lru_next; h->lru_next->lru_prev = h; @@ -202,7 +200,7 @@ static void lru_untouch(struct hash_entr static void forget_block(struct hash_block *hb) { struct hash_entry *h = hb->he_first; - + hb->lru_next->lru_prev = hb->lru_prev; hb->lru_prev->lru_next = hb->lru_next; @@ -228,21 +226,21 @@ static void lru_touch_block(struct hash_ { h->lru_next->lru_prev = h->lru_prev; h->lru_prev->lru_next = h->lru_next; - + h->lru_next = &lru_first_block; h->lru_prev = lru_first_block.lru_prev; h->lru_prev->lru_next = h; - lru_first_block.lru_prev = h; + lru_first_block.lru_prev = h; } -static __inline__ int check_block(struct hash_block *hb) +STATIC_INLINE int check_block(struct hash_block *hb) { #ifndef RELY_ON_LOADSEG_DETECTION struct hash_entry *h = hb->he_first; - + do { struct hash_entry *next = h->next_same_block; - if (h->matchword != *(ULONG *)get_real_address(h->addr)) + if (h->matchword != *(uae_u32 *)get_real_address(h->addr)) return 0; h = next; } while (h != hb->he_first); @@ -250,10 +248,10 @@ static __inline__ int check_block(struct return 1; } -ULONG flush_icache(void) +uae_u32 flush_icache(void) { struct hash_block *hb = lru_first_block.lru_next; - + while (hb != &lru_first_block) { struct hash_block *next = hb->lru_next; if (hb->cpage != NULL) { @@ -278,7 +276,7 @@ void possible_loadseg(void) static struct hash_block *new_block(void) { struct hash_block *b = freelist_block; - + if (b != NULL) { freelist_block = b->lru_next; } else @@ -302,7 +300,7 @@ static struct hash_entry *get_free_hash( } h = lru_first_hash.lru_next; if (num_unused_hash >= MAX_UNUSED_HASH && h->block == NULL - && !h->locked) + && !h->locked) { remove_hash_from_lists(h); num_unused_hash--; @@ -321,10 +319,10 @@ static struct hash_entry *get_free_hash( return h; } -static struct hash_entry *new_hash(CPTR addr) +static struct hash_entry *new_hash(uaecptr addr) { struct hash_entry *h = get_free_hash(); - + h->addr = addr; /* Chain the new node */ @@ -336,19 +334,19 @@ static struct hash_entry *new_hash(CPTR h->lru_prev = lru_first_hash.lru_prev; h->lru_prev->lru_next = h; lru_first_hash.lru_prev = h; - + h->next_same_block = NULL; return h; } -static struct hash_entry *find_hash(CPTR addr) +static struct hash_entry *find_hash(uaecptr addr) { struct hash_entry *h; struct hash_entry *h1 = cpu_hash + ((addr >> 1) & HASH_MASK); if (h1->next->addr == addr) return h1->next; - + for (h = h1->next; h != h1; h = h->next) { if (h->addr == addr) { /* Put it at the head of the list so that the above shortcut @@ -363,7 +361,7 @@ static struct hash_entry *find_hash(CPTR return NULL; } -static struct hash_entry *get_hash_for_func(CPTR addr, int mark_locked) +static struct hash_entry *get_hash_for_func(uaecptr addr, int mark_locked) { struct hash_entry *h = find_hash(addr); if (h == NULL) @@ -377,7 +375,7 @@ static struct hash_entry *get_hash_for_f return h; } -static struct hash_entry *get_hash(CPTR addr) +static struct hash_entry *get_hash(uaecptr addr) { struct hash_entry *h = get_hash_for_func(addr, 0); @@ -397,17 +395,17 @@ static struct hash_entry *get_hash(CPTR return h; } -void special_flush_hash(CPTR addr) +void special_flush_hash(uaecptr addr) { struct hash_entry *h = get_hash_for_func(addr, 0); - + h->cacheflush = 1; } -static __inline__ void m68k_setpc_hash(CPTR newpc) +STATIC_INLINE void m68k_setpc_hash(uaecptr newpc) { struct hash_entry *h = get_hash(newpc); - + if (h->cacheflush) flush_icache(); @@ -419,14 +417,14 @@ static __inline__ void m68k_setpc_hash(C nr_bbs_to_run = nr_bbs_start; regs.spcflags |= SPCFLAG_EXEC; } - } else + } else flush_icache(); } regs.pc = newpc; regs.pc_p = regs.pc_oldp = get_real_address(newpc); } -static __inline__ void m68k_setpc_nohash(CPTR newpc) +STATIC_INLINE void m68k_setpc_nohash(uaecptr newpc) { #if 0 /* This is probably not too good for efficiency... FIXME */ @@ -439,22 +437,22 @@ static __inline__ void m68k_setpc_nohash regs.pc_p = regs.pc_oldp = get_real_address(newpc); } -void m68k_setpc(CPTR newpc) +void m68k_setpc(uaecptr newpc) { - m68k_setpc_hash(newpc); + m68k_setpc_hash(newpc); } -void m68k_setpc_fast(CPTR newpc) +void m68k_setpc_fast(uaecptr newpc) { - m68k_setpc_nohash(newpc); + m68k_setpc_nohash(newpc); } -void m68k_setpc_rte(CPTR newpc) +void m68k_setpc_rte(uaecptr newpc) { m68k_setpc_nohash(newpc); } -void m68k_setpc_bcc(CPTR newpc) +void m68k_setpc_bcc(uaecptr newpc) { m68k_setpc_hash(newpc); } @@ -463,7 +461,7 @@ static void hash_init(void) { int i; struct hash_entry **hepp; - + freelist_block = NULL; freelist_hash = NULL; @@ -494,7 +492,7 @@ static void code_init(void) #define CC68K_N 2 #define CC68K_X 1 -static __inline__ int cc_flagmask_68k(const int cc) +STATIC_INLINE int cc_flagmask_68k(const int cc) { switch(cc){ case 0: return 0; /* T */ @@ -515,10 +513,10 @@ static __inline__ int cc_flagmask_68k(co case 15:return CC68K_N|CC68K_V|CC68K_Z; /* LE */ } abort(); - return 0; + return 0; } -static __inline__ void translate_step_over_ea(UBYTE **pcpp, amodes m, +STATIC_INLINE void translate_step_over_ea(uae_u8 **pcpp, amodes m, wordsizes size) { switch (m) { @@ -544,7 +542,7 @@ static __inline__ void translate_step_ov case Ad8r: case PC8r: { - UWORD extra = *(*pcpp)++; + uae_u16 extra = *(*pcpp)++; extra <<= 8; extra |= *(*pcpp)++; /* @@@ handle 68020 stuff here */ @@ -558,14 +556,14 @@ static __inline__ void translate_step_ov } } -static struct instr *translate_getnextinsn(UBYTE **pcpp) +static struct instr *translate_getnextinsn(uae_u8 **pcpp) { - UWORD opcode; + uae_u16 opcode; struct instr *dp; - + opcode = *(*pcpp)++ << 8; opcode |= *(*pcpp)++; - + if (cpufunctbl[opcode] == op_illg) { opcode = 0x4AFC; } @@ -582,12 +580,12 @@ static struct instr *translate_getnextin #define CB_STACKSIZE 200 #define BB_STACKSIZE 200 -static ULONG condbranch_stack[CB_STACKSIZE]; +static uae_u32 condbranch_stack[CB_STACKSIZE]; static int condbranch_src_stack[CB_STACKSIZE]; struct bb_info { struct hash_entry *h; - CPTR stopaddr; + uaecptr stopaddr; int can_compile_last; struct bb_info *bb_next1, *bb_next2; int flags_live_at_end; @@ -597,12 +595,12 @@ struct bb_info { static int top_bb; -static CPTR bcc_target_stack[BB_STACKSIZE]; +static uaecptr bcc_target_stack[BB_STACKSIZE]; -static int new_bcc_target(CPTR addr) +static int new_bcc_target(uaecptr addr) { int i; - + for (i = 0; i < top_bb; i++) if (bcc_target_stack[i] == addr) return 1; @@ -615,11 +613,11 @@ static int new_bcc_target(CPTR addr) static int bcc_compfn(const void *a, const void *b) { - CPTR *a1 = (CPTR *)a, *b1 = (CPTR *)b; - + uaecptr *a1 = (uaecptr *)a, *b1 = (uaecptr *)b; + if (*a1 == *b1) printf("BUG!!\n"); - + if (*a1 < *b1) return 1; return -1; @@ -628,10 +626,10 @@ static int bcc_compfn(const void *a, con static int bb_compfn(const void *a, const void *b) { struct bb_info *a1 = (struct bb_info *)a, *b1 = (struct bb_info *)b; - + if (a1->h->addr == b1->h->addr) printf("BUG!!\n"); - + if (a1->h->addr < b1->h->addr) return -1; return 1; @@ -646,24 +644,24 @@ static int find_basic_blocks(struct hash new_bcc_target(h->addr); while (top_bb > current_bb) { - CPTR addr = bcc_target_stack[current_bb]; + uaecptr addr = bcc_target_stack[current_bb]; int ninsns = 0; - UBYTE *realpc = get_real_address(addr); - UBYTE *rpc_start = realpc; - + uae_u8 *realpc = get_real_address(addr); + uae_u8 *rpc_start = realpc; + for(;;) { - CPTR thisinsn_addr = (realpc - rpc_start) + addr; - UBYTE *rpc_save = realpc; + uaecptr thisinsn_addr = (realpc - rpc_start) + addr; + uae_u8 *rpc_save = realpc; struct instr *dp = translate_getnextinsn(&realpc); - CPTR nextinsn_addr = (realpc - rpc_start) + addr; + uaecptr nextinsn_addr = (realpc - rpc_start) + addr; - if (dp->mnemo == i_RTS || dp->mnemo == i_RTE + if (dp->mnemo == i_RTS || dp->mnemo == i_RTE || dp->mnemo == i_RTR || dp->mnemo == i_RTD - || dp->mnemo == i_JMP || dp->mnemo == i_ILLG) + || dp->mnemo == i_JMP || dp->mnemo == i_ILLG) { break; } - + if (dp->mnemo == i_BSR || dp->mnemo == i_JSR) { if (!new_bcc_target(nextinsn_addr)) return 0; @@ -671,21 +669,21 @@ static int find_basic_blocks(struct hash } if (dp->mnemo == i_DBcc) { - CPTR newaddr = thisinsn_addr + 2 + (WORD)((*(rpc_save+2) << 8) | *(rpc_save+3)); + uaecptr newaddr = thisinsn_addr + 2 + (uae_s16)((*(rpc_save+2) << 8) | *(rpc_save+3)); if (!new_bcc_target(nextinsn_addr)) return 0; if (!new_bcc_target(newaddr)) return 0; break; } - + if (dp->mnemo == i_Bcc) { - CPTR newaddr; + uaecptr newaddr; if (dp->smode == imm1) - newaddr = thisinsn_addr + 2 + (WORD)((*(rpc_save+2) << 8) | *(rpc_save+3)); + newaddr = thisinsn_addr + 2 + (uae_s16)((*(rpc_save+2) << 8) | *(rpc_save+3)); else - newaddr = thisinsn_addr + 2 + (BYTE)dp->sreg; - + newaddr = thisinsn_addr + 2 + (uae_s8)dp->sreg; + if (dp->cc != 0) if (!new_bcc_target(nextinsn_addr)) return 0; @@ -697,7 +695,7 @@ static int find_basic_blocks(struct hash current_bb++; } - qsort(bcc_target_stack, top_bb, sizeof (CPTR), bcc_compfn); + qsort(bcc_target_stack, top_bb, sizeof (uaecptr), bcc_compfn); return 1; } @@ -707,19 +705,19 @@ static int m68k_scan_func(struct hash_en int i; struct hash_block *found_block; struct hash_entry **hepp; - + if (!find_basic_blocks(h)) return 0; found_block = NULL; - + /* First, lock the hash entries we already have to prevent grief */ for (i = 0; i < top_bb; i++) { struct hash_entry *h = find_hash(bcc_target_stack[i]); if (h != NULL) h->locked = 1; } - + /* Allocate new ones */ for (i = 0; i < top_bb; i++) { struct hash_entry *h = get_hash_for_func(bcc_target_stack[i], 1); @@ -775,12 +773,12 @@ struct ea_reg_info { int regs_set:16; int regs_used:16; int nr_scratch; - ULONG temp1, temp2; + uae_u32 temp1, temp2; }; #define MAX_TRANSLATE 2048 struct insn_info_struct { - CPTR address; + uaecptr address; struct instr *dp; int flags_set; int flags_used; @@ -805,10 +803,10 @@ struct insn_info_struct { #if 0 static void analyze_ea_for_insn(amodes mode, int reg, wordsizes size, struct ea_reg_info *eai, - UBYTE **pcpp, CPTR pca, + uae_u8 **pcpp, uaecptr pca, int ea_purpose) { - UBYTE *p = *pcpp; + uae_u8 *p = *pcpp; switch(mode) { case Dreg: @@ -820,7 +818,7 @@ static void analyze_ea_for_insn(amodes m if (ea_purpose & EA_STORE) eai->regs_set |= 1 << reg; break; - + case Areg: eai->ea_type = eat_reg; if (size != sz_long && (ea_purpose & EA_STORE)) @@ -830,7 +828,7 @@ static void analyze_ea_for_insn(amodes m if (ea_purpose & EA_STORE) eai->regs_set |= 1 << (8+reg); break; - + case Ad16: case Aind: case Apdi: @@ -843,10 +841,10 @@ static void analyze_ea_for_insn(amodes m eai->ea_type = eat_imem; pii->regs_used |= 1 << (8+reg); - eai->temp = (UWORD)((*p << 8) | *(p+1)); + eai->temp = (uae_u16)((*p << 8) | *(p+1)); r = (eai->temp & 0x7000) >> 12; - (*pcpp) += 2; p += 2; - + (*pcpp) += 2; p += 2; + if (eai->temp1 & 0x8000) pii->regs_used |= 1 << (8+r); else @@ -855,8 +853,8 @@ static void analyze_ea_for_insn(amodes m case PC8r: eai->ea_type = eat_imem; - eai->temp1 = (UWORD)do_get_mem_word((UWORD *)p); - eai->temp2 = pca + (BYTE)eai->temp1; + eai->temp1 = (uae_u16)do_get_mem_word((uae_u16 *)p); + eai->temp2 = pca + (uae_s8)eai->temp1; (*pcpp) += 2; p += 2; r = (eai->temp1 & 0x7000) >> 12; @@ -865,22 +863,22 @@ static void analyze_ea_for_insn(amodes m else pii->regs_used |= 1 << r; break; - - case PC16: + + case PC16: eai->ea_type = eat_amem; - eai->temp1 = pca + (WORD)do_get_mem_word((UWORD *)p); + eai->temp1 = pca + (uae_s16)do_get_mem_word((uae_u16 *)p); (*pcpp) += 2; break; - + case absw: eai->ea_type = eat_amem; - eai->temp1 = (WORD)do_get_mem_word((UWORD *)p); + eai->temp1 = (uae_s16)do_get_mem_word((uae_u16 *)p); (*pcpp) += 2; break; case absl: eai->ea_type = eat_amem; - eai->temp1 = (LONG)do_get_mem_long((ULONG *)p); + eai->temp1 = (uae_s32)do_get_mem_long((uae_u32 *)p); (*pcpp) += 4; break; @@ -889,31 +887,31 @@ static void analyze_ea_for_insn(amodes m goto imm2_const; if (size == sz_word) goto imm1_const; - + /* fall through */ case imm0: eai->ea_type = eat_imm; - eai->temp1 = (BYTE)*(p+1); + eai->temp1 = (uae_s8)*(p+1); (*pcpp) += 2; break; case imm1: imm1_const: eai->ea_type = eat_imm; - eai->temp1 = (WORD)do_get_mem_word((UWORD *)p); + eai->temp1 = (uae_s16)do_get_mem_word((uae_u16 *)p); (*pcpp) += 2; break; case imm2: imm2_const: eai->ea_type = eat_imm; - eai->temp1 = (LONG)do_get_mem_long((ULONG *)p); + eai->temp1 = (uae_s32)do_get_mem_long((uae_u32 *)p); (*pcpp) += 4; break; case immi: eai->ea_type = eat_imm; - eai->temp1 = (BYTE)reg; + eai->temp1 = (uae_s8)reg; break; default: @@ -924,10 +922,10 @@ static void analyze_ea_for_insn(amodes m static struct bb_info *find_bb(struct hash_entry *h) { int i; - + if (h == NULL) printf("Bug...\n"); - + for (i = 0; i < top_bb; i++) if (bb_stack[i].h == h) return bb_stack + i; @@ -943,7 +941,7 @@ static int m68k_scan_block(struct hash_b int changed, round; top_bb = 0; - + do { struct bb_info *bb = bb_stack + top_bb; bb->h = h; @@ -952,7 +950,7 @@ static int m68k_scan_block(struct hash_b h = h->next_same_block; top_bb++; } while (h != hb->he_first); - + qsort(bb_stack, top_bb, sizeof (struct bb_info), bb_compfn); *movem_count = 0; @@ -960,9 +958,9 @@ static int m68k_scan_block(struct hash_b iip = 0; for (i = 0; i < top_bb; i++) { struct bb_info *bb = bb_stack + i; - UBYTE *realpc = get_real_address(bb->h->addr); - UBYTE *rpc_start = realpc; - CPTR stop_addr = 0; + uae_u8 *realpc = get_real_address(bb->h->addr); + uae_u8 *rpc_start = realpc; + uaecptr stop_addr = 0; int live_at_start = 31, may_clear_las = 31; struct insn_info_struct *prev_ii = NULL; @@ -972,19 +970,19 @@ static int m68k_scan_block(struct hash_b for (;;) { struct insn_info_struct *thisii = insn_info + iip; - CPTR thisinsn_addr = (realpc - rpc_start) + bb->h->addr; - UBYTE *rpc_save = realpc; + uaecptr thisinsn_addr = (realpc - rpc_start) + bb->h->addr; + uae_u8 *rpc_save = realpc; struct instr *dp = translate_getnextinsn(&realpc); - CPTR nextinsn_addr = (realpc - rpc_start) + bb->h->addr; - + uaecptr nextinsn_addr = (realpc - rpc_start) + bb->h->addr; + int fset = dp->flagdead == -1 ? 31 : dp->flagdead; int fuse = dp->flaglive == -1 ? 31 : dp->flaglive; - + if (thisinsn_addr == stop_addr) { bb->bb_next1 = find_bb (find_hash (thisinsn_addr)); break; } - + if (dp->mnemo == i_Scc || dp->mnemo == i_Bcc || dp->mnemo == i_DBcc) { fset = 0, fuse = cc_flagmask_68k(dp->cc); if (prev_ii && dp->mnemo != i_Scc) /* Don't use Scc here: ea can cause an exit */ @@ -993,7 +991,7 @@ static int m68k_scan_block(struct hash_b may_clear_las &= ~fuse; live_at_start &= ~(fset & may_clear_las); - + thisii->dp = dp; thisii->address = thisinsn_addr; thisii->stop_translation = 0; @@ -1009,7 +1007,7 @@ static int m68k_scan_block(struct hash_b if (iip == MAX_TRANSLATE) return 0; - if (dp->mnemo == i_RTS || dp->mnemo == i_RTE + if (dp->mnemo == i_RTS || dp->mnemo == i_RTE || dp->mnemo == i_RTR || dp->mnemo == i_RTD || dp->mnemo == i_JMP || dp->mnemo == i_ILLG) { @@ -1030,7 +1028,7 @@ static int m68k_scan_block(struct hash_b } if (dp->mnemo == i_DBcc) { - CPTR newaddr = thisinsn_addr + 2 + (WORD)((*(rpc_save+2) << 8) | *(rpc_save+3)); + uaecptr newaddr = thisinsn_addr + 2 + (uae_s16)((*(rpc_save+2) << 8) | *(rpc_save+3)); bb->can_compile_last = 1; bb->bb_next1 = find_bb (get_hash_for_func (newaddr, 1)); if (bb->bb_next1 == NULL) @@ -1041,13 +1039,13 @@ static int m68k_scan_block(struct hash_b thisii->regs_used = 65535; break; } - + if (dp->mnemo == i_Bcc) { - CPTR newaddr; + uaecptr newaddr; if (dp->smode == imm1) - newaddr = thisinsn_addr + 2 + (WORD)((*(rpc_save+2) << 8) | *(rpc_save+3)); + newaddr = thisinsn_addr + 2 + (uae_s16)((*(rpc_save+2) << 8) | *(rpc_save+3)); else - newaddr = thisinsn_addr + 2 + (BYTE)dp->sreg; + newaddr = thisinsn_addr + 2 + (uae_s8)dp->sreg; bb->can_compile_last = 1; bb->bb_next1 = find_bb(get_hash_for_func(newaddr, 1)); if (bb->bb_next1 == NULL) @@ -1062,7 +1060,7 @@ static int m68k_scan_block(struct hash_b } if (dp->mnemo == i_MVMLE || dp->mnemo == i_MVMEL) { - UWORD regmask = (*(rpc_save + 2) << 8) | (*(rpc_save + 3)); + uae_u16 regmask = (*(rpc_save + 2) << 8) | (*(rpc_save + 3)); *movem_count += count_bits(regmask); if (dp->dmode == Apdi) regmask = bitswap(regmask); @@ -1086,7 +1084,7 @@ static int m68k_scan_block(struct hash_b int mnemo; int current_live; struct instr *dp; - + iip = bb->last_iip; mnemo = insn_info[iip].dp->mnemo; @@ -1097,7 +1095,7 @@ static int m68k_scan_block(struct hash_b insn_info[bb->bb_next1->first_iip].jump_target = 1; } } - + /* And take care of flag life information */ dp = insn_info[iip].dp; if (insn_info[iip].stop_translation) @@ -1135,7 +1133,7 @@ static int m68k_scan_block(struct hash_b #define MAX_JSRS 4096 /* must be a power of two */ -static CPTR jsr_rets[MAX_JSRS]; +static uaecptr jsr_rets[MAX_JSRS]; static struct hash_entry *jsr_hash[MAX_JSRS]; static int jsr_num; static struct hash_entry dummy_hash; /* This is for safety purposes only */ @@ -1160,9 +1158,8 @@ void m68k_do_rts(void) jsr_num--; } -__inline__ void m68k_do_jsr(CPTR dest) +__inline__ void m68k_do_jsr(uaecptr oldpc, uaecptr dest) { - ULONG oldpc = m68k_getpc(); struct hash_entry *h = find_hash(oldpc); if (jsr_num == MAX_JSRS) @@ -1179,9 +1176,9 @@ __inline__ void m68k_do_jsr(CPTR dest) m68k_setpc(dest); } -void m68k_do_bsr(LONG offset) +void m68k_do_bsr(uaecptr oldpc, uae_s32 offset) { - m68k_do_jsr(m68k_getpc() + offset); + m68k_do_jsr(oldpc, m68k_getpc() + offset); } /* Here starts the actual compiling part */ @@ -1189,7 +1186,7 @@ void m68k_do_bsr(LONG offset) static char *compile_current_addr; static char *compile_last_addr; -static __inline__ void assemble(UBYTE a) +STATIC_INLINE void assemble(uae_u8 a) { if (compile_current_addr < compile_last_addr) { *compile_current_addr++ = a; @@ -1198,7 +1195,7 @@ static __inline__ void assemble(UBYTE a) } } -static __inline__ void assemble_ulong(ULONG a) +STATIC_INLINE void assemble_ulong(uae_u32 a) { assemble(a); assemble(a >> 8); @@ -1206,7 +1203,7 @@ static __inline__ void assemble_ulong(UL assemble(a >> 24); } -static __inline__ void assemble_ulong_68k(ULONG a) +STATIC_INLINE void assemble_ulong_68k(uae_u32 a) { assemble(a >> 24); assemble(a >> 16); @@ -1214,23 +1211,23 @@ static __inline__ void assemble_ulong_68 assemble(a); } -static __inline__ void assemble_uword(UWORD a) +STATIC_INLINE void assemble_uword(uae_u16 a) { assemble(a); assemble(a >> 8); } -static __inline__ void assemble_long(void *a) +STATIC_INLINE void assemble_long(void *a) { - assemble_ulong((ULONG)a); + assemble_ulong((uae_u32)a); } -static __inline__ void compile_org(char *addr) +STATIC_INLINE void compile_org(char *addr) { compile_current_addr = addr; } -static __inline__ char *compile_here(void) +STATIC_INLINE char *compile_here(void) { return compile_current_addr; } @@ -1273,13 +1270,13 @@ struct register_mapping { * First, code to compile some primitive x86 instructions */ -static void compile_lea_reg_with_offset(int dstreg, int srcreg, ULONG srcoffs) +static void compile_lea_reg_with_offset(int dstreg, int srcreg, uae_u32 srcoffs) { assemble(0x8D); if (srcreg == -2) { assemble(0x05 + 8*dstreg); assemble_ulong(srcoffs); - } else if ((LONG)srcoffs >= -128 && (LONG)srcoffs <= 127) { + } else if ((uae_s32)srcoffs >= -128 && (uae_s32)srcoffs <= 127) { assemble(0x40 + 8*dstreg + srcreg); assemble(srcoffs); } else { @@ -1306,7 +1303,7 @@ static void compile_move_reg_reg(int dst } static void compile_move_between_reg_mem_regoffs(int dstreg, int srcreg, - ULONG srcoffs, wordsizes size, + uae_u32 srcoffs, wordsizes size, int code) { if (size == sz_byte && (dstreg & 0x80) != 0) @@ -1323,11 +1320,11 @@ static void compile_move_between_reg_mem assemble(code); else assemble(code + 1); - + if (srcreg == -2) { assemble(0x05 + 8*dstreg); assemble_ulong(srcoffs); - } else if ((LONG)srcoffs >= -128 && (LONG)srcoffs <= 127) { + } else if ((uae_s32)srcoffs >= -128 && (uae_s32)srcoffs <= 127) { assemble(0x40 + 8*dstreg + srcreg); assemble(srcoffs); } else { @@ -1336,13 +1333,13 @@ static void compile_move_between_reg_mem } } -static void compile_move_reg_from_mem_regoffs(int dstreg, int srcreg, - ULONG srcoffs, wordsizes size) +static void compile_move_reg_from_mem_regoffs(int dstreg, int srcreg, + uae_u32 srcoffs, wordsizes size) { compile_move_between_reg_mem_regoffs(dstreg, srcreg, srcoffs, size, 0x8A); } -static void compile_move_reg_to_mem_regoffs(int dstreg, ULONG dstoffs, +static void compile_move_reg_to_mem_regoffs(int dstreg, uae_u32 dstoffs, int srcreg, wordsizes size) { compile_move_between_reg_mem_regoffs(srcreg, dstreg, dstoffs, size, 0x88); @@ -1375,12 +1372,12 @@ static void compile_force_byteorder(stru { if (x86r < 0 || map->x86_byteorder[x86r] == desired_bo) return; - + if (map->x86_byteorder[x86r] == BO_SWAPPED_LONG) compile_byteswap(x86r, sz_long, save_flags); else if (map->x86_byteorder[x86r] == BO_SWAPPED_WORD) compile_byteswap(x86r, sz_word, save_flags); - + if (desired_bo == BO_SWAPPED_LONG) compile_byteswap(x86r, sz_long, save_flags); else if (desired_bo == BO_SWAPPED_WORD) @@ -1391,11 +1388,11 @@ static void compile_force_byteorder(stru /* Add a constant offset to a x86 register. If it's in the cache, make sure * we update the const_offset value. The flags are unaffected by this */ -static void compile_offset_reg(struct register_mapping *map, int x86r, - ULONG offset) +static void compile_offset_reg(struct register_mapping *map, int x86r, + uae_u32 offset) { int cached_68k; - + if (offset == 0 || x86r == -1 || x86r == -2) return; @@ -1416,7 +1413,7 @@ static int get_unused_x86_register(struc continue; if (map->x86_users[x86r] > 0) continue; - + map->x86_verified[x86r] = 0; map->x86_byteorder[x86r] = BO_NORMAL; return x86r; @@ -1429,8 +1426,8 @@ static int get_unused_x86_register(struc * If may_clobber is 1 and the reg had an offset, the reg will be offsetted * by this function */ -static void sync_reg(struct register_mapping *map, int x86r, void *m68kr, - ULONG offset, int dirty, int may_clobber) +static void sync_reg(struct register_mapping *map, int x86r, void *m68kr, + uae_u32 offset, int dirty, int may_clobber) { if (dirty || offset != 0) compile_force_byteorder(map, x86r, BO_NORMAL, 1); @@ -1440,14 +1437,14 @@ static void sync_reg(struct register_map dirty = 1; } else { int tmpr = get_unused_x86_register(map); - if (tmpr != -1) { + if (tmpr != -1) { compile_lea_reg_with_offset(tmpr, x86r, offset); x86r = tmpr; dirty = 1; } else { compile_lea_reg_with_offset(x86r, x86r, offset); assemble(0x89); /* movl x86r,m68kr */ - assemble(0x05 + (x86r << 3)); + assemble(0x05 + (x86r << 3)); assemble_long(m68kr); compile_lea_reg_with_offset(x86r, x86r, -offset); return; @@ -1456,7 +1453,7 @@ static void sync_reg(struct register_map } if (dirty) { assemble(0x89); /* movl x86r,m68kr */ - assemble(0x05 + (x86r << 3)); + assemble(0x05 + (x86r << 3)); assemble_long(m68kr); } } @@ -1485,20 +1482,20 @@ static void sync_reg_cache(struct regist memset(map->x86_dirty, 0, sizeof map->x86_dirty); } -static void remove_x86r_from_cache(struct register_mapping *map, int x86r, +static void remove_x86r_from_cache(struct register_mapping *map, int x86r, int may_clobber) { int j; int reg_68k; - + if (x86r == -1) return; reg_68k = map->x86_cache_reg[x86r]; - + if (reg_68k == -1) return; - + if (map->x86_cr_type[x86r] == 1) { map->dreg_map[reg_68k] = -1; sync_reg(map, x86r, regs.regs + reg_68k, map->x86_const_offset[x86r], @@ -1609,9 +1606,9 @@ static int get_and_lock_68k_reg(struct r { int x86r; int *regmap; - ULONG *reghome; - ULONG const_off = 0; - + uae_u32 *reghome; + uae_u32 const_off = 0; + if (reg < 0 || reg > 7) { printf("Mad compiler disease\n"); return 0; @@ -1621,10 +1618,10 @@ static int get_and_lock_68k_reg(struct r regmap = map->dreg_map, reghome = regs.regs; else regmap = map->areg_map, reghome = regs.regs + 8; - + if (preferred == 0) preferred = ALL_X86_REGS; - + x86r = regmap[reg]; if (x86r == -1) { x86r = get_free_x86_register(map, preferred); @@ -1639,7 +1636,7 @@ static int get_and_lock_68k_reg(struct r regmap[reg] = x86r; } else { const_off = map->x86_const_offset[x86r]; - + if (map->x86_locked[x86r] == 2 || (map->x86_locked[x86r] == 1 && (lock_type == 2 || (const_off != 0 && no_offset)))) { @@ -1647,7 +1644,7 @@ static int get_and_lock_68k_reg(struct r int old_dirty = 0; int old_verified; int old_bo; - + newr = get_free_x86_register(map, preferred); if (const_off == 0) { compile_move_reg_reg(newr, x86r, sz_long); @@ -1695,7 +1692,7 @@ static int get_and_lock_68k_reg(struct r */ static int compile_force_const_reg(struct register_mapping *map, int x86r, - ULONG *offs, int desired) + uae_u32 *offs, int desired) { int newr = x86r; @@ -1720,7 +1717,7 @@ static void compile_extend_long(struct r printf("Bad reg in extend_long\n"); return; } - + compile_force_byteorder(map, x86r, BO_NORMAL, 1); if (size != sz_long) { @@ -1744,10 +1741,10 @@ struct ea_info { wordsizes size; int address_reg; /* The x86 reg holding the address, or -1 if ea doesn't refer to memory * -2 if it refers to memory, but only with a constant address */ - ULONG addr_const_off; /* Constant offset to the address */ - int data_reg; /* The x86 reg that holds the data. -1 if data is not present yet. + uae_u32 addr_const_off; /* Constant offset to the address */ + int data_reg; /* The x86 reg that holds the data. -1 if data is not present yet. * -2 if data is constant */ - ULONG data_const_off; + uae_u32 data_const_off; int flags; /* Extra info. Contains the dp field of d8r modes */ int purpose; }; @@ -1805,20 +1802,20 @@ static void compile_prepare_undo(struct switch(mode){ default: break; - + case Apdi: x86r = get_and_lock_68k_reg(map, reg, 0, ADDRESS_X86_REGS, 0, 1); /* This saves recording the byteorder in the pud structure, and we'll * need it in normal byteorder anyway */ compile_force_byteorder(map, x86r, BO_NORMAL, 0); - /* + /* * Add this reg with its current offset to the undo buffer. * Since we have locked it, we are certain that it will not be * modified. */ add_undo(pud, x86r, reg, map->x86_const_offset[x86r], map->x86_dirty[x86r]); break; - + case Aipi: x86r = get_and_lock_68k_reg(map, reg, 0, ADDRESS_X86_REGS, 0, 1); compile_force_byteorder(map, x86r, BO_NORMAL, 0); @@ -1834,31 +1831,31 @@ static void compile_prepare_undo(struct */ static void compile_prepareea(struct register_mapping *map, amodes mode, - int reg, wordsizes size, UBYTE **pcpp, CPTR pca, + int reg, wordsizes size, uae_u8 **pcpp, uaecptr pca, struct ea_info *eainf, int eaino, int ea_purpose, int pidmult) { struct ea_info *eai = eainf + eaino; int pdival = size == sz_byte && reg != 7 ? 1 : size == sz_long ? 4 : 2; - UBYTE *p = *pcpp; - UWORD dp; + uae_u8 *p = *pcpp; + uae_u16 dp; int r; int x86r, tmpr; pdival *= pidmult; - + init_eainfo(eai); eai->mode = mode; eai->size = size; eai->reg = reg; - + switch(mode){ case Dreg: case Areg: break; - + case Ad16: - eai->addr_const_off = (WORD)do_get_mem_word((UWORD *)p); + eai->addr_const_off = (uae_s16)do_get_mem_word((uae_u16 *)p); (*pcpp) += 2; p += 2; x86r = eai->address_reg = get_and_lock_68k_reg(map, reg, 0, ADDRESS_X86_REGS, 0, 1); compile_force_byteorder(map, x86r, BO_NORMAL, 0); @@ -1870,14 +1867,14 @@ static void compile_prepareea(struct reg compile_force_byteorder(map, x86r, BO_NORMAL, 0); eai->addr_const_off = map->x86_const_offset[x86r]; break; - + case Apdi: x86r = eai->address_reg = get_and_lock_68k_reg(map, reg, 0, ADDRESS_X86_REGS, 0, 1); compile_force_byteorder(map, x86r, BO_NORMAL, 0); map->x86_const_offset[x86r] -= pdival; eai->addr_const_off = map->x86_const_offset[x86r]; break; - + case Aipi: x86r = eai->address_reg = get_and_lock_68k_reg(map, reg, 0, ADDRESS_X86_REGS, 0, 1); compile_force_byteorder(map, x86r, BO_NORMAL, 0); @@ -1886,13 +1883,13 @@ static void compile_prepareea(struct reg break; case Ad8r: - dp = (WORD)do_get_mem_word((UWORD *)p); + dp = (uae_s16)do_get_mem_word((uae_u16 *)p); r = (dp & 0x7000) >> 12; - (*pcpp) += 2; p += 2; - + (*pcpp) += 2; p += 2; + tmpr = get_and_lock_68k_reg(map, reg, 0, ADDRESS_X86_REGS, 0, 1); compile_force_byteorder(map, tmpr, BO_NORMAL, 0); - eai->addr_const_off = map->x86_const_offset[tmpr] + (BYTE)dp; + eai->addr_const_off = map->x86_const_offset[tmpr] + (uae_s8)dp; if (dp & 0x800) { x86r = get_and_lock_68k_reg(map, r, dp & 0x8000 ? 0 : 1, ADDRESS_X86_REGS, 0, 2); @@ -1905,14 +1902,14 @@ static void compile_prepareea(struct reg compile_force_byteorder(map, x86r, BO_NORMAL, 0); } eai->address_reg = x86r; - + r = (dp & 0x7000) >> 12; if (dp & 0x800) { if (eai->addr_const_off == 0) { assemble(0x03); assemble(0xC0 + tmpr + x86r*8); /* addl basereg,addrreg */ - } else if ((LONG)eai->addr_const_off >= -128 && (LONG)eai->addr_const_off <= 127) { - assemble(0x8D); + } else if ((uae_s32)eai->addr_const_off >= -128 && (uae_s32)eai->addr_const_off <= 127) { + assemble(0x8D); assemble(0x44 + x86r*8); /* leal disp8(dispreg,basereg),dispreg */ assemble(x86r*8 + tmpr); assemble(eai->addr_const_off); @@ -1932,10 +1929,10 @@ static void compile_prepareea(struct reg break; case PC8r: - dp = (WORD)do_get_mem_word((UWORD *)p); + dp = (uae_s16)do_get_mem_word((uae_u16 *)p); (*pcpp) += 2; p += 2; r = (dp & 0x7000) >> 12; - eai->addr_const_off = pca + (BYTE)dp; + eai->addr_const_off = pca + (uae_s8)dp; if (dp & 0x800) { x86r = get_and_lock_68k_reg(map, r, dp & 0x8000 ? 0 : 1, ADDRESS_X86_REGS, 0, 1); remove_x86r_from_cache(map, x86r, 0); @@ -1951,21 +1948,21 @@ static void compile_prepareea(struct reg } eai->address_reg = x86r; break; - + case PC16: - eai->addr_const_off = pca + (WORD)do_get_mem_word((UWORD *)p); + eai->addr_const_off = pca + (uae_s16)do_get_mem_word((uae_u16 *)p); eai->address_reg = -2; (*pcpp) += 2; p += 2; break; - + case absw: - eai->addr_const_off = (WORD)do_get_mem_word((UWORD *)p); + eai->addr_const_off = (uae_s16)do_get_mem_word((uae_u16 *)p); eai->address_reg = -2; (*pcpp) += 2; p += 2; break; case absl: - eai->addr_const_off = (LONG)do_get_mem_long((ULONG *)p); + eai->addr_const_off = (uae_s32)do_get_mem_long((uae_u32 *)p); eai->address_reg = -2; (*pcpp) += 4; p += 4; break; @@ -1975,30 +1972,30 @@ static void compile_prepareea(struct reg goto imm2_const; if (size == sz_word) goto imm1_const; - + /* fall through */ case imm0: - eai->data_const_off = (BYTE)*(p+1); + eai->data_const_off = (uae_s8)*(p+1); eai->data_reg = -2; (*pcpp) += 2; p += 2; break; case imm1: imm1_const: - eai->data_const_off = (WORD)do_get_mem_word((UWORD *)p); + eai->data_const_off = (uae_s16)do_get_mem_word((uae_u16 *)p); eai->data_reg = -2; (*pcpp) += 2; p += 2; break; case imm2: imm2_const: - eai->data_const_off = (LONG)do_get_mem_long((ULONG *)p); + eai->data_const_off = (uae_s32)do_get_mem_long((uae_u32 *)p); eai->data_reg = -2; (*pcpp) += 4; p += 4; break; case immi: - eai->data_const_off = (BYTE)reg; + eai->data_const_off = (uae_s8)reg; eai->data_reg = -2; break; @@ -2011,14 +2008,14 @@ static void compile_prepareea(struct reg static void compile_get_excl_lock(struct register_mapping *map, struct ea_info *eai) { int x86r = eai->data_reg; - + if (x86r >= 0 && map->x86_locked[x86r] == 1) { int newr; if (eai->size == sz_byte) newr = get_typed_x86_register(map, DATA_X86_REGS); else newr = get_free_x86_register(map, ALL_X86_REGS); - + compile_move_reg_reg(newr, x86r, sz_long); eai->data_reg = newr; lock_reg(map, eai->data_reg, 2); @@ -2032,7 +2029,7 @@ static void compile_get_excl_lock(struct * 386 instruction. */ -static __inline__ int rmop_long(struct ea_info *eai) +STATIC_INLINE int rmop_long(struct ea_info *eai) { if (eai->data_reg == -2) printf("rmop for const\n"); @@ -2047,7 +2044,7 @@ static __inline__ int rmop_long(struct e if (eai->addr_const_off == 0 && eai->address_reg != r_EBP) { return eai->address_reg; } - else if ((LONG)eai->addr_const_off >= -128 && (LONG)eai->addr_const_off <= 127) { + else if ((uae_s32)eai->addr_const_off >= -128 && (uae_s32)eai->addr_const_off <= 127) { return eai->address_reg | 0x40; } #endif @@ -2062,7 +2059,7 @@ static __inline__ int rmop_long(struct e return 0; } -static __inline__ int rmop_short(struct ea_info *eai) +STATIC_INLINE int rmop_short(struct ea_info *eai) { if (eai->data_reg == -2) printf("rmop_short for const\n"); @@ -2078,14 +2075,14 @@ static __inline__ int rmop_short(struct return 0; } -static __inline__ void rmop_finalize(struct ea_info *eai) +STATIC_INLINE void rmop_finalize(struct ea_info *eai) { if (eai->data_reg == -2) assemble_ulong(eai->data_const_off); else if (eai->data_reg == -1) { if (eai->address_reg == -2) /* Constant address */ - assemble_long(address_space + (LONG)eai->addr_const_off); + assemble_long(address_space + (uae_s32)eai->addr_const_off); else if (eai->address_reg == -1) { /* Register in its home location */ if (eai->mode == Areg) @@ -2095,15 +2092,15 @@ static __inline__ void rmop_finalize(str } else { #if 0 /* Indirect address with offset */ - if ((LONG)eai->addr_const_off >= -128 && (LONG)eai->addr_const_off <= 127) { + if ((uae_s32)eai->addr_const_off >= -128 && (uae_s32)eai->addr_const_off <= 127) { } #endif - assemble_long(address_space + (LONG)eai->addr_const_off); + assemble_long(address_space + (uae_s32)eai->addr_const_off); } } } -static void compile_eas(struct register_mapping *map, struct ea_info *eainf, int eaino_s, int eaino_d, +static void compile_eas(struct register_mapping *map, struct ea_info *eainf, int eaino_s, int eaino_d, int optype) { struct ea_info *eais = eainf + eaino_s; @@ -2151,8 +2148,8 @@ static void compile_fetchmem(struct regi lock_reg(map, x86r, 2); compile_force_byteorder(map, eai->address_reg, BO_NORMAL, 0); - compile_move_reg_from_mem_regoffs(x86r, eai->address_reg, - (ULONG)(eai->addr_const_off + address_space), + compile_move_reg_from_mem_regoffs(x86r, eai->address_reg, + (uae_u32)(eai->addr_const_off + address_space), eai->size); map->x86_verified[x86r] = 0; switch (eai->size) { @@ -2209,17 +2206,17 @@ static int binop_alternatives[] = { 7, 1, 5, 3, 0, 0 -}; +}; static int binop_worda_alternatives[] = { 1, 3, 0, 0 -}; +}; static int regonly_alternatives[] = { 1, 1, 0, 0 -}; +}; static void compile_loadeas(struct register_mapping *map, struct ea_info *eainf, int eaino_s, int eaino_d, int *alternatives, @@ -2232,7 +2229,7 @@ static void compile_loadeas(struct regis int best = 0; int bestcost = -1; int *ap; - ULONG *sregp = NULL, *dregp = NULL; + uae_u32 *sregp = NULL, *dregp = NULL; int screg = -1, dcreg = -1; int stype = -1, dtype = -1; int asrc, adst; @@ -2267,7 +2264,7 @@ static void compile_loadeas(struct regis } ap = alternatives; - + for (i = 0;; i++) { int cost = 0; @@ -2275,14 +2272,14 @@ static void compile_loadeas(struct regis if (asrc == 0) break; adst = *ap++; - + if (stype == -2 && (asrc & 4) == 0) cost++; else if (stype == -1 && ((asrc & 2) == 0 || (eais->size != sz_byte && !scramble_poss))) cost++; else if (stype == 0 && screg == -1 && (asrc & 2) == 0) cost++; - + if (dtype == -1 && ((adst & 2) == 0 || (eaid->size != sz_byte && !scramble_poss))) /* The !load_dest case isn't handled by the current code, * and it isn't desirable anyway. Use a different alternative @@ -2290,16 +2287,16 @@ static void compile_loadeas(struct regis cost += load_dest ? 1 : 100; else if (dtype == 0 && dcreg == -1 && (adst & 2) == 0) cost++; - + if (bestcost == -1 || cost < bestcost) { bestcost = cost; best = i; } } - + asrc = alternatives[2*best]; adst = alternatives[2*best+1]; - + if (dtype == -1) { if (load_dest) { if ((adst & 2) == 0 || (eaid->size != sz_byte && !scramble_poss)) @@ -2333,9 +2330,9 @@ static void compile_loadeas(struct regis int reg_bo; eaid->data_reg = get_and_lock_68k_reg(map, eaid->reg, eaid->mode == Dreg, regprefs, 1, 2); eaid->data_const_off = 0; - + reg_bo = map->x86_byteorder[eaid->data_reg]; - + if (reg_bo != BO_NORMAL) { if (reg_bo != scrambled_bo) compile_force_byteorder(map, eaid->data_reg, BO_NORMAL, 0); @@ -2344,7 +2341,7 @@ static void compile_loadeas(struct regis } } } - + if (stype == -2) { /* @@@ may need to scramble imm, this is a workaround */ if ((asrc & 4) == 0 || scrambled) @@ -2358,32 +2355,32 @@ static void compile_loadeas(struct regis eais->data_const_off = 0; } } - + /* Optimization */ if (scrambled && eais->data_reg >= 0 && !load_dest && map->x86_byteorder[eais->data_reg] == BO_NORMAL && eaid->size == sz_long && dtype == 0) scrambled = 0; - + if (regprefs != 0 && eais->data_reg >= 0 && ((1 << eais->data_reg) & regprefs) == 0) { int tmpr = get_typed_x86_register(map, regprefs); compile_move_reg_reg(tmpr, eais->data_reg, sz_long); eais->data_reg = tmpr; } - + if (regprefs != 0 && eaid->data_reg >= 0 && ((1 << eaid->data_reg) & regprefs) == 0) { int tmpr = get_typed_x86_register(map, regprefs); compile_move_reg_reg(tmpr, eaid->data_reg, sz_long); eaid->data_reg = tmpr; } - + /* Now set the byteorder once and for all (should already be correct for * most cases) */ if (scrambled) { if (eaid->data_reg >= 0) compile_force_byteorder(map, eaid->data_reg, scrambled_bo, 0); if (eais->data_reg >= 0) - compile_force_byteorder(map, eais->data_reg, scrambled_bo, 0); + compile_force_byteorder(map, eais->data_reg, scrambled_bo, 0); } else { if (eaid->data_reg >= 0) compile_force_byteorder(map, eaid->data_reg, BO_NORMAL, 0); @@ -2401,7 +2398,7 @@ static void compile_fetchea(struct regis int best = 0; int bestcost = -1; int *ap; - ULONG *sregp = NULL; + uae_u32 *sregp = NULL; int screg = -1, stype = -1; int regprefs = eais->size == sz_byte ? DATA_X86_REGS : 0; @@ -2431,7 +2428,7 @@ static void compile_fetchea(struct regis eais->data_const_off = 0; } } - + if (eais->data_reg >= 0) compile_force_byteorder(map, eais->data_reg, BO_NORMAL, 0); } @@ -2461,7 +2458,7 @@ static void compile_note_modify(struct r map->x86_cr_type[eai->data_reg] = 1; map->dreg_map[eai->reg] = eai->data_reg; } - map->x86_verified[eai->data_reg] = 0; + map->x86_verified[eai->data_reg] = 0; map->x86_const_offset[eai->data_reg] = eai->data_const_off; map->x86_dirty[eai->data_reg] = 1; } @@ -2481,7 +2478,7 @@ static void compile_note_modify(struct r map->x86_cr_type[eai->data_reg] = 0; map->areg_map[eai->reg] = eai->data_reg; } - map->x86_verified[eai->data_reg] = 0; + map->x86_verified[eai->data_reg] = 0; map->x86_const_offset[eai->data_reg] = eai->data_const_off; map->x86_dirty[eai->data_reg] = 1; } @@ -2490,7 +2487,7 @@ static void compile_note_modify(struct r /* Storing to memory from reg? */ if (eai->data_reg >= 0) { compile_offset_reg(map, eai->data_reg, eai->data_const_off); - + switch (eai->size) { case sz_byte: compile_force_byteorder(map, eai->data_reg, BO_NORMAL, 1); break; case sz_word: compile_force_byteorder(map, eai->data_reg, BO_SWAPPED_WORD, 1); break; @@ -2498,7 +2495,7 @@ static void compile_note_modify(struct r } compile_force_byteorder(map, eai->address_reg, BO_NORMAL, 0); compile_move_reg_to_mem_regoffs(eai->address_reg, - (ULONG)(eai->addr_const_off + address_space), + (uae_u32)(eai->addr_const_off + address_space), eai->data_reg, eai->size); } } @@ -2567,7 +2564,7 @@ static void compile_storeea(struct regis } } else { int destr; - + have_cache_reg_d: destr = map->dreg_map[eaid->reg]; @@ -2588,18 +2585,18 @@ static void compile_storeea(struct regis map->x86_byteorder[destr] = BO_NORMAL; } else if (eais->data_reg == -1) { if (eais->mode == Dreg) { - compile_move_reg_from_mem_regoffs(destr, -2, (ULONG)(regs.regs + eais->reg), + compile_move_reg_from_mem_regoffs(destr, -2, (uae_u32)(regs.regs + eais->reg), eais->size); map->x86_byteorder[destr] = BO_NORMAL; } else if (eais->mode == Areg) { - compile_move_reg_from_mem_regoffs(destr, -2, (ULONG)(regs.regs + 8 + eais->reg), + compile_move_reg_from_mem_regoffs(destr, -2, (uae_u32)(regs.regs + 8 + eais->reg), eais->size); map->x86_byteorder[destr] = BO_NORMAL; } else { /* Move mem to reg */ compile_force_byteorder(map, eais->address_reg, BO_NORMAL, 0); compile_move_reg_from_mem_regoffs(destr, eais->address_reg, - (ULONG)(eais->addr_const_off + address_space), + (uae_u32)(eais->addr_const_off + address_space), eais->size); switch (eais->size) { @@ -2627,7 +2624,7 @@ static void compile_storeea(struct regis } } } - + if (map->dreg_map[eaid->reg] >= 0) map->x86_dirty[map->dreg_map[eaid->reg]] = 1; return; @@ -2641,7 +2638,7 @@ static void compile_storeea(struct regis map->x86_dirty[eais->data_reg] = 1; map->x86_verified[eais->data_reg] = 0; map->x86_const_offset[eais->data_reg] = eais->data_const_off; return; - } + } /* Is the destination register in its home location? */ if (map->areg_map[eaid->reg] < 0) { if (eais->data_reg == -2) { @@ -2669,7 +2666,7 @@ static void compile_storeea(struct regis } } else { int destr; - + have_cache_reg_a: destr = map->areg_map[eaid->reg]; @@ -2686,20 +2683,20 @@ static void compile_storeea(struct regis map->x86_byteorder[destr] = BO_NORMAL; } else if (eais->data_reg == -1) { if (eais->mode == Dreg) { - compile_move_reg_from_mem_regoffs(destr, -2, (ULONG)(regs.regs + eais->reg), + compile_move_reg_from_mem_regoffs(destr, -2, (uae_u32)(regs.regs + eais->reg), eais->size); map->x86_byteorder[destr] = BO_NORMAL; } else if (eais->mode == Areg) { - compile_move_reg_from_mem_regoffs(destr, -2, (ULONG)(regs.regs + 8 + eais->reg), + compile_move_reg_from_mem_regoffs(destr, -2, (uae_u32)(regs.regs + 8 + eais->reg), eais->size); map->x86_byteorder[destr] = BO_NORMAL; } else { /* Move mem to reg */ compile_force_byteorder(map, eais->address_reg, BO_NORMAL, 0); - compile_move_reg_from_mem_regoffs(destr, eais->address_reg, - (ULONG)(eais->addr_const_off + address_space), + compile_move_reg_from_mem_regoffs(destr, eais->address_reg, + (uae_u32)(eais->addr_const_off + address_space), eais->size); - + map->x86_byteorder[destr] = BO_SWAPPED_LONG; } } else { @@ -2713,7 +2710,7 @@ static void compile_storeea(struct regis map->x86_verified[eais->data_reg] = 0; } } - + if (map->areg_map[eaid->reg] >= 0) map->x86_dirty[map->areg_map[eaid->reg]] = 1; return; @@ -2724,7 +2721,7 @@ static void compile_storeea(struct regis /* Correct the byteorder */ if (eais->data_reg != -2) { compile_offset_reg(map, eais->data_reg, eais->data_const_off); - + switch (eaid->size) { case sz_byte: compile_force_byteorder(map, eais->data_reg, BO_NORMAL, 1); break; case sz_word: compile_force_byteorder(map, eais->data_reg, BO_SWAPPED_WORD, 1); break; @@ -2732,7 +2729,7 @@ static void compile_storeea(struct regis } compile_force_byteorder(map, eaid->address_reg, BO_NORMAL, 0); compile_move_reg_to_mem_regoffs(eaid->address_reg, - (ULONG)(eaid->addr_const_off + address_space), + (uae_u32)(eaid->addr_const_off + address_space), eais->data_reg, eaid->size); } else { switch (eaid->size) { @@ -2749,7 +2746,7 @@ static void compile_storeea(struct regis } compile_force_byteorder(map, eaid->address_reg, BO_NORMAL, 0); /* generate code to move valueoffset,eaoffset(eareg) */ - switch(eaid->size) { + switch(eaid->size) { case sz_byte: assemble(0xC6); break; case sz_word: assemble(0x66); /* fall through */ case sz_long: assemble(0xC7); break; @@ -2774,7 +2771,7 @@ static void compile_storeea(struct regis static struct { struct register_mapping map; char *jmpoffs; - ULONG address; + uae_u32 address; int noflush:1; } compile_exit_stack[CE_STACK_SIZE]; @@ -2785,7 +2782,7 @@ static struct register_mapping current_e static void generate_exit(struct register_mapping *map, int address) { int i; - + if (map != NULL) sync_reg_cache (map, 1); assemble(0xB8); /* movl $new_pc,%eax */ @@ -2793,7 +2790,7 @@ static void generate_exit(struct registe assemble(0xC3); /* RET */ } -static void copy_map_with_undo(struct register_mapping *dst, +static void copy_map_with_undo(struct register_mapping *dst, struct register_mapping *src, struct pid_undo *pud) { @@ -2829,7 +2826,7 @@ static void generate_possible_exit(struc struct pid_undo *pud) { struct register_mapping exit_regmap; - + if (!exits_necessary) { unlock_pud(map, pud); return; @@ -2907,7 +2904,7 @@ static void finish_condjumps(int lastiip #define CC_X_FROM_86C 1 #define CC_C_FROM_86C 2 #define CC_Z_FROM_86Z 4 -#define CC_V_FROM_86V 8 +#define CC_V_FROM_86V 8 #define CC_N_FROM_86N 16 #define CC_TEST_REG 32 #define CC_Z_FROM_86C 64 @@ -2918,7 +2915,7 @@ static void finish_condjumps(int lastiip static unsigned int cc_status; static int cc_reg; -static ULONG cc_offset; +static uae_u32 cc_offset; static wordsizes cc_size; static void compile_do_cc_test_reg(struct register_mapping *map) @@ -2935,7 +2932,7 @@ static void compile_do_cc_test_reg(struc assemble(0xC0 + 9*cc_reg); } -static int compile_flush_cc_cache(struct register_mapping *map, int status, +static int compile_flush_cc_cache(struct register_mapping *map, int status, int live_at_end, int user_follows, int user_live_at_end, int user_ccval) { @@ -2992,15 +2989,15 @@ static int compile_flush_cc_cache(struct } /* - * Now store the flags which are live at the end of this insn and set by - * us into their home locations + * Now store the flags which are live at the end of this insn and set by + * us into their home locations */ if (status == CC_TEST_REG) { if ((live_at_end & (CC68K_C|CC68K_V|CC68K_Z|CC68K_N)) == 0) goto all_ok; if (cc_reg == -2) { - UBYTE f = 0; + uae_u8 f = 0; if (cc_size == sz_byte) { f |= (cc_offset & 0x80) ? 0x80 : 0; f |= (cc_offset & 0xFF) == 0 ? 0x40 : 0; @@ -3011,7 +3008,7 @@ static int compile_flush_cc_cache(struct f |= (cc_offset & 0x80000000) ? 0x80 : 0; f |= (cc_offset & 0xFFFFFFFF) == 0 ? 0x40 : 0; } - assemble(0xC7); assemble(0x05); + assemble(0xC7); assemble(0x05); assemble_long((char*)®flags); assemble_uword(f); } else { @@ -3020,7 +3017,7 @@ static int compile_flush_cc_cache(struct /* pushfl; popl tmpr; movl tempr, regflags */ assemble(0x9C); assemble(0x58+tmpr); - compile_move_reg_to_mem_regoffs(-2, (ULONG)®flags, tmpr, sz_long); + compile_move_reg_to_mem_regoffs(-2, (uae_u32)®flags, tmpr, sz_long); } } else if (status == CC_Z_FROM_86C) { if ((live_at_end & CC68K_Z) != 0) { @@ -3029,7 +3026,7 @@ static int compile_flush_cc_cache(struct /* setnc tmpr; shl $6, tmpr; andb $~0x40, regflags; orb tmpr, regflags */ assemble(0x0F); assemble(0x93); assemble(0xC0 + tmpr); assemble(0xC0); assemble(4*8 + 0xC0 + tmpr); assemble(6); - assemble(0x80); assemble(0x05+0x20); assemble_long(®flags); assemble((UBYTE)~0x40); + assemble(0x80); assemble(0x05+0x20); assemble_long(®flags); assemble((uae_u8)~0x40); assemble(0x08); assemble(0x05+ tmpr*8); assemble_long(®flags); assemble(0x9D); } @@ -3043,19 +3040,19 @@ static int compile_flush_cc_cache(struct assemble(0x9D); /* adc $0, tmpr */ assemble(0x80); assemble(0xC0 + tmpr + 8*2); assemble(0); - compile_move_reg_to_mem_regoffs(-2, (ULONG)®flags, tmpr, sz_long); + compile_move_reg_to_mem_regoffs(-2, (uae_u32)®flags, tmpr, sz_long); if (status == CC_AFTER_ROX) - compile_move_reg_to_mem_regoffs(-2, 4 + (ULONG)®flags, tmpr, sz_long); + compile_move_reg_to_mem_regoffs(-2, 4 + (uae_u32)®flags, tmpr, sz_long); } else if (status != 0) { assert((status & CC_TEST_REG) == 0); assert (status == (CC_C_FROM_86C | CC_Z_FROM_86Z | CC_N_FROM_86N | CC_X_FROM_86C | CC_V_FROM_86V) || status == (CC_C_FROM_86C | CC_Z_FROM_86Z | CC_N_FROM_86N | CC_V_FROM_86V) || status == CC_C_FROM_86C); - + if ((status & CC_X_FROM_86C) == 0) live_at_end &= ~CC68K_X; - - if (status == CC_C_FROM_86C && (live_at_end & CC68K_C) != 0) + + if (status == CC_C_FROM_86C && (live_at_end & CC68K_C) != 0) fprintf(stderr, "Shouldn't be needing C here!\n"); else if (live_at_end) { if ((live_at_end & CC68K_X) == 0) @@ -3065,15 +3062,15 @@ static int compile_flush_cc_cache(struct if ((status & CC_X_FROM_86C) != 0 && live_at_end == CC68K_X) { /* SETC regflags + 4 */ assemble(0x0F); assemble(0x92); - assemble(0x05); assemble_long(4 + (ULONG)®flags); + assemble(0x05); assemble_long(4 + (uae_u32)®flags); } else { int tmpr = get_free_x86_register(map, ALL_X86_REGS); /* pushfl; popl tmpr; movl tempr, regflags */ assemble(0x9C); assemble(0x58+tmpr); - compile_move_reg_to_mem_regoffs(-2, (ULONG)®flags, tmpr, sz_long); - + compile_move_reg_to_mem_regoffs(-2, (uae_u32)®flags, tmpr, sz_long); + if (status & CC_X_FROM_86C) { - compile_move_reg_to_mem_regoffs(-2, 4 + (ULONG)®flags, tmpr, sz_word); + compile_move_reg_to_mem_regoffs(-2, 4 + (uae_u32)®flags, tmpr, sz_word); } } } @@ -3105,15 +3102,15 @@ static char *compile_condbranch(struct r /* Fine */; else if (new_cc_status == CC_SAHF) { int tmpr = get_free_x86_register(map, ALL_X86_REGS); - compile_move_reg_from_mem_regoffs(tmpr, -2, (ULONG)®flags, sz_long); + compile_move_reg_from_mem_regoffs(tmpr, -2, (uae_u32)®flags, sz_long); assemble(0x66); assemble(0x50+tmpr); assemble(0x66); assemble(0x9D); new_cc_status = CC_C_FROM_86C|CC_Z_FROM_86Z|CC_N_FROM_86N|CC_V_FROM_86V; } else if (new_cc_status == CC_TEST_CONST) { int n,z; switch(cc_size) { - case sz_byte: n = ((BYTE)cc_offset) < 0; z = ((BYTE)cc_offset) == 0; break; - case sz_word: n = ((WORD)cc_offset) < 0; z = ((WORD)cc_offset) == 0; break; - case sz_long: n = ((LONG)cc_offset) < 0; z = ((LONG)cc_offset) == 0; break; + case sz_byte: n = ((uae_s8)cc_offset) < 0; z = ((uae_s8)cc_offset) == 0; break; + case sz_word: n = ((uae_s16)cc_offset) < 0; z = ((uae_s16)cc_offset) == 0; break; + case sz_long: n = ((uae_s32)cc_offset) < 0; z = ((uae_s32)cc_offset) == 0; break; } #define Bcc_TRUE 0 #define Bcc_FALSE 1 @@ -3143,10 +3140,10 @@ static char *compile_condbranch(struct r } else if (cc != 0 && cc != 1) printf("Groan!\n"); } - + if (cc == 1) return NULL; - + if ((flagsneeded & new_cc_status) == flagsneeded) { char *result; /* We can generate a simple branch */ @@ -3178,17 +3175,17 @@ static char *compile_condbranch(struct r return NULL; } -static void compile_handle_bcc(struct register_mapping *map, int iip, +static void compile_handle_bcc(struct register_mapping *map, int iip, int new_cc_status) { insn_info[iip].compiled_fillin = compile_condbranch(map, iip, new_cc_status); } -static void compile_handle_dbcc(struct register_mapping *map, int iip, +static void compile_handle_dbcc(struct register_mapping *map, int iip, int new_cc_status, int dreg) { char *fillin1 = compile_condbranch(map, iip, new_cc_status); - + /* subw $1,dreg; jnc ... */ assemble(0x66); assemble(0x83); assemble(0x05 + 5*8); assemble_long(regs.regs + dreg); @@ -3207,7 +3204,7 @@ static void compile_handle_dbcc(struct r static void handle_bit_insns(struct register_mapping *map, struct ea_info *eainf, int eaino_s, int eaino_d, instrmnem optype) { - struct ea_info *srcea = eainf + eaino_s, *dstea = eainf + eaino_d; + struct ea_info *srcea = eainf + eaino_s, *dstea = eainf + eaino_d; int code = (optype == i_BTST ? 0 : optype == i_BSET ? 1 : optype == i_BCLR ? 2 @@ -3260,7 +3257,7 @@ static void handle_bit_insns(struct regi if (dstea->data_reg != -1) printf("Things don't look good in handle_bit_insns\n"); if (srcea->data_reg == -2) { - assemble(0x0F); assemble(0xBA); + assemble(0x0F); assemble(0xBA); assemble(addr_code + 8*(4 + code)); assemble_long(address_space + dstea->addr_const_off); assemble(srcea->data_const_off); @@ -3269,15 +3266,15 @@ static void handle_bit_insns(struct regi assemble(addr_code + srcea->data_reg*8); assemble_long(address_space + dstea->addr_const_off); } - + } cc_status = CC_Z_FROM_86C; } static int do_rotshi = 1; -static void handle_rotshi(struct register_mapping *map, int iip, - UBYTE *realpc, CPTR current_addr, struct pid_undo *pud) +static void handle_rotshi(struct register_mapping *map, int iip, + uae_u8 *realpc, uaecptr current_addr, struct pid_undo *pud) { struct ea_info eai; int amode_reg = insn_info[iip].dp->sreg; @@ -3287,7 +3284,7 @@ static void handle_rotshi(struct registe int mnemo = insn_info[iip].dp->mnemo; int shiftcode; int locked_eax_for_sahf = 0; - + switch(mnemo) { case i_ASLW: shiftcount = 1; mnemo = i_ASL; break; case i_ASRW: shiftcount = 1; mnemo = i_ASR; break; @@ -3311,22 +3308,22 @@ static void handle_rotshi(struct registe } else if (mnemo == i_ASR || mnemo == i_LSR || mnemo == i_LSL) { remove_x86r_from_cache(map, r_EAX, 1); locked_eax_for_sahf = 1; - lock_reg(map, r_EAX, 2); + lock_reg(map, r_EAX, 2); } - + } if (mnemo == i_ROXR || mnemo == i_ROXL) { remove_x86r_from_cache(map, r_EAX, 1); lock_reg(map, r_EAX, 2); - compile_move_reg_from_mem_regoffs(r_AH, -2, 4 + (ULONG)®flags, sz_byte); + compile_move_reg_from_mem_regoffs(r_AH, -2, 4 + (uae_u32)®flags, sz_byte); } compile_prepare_undo(map, amode_mode, amode_reg, pud); compile_prepareea(map, amode_mode, amode_reg, size, &realpc, current_addr, &eai, 0, EA_LOAD|EA_STORE|EA_MODIFY, 1); - + generate_possible_exit(map, &eai, iip, pud); - + compile_fetchea(map, &eai, 0, 1); compile_force_byteorder(map, eai.data_reg, BO_NORMAL, 0); @@ -3336,7 +3333,7 @@ static void handle_rotshi(struct registe break; case i_LSL: shiftcode = 4; cc_status = CC_C_FROM_86C | CC_Z_FROM_86Z | CC_N_FROM_86N | CC_V_FROM_86V | CC_X_FROM_86C; - break; + break; case i_LSR: shiftcode = 5; cc_status = CC_C_FROM_86C | CC_Z_FROM_86Z | CC_N_FROM_86N | CC_V_FROM_86V | CC_X_FROM_86C; break; @@ -3374,8 +3371,8 @@ static void handle_rotshi(struct registe compile_note_modify(map, &eai, 0); } -static void handle_rotshi_variable(struct register_mapping *map, int iip, - UBYTE *realpc, CPTR current_addr, +static void handle_rotshi_variable(struct register_mapping *map, int iip, + uae_u8 *realpc, uaecptr current_addr, struct pid_undo *pud) { struct ea_info eais, eaid; @@ -3395,14 +3392,14 @@ static void handle_rotshi_variable(struc } else if (mnemo == i_ASR || mnemo == i_LSR || mnemo == i_LSL) { remove_x86r_from_cache(map, r_EAX, 1); locked_eax_for_sahf = 1; - lock_reg(map, r_EAX, 2); + lock_reg(map, r_EAX, 2); } - + } if (mnemo == i_ROXR || mnemo == i_ROXL) { remove_x86r_from_cache(map, r_EAX, 1); lock_reg(map, r_EAX, 2); - compile_move_reg_from_mem_regoffs(r_AH, -2, 4 + (ULONG)®flags, + compile_move_reg_from_mem_regoffs(r_AH, -2, 4 + (uae_u32)®flags, sz_byte); } /* Both src and dest are Dreg modes */ @@ -3412,7 +3409,7 @@ static void handle_rotshi_variable(struc compile_prepareea(map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, &eaid, 0, EA_LOAD|EA_STORE|EA_MODIFY, 1); - + compile_fetchea(map, &eais, 0, 1); compile_fetchea(map, &eaid, 1, 1); compile_force_byteorder(map, eais.data_reg, BO_NORMAL, 0); @@ -3434,7 +3431,7 @@ static void handle_rotshi_variable(struc break; case i_LSL: shiftcode = 4; cc_status = CC_C_FROM_86C | CC_Z_FROM_86Z | CC_N_FROM_86N | CC_V_FROM_86V | CC_X_FROM_86C; - break; + break; case i_LSR: shiftcode = 5; cc_status = CC_C_FROM_86C | CC_Z_FROM_86Z | CC_N_FROM_86N | CC_V_FROM_86V | CC_X_FROM_86C; break; @@ -3472,7 +3469,7 @@ static void handle_rotshi_variable(struc compile_unlock_reg(map, r_ECX); } -static ULONG testmask = 0xF80000, testval = 0xF80000; +static uae_u32 testmask = 0xF80000, testval = 0xF80000; static int m68k_compile_block(struct hash_block *hb) { @@ -3480,11 +3477,11 @@ static int m68k_compile_block(struct has int last_iip = m68k_scan_block(hb, &movem_extra); struct register_mapping map; int i, iip, szflag; - UBYTE *realpc_start = NULL; + uae_u8 *realpc_start = NULL; struct bb_info *current_bb; int cc_status_for_bcc = CC_SAHF; struct insn_reg_needs reg_needs_init; - + cesp = 0; if (n_compiled > n_max_comp) @@ -3500,17 +3497,17 @@ static int m68k_compile_block(struct has return 1; exits_necessary = ((hb->he_first->addr & 0xF80000) == 0xF80000 || !USER_PROGRAMS_BEHAVE); - + if (alloc_code (hb, last_iip + movem_extra) == NULL) { hb->allocfailed = 1; return 0; } compile_org(hb->compile_start); compile_last_addr = (char *)hb->compile_start + hb->alloclen; - + /* m68k_scan_block() will leave this all set up */ current_bb = bb_stack; - + for (i = 0; i < 8; i++) { map.dreg_map[i] = map.areg_map[i] = -1; map.x86_dirty[i] = 0; @@ -3520,17 +3517,17 @@ static int m68k_compile_block(struct has map.x86_verified[i] = 0; map.x86_byteorder[i] = BO_NORMAL; } - + reg_needs_init.checkpoint_no = 0; for (i = 0; i < 8; i++) { reg_needs_init.dreg_needed[i] = reg_needs_init.areg_needed[i] = -1; reg_needs_init.dreg_mask[i] = reg_needs_init.areg_mask[i] = ALL_X86_REGS; } - + for (iip = 0; iip < last_iip && !compile_failure; iip++) { - UBYTE *realpc; + uae_u8 *realpc; struct ea_info eainfo[8]; - CPTR current_addr; + uaecptr current_addr; struct pid_undo pub; struct insn_reg_needs this_reg_needs = reg_needs_init; @@ -3551,15 +3548,15 @@ static int m68k_compile_block(struct has realpc_start = get_real_address(current_bb->h->addr); current_bb->h->execute = (code_execfunc)compile_here(); - current_bb->h->matchword = *(ULONG *)realpc_start; + current_bb->h->matchword = *(uae_u32 *)realpc_start; cc_status_for_bcc = CC_SAHF; } - realpc = realpc_start + (current_addr - current_bb->h->addr); + realpc = realpc_start + (current_addr - current_bb->h->addr); - insn_info[iip].compiled_jumpaddr = compile_here(); + insn_info[iip].compiled_jumpaddr = compile_here(); insn_info[iip].compiled_fillin = NULL; - + if (insn_info[iip].jump_target) { if (cesp == CE_STACK_SIZE) { generate_exit(NULL, insn_info[iip].address); @@ -3625,14 +3622,14 @@ static int m68k_compile_block(struct has assemble(0x89); assemble(0x5 + r_ECX*8); assemble_long(&jsr_num); assemble(0x83); assemble(0x05 + 5*8); assemble_long(regs.regs + 15); assemble(-4); /* Off we go */ - assemble(0xFF); assemble(4*8 + 0xC0 + r_EBX); + assemble(0xFF); assemble(4*8 + 0xC0 + r_EBX); } break; - + case i_JMP: sync_reg_cache(&map, 1); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); { @@ -3650,7 +3647,7 @@ static int m68k_compile_block(struct has assemble(0x09); assemble(0xC0 + 9*r_EBX); assemble(0x0F); assemble(0x85); tmp1 = compile_here(); assemble_ulong(0); generate_exit(&map, insn_info[iip].address); - tmp2 = compile_here(); compile_org(tmp1); + tmp2 = compile_here(); compile_org(tmp1); assemble_ulong((tmp2 - tmp1) - 4); compile_org(tmp2); /* Off we go */ @@ -3664,7 +3661,7 @@ static int m68k_compile_block(struct has lock_reg(&map, r_ECX, 2); lock_reg(&map, r_EBX, 2); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); { @@ -3692,16 +3689,16 @@ static int m68k_compile_block(struct has compile_org(tmp3); assemble_ulong(tmp1-tmp3); compile_org(tmp2); /* movl $something,disp32(,%ecx,4) */ - assemble(0xC7); assemble(0x04); assemble(0x8d); + assemble(0xC7); assemble(0x04); assemble(0x8d); assemble_long(jsr_rets); assemble_ulong(insn_info[iip+1].address); - assemble(0xC7); assemble(0x04); assemble(0x8d); + assemble(0xC7); assemble(0x04); assemble(0x8d); assemble_long(jsr_hash); assemble_long((current_bb + 1)->h); /* incl jsr_num */ assemble(0xFF); assemble(0x05); assemble_long(&jsr_num); /* Put things on the 68k stack */ assemble(0x83); assemble(0x05 + 5*8); assemble_long(regs.regs + 15); assemble(4); assemble(0x8B); assemble(r_ECX*8+ 0x05); assemble_long(regs.regs + 15); - assemble(0xC7); assemble(0x80 + r_ECX); assemble_long(address_space); + assemble(0xC7); assemble(0x80 + r_ECX); assemble_long(address_space); assemble_ulong_68k(insn_info[iip+1].address); /* Off we go */ assemble(0xFF); assemble(4*8 + 0xC0 + r_EBX); @@ -3713,12 +3710,12 @@ static int m68k_compile_block(struct has lock_reg(&map, r_ECX, 2); lock_reg(&map, r_EBX, 2); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); { char *tmp1, *tmp2, *tmp3; - CPTR dest = insn_info[iip].address + 2 + (LONG)eainfo[0].data_const_off; + uaecptr dest = insn_info[iip].address + 2 + (uae_s32)eainfo[0].data_const_off; struct hash_entry *tmph; if ((tmph = get_hash_for_func(dest, 1)) == 0) { generate_exit(&map, insn_info[iip].address); @@ -3740,22 +3737,22 @@ static int m68k_compile_block(struct has compile_org(tmp3); assemble_ulong(tmp1-tmp3); compile_org(tmp2); /* movl $something,disp32(,%ecx,4) */ - assemble(0xC7); assemble(0x04); assemble(0x8d); + assemble(0xC7); assemble(0x04); assemble(0x8d); assemble_long(jsr_rets); assemble_ulong(insn_info[iip+1].address); - assemble(0xC7); assemble(0x04); assemble(0x8d); + assemble(0xC7); assemble(0x04); assemble(0x8d); assemble_long(jsr_hash); assemble_long((current_bb + 1)->h); /* incl jsr_num */ assemble(0xFF); assemble(0x05); assemble_long(&jsr_num); /* Put things on the 68k stack */ assemble(0x83); assemble(0x05 + 5*8); assemble_long(regs.regs + 15); assemble(4); assemble(0x8B); assemble(r_ECX*8+ 0x05); assemble_long(regs.regs + 15); - assemble(0xC7); assemble(0x80 + r_ECX); assemble_long(address_space); + assemble(0xC7); assemble(0x80 + r_ECX); assemble_long(address_space); assemble_ulong_68k(insn_info[iip+1].address); /* Off we go */ assemble(0xFF); assemble(4*8 + 0xC0 + r_EBX); } break; - + case i_Bcc: sync_reg_cache(&map, 0); compile_handle_bcc(&map, iip, cc_status_for_bcc); @@ -3773,7 +3770,7 @@ static int m68k_compile_block(struct has case i_Scc: compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_STORE, 1); @@ -3791,20 +3788,20 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, - eainfo, 1, - (insn_info[iip].dp->mnemo == i_ADD || insn_info[iip].dp->mnemo == i_SUB + eainfo, 1, + (insn_info[iip].dp->mnemo == i_ADD || insn_info[iip].dp->mnemo == i_SUB ? EA_MODIFY | EA_LOAD | EA_STORE : EA_LOAD | EA_STORE), 1); generate_possible_exit(&map, eainfo, iip, &pub); generate_possible_exit(&map, eainfo+1, iip, &pub); - + compile_loadeas(&map, eainfo, 0, 1, binop_alternatives, 0, 1); switch (insn_info[iip].dp->mnemo) { @@ -3812,7 +3809,7 @@ static int m68k_compile_block(struct has case i_SUB: compile_eas(&map, eainfo, 0, 1, 5); break; case i_CMP: case i_CMPM: compile_eas(&map, eainfo, 0, 1, 7); break; } - + if (insn_info[iip].dp->mnemo != i_CMP && insn_info[iip].dp->mnemo != i_CMPM) compile_note_modify(&map, eainfo, 1); switch (insn_info[iip].dp->mnemo) { @@ -3832,11 +3829,11 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 1, EA_MODIFY | EA_LOAD | EA_STORE, 1); @@ -3846,13 +3843,13 @@ static int m68k_compile_block(struct has compile_loadeas(&map, eainfo, 0, 1, binop_alternatives, 0, 1); /* bt $0, regflags+4 ; get carry */ - assemble(0x0F); assemble(0xBA); assemble(0x5+4*8); - assemble_ulong(4 + (ULONG)®flags); assemble(0); + assemble(0x0F); assemble(0xBA); assemble(0x5+4*8); + assemble_ulong(4 + (uae_u32)®flags); assemble(0); switch (insn_info[iip].dp->mnemo) { case i_ADDX: compile_eas(&map, eainfo, 0, 1, 2); break; case i_SUBX: compile_eas(&map, eainfo, 0, 1, 3); break; - } + } compile_note_modify(&map, eainfo, 1); if (insn_info[iip].flags_live_at_end & CC68K_Z) { @@ -3865,7 +3862,7 @@ static int m68k_compile_block(struct has assemble(0x21); assemble(0x05 + 8*tmpr); assemble_long(®flags); assemble(0x81); assemble(0xC0 + 8*4 + tmpr); assemble_ulong(~0x40); assemble(0x09); assemble(0x05 + 8*tmpr); assemble_long(®flags); - compile_move_reg_to_mem_regoffs(-2, 4 + (ULONG)®flags, tmpr, sz_long); + compile_move_reg_to_mem_regoffs(-2, 4 + (uae_u32)®flags, tmpr, sz_long); cc_status = 0; } else { /* Lies! */ @@ -3878,17 +3875,17 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 1, EA_MODIFY | EA_LOAD | EA_STORE, 1); generate_possible_exit(&map, eainfo, iip, &pub); generate_possible_exit(&map, eainfo+1, iip, &pub); - + compile_loadeas(&map, eainfo, 0, 1, regonly_alternatives, 0, 1); /* Extend the regs properly */ @@ -3918,16 +3915,16 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, sz_long, &realpc, current_addr, - eainfo, 1, + eainfo, 1, (insn_info[iip].dp->mnemo == i_ADDA || insn_info[iip].dp->mnemo == i_SUBA ? EA_MODIFY | EA_LOAD | EA_STORE - : EA_LOAD | EA_STORE), + : EA_LOAD | EA_STORE), 1); generate_possible_exit(&map, eainfo, iip, &pub); @@ -3960,20 +3957,20 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 1, EA_STORE, 1); generate_possible_exit(&map, eainfo, iip, &pub); generate_possible_exit(&map, eainfo + 1, iip, &pub); - + compile_loadeas(&map, eainfo, 0, 1, binop_alternatives, 1, 0); compile_storeea(&map, eainfo, 0, 1); - + if (eainfo[0].data_reg == -2) { cc_status = CC_TEST_REG; cc_reg = -2; @@ -3990,14 +3987,14 @@ static int m68k_compile_block(struct has cc_offset = 0; } cc_size = eainfo[0].size; - + break; case i_MOVEA: compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, @@ -4006,7 +4003,7 @@ static int m68k_compile_block(struct has eainfo, 1, EA_STORE, 1); generate_possible_exit(&map, eainfo, iip, &pub); - + compile_loadeas(&map, eainfo, 0, 1, insn_info[iip].dp->size == sz_word ? binop_worda_alternatives : binop_alternatives, 0, 0); @@ -4024,7 +4021,7 @@ static int m68k_compile_block(struct has case i_EXG: if (insn_info[iip].dp->smode != insn_info[iip].dp->dmode - || insn_info[iip].dp->sreg != insn_info[iip].dp->dreg) + || insn_info[iip].dp->sreg != insn_info[iip].dp->dreg) { compile_prepareea(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, @@ -4042,11 +4039,11 @@ static int m68k_compile_block(struct has cc_status = 0; break; - + case i_LINK: compile_prepare_undo(&map, Apdi, 7, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, sz_long, &realpc, current_addr, eainfo, 0, EA_LOAD|EA_STORE, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, @@ -4074,19 +4071,19 @@ static int m68k_compile_block(struct has compile_prepareea(&map, Areg, 7, sz_long, &realpc, current_addr, eainfo, 5, EA_STORE, 1); compile_fetchea(&map, eainfo, 4, 1); - eainfo[4].data_const_off += (WORD)eainfo[1].data_const_off; + eainfo[4].data_const_off += (uae_s16)eainfo[1].data_const_off; compile_storeea(&map, eainfo, 4, 5); /* A7+off -> A7 */ cc_status = 0; break; - + case i_UNLK: compile_prepareea(&map, Areg, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, sz_long, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, Areg, 7, sz_long, &realpc, current_addr, eainfo, 1, EA_STORE, 1); - + generate_possible_exit(&map, eainfo + 0, iip, &pub); compile_fetchea(&map, eainfo, 0, 1); @@ -4098,13 +4095,13 @@ static int m68k_compile_block(struct has compile_prepareea(&map, Aipi, 7, sz_long, &realpc, current_addr, eainfo, 2, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, sz_long, &realpc, current_addr, eainfo, 3, EA_STORE, 1); compile_fetchea(&map, eainfo, 2, 1); compile_storeea(&map, eainfo, 2, 3); - cc_status = 0; + cc_status = 0; break; case i_OR: @@ -4113,17 +4110,17 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 1, EA_MODIFY | EA_LOAD | EA_STORE, 1); generate_possible_exit(&map, eainfo, iip, &pub); generate_possible_exit(&map, eainfo + 1, iip, &pub); - + compile_loadeas(&map, eainfo, 0, 1, binop_alternatives, 0, 1); switch (insn_info[iip].dp->mnemo) { @@ -4131,7 +4128,7 @@ static int m68k_compile_block(struct has case i_EOR: compile_eas(&map, eainfo, 0, 1, 6); break; case i_OR: compile_eas(&map, eainfo, 0, 1, 1); break; } - + compile_note_modify(&map, eainfo, 1); cc_status = CC_Z_FROM_86Z | CC_C_FROM_86C | CC_V_FROM_86V | CC_N_FROM_86N; break; @@ -4139,23 +4136,23 @@ static int m68k_compile_block(struct has case i_TST: compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); generate_possible_exit(&map, eainfo, iip, &pub); - + compile_fetchea(&map, eainfo, 0, 1); cc_status = CC_TEST_REG; cc_reg = eainfo[0].data_reg; cc_offset = 0; cc_size = eainfo[0].size; break; - + case i_CLR: compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_STORE, 1); compile_prepareea(&map, immi, 0, sz_long, &realpc, current_addr, @@ -4174,7 +4171,7 @@ static int m68k_compile_block(struct has /* No exits, no undo - this is always a Dreg; fetchea will get it in a reg * without offset */ compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size == sz_long ? sz_word : sz_byte, &realpc, current_addr, eainfo, 0, EA_LOAD|EA_STORE, 1); @@ -4188,14 +4185,14 @@ static int m68k_compile_block(struct has assemble(0xBF); else assemble(0xBE); - + assemble(0xC0 + 9*eainfo[0].data_reg); map.x86_dirty[eainfo[0].data_reg] = 1; cc_status = CC_TEST_REG; cc_reg = eainfo[0].data_reg; cc_offset = 0; - cc_size = eainfo[0].size; + cc_size = eainfo[0].size; break; case i_NOT: @@ -4204,20 +4201,20 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD|EA_STORE, 1); generate_possible_exit(&map, eainfo, iip, &pub); - + compile_fetchea(&map, eainfo, 0, 1); compile_force_byteorder(&map, eainfo[0].data_reg, BO_NORMAL, 0); if (insn_info[iip].dp->size == sz_word) assemble(0x66); assemble(0xF6 + szflag); - + assemble(0xC0 + eainfo[0].data_reg + 8*(insn_info[iip].dp->mnemo == i_NOT ? 2 : 3)); compile_note_modify(&map, eainfo, 0); @@ -4251,13 +4248,13 @@ static int m68k_compile_block(struct has cc_status = CC_TEST_REG; cc_reg = eainfo[0].data_reg; cc_offset = 0; - cc_size = eainfo[0].size; + cc_size = eainfo[0].size; break; - + case i_LEA: /* No exits necessary here: never touches memory */ compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, 0, 1); eainfo[0].data_reg = eainfo[0].address_reg; @@ -4275,7 +4272,7 @@ static int m68k_compile_block(struct has case i_PEA: compile_prepare_undo(&map, Apdi, 7, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, 0, 1); eainfo[0].data_reg = eainfo[0].address_reg; @@ -4293,7 +4290,7 @@ static int m68k_compile_block(struct has case i_MVMEL: compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, sz_word, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); sync_reg_cache(&map, 0); @@ -4304,20 +4301,20 @@ static int m68k_compile_block(struct has * from. */ int scratch0, scratch1, scratch2; - UWORD mask = eainfo[0].data_const_off; + uae_u16 mask = eainfo[0].data_const_off; int bits = count_bits(mask); int size = insn_info[iip].dp->size == sz_long ? 4 : 2; int i; - UBYTE x86amode; - ULONG current_offs = 0; - + uae_u8 x86amode; + uae_u32 current_offs = 0; + compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); /* !!! Note current_addr + 2 here! */ compile_prepareea(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr + 2, eainfo, 1, EA_LOAD, bits); - + generate_possible_exit(&map, eainfo + 1, iip, &pub); scratch0 = get_free_x86_register(&map, ADDRESS_X86_REGS); @@ -4327,20 +4324,20 @@ static int m68k_compile_block(struct has scratch2 = get_free_x86_register(&map, ADDRESS_X86_REGS); lock_reg(&map, scratch2, 2); compile_force_byteorder(&map, eainfo[1].address_reg, BO_NORMAL, 0); - - compile_lea_reg_with_offset(scratch1, -2, (ULONG)regs.regs); + + compile_lea_reg_with_offset(scratch1, -2, (uae_u32)regs.regs); compile_lea_reg_with_offset(scratch2, eainfo[1].address_reg, - (ULONG)(address_space + eainfo[1].addr_const_off)); + (uae_u32)(address_space + eainfo[1].addr_const_off)); for (i = 0; i < 16; i++) { int r68k = i; int *cache68k = i < 8 ? map.dreg_map : map.areg_map; - if (mask & 1 - && (i < 8 + if (mask & 1 + && (i < 8 || insn_info[iip].dp->dmode != Aipi || (r68k & 7) != insn_info[iip].dp->dreg)) { int tmpr = cache68k[r68k & 7]; - + if (tmpr != -1) { cache68k[r68k & 7] = -1; map.x86_cache_reg[tmpr] = -1; @@ -4371,18 +4368,18 @@ static int m68k_compile_block(struct has case i_MVMLE: compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, sz_word, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); sync_reg_cache(&map, 0); { int scratch0,scratch1,scratch2; - UWORD mask = eainfo[0].data_const_off; + uae_u16 mask = eainfo[0].data_const_off; int bits = count_bits(mask); int size = insn_info[iip].dp->size == sz_long ? 4 : 2; int i; - UBYTE x86amode; - ULONG current_offs = 0; + uae_u8 x86amode; + uae_u32 current_offs = 0; int addrareg = -1; if (insn_info[iip].dp->dmode == Aind || insn_info[iip].dp->dmode == Apdi @@ -4401,7 +4398,7 @@ static int m68k_compile_block(struct has insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr + 2, eainfo, 1, EA_STORE, bits); - + generate_possible_exit(&map, eainfo + 1, iip, &pub); scratch0 = get_free_x86_register(&map, ADDRESS_X86_REGS); @@ -4413,9 +4410,9 @@ static int m68k_compile_block(struct has compile_force_byteorder(&map, eainfo[1].address_reg, BO_NORMAL, 0); - compile_lea_reg_with_offset(scratch1, -2, (ULONG)regs.regs); + compile_lea_reg_with_offset(scratch1, -2, (uae_u32)regs.regs); compile_lea_reg_with_offset(scratch2, eainfo[1].address_reg, - (ULONG)(address_space + eainfo[1].addr_const_off)); + (uae_u32)(address_space + eainfo[1].addr_const_off)); for (i = 0; i < 16; i++) { int r68k = i; @@ -4454,11 +4451,11 @@ static int m68k_compile_block(struct has compile_prepare_undo(&map, insn_info[iip].dp->smode, insn_info[iip].dp->sreg, &pub); compile_prepare_undo(&map, insn_info[iip].dp->dmode, insn_info[iip].dp->dreg, &pub); compile_prepareea(&map, insn_info[iip].dp->smode, - insn_info[iip].dp->sreg, + insn_info[iip].dp->sreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 0, EA_LOAD, 1); compile_prepareea(&map, insn_info[iip].dp->dmode, - insn_info[iip].dp->dreg, + insn_info[iip].dp->dreg, insn_info[iip].dp->size, &realpc, current_addr, eainfo, 1, 0, 1); @@ -4467,15 +4464,15 @@ static int m68k_compile_block(struct has handle_bit_insns(&map, eainfo, 0, 1, insn_info[iip].dp->mnemo); break; - - case i_ASL: case i_ASR: case i_LSL: case i_LSR: + + case i_ASL: case i_ASR: case i_LSL: case i_LSR: case i_ROL: case i_ROR: case i_ROXL:case i_ROXR: if (insn_info[iip].dp->smode == Dreg && do_rotshi) { handle_rotshi_variable(&map, iip, realpc, current_addr, &pub); break; } /* fall through */ - case i_ASLW: case i_ASRW: case i_LSLW: case i_LSRW: + case i_ASLW: case i_ASRW: case i_LSLW: case i_LSRW: case i_ROLW: case i_RORW: case i_ROXLW:case i_ROXRW: if (do_rotshi) { handle_rotshi(&map, iip, realpc, current_addr, &pub); @@ -4487,12 +4484,12 @@ static int m68k_compile_block(struct has break; } if (insn_info[iip].ccuser_follows) - cc_status_for_bcc = compile_flush_cc_cache(&map, cc_status, + cc_status_for_bcc = compile_flush_cc_cache(&map, cc_status, insn_info[iip].flags_live_at_end, 1, insn_info[iip+1].flags_live_at_end, insn_info[iip+1].dp->cc); else - cc_status_for_bcc = compile_flush_cc_cache(&map, cc_status, + cc_status_for_bcc = compile_flush_cc_cache(&map, cc_status, insn_info[iip].flags_live_at_end, 0, 0, 0); @@ -4511,9 +4508,9 @@ static int m68k_compile_block(struct has { int needed_len = compile_here() - hb->compile_start; int allocsize = (needed_len + PAGE_SUBUNIT - 1) & ~(PAGE_SUBUNIT-1); - ULONG allocmask; + uae_u32 allocmask; int allocbits; - + allocbits = (allocsize >> SUBUNIT_ORDER); allocmask = (1 << allocbits) - 1; while ((allocmask & hb->page_allocmask) != allocmask) @@ -4525,7 +4522,7 @@ static int m68k_compile_block(struct has hb->cpage->allocmask |= allocmask; } return 0; - + oops: if (1 || !quiet_compile) fprintf(stderr, "Compile failed!\n"); @@ -4534,7 +4531,7 @@ static int m68k_compile_block(struct has hb->untranslatable = 1; { struct hash_entry *h = hb->he_first; - + do { h->execute = NULL; h = h->next_same_block;