]> git.sur5r.net Git - cc65/blob - include/6502.h
getfd.o: new object file
[cc65] / include / 6502.h
1 /*
2  * 6502.h
3  *
4  * Ullrich von Bassewitz, 20.09.1998
5  */
6
7
8
9 #ifndef _6502_H
10 #define _6502_H
11
12
13
14 /* Possible returns of getcpu() */
15 #define CPU_6502        0
16 #define CPU_65C02       1
17 #define CPU_65816       2
18
19 unsigned char getcpu (void);
20 /* Detect the CPU the program is running on */
21
22
23
24 /* Macros for CPU instructions */
25 #define BRK()   __asm__ ("\tbrk")
26 #define CLI()   __asm__ ("\tcli")
27 #define SEI()   __asm__ ("\tsei")
28 #define JAM()   __asm__ ("\t.byte\t$02")
29
30
31
32 /* Struct that holds the registers for the sys function */
33 struct regs {
34     unsigned char a;            /* A register value */
35     unsigned char x;            /* X register value */
36     unsigned char y;            /* Y register value */
37     unsigned char flags;        /* Flags value */
38     unsigned      pc;           /* Program counter */
39 };
40
41 /* Defines for the flags in the regs structure */
42 #define F_NEG           0x80    /* N flag */
43 #define F_OVF           0x40    /* V flag */
44 #define F_BRK           0x10    /* B flag */
45 #define F_DEC           0x08    /* D flag */
46 #define F_IEN           0x04    /* I flag */
47 #define F_ZERO          0x02    /* Z flag */
48 #define F_CARRY         0x01    /* C flag */
49
50 /* Function to call any machine language subroutine. All registers in the
51  * regs structure are passed into the routine and the results are passed
52  * out. Some of the flags are ignored on input. The called routine must
53  * end with an RTS.
54  */
55 void __fastcall__ _sys (struct regs* r);
56
57
58
59 /* Set and reset the break vector. The given user function is called if
60  * a break occurs. The values of the registers may be read from the brk_...
61  * variables. The value in brk_pc will point to the address that contains
62  * the brk instruction.
63  * The set_brk function will install an exit handler that will reset the
64  * vector if the program ends.
65  */
66
67 extern unsigned char brk_a;     /* A register value */
68 extern unsigned char brk_x;     /* X register value */
69 extern unsigned char brk_y;     /* Y register value */
70 extern unsigned char brk_sr;    /* Status register */
71 extern unsigned brk_pc;         /* PC value */
72
73 typedef void (*brk_handler) (void);
74 /* Type of the break handler */
75
76 void __fastcall__ set_brk (brk_handler f);
77 /* Set the break vector to the given address, return the old address */
78
79 void reset_brk (void);
80 /* Reset the break vector to the original value */
81
82
83
84 /* End of 6502.h */
85 #endif
86
87
88