/[gxemul]/trunk/src/cpus/bintrans_i386.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpus/bintrans_i386.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 21 by dpavlin, Mon Oct 8 16:18:51 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2004-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: bintrans_i386.c,v 1.1 2005/08/29 14:36:41 debug Exp $   *  $Id: bintrans_i386.c,v 1.3 2006/02/09 22:40:26 debug Exp $
29   *   *
30   *  i386 specific code for dynamic binary translation.   *  i386 specific code for dynamic binary translation.
31   *  See bintrans.c for more information.  Included from bintrans.c.   *  See bintrans.c for more information.  Included from bintrans.c.
# Line 64  static void bintrans_host_cacheinvalidat Line 64  static void bintrans_host_cacheinvalidat
64  #define ofs_tabl0       (((size_t)&dummy_cpu.cd.mips.vaddr_to_hostaddr_table0) - ((size_t)&dummy_cpu))  #define ofs_tabl0       (((size_t)&dummy_cpu.cd.mips.vaddr_to_hostaddr_table0) - ((size_t)&dummy_cpu))
65  #define ofs_chunks      ((size_t)&dummy_vth32_table.bintrans_chunks[0] - (size_t)&dummy_vth32_table)  #define ofs_chunks      ((size_t)&dummy_vth32_table.bintrans_chunks[0] - (size_t)&dummy_vth32_table)
66  #define ofs_chunkbase   ((size_t)&dummy_cpu.cd.mips.chunk_base_address - (size_t)&dummy_cpu)  #define ofs_chunkbase   ((size_t)&dummy_cpu.cd.mips.chunk_base_address - (size_t)&dummy_cpu)
67  #define ofs_h_l         (((size_t)&dummy_cpu.cd.mips.host_load) - ((size_t)&dummy_cpu))  #define ofs_h_l         (((size_t)&dummy_cpu.cd.mips.host_OLD_load) - ((size_t)&dummy_cpu))
68  #define ofs_h_s         (((size_t)&dummy_cpu.cd.mips.host_store) - ((size_t)&dummy_cpu))  #define ofs_h_s         (((size_t)&dummy_cpu.cd.mips.host_OLD_store) - ((size_t)&dummy_cpu))
69    
70    
71  static void (*bintrans_runchunk)(struct cpu *, unsigned char *);  static void (*bintrans_runchunk)(struct cpu *, unsigned char *);
# Line 1892  static int bintrans_write_instruction__l Line 1892  static int bintrans_write_instruction__l
1892                  *a++ = 0xc1; *a++ = 0xeb; *a++ = 0x0c;  /*  shr $12, %ebx   */                  *a++ = 0xc1; *a++ = 0xeb; *a++ = 0x0c;  /*  shr $12, %ebx   */
1893    
1894                  if (load) {                  if (load) {
1895                          /*  ecx = cpu->cd.mips.host_load  */                          /*  ecx = cpu->cd.mips.host_OLD_load  */
1896                          *a++ = 0x8b; *a++ = 0x8e; *a++ = ofs_h_l & 255;                          *a++ = 0x8b; *a++ = 0x8e; *a++ = ofs_h_l & 255;
1897                          *a++ = (ofs_h_l >> 8) & 255;                          *a++ = (ofs_h_l >> 8) & 255;
1898                          *a++ = (ofs_h_l >> 16) & 255; *a++ = (ofs_h_l >> 24) & 255;                          *a++ = (ofs_h_l >> 16) & 255; *a++ = (ofs_h_l >> 24) & 255;
1899                  } else {                  } else {
1900                          /*  ecx = cpu->cd.mips.host_store  */                          /*  ecx = cpu->cd.mips.host_OLD_store  */
1901                          *a++ = 0x8b; *a++ = 0x8e; *a++ = ofs_h_s & 255;                          *a++ = 0x8b; *a++ = 0x8e; *a++ = ofs_h_s & 255;
1902                          *a++ = (ofs_h_s >> 8) & 255;                          *a++ = (ofs_h_s >> 8) & 255;
1903                          *a++ = (ofs_h_s >> 16) & 255; *a++ = (ofs_h_s >> 24) & 255;                          *a++ = (ofs_h_s >> 16) & 255; *a++ = (ofs_h_s >> 24) & 255;
1904                  }                  }
1905    
1906                  /*  ecx = host_load[a] (or host_store[a])  */                  /*  ecx = host_OLD_load[a] (or host_OLD_store[a])  */
1907                  *a++ = 0x8b; *a++ = 0x0c; *a++ = 0x99;  /*  mov (%ecx,%ebx,4),%ecx  */                  *a++ = 0x8b; *a++ = 0x0c; *a++ = 0x99;  /*  mov (%ecx,%ebx,4),%ecx  */
1908    
1909                  /*                  /*
# Line 2697  static int bintrans_write_instruction__t Line 2697  static int bintrans_write_instruction__t
2697  /*  /*
2698   *  bintrans_backend_init():   *  bintrans_backend_init():
2699   *   *
2700   *  This is neccessary for broken GCC 2.x. (For GCC 3.x, this wouldn't be   *  This is necessary for broken GCC 2.x. (For GCC 3.x, this wouldn't be
2701   *  neccessary, and the old code would have worked.)   *  needed; the old code would have worked.)
2702   */   */
2703  static void bintrans_backend_init(void)  static void bintrans_backend_init(void)
2704  {  {
# Line 2897  static void bintrans_backend_init(void) Line 2897  static void bintrans_backend_init(void)
2897          *p++ = 0x89; *p++ = 0xc3;               /*  mov %eax, %ebx  */          *p++ = 0x89; *p++ = 0xc3;               /*  mov %eax, %ebx  */
2898          *p++ = 0xc1; *p++ = 0xeb; *p++ = 0x0c;  /*  shr $12, %ebx   */          *p++ = 0xc1; *p++ = 0xeb; *p++ = 0x0c;  /*  shr $12, %ebx   */
2899    
2900          /*  ecx = cpu->cd.mips.host_load  */          /*  ecx = cpu->cd.mips.host_OLD_load  */
2901          *p++ = 0x8b; *p++ = 0x8e; *p++ = ofs_h_l & 255;          *p++ = 0x8b; *p++ = 0x8e; *p++ = ofs_h_l & 255;
2902          *p++ = (ofs_h_l >> 8) & 255;          *p++ = (ofs_h_l >> 8) & 255;
2903          *p++ = (ofs_h_l >> 16) & 255; *p++ = (ofs_h_l >> 24) & 255;          *p++ = (ofs_h_l >> 16) & 255; *p++ = (ofs_h_l >> 24) & 255;
2904    
2905          /*  ecx = host_load[a]  */          /*  ecx = host_OLD_load[a]  */
2906          *p++ = 0x8b; *p++ = 0x0c; *p++ = 0x99;  /*  mov (%ecx,%ebx,4),%ecx  */          *p++ = 0x8b; *p++ = 0x0c; *p++ = 0x99;  /*  mov (%ecx,%ebx,4),%ecx  */
2907    
2908          /*  ret  */          /*  ret  */
# Line 2931  static void bintrans_backend_init(void) Line 2931  static void bintrans_backend_init(void)
2931          *p++ = 0x89; *p++ = 0xc3;               /*  mov %eax, %ebx  */          *p++ = 0x89; *p++ = 0xc3;               /*  mov %eax, %ebx  */
2932          *p++ = 0xc1; *p++ = 0xeb; *p++ = 0x0c;  /*  shr $12, %ebx   */          *p++ = 0xc1; *p++ = 0xeb; *p++ = 0x0c;  /*  shr $12, %ebx   */
2933    
2934          /*  ecx = cpu->cd.mips.host_store  */          /*  ecx = cpu->cd.mips.host_OLD_store  */
2935          *p++ = 0x8b; *p++ = 0x8e; *p++ = ofs_h_s & 255;          *p++ = 0x8b; *p++ = 0x8e; *p++ = ofs_h_s & 255;
2936          *p++ = (ofs_h_s >> 8) & 255;          *p++ = (ofs_h_s >> 8) & 255;
2937          *p++ = (ofs_h_s >> 16) & 255; *p++ = (ofs_h_s >> 24) & 255;          *p++ = (ofs_h_s >> 16) & 255; *p++ = (ofs_h_s >> 24) & 255;
2938    
2939          /*  ecx = host_store[a]  */          /*  ecx = host_OLD_store[a]  */
2940          *p++ = 0x8b; *p++ = 0x0c; *p++ = 0x99;  /*  mov (%ecx,%ebx,4),%ecx  */          *p++ = 0x8b; *p++ = 0x0c; *p++ = 0x99;  /*  mov (%ecx,%ebx,4),%ecx  */
2941    
2942          /*  ret  */          /*  ret  */

Legend:
Removed from v.21  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26