mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-28 10:51:14 +00:00
a02.c02 - Debugged fndsym() and evlsym()
This commit is contained in:
parent
b2820d2549
commit
847ea78c3f
67
apps/a02.c02
67
apps/a02.c02
@ -67,8 +67,7 @@ int v, w;
|
|||||||
|
|
||||||
/* Function Variables */
|
/* Function Variables */
|
||||||
char found, match, opcode, opdfnd; //lookup(), asmpso(), asmopc()
|
char found, match, opcode, opdfnd; //lookup(), asmpso(), asmopc()
|
||||||
int addr; //fndsym()
|
int opdval; //evlopd() values
|
||||||
int opdval; //evlopd() values
|
|
||||||
char hilo, opdrqd, prns, reqbyt, result; //evlopd() flags
|
char hilo, opdrqd, prns, reqbyt, result; //evlopd() flags
|
||||||
int addend; //adrslt()
|
int addend; //adrslt()
|
||||||
char digit; //evlhex()
|
char digit; //evlhex()
|
||||||
@ -126,7 +125,7 @@ int lstadr; //List Address
|
|||||||
/* Print Error Message and Exit *
|
/* Print Error Message and Exit *
|
||||||
* Args: Y,X = Address of Eror Message */
|
* Args: Y,X = Address of Eror Message */
|
||||||
void error() {
|
void error() {
|
||||||
putstr(); putln(" ERROR");
|
putc('!'); putstr(); putln(" ERROR");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,37 +253,36 @@ void prtsym() {
|
|||||||
printf("%nSYMBOLS%nBLK SZ VALUE NAME%n");
|
printf("%nSYMBOLS%nBLK SZ VALUE NAME%n");
|
||||||
usrptr = &symtbl;
|
usrptr = &symtbl;
|
||||||
iacc(symptr); //end of symbol table for icmp()
|
iacc(symptr); //end of symbol table for icmp()
|
||||||
puts(">PRTSYM: LISTING FROM $");putwrd(usrptr);
|
|
||||||
puts(" TO $"); putwrd(intacc); newlin();
|
|
||||||
//for (j=0; j<9; j++) {
|
|
||||||
while (icmp(iacc(usrptr),symptr):-) {
|
while (icmp(iacc(usrptr),symptr):-) {
|
||||||
//iacc(usrptr); putdec(icmp(symptr));newlin();
|
|
||||||
for (i=0; i<@symbol; i++) {symbol[i] = *usrptr; usrptr++;}
|
for (i=0; i<@symbol; i++) {symbol[i] = *usrptr; usrptr++;}
|
||||||
putder(symbol.block);
|
putder(symbol.block); setdst(symbol.value); printf(symbol.bytes," %d %J ");
|
||||||
setdst(symbol.value); printf(symbol.bytes," %d %J ");
|
if (symbol.block) putchr('.'); putln(symbol.name);
|
||||||
putln(symbol.name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Find Symbol in Table *
|
/* Find Symbol in Table *
|
||||||
* Args: n = Number of Symbols in Table *
|
|
||||||
* s = Address of Table *
|
|
||||||
* Uses: word = Symbol Name *
|
* Uses: word = Symbol Name *
|
||||||
* Sets: srcptr = Address of Entry *
|
* local = Local Symbol Flag *
|
||||||
* varble = Contents of Entry *
|
* blknum = Subroutine Block # *
|
||||||
* Destroys: dstptr *
|
* Sets: varble = Contents of Entry *
|
||||||
|
* Destroys: b, dstptr *
|
||||||
* Returns: TRUE if Symbol was Found */
|
* Returns: TRUE if Symbol was Found */
|
||||||
char fndsym(n, addr) {
|
char fndsym() {
|
||||||
if (#DEBUG&4) {putstr("#SYMBOL "); putstr(word);}
|
if (#DEBUG&4) printf(setdst(local,word),"FNDSYM: WORD=\"%S\", LOCAL=%d - ");
|
||||||
setdst(word); setsrc(addr);
|
b = (local) ? blknum : 0; //Block level to match
|
||||||
for (i=0; i<n; i++) {
|
setdst(word); //For strcmp
|
||||||
if (strcms(word)) {addsra(@varble); continue;}
|
usrptr = &symtbl;
|
||||||
setdst(varble); memcpy(@varble);
|
iacc(symptr); //end of symbol table for icmp()
|
||||||
if (#DEBUG&4) prtlin(" FOUND ");
|
while (icmp(iacc(usrptr),symptr):-) {
|
||||||
|
varble.block = *usrptr;
|
||||||
|
if (varble.block <> b) {usrptr = iaddc(@varble,usrptr); continue;}
|
||||||
|
usrptr++; if (strcmp(usrptr)) {usrptr = iaddc(@varble-1,usrptr); continue;}
|
||||||
|
for (i=1; i<@varble; i++) {varble[i] = *usrptr; usrptr++;}
|
||||||
|
if (#DEBUG&4) putln("FOUND");
|
||||||
return #TRUE;
|
return #TRUE;
|
||||||
}
|
}
|
||||||
if (#DEBUG&4) prtlin(" NOT FOUND ");
|
if (#DEBUG&4) putln("NOT FOUND");
|
||||||
return #FALSE;
|
return #FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +412,7 @@ int evlhex() {
|
|||||||
* Returns: #TRUE if a term was found */
|
* Returns: #TRUE if a term was found */
|
||||||
char evltrm() {
|
char evltrm() {
|
||||||
skpspc();
|
skpspc();
|
||||||
if (isalph(inplin[inpidx]) or inplin[inpidx] == '.') {
|
if (isalud(inplin[inpidx])) {
|
||||||
if (evlsym()) term = symbol.value; else term = &$0100;
|
if (evlsym()) term = symbol.value; else term = &$0100;
|
||||||
}
|
}
|
||||||
else if (isdigt(inplin[inpidx]))
|
else if (isdigt(inplin[inpidx]))
|
||||||
@ -436,7 +434,7 @@ char evlsym() {
|
|||||||
for (i=0; i<wrdlen; i++) {
|
for (i=0; i<wrdlen; i++) {
|
||||||
if (opridx:+) {oprnd[opridx] = word[i]; opridx++;}
|
if (opridx:+) {oprnd[opridx] = word[i]; opridx++;}
|
||||||
}
|
}
|
||||||
else found = fndsym(&symtbl);
|
else found = fndsym();
|
||||||
if (found) opdval = symbol.value;
|
if (found) opdval = symbol.value;
|
||||||
else error("UNDEFINED SYMBOL");
|
else error("UNDEFINED SYMBOL");
|
||||||
}
|
}
|
||||||
@ -698,12 +696,22 @@ void tlabel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Test function evltrm
|
//Test function evltrm
|
||||||
void tevtrm() {
|
void tterm() {
|
||||||
setln();
|
setln();
|
||||||
if (evltrm()) printf(setdst(term)," TERM=%i%n");
|
if (evltrm()) printf(setdst(term)," TERM=%i%n");
|
||||||
else putln("NO TERM FOUND");
|
else putln("NO TERM FOUND");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Test find symbol
|
||||||
|
void tfind(local, tmpptr) {
|
||||||
|
setdst(word); strcpy(tmpptr);
|
||||||
|
//found = fndsym(); putdel(found);
|
||||||
|
if (fndsym()) {
|
||||||
|
setdst(varble.name); printf(varble.block, " VARBLE.BLOCK=%d, NAME=\"%s\", ");
|
||||||
|
setdst(varble.value); printf(varble.bytes,"BYTES=%d, VALUE=%i%n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tmnmnc() {
|
void tmnmnc() {
|
||||||
setln();
|
setln();
|
||||||
pmnmnc();
|
pmnmnc();
|
||||||
@ -713,8 +721,11 @@ void tmnmnc() {
|
|||||||
tests:
|
tests:
|
||||||
orgadr = &$0300; orgset = #TRUE;
|
orgadr = &$0300; orgset = #TRUE;
|
||||||
curadr = orgadr;
|
curadr = orgadr;
|
||||||
tlabel("FEE "); tlabel(".FI "); tlabel("FOE: "); tlabel(".FUM: ");
|
tlabel("GLOBAL"); tlabel(".LOCAL"); tlabel("GLOBC:"); tlabel(".LOCC:");
|
||||||
tevtrm(" 12345"); tevtrm("%10101"); tevtrm("$1001 ");
|
tterm(" 123"); tterm(" $FF "); tterm("%10101010");
|
||||||
|
tterm(" 4567"); tterm("$1001 "); tterm("%1010101001010101");
|
||||||
|
tfind(0,"LOCAL"); tfind('.',"GLOBAL"); tfind(0,"LOCC"); tfind('.',"GLOBC");
|
||||||
|
tterm("GLOBAL"); tterm(".LOCAL"); tterm(" GLOBC"); tterm(" .LOCC");
|
||||||
prtsym();
|
prtsym();
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user