Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specasm v9 #12

Merged
merged 20 commits into from
May 4, 2024
Merged

Specasm v9 #12

merged 20 commits into from
May 4, 2024

Conversation

markdryan
Copy link
Owner

Specasm v8 contains numerous updates and improvements:

  • Specasm can now create zx81 binaries and .p files.
    • There's a new zx81 linker directive that instructs the linker to set the org address to 16514 (unless overridden) and to transliterate all strings and character constants from ASCII to the corresponding ZX81 encoding.
    • Samake can now generate .p files, containers for ZX81 programs.
  • Specasm v9 includes support for unit testing.
    • A new type of source file, a .t file, is supported that is designed to contain test code. When the linker encounters a .t file it will create a separate binary with a .tst extension containing both the normal program code, stored in the .x files, and the test code in the .t files.
    • Samake has been updated to generate test harnesses. When run with the "tst" parameter it will examine the .tst binary, identify all the unit tests it contains and generate a BASIC program to call the unit tests and print their results to the screen.
    • Some library code has been added which is designed for use in unit tests to verify that the code being tested only corrupts the registers it is expected to corrupt.
  • The max path size when including another file or directory has been increased.
  • A bug related to the parsing of ld (ix+1), =exp has been fixed.
  • A bug has been fixed in the editor which resulted in incorrect error messages being displayed when a ld instruction containing a label of expression was used. This occurred when the file being edited had no free strings available.
  • Label subtraction support has been removed from the linker, to save space. This feature was deprecated in Specasm v5 and removed from the editor in Specasm v7. If you still have old object files around that use this feature, the linker will invite you to load and save those files in the editor before re-linking.
  • The documentation is now included in the release.zip files.
  • The names of the installation and removal scripts have been changed from INSTALL and REMOVE to INSTALL.BAS and REMOVE.BAS

A new linker directive, zx81, has been added which changes the default
org address to 16514 and instructs the linker to transliterate all
string and character literals from ASCII to their equivalent ZX81
encoding, where available.

Samake has also been updated to support the generation of .p files.

Signed-off-by: Mark Ryan <[email protected]>
We don't allow more than 64 files in a binary and I doubt we'll
ever allow more than 256.  So no need to use 16 bit integers to
keep track of the number of object files we have.

Signed-off-by: Mark Ryan <[email protected]>
This is necessary to provide enough space for including files with
the + directive as the /specasm/ has to be prepended and a .x has
to be potentially appened.  This will reduce the maximum number
of pending files from 35 to 23 when processing includes, but hopefully
that will be enough.  Without this change the + directive is fairly
useless.

Signed-off-by: Mark Ryan <[email protected]>
This syntax was understood by the parser but not by the formatter or
the linker, and so resulted in corrupted text in specasm and
incorrectly encoded instructions.  All fixed now.

To get this all to fit we had to free a bit of space in line_dump.c.
We did this by factorising an array of register names.  This saved
more memory than expected so maybe we should move all those arrays
outside of the functions in which they are used.

Signed-off-by: Mark Ryan <[email protected]>
The instead of this.

Signed-off-by: Mark Ryan <[email protected]>
As recently discovered, having initialized arrays inside functions seems
to be more expensive than the equivalent static arrays.  As we've had
problems with local static arrays let's make those arrays global and
save some bytes.

Signed-off-by: Mark Ryan <[email protected]>
To make room for more exciting code in link_obj.c.

Signed-off-by: Mark Ryan <[email protected]>
Add unit test support.  Specasm now supports .t files which can include
unit test code.  This code is included in a separate binary with a .tst
suffix created by the linker.  The .tst file contains a jump table to
all the test functions (functions that begin with a Test prefix) and
the contents of the .t files as well as the contents of all the .x files.

Samake has been modified to generate BASIC test harnesses that invoke
all the Test* functions found in the .tst binary printing their results
to the screen.

.t files are not included when directories are included using - or +
but can be explicitly included by name.

Signed-off-by: Mark Ryan <[email protected]>
Signed-off-by: Mark Ryan <[email protected]>
With clang-format.

Signed-off-by: Mark Ryan <[email protected]>
The documents can be read directly on the spectrum.

Signed-off-by: Mark Ryan <[email protected]>
The linker no longer understands label subtraction and will emit
an error if ask to process any old .x files that still use it.
The error should explain to the user how they can resolve the issue
by loading the offending file into specasm and re-saving it.
This saves about 400 bytes.

Signed-off-by: Mark Ryan <[email protected]>
The ld instruction was reporting the wrong error code when used
with labels or expressions and the number of strings in the .x
were exhausted.  The user should have seen a "Too many strings"
error, but instead they were confronted with a "Bad register"
error which was very confusing.  Should all be fixed now.

Signed-off-by: Mark Ryan <[email protected]>
It just wastes bytes and 4 of our 32 characters on the screen.

Signed-off-by: Mark Ryan <[email protected]>
The length was previously hardcoded to 8.  This commit modifies uses
the LEN keyword to determine the correct length.
which contains routines that can be used in unit tests to determine
which registers have changed.

Signed-off-by: Mark Ryan <[email protected]>
Add a .BAS extension so that they're recognized by all file
browsers.

Signed-off-by: Mark Ryan <[email protected]>
For the v9 release.

Signed-off-by: Mark Ryan <[email protected]>
It seems that the stat command has a different interface on MacOS
and Linux.

Signed-off-by: Mark Ryan <[email protected]>
The sanitizer found that error strings containing paths might end
up being truncated as such error messages might not fit into 96
bytes.  We now allow 4 lines for linker error messages.

Signed-off-by: Mark Ryan <[email protected]>
@markdryan markdryan merged commit a7583b1 into main May 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant