You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* End of the program information section within the information section. Save as a NOP with address 0xFFFF so the processor isn't bothered but we can tell later. */
290
325
elseif(!strncmp(trimed, "EPINF", 6))
@@ -452,10 +487,23 @@ int main(int argc, char **argv)
452
487
/* A very niche but important instruction. */
453
488
elseif(!strncmp(trimed, "CXA", 4))
454
489
{
455
-
/* We only need to understand that it's the carry and XOR to accumulator instruction, we don't care about the rest of the line. */
456
-
doneline=1;
457
-
/* Add the instruction to the output buffer. */
458
-
addinst(outbuf, CXA, NOADDR, &bits, &bytes);
490
+
free(trimed);
491
+
/* Get the next token, which is likely a label (though it could be a number) */
492
+
tokens=strtok(NULL, delims);
493
+
trimed=trim(tokens);
494
+
/* Check firstly that there is a valid label or address after the instruction. */
/* Copy the contains of the label's name, up until the zero terminator (our calloc gave us an all zero string array, so any data copied in is automatically zero terminated). */
62
-
memcpy(tempstr, labelstr, (strlen(labelstr) -1));
62
+
strcpy(tempstr, labelstr);
63
+
/* Strip the trailing ":" */
64
+
for(i=0; i<strlen(tempstr); i++)
65
+
{
66
+
if(tempstr[i] ==':')
67
+
{
68
+
tempstr[i] ='\0';
69
+
break;
70
+
}
71
+
}
63
72
/* Before we commit to keeping this label, check if we've used the name already. */
64
73
/* Because using the same label for two different locations makes no sense. */
/* Check if the name of the unknown label is the same as the label that we just had declared. */
111
120
if(!strcmp((*unknownlabels)[i].str, tempstr))
112
121
{
113
-
114
122
/* If it is, then take stock of both the address it was referenced. If a label is referencing a label, we need to move 1 nibble back (as there is no instruction, just 4 nibbles). Cheaper than doing an if below. */
115
123
unsigned short intinstaddress= (*unknownlabels)[i].addr- ((*unknownlabels)[i].type&1);
116
124
/* And the address the label points to plus the requested offset. We need to add one nibble if it is an instruction referencing a nibble as we moved one back above. */
0 commit comments