summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-11-11 13:27:17 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2019-11-11 13:27:17 -0500
commit03cf68ff44084f76de7eae2fe93731312f493eb7 (patch)
treef07c799db6beafa197f2ee9f906a3987e055d303 /sux.c
parent1a8c15676cc6aea4a5527d729489e523816cae04 (diff)
Added comments in opcode.h, and started work on the
Sux emulator.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sux.c b/sux.c
new file mode 100644
index 0000000..4e64277
--- /dev/null
+++ b/sux.c
@@ -0,0 +1,31 @@
+#include <limits.h>
+#include "opcode.h"
+#include <stdint.h>
+uint64_t a; /* Accumulator. */
+uint64_t y; /* Y index. */
+uint64_t x; /* X index. */
+uint64_t ps; /* Processor status. */
+
+uint64_t alu(uint8_t opcode, uint64_t value) {
+ uint64_t sum;
+ uint8_t carry, vf;
+ switch(opcode) {
+ /* Add with carry. */
+ case ADC:
+ sum = a+value+carry;
+ vf = (~(a^value) & (a^sum & 0x80));
+ carry = (sum < value) ? 1 : 0;
+ a |= sum;
+ break;
+ /* Subtract with carry. */
+ case SBC:
+ sum = a-value-!carry
+ vf = (a^value) & (a^sum) & 0x80;
+ carry = (sum > value) ? 1 : 0;
+ a |= sum;
+ break;
+
+
+
+ }
+}