0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-12-02 02:27:25 +00:00

Removed the noisy prints in the assembler

This commit is contained in:
neauoire 2021-06-27 10:03:09 -07:00
parent b5966ea78d
commit 2566943659
2 changed files with 23 additions and 15 deletions

View file

@ -31,12 +31,16 @@ Begin by building the assembler and emulator by running the build script. The as
./build.sh ./build.sh
``` ```
### Assembler
The following command will create an Uxn-compatible rom from an [uxntal file](https://wiki.xxiivv.com/site/uxntal.html), point to a different .tal file in `/projects` to assemble a different rom. The following command will create an Uxn-compatible rom from an [uxntal file](https://wiki.xxiivv.com/site/uxntal.html), point to a different .tal file in `/projects` to assemble a different rom.
``` ```
bin/uxnasm projects/examples/demos/life.tal bin/life.rom bin/uxnasm projects/examples/demos/life.tal bin/life.rom
``` ```
### Emulator
To start the rom, point the emulator to the newly created rom: To start the rom, point the emulator to the newly created rom:
``` ```
@ -45,6 +49,14 @@ bin/uxnemu bin/life.rom
You can also use the emulator without graphics by using `uxncli`. You can find additional roms [here](https://sr.ht/~rabbits/uxn/sources). You can also use the emulator without graphics by using `uxncli`. You can find additional roms [here](https://sr.ht/~rabbits/uxn/sources).
### I/O
You can send events from Uxn to another application, or another instance of uxn, with the Unix pipe. For a companion application that translates notes data into midi, see the [shim](https://git.sr.ht/~rabbits/shim).
```
uxnemu orca.rom | shim
```
## Emulator Controls ## Emulator Controls
- `F1` toggle zoom - `F1` toggle zoom

View file

@ -18,7 +18,7 @@ typedef signed char Sint8;
typedef unsigned short Uint16; typedef unsigned short Uint16;
typedef struct { typedef struct {
char name[64], items[128][64]; char name[64], items[256][64];
Uint8 len; Uint8 len;
Uint16 refs; Uint16 refs;
} Macro; } Macro;
@ -141,7 +141,7 @@ sublabel(char *src, char *scope, char *name)
int int
error(char *name, char *id) error(char *name, char *id)
{ {
printf("Error: %s[%s]\n", name, id); fprintf(stderr, "Error: %s[%s]\n", name, id);
return 0; return 0;
} }
@ -167,7 +167,6 @@ makemacro(char *name, FILE *f)
return error("Word too long", name); return error("Word too long", name);
scpy(word, m->items[m->len++], 64); scpy(word, m->items[m->len++], 64);
} }
printf("New macro #%d: %s, %d items\n", p.mlen, m->name, m->len);
return 1; return 1;
} }
@ -185,7 +184,6 @@ makelabel(char *name, Uint16 addr)
l->addr = addr; l->addr = addr;
l->refs = 0; l->refs = 0;
scpy(name, l->name, 64); scpy(name, l->name, 64);
printf("New label #%d: %s, at 0x%04x\n", p.llen, l->name, l->addr);
return 1; return 1;
} }
@ -293,23 +291,22 @@ pass1(FILE *f)
int ccmnt = 0; int ccmnt = 0;
Uint16 addr = 0; Uint16 addr = 0;
char w[64], scope[64], subw[64]; char w[64], scope[64], subw[64];
printf("Pass 1\n");
while(fscanf(f, "%s", w) == 1) { while(fscanf(f, "%s", w) == 1) {
if(skipblock(w, &ccmnt, '(', ')')) continue; if(skipblock(w, &ccmnt, '(', ')')) continue;
if(w[0] == '|') { if(w[0] == '|') {
if(!sihx(w + 1)) if(!sihx(w + 1))
return error("Invalid padding", w); return error("Pass 1 - Invalid padding", w);
addr = shex(w + 1); addr = shex(w + 1);
} else if(w[0] == '%') { } else if(w[0] == '%') {
if(!makemacro(w + 1, f)) if(!makemacro(w + 1, f))
return error("Invalid macro", w); return error("Pass 1 - Invalid macro", w);
} else if(w[0] == '@') { } else if(w[0] == '@') {
if(!makelabel(w + 1, addr)) if(!makelabel(w + 1, addr))
return error("Invalid label", w); return error("Pass 1 - Invalid label", w);
scpy(w + 1, scope, 64); scpy(w + 1, scope, 64);
} else if(w[0] == '&') { } else if(w[0] == '&') {
if(!makelabel(sublabel(subw, scope, w + 1), addr)) if(!makelabel(sublabel(subw, scope, w + 1), addr))
return error("Invalid sublabel", w); return error("Pass 1 - Invalid sublabel", w);
} else if(sihx(w)) } else if(sihx(w))
addr += slen(w) / 2; addr += slen(w) / 2;
else else
@ -324,7 +321,6 @@ pass2(FILE *f)
{ {
int ccmnt = 0, cmacr = 0; int ccmnt = 0, cmacr = 0;
char w[64], scope[64], subw[64]; char w[64], scope[64], subw[64];
printf("Pass 2\n");
while(fscanf(f, "%s", w) == 1) { while(fscanf(f, "%s", w) == 1) {
if(w[0] == '%') continue; if(w[0] == '%') continue;
if(w[0] == '&') continue; if(w[0] == '&') continue;
@ -334,7 +330,7 @@ pass2(FILE *f)
if(skipblock(w, &cmacr, '{', '}')) continue; if(skipblock(w, &cmacr, '{', '}')) continue;
if(w[0] == '|') { if(w[0] == '|') {
if(p.length && shex(w + 1) < p.ptr) if(p.length && shex(w + 1) < p.ptr)
return error("Memory Overwrite", w); return error("Pass 2 - Memory Overwrite", w);
p.ptr = shex(w + 1); p.ptr = shex(w + 1);
continue; continue;
} else if(w[0] == '$') { } else if(w[0] == '$') {
@ -347,7 +343,7 @@ pass2(FILE *f)
if(w[1] == '&') if(w[1] == '&')
scpy(sublabel(subw, scope, w + 2), w + 1, 64); scpy(sublabel(subw, scope, w + 2), w + 1, 64);
if(!parsetoken(w)) if(!parsetoken(w))
return error("Unknown label in second pass", w); return error("Pass 2 - Unknown label", w);
} }
return 1; return 1;
} }
@ -356,15 +352,15 @@ void
cleanup(char *filename) cleanup(char *filename)
{ {
int i; int i;
printf("Assembled %s(%d bytes), %d labels, %d macros.\n\n", filename, (p.length - TRIM), p.llen, p.mlen);
for(i = 0; i < p.llen; ++i) for(i = 0; i < p.llen; ++i)
if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z') if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z')
continue; /* Ignore capitalized labels(devices) */ continue; /* Ignore capitalized labels(devices) */
else if(!p.labels[i].refs) else if(!p.labels[i].refs)
printf("--- Unused label: %s\n", p.labels[i].name); fprintf(stderr, "--- Unused label: %s\n", p.labels[i].name);
for(i = 0; i < p.mlen; ++i) for(i = 0; i < p.mlen; ++i)
if(!p.macros[i].refs) if(!p.macros[i].refs)
printf("--- Unused macro: %s\n", p.macros[i].name); fprintf(stderr, "--- Unused macro: %s\n", p.macros[i].name);
printf("Assembled %s(%d bytes), %d labels, %d macros.\n", filename, (p.length - TRIM), p.llen, p.mlen);
} }
int int