Skip to content

Releases

uplm80 0.5.0

Choose a tag to compare

@avwohl avwohl released this 05 Nov 11:12

Changed: upeepz80 0.2.8 or later, and CI runs the -g tests

upeepz80 0.2.8 and um80 0.4.0 are on PyPI (2026-11-04). pyproject.toml
now requires upeepz80>=0.2.8, the first release that keeps -g's ;#
markers without changing the code, and UPLM80_MIN in compiler.py follows
it. Below the floor the tail-call probe still decides, so 0.2.6 and 0.2.7
pass without -g. The Tests workflow installs um80>=0.4.0, builds cpmemu
from its repository and sets UPLM80_REQUIRE_TOOLS=1, so the D2 byte test,
the prog.dbg tests and the live udb80 tests run there and fail rather than
skip when a tool is missing. Measured in a Python 3.12 virtual environment
with the PyPI packages and a fresh cpmemu, as the workflow has them: 3185
passed, 340 skipped. The todo item for the release is closed.

Added: -g, source-line markers for a debugger

Phase 4 of the debugger plan (cpmemu docs/debugger_plan.md) for uplm80.
uplm80 -g writes ;# markers (um80_and_friends docs/debug_info.md)
into the .mac text: ;#file for the source file and each $INCLUDE
file, ;#line in front of each statement, ;#func and ;#endfunc round
each procedure (frame=ix for a REENTRANT one, frame=static for the
rest, pops the bytes of arguments past the second) and round the main
program's statements, ;#inline and ;#endinline round a procedure the
-O3 inliner put into its caller, and ;#line 0 0 in front of the jump
table of a big DO CASE. The ;#func of a REENTRANT procedure has
ixbegin= and ixend=: compiler.add_ix_range_labels writes the two
labels (??IXB1, ??IXE1) after upeepz80 has run, so no label stops the
peephole optimizer. A line is the source's own: an $INCLUDE file's
line in that file, and for a LITERALLY's text the line of the name it
replaced. Assemble with um80 --debug-info and link with ul80 --debug-info to get prog.dbg. docs/debug_info.md has the detail.

Measured on 2026-11-04 (um80_and_friends 92196ca and 8c828b3, upeepz80
ab4de24 on top of 0.2.7):

  • The code does not change (D2). 68 programs (tests/*.plm,
    sample_code, examples, one of romwbw_emu) compiled with and without
    -g, assembled and linked, at -O0 to -O3: 272 builds, 272 with the
    same .COM (the .REL for 3 programs that need an EXTERNAL data
    symbol). 14 of the 68 (the CP/M 1.x sources) do not compile with or
    without -g. tests/test_debug_info.py repeats the test for the 22
    programs of tests/ that have an expected output, at four levels
    (about 100 s), and the .mac text of a program without its marker lines
    is the same as without -g.

  • Coverage. Of the instruction bytes in the routines (;#func to
    ;#endfunc, the main program's included) of the 51 programs that link,
    100.00% have a source line in prog.dbg: 46172 of 46172 bytes at -O2
    (50171 at -O0, 46220 at -O1, 45356 at -O3). Outside the runtime,
    46172 of 46182 bytes (99.98%) have one; the 10 others are the
    entry code of tests/test_array_bug.plm, the one program with no main
    statements. A REENTRANT
    program (tests/test_reentrant.plm: 909 of 909 bytes) is among them.

  • Live. udb80 against cpmemu --gdb on a -g -O2 program with a
    REENTRANT recursive FACTORIAL: break demo.plm:36, step into FACT,
    next, finish, and bt show FACT four deep above the main
    program, with the PL/M lines.

  • ixbegin and ixend (re-measured 2026-11-04). 48 programs that link
    with -g, -O0 to -O3: 0 instruction bytes of the routines without a
    source line (43301, 39902, 39858 and 38640 bytes), and every REENTRANT
    routine has an IX range inside its own addresses in prog.dbg. The
    D2 byte test again: 53 programs at four levels, 212 builds with the same
    .COM with and without -g, 0 different (14 programs do not compile,
    with or without -g). A routine with several exits has one IX range.

  • Tests. tests/test_debug_info.py also checks the line of a
    statement the optimizers rewrite (CSE, a folded constant, an unrolled
    loop; -O2 and -O3), the IX range, and a two-module compile. The
    tests that need um80 and ul80 fail instead of skipping when
    UPLM80_REQUIRE_TOOLS=1.

  • Against upeepz80 0.2.7, which lets a marker hide a dead store, the -g
    tests at -O1 and above skip with the reason (45 of 51), or fail under
    UPLM80_REQUIRE_TOOLS=1. 0.5.0 requires upeepz80 0.2.8 (see the first
    section).

Changed

  • AsmLine has a raw field for a line written as it is (a marker is
    ;#kind, not the ; + comment of comment). note_origins also gives
    a node position an end_origin, the (file, line) of its last line. The
    -O3 inliner marks the statement it puts in place of a call
    (uplm80_inline). None of the AsmLine, note_origins and inliner
    changes changes the code without -g.

Not done

  • (Written before upeepz80 0.2.8, and closed by the first section.) With
    -g at -O1 and above the compiler tests the installed upeepz80
    (upeepz80_markers_problem) and refuses 0.2.7 and before: 0.2.7 lets a
    ;#line marker hide the dead store at a procedure's entry, and the
    .mac text differs in 15 of 156 compiles (5 programs at -O1 to
    -O3, measured). The check stays for an older upeepz80 that pip keeps.
  • No nostmt marker: the optimizer's loop-invariant pass only caches
    expressions for CSE and moves no code out of a loop.
  • A runtime routine (??mul16 and the others) has no marker, so a
    debugger shows it at the assembler level. In udb80 (phase 3, not this
    repository), next over a call of ??mul16 stopped at the routine's
    first instruction (FACT's n * fact(n - 1), measured); next over a
    call of a PL/M procedure, FACT recursion included, worked.

Added: -g, variables for a debugger

Phase 8 of the debugger plan (cpmemu docs/debugger_plan.md) for uplm80.
uplm80 -g also writes ;#var and ;#type markers
(um80_and_friends docs/debug_info.md, Variables) for every variable
(uplm80/debug_vars.py, CodeGenerator notes each one as it hands out
the storage, add_vars writes the markers after upeepz80, with
add_ix_range_labels, because only the final text says what is left).
Each storage kind has a record:

  • module level, INITIAL, DATA, AT, PUBLIC, and a procedure's
    locals that have their own label: at=LABEL (kind=global for PUBLIC,
    static at module level, local in a procedure or DO block);
  • the shared area: at=??AUTO+N, in the routine of the owner;
  • a REENTRANT procedure: ix=N (parameters at IX+4 and up, locals below);
  • a parameter or a local of a static procedure (not INITIAL, DATA, AT,
    PUBLIC or BASED): range= from the instruction after the first store to
    its slot, to the end of the routine, so the record does not claim a value
    before the store (the slot of ??AUTO holds other routines' bytes
    there);
  • a BASED variable: the format has no "address held in another variable",
    so the record is a pointer (*T) at the place of the base, at=CTL+2 for
    a base that is a structure member;
  • a variable of a DO block of the main program, a nested procedure (and
    a copy of the variables of the procedures around it, as locals), an
    $INCLUDE file (decl= names the file);
  • none why=no-storage for a slot of ??AUTO that no instruction of the
    routine names, none why=no-frame for an ix= variable of a routine
    that lost ixbegin.

Types are typedef:BYTE (target ushort:1, so udb80 prints numbers and
lists of numbers, not C strings that stop at a zero byte) and
typedef:ADDRESS (uint:2), [N]T for an array (PL/M's dimension is the
number of elements), and struct:TAG for a STRUCTURE (the tag is the
variable's name, NAME.2 for another layout of the same name). A name is
shown as the source spells it, without the $ (udb80 has no $ in
names): the token's line and column, checked against the source text; the
upper-case name when the check fails. LITERALLY, LABEL, procedure,
EXTERNAL and the built-ins MEMORY and STACKPTR have no record. A fault in the
variable code is a warning and a build with no variable records
(UPLM80_DEBUG_VARS_STRICT=1 raises it). docs/debug_info.md has the
detail.

Measured on 2026-11-04 (um80_and_friends d39debc, upeepz80 0.2.7 plus
ab4de24):

  • The code does not change (D2). 69 files (tests/, sample_code,
    examples, one of romwbw_emu): 14 do not compile, with or without -g.
    The other 55 at -O0 to -O3 are 220 builds, with and without -g
    (through um80 --debug-info and ul80 --debug-info): 220 have the same
    .COM (the .REL for programs that need an EXTERNAL data symbol), and
    neither tool wrote a warning (measured again after the range of the
    locals was added). tests/test_debug_info.py (51 tests) passed
    before and after. tests/test_debug_vars.py repeats the byte test for
    its program at four levels, and checks that the .mac text without the
    marker lines and the ??VRn labels is the text of a compile without -g.
  • Records. 55 programs give 2848 ;#var lines at -O2 (a copy for a
    nested procedure counts): 999 in ??AUTO, 1471 at a procedure's or
    block's label, 331 at a module label, 15 in an IX frame, 32 none.
    The 50 that link give 1416 rows in prog.dbg (1110 of the routines'
    own variables and 306 copies in nested procedures), 764 of them with a
    range= (264 before locals got one), 28 with no place at -O2 (22 at -O0), all no-storage.
    Of 1630 names, 387 are shown in the case the source has, 1235 are upper
    case in the source, and 8 (a structure member from a LITERALLY) fell
    back to the upper-case name.
  • Live. udb80 (python3 -m um80.udb80) against cpmemu --gdb,
    -O0 to -O3: print of a BYTE, an ADDRESS, BYTE and ADDRESS arrays,
    a DATA table, a STRUCTURE, an array of STRUCTUREs, a PUBLIC, an AT
    variable, a factored INITIAL, a BASED variable (print bb the pointer,
    `print...
Read more

uplm80 0.4.4

Choose a tag to compare

@avwohl avwohl released this 27 Sep 16:16

What 0.4.3's final release check found and left for a later release, what
0.4.3's Known issues listed as compiled without a word, and what checking
0.4.4 against Intel's PL/M-80 V3.1 found. More of the errors V3.1 gives,
V3.1's numbers and texts, at every level: more than one subscript, a CALL
through what is not an ADDRESS scalar or of a built-in with a type, a
built-in with too few or too many arguments, MEMORY without a subscript, a
procedure that calls itself, a REENTRANT procedure where V3.1 refuses one,
an assignment to a built-in or a procedure; what a restricted expression -
a DATA or INITIAL value, an AT address, a constant list - does not take: a
built-in, which -O1 and up folded, a name, parentheses, an operator but

  • and -, a number a byte does not hold, a location with two subscripts or
    with one on what is not an array, and in an AT the location of a
    procedure, a label or a BASED variable among them; a base V3.1 does not
    take - BASED or a member of what is, on which um80 failed, a BYTE, a name
    declared further down; and a LABEL that labels no statement, on which in a
    DATA list um80 failed. Every flag reader the flags of a SHL or SHR of a
    BYTE may reach is warned of, and every -O level reads the flags -O0
    reads. A location in a DATA or INITIAL list or an AT address is the
    variable the name means, declared in its block or one around it, before
    the list or after it, whatever the form of its declaration; that of a
    REENTRANT procedure's local or a BASED variable in a list, of a factored
    BASED declaration too, is uplm80's own refusal, as in an AT, not um80's
    "Undefined symbol" or another block's variable. A factored BASED
    declaration on a member, (a based s.p) byte, is BASED, and a base is the
    declaration of its name made before the variable BASED on it, wherever
    that variable is used. Smaller code after an 8-bit operation, and the
    columns after a LITERALLY's text are the source's.

Incompatible: more errors Intel's PL/M-80 gives

What uplm80 compiled and Intel's PL/M-80 V3.1 rejects is refused as V3.1
refuses it, with the number and text of each error V3.1 gives, at every
-O level (of some combinations of two errors, not every one: Known
issues). No program of MP/M II (DRI's tree and mpm2's overrides), of
80un 0.3.3 or of sample_code has any of these, and none of the 88
compiles of their PL/M gives a new error; one test's program, which called
through an array's element to have its address found in DE, calls through
a BASED ADDRESS now. V3.1 rejects each program of tests/test_names.py
with the errors the message names, and no other
(tests/test_intel_oracle.py), and builds the programs of what it takes
of the same forms to print what uplm80's builds print. Three of 0.4.3's
messages name more of V3.1's errors: an INTERRUPT, PUBLIC or EXTERNAL
procedure with no statements in a procedure or a DO block #174, INVALID
NULL PROCEDURE, besides #39, as V3.1 then takes it for a procedure of its
own, and an EXTERNAL one has none, and a typed one #156, MISSING RETURN
STATEMENT IN TYPED PROCEDURE, too; a typed procedure with no statements
#156 besides #174; and LENGTH and LAST of a reference with anything in
parentheses in a subscript #125, ILLEGAL ARGUMENT FOR BUILT-IN PROCEDURE,
besides #32 (SIZE only #32). And the message of .lb of a label in an
expression, which uplm80 refuses since 0.4.1, names V3.1's #158, INVALID
DOT OPERAND, LABEL ILLEGAL.

  • More than one subscript (ERROR #114, INVALID SUBSCRIPT, MULTIPLE
    SUBSCRIPTS ILLEGAL), wherever a subscript goes: of an array, a BASED
    one, a member array, an array of structures and MEMORY, in an
    expression, as a target and after a dot - b = a(1, 2), a(1, 2) = w, .a(1, 2), s.m(1, 2), sa(1, 2).m(0), sa(1).m(0, 1),
    memory(1, 2). uplm80 took the subscripts for arguments and called,
    at every level, through the value of a(0) (0.4.3's release check);
    0.4.3 made the same of a scalar an error. In a DATA or INITIAL list,
    an AT address or a constant list, data (.a(1, 2)), it is V3.1's #150
    (Incompatible: V3.1's errors in a restricted expression).

    A(1, 2): A is an array, and an array takes one subscript; Intel's
    PL/M-80 V3.1 rejects it (ERROR #114, INVALID SUBSCRIPT, MULTIPLE
    SUBSCRIPTS ILLEGAL)
    
  • A subscript on a scalar member, s.k(1), which uplm80 took for
    the element that far past s.k (ERROR #127, INVALID SUBSCRIPT ON
    NON-ARRAY, and #32, INVALID SYNTAX, TEXT IGNORED UNTIL ';'); a
    subscript or an argument list after another, a(1)(2) and h(1)(2),
    which uplm80 took for a call through the element or through what h
    returns (#32); and a second port, input(1, 2) and output(1, 2) = b, which uplm80 left out (ERROR #108, MISSING ')' AFTER INPUT/OUTPUT
    PORT NUMBER).

  • A CALL through what is not an ADDRESS scalar (ERROR #118, INVALID
    INDIRECT CALL, IDENTIFIER NOT AN ADDRESS SCALAR, and #32 where
    parentheses follow): an array, call aa(1) and call aa(1)(b, c),
    which uplm80 took for a call through aa(0), with 1, and through
    aa(1); a member array, a member of an element of an array of
    structures, call sa(1).g, where V3.1 takes SA for what is called and
    the rest for its arguments, MEMORY, a structure, and a BYTE - a
    variable, a parameter or a member - whose value uplm80 called; and a
    label, call l, which uplm80 called and the link found no L for. A
    CALL through an ADDRESS, a structure's ADDRESS member or a BASED
    ADDRESS, with arguments or without, is compiled as before, as V3.1
    compiles it, and so is one through the ADDRESS member of an array of
    structures, BASED or not, named without a subscript, call sa.g, which
    calls through sa(0).g: V3.1 takes it in a CALL, and rejects it in an
    expression (ERROR #133, of which uplm80 warns: 0.4.3).

    CALL AA(1): AA is an array, and a CALL calls a procedure, or
    through an ADDRESS scalar (Programming Manual 9800268B, 8.2.1);
    Intel's PL/M-80 V3.1 rejects it (ERROR #118, INVALID INDIRECT CALL,
    IDENTIFIER NOT AN ADDRESS SCALAR, and #32, INVALID SYNTAX, TEXT
    IGNORED UNTIL ';')
    
  • A CALL of a built-in with a type (ERROR #129, ILLEGAL 'CALL' WITH
    TYPED PROCEDURE, and #32 where parentheses follow): call stackptr,
    which uplm80 compiled to a call through the value of SP, call carry,
    to a call of an undefined CARRY, and call rol(b, 1) and the like, to
    the built-in's value, unused. A CALL of a typed procedure the program
    declares is still taken (README).

  • A built-in with too few or too many arguments (ERROR #154, INVALID
    NUMBER OF ARGUMENTS IN CALL, TOO FEW, and #153, TOO MANY): call time;,
    call move(1, .b);, b = rol(b); and w = stackptr(1);, which stopped
    uplm80 with a traceback, and b = high;, b = low(b, 1), b = carry(1) and call time(1, 2), which it compiled (found checking
    0.4.4; 0.4.3 the same); LENGTH, LAST or SIZE with no argument or more
    than one (#124, MISSING ARGUMENTS FOR BUILT-IN PROCEDURE; #126, MISSING
    ')' AFTER BUILT-IN PROCEDURE ARGUMENT LIST); and INPUT or OUTPUT without
    a port, b = input; and output = b; (#109, MISSING INPUT/OUTPUT PORT
    NUMBER).

  • MEMORY without a subscript, b = memory, memory = b, `w = memory

    • 1(ERROR #133, ILLEGAL REFERENCE TO UNSUBSCRIPTED ARRAY), which uplm80 took formemory(0); .memory` and LENGTH, LAST and SIZE of it
      are taken, as V3.1 takes them.
  • A procedure that calls itself, not REENTRANT (ERROR #170, ILLEGAL
    RECURSIVE CALL): r: procedure; ... call r; end r;, return h in a
    typed H, and a call of R from a procedure declared in it (0.4.3's Known
    issues). Its locals are static and a second activation overwrote the
    first's. A REENTRANT procedure calls itself, and a CALL through the
    address of the procedure it is in is taken, as V3.1 takes them.

    R: procedure R is called from inside itself, and only a REENTRANT
    procedure may be (Programming Manual 9800268B, 8.1.7); Intel's
    PL/M-80 V3.1 rejects it (ERROR #170, ILLEGAL RECURSIVE CALL)
    
  • A REENTRANT procedure not at the outer level of its module, in a
    procedure or in a DO block (ERROR #39, INVALID ATTRIBUTE OR
    INITIALIZATION, NOT AT MODULE LEVEL), and a procedure declared in a
    REENTRANT one
    , in it or in a DO block of it (ERROR #88, INVALID
    PROCEDURE NESTING, ILLEGAL IN REENTRANT PROCEDURE); both of a REENTRANT
    procedure in a REENTRANT one (0.4.3's Known issues), and of an
    INTERRUPT, PUBLIC or EXTERNAL one, which 0.4.3 refused with #39 alone;
    and of one with no statements #174, INVALID NULL PROCEDURE, besides,
    and of a typed one #156 too (found checking 0.4.4).

  • An assignment to a built-in or a procedure (ERROR #128, INVALID
    LEFT-HAND OPERAND OF ASSIGNMENT, and #131, ILLEGAL REFERENCE TO UNTYPED
    PROCEDURE, of one without a type), as a statement's target or an
    embedded assignment's: input(1) = b, low(w) = b, b, carry = 1,
    time(1) = b, f = b of a procedure F, which uplm80 compiled to a
    store to a symbol of the name that only the link found undefined (found
    checking 0.4.4; 0.4.3 the same). Of one without as many arguments as
    it takes, V3.1's error of its arguments besides: time = 1, mon1 = 1, #154, INVALID NUMBER OF ARGUMENTS IN CALL, TOO FEW, low(w, 2) = b #153, TOO MANY, input = b #109 and last = b #124. MEMORY,
    OUTPUT and STACKPTR are assigned as before.

  • An END that names the first of two labels on a DO, m: n: do; ... end m; (ERROR #20, MISMATCHED IDENTIFIER AT END OF BLOCK): V3.1 takes
    only the label next to DO, end n; (0.4.3's Known issues).

Incompatible: V3.1's errors in a restricted expression

What a restricted expression does not take - a DATA or INITIAL value, an
AT address, a constant of a constant list .(...) (Programming Manual
9800268B, 4.1.3, 6.2.8, 6.2.9) - is refused as V3.1 refuses it, with its
errors' numbers and texts, when the parser gives the program...

Read more

uplm80 0.4.3

Choose a tag to compare

@avwohl avwohl released this 27 Sep 00:20

SHL and SHR of a BYTE are a BYTE, as the manual and Intel's PL/M-80 V3.1
make them, with a warning where what a program written for uplm80
computes changes; 80un's sources are fixed for it. The errors V3.1 gives
that 0.4.2 did not, its Known issues, are given, but for two forms
uplm80's own tests exist to test, which stay, with a warning. Messages
name the source's line after a LITERALLY over several lines, and its
column after out:end p;.

Incompatible: SHL and SHR of a BYTE are a BYTE

SHL and SHR of a BYTE are a BYTE, shifted in eight bits, as the manual
gives them the type of their pattern (11.1.4) and Intel's PL/M-80 V3.1
compiles them (0.4.2's Known issues). uplm80 zero-extended a BYTE pattern
and shifted it in sixteen bits, with an ADDRESS result: w = shl(b, 4)
with b = 0F0H was 0F00H, and is 0000H. The bits shifted out of a BYTE are
lost, a count of 8 or more leaves 0 (V3.1 shifts by the count mod 8:
README, Known differences), and the arithmetic around the shift is a
BYTE's: with c = 3 and z = 0, w = shl(c, 7) + 0ffh is 007FH and w = shr(z, 4) - 1 00FFH, where they were 027FH and 0FFFFH. A SHR of a BYTE
has the value it had. b * 16 is still SHL(DOUBLE(b), 4), and
SHL(DOUBLE(hi), 8) OR lo still builds a word in two loads. The program
in tests/test_expression_types.py prints at -O0 to -O3 what V3.1's
build of it prints.

It changes what a program written for uplm80 computes where it shifts a
BYTE and uses the bits shifted out: 80un built words with lo + shl(b, 8) and buffer addresses with shl(i, 7), and built with SHL of a BYTE a
BYTE, its 80un test.arc extracted one member of thirteen (0.4.2). 80un's
sources shift SHL(DOUBLE(x), n) where they want the bits kept, since its
branch fix/byte-shifts (80un 0.3.3, unreleased). To keep the old meaning,
write SHL(DOUBLE(x), n), which is right under any compiler.

The compiler warns where the two meanings can differ, but for the few
places Known issues lists (uplm80/byte_shifts.py): at a SHL of a BYTE that can shift a set bit out,
whose result, through what it is part of, reaches a place that uses the
bits above its low byte - a store to an ADDRESS, an ADDRESS argument or
RETURN, a subscript, a relation, / and MOD, SHR, SCL, SCR, HIGH and
DOUBLE of it, a DO CASE's selector, or an ADDRESS beside it, which such a
place then uses. Intel's PL/M-80 gives no warning.

warning: SHL(B, 4): SHL of a BYTE is a BYTE (Programming Manual
9800268B, 11.1.4), and the bits shifted out of it, which this
expression uses, are lost; SHL(DOUBLE(B), 4) keeps them. uplm80 before
0.4.3 shifted a BYTE in 16 bits

A SHL whose pattern's largest value, shifted by its count's, fits in eight
bits loses nothing: shl(dcnt and 11b, 5), shl(3, 4), shl(n, 2) after
if n > 32 then return;. A variable's largest value is what the program
assigns it anywhere, and at the SHL what the statements before it have left
it, the tests it passed and the case of a DO CASE on it included; a typed
procedure's is what its RETURNs give. That is followed for a scalar whose
address is never taken, nor AT, BASED, PUBLIC or EXTERNAL, across calls of
procedures that do not assign it. There is no warning for a SHR, nor for
BYTE arithmetic around a shift that loses nothing (shr(z, 4) - 1 above).
Of the programs checked, only CP/M 2.0's STAT in sample_code has such
arithmetic whose value the compiler cannot bound, .devr(shl(iobyte and 11b, 2) + j), whose j keeps the sum below 256. Where it can, the values
are 0.4.2's: STAT's .devr(shl(i, 4) + j), i at most 3 and j 12, and
MP/M II MPMLDR's (shr(nmb$cns - 1, 2) + 1) * 256 and the like, DRI's
and mpm2's, at most 64 before the product. The warnings, of the programs
checked:

  • 80un's sources before the fix: the 29 places the fix changed, and no
    other; its sources after it: none. tests/bug_80un.plm, 80un's old
    single-file source, which 80un keeps as src/plm/archive/80un.plm: 20,
    each of a kind 80un's fix changed.
  • MP/M II, DRI's tree and mpm2's overrides: 7, in ERA, REN, SET (2), SHOW
    (DRI's and mpm2's) and STAT, each shl(dcnt, 5) + .tbuff or the like,
    of a directory code BDOS returns, 0 to 3 or 0FFH, which the program has
    tested against 0FFH, but for SHOW: its readlbl leaves 0FFH when the
    search does not find the label getlbl reported, and shl(dcnt, 5) is
    then 0E0H, as V3.1 computes it. The compiler cannot know dcnt is below
    8, and the programs do what V3.1's builds of them do.
  • sample_code, and the programs of tests/ but those that test the
    warning and the generators' (Verified): none.

Of the 87 compiles of MP/M II's and 80un's PL/M, 24 of MP/M II's and 12
of 80un's are smaller, by 619 and 209 bytes in all at -O2.

Incompatible: more errors Intel's PL/M-80 gives

What 0.4.2's Known issues listed as compiled by uplm80 and rejected by
Intel's PL/M-80 V3.1 is refused as V3.1 refuses it, with its error's
number and text, when the parser gives the program, at every -O level.
Two forms uplm80's own tests exist to test are compiled as before, with a
warning that names V3.1's error. No program of MP/M II (DRI's tree and
mpm2's overrides), of 80un or of sample_code has any of these; the tests
whose programs had one in passing, a procedure with no statements or a
call of one declared further on, have it no more. V3.1 rejects each
program of tests/test_names.py with the error the message names
(tests/test_intel_oracle.py), and compiles the program of the forms it
takes to print what uplm80's build prints.

  • An END that names another block (ERROR #20, MISMATCHED IDENTIFIER
    AT END OF BLOCK): p: procedure; ... end q;, out: end q;, l: do; ... end m;, do; ... end n;. uplm80 took no notice of the name.

    END Q: the END of procedure P names Q; Intel's PL/M-80 V3.1 rejects
    it (ERROR #20, MISMATCHED IDENTIFIER AT END OF BLOCK)
    
  • A DO CASE with no case, do case n; end; or do case n; l: end;
    (ERROR #201, INVALID DO CASE BLOCK, AT LEAST ONE CASE REQUIRED).

  • The address of a call, .h(1) of a procedure H (ERROR #104,
    ILLEGAL PROCEDURE INVOCATION WITH DOT OPERATOR); .h is its address.

  • Anything in parentheses in a subscript of the argument of LENGTH,
    LAST or SIZE
    - a call, size(ab(h(1))), a subscript, size(ab(ab(1))),
    a built-in or a parenthesized expression, size(ab((i))) (ERROR #32,
    INVALID SYNTAX, TEXT IGNORED UNTIL ';'): V3.1 takes no such subscript,
    and uplm80, which does not evaluate the subscripts there, did not call
    h. size(ab(i + 1)), size(ab(f)) of a typed procedure and
    size(sa(i).z) are taken, as V3.1 takes them.

  • A procedure with no statements (ERROR #174, INVALID NULL
    PROCEDURE), g: procedure; declare k byte; end g;, a label on its END
    or not; uplm80 made it return.

  • An array or a member array without a subscript, but after a dot and
    as the argument of LENGTH, LAST or SIZE (3.6.2): a = 3, x = a,
    call p(a), sz(a) (ERROR #133, ILLEGAL REFERENCE TO UNSUBSCRIPTED
    ARRAY) and s.m = 4 (ERROR #134, ILLEGAL REFERENCE TO UNSUBSCRIPTED
    MEMBER ARRAY), which uplm80 took for a(0) and s.m(0). A member of an
    array of structures named without its subscript, s2.m(4), is taken
    for s2(0).m(4) as before, with a warning:
    tests/test_calls_and_loops.py tests what a store through it reaches.

    A: A is an array, and an array is named without a subscript only as
    the operand of a dot or the argument of LENGTH, LAST or SIZE
    (Programming Manual 9800268B, 3.6.2); Intel's PL/M-80 V3.1 rejects
    it (ERROR #133, ILLEGAL REFERENCE TO UNSUBSCRIPTED ARRAY)
    warning: S2.M: S2 is an array, and this is taken for S2(0).M;
    Intel's PL/M-80 V3.1 rejects it (ERROR #133, ...)
    
  • A subscript on a scalar (ERROR #127, INVALID SUBSCRIPT ON
    NON-ARRAY): x(1) is taken, as before, for the element that far past x,
    with a warning - tests/test_optimizer_soundness.py tests it - and
    shl(w, 3) of a program's ADDRESS SHL, two subscripts, which uplm80
    took for a call through SHL's value, is an error (#127, and #114,
    INVALID SUBSCRIPT, MULTIPLE SUBSCRIPTS ILLEGAL). call q(1, 2) of an
    ADDRESS q calls through it (8.2.1), as V3.1 has it.

  • A call of a procedure declared further on (ERROR #169, ILLEGAL
    FORWARD CALL): p: procedure; call q; end p; q: procedure; ..., and y = f + 1 of a typed f declared after. A REENTRANT procedure may call
    one declared after it that is REENTRANT too, as V3.1 allows and MP/M
    II's SN.PLM does, and the address of a procedure, .q, may be taken
    before its declaration, as the INITIAL lists of MP/M II's resident
    processes take theirs.

    Q: procedure Q is declared after this call of it, and a procedure is
    called only after its declaration, but by a REENTRANT procedure if
    it is REENTRANT too; Intel's PL/M-80 V3.1 rejects it (ERROR #169,
    ILLEGAL FORWARD CALL)
    

Fixed

  • The columns after a label's colon against END, out:end p; b = zz;, are the source's (0.4.2's Known issues). The front end puts a
    null statement between the labels on an END and the END, and where no
    blank follows the colon for its ; to take the place of, it put one in,
    and a message about what followed on the line gave a column one too far
    for each. A second such label on a line was not marked the end of its
    block either: do case k; ... x:end; y:end; counted y: among its
    cases.
  • A LITERALLY whose text runs over several lines no longer moves the
    lines after its use.
    The macro pass put the text in with its line
    ends, so every message about a later line named a line too far on, by
    the text's line ends at each use: MP/M II's ERA, REN and SET use
    PROCES.LIT's PROCESS$DESCRIPTOR once, whose text, with the texts it
    names, has 16 line ends, and were reported 16 lines on. The text goes
    in on one line, as a line end in it is a blank; the 87 ...
Read more

uplm80 0.4.2

Choose a tag to compare

@avwohl avwohl released this 26 Sep 16:58

uplm80 checked against Intel's own PL/M-80 V3.1 as a matter of course:
scripts/intel_oracle.py builds a program with both compilers and
compares what the builds print, and the suite runs it where Intel's
binaries are found. What it and 0.4.1's Known issues found is settled:
LENGTH, LAST and SIZE of a qualified reference, which uplm80 refused; a
store through MEMORY that a counted loop did not see; a label on an END
statement; and the errors V3.1 gives and uplm80 did not, which stay
warnings where a program written for uplm80 relies on the form. SHL and
SHR of a BYTE stay an ADDRESS, as 80un relies on them (Known issues).

Incompatible: errors Intel's PL/M-80 gives

More of what PL/M-80 does not allow, which uplm80 compiled (0.4.1's Known
issues), is refused as Intel's PL/M-80 V3.1 refuses it, when the parser
gives the program, at every -O level. What a program written for uplm80
relies on is compiled as before, with a warning that names V3.1's error:
of MP/M II's and 80un's sources, sample_code and the programs of
tests/, only the tests use any of these, and only f() of a procedure
(tests/test_implicit_calls.plm) and INITIAL in a procedure (the pytest's
programs; 80un, uplm80's own, may use it too). Every one of the 87 MP/M II
and 80un compiles, sample_code and the test programs compile to 0.4.1's
assembly.

  • A dimension of 0 is an error, of an array or of a structure's
    member, declare b (0) byte (ERROR #57, INVALID DIMENSION, ZERO
    ILLEGAL). uplm80 took it for a scalar: one byte, and a SIZE of 1.

    (0): an array has at least one element, and a dimension of 0 gives it
    none; Intel's PL/M-80 V3.1 rejects it (ERROR #57, INVALID DIMENSION,
    ZERO ILLEGAL)
    
  • The address of a built-in is an error, but MEMORY's: .double,
    .stackptr, .move, .output(3) (ERROR #123, INVALID DOT OPERAND,
    BUILT-IN PROCEDURE ILLEGAL). uplm80 compiled .double to the address
    of a symbol DOUBLE, which nothing defines, and .output(3) to a call
    of one.

    .DOUBLE: DOUBLE is a built-in, and of the built-ins only MEMORY has an
    address; Intel's PL/M-80 V3.1 rejects it (ERROR #123, INVALID DOT
    OPERAND, BUILT-IN PROCEDURE ILLEGAL)
    
  • Empty parentheses after a built-in are an error, carry(),
    zero(), dec() (ERROR #102, MISSING PRIMARY OPERAND, and #153,
    INVALID NUMBER OF ARGUMENTS IN CALL), as after a variable (0.4.1).
    After a procedure, f() and CALL g(), they are still taken for f
    and g - tests/test_implicit_calls.plm has result = callee$func(); - with a warning:

    CARRY(): CARRY is a built-in, and PL/M-80 has neither an empty
    subscript nor an empty argument list
    warning: F(): PL/M-80 has no empty argument list, and this is taken
    for F, a call with no arguments; Intel's PL/M-80 V3.1 rejects it
    (ERROR #102, MISSING PRIMARY OPERAND, and #153, INVALID NUMBER OF
    ARGUMENTS IN CALL)
    
  • A PUBLIC or EXTERNAL procedure or variable in a procedure or a DO
    block is an error
    (ERROR #39 and #73, INVALID ATTRIBUTE OR
    INITIALIZATION, NOT AT MODULE LEVEL). INITIAL there initializes the
    variable once, when the program is loaded, as before, with a warning:
    the programs of the pytest have it, and 80un may.

    X: a PUBLIC variable must be declared at the outer level of the
    module, not in procedure P; Intel's PL/M-80 V3.1 rejects it (ERROR
    #73, INVALID ATTRIBUTE OR INITIALIZATION, NOT AT MODULE LEVEL)
    warning: K: INITIAL in procedure P initializes the variable once,
    when the program is loaded, not at each entry; Intel's PL/M-80 V3.1
    rejects it (ERROR #73, INVALID ATTRIBUTE OR INITIALIZATION, NOT AT
    MODULE LEVEL)
    

    tests/test_names.py has each; V3.1 rejects each of its programs with
    the error the message names (tests/test_intel_oracle.py).

Fixed

  • LENGTH, LAST and SIZE of a qualified reference, as the manual
    allows them (11.1.2): of a structure's member, LENGTH(st.z); of a
    member of an element of an array of structures, LAST(sa(i).w), or of
    the array, LENGTH(sa.z) (partially qualified); and SIZE of an
    element, SIZE(sa(2)), SIZE(ab(2)), SIZE(st.z(1)). uplm80 took
    only a variable's name and stopped at each: "LENGTH() needs an array
    whose extent is known", "SIZE() needs a declared variable" (0.4.1 the
    same). The subscripts are not evaluated, and a LENGTH or LAST that fits
    is a BYTE, as of an array. Intel's PL/M-80 V3.1 compiles the program
    in tests/test_expression_types.py - members of structures at module
    level, in a procedure and in a REENTRANT one, and of BASED ones - to
    print what uplm80's build prints at -O0 to -O3. LENGTH or LAST of
    what is not an array - an element, a scalar member, a structure - is
    still an error, as it is to V3.1 (ERROR #125, ILLEGAL ARGUMENT FOR
    BUILT-IN PROCEDURE, and #157, INVALID ARGUMENT, ARRAY REQUIRED FOR
    LENGTH OR LAST), and so is SIZE of a subscripted scalar (#127) or of a
    member no structure has (#112). The oracle's generator no longer leaves
    them out (README, Known differences).
  • A counted loop over the last variable ends where a store through
    MEMORY sets it.
    MEMORY begins where the last variable ends, in V3.1's
    layout as in uplm80's, so p = .memory - 1 with a BASED b,
    memory(0ffffh), the subscript wrapping, and memory(k) with k =
    0FFFFH each reach the last module-level variable, or a procedure's
    static local laid out last, and a BYTE loop over it, counted in B, ran
    its count: 000B 0014 at -O0 to -O3, where Intel's PL/M-80 V3.1
    build prints 0003 0015 (Known issues, 0.4.1). A store through MEMORY
    now makes every module-level variable and static local reachable, as
    the address of a variable does (0.4.1, Fixed), where .memory is
    taken or MEMORY is subscripted by what is not a constant, or by a
    constant of 8000H or more; memory(5) runs on from the end, and a
    loop beside it is still counted. The programs in
    tests/test_calls_and_loops.py print, at -O0 to -O3, what Intel's
    build of each prints. The 87 MP/M II and 80un compiles, MP/M II's ED
    and STAT among them, which take .memory and subscript MEMORY by a
    variable, compile to 0.4.1's assembly at -O0, -O2 and -O3.
  • A label on an END statement, out: end p;, as a label may prefix
    any statement (Programming Manual A.4.4.1); it was a syntax error
    (Known issues, 0.4.1). The grammar takes a label only on a statement a
    block holds, so the front end puts a null statement between the labels
    and the END, in place of the blank after the colon where there is one,
    and a GOTO to it goes where Intel's PL/M-80 V3.1 goes: on to the next
    step of an iterative DO and the next test of a DO WHILE, and out of a
    DO, a DO CASE - whose cases it is not one of - and a procedure. The
    program in tests/test_calls_and_loops.py prints, at -O0 to -O3,
    what V3.1's build of it prints. No program of MP/M II, 80un,
    sample_code or tests/ has one; each compiles as before.

Added

  • scripts/intel_oracle.py, a differential test with Intel's PL/M-80
    V3.1 as the oracle
    (README, Testing against Intel's PL/M-80). It
    builds a program the way DRI's P.SUB built its CP/M programs - PLM80,
    LINK with X0100 and PLM80.LIB, LOCATE, OBJCPM - and with uplm80 at
    -O0 to -O3, runs every build under cpmemu, and says whether each
    level prints what Intel's build prints; --random N checks programs of
    tests/plm_intel.py, a generator of programs in the dialect both
    compilers share, --corpus the programs of tests/ and sample_code/,
    and --reduce cuts a difference down to the lines it needs. Intel's
    binaries are not in the repository: the oracle finds them on DRI's MP/M
    II work disk, or through $PLM80_TOOLS, and runs them on
    tools/isis, a small ISIS-II emulator on cpmemu's qkz80 core (make -C tools/isis), or on romwbw_emu's tools/romwbw-plm80.
  • tests/test_intel_oracle.py, in the suite: generated programs, a
    program of tests/, and the programs of this release's tests whose
    output is transcribed from Intel's build, each built by both compilers.
    Without Intel's binaries - as on CI - it skips, building nothing.

Known issues

uplm80 still compiles these, which Intel's PL/M-80 V3.1 rejects (0.4.1
the same):

  • f() and CALL g() of a procedure, taken for f and g, with a
    warning (ERROR #102, MISSING PRIMARY OPERAND, and #153, INVALID NUMBER
    OF ARGUMENTS IN CALL; Incompatible).
  • A subscript on a scalar, x(0) or x(1), the byte at X's address
    plus the subscript (#127, INVALID SUBSCRIPT ON NON-ARRAY); and shl(w, 3) where the program declares SHL an ADDRESS, a call through SHL's
    value (#127, and #114, MULTIPLE SUBSCRIPTS ILLEGAL).
  • An array, or an array member, without a subscript anywhere but in a
    location reference or LENGTH, LAST and SIZE (3.6.2): a = 3 and x = a are a(0), s.m = 4 is s.m(0), s2.m(1) of an array of
    structures is s2(0).m(1), and size(a), SIZE an array of the
    program's, is size(a(0)) (#133, ILLEGAL REFERENCE TO UNSUBSCRIPTED
    ARRAY, and #134, ILLEGAL REFERENCE TO UNSUBSCRIPTED MEMBER ARRAY).
  • INITIAL in a procedure's declaration, or a DO block's, which
    initializes the variable once, when the program is loaded, with a
    warning (#73, INVALID ATTRIBUTE OR INITIALIZATION, NOT AT MODULE LEVEL;
    Incompatible).
  • A procedure with no statements, g: procedure; end g;, which returns
    (#174, INVALID NULL PROCEDURE).
  • A call of a procedure that its block declares after the call, p: procedure; call q; end p; q: procedure; ... end q;, and y = f + 1
    of a typed procedure f declared after it (#169, ILLEGAL FORWARD
    CALL).
  • These four, which 0.4.2's release check found, each rejected by V3.1
    with the error named: an END that names another block, p: procedure; ... end q; or out: end q; (#20, MISMATCHED IDENTIFIER AT END OF
    BLOCK); a DO CASE with n...
Read more

v0.4.1

Choose a tag to compare

@avwohl avwohl released this 26 Sep 14:20

The Known issues 0.3.7 listed, and 0.4.0 carried, each settled by the
Programming Manual (9800268B) and, where it leaves room, by what Intel's
PL/M-80 V3.1 does with the same source: its listing, its diagnostics,
and the code it generates, linked with DRI's X0100 and run. Four of
them were code the compiler got wrong, four were programs it should
have refused; one is PL/M-80's own rule, one a test's wrong
expectation, and the others were fixed by 0.4.0, upeepz80 0.2.6 and
um80 0.3.51. Checking them against V3.1 found three more kinds of
program to refuse - a parameter no DECLARE declares, a LITERALLY used
before its declaration, a dimension that is not a number - and two more
cases of two of the four: a store that runs back to a counted loop's
index, and a built-in's name another module of a multi-file compile
makes PUBLIC. What V3.1 rejects and uplm80 still compiles is listed
under Known issues.

Incompatible: errors Intel's PL/M-80 gives

A program PL/M-80 does not allow, which uplm80 compiled, is now refused
as Intel's compiler refuses it. These rules of a program's names are
checked as the parser gives the program, before the optimizer rewrites
or drops anything, so every -O level finds the same errors; a
multi-file compile parses and checks every module before it optimizes
any.

  • A name declared nowhere is an error, as it is to Intel's PL/M-80
    V3.1 (ERROR #105, UNDECLARED IDENTIFIER). y = nosuch + 1 compiled to
    ld hl,(NOSUCH), and only um80 reported it, as an undefined symbol, or
    nothing did where the optimizer dropped the use (Known issues, 0.3.7;
    0.3.6 the same). A built-in needs no declaration, and in a multi-file
    compile a module still names another's PUBLIC name without declaring it
    EXTERNAL, unless it is a built-in's name, which is the built-in (Fixed).

    NOSUCH is not declared (Programming Manual 9800268B, 6.1)
    

    Of the 87 compiles of MP/M II and 80un, the ten that did not assemble,
    for this reason, now stop here: MP/M II's MSCMN.PLM, which
    MSBRS.PLM and MSRSP.PLM include after declaring what it uses, and
    eight of 80un's modules compiled alone, which name each other's
    procedures (80un compiles them together).

  • A parameter that no DECLARE of its procedure declares, or that one
    declares as anything but a BYTE or an ADDRESS scalar, is an error
    :
    "Each formal parameter must be declared as a non-based scalar variable
    in a DECLARE statement preceding the first executable statement in the
    procedure body" (8.1.1). A parameter that only the PROCEDURE statement
    names was an ADDRESS: p: procedure (a, b); declare a byte; y = a + b; end p; stored b with ld (??AUTO+1),de and added it as one, and with
    a declared only in a DO block of the procedure, that block's y = a
    read the block's own variable, which nothing set. A parameter declared
    an array, BASED, a LABEL or a structure, or with PUBLIC, EXTERNAL,
    INITIAL, DATA or AT, was compiled as declared, and a second declaration
    of one was taken without a word (0.4.0 the same). Intel's PL/M-80 V3.1
    rejects each: ERROR #25, UNDECLARED PARAMETER (and #105, UNDECLARED
    IDENTIFIER, at a use of it); #76, CONFLICTING ATTRIBUTE WITH
    PARAMETER; #77, INVALID PARAMETER DECLARATION, BASE ILLEGAL; #79,
    ILLEGAL PARAMETER TYPE, NOT BYTE OR ADDRESS; and #78, DUPLICATE
    DECLARATION. An EXTERNAL or a REENTRANT procedure's parameters are
    declared too, as V3.1 asks.

    B is a parameter of P, and no DECLARE of the procedure declares it; a
    parameter is declared a BYTE or an ADDRESS scalar, not BASED, by a
    DECLARE of its procedure (Programming Manual 9800268B, 8.1.1)
    A is a parameter of P, and a parameter is declared a BYTE or an
    ADDRESS scalar, not BASED and with no other attribute (Programming
    Manual 9800268B, 8.1.1)
    

    None of the 87 MP/M II and 80un compiles, sample_code, the test
    programs and intel80tools' 469 PL/M files has one.

  • A LITERALLY's name used before its declaration, and a dimension that
    is not a number, are errors.
    A LITERALLY's text is "substituted for
    each occurrence of the identifier in subsequent text" (6.4), and uplm80
    put it in place of a use that comes before the declaration too: p: procedure; y = lit; end p; declare lit literally '5'; compiled to y = 5, and so did such a use in a DO CASE or in a procedure nested in the
    one declaring lit. A dimension "is a numeric constant in parentheses"
    (6.2.5), and declare a (lit) byte before lit's declaration made a
    a scalar, as did a dimension that names a variable, a LITERALLY out of
    its scope or a name declared nowhere, of an array or of a structure's
    member (0.4.0 the same). Intel's PL/M-80 V3.1 rejects each: ERROR #105,
    UNDECLARED IDENTIFIER, and #59, ILLEGAL DIMENSION ATTRIBUTE. A variable
    that a procedure names and an enclosing block declares after it is
    still that variable, in both compilers.

    LIT is not declared here: a LITERALLY declared after it puts its text
    in place of LIT only in the text that follows the declaration
    (Programming Manual 9800268B, 6.4)
    (LIT): the dimension of an array is a number, and LIT is not a
    LITERALLY declared before it whose text is one (Programming Manual
    9800268B, 6.2.5)
    

    None of the 87 MP/M II and 80un compiles, sample_code, the test
    programs and intel80tools' 469 PL/M files has one.

  • Empty parentheses after a variable, x(), after a structure member,
    s.m(), and after a subscript, a(1)(), are an error.
    PL/M-80 has
    no empty subscript or argument list. y = x() + 1 with x a BYTE compiled
    to a CALL through x's value (0.3.6: call X), and so did an array, a
    BASED variable, a structure, a parameter and CALL w() of an ADDRESS
    (Known issues, 0.3.7); y = s.m() compiled to ld a,(S) / ld l,a / ld h,0 / call ??jphl, a call through the member's value, and w = s.a(), y = sa(1).m() and CALL s.a() the same, and y = a(1)() and
    y = q(1)() called through the element's value and through what q(1)
    returned (0.4.0 the same). Intel's PL/M-80 V3.1 rejects each: ERROR #127,
    INVALID SUBSCRIPT ON NON-ARRAY, and #102, MISSING PRIMARY OPERAND, in
    an expression after a scalar, a parameter or a BASED variable, and after
    a structure with #135, ILLEGAL REFERENCE TO AN UNQUALIFIED STRUCTURE;
    #102 alone after an array or an array member, and in CALL w() and
    CALL s.a(); #127 and #32, INVALID SYNTAX, after a scalar member in an
    expression; and #32 after a subscript (with #118 in CALL a(1)(), and
    #135 in sa(1)()).

    X(): X is a variable, and PL/M-80 has neither an empty subscript nor
    an empty argument list
    SA(1).M(): SA(1).M is a structure member, and PL/M-80 has neither an
    empty subscript nor an empty argument list
    

    A procedure's f() is still taken for f, as uplm80 always has; V3.1
    rejects that too (#102).

  • .label, the address of a label, in an expression is an error. The
    dot operator takes a variable or a procedure (4.1.3), and Intel's
    PL/M-80 V3.1 rejects .label in an expression, ERROR #158, INVALID DOT
    OPERAND, LABEL ILLEGAL, whether or not the label is declared LABEL and
    whether it is defined before the expression or after; it accepts one in
    a DATA or an INITIAL list, and so does uplm80, as before (MP/M II's
    MPMLDR begins DATA (0C3H, .start-3)). uplm80 compiled the expression to
    the label's address (Known issues, 0.3.7; 0.3.6 the same).

    .HERE: HERE is a label, and the dot operator takes a variable or a
    procedure (Programming Manual 9800268B, 4.1.3); the address of a
    label may be given only in a DATA or an INITIAL list
    
  • An INTERRUPT procedure nested in a procedure, or declared in a DO
    block, is an error
    , as it is to Intel's PL/M-80 V3.1 (ERROR #39,
    INVALID ATTRIBUTE OR INITIALIZATION, NOT AT MODULE LEVEL): "it may only
    be used in a PROCEDURE statement at the outer level of a program
    module" (8.1.6). uplm80 compiled a nested one, and a local of the
    procedure around it that the interrupt read could be in ??AUTO, in
    another procedure's frame (Known issues, 0.3.7; 0.3.6 the same).

    IH: an INTERRUPT procedure must be declared at the outer level of the
    module, not in procedure OUTER (Programming Manual 9800268B, 8.1.6)
    

Fixed

  • A procedure or a variable named like a built-in is the program's, as
    a declaration hides the built-in of its name (9.2), and as Intel's
    PL/M-80 V3.1 compiles it. The optimizer wrote an ADDRESS constant below
    256, and a value it widened to ADDRESS, as a call of DOUBLE, and every
    call of DOUBLE of a constant was taken for one: with a procedure DOUBLE
    of the program's, double(30h) was 30H at -O1 and up however the
    procedure was written (Known issues, 0.3.7). The optimizer's DOUBLE is
    now called by a name no program can declare, ??DOUBLE. And wherever
    the optimizer or code generation knew a built-in by its name alone, it
    now also checks that the program does not declare the name there. These
    were wrong too (0.3.6 the same): a DOUBLE or LOW of the program's in a
    condition or in a DO's bound was folded as the built-in, at every level;
    w * 8 and w / 2 became calls of the program's SHL and SHR at -O2
    and -O3; an array OUTPUT or MEMORY was stored to as the port, or as
    memory past the end of the program, and .memory of one was the end of
    the program, and a variable STACKPTR was SP, at every level. A program
    that declares no built-in's name compiles to the code 0.4.0 compiles it
    to: the 87 MP/M II and 80un compiles, and 300 random programs and the
    test programs, at -O0 to -O3.

    In a multi-file compile, the other way round: a module that does not
    declare a built-in's name means the built-in, as it does compiled alone
    and linked, though another module makes a procedure or a variable of
    that name PUBLIC (10.4). With module MA's `shl: procedure (a, b) addres...

Read more

v0.4.0

Choose a tag to compare

@avwohl avwohl released this 26 Sep 01:54

Procedures are now called the way Intel's PL/M-80 calls them, so code
uplm80 compiles links, unmodified, with assembly written for PL/M-80 -
Digital Research's X0100.ASM (mon1 equ 0005h), MP/M II's LDMONX.ASM
(ldmon1 equ 0d06h) and BRSPBI.ASM - and with objects PL/M-80
compiled. Up to 0.3.x no uplm80 module did: each of the three conventions
it had differed from Intel's, and every program linked with DRI's
interface modules needed a shim that turned one into the other.

The convention is PL/M-80 V3.1's as its own output shows it: DRI's
PIP.PRL, which PL/M-80 compiled, has MOVE: PROCEDURE (S, D, N) at
0AACH,

LXI H,244EH / MOV M,E        ; N, the last argument, from E
DCX H / MOV M,B / DCX H / MOV M,C    ; D, the one before, from BC
DCX H / POP D                ; the return address
POP B / MOV M,B / DCX H / MOV M,C    ; S, pushed by the caller
PUSH D

and V3.1's listings of test modules, and byte-for-byte rebuilds of DRI's
utilities with Intel's compiler, agree.

Incompatible: calling convention

Rebuild every module. A module built by 0.3.x does not work with one
built by 0.4.0, and nothing at link time says so: they export and import
the same names.

Arguments Where they are at the call
0 nothing
1 a1 in BC (C for a BYTE parameter)
2 a1 in BC (C), a2 in DE (E)
n ≥ 3 a1 … a(n−2) pushed left to right, one word each; a(n−1) in BC (C); an in DE (E)
  • The callee takes the pushed words off the stack. The caller no
    longer pops anything after a call. At entry [SP] is the return
    address, [SP+2] a(n−2), and so on to [SP+2(n−2)], a1.

  • A BYTE argument in a register is in C or E, and B or D is undefined; a
    pushed BYTE is the low byte of its word.

  • A BYTE result is in A and an ADDRESS one in HL, as before.

  • A call keeps SP, IX and IY, and nothing else: A, the flags, BC, DE and
    HL are destroyed.

  • This is so for every procedure - PUBLIC, EXTERNAL, nested, REENTRANT -
    but one exception. A procedure with one parameter that nothing outside
    the compile can reach - not PUBLIC, EXTERNAL or REENTRANT, and its
    address never taken - still takes it in A (a BYTE) or HL (an ADDRESS),
    where its body wants it. No other module, no assembly and no CALL
    through an address can tell.

  • A CALL through an address places the arguments the same way, each
    widened to ADDRESS, with the address in HL, and calls ??jphl (jp (hl)), which replaces ??jpde.

  • MON1(f, a) and MON2(f, a) with a constant f are still compiled as
    the BDOS call itself, ld de,a / ld c,f / call 5, and the argument is
    converted to the parameter's type like any other: a BYTE passed to
    MON1's ADDRESS parameter is now ld e,a / ld d,0, where D was left as it
    happened to be. PL/M-80 does the same (MP/M II's MPMLDR at 03D1H: LHLD char / MVI H,0 / XCHG / MVI C,2), and a function that reads DE whole,
    such as MP/M II's 141 (delay), needs it.

  • Two new errors. A direct call must pass as many arguments as the
    procedure has parameters, as PL/M-80 V3.1 requires (153 and 154): with
    the callee removing the pushed words, a call with too many or too few
    would return with the stack moved. 0.3.x dropped extra arguments to a
    procedure private to its module without a word. A CALL through an
    address is not checked (8.2.1). And an INTERRUPT procedure may not have
    parameters (8.1.6).

    invalid number of arguments in call of P2, too few: 1 for 2 parameters
    IH: an INTERRUPT procedure may not have parameters (8.1.6)
    
  • upeepz80 0.2.6 or later is required. 0.2.5 turned push … / call p / ret into push … / jp p, and p then took its return address for its
    first argument. At -O1 and up the compiler now stops with an error
    naming both versions if upeepz80's is below 0.2.6, unless that
    upeepz80 keeps the call of such a routine: a development tree with the
    fix, still numbered 0.2.5, does, and the release 0.2.5 does not.

    upeepz80 0.2.5 is too old: uplm80 needs upeepz80 0.2.6 or later (…)
    

What 0.3.x did: a procedure private to its module had all but its last
argument written straight into its own storage by the caller and the last
in A or HL; a PUBLIC, EXTERNAL or REENTRANT one had every argument pushed,
left to right and each widened to 16 bits, and popped by the caller after
the call; a CALL through an address passed only one, except to a PUBLIC
or REENTRANT procedure.

An assembly routine written for 0.3.x changes like this:

A 0.3.x assembly routine… …becomes in 0.4.0
read its one argument at SP+2; the caller popped it reads BC (C for a BYTE); pops nothing
read two at SP+4 and SP+2 reads BC and DE
read n ≥ 3 at SP+2n … SP+2 pops the return address, pops the n−2 stacked words (last pushed first), takes BC = a(n−1) and DE = an, and puts the return address back
returned with its arguments still pushed returns with the stacked words removed

For example, the BDOS interface a CP/M program links with. MON1, MON2,
MON2A and MON3 are equates now, as in DRI's X0100.ASM, since a call
already has the function in C and the argument in DE:

; 0.3.x                                 ; 0.4.0
MON1:   ld      hl,2                    MON1    equ     5
        add     hl,sp                   MON2    equ     5
        ld      e,(hl)                  MON2A   equ     5
        inc     hl                      MON3    equ     5
        ld      d,(hl)                          public  MON1,MON2,MON2A,MON3
        inc     hl
        ld      c,(hl)
        jp      5

and a routine of three arguments, cap3(a address, b byte, c address):

; 0.3.x: a, b, c pushed; the caller pops them
CAP3:   ld      hl,2
        add     hl,sp
        ld      e,(hl)          ; c
        inc     hl
        ld      d,(hl)
        ld      (VC),de
        inc     hl
        ld      a,(hl)          ; b
        ld      (VB),a
        inc     hl
        inc     hl
        ld      e,(hl)          ; a
        inc     hl
        ld      d,(hl)
        ld      (VA),de
        ret

; 0.4.0: a pushed, b in C, c in DE; CAP3 takes a off the stack
CAP3:   ld      (VC),de
        ld      a,c
        ld      (VB),a
        pop     hl              ; the return address
        ex      (sp),hl         ; a, and the return address back on top
        ld      (VA),hl
        ret

Assembly that calls a PL/M procedure does the same from the other side:
it pushes the first arguments, loads the last two into BC and DE, and
leaves the stack alone after the call.

Changed

  • Smaller code. Over MP/M II's PL/M (UTIL2 to UTIL7 and MPMLDR, 39
    modules, SDIR's eight included) and 80un's two programs, at -O2 with
    upeepz80 0.2.6, the code is 111,219 bytes against 0.3.7's 113,528
    (−2,309), and no module is larger. A pushed argument costs one push
    where 0.3.x stored it into the callee's slot, the entry stores it once,
    and the A/HL exception saves the ld c,a or ld b,h / ld c,l every
    call of a one-parameter procedure would otherwise need (about 1,300
    bytes of it). The data is 36,526 bytes against 36,531: nothing is stored
    before a call, so the call graph no longer keeps a callee's frame apart
    from the procedures its arguments call.
  • A procedure's entry stores its arguments (the last from DE, the one
    before from BC, the pushed ones popped). With one or two parameters it
    leaves BC and DE as they came, so DRI's CP/M 1.x MON1: PROCEDURE (F, A); … GO TO BDOS; END MON1; passes them on to the BDOS.
  • A REENTRANT procedure pushes the arguments that came in BC and DE under
    its return address, which is the frame 0.3.x had, and every exit takes
    all of them off the stack, keeping A and HL.
  • A GOTO out of a procedure can now abandon, besides the return addresses
    of the calls it leaves, the words pushed for a call whose arguments were
    being evaluated: the first arguments, and BC, kept round the last one.
    call p3(1, 2, f), where f ends in goto again, leaves two. The
    label at the outer level of the main program that such a GOTO reaches
    sets SP again, as it does since 0.3.7, and that takes them off too: 1000
    such GOTOs run in -m bare's 64-byte stack, out of an argument of a
    direct call, of a CALL through an address and of a REENTRANT
    procedure's callee (tests/test_goto_stack.py). A GOTO to a label in a
    DO block of the main program, which draws a warning, leaves them, as
    Intel's PL/M-80 does.
  • STACKPTR in a call's arguments reads SP with the arguments pushed for
    the call so far, as in PL/M-80's code. After sp0 = stackptr, call p5(1, 2, 3, 4, stackptr - sp0) passes 0FFFAH, three words down, and
    call p2(4, stackptr - sp0) passes 0, as PL/M-80 V3.1's code does;
    0.3.7 passed 0 to both, p5 and p2 being private. BC, the next-to-last
    argument, is saved round the last one's code only where that may write
    B or C: round a call of a procedure, ??mul16, ??div16, ??mod16 or
    ??inp, and not of ??subde, which leaves BC as it is. The two
    compilers still differ in two cases. V3.1 loads a next-to-last argument
    that is a constant or a variable into BC after the last one's code, and
    so saves nothing round it: with one = 1, `call p2(4, (stackptr - sp0)
    • one)passes 0 there and 0FFFEH here. And it pushes a next-to-last argument it has computed while it evaluates the last:call p2(sp0 -
      stackptr, stackptr - sp0)` passes 0FFFEH there and 0 here.
  • A call's arguments are evaluated from left to right. PL/M-80 V3.1 loads
    a next-to-last argument that is a variable into BC after it has
    evaluated the last one, so where the last argument's code changes that
    variable (call p2(v, f), with f assigning v), its code passes the
    new value and uplm80's the old one. The language leaves this open: "PL/M
    does not guarantee the order of evaluation of operands", and where the
    order matters "the value of the expression is undefined" (9800268B,
    4....
Read more

v0.3.7

Choose a tag to compare

@avwohl avwohl released this 25 Sep 22:40

Two sets of fixes, each checked against what Digital Research's own PL/M-80
does, and a program layout that is Intel's.

The first began with six defects found while rebuilding MP/M II's resident
system processes from DRI's sources, each worked around in those sources until
now; three more turned up in the same code, and an independent verification of
those fixes found the rest. DRI's binaries settle what is right: the
SPOOL.RSP, SCHED.RSP and MPMSTAT.RSP built from source now match DRI's in
layout and in every initialised byte, and each resident process's stack holds
what DRI's SCHED.BRS holds.

The second makes division, MOD and every other expression give what DRI's
PL/M-80 gives. Division and MOD agree with DRI's divide routine for every
operand pair, zero divisors included, on every path uplm80 computes them by:
the runtime routines, constant folding, strength reduction and DATA/INITIAL
values. tests/test_divmod_dri.py runs DRI's own routine on an 8080
interpreter as the reference and compares a compiled table of divisions
against it at -O0 to -O3. Every expression now has the value and the type
Intel's PL/M-80 Programming Manual gives it, at every optimization level: a
constant up to 255 is a BYTE; + - AND OR XOR of two BYTEs and - or NOT
of one wrap at eight bits; * / MOD are ADDRESS; a relation is the BYTE 0FFH
or 0. The optimizer folded constants as untyped 16-bit numbers that code
generation then typed by magnitude, so arithmetic next to a folded, propagated
or rewritten operand could change width. uplm80/plm_types.py states the
rules once, the optimizer and the code generator follow them, and
tests/plm_difftest.py checks random programs against a Python model of them.
DO loops now end the way DRI's end, when the increment carries out of the
index, and are laid out as DRI lays them out.

The layout puts a program's variables last, after its code, its constants,
the procedures' shared locals and the stack, as Intel's PL/M-80 does (see
Changed). DRI's programs use everything past their last variable as a
buffer, and MP/M II's SUBMIT and SPOOL now build from DRI's own sources and
behave as DRI's binaries do.

A procedure's variables are static, as the manual has them, its parameters
included, except where no program can tell: a local or a parameter shares
the procedures' overlaid storage only if every call assigns it before
anything reads it, and only where no pointer or overrun from another local
can tell it from DRI's layout (see Changed).

Every name means the declaration PL/M-80 gives it (uplm80/names.py):
labels, procedures and LITERALLYs of one name in different blocks, and in a
multi-file compile each module's private names, are kept apart; a GOTO that
PL/M-80 does not allow is an error; and a CALL through an address calls the
procedure. Every warning and error names the file and line it is about.

Each fix has a regression test that fails without it.

Fixed

Procedure locals

  • A local without INITIAL did not keep its value from one call to the
    next.
    PL/M-80 allocates a procedure's variables statically (Programming
    Manual, 8.1.7); uplm80 put every uninitialised local in ??AUTO, overlaid
    on the locals of procedures never active at the same time, so a count, a
    first-time flag or a position kept in one came back as another procedure
    had left it: tick: procedure address; declare (count, seen) address; if seen <> 1234h then do; seen = 1234h; count = 0; end; count = count + 1; return count; end tick;, called in a loop with another procedure that
    has locals of its own, returned 1 every time, at every level (the
    integration verification's F6; 0.3.6 the same). Such a local is static
    now (see Changed). DRI's code counts on it: MP/M II's PIP, retrying a
    multi-file copy after an error, calls MULTCOPY again, which goes on from
    the directory entry and the count it keeps in NEXTDIR and NCOPIED
    (if eretry = 0 then NEXTDIR, NCOPIED = 0); both are static.

  • A pointer to a parameter, kept after the call, pointed into storage that
    other procedures overlay.
    PL/M-80 allocates a procedure's parameters
    statically, like its other variables, but uplm80 kept every parameter in
    ??AUTO because every call assigns it. After sv: procedure (v); declare v byte; keep = .v; end sv;, the sequence call sv('P'); call other; read
    0FFH (other's locals) through keep, where DRI's code reads 'P' (0.3.6
    the same). A procedure whose address is taken also read a parameter of the
    procedure it is nested in out of ??AUTO after that procedure had returned.
    A parameter is now static by the same rules as any other local (see
    Changed).

  • A pointer or an overrun from a local reached something other than what
    DRI's layout has there.
    DRI lays out what a procedure's text declares in
    the order the text declares it (see Changed). uplm80 kept a frame's locals
    in ??AUTO apart from three things: the parameters and locals of procedures
    nested among them, the variables of the procedure's DO blocks, and its
    INITIAL locals, which were static (0.3.6 the same). Examples:

    • with declare arr (2) byte before a nested inner: procedure (v) byte
      and declare nxt byte after it, arr(2) = inner('I') set nxt instead
      of v;
    • with arr INITIAL, arr(n) = 'F' did not reach the local declared after
      it, and neither did .v + 1 with v INITIAL;
    • a read of arr(2) did not see what the previous call had left in nxt.

    These now reach what DRI's layout has there.

  • An INTERRUPT procedure's frame was put over the frames of the procedures
    it interrupts.
    ??AUTO overlays the frames of procedures that are never
    active at the same time, and the call graph decides which those are. Nothing
    calls an INTERRUPT procedure: the interrupt activates it (8.1.6), whatever
    is running. So ih: procedure interrupt 7; declare (x, y) byte; ... call helper; end ih; shared its frame with work, which ih may interrupt, and
    so did helper (0.3.6 the same). An INTERRUPT procedure and everything it
    calls are now active together with every procedure, and their frames overlap
    none.

  • A procedure called through an address, or called back from outside the
    module, shared its frame with its caller.
    A CALL through an address
    (8.2.1) may call any procedure whose address is taken. An EXTERNAL procedure
    may call back any PUBLIC procedure, or any procedure whose address it was
    given. The call graph had none of those calls. back called an EXTERNAL
    ext, which called the PUBLIC cb; cb's frame was back's, and back's
    local came back 0FFH at every level. The same happened to through, which
    passed the address of cb2 to an EXTERNAL icall (0.3.6 the same). A
    procedure with a CALL through an address may now call every procedure
    whose address is taken, and an EXTERNAL procedure may call back every PUBLIC
    procedure and every procedure whose address is taken, whether the address is
    taken in the main program or in a procedure. A call of MON1 or MON2 with a
    constant function is a call of the BDOS, which calls nothing back. A CALL
    through an address now calls the procedure, too (see Names and labels):
    CALL f from caller to a procedure that fills its frame with 0FFH leaves
    caller's locals as they were.

  • A parameter reached only through the address of the parameter before it
    lost its value at -O1 and up.
    upeepz80 drops the store of the last
    argument at a procedure's entry when nothing else in the module names the
    parameter's storage. So pq: procedure (a, b) byte; declare (a, b) byte; ... pp = .a + 1; return c; (with c BASED on pp) returned 0 for pq('A', 'B'). 0.3.6 did the same whenever no other procedure happened to name that
    slot in ??AUTO. Each static parameter is now also named by an EQU, which
    costs nothing and which upeepz80 counts as a use. The rule itself belongs to
    upeepz80.

  • An embedded assignment was not stored when the procedure returned its
    target next.
    RETURN took the value from A instead, even though the rest of
    the statement could change A and the target has to keep its value. MP/M II's
    LOAD reads a HEX file through READCS: PROCEDURE BYTE; DECLARE B BYTE; CS = CS + (B := READBYTE); RETURN B;, which returned CS + B, so LOAD built from
    source stopped with INVERTED LOAD ADDRESS on the first record of any file.
    With v static, old = v; old = (v := old + 1); return v; returned 1 on
    every call (0.3.6 the same for both). The store is now always made. LOAD
    built from source now produces, from a test HEX file, the same .COM as DRI's
    LOAD.COM: under MP/M II, and in BARE mode under cpmemu at -O0 to -O3. ED's
    GETSOURCE is 6 bytes longer.

  • A counted loop left its index with a value PL/M-80 would not give it. A
    BYTE DO i = 0 TO n whose body does not name i counts its passes in B. It
    gives i its final value up front only if something may read i, and it
    allows a RETURN from the body when i is the procedure's own. Two things
    went wrong (0.3.6 the same):

    • a static i keeps its value until the next call, which read the final
      value (10) where a RETURN in the third pass leaves 2;
    • with declare arr (2) byte, i byte, arr(2) read 0 after the loop
      instead of 10.

    A loop is no longer counted when its index can be reached without naming it,
    or when the index is static and the body can RETURN.

Division and MOD

  • x MOD 0 was 0; PL/M-80 gives x. DRI's PL/M-80 sends every / and
    MOD through one routine, module @P0029 of its PLM80.LIB (the same 31 bytes
    sit at 39B0H in MP/M II's SDIR.PRL, and in DIR, ED, STAT, SHOW, TOD, SCHED,
    MPMSTAT, GENSYS, LINK and LIB). It has no zero test: sixteen
    shift-and-subtract steps, in which a zero divisor always fits, so the
    quotient comes out 0FFFFH and the remainder is the dividend. ??div16
    tested for zero and returned a remain...
Read more

uplm80 0.3.6

Choose a tag to compare

@avwohl avwohl released this 24 Sep 07:07

Found by building every PL/M program in Digital Research's MP/M II sources and
running each one next to DRI's own binary on the same disk, command by command,
until the two printed the same thing. Adds an MP/M runtime mode. Each fix has a
regression test that fails when it is reverted, and 80un's 80un.com and
80unbas.com still rebuild byte-identical.

Requires upeepz80 0.2.4, whose dead-store elimination deleted the store in
var = (a = b).

Added

  • -m mpm, for MP/M II .PRL/.RSP/.SPR modules. MP/M gives each
    process a memory segment and puts its page zero at the segment's base, so the
    BDOS entry, the stack-top pointer at 0006H and the warm-boot jump have to be
    relocated when the program loads. Only a resolved symbol reference reaches a
    .PRL relocation bitmap, so MP/M mode emits them as the externals ??BDOS,
    ??MAXB and ??BOOT rather than literals (link with a module that defines
    them at 0005H, 0006H and 0000H, and with ul80 --prl, which relocates
    page-zero symbols). This is how DRI's PL/M-80 got the same effect:
    PLM_WORK/X0100.ASM and X0200.ASM publish the same names at different
    offsets and GENMOD diffed the two links. The names carry the compiler's ??
    prefix because a PL/M identifier cannot contain ?, and something collides
    otherwise: SDIR declares a variable called bdos. MP/M mode sets SP with the
    single three-byte ld sp,??STACK over a 512-byte stack in the image, because
    DRI's sources enter themselves by a jump to .start-3. CP/M and bare modes
    are unchanged.

Fixed

  • A PUBLIC procedure took its arguments the way a private one does. A
    procedure private to its module is called with the earlier arguments already
    written into its own storage and only the last in a register; a caller in
    another module cannot name that storage. A public procedure now takes all its
    arguments on the stack. SDIR's pdecimal(v, prec, zerosup) read two of its
    three arguments from slots nobody had written.
  • AT(.MEMORY) was not the end of the program. It named a label at the
    end of the module — the middle of a multi-module program — and was emitted
    as an EQU, which reads as zero above its own declaration. It is now a label
    beside the linker's __END__, with the EXTRN ahead of the EQU that uses
    it. SDIR's 128-entry hash table first cleared page zero, then another
    module's strings.
  • AT(...) understood only a bare NAME(<literal>). A constant
    expression, NAME(const), STRUCT.MEMBER or a chain of them fell through to
    EQU $, the assembler's location counter. STAT read a stray byte as its $
    parameter and set a file read-only instead of listing it; PIP
    (DESTR ADDRESS AT(.DEST.FCB(33))) and PRLCOM were miscompiled the same way.
    An AT that cannot be resolved is now an error. AT(.name) uses EQU rather
    than SET, and AT(.external) emits the EQU even when a reference comes
    first.
  • A STRUCTURE initialiser was emitted at one width. It gives one value per
    member, each at the member's own width; whatever the list does not fill is
    now reserved. SDIR's ten-byte parser control block came out as five bytes of
    zero. A value the emitter could not place was dropped silently and is now an
    error; .name(n) is placeable.
  • x BASED s.m read its pointer from the start of s. The member was
    parsed and dropped. SDIR matched every command-line argument against
    address 0 and answered "File Not Found."
  • DECLARE x (*) BYTE DATA (...) had no extent. LAST(x) was -2, so PIP
    never searched its delimiter table and answered "INVALID FORMAT" to every
    command.
  • A nested procedure's return type was not known where it is used. Its
    symbol is filed under its scoped name and the lookup searched only the top
    level, so a BYTE result was read out of L instead of A. LENGTH,
    LAST and SIZE used the same lookup; where they cannot answer they now
    raise instead of emitting zero.
  • A variable BY step was treated as BY 1. Only a literal step was read.
    SDIR walks an FCB disk map BY i, and counted every block twice on a disk
    with word block numbers.
  • A declared variable did not shadow a condition-flag built-in. CARRY,
    ZERO, SIGN and PARITY are ordinary words a program may declare; STAT's
    zero-suppression flag zero read the Z flag. STACKPTR deliberately stays a
    built-in, since assigning to it sets SP.
  • A callee's frame was reused while its own arguments were evaluated. The
    overlay analysis let a procedure called from a later argument share storage
    with an earlier argument already stored, so call f(7, g) could destroy the
    7. Bites at the default -O2.
  • A procedure-local STRUCTURE was sized as two bytes. The next procedure's
    frame was overlaid inside it. -O2.
  • The target of an embedded assignment was folded like a value.
    q = (k := 7) after k = 5 stored through the literal 5 and left the stale
    fact about k in place. -O3 only.
  • An induction step hidden in a subscript did not count as modifying the
    variable,
    so arr(i := i + 1) = 9 could fold away a loop's exit test.
    -O3 only.
  • Only the module that sets SP carries a stack buffer; a program linked
    from eight modules was carrying eight.

0.3.5 was tagged but never published to PyPI; its changes are in this release too — see the CHANGELOG.

uplm80 0.3.4

Choose a tag to compare

@avwohl avwohl released this 19 Sep 19:05

The third code-generation defect of the same family, and the one that made CrLZH decoding in the 80un unpacker come out wrong. That known issue is now closed.

The base address of a subscripted element was destroyed by the index expression. _gen_subscript_addr parked the array base in DE and then generated the index. An index that is itself a 16-bit expression emits ld de,nn, which overwrote the base, and the closing add hl,de then added the index constant a second time instead of the base. PRNT(I + LZH$T) = I with LZH$T = 629 stored to (I + 629) * 2 + 629 rather than PRNT + (I + 629) * 2, so every element address was wrong and the store landed on unrelated memory.

An index of I or I + 1 was unaffected, since neither needs DE — a + 1 becomes inc hl. Only an index carrying a constant too large for inc, or any other 16-bit subexpression, triggered the defect. That is why so little broke so specifically: in 80un only init$tree and update$tree index that way, and the result was a CrLZH Huffman parent table that was never initialised.

The base is now kept on the stack across generation of the index, which is what the generator did before bdb0f8a migrated subscripts onto the register allocator. Both member-subscript paths had the same defect and are fixed too.

Regression tests for all three defects fixed in 0.3.3 and 0.3.4 ship with this release, written as register-liveness invariants over the generated assembly rather than as golden output: a value parked in DE or B must not be destroyed before it is read, and the false path of a BYTE > must reach the xor a that loads zero. Each test fails against a copy of the generator with its fix reverted.

CrLZH known issue closed. Built with this release, 80un scores 15 of 15 byte-exact against the original CP/M UNCR24.COM and reproduces its Python decoders on 107 of 108 sample-corpus members — parity with 01cfcc6, the last generator known to be good. 80un no longer needs to pin an old compiler to ship a correct binary.

uplm80 0.3.3

Choose a tag to compare

@avwohl avwohl released this 19 Sep 18:19

Two code-generation defects that silently produced wrong Z80, plus the PL/M string-literal fix that comes with the raised uplox floor. Both codegen defects are present in every earlier release; commit 273c83a made them reachable rather than introducing them.

A BYTE > comparison used as a value was non-zero when false. In _gen_byte_comparison_const and _gen_byte_comparison the GT arm jumped to the join label that follows ld a,0ffh rather than to the xor a false case, leaving the xor a unreachable and the compared operand in the accumulator. Y = X > 32 with X = 6 assigned 6, not 0.

Register B was clobbered while the other operand of a byte AND, OR, XOR or SUB was generated. _gen_byte_binary and _gen_byte_comparison parked one operand in B with ld b,a and then generated the other operand. B is not callee-saved, a nested byte comparison uses ld b,a as its own scratch move, and a procedure call in the other operand overwrites B, so the closing and b masked against garbage: D = (A > 0) AND (B < C) with A = 0 came out true. The operand is now spilled through the stack and B is loaded only once the other operand exists. pop bc would be shorter, but it also overwrites C, where the CP/M call convention keeps a live argument — CALL MON1(2, '0' + X) turned into a call to BDOS function 68.

Both defects only reach the generated code when a comparison is materialised as a value, which is why 273c83a — correctly making PL/M-80's AND and OR bitwise rather than short-circuit — made them load-bearing.

Changed: uplox floor raised to >=3.3.1 and uplm80/_plm_parser.py regenerated, so a backslash inside a PL/M character literal no longer fails to lex.

Known issue: code generated for the CrLZH decoder of the 80un unpacker is still wrong. See CHANGELOG.md.