Skip to content

Commit 2295f8c

Browse files
committed
Changed something around for months because people are lazy
1 parent 3906946 commit 2295f8c

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

examples/offsettest.asm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
LOD beep[0d2]
2-
beep: .data 0o3 0b1110
1+
INF 1000
2+
LOD &(beep[0])[0]
3+
beep: .data 4 0xABCD

src/as4.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -729,36 +729,14 @@ int main(int argc, char **argv)
729729
fprintf(stderr, "Used but undeclared label %s.\n", unknownlabels[i].str);
730730
exit(20);
731731
}
732-
/* Once we have made sure this label has been declared correctly, free the allocated memory for the label string. */
733-
/* We don't need it anymore. */
734-
if(unknownlabels[i].str != NULL)
735-
{
736-
/*free(unknownlabels[i].str);*/
737-
}
738732
}
739-
/* Once we've checked all the unknown labels, free the entire structure array. We don't need it anymore. */
740-
free(unknownlabels);
741733
}
742734

743735
/* Once we're sure everything is in order, write the buffer to a file. */
744736
for(i = 0; i < bytes; i++)
745737
{
746738
fputc(outbuf[i], output);
747739
}
748-
749-
/* Once we've written everything to a file, we don't need the known labels anymore, so get rid of them. */
750-
/* Iterate through and free all the label things and the array itself. */
751-
if(labels != NULL)
752-
{
753-
for(i = 0; i < numlabels; i++)
754-
{
755-
if(labels[i].str != NULL)
756-
{
757-
/*free(labels[i].str);*/
758-
}
759-
}
760-
free(labels);
761-
}
762740
/* We now have no use for the output buffer, as we wrote it to a file. Set it free. */
763741
free(outbuf);
764742
/* It's also a nice thing to close your file handles. We're done writing the buffer to the output, so close it. */

src/label.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ void addlabel(char *outbuf, label **labels, label **unknownlabels, unsigned long
131131
{
132132
char *nstr = calloc(1, 6);
133133
/* As this is getting a portion of the address of the label accessed, we get the label's address and bitwise and that section then shift it back. */
134-
sprintf(nstr, "N_[%X]", (labeladdr & (0xF << ((*unknownlabels)[i].addroffset * 4))) >> ((*unknownlabels)[i].addroffset * 4));
134+
sprintf(nstr, "N_[%X]", (labeladdr & (0xF << ( (3 - (*unknownlabels)[i].addroffset) * 4))) >> ( ( 3 - (*unknownlabels)[i].addroffset) * 4));
135135
labeladdr = findlabel(unknownlabels, labels, nstr, (*numlabels), numunknownlabels, instaddress * 4UL, ((*unknownlabels)[i].type) & 1);
136136
continue;
137137
}
138138
else
139139
{
140-
labeladdr = ((labeladdr & (0xF << ((*unknownlabels)[i].addroffset * 4))) >> ((*unknownlabels)[i].addroffset * 4)) + N_START;
140+
labeladdr = ((labeladdr & (0xF << ((3 - (*unknownlabels)[i].addroffset) * 4))) >> ((3 - (*unknownlabels)[i].addroffset) * 4)) + N_START;
141141
}
142142
}
143143
/* The address it was referenced at is actually the opcode of the instruction, so go up one nibble to point to the address section. */

0 commit comments

Comments
 (0)