summaryrefslogtreecommitdiff
path: root/igen/sux-igen/addr-modes.igen
blob: 3780ed21409e59207f91d0bca2ef9e3f292fe88f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "utils.igen"

%%

/*
am((abs|zm)[xy]?) {
	if (am == zmx || am == absx) {
		idx = cpu->x;
	} else if (am == zmy || am == absy) {
		idx = cpu->y;
	}

	if (am == abs || am == absx || am == absy) {
		is_abs = 1;
	}

	size = ((prefix & 0xC) >> 1) | is_abs;
	addr = read(cpu->pc, size) + idx;
	value = read(addr, rs);
}

am((a)?ind([xy])?) {
	if (am == indx || am == aindx) {
		idx = cpu->x;
		pre_idx = 1;
	} else if (am == indy || am == aindy) {
		idx = cpu->y;
	}

	if (am == aind || am == aindx || am == aindy) {
		is_abs = 1;
	}

	size = ((prefix & 0xC) >> 1) | is_abs;

	if (pre_idx) {
		addr = read(read(cpu->pc + idx, size), 7);
	} else {
		addr = read(read(cpu->pc, size), 7) + idx;
	}

	value = read(addr, rs);
}

am(eind) {
	addr = cpu->e;
	value = read(addr, rs);
}
*/

am(abs|zm([xy])?) {
	if (am == abs) {
		mem_type = ABS;
	} else {
		if (am == zmx) {
			idx = cpu->x;
		} else if (am == zmy) {
			idx = cpu->y;
		}
		mem_type = ZM;
	}
	addr = read_addr(prefix, mem_type) + idx;
	value = read(addr, rs);
}

am(ind([xy])?) {
	if (am == indx) {
		idx = cpu->x;
		pre_idx = 1;
	} else if (am == indy) {
		idx = cpu->y;
	}
	mem_type = ZM;
	addr = ind_idx_addr(prefix, mem_type, idx, pre_idx);
	value = read(addr, rs);
}

am(rel) {
	addr = rel_addr(prefix);
}

am(imm) {
	value = read(cpu->pc, rs);
	cpu->pc += rs+1;
}

am(breg) {
	value = cpu->b;
}

%%