]> git.sur5r.net Git - cc65/blob - include/6502.h
Fixed gcc compiler warning (#867)
[cc65] / include / 6502.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  6502.h                                   */
4 /*                                                                           */
5 /*                        6502 specific declarations                         */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2012, Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _6502_H
37 #define _6502_H
38
39
40
41 /* We need size_t */
42 #ifndef _HAVE_size_t
43 #define _HAVE_size_t
44 typedef unsigned size_t;
45 #endif
46
47
48
49 /* Possible returns of getcpu() */
50 #define CPU_6502        0
51 #define CPU_65C02       1
52 #define CPU_65816       2
53 #define CPU_4510        3
54 #define CPU_65SC02      4
55 #define CPU_65CE02      5
56 #define CPU_HUC6280     6
57 #define CPU_2A0x        7
58 #define CPU_45GS02      8
59
60 unsigned char getcpu (void);
61 /* Detect the CPU the program is running on */
62
63
64
65 /* Macros for CPU instructions */
66 #define BRK()   __asm__ ("brk")
67 #define CLI()   __asm__ ("cli")
68 #define SEI()   __asm__ ("sei")
69
70
71
72 /* Struct that holds the registers for the sys function */
73 struct regs {
74     unsigned char a;            /* A register value */
75     unsigned char x;            /* X register value */
76     unsigned char y;            /* Y register value */
77     unsigned char flags;        /* Flags value */
78     unsigned      pc;           /* Program counter */
79 };
80
81 /* Defines for the flags in the regs structure */
82 #define F6502_N         0x80    /* N flag */
83 #define F6502_V         0x40    /* V flag */
84 #define F6502_B         0x10    /* B flag */
85 #define F6502_D         0x08    /* D flag */
86 #define F6502_I         0x04    /* I flag */
87 #define F6502_Z         0x02    /* Z flag */
88 #define F6502_C         0x01    /* C flag */
89
90 /* Function to call any machine language subroutine. All registers in the
91 ** regs structure are passed into the routine and the results are passed
92 ** out. The B flag is ignored on input. The called routine must end with
93 ** an RTS.
94 */
95 void __fastcall__ _sys (struct regs* r);
96
97
98
99 /* Set and reset the break vector. The given user function is called if
100 ** a break occurs. The values of the registers may be read from the brk_...
101 ** variables. The value in brk_pc will point to the address that contains
102 ** the brk instruction.
103 ** The set_brk function will install an exit handler that will reset the
104 ** vector if the program ends.
105 */
106
107 extern unsigned char brk_a;     /* A register value */
108 extern unsigned char brk_x;     /* X register value */
109 extern unsigned char brk_y;     /* Y register value */
110 extern unsigned char brk_sr;    /* Status register */
111 extern unsigned brk_pc;         /* PC value */
112
113 typedef void (*brk_handler) (void);
114 /* Type of the break handler */
115
116 void __fastcall__ set_brk (brk_handler f);
117 /* Set the break vector to the given address */
118
119 void reset_brk (void);
120 /* Reset the break vector to the original value */
121
122
123
124 /* Possible returns for irq_handler() */
125 #define IRQ_NOT_HANDLED 0
126 #define IRQ_HANDLED     1
127
128 typedef unsigned char (*irq_handler) (void);
129 /* Type of the C level interrupt request handler */
130
131 void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);
132 /* Set the C level interrupt request vector to the given address */
133
134 void reset_irq (void);
135 /* Reset the C level interrupt request vector */
136
137
138
139 /* End of 6502.h */
140 #endif