OXYGENHUB
◆ main enhanced-x16-emulator / src / cpu / registers.h
864 B · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
9120e874 Andy McCall 1
2
#ifndef _REGISTERS_H_
3
#define _REGISTERS_H_
4
5
#include <stdint.h>
6
#include <stdbool.h>
7
#include "../endian.h"
8
9
#define FLAG_CARRY     0x01
10
#define FLAG_ZERO      0x02
11
#define FLAG_INTERRUPT 0x04
12
#define FLAG_DECIMAL   0x08
13
#define FLAG_INDEX_WIDTH 0x10
14
#define FLAG_MEMORY_WIDTH  0x20
15
#define FLAG_OVERFLOW  0x40
16
#define FLAG_SIGN      0x80
17
18
// For 65C02
19
#define FLAG_BREAK FLAG_INDEX_WIDTH
20
#define FLAG_CONSTANT FLAG_MEMORY_WIDTH
21
22
//6502 CPU registers
23
24
struct regs
25
{
26
    LOW_HIGH_UNION(c, a, b);
27
    LOW_HIGH_UNION(x, xl, xh);
28
    LOW_HIGH_UNION(y, yl, yh);
29
30
    uint16_t dp;
31
    uint16_t sp;
32
33
    uint8_t db;
34
    uint16_t pc;
35
    uint8_t k;
36
37
    uint8_t status;
38
    uint8_t e;
39
40
    bool is65c816;
41
};
42
43
void increment_wrap_at_page_boundary(uint16_t *value);
44
void decrement_wrap_at_page_boundary(uint16_t *value);
45
uint16_t direct_page_add(uint16_t offset);
46
47
#endif