]> git.sur5r.net Git - cc65/blob - include/6502.h
Added/updated header blocks
[cc65] / include / 6502.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  6502.h                                   */
4 /*                                                                           */
5 /*                        6502 specific declarations                         */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2001 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
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 /* Possible returns of getcpu() */
42 #define CPU_6502        0
43 #define CPU_65C02       1
44 #define CPU_65816       2
45
46 unsigned char getcpu (void);
47 /* Detect the CPU the program is running on */
48
49
50
51 /* Macros for CPU instructions */
52 #define BRK()   __asm__ ("\tbrk")
53 #define CLI()   __asm__ ("\tcli")
54 #define SEI()   __asm__ ("\tsei")
55
56
57
58 /* Struct that holds the registers for the sys function */
59 struct regs {
60     unsigned char a;            /* A register value */
61     unsigned char x;            /* X register value */
62     unsigned char y;            /* Y register value */
63     unsigned char flags;        /* Flags value */
64     unsigned      pc;           /* Program counter */
65 };
66
67 /* Defines for the flags in the regs structure */
68 #define F_NEG           0x80    /* N flag */
69 #define F_OVF           0x40    /* V flag */
70 #define F_BRK           0x10    /* B flag */
71 #define F_DEC           0x08    /* D flag */
72 #define F_IEN           0x04    /* I flag */
73 #define F_ZERO          0x02    /* Z flag */
74 #define F_CARRY         0x01    /* C flag */
75
76 /* Function to call any machine language subroutine. All registers in the
77  * regs structure are passed into the routine and the results are passed
78  * out. Some of the flags are ignored on input. The called routine must
79  * end with an RTS.
80  */
81 void __fastcall__ _sys (struct regs* r);
82
83
84
85 /* Set and reset the break vector. The given user function is called if
86  * a break occurs. The values of the registers may be read from the brk_...
87  * variables. The value in brk_pc will point to the address that contains
88  * the brk instruction.
89  * The set_brk function will install an exit handler that will reset the
90  * vector if the program ends.
91  */
92
93 extern unsigned char brk_a;     /* A register value */
94 extern unsigned char brk_x;     /* X register value */
95 extern unsigned char brk_y;     /* Y register value */
96 extern unsigned char brk_sr;    /* Status register */
97 extern unsigned brk_pc;         /* PC value */
98
99 typedef void (*brk_handler) (void);
100 /* Type of the break handler */
101
102 void __fastcall__ set_brk (brk_handler f);
103 /* Set the break vector to the given address, return the old address */
104
105 void reset_brk (void);
106 /* Reset the break vector to the original value */
107
108
109
110 /* End of 6502.h */
111 #endif
112
113
114