Skip to content

Add a very basic ZX Spectrum plat. #297

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

Open
wants to merge 1 commit into
base: default
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ vars.ackcflags = {
}
vars.ackldflags = {}
vars.plats = {
-- keep sorted
"cpm",
"em22",
"linux386",
"linux68k",
"linuxppc",
"linuxmips",
"msdos86",
"linuxppc",
"msdos386",
"msdos86",
"osx386",
"osxppc",
"pc86",
"rpi",
"pdpv7",
"em22",
"rpi",
"spectrum",
}
vars.plats_with_tests = {
"cpm",
Expand Down
12 changes: 12 additions & 0 deletions mach/z80/as/build.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bundle {
name = "headers",
srcs = {
"./mach0.c",
"./mach1.c",
"./mach2.c",
"./mach3.c",
"./mach4.c",
"./mach5.c",
}
}

8 changes: 4 additions & 4 deletions mach/z80/cg/table
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ gto | | remove(ALL)
move({EXTENDED_ADDR,$1},HL)
"call .gto"
| | |
lim | | | {EXTENDED,"ignmask"} | |
lim | | | {EXTENDED,".ignmask"} | |
lin | | remove(ALL) allocate(HL_REG)
move({IMMEDIATE,$1},HL)
"ld (hol0),hl"
Expand All @@ -1369,12 +1369,12 @@ rck $1 == 2 | STACK | allocate(ALL_REG)
rtt | | | | ret 0|
sig | HL_REG_SCR |

"ld (trapproc),hl"
"ld hl,trapproc"
"ld (.trapproc),hl"
"ld hl,.trapproc"
| HL | |
sim | HL_REG | remove(MEM_ALL)
"pop hl"
"ld (ignmask),hl" | | |
"ld (.ignmask),hl" | | |
str $1 == 0 | | "pop iy" | | |
str $1 == 1 | STACK | allocate(HL_REG)
"pop hl"
Expand Down
4 changes: 2 additions & 2 deletions mach/z80/int/em.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
EILLINS=18
EILLSIZE=19
ECASE=20
EMON=25
EBADMON=25

!--------------------------- Initialization ---------------------------

Expand Down Expand Up @@ -3615,7 +3615,7 @@ e.case:
ld hl,ECASE
jr 9b
e.mon:
ld hl,EMON
ld hl,EBADMON
jr 9b
e.array:
push af
Expand Down
42 changes: 0 additions & 42 deletions mach/z80/libem/LIST

This file was deleted.

53 changes: 53 additions & 0 deletions mach/z80/libem/build.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = {
"./aar2.s",
"./aar.s",
"./aaru.s",
"./and.s",
"./cii.s",
"./cms.s",
"./cmu4.s",
"./cmu.s",
"./csa.s",
"./csb.s",
"./dvi2.s",
"./dvi4.s",
"./dvu2.s",
"./dvu4.s",
"./exg.s",
"./gto.s",
"./hulp.s",
"./inn.s",
"./ior.s",
"./lar2.s",
"./lar.s",
"./laru.s",
"./los.s",
"./mli2.s",
"./mli4.s",
"./nop.s",
"./outdec.s",
"./rck.s",
"./ret.s",
"./rmi2.s",
"./sar2.s",
"./sar.s",
"./saru.s",
"./sdf.s",
"./sdl.s",
"./set.s",
"./str.s",
"./sts.s",
"./trp.s",
"./unim.s",
"./xor.s",
},
vars = {
plat = plat,
["+ackcflags"] = {"-Imach/z80/libem"}
},
}
end

3 changes: 2 additions & 1 deletion mach/z80/libem/nop.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#
.define .nop
.sect .text
.sect .rom
Expand Down Expand Up @@ -26,7 +27,7 @@
push de
ld de,1
push de
call WRITE
call _write
pop de
pop de
pop de
Expand Down
6 changes: 3 additions & 3 deletions mach/z80/libem/trp.s
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
push hl ! save error no on stack
push bc
push ix
push hl ! test bit "error no" of ignmask
ld hl,(ignmask)
push hl ! test bit "error no" of .ignmask
ld hl,(.ignmask)
ex (sp),hl
push hl
ld hl,2
Expand All @@ -43,7 +43,7 @@
push iy
ld iy,2
push iy
call WRITE
call _write
pop iy
pop iy
pop iy
Expand Down
4 changes: 2 additions & 2 deletions mach/z80/libem/unim.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ unimpld: ! used in dispatch table to
ret

e.mon:
ld hl,EMON
ld hl,EBADMON
jr 9b
e.rck:
push af
ld a,(ignmask)
ld a,(.ignmask)
bit 1,a
jr nz,8f
ld hl,ERANGE
Expand Down
13 changes: 13 additions & 0 deletions mach/z80/libend/build.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = {
"./edata.s",
"./em_end.s",
"./end.s",
"./etext.s",
},
vars = { plat = plat },
}
end

4 changes: 2 additions & 2 deletions mach/z80/libmon/head_em.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.define EARRAY,ERANGE,EILLINS,EILLSIZE,ECASE,EMON,EHEAP
.define EARRAY,ERANGE,EILLINS,EILLSIZE,ECASE,EBADMON,EHEAP
.define hol0,trapproc,trpim,argv,hp,.reghp,envp,begbss,ignmask
.define savebc,savede,savehl,saveix,saveaf,saveiy,ebadmon
.define WRITE,EXIT
Expand All @@ -13,7 +13,7 @@
EILLINS=18
EILLSIZE=19
ECASE=20
EMON=25
EBADMON=25
ebadmon=25


Expand Down
4 changes: 2 additions & 2 deletions mach/z80/libsys/head_em.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.define EARRAY,ERANGE,EILLINS,EILLSIZE,ECASE,EMON,EHEAP
.define EARRAY,ERANGE,EILLINS,EILLSIZE,ECASE,EBADMON,EHEAP
.define hol0,trapproc,trpim,argv,hp,.reghp,envp,begbss,ignmask
.define savebc,savede,savehl,saveix,saveaf,saveiy,ebadmon
.define WRITE,EXIT
Expand All @@ -13,7 +13,7 @@
EILLINS=18
EILLSIZE=19
ECASE=20
EMON=25
EBADMON=25
ebadmon=25


Expand Down
73 changes: 73 additions & 0 deletions plat/spectrum/boot.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#

! Declare segments (the order is important).

.sect .text
.sect .rom
.sect .data
.sect .bss

.sect .bss
STACKSIZE = 512
.comm stack, STACKSIZE

.sect .text
begtext:
! We have to clear the bss. (argify requires it.)

ld hl, endbss
push hl
ld de, begbss
sbc hl, de
ld b, h
ld c, l
dec bc
pop hl
xor a
ld (de), a
inc de
ldir

! Set up the stack (now it's been cleared, since it's in the BSS).

ld sp, stack + STACKSIZE

! Push standard parameters.

ld hl, envp
push hl
ld hl, argv
push hl
ld hl, 1
push hl

! Go.

call __m_a_i_n
.define EXIT, __exit
EXIT:
__exit:
jr __exit
.align 2

! Define symbols at the beginning of our various segments, so that we can find
! them. (Except .text, which has already been done.)

.define begtext, begdata, begbss
.sect .data; begdata:
.sect .rom; begrom:
.sect .bss; begbss:

! Some magic data. All EM systems need these.

.define .ignmask, _errno, .trapproc
.comm .ignmask, 2
.comm _errno, 2
.comm .trapproc, 2

! The fake argv and env arrays.

.sect .data
argv: .data2 exename, 0
envp: .data2 0
exename: .asciz 'spectrum'
25 changes: 25 additions & 0 deletions plat/spectrum/build-pkg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include("plat/build.lua")

ackfile {
name = "boot",
srcs = { "./boot.s" },
vars = { plat = "spectrum" }
}

build_plat_libs {
name = "libs",
arch = "z80",
plat = "spectrum",
}

installable {
name = "pkg",
map = {
"+tools",
"+libs",
"./include+pkg",
["$(PLATIND)/spectrum/boot.o"] = "+boot",
["$(PLATIND)/spectrum/libsys.a"] = "./libsys+lib",
}
}

27 changes: 27 additions & 0 deletions plat/spectrum/build-tools.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
include("plat/build.lua")

build_as {
name = "as",
arch = "z80",
}

build_cg {
name = "cg",
arch = "z80",
}

build_top {
name = "top",
arch = "z80"
}

return installable {
name = "tools",
map = {
["$(PLATDEP)/spectrum/as"] = "+as",
["$(PLATDEP)/spectrum/cg"] = "+cg",
["$(PLATDEP)/spectrum/top"] = "+top",
["$(PLATIND)/descr/spectrum"] = "./descr",
"util/opt+pkg",
}
}
Loading