Fixed issue with addr offset
This commit is contained in:
parent
560ead0e32
commit
60cbe91cde
13
README.md
13
README.md
|
@ -40,18 +40,21 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn
|
|||
|
||||
@loop
|
||||
,dev1w STR
|
||||
,iterator LDR
|
||||
,01 ADD
|
||||
,iterator STR
|
||||
,iterator LDR
|
||||
,incr JSU ( call incr )
|
||||
,05 NEQ ,loop ROT JSC
|
||||
|
||||
BRK ( RESET )
|
||||
|
||||
@incr
|
||||
,iterator LDR
|
||||
,01 ADD
|
||||
,iterator STR
|
||||
,iterator LDR
|
||||
RTS
|
||||
|
||||
|c000 @FRAME BRK
|
||||
|d000 @ERROR BRK
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
||||
```
|
||||
|
||||
## Mission
|
||||
|
|
|
@ -10,14 +10,18 @@
|
|||
|
||||
@loop
|
||||
,dev1w STR
|
||||
,iterator LDR
|
||||
,01 ADD
|
||||
,iterator STR
|
||||
,iterator LDR
|
||||
,incr JSU ( call incr )
|
||||
,05 NEQ ,loop ROT JSC
|
||||
|
||||
BRK ( RESET )
|
||||
|
||||
@incr
|
||||
,iterator LDR
|
||||
,01 ADD
|
||||
,iterator STR
|
||||
,iterator LDR
|
||||
RTS
|
||||
|
||||
|c000 @FRAME BRK
|
||||
|d000 @ERROR BRK
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
5
uxn.c
5
uxn.c
|
@ -164,7 +164,7 @@ reset(void)
|
|||
int
|
||||
error(char *name)
|
||||
{
|
||||
printf("Error: %s\n", name);
|
||||
printf("Error: %s, at 0x%04x\n", name, cpu.counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -195,8 +195,7 @@ eval(void)
|
|||
if(instr > 0x10)
|
||||
setflag(FLAG_ZERO, 0);
|
||||
if(cpu.counter == 128) {
|
||||
printf("REACHED COUNTER\n");
|
||||
return 0;
|
||||
return error("Reached bounds");
|
||||
}
|
||||
cpu.counter++;
|
||||
return 1;
|
||||
|
|
14
uxnasm.c
14
uxnasm.c
|
@ -107,12 +107,6 @@ shex(char *s) /* string to num */
|
|||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
ismarker(char *w)
|
||||
{
|
||||
return w[0] == '[' || w[0] == ']' || w[0] == '{' || w[0] == '}';
|
||||
}
|
||||
|
||||
int
|
||||
iscomment(char *w, int *skip)
|
||||
{
|
||||
|
@ -173,7 +167,7 @@ findlabel(char *s)
|
|||
int
|
||||
error(char *name, char *id)
|
||||
{
|
||||
printf("Error: %s(%s)\n", name, id);
|
||||
printf("Error: %s[%s]\n", name, id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -241,9 +235,7 @@ pass1(FILE *f)
|
|||
else if(w[0] == '"')
|
||||
addr += slen(w + 1) + 2;
|
||||
else if(w[0] == ',')
|
||||
addr += 4;
|
||||
else if(ismarker(w))
|
||||
addr += 0;
|
||||
addr += 2 + (sihx(w + 1) && slen(w + 1) == 2 ? 1 : 2);
|
||||
else
|
||||
return error("Unknown label", w);
|
||||
}
|
||||
|
@ -262,7 +254,7 @@ pass2(FILE *f)
|
|||
if(w[0] == '@') continue;
|
||||
if(w[0] == ';') continue;
|
||||
suca(w);
|
||||
if(iscomment(w, &skip) || ismarker(w)) continue;
|
||||
if(iscomment(w, &skip)) continue;
|
||||
if(w[0] == '|')
|
||||
p.ptr = shex(w + 1);
|
||||
else if(w[0] == ':')
|
||||
|
|
Loading…
Reference in New Issue