/
storeOpcodes.c
181 lines (148 loc) · 5.56 KB
/
storeOpcodes.c
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/**
* toyemu - 6502 CPU emulator
* Copyright (C) 2012-2013 Dakota Edgerton
* mail: dedgerton97@gmail.com
*
* This file is part of toyemu.
*
* toyemu is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* toyemu is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with toyemu. If not, see <http://www.gnu.org/licenses/>.
*/
#include "storeOpcodes.h"
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////STA opcodes//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void opcode0x85(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x85Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1], accu); // Load the value at memory address [OPERAND] into accumulator
pcnt += 2;
return;
}
void opcode0x95(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x95Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1] + xreg, accu);
pcnt += 2;
return;
}
void opcode0x8D(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x8DEncountered, opcodeEncEnd);
uint16_t memoryAddress = (data[1] << 8) | data[2];
printf("OP_PARSE: Operand is 0x%04X\n", memoryAddress);
writeMemory(memoryAddress, accu);
pcnt += 3;
return;
}
void opcode0x9D(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x9DEncountered, opcodeEncEnd);
uint16_t memoryAddress = (data[1] << 8) | data[2];
printf("OP_PARSE: Operand is 0x%04X\n", memoryAddress);
writeMemory(memoryAddress + xreg, accu);
pcnt += 3;
return;
}
void opcode0x99(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x99Encountered, opcodeEncEnd);
uint16_t memoryAddress = (data[1] << 8) | data[2];
printf("OP_PARSE: Operand is 0x%04X\n", memoryAddress);
writeMemory(memoryAddress + yreg, accu);
pcnt += 3;
return;
}
void opcode0x81(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x81Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1] + xreg, accu);
pcnt += 2;
return;
}
void opcode0x91(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x91Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory((data[1]) + yreg, accu);
pcnt += 2;
return;
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////end STA opcodes//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////STX opcodes//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void opcode0x86(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x86Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1], xreg); // Load the value at memory address [OPERAND] into accumulator
pcnt += 2;
return;
}
void opcode0x96(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x96Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1] + yreg, xreg);
pcnt += 2;
return;
}
void opcode0x8E(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x8EEncountered, opcodeEncEnd);
uint16_t memoryAddress = (data[1] << 8) | data[2];
printf("OP_PARSE: Operand is 0x%04X\n", memoryAddress);
writeMemory(memoryAddress, xreg);
pcnt += 3;
return;
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////end STX opcodes//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////STY opcodes//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void opcode0x84(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x84Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1], yreg);
pcnt += 2;
return;
}
void opcode0x94(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x94Encountered, opcodeEncEnd);
printf("OP_PARSE: Operand is 0x%02X\n", data[1]);
writeMemory(data[1] + xreg, yreg);
pcnt += 2;
return;
}
void opcode0x8C(uint8_t* data)
{
printf("%s%s%s", opcodeEncStart, opcode0x8CEncountered, opcodeEncEnd);
uint16_t memoryAddress = (data[1] << 8) | data[2];
printf("OP_PARSE: Operand is 0x%04X\n", memoryAddress);
writeMemory(memoryAddress, yreg);
pcnt += 3;
return;
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////end STY opcodes//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////