Skip to content

Commit 0d552ba

Browse files
committed
Unify the z-macro syntax between the CP/M assembler and zif.
1 parent d17f89d commit 0d552ba

File tree

16 files changed

+735
-720
lines changed

16 files changed

+735
-720
lines changed

apps/adm3atst.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.label test_string
44
.label BIOS
55

6-
.zproc start
6+
zproc start
77
lda #<test_string
88
ldx #>test_string
99
ldy #BDOS_PRINTSTRING
@@ -20,7 +20,7 @@ BIOS:
2020
jsr $1234
2121

2222
rts
23-
.zendproc
23+
zendproc
2424

2525
test_string:
2626
.byte 26, "ADM-3A TEST - Screen cleared", 11,11, 13,10

apps/asm.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,23 +1440,29 @@ static void consumeInclude()
14401440
token = currentByte = ';';
14411441
}
14421442

1443-
static void lookupAndCall(const SymbolCallbackEntry* entries)
1443+
static bool lookupAndCall(const SymbolCallbackEntry* entries)
14441444
{
14451445
for (;;)
14461446
{
14471447
if (strcmp(entries->string, parseBuffer) == 0)
14481448
{
14491449
consumeToken();
14501450
entries->callback();
1451-
return;
1451+
return true;
14521452
}
14531453
entries++;
14541454

14551455
if (!entries->string)
1456-
fatal("unknown pseudo-op");
1456+
return false;
14571457
}
14581458
}
14591459

1460+
static void lookupAndCallOrFail(const SymbolCallbackEntry* entries)
1461+
{
1462+
if (!lookupAndCall(entries))
1463+
fatal("unknown pseudo-op");
1464+
}
1465+
14601466
static void parse()
14611467
{
14621468
top = cpm_ram;
@@ -1469,6 +1475,11 @@ static void parse()
14691475
{"fill", consumeDotFill},
14701476
{"expand", consumeDotExpand},
14711477
{"label", consumeDotLabel},
1478+
{"include", consumeInclude},
1479+
{}
1480+
};
1481+
1482+
static const SymbolCallbackEntry nondotEntries[] = {
14721483
{"zproc", consumeZproc},
14731484
{"zendproc", consumeZendproc},
14741485
{"zloop", consumeZloop},
@@ -1479,7 +1490,6 @@ static void parse()
14791490
{"zuntil", consumeZuntil},
14801491
{"zif", consumeZif},
14811492
{"zendif", consumeZendif},
1482-
{"include", consumeInclude},
14831493
{}
14841494
};
14851495

@@ -1497,10 +1507,15 @@ static void parse()
14971507
case '.':
14981508
consumeToken();
14991509
expect(TOKEN_ID);
1500-
lookupAndCall(dotEntries);
1510+
lookupAndCallOrFail(dotEntries);
15011511
break;
15021512

15031513
case TOKEN_ID:
1514+
/* Pseudooperations. */
1515+
1516+
if (lookupAndCall(nondotEntries))
1517+
break;
1518+
15041519
/* Process instructions. */
15051520

15061521
if (tokenLength == 3)

0 commit comments

Comments
 (0)