Fixed issue with label length in pass2
This commit is contained in:
parent
5610b9eb77
commit
f4423ad629
10
assembler.c
10
assembler.c
|
@ -29,7 +29,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
char name[64];
|
||||
Uint8 refs, maps;
|
||||
Uint16 addr;
|
||||
Uint16 addr, len;
|
||||
Map map[16];
|
||||
} Label;
|
||||
|
||||
|
@ -236,7 +236,8 @@ makevariable(char *name, Uint16 *addr, FILE *f)
|
|||
if(word[0] == '}') break;
|
||||
scpy(word, l->map[l->maps].name, 64);
|
||||
fscanf(f, "%u", &l->map[l->maps].size);
|
||||
*addr += l->map[l->maps++].size;
|
||||
*addr += l->map[l->maps].size;
|
||||
l->len += l->map[l->maps++].size;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -384,11 +385,14 @@ pass2(FILE *f)
|
|||
char w[64], scope[64], subw[64];
|
||||
printf("Pass 2\n");
|
||||
while(fscanf(f, "%s", w) == 1) {
|
||||
if(w[0] == ';') continue;
|
||||
if(w[0] == '$') continue;
|
||||
if(w[0] == '%') continue;
|
||||
if(skipblock(w, &ccmnt, '(', ')')) continue;
|
||||
if(skipblock(w, &ctemplate, '{', '}')) continue;
|
||||
if(w[0] == ';') {
|
||||
p.ptr += findlabel(w + 1)->len;
|
||||
continue;
|
||||
}
|
||||
if(w[0] == '|') {
|
||||
p.ptr = shex(w + 1);
|
||||
continue;
|
||||
|
|
2
build.sh
2
build.sh
|
@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
|||
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||
|
||||
# run
|
||||
./bin/assembler projects/software/nasu.usm bin/boot.rom
|
||||
./bin/assembler projects/software/noodle.usm bin/boot.rom
|
||||
./bin/emulator bin/boot.rom
|
||||
|
|
Loading…
Reference in New Issue