home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / emulaton / at2600 / !v2600 / h / cpu < prev    next >
Text File  |  1997-03-24  |  4KB  |  188 lines

  1. /*****************************************************************************
  2.  
  3.    This file is part of x2600, the Atari 2600 Emulator
  4.    ===================================================
  5.    
  6.    Copyright 1996 Alex Hornby. For contributions see the file CREDITS.
  7.  
  8.    This software is distributed under the terms of the GNU General Public
  9.    License. This is free software with ABSOLUTELY NO WARRANTY.
  10.    
  11.    See the file COPYING for details.
  12.    
  13.    $Id: cpu.h,v 1.5 1996/04/01 14:51:50 alex Exp $
  14. ******************************************************************************/
  15. /*
  16.  *
  17.  * This file was part of x64.
  18.  *
  19.  * This file contains useful stuff when you are creating
  20.  * virtual machine like MCS6510 based microcomputer.
  21.  *
  22.  * Included are:
  23.  *    o registers
  24.  *    o flags in PSW
  25.  *      o addressing modes
  26.  *
  27.  * Written by
  28.  *   Vesa-Matti Puro (vmp@lut.fi)
  29.  *   Jarkko Sonninen (sonninen@lut.fi)
  30.  *   Jouko Valta (jopi@stekt.oulu.fi)
  31.  *
  32.  *
  33.  */
  34.  
  35. #ifndef X2600_CPU_H
  36. #define X2600_CPU_H
  37.  
  38.  
  39. #include "config.h"
  40. #include "types.h"
  41.  
  42. /* Initialise the CPU */
  43. void init_cpu(ADDRESS addr);
  44.  
  45. /* 6507 Registers. */
  46. #define AC        accumulator
  47. #define XR        x_register
  48. #define YR        y_register
  49. #define SP        stack_pointer
  50. #define PC        program_counter
  51. #define PCH        ((PC>>8)&0xff)
  52. #define PCL        (PC&0xff)
  53.  
  54. #define ZF        zero_flag
  55. #define SF        sign_flag
  56. #define OF        overflow_flag
  57. #define BF        break_flag
  58. #define DF        decimal_flag
  59. #define IF        interrupt_flag
  60. #define CF        carry_flag
  61.  
  62.  
  63. /* Masks which indicate location of status flags in PSW. */
  64. #define S_SIGN        0x80
  65. #define S_OVERFLOW    0x40
  66. #define S_NOTUSED     0x20
  67. #define S_BREAK        0x10
  68. #define S_DECIMAL    0x08
  69. #define S_INTERRUPT    0x04
  70. #define S_ZERO        0x02
  71. #define S_CARRY        0x01
  72.  
  73.  
  74. /* ADDRESSING MODES */
  75.  
  76. #define IMPLIED        0
  77. #define ACCUMULATOR    1
  78. #define IMMEDIATE    2
  79.  
  80. #define ZERO_PAGE    3
  81. #define ZERO_PAGE_X    4
  82. #define ZERO_PAGE_Y    5
  83.  
  84. #define ABSOLUTE    6
  85. #define ABSOLUTE_X    7
  86. #define ABSOLUTE_Y    8
  87.  
  88. #define ABS_INDIRECT    9
  89. #define INDIRECT_X    10
  90. #define INDIRECT_Y    11
  91.  
  92. #define RELATIVE    12
  93.  
  94. #define ASS_CODE    13
  95.  
  96.  
  97. /*
  98.  * Declaration for lookup-table which is used to translate MOS6502
  99.  * machine instructions. Machine code is used as index to array called
  100.  * lookup. Pointer to function is then fetched from array and function
  101.  * is called.
  102.  */
  103.  
  104. extern struct lookup_tag {
  105.     char          *mnemonic;    /* Selfdocumenting? */
  106.     short          addr_mode;
  107.     unsigned char  source;
  108.     unsigned char  destination;
  109.     unsigned char  cycles;
  110.     unsigned char  pbc_fix;    /* Cycle for Page Boundary Crossing */
  111. }       lookup[];
  112.  
  113.  
  114. /* Addressing mode (addr_mode) is used when instruction is diassembled
  115.  * or assembled by diassembler or assembler. This is used i.e.
  116.  * in function char *sprint_opcode() in the file misc.c.
  117.  *
  118.  * MOS6502 addressing modes are #defined in the file "vmachine.h".
  119.  *
  120.  * Mnemonic is character string telling the name of the instruction.
  121.  */
  122.  
  123. #define M_NONE    0
  124. #define M_AC     1
  125. #define M_XR    2
  126. #define M_YR    3
  127. #define M_SP    4
  128. #define M_SR    5
  129. #define M_PC    6
  130. #define M_IMM    7
  131. #define M_ZERO    8
  132. #define M_ZERX    9
  133. #define M_ZERY    10
  134. #define M_ABS    11
  135. #define M_ABSX    12
  136. #define M_ABSY    13
  137. #define M_AIND    14
  138. #define M_INDX    15
  139. #define M_INDY    16
  140. #define M_REL    17
  141. #define M_FC    18
  142. #define M_FD    19
  143. #define M_FI    20
  144. #define M_FV    21
  145. #define M_ADDR    22
  146. #define M_    23
  147.  
  148. #ifndef NO_UNDOC_CMDS
  149. #define M_ACIM    24    /* Source: AC & IMMED (bus collision) */
  150. #define M_ANXR    25    /* Source: AC & XR (bus collision) */
  151. #define M_AXIM    26    /* Source: (AC | #EE) & XR & IMMED (bus collision) */
  152. #define M_ACNC    27    /* Dest: M_AC and Carry = Negative */
  153. #define M_ACXR    28    /* Dest: M_AC, M_XR */
  154.  
  155. #define M_SABY    29    /* Source: (ABS_Y & SP) (bus collision) */
  156. #define M_ACXS    30    /* Dest: M_AC, M_XR, M_SP */
  157. #define M_STH0    31    /* Dest: Store (src & Addr_Hi+1) to (Addr +0x100) */
  158. #define M_STH1    32
  159. #define M_STH2    33
  160. #define M_STH3    34
  161.  
  162. #else
  163. #define M_ACIM    M_NONE
  164. #define M_ANXR    M_NONE
  165. #define M_AXIM    M_NONE
  166. #define M_ACNC    M_NONE
  167. #define M_ACXR    M_NONE
  168.  
  169. #define M_SABY    M_NONE
  170. #define M_ACXS    M_NONE
  171. #define M_STH0    M_NONE
  172. #define M_STH1    M_NONE
  173. #define M_STH2    M_NONE
  174. #define M_STH3    M_NONE
  175. #endif
  176.  
  177.  
  178.  
  179. #endif  /* X2600_CPU_H */
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.