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
/* The address it was referenced at is actually the opcode of the instruction, so go up one nibble to point to the address section. */
@@ -199,6 +199,11 @@ unsigned short int findlabel(label **unknownlabels, label **labels, char *labels
199
199
fprintf(stderr, "findlabel: Type can only be 0 or 1\n");
200
200
exit(33);
201
201
}
202
+
if(labelstr==NULL)
203
+
{
204
+
fprintf(stderr, "findlabel: labelstr cannot be null!\n");
205
+
exit(34);
206
+
}
202
207
/* Set errno to 0 so we can check for errors from strtol, which will tell us if the token after the assembly instruction is a number or a label (if it's neither we find out a bit later, not in this function). */
203
208
errno=0;
204
209
/* tempaddress is 0 if the labelstr is actually a label and not a value. */
@@ -259,9 +264,9 @@ unsigned short int findlabel(label **unknownlabels, label **labels, char *labels
259
264
if(endptr[0] ==']'&&endptr[1] =='\0')
260
265
{
261
266
/* However, the offset must be between 0 and 3 as addresses are 4 nibbles. */
262
-
if(addroffset>3||addroffset<0)
267
+
if(addroffset>3)
263
268
{
264
-
fprintf(stderr, "Line %llu: The offset of an address of operation must be between 0 and 4.\n", FILELINE);
269
+
fprintf(stderr, "Line %llu: The offset of an address of operation must be between 0 and 3.\n", FILELINE);
265
270
exit(51);
266
271
}
267
272
formatcorrect=1;
@@ -287,7 +292,7 @@ unsigned short int findlabel(label **unknownlabels, label **labels, char *labels
287
292
}
288
293
}
289
294
/* If the string has not passed all the trials, punish the user. */
290
-
if(formatcorrect=0)
295
+
if(formatcorrect==0)
291
296
{
292
297
fprintf(stderr, "Line %llu: Format of an address of operation must be &(LABEL[OFFSET])[ADDRESS_OFFSET].\n", FILELINE);
0 commit comments