Added version to uxnasm
This commit is contained in:
parent
2e25f6c27e
commit
c26de05efa
2
build.sh
2
build.sh
|
@ -96,11 +96,13 @@ if [ $norun = 1 ]; then exit; fi
|
||||||
|
|
||||||
# Test usage
|
# Test usage
|
||||||
|
|
||||||
|
./bin/uxnasm
|
||||||
./bin/uxncli
|
./bin/uxncli
|
||||||
./bin/uxnemu
|
./bin/uxnemu
|
||||||
|
|
||||||
# Test version
|
# Test version
|
||||||
|
|
||||||
|
./bin/uxnasm -v
|
||||||
./bin/uxncli -v
|
./bin/uxncli -v
|
||||||
./bin/uxnemu -v
|
./bin/uxnemu -v
|
||||||
|
|
||||||
|
|
36
src/uxnasm.c
36
src/uxnasm.c
|
@ -175,15 +175,6 @@ makelabel(char *name)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
makelambda(int id)
|
|
||||||
{
|
|
||||||
scpy("lambda", p.lambda, 0x07);
|
|
||||||
p.lambda[6] = '0' + (id >> 0x4);
|
|
||||||
p.lambda[7] = '0' + (id & 0xf);
|
|
||||||
return p.lambda;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
makereference(char *scope, char *label, char rune, Uint16 addr)
|
makereference(char *scope, char *label, char rune, Uint16 addr)
|
||||||
{
|
{
|
||||||
|
@ -192,10 +183,7 @@ makereference(char *scope, char *label, char rune, Uint16 addr)
|
||||||
if(p.refs_len >= 0x800)
|
if(p.refs_len >= 0x800)
|
||||||
return error("References limit exceeded", label);
|
return error("References limit exceeded", label);
|
||||||
r = &p.refs[p.refs_len++];
|
r = &p.refs[p.refs_len++];
|
||||||
if(label[0] == '{') {
|
if(label[0] == '&') {
|
||||||
p.lambda_stack[p.lambda_ptr++] = p.lambda_count;
|
|
||||||
scpy(makelambda(p.lambda_count++), r->name, 0x40);
|
|
||||||
} else if(label[0] == '&') {
|
|
||||||
if(!sublabel(subw, scope, label + 1))
|
if(!sublabel(subw, scope, label + 1))
|
||||||
return error("Invalid sublabel", label);
|
return error("Invalid sublabel", label);
|
||||||
scpy(subw, r->name, 0x40);
|
scpy(subw, r->name, 0x40);
|
||||||
|
@ -213,6 +201,15 @@ makereference(char *scope, char *label, char rune, Uint16 addr)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
makelambda(int id)
|
||||||
|
{
|
||||||
|
scpy("lambda", p.lambda, 0x07);
|
||||||
|
p.lambda[6] = '0' + (id >> 0x4);
|
||||||
|
p.lambda[7] = '0' + (id & 0xf);
|
||||||
|
return p.lambda;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
writebyte(Uint8 b)
|
writebyte(Uint8 b)
|
||||||
{
|
{
|
||||||
|
@ -364,10 +361,14 @@ parse(char *w, FILE *f)
|
||||||
while((c = w[++i]))
|
while((c = w[++i]))
|
||||||
if(!writebyte(c)) return 0;
|
if(!writebyte(c)) return 0;
|
||||||
break;
|
break;
|
||||||
|
case '{': /* lambda start */
|
||||||
|
p.lambda_stack[p.lambda_ptr++] = p.lambda_count;
|
||||||
|
makereference(p.scope, makelambda(p.lambda_count++), ' ', p.ptr + 1);
|
||||||
|
return writebyte(0x60) && writeshort(0xffff, 0);
|
||||||
case '}': /* lambda end */
|
case '}': /* lambda end */
|
||||||
if(!makelabel(makelambda(p.lambda_stack[--p.lambda_ptr])))
|
if(!makelabel(makelambda(p.lambda_stack[--p.lambda_ptr])))
|
||||||
return error("Invalid label", w);
|
return error("Invalid label", w);
|
||||||
break;
|
return writebyte(0x6f);
|
||||||
case '[':
|
case '[':
|
||||||
case ']':
|
case ']':
|
||||||
if(slen(w) == 1) break; /* else fallthrough */
|
if(slen(w) == 1) break; /* else fallthrough */
|
||||||
|
@ -497,9 +498,12 @@ writesym(char *filename)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int i = 1;
|
||||||
FILE *src, *dst;
|
FILE *src, *dst;
|
||||||
if(argc < 3)
|
if(i == argc)
|
||||||
return !error("usage", "uxnasm input.tal output.rom");
|
return error("usage", "uxnasm [-v] input.tal output.rom");
|
||||||
|
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||||
|
return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 8 Aug 2023\n");
|
||||||
if(!(src = fopen(argv[1], "r")))
|
if(!(src = fopen(argv[1], "r")))
|
||||||
return !error("Invalid input", argv[1]);
|
return !error("Invalid input", argv[1]);
|
||||||
if(!assemble(src))
|
if(!assemble(src))
|
||||||
|
|
Loading…
Reference in New Issue