Skip to content

Commit 6811598

Browse files
committed
Fixed issue with whitespace in labels
1 parent d2298d6 commit 6811598

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

examples/infiniteloop.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Start:
2+
NOP
3+
JMP Start
4+
HLT

out

10 Bytes
Binary file not shown.

src/as4.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,15 @@ unsigned short int findlabel(label **unknownlabels, label **labels, const char *
770770
}
771771
/* Copy the name of the label into the temporary string pointer for comparison. */
772772
memcpy(tempstr, labelstr, strlen(labelstr));
773+
/* Remove any possible whitespace */
774+
for(i = 0; i < strlen(tempstr); i++)
775+
{
776+
if(isspace(tempstr[i]))
777+
{
778+
tempstr[i] = '\0';
779+
break;
780+
}
781+
}
773782
/* Check that the pointer to the pointer to the collection of labels is valid .*/
774783
if(labels != NULL)
775784
{

src/as4.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <sys/stat.h>
1010
#include <stdint.h>
1111
#include <errno.h>
12+
#include <ctype.h>
1213
/* This is a 4-bit assembler for the Nibble Knowledge computer */
1314
/* Hacked together by Ryan Harvey Oct 12 2015 - for a minicompter design that should be from the 60s! */
1415
/* This was essentially hacked together in a single day - beware! */
@@ -58,4 +59,4 @@ unsigned short int findlabel(label **unknownlabels, label **labels, const char *
5859
/* addstring() handles adding .ascii and .ascii (zero terminating ascii string) to the output buffer, including handling escape characters. */
5960
void addstring(char *outbuf, char *string, char zeroterm, unsigned long long *bits, unsigned long long *bytes);
6061

61-
#endif /* _AS4_H_ */
62+
#endif /* _AS4_H_ */

0 commit comments

Comments
 (0)