.\" Manpage for ulas.
.\" Contact lukas@krickl.dev to correct errors or typos.
-.TH man 1 "29 October 2024" "0.0.1" "ulas language reference"
+.TH man 5 "19 January 2025" "0.0.1" "ulas language reference"
.SH PREPROCESSOR
Re-defines the ascii value for one character to another value.
Can be used for custom encodings.
-.SH .chr
+.SH chr
\.chr 01233213
Outputs a byte as a 2bpp sprite.
Must have exactly 8 values ranging from 0-3
Repeats the instruction n times advancing from 0 by step each iteration.
The first parameter is a counter value that allows the instruction to access the
current iterator value.
+
+.SH section
+ \.section <name>
+ Defines a section name.
+ This is currently only used for mlb symbol files, but might be added to other areas in the future.
+ If no section was defined the .section directive will use pre-defined values for mlb outputs.
+
.SH SEE ALSO
ulas(1) for a rference on how to use ulas.
Lukas Krickl (lukas@krickl.dev)
.SH COPYRIGHT
- Copyright 2024 Lukas Krickl (lukas@krickl.dev)
+ Copyright 2025 Lukas Krickl (lukas@krickl.dev)
}
int ulas_symbolout_mlbloc(FILE *dst, long addr) {
+ if (ulas.section[0] != '\0') {
+ fprintf(dst, "%s:", ulas.section);
+ return 0;
+ }
+
if (addr == -1) {
fprintf(dst, "Unknown:");
return 0;
return rc;
}
+int ulas_asmdirsection(FILE *dst, FILE *src, const char **line,
+ unsigned long n) {
+ ulas_tok(&ulas.tok, line, n);
+ if (!ulas_isname(ulas.tok.buf,
+ MIN(strlen(ulas.tok.buf), ulas.tok.maxlen))) {
+ ULASERR("Unexpected token '%s'\n", ulas.tok.buf);
+ return -1;
+ }
+ strncpy(ulas.section, ulas.tok.buf, ULAS_SECTIONMAX);
+ return 0;
+}
+
int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) {
// this buffer is written both to dst and to verbose output
char outbuf[ULAS_OUTBUFMAX];
}
if (ulas.tok.buf[0] == ULAS_TOK_ASMDIR_BEGIN) {
- const char *dirstrs[] = {ULAS_ASMSTR_ORG, ULAS_ASMSTR_SET,
- ULAS_ASMSTR_BYTE, ULAS_ASMSTR_STR,
- ULAS_ASMSTR_FILL, ULAS_ASMSTR_PAD,
- ULAS_ASMSTR_INCBIN, ULAS_ASMSTR_DEF,
- ULAS_ASMSTR_CHKSM, ULAS_ASMSTR_ADV,
- ULAS_ASMSTR_SET_ENUM_DEF, ULAS_ASMSTR_DEFINE_ENUM,
- ULAS_ASMSTR_SETCHRCODE, ULAS_ASMSTR_CHR,
- ULAS_ASMSTR_REP, NULL};
+ const char *dirstrs[] = {ULAS_ASMSTR_ORG,
+ ULAS_ASMSTR_SET,
+ ULAS_ASMSTR_BYTE,
+ ULAS_ASMSTR_STR,
+ ULAS_ASMSTR_FILL,
+ ULAS_ASMSTR_PAD,
+ ULAS_ASMSTR_INCBIN,
+ ULAS_ASMSTR_DEF,
+ ULAS_ASMSTR_CHKSM,
+ ULAS_ASMSTR_ADV,
+ ULAS_ASMSTR_SET_ENUM_DEF,
+ ULAS_ASMSTR_DEFINE_ENUM,
+ ULAS_ASMSTR_SETCHRCODE,
+ ULAS_ASMSTR_CHR,
+ ULAS_ASMSTR_REP,
+ ULAS_ASMSTR_SECTION,
+ NULL};
enum ulas_asmdir dirs[] = {
ULAS_ASMDIR_ORG, ULAS_ASMDIR_SET,
ULAS_ASMDIR_BYTE, ULAS_ASMDIR_STR,
ULAS_ASMDIR_CHKSM, ULAS_ASMDIR_ADV,
ULAS_ASMDIR_SET_ENUM_DEF, ULAS_ASMDIR_DEFINE_ENUM,
ULAS_ASMDIR_SETCHRCODE, ULAS_ASMDIR_CHR,
- ULAS_ASMDIR_REP};
+ ULAS_ASMDIR_REP, ULAS_ASMDIR_SECTION};
enum ulas_asmdir dir = ULAS_ASMDIR_NONE;
case ULAS_ASMDIR_REP:
rc = ulas_asmdirrep(dst, src, &line, n);
break;
+ case ULAS_ASMDIR_SECTION:
+ rc = ulas_asmdirsection(dst, src, &line, n);
+ break;
case ULAS_ASMDIR_PAD:
// TODO: pad is the same as .fill n, $ - n
case ULAS_ASMDIR_NONE:
#define ULAS_OUTBUFMAX 64
#define ULAS_MACROPARAMMAX 15
+#define ULAS_SECTIONMAX 32
+
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define ULAS_ASMSTR_SETCHRCODE ".scc"
#define ULAS_ASMSTR_CHR ".chr"
#define ULAS_ASMSTR_REP ".rep"
+#define ULAS_ASMSTR_SECTION ".section"
// configurable tokens
#define ULAS_TOK_COMMENT ';'
// defaults to just x=x mapping
// but cna be set with a directive
char charcodemap[ULAS_CHARCODEMAPLEN];
+ char section[ULAS_SECTIONMAX];
struct ulas_arch arch;
};
// .rep <n>, <step>, <line>
// repeats a line n times
ULAS_ASMDIR_REP,
+ // .section <name>
+ // set the current section
+ ULAS_ASMDIR_SECTION,
};
#define ULAS_INSTRTOKMAX 16