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
Copy file name to clipboardExpand all lines: src/as4.c
+153-5Lines changed: 153 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -59,13 +59,15 @@ int main(int argc, char **argv)
59
59
label*labels=NULL;
60
60
/* Pointer to the collection of referenced and potentially valid but undeclared labels */
61
61
label*unknownlabels=NULL;
62
-
62
+
/* If we are in a PINF, treat every unknown tuple as a pseudo instruction with a data field. */
63
+
unsigned charinpinf=0;
64
+
/* endptr is used to check if numbers are valid. */
65
+
char*endptr=NULL;
66
+
63
67
/* Check if a base address has been specified */
64
68
if(!strncmp(argv[1], "-b", 3))
65
69
{
66
-
/* We use this endptr to check if the input is valid */
67
70
/* strtoul sets this endptr to the address of the first invalid character - if that's equal to argv[2], the entire string was invalid. */
68
-
char*endptr=NULL;
69
71
70
72
/* If yes, out input and output arguments are two elements farther in the array so increment arg */
71
73
arg+=2;
@@ -226,6 +228,136 @@ int main(int argc, char **argv)
226
228
/* Add the instruction to the output buffer. */
227
229
addinst(outbuf, NOP, NOADDR, &bits, &bytes);
228
230
}
231
+
/* Start of the information section. Save as NOP with address 0xFFFF so the processor isn't bothered but we can tell later. */
232
+
elseif(!strncmp(tokens, "INF", 4))
233
+
{
234
+
/* ignore anything after INF on this line */
235
+
doneline=1;
236
+
/* Add this to the output buffer. */
237
+
addinst(outbuf, NOP, 0xFFFF, &bits, &bytes);
238
+
239
+
}
240
+
/* Start 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. */
241
+
elseif(!strncmp(tokens, "PINF", 5))
242
+
{
243
+
/* ignore anything after PINF on this line. */
244
+
doneline=1;
245
+
/* Within the PINF...EPINF section, treat all unknown tuples as psuedo-instructions with a data section. */
246
+
inpinf=1;
247
+
/* Add this to the output buffer */
248
+
addinst(outbuf, NOP, 0xFFFF, &bits, &bytes);
249
+
250
+
}
251
+
/* Record the base address into the executable. If the base address is specified externally, use that. */
252
+
elseif(!strncmp(tokens, "BADR", 5))
253
+
{
254
+
255
+
tokens=strtok(NULL, delims);
256
+
/* Check firstly that there is a valid label or address after the instruction. */
/* 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. */
277
+
elseif(!strncmp(tokens, "EPINF", 6))
278
+
{
279
+
/* ignore everything after EPINF on this line. */
280
+
doneline=1;
281
+
/* We're out of the PINF, actually ignore unknowns now. */
282
+
inpinf=0;
283
+
/* Add to the output buffer */
284
+
addinst(outbuf, NOP, 0xFFFF, &bits, &bytes);
285
+
286
+
}
287
+
/* Record the start of the data section. Allows easier disassembly. */
288
+
elseif(!strncmp(tokens, "DSEC", 5))
289
+
{
290
+
tokens=strtok(NULL, delims);
291
+
/* Check firstly that there is a valid label or address after the instruction. */
0 commit comments