1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 01:31:33 +00:00

a02 assembler: fixed error in hexadecimal evaluation

This commit is contained in:
Curtis F Kaylor 2020-09-08 13:05:04 -04:00
parent 37b98c5d0b
commit 501944f525
2 changed files with 11 additions and 4 deletions

13
a02.c
View File

@ -67,8 +67,15 @@ void usage(char* appnam) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Print Error Dump Info */
void xdump(void) {
puts("Error Dump");
oprnd[opridx]=0; printf("Operand: %s\n", oprnd);
}
/* Print Error Message and Exit */ /* Print Error Message and Exit */
void xerror(char* format, char *s) { void xerror(char* format, char *s) {
if (debug) xdump();
if (lineno) fprintf(stderr, "%04d: ", lineno); if (lineno) fprintf(stderr, "%04d: ", lineno);
fprintf(stderr, format, s); fprintf(stderr, format, s);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -182,7 +189,7 @@ int evlbin() {
return result; return result;
} }
/* Evaluate Binary Number */ /* Evaluate Character Constant */
int evlchr() { int evlchr() {
int result = 0; int result = 0;
cpychr('\''); cpychr('\'');
@ -207,7 +214,7 @@ int evlhex() {
int result = 0; int result = 0;
cpychr('$'); cpychr('$');
while (isxdigit(*linptr)) { while (isxdigit(*linptr)) {
int digit = *linptr - '0'; int digit = toupper(*linptr) - '0';
if (digit > 9) digit = digit - 7; if (digit > 9) digit = digit - 7;
result = (result << 4) + digit; result = (result << 4) + digit;
cpychr(0); cpychr(0);
@ -333,7 +340,7 @@ void asmwrd(void) {
} while (cpychr(',')); } while (cpychr(','));
} }
/* Assemble FILL Pseudo-Op */ /* Assemble ALIGN Pseudo-Op */
void asmaln(void) { void asmaln(void) {
if (debug) puts("Assembling ALIGN Pseudo-Op"); if (debug) puts("Assembling ALIGN Pseudo-Op");
int size = evlopd(0xFFFF); if (size < 2) return; int size = evlopd(0xFFFF); if (size < 2) return;

2
a02.h
View File

@ -22,7 +22,7 @@
#define INDCY 0x0800 //(Indirect),Y #define INDCY 0x0800 //(Indirect),Y
#define RELTV 0x1000 //Relative #define RELTV 0x1000 //Relative
char zpgabs[][] = {"Absolute", "ZeroPage"}; char zpgabs[][9] = {"Absolute", "ZeroPage"};
struct amd {int amode; char desc[12];}; struct amd {int amode; char desc[12];};
struct amd amdesc[] = { struct amd amdesc[] = {