Skip to content

Commit

Permalink
Merge pull request #13 from markdryan/markdryan/v10
Browse files Browse the repository at this point in the history
Specasm v10
  • Loading branch information
markdryan authored Sep 24, 2024
2 parents a7583b1 + 15de634 commit adaaeff
Show file tree
Hide file tree
Showing 88 changed files with 4,743 additions and 962 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ build.sh
compile.sh
!build/48/specasm/
!bas/48/*.TAP
!bas/128/*.TAP
!bas/*.TAP
build/48/specasm/release/
!build/next/specasm/
!build/128/specasm/
build/next/specasm/release/
build/48/unit/tests/
build/128/unit/tests/
build/128/specasm/sald128
build/next/unit/tests/
examples/hello/hello
examples/hello/hello.x
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ COMMON =\
line_common.c

SRCS =\
analysis.c \
clipboard.c \
editor.c \
editor_buffers.c \
editor_extra.c \
editor_tests.c \
editor_test_content.c \
ld_parse.c \
Expand All @@ -20,6 +23,7 @@ SRCS =\
peer_unit.c \
peer_posix_screen.c \
peer_text_screen.c \
scratch.c \
state_dump.c \
state_parse.c \
test_content.c \
Expand All @@ -35,7 +39,11 @@ SAIMPORT =\
ld_parse.c \
line_parse.c \
line_parse_common.c \
line_dump.c \
line_dump_common.c \
state_dump.c \
saimport.c \
scratch.c \
state_parse.c

SAEXPORT =\
Expand Down
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Specasm is a Z80 assembler designed to run on the 48k and 128k ZX Spectrum and t
[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.
> There are three different Zip files available, specasm48.zip for the 48kb, specasm128.zip for the 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

Expand Down Expand Up @@ -63,7 +63,7 @@ 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'. We need to create a BASIC loader before we can execute the program. To do this type
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 it's 'hello'. We need to create a BASIC loader before we can execute the program. To do this type

```
CLEAR 32767
Expand Down Expand Up @@ -91,7 +91,7 @@ You should see.

## Building Specasm

### For the 48kb and 128kb Spectrums
### For the 48kb Spectrum

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

Expand All @@ -110,6 +110,16 @@ make release

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

### For the 128kb Spectrum

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

This will create a zip file called specasm128.zip.

### For the Spectrum Next

```
Expand Down Expand Up @@ -156,7 +166,7 @@ To run the linker tests with the Next Opcodes enabled, type
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
A large proportion (but not all) of the unit tests can be run on the Spectrums themselves. To build these tests for the 48kb Spectrum type

```
build/48/unit
Expand All @@ -166,6 +176,14 @@ 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. Run the unitzx.tap file to run the tests.

To build for the 128kb Spectrum, type

```
build/128/unit
make
make tests
```

To build for the ZX Spectrum Next, type

```
Expand Down
75 changes: 75 additions & 0 deletions asm/sald128/sald128.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.timer equ $5c78
.cpuid equ 2899
.bankVar equ $5b5c
.bankPort equ $7ffd
.Main
; jump table
dw calib
dw bank0
dw bank4
dw bank6
dw bank1

.calib
halt
ld hl, 0
ld a, (=timer)
ld b, a
.calibLoop
inc hl
nop
nop
nop
nop
ld a, (=timer)
cp b
jr z, calibLoop
ld c, l
ld b, h
or a
ret

align 4
.bank128
db 16,20,22,17
.bankPlus2a
db 16,17,19,20

.bank0
ld c, 0
jr switchBank
.bank4
ld c, 1
jr switchBank
.bank6
ld c, 2
jr switchBank
.bank1
ld c, 3


.switchBank
ld a, (=cpuid)
cp 126
jr nz, toastPages
ld hl, bankPlus2a
jr startSwitch
.toastPages
ld hl, bank128
.startSwitch
ld a, c
add a, l
ld l, a
ld b, (hl)
di
ld a, (=bankVar)
and $E0
or b
ld (=bankVar), a
ld bc, =bankPort
out (c), a
ei
ld bc, 0
or a
ret

94 changes: 92 additions & 2 deletions asm/tst/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
call TstCheckRegs
ret


.TestChkBaseBad
ld hl, baseBad
call TstParseRegs
Expand Down Expand Up @@ -54,40 +55,122 @@
ret

.TestChkPrime
di
exx
ex af, af'
push af
push bc
push de
push hl
ex af, af'
exx

ld hl, primeGood
call TstParseRegs
call TstSaveRegs
call modAllPrime
call TstCheckRegs

exx
ex af, af'
pop hl
pop de
pop bc
pop af
ex af, af'
exx
ei
ret

.TestChkPrimeBad
di
exx
ex af, af'
push af
push bc
push de
push hl
ex af, af'
exx

ld hl, baseBad
call TstParseRegs
call TstSaveRegs
call modAllPrime
call TstCheckRegs

exx
ex af, af'
pop hl
pop de
pop bc
pop af
ex af, af'
exx
ei

ld a, c
or b
jr z, badFail
jp z, badFail
ld hl, primeGood
call strcmp
ret

.TestChkMixed
di
exx
ex af, af'
push af
push bc
push de
push hl
ex af, af'
exx

ld hl, mixedGood
call TstParseRegs
call TstSaveRegs
call modMixed
call TstCheckRegs

exx
ex af, af'
pop hl
pop de
pop bc
pop af
ex af, af'
exx
ei
ret

.TestChkMixedBad
di
exx
ex af, af'
push af
push bc
push de
push hl
ex af, af'
exx

ld hl, baseBad
call TstParseRegs
call TstSaveRegs
call modMixed
call TstCheckRegs

exx
ex af, af'
pop hl
pop de
pop bc
pop af
ex af, af'
exx
ei

ld a, c
or b
jp z, badFail
Expand All @@ -96,14 +179,21 @@
ret

.strcmp
ld a, 6
add a, c
ld c, a
ld a, 0
adc a, b
ld b, a
.strcmpLoop
ld a, (bc)
cp (hl)
jr nz, cmpFail
or a
jr z, cmpOk
inc hl
inc bc
jr strcmp
jr strcmpLoop
.cmpFail
ld bc, 1
ret
Expand Down
Loading

0 comments on commit adaaeff

Please sign in to comment.