Hello World C program for the ZX Spectrum Next using the z88dk compiler.
Z88DK
Z88DK is a collection of software development tools that targets the 8080 and z80 family of machines. It allows development of programs in C, assembly language or any mixture of the two. What makes z88dk unique is its ease of use, built-in support for many z80 machines, including ZX Spectrum Next, and its extensive set of assembly language library subroutines implementing the C standard and extensions.
The Z88DK offers several C Run Times (CRT) that can be selected using -startup at compile time. These CRTs provide the initialisation code that is called before main(). Some of them provide a simple tty device which supports controls codes such as \x16nn move cursor to X,Y.
NB when installing z88dk on Windows you need to set up the environment variables
- create a environment variable to point to the z88dk root folder e.g. called z88dk
- include z88dk\bin in your PATH
- set Z80_OZFILES to point to \lib e.g. $Env:Z80_OZFILES=$Env:z88dk+"\Lib\"
- ZCCCFG to point to the config folder e.g. $Env:ZCCCFG=$Env:z88dk+"\Lib\Config"
Hello World C program
The following program prints "Hello World" near the middle of the screen and then loops forever changing the border between red and yellow.
The resultant .nex file can be loaded by a ZX Spectrum emulator such as
CSpect or copied over and run on real ZX Spectrum Next hardware.
No comments:
Post a Comment