Skip to content

Commit

Permalink
Merge pull request #9 from markdryan/markdryan/v7
Browse files Browse the repository at this point in the history
Specasm v7
  • Loading branch information
markdryan authored Jan 28, 2024
2 parents ee3bd26 + be40eca commit ff5ff50
Show file tree
Hide file tree
Showing 71 changed files with 5,607 additions and 2,905 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ jobs:
run: |
./unittests
cd tests && ./tests.sh
- name: next
run: |
make clean
CFLAGS="-DSPECASM_TARGET_NEXT_OPCODES" make -j
./unittests
cd tests && SPECASM_TARGET_NEXT_OPCODES=1 ./tests.sh
- name: sanatizer
run: |
make clean
CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer -Wall -Werror" make
CFLAGS="-DSPECASM_TARGET_NEXT_OPCODES -g -fsanitize=address -fno-omit-frame-pointer -Wall -Werror" make
./unittests
21 changes: 19 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,27 @@ specasm-bare
test_content_zx
SAIMPORT
SAEXPORT
SPECASM
*.map
SALINK
SAIMPORT.X
SAEXPORT.X
UNITNEXT
UNITZX
SAIMPORT.X
SAEXPORT.X
SAMAKE
SAMAKE.X
build.sh
compile.sh
build/release
build/unitzx
!build/48/specasm/
!bas/48/*.TAP
!bas/*.TAP
build/48/specasm/release/
!build/next/specasm/
build/next/specasm/release/
build/48/unit/tests/
build/next/unit/tests/
examples/hello/hello
examples/hello/hello.x
.DS_Store
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ SRCS =\
editor.c \
editor_tests.c \
editor_test_content.c \
ld_parse.c \
line_parse.c \
line_parse_common.c \
line_dump_common.c \
line_dump.c \
peer_unit.c \
peer_posix_screen.c \
Expand All @@ -28,26 +31,34 @@ POSIX = \
peer_text_screen.c

SAIMPORT =\
ld_parse.c \
line_parse.c \
line_parse_common.c \
saimport.c \
state_parse.c

SAEXPORT =\
line_dump.c \
line_dump_common.c \
state_dump.c \
saexport.c

SALINK =\
link_obj.c \
map.c \
salink.c \
expression.c

SAMAKE =\
samake.c

TEST_CONTENT_ZX =\
test_content.c \
test_content_zx.c

CFLAGS += -Wall -MMD -DUNITTESTS -Isrc

all: unittests saimport saexport salink
all: unittests saimport saexport salink samake

unittests: $(BASE:%.c=%.o) $(COMMON:%.c=%.o) $(SRCS:%.c=%.o)
$(CC) $(CFLAGS) -o $@ $^
Expand All @@ -64,8 +75,11 @@ salink: $(BASE:%.c=%.o) $(POSIX:%.c=%.o) $(SALINK:%.c=%.o)
test_content_zx: $(TEST_CONTENT_ZX:%.c=%.o)
$(CC) $(CFLAGS) -o $@ $^

samake: $(BASE:%.c=%.o) $(POSIX:%.c=%.o) $(SAMAKE:%.c=%.o)
$(CC) $(CFLAGS) -o $@ $^

clean:
- rm *.d *.o unittests saimport saexport salink
- rm *.d *.o unittests saimport saexport salink samake

-include $(BASE:%.c=%.d)
-include $(COMMON:%.c=%.d)
Expand All @@ -74,4 +88,5 @@ clean:
-include $(SAIMPORT:%.c=%.d)
-include $(SAEXPORT:%.c=%.d)
-include $(SALINK:%.c=%.d)
-include $(SAMAKE:%.c=%.d)
-include $(TEST_CONTENT_ZX:%.c=%.d)
98 changes: 80 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# Specasm

Specasm is a Z80 assembler designed to run on the 48k and 128k ZX Spectrum. It requires an SD card solution running ESXDOS 0.87 or greater to function. For detailed information about how Specasm works, please see the [documentation](https://github.com/markdryan/specasm/blob/master/docs/specasm.md). To get started, carry on reading.
Specasm is a Z80 assembler designed to run on the 48k and 128k ZX Spectrum and the ZX Spectrum Next. It requires an SD card solution running ESXDOS 0.87 or greater to function on the 48Kb and 128Kb ZX Spectrum. For detailed information about how Specasm works, please see the [documentation](https://github.com/markdryan/specasm/blob/master/docs/specasm.md). To get started, carry on reading.

## Getting Started

Download the latest release of Specasm, and unzip the contents of the file into the root directory of your SD card. You should now have a folder in your root directory called SPECASM that contains some .tap and some BASIC files. It should look something like this.
[Download](https://github.com/markdryan/specasm/releases) the latest release of Specasm appropriate for your Spectrum and unzip the contents of the file into the root directory of your SD card.

> [!TIP]
> There are two different Zip files available, specasm48.zip for the 48kb and 128kb Spectrum, and specasmnext.zip for the ZX Spectrum Next. You must download the appropriate version for your machine.
You should now have a folder in your root directory called SPECASM. It should look something like this if you downloaded specasm48.zip

![Installing](/docs/install.png)

Now navigate to the INSTALL file, which is a BASIC program, and press **ENTER** to execute it. This will use ESXDOS's **.launcher** command to set up some command line short cuts for the tap files in the SPECASM directory.
Now navigate to the INSTALL file, which is a BASIC program, and press **ENTER** to execute it. On the 48kb or 128kb Spectrum this will use ESXDOS's **.launcher** command to set up some command line short cuts for the tap files in the SPECASM directory. It will also copy some executables to the /bin folder. On the ZX Spectrum Next it will copy the various executable programs that compose Specasm to the /dot folder.

## Reinstalling Specasm

To upgrade to a new version of Specasm perform the following steps.

1. Manually remove the old /Specasm directory on your SD card, e.g., rm -rf /Specasm
2. Download the latest release and unzip its contents to /Specasm on the SD card
3. Execute the REMOVE BASIC program. This can be done from the ESXDOS file browser or by loading it from the BASIC prompt. This will remove the old version of Specasm stored under the /bin folder, and will also de-register the old **.launcher** shortcuts.
1. Execute the REMOVE BASIC program. This can be done from the ESXDOS file browser or by loading it from the BASIC prompt. This will remove the old version of Specasm stored under the /bin or the /dot folders, and will also de-register the old **.launcher** shortcuts.
2. Manually remove the old /Specasm directory on your SD card, e.g., rm -rf /Specasm
3. Download the latest release and unzip its contents to /Specasm on the SD card
4. Run the INSTALL BASIC program. This will install the new version of Specasm.

## Assembling your First Program
Expand All @@ -25,8 +30,10 @@ Now, create a new directory somewhere on your SD card and cd into it and type .s


```
.mkdir /asm/demo
.cd /asm/demo
.mkdir /asm
.cd /asm
.mkdir demo
.cd demo
.specasm
```

Expand Down Expand Up @@ -56,30 +63,66 @@ You should see something like this appear on your screen

![Hello Specasm](/docs/salink.png)

Once the linker has finished a binary file will be created. The name of the file will be reported by the linker. In the example above its 'hello'. To execute the program, enter the BASIC commands at the bottom of the image above and press **ENTER**. You should see.
Once the linker has finished a binary file will be created. The name of the file will be reported by the linker. In the example above its 'hello'. We need to create a BASIC loader before we can execute the program. To do this type

```
CLEAR 32767
.samake
```

> [!TIP]
> Note the CLEAR statement is not needed on the ZX Spectrum Next.
This should create a file called hello.BAS. To run your program on a 48Kb or 128Kb Spectrum type

```
LOAD * "hello.bas"
```

On the ZX Spectrum Next simply type

```
LOAD "hello.bas"
```

You should see.

![Hello Specasm](/docs/hello.png)

## Building Specasm

Specasm is built with [z88dk](https://github.com/z88dk/z88dk) and GNU Make. Install a recent version and then
### For the 48kb and 128kb Spectrums

Specasm is built with [z88dk](https://github.com/z88dk/z88dk) and GNU Make. To build Specasm for the 48k Spectrum clone the repoistory and type

```
cd build
cd build/48/specasm
make -j
```

And then wait. All the tap and dotx files will be created in the build directory.
and then wait. All the tap and dotx files will be created in the build directory.

To create a zip file with all the files that need to be copied onto the spectrum, type

```
make release
```

from the same directory. The specasm.zip file can be found in the build/release folder.
from the same directory. The specasm48.zip file can be found in the build/release folder.

### For the Spectrum Next

```
cd build/next/specasm
make -j
make release
```

This will create a zip file called specasmnext.zip.

### On Linux or macOS

The saexport, saimport and salink commands can be built and run on POSIX compatible systems. Simply type make from the main Specasm directory. The saimport is essentially the assembler without the editor, so can be used in conjunction with salink to assemble and build Spectrum programs directly on a modern machine, but where's the fun in that?
The samake, saexport, saimport and salink commands can be built and run on POSIX compatible systems. Simply type make from the main Specasm directory. The saimport is essentially the assembler without the editor, so can be used in conjunction with salink to assemble and build Spectrum programs directly on a modern machine, but where's the fun in that?

## Tests

Expand All @@ -92,6 +135,13 @@ make

from the project's top level folder.

To run the tests extra instructions supported by the Spectrum Next type

```
CFLAGS="-DSPECASM_TARGET_NEXT_OPCODES" make -j
./unittests
```

To run the linker tests perform the following steps

```
Expand All @@ -100,16 +150,28 @@ cd tests
./tests.sh
```

A large proportion (but not all) of the unit tests can be run on the spectrum itself. To build these tests type
To run the linker tests with the Next Opcodes enabled, type

```
cd unitzx
cd tests && SPECASM_TARGET_NEXT_OPCODES=1 ./tests.sh
```

A large proportion (but not all) of the unit tests can be run on the Spectrums themselves. To build these tests for the 48kb and 128kb Spectrums type

```
build/48/unit
make
make tests
```

This will create a folder called tests in the unitzx folder. Inside this folder are 3 files that need to be copied to the same directory on your spectrum. Run the unizx.tap file to run the tests.

This will create a folder called tests in the unit folder. Inside this folder are 3 files that need to be copied to the same directory on your spectrum. Run the unitzx.tap file to run the tests.

To build for the ZX Spectrum Next, type

```
build/next/unit
make -j
make tests
```

This will create a folder called tests in the unit folder. Inside this folder are 3 files that need to be copied to the same directory on your spectrum. The unitnext file is a dotn file which needs to be copied to the /dot directory. Then make sure you are in the folder containing the test_bad and test_op files and type .unitnext.
Binary file added bas/48/INSTALL
Binary file not shown.
Binary file added bas/48/LINKLD.TAP
Binary file not shown.
Binary file added bas/48/REMOVE
Binary file not shown.
File renamed without changes.
Binary file removed bas/INSTALL
Binary file not shown.
Binary file removed bas/REMOVE
Binary file not shown.
Binary file added bas/next/INSTALL
Binary file not shown.
Binary file added bas/next/REMOVE
Binary file not shown.
54 changes: 54 additions & 0 deletions build/48/specasm/Make.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
error.o: error.c error.h
expression.o: expression.c error.h expression.h salink.h \
line.h state_base.h strings.h
state_base.o: state_base.c peer.h error.h peer_zx.h \
line.h state_base.h strings.h
state_dump.o: state_dump.c state.h state_base.h line.h \
error.h strings.h
state_parse.o: state_parse.c state.h state_base.h line.h \
error.h strings.h
ld_parse.o: ld_parse.c line_common.h line.h error.h \
line_parse_common.h peer.h peer_unit.h state.h \
state_base.h strings.h
ld_parse_banked.o: ld_parse.c line_common.h line.h error.h \
line_parse_common.h peer.h peer_unit.h state.h \
state_base.h strings.h
line_common.o: line_common.c line_common.h line.h error.h
line_dump.o: line_dump.c line_common.h line.h error.h \
peer.h peer_zx.h state.h state_base.h strings.h
line_dump_common.o: line_dump_common.c line_common.h line.h \
error.h peer.h peer_zx.h state.h state_base.h \
strings.h
line_parse.o: line_parse.c line_common.h line.h error.h\
peer.h peer_zx.h state.h state_base.h strings.h
line_parse_common.o: line_parse_common.c line.h error.h \
line_common.h line_parse_common.h state.h state_base.h \
strings.h
link_obj.o: link_obj.c expression.h salink.h line.h \
error.h peer_file.h map.h peer.h peer_unit.h \
state_base.h strings.h
map.o: map.c map.h peer.h error.h peer_zx.h \
line.h salink.h peer_file.h state_base.h strings.h
editor.o: editor.c editor.h peer.h error.h \
peer_zx.h line.h state.h state_base.h strings.h \
util_print_zx.h
saimport.o: saimport.c peer.h error.h peer_zx.h \
line.h peer_file.h state.h state_base.h strings.h \
util_print_zx.h
saexport.o: saexport.c peer.h error.h peer_zx.h \
line.h peer_file.h state.h state_base.h strings.h \
util_print_zx.h
salink.o: salink.c peer.h error.h peer_zx.h line.h \
peer_file.h state_base.h strings.h \
util_print_zx.h
specasm.o: specasm.c editor.h peer.h error.h \
line.h peer_file.h state.h state_base.h strings.h
peer_zx.o: peer_zx.c peer.h state.h state_base.h line.h \
strings.h error.h util_print_zx.h
peer_file_zx.o: peer_file_zx.c error.h peer_file.h
util_print_zx.o: util_print_zx.h
samake.o: samake.c peer.h error.h peer_zx.h line.h \
salink.h peer_file.h state_base.h strings.h

%.o: %.c
zcc $(CFLAGS) -o $@ -c $<
Loading

0 comments on commit ff5ff50

Please sign in to comment.