1 /*****************************************************************************/
5 /* 6502 specific declarations */
9 /* (C) 1998-2012, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
44 typedef unsigned size_t;
49 /* Possible returns of getcpu() */
54 unsigned char getcpu (void);
55 /* Detect the CPU the program is running on */
59 /* Macros for CPU instructions */
60 #define BRK() __asm__ ("brk")
61 #define CLI() __asm__ ("cli")
62 #define SEI() __asm__ ("sei")
66 /* Struct that holds the registers for the sys function */
68 unsigned char a; /* A register value */
69 unsigned char x; /* X register value */
70 unsigned char y; /* Y register value */
71 unsigned char flags; /* Flags value */
72 unsigned pc; /* Program counter */
75 /* Defines for the flags in the regs structure */
76 #define F6502_N 0x80 /* N flag */
77 #define F6502_V 0x40 /* V flag */
78 #define F6502_B 0x10 /* B flag */
79 #define F6502_D 0x08 /* D flag */
80 #define F6502_I 0x04 /* I flag */
81 #define F6502_Z 0x02 /* Z flag */
82 #define F6502_C 0x01 /* C flag */
84 /* Function to call any machine language subroutine. All registers in the
85 * regs structure are passed into the routine and the results are passed
86 * out. The B flag is ignored on input. The called routine must end with
89 void __fastcall__ _sys (struct regs* r);
93 /* Set and reset the break vector. The given user function is called if
94 * a break occurs. The values of the registers may be read from the brk_...
95 * variables. The value in brk_pc will point to the address that contains
96 * the brk instruction.
97 * The set_brk function will install an exit handler that will reset the
98 * vector if the program ends.
101 extern unsigned char brk_a; /* A register value */
102 extern unsigned char brk_x; /* X register value */
103 extern unsigned char brk_y; /* Y register value */
104 extern unsigned char brk_sr; /* Status register */
105 extern unsigned brk_pc; /* PC value */
107 typedef void (*brk_handler) (void);
108 /* Type of the break handler */
110 void __fastcall__ set_brk (brk_handler f);
111 /* Set the break vector to the given address */
113 void reset_brk (void);
114 /* Reset the break vector to the original value */
118 /* Possible returns for irq_handler() */
119 #define IRQ_NOT_HANDLED 0
120 #define IRQ_HANDLED 1
122 typedef unsigned char (*irq_handler) (void);
123 /* Type of the C level interrupt request handler */
125 void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);
126 /* Set the C level interrupt request vector to the given address */
128 void reset_irq (void);
129 /* Reset the C level interrupt request vector */