Skip to content

Commit adaaeff

Browse files
authored
Merge pull request #13 from markdryan/markdryan/v10
Specasm v10
2 parents a7583b1 + 15de634 commit adaaeff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4743
-962
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ build.sh
2727
compile.sh
2828
!build/48/specasm/
2929
!bas/48/*.TAP
30+
!bas/128/*.TAP
3031
!bas/*.TAP
3132
build/48/specasm/release/
3233
!build/next/specasm/
34+
!build/128/specasm/
3335
build/next/specasm/release/
3436
build/48/unit/tests/
37+
build/128/unit/tests/
38+
build/128/specasm/sald128
3539
build/next/unit/tests/
3640
examples/hello/hello
3741
examples/hello/hello.x

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ COMMON =\
88
line_common.c
99

1010
SRCS =\
11+
analysis.c \
1112
clipboard.c \
1213
editor.c \
14+
editor_buffers.c \
15+
editor_extra.c \
1316
editor_tests.c \
1417
editor_test_content.c \
1518
ld_parse.c \
@@ -20,6 +23,7 @@ SRCS =\
2023
peer_unit.c \
2124
peer_posix_screen.c \
2225
peer_text_screen.c \
26+
scratch.c \
2327
state_dump.c \
2428
state_parse.c \
2529
test_content.c \
@@ -35,7 +39,11 @@ SAIMPORT =\
3539
ld_parse.c \
3640
line_parse.c \
3741
line_parse_common.c \
42+
line_dump.c \
43+
line_dump_common.c \
44+
state_dump.c \
3845
saimport.c \
46+
scratch.c \
3947
state_parse.c
4048

4149
SAEXPORT =\

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Specasm is a Z80 assembler designed to run on the 48k and 128k ZX Spectrum and t
77
[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.
88

99
> [!TIP]
10-
> 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.
10+
> 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.
1111
1212
You should now have a folder in your root directory called SPECASM. It should look something like this if you downloaded specasm48.zip
1313

@@ -63,7 +63,7 @@ You should see something like this appear on your screen
6363

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

66-
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
66+
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
6767

6868
```
6969
CLEAR 32767
@@ -91,7 +91,7 @@ You should see.
9191

9292
## Building Specasm
9393

94-
### For the 48kb and 128kb Spectrums
94+
### For the 48kb Spectrum
9595

9696
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
9797

@@ -110,6 +110,16 @@ make release
110110

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

113+
### For the 128kb Spectrum
114+
115+
```
116+
cd build/128/specasm
117+
make -j
118+
make release
119+
```
120+
121+
This will create a zip file called specasm128.zip.
122+
113123
### For the Spectrum Next
114124

115125
```
@@ -156,7 +166,7 @@ To run the linker tests with the Next Opcodes enabled, type
156166
cd tests && SPECASM_TARGET_NEXT_OPCODES=1 ./tests.sh
157167
```
158168

159-
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
169+
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
160170

161171
```
162172
build/48/unit
@@ -166,6 +176,14 @@ make tests
166176

167177
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.
168178

179+
To build for the 128kb Spectrum, type
180+
181+
```
182+
build/128/unit
183+
make
184+
make tests
185+
```
186+
169187
To build for the ZX Spectrum Next, type
170188

171189
```

asm/sald128/sald128.s

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
.timer equ $5c78
2+
.cpuid equ 2899
3+
.bankVar equ $5b5c
4+
.bankPort equ $7ffd
5+
.Main
6+
; jump table
7+
dw calib
8+
dw bank0
9+
dw bank4
10+
dw bank6
11+
dw bank1
12+
13+
.calib
14+
halt
15+
ld hl, 0
16+
ld a, (=timer)
17+
ld b, a
18+
.calibLoop
19+
inc hl
20+
nop
21+
nop
22+
nop
23+
nop
24+
ld a, (=timer)
25+
cp b
26+
jr z, calibLoop
27+
ld c, l
28+
ld b, h
29+
or a
30+
ret
31+
32+
align 4
33+
.bank128
34+
db 16,20,22,17
35+
.bankPlus2a
36+
db 16,17,19,20
37+
38+
.bank0
39+
ld c, 0
40+
jr switchBank
41+
.bank4
42+
ld c, 1
43+
jr switchBank
44+
.bank6
45+
ld c, 2
46+
jr switchBank
47+
.bank1
48+
ld c, 3
49+
50+
51+
.switchBank
52+
ld a, (=cpuid)
53+
cp 126
54+
jr nz, toastPages
55+
ld hl, bankPlus2a
56+
jr startSwitch
57+
.toastPages
58+
ld hl, bank128
59+
.startSwitch
60+
ld a, c
61+
add a, l
62+
ld l, a
63+
ld b, (hl)
64+
di
65+
ld a, (=bankVar)
66+
and $E0
67+
or b
68+
ld (=bankVar), a
69+
ld bc, =bankPort
70+
out (c), a
71+
ei
72+
ld bc, 0
73+
or a
74+
ret
75+

asm/tst/check.ts

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
call TstCheckRegs
99
ret
1010

11+
1112
.TestChkBaseBad
1213
ld hl, baseBad
1314
call TstParseRegs
@@ -54,40 +55,122 @@
5455
ret
5556

5657
.TestChkPrime
58+
di
59+
exx
60+
ex af, af'
61+
push af
62+
push bc
63+
push de
64+
push hl
65+
ex af, af'
66+
exx
67+
5768
ld hl, primeGood
5869
call TstParseRegs
5970
call TstSaveRegs
6071
call modAllPrime
6172
call TstCheckRegs
73+
74+
exx
75+
ex af, af'
76+
pop hl
77+
pop de
78+
pop bc
79+
pop af
80+
ex af, af'
81+
exx
82+
ei
6283
ret
6384

6485
.TestChkPrimeBad
86+
di
87+
exx
88+
ex af, af'
89+
push af
90+
push bc
91+
push de
92+
push hl
93+
ex af, af'
94+
exx
95+
6596
ld hl, baseBad
6697
call TstParseRegs
6798
call TstSaveRegs
6899
call modAllPrime
69100
call TstCheckRegs
101+
102+
exx
103+
ex af, af'
104+
pop hl
105+
pop de
106+
pop bc
107+
pop af
108+
ex af, af'
109+
exx
110+
ei
111+
70112
ld a, c
71113
or b
72-
jr z, badFail
114+
jp z, badFail
73115
ld hl, primeGood
74116
call strcmp
75117
ret
76118

77119
.TestChkMixed
120+
di
121+
exx
122+
ex af, af'
123+
push af
124+
push bc
125+
push de
126+
push hl
127+
ex af, af'
128+
exx
129+
78130
ld hl, mixedGood
79131
call TstParseRegs
80132
call TstSaveRegs
81133
call modMixed
82134
call TstCheckRegs
135+
136+
exx
137+
ex af, af'
138+
pop hl
139+
pop de
140+
pop bc
141+
pop af
142+
ex af, af'
143+
exx
144+
ei
83145
ret
84146

85147
.TestChkMixedBad
148+
di
149+
exx
150+
ex af, af'
151+
push af
152+
push bc
153+
push de
154+
push hl
155+
ex af, af'
156+
exx
157+
86158
ld hl, baseBad
87159
call TstParseRegs
88160
call TstSaveRegs
89161
call modMixed
90162
call TstCheckRegs
163+
164+
exx
165+
ex af, af'
166+
pop hl
167+
pop de
168+
pop bc
169+
pop af
170+
ex af, af'
171+
exx
172+
ei
173+
91174
ld a, c
92175
or b
93176
jp z, badFail
@@ -96,14 +179,21 @@
96179
ret
97180

98181
.strcmp
182+
ld a, 6
183+
add a, c
184+
ld c, a
185+
ld a, 0
186+
adc a, b
187+
ld b, a
188+
.strcmpLoop
99189
ld a, (bc)
100190
cp (hl)
101191
jr nz, cmpFail
102192
or a
103193
jr z, cmpOk
104194
inc hl
105195
inc bc
106-
jr strcmp
196+
jr strcmpLoop
107197
.cmpFail
108198
ld bc, 1
109199
ret

0 commit comments

Comments
 (0)