From 1b061ec0339afc5f1a2d64c98ac4065b4c6a9b32 Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Fri, 15 Nov 2019 14:30:43 -0500 Subject: [PATCH] Added A02 Assembler to Makefile --- Makefile | 3 ++- a02.c | 34 +++++++++++++++++----------------- c02.ppj | 10 +++++++--- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index df189d1..a3dda15 100644 --- a/Makefile +++ b/Makefile @@ -4,5 +4,6 @@ mainfile=src/c02.c outfile=c02 c02: ${incfiles} ${mainfile} gcc ${gccopts} ${incfiles} ${mainfile} -o ${outfile} + gcc ${gccopts} a02.h a02.c -o a02 clean: - rm ${outfile} + rm ${outfile} a02 diff --git a/a02.c b/a02.c index a188ebd..a471ea5 100644 --- a/a02.c +++ b/a02.c @@ -284,6 +284,21 @@ void outwrd(int w) { outbyt(w >> 8); } +/* Lookup Opcode */ +int lkpopc(struct opc opl[]) { + if (DEBUG) printf("Looking up Mnemonic %s\n", mnmnc); + token = 0xFF; //Set Token to Invalid + char mne[5]; strncpy(mne, mnmnc, 4); mne[4] = 0; //Truncate Mnemonic to Four Characters + for (int i=0; opl[i].name[0]; i++) { + if (strcmp(opl[i].name, mne)) continue; + token = opl[i].token; + amode = opl[i].amode; + if (DEBUG) printf("Found token %02X, amode %04X\n", token, amode); + return TRUE; + } + return FALSE; +} + /* Assemble BYTE Pseudo-Op */ void asmbyt(void) { if (DEBUG) puts("Assembling BYTE Pseudo-Op"); @@ -405,21 +420,6 @@ int asmpso(int dot) { return TRUE; } -/* Lookup Opcode */ -int lkpopc(struct opc opl[]) { - if (DEBUG) printf("Looking up Mnemonic %s\n", mnmnc); - token = 0xFF; //Set Token to Invalid - char mne[5]; strncpy(mne, mnmnc, 4); mne[4] = 0; //Truncate Mnemonic to Four Characters - for (int i=0; opl[i].name[0]; i++) { - if (strcmp(opl[i].name, mne)) continue; - token = opl[i].token; - amode = opl[i].amode; - if (DEBUG) printf("Found token %02X, amode %04X\n", token, amode); - return TRUE; - } - return FALSE; -} - /* Check for Valid Addressing Mode */ int chkmod(int mode) { char* s = NULL; //Pointer to Addressing Mode Description @@ -513,9 +513,9 @@ void dbgopc(void) { case 0x11: puts("(Indirect)"); break; case 0x04: puts("ZeroPage"); break; case 0x0C: puts("Absolute"); break; - case 0x14: puts("ZeroPage,X"); break; + case 0x14: if ((token == 0x82 || token == 0xA2)) puts("ZeroPage,Y"); + else puts("ZeroPage,X"); break; case 0x1C: puts("Absolute,X"); break; - case 0x14: puts("ZeroPage,Y"); break; case 0x18: puts("Absolute,Y"); break; default: puts("UNKOWN"); } diff --git a/c02.ppj b/c02.ppj index f45d1dd..a2c03e5 100644 --- a/c02.ppj +++ b/c02.ppj @@ -8,7 +8,7 @@ POC_PROJECT_TYPE = 13# POC_PROJECT_OUTPUTDIR = output# POC_PROJECT_RESULTDIR = .# POC_PROJECT_ARGUMENTS = # -POC_PROJECT_WORKPATH = .# +POC_PROJECT_WORKPATH = src# POC_PROJECT_EXECUTOR = # POC_PROJECT_ZIPEXTRA = # CC = pocc.exe# @@ -153,8 +153,10 @@ output\label.obj: \ src\label.c \ src\asm.h \ src\common.h \ + src\files.h \ src\label.h \ - src\parse.h + src\parse.h \ + src\vars.h $(CC) $(CCFLAGS) "$!" -Fo"$@" # @@ -164,9 +166,11 @@ output\parse.obj: \ src\parse.c \ src\asm.h \ src\common.h \ + src\expr.h \ src\files.h \ src\label.h \ - src\parse.h + src\parse.h \ + src\stmnt.h $(CC) $(CCFLAGS) "$!" -Fo"$@" #