4 * Ullrich von Bassewitz, 20.09.1998
14 /* Possible returns of getcpu() */
19 unsigned char getcpu (void);
20 /* Detect the CPU the program is running on */
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")
32 /* Struct that holds the registers for the sys function */
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 */
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 */
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
55 void __fastcall__ _sys (struct regs* r);
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.
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 */
73 typedef void (*brk_handler) (void);
74 /* Type of the break handler */
76 void __fastcall__ set_brk (brk_handler f);
77 /* Set the break vector to the given address, return the old address */
79 void reset_brk (void);
80 /* Reset the break vector to the original value */