}
if (ulas.address < 0x14C) {
- for (int i =0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
ulas.chksm = ulas.chksm - outbuf[i] - 1;
}
}
long other_writes = 0;
const char *start = line;
+ const char *instr_start = start;
int rc = 0;
// read the first token and decide
return 0;
}
+ // is it a label?
+ if (ulas_islabelname(ulas.tok.buf, strlen(ulas.tok.buf))) {
+ instr_start = line;
+ struct ulas_tok label_tok = {ULAS_INT, {ulas.address}};
+ ulas_symbolset(ulas.tok.buf, -1, label_tok, 1);
+ ulas_tok(&ulas.tok, &line, n);
+ // is next token empty?
+ if (ulas_istokend(&ulas.tok)) {
+ ulas_asmlst(start, outbuf, towrite);
+ return 0;
+ }
+ }
+
if (ulas.tok.buf[0] == ULAS_TOK_ASMDIR_BEGIN) {
const char *dirstrs[] = {ULAS_ASMSTR_ORG, ULAS_ASMSTR_SET,
ULAS_ASMSTR_BYTE, ULAS_ASMSTR_STR,
} else {
// is regular line in form of [label:] instruction ; comment
- // is it a label?
- if (ulas_islabelname(ulas.tok.buf, strlen(ulas.tok.buf))) {
- const char *prev = line;
- struct ulas_tok label_tok = {ULAS_INT, {ulas.address}};
- ulas_symbolset(ulas.tok.buf, -1, label_tok, 1);
-
- // is next token empty?
- if (ulas_tok(&ulas.tok, &line, n) == 0 ||
- strnlen(ulas.tok.buf, ulas.tok.maxlen) == 0) {
- ulas_asmlst(start, outbuf, towrite);
- return 0;
- }
-
- line = prev;
- } else {
- // start over for the next step...
- line = start;
- }
+ // start over for the next step...
+ line = instr_start;
int nextwrite = ulas_asminstr(outbuf, ULAS_OUTBUFMAX, &line, n);
if (nextwrite == -1) {