Add 6502 TXA instruction
This commit is contained in:
parent
53836cabe3
commit
e16a879527
|
@ -1,6 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include "6502.h"
|
||||
|
||||
void txa(FILE *outfile) {
|
||||
fwrite(TXA, 1, 1, outfile);
|
||||
}
|
||||
|
||||
void inx(FILE *outfile) {
|
||||
fwrite(INX, 1, 1, outfile);
|
||||
}
|
||||
|
@ -12,3 +16,4 @@ void iny(FILE *outfile) {
|
|||
void nop(FILE *outfile) {
|
||||
fwrite(NOP, 1, 1, outfile);
|
||||
}
|
||||
|
||||
|
|
14
src/6502.h
14
src/6502.h
|
@ -1,9 +1,23 @@
|
|||
#ifndef _6502_H
|
||||
#define _6502_H
|
||||
|
||||
#define TAX "\xAA"
|
||||
#define TAY "\xA8"
|
||||
#define TSX "\xBA"
|
||||
#define TXA "\x8A"
|
||||
#define TXS "\x9A"
|
||||
#define TYA "\x98"
|
||||
|
||||
#define INX "\xE8"
|
||||
#define INY "\xC8"
|
||||
|
||||
#define NOP "\xEA"
|
||||
|
||||
void txa(FILE *outfile);
|
||||
|
||||
void inx(FILE *outfile);
|
||||
void iny(FILE *outfile);
|
||||
|
||||
void nop(FILE *outfile);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,6 @@ all: main
|
|||
main:
|
||||
$(CC) $(CFLAGS) $(SRCFILES) -o $(OBJFILES)
|
||||
test:
|
||||
./gasm ../tests/test.asm ../tests/test.bin
|
||||
./gasm ../tests/test.asm -o ../tests/test.bin
|
||||
xxd ../tests/test.bin
|
||||
|
||||
|
|
|
@ -39,9 +39,11 @@ void parser(char lexed_buf[512][128][128], FILE *outfile) { // outfile is needed
|
|||
inx(outfile);
|
||||
} else if (!strcmp(lexed_buf[i][j], "INY")) {
|
||||
iny(outfile);
|
||||
} else if (!strcmp(lexed_buf[i][j], "TXA")) {
|
||||
txa(outfile);
|
||||
} else {
|
||||
printf("Unrecognized command: %s\n", lexed_buf[i][j]);
|
||||
break;
|
||||
printf("Unrecognized command: %s\n", lexed_buf[i][j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue