Z88DK :- ZX Next Target (+zxn)

If you like transforming your statements into code, this is the place for you

Moderator: Programming Moderators

Alcoholics Anonymous
Posts: 775
Joined: Mon May 29, 2017 7:00 pm

Z88DK :- ZX Next Target (+zxn)

Postby Alcoholics Anonymous » Mon Aug 14, 2017 4:30 am

Z88DK is a sophisticated cross-development tool for the z80/z180/rabbit processors that supports the development of software in any mixture of C or assembler. Its set of tools includes a front end that can take any set of input source files to final executable, two C compilers, an assembler/linker/librarian and an appmake tool to generate any format output executable from the binaries the toolchain generates.

Any memory model is supported and the libraries Z88DK comes with include the largest collection of z80 code on the internet. Programs can optionally choose to use any of more than a thousand assembly language subroutines covering floating point math, integer math, container types (list, vector, priority queue, etc), memory allocation (malloc, block or obstack), data compression, string manipulation, file io, and many more things. (The library root is at https://github.com/z88dk/z88dk/tree/mas ... EVELOPMENT ).

For the ZX Next, machine specific code is also available like file io through esxdos, reading the keyboard, joysticks, mice, generating display file addresses for several video modes, software sprites for the ULA modes, etc. The Next target is still being developed and more will come to cover more of the Next's special features.

At the moment the toolchain can automatially generate tap files, sna snapshots, dot commands and extended dot commands in addition to plain binaries as ZX Next output types. A single compile line can take your c/asm project straight to executable ready for loading on the Next.

What is unique about Z88DK is that it performs proper linking, meaning code can be distributed and shared easily with the tools automatically extracting code, graphics and sound from libraries as needed and no more than what is needed. It can also generate output for any memory configuration and it can be customized on a target machine basis.

For the Next, in addition to special code that uses the Next hardware, it also means Z88DK can generate code for the ZX Next z80-cpu variant.

The following new instructions are already supported by Z88DK's assembler:

Code: Select all

New Z80 opcodes on the NEXT (more to come)
4T*    swapnib           ED 23           A bits 7-4 swap with A bits 3-0
4T     mul               ED 30           multiply DE*HL = DEHL (no flags set)
4T     add  hl,a         ED 31           Add A to HL (no flags set)
4T*    add  de,a         ED 32           Add A to DE (no flags set)
4T*    add  bc,a         ED 33           Add A to BC (no flags set)
12T    add  hl,NNNN    ED 34 LO HI     Add NNNN to HL (no flags set)
12T*   add  de,NNNN     ED 35 LO HI     Add NNNN to DE (no flags set)
12T*   add  bc,NNNN     ED 36 LO HI     Add NNNN to BC (no flags set)
       outinb            ED 90           out (c),(hl), hl++
16T    ldix              ED A4           As LDI,  but if byte==A does not copy
21T    ldirx             ED B4           As LDIR, but if byte==A does not copy
16T*   lddx              ED AC           As LDD,  but if byte==A does not copy, and DE is incremented
21T*   lddrx             ED BC           As LDDR,  but if byte==A does not copy
21T*   fillde            ED B5           Using A fill from DE for BC bytes
21T*   ldirscale         ED B6           As LDIRX,  if(hl)!=A then (de)=(hl); HL_A'+=BC'; DE+=DE'; dec BC; Loop.
14T*   ldpirx            ED B7           (de) = ( (hl&$fff8)+(E&7) ) when != A
4T*    ld  hl,sp         ED 25           transfer SP to HL
4T*    ld  a32,dehl    ED 20           transfer dehl into A32
4T*    ld  dehl,a32    ED 21           transfer A32 into dehl
4T*    ex  a32,dehl    ED 22           swap A32 with dehl
4T     inc dehl          ED 37           increment 32bit dehl
4T*    dec dehl          ED 38           increment 32bit dehl
4T*    add dehl,a        ED 39           Add A to 32bit dehl
4T     add dehl,bc       ED 3A           Add BC to 32bit dehl
12T    add dehl,NNNN    ED 3B LO HI     Add NNNN to 32bit dehl
4T*    sub dehl,a        ED 3C           Subtract A from 32bit dehl
4T*    sub dehl,bc       ED 3D           Subtract BC from 32bit dehl
4T     mirror a          ED 24           mirror the bits in A     
4T     mirror de         ED 26           mirror the bits in DE     
12T*   push NNNN        ED 8A LO HI     push 16bit immediate value
4T*    popx              ED 8B           pop value and discard

12T*   nextreg reg,val   ED 91 reg,val   Set a NEXT register (like doing out($243b),reg then out($253b),val
 8T*    nextreg reg,a     ED 92 reg       Set a NEXT register using A (like doing out($243b),reg then out($253b),A )
** reg,val are both 8-bit numbers

4T   pixeldn           ED 93           Move down a line on the ULA screen
4T   pixelad           ED 94           using D,E (as Y,X) calculate the ULA screen address and store in HL
4T   setae             ED 95           Using the lower 3 bits of E (X coordinate), set the correct bit value in A
7T   test NN         ED 27 NN     And A with NN and set all flags. A is not affected.

* Times are guesses based on other instruction times.  All of this subject to change.
(Although be careful with using these now as only CSpect and the real thing will understand them).

And Z88DK comes with many defines, whether that be constants or io ports, supplied, eg:

* Next hardware ( https://github.com/z88dk/z88dk/blob/mas ... _target.m4 )
* ESXDOS ( https://github.com/z88dk/z88dk/blob/mas ... _esxdos.m4 )
* RRRGGGBB colours ( https://github.com/z88dk/z88dk/blob/mas ... 2_color.m4 )

Mainly this thread is here to allow APIs developed for the ZX Next to be briefly documented with examples.

For an introduction using C, see:
https://github.com/z88dk/z88dk/blob/mas ... Started.md
This in-progress tutorial is for the zx spectrum, however it also applies to the ZX Next. Compile lines can be changed from "zcc +zx ..." to "zcc +zxn ..." to target the ZX Next specifically.

There is a fine line between C and asm and asm programmers will benefit from reading the tutorial above. It won't take much time to go through it. The main change from non-linking assemblers is that the assembler organizes output into containers called sections. The linker then places those sections in memory according to a memory map it is given. By default Z88DK provides a memory map and defines containers that asm programmers can place their things into to ensure they become part of the output binary:

https://www.z88dk.org/wiki/doku.php?id= ... y_language

Z88DK executables normally (as in unless you stop it from doing so) contain some short startup code called the crt that does initialization. This crt starts the program by calling "_main". If your project is pure asm, its entry point must be labelled "_main".

This is not the place to document all these things so instead a post or two giving examples will follow.

https://www.z88dk.org/wiki/doku.php?id= ... stallation

Or github:

Make sure you are using a current version to gain access to the +zxn target. Because this is an active target, be prepared to update periodically.

There are several other threads on this forum that cover a number of usage and technical issues.
Last edited by Alcoholics Anonymous on Tue Aug 29, 2017 3:18 am, edited 5 times in total.

Posts: 121
Joined: Mon Jun 05, 2017 9:38 pm

Re: Z88DK :- ZX Next Target (+zxn)

Postby Stefan123 » Mon Aug 14, 2017 1:02 pm

Great work! I'm impressed that you have already added the Next-specific Z80 instructions to the Z88DK's assembler, you're really fast at adding new features. The new ESXDOS integration in Z88DK is a pleasure to use.

I have used Z88DK now for a while and I can really recommend it as a way of quickly getting into ZX Spectrum development. Sometimes it can be a bit difficult navigating the documentation at https://www.z88dk.org/ since it covers two flavours of the C compilers and libraries and many different targets (tip: the generic embedded target documentation contains lot of useful info). However, Alvin and his fellow Z88DK developers are very helpful on the Z88DK forum (https://www.z88dk.org/forum/forums.php) and patiently answers all your questions :)

Posts: 36
Joined: Tue May 30, 2017 11:14 am

Re: Z88DK :- ZX Next Target (+zxn)

Postby Spec-chum » Thu Aug 17, 2017 11:57 pm

Incredible work!

So going to have to try and get my head round z88dk and give this a go.
I'm not insane; my mother had me tested

Posts: 18
Joined: Wed May 31, 2017 5:08 am

Re: Z88DK :- ZX Next Target (+zxn)

Postby adam » Fri Aug 18, 2017 7:28 pm

There's some interesting stuff in the new Z80 instructions (multiply!), I'm curious if the Z88DK compiler authors find these useful for generating better code, or if they have any killer suggestions for instructions that would make a lot of compiled code better.

Posts: 4
Joined: Fri Aug 18, 2017 9:47 pm

Re: Z88DK :- ZX Next Target (+zxn)

Postby dom » Fri Aug 18, 2017 9:53 pm

AA is in conversation I believe. There's a GitHub issue here: https://github.com/z88dk/z88dk/issues/312

We've got some (as of yet not enabled) post compilation replacement rules here: https://github.com/z88dk/z88dk/blob/mas ... xn_rules.1 and I've added a few bits to sccz80 as well.

The main win would really come from things like ld hl,(sp+n) and other instructions that the Rabbits have.

Alcoholics Anonymous
Posts: 775
Joined: Mon May 29, 2017 7:00 pm

Re: Z88DK :- ZX Next Target (+zxn)

Postby Alcoholics Anonymous » Sat Aug 19, 2017 3:50 am

The new instructions have a fairly big impact on the libraries too. I think we'll be making changes there for a while. It's not just in the math related functions (this is where I will be personally poking around first as we have a related longstanding issue with using the mult instructions for the z180 too), it reaches into the display file related functions, printing, scrolling, windows, etc. It's likely that we'll try to inline some of the functions with the new instructions.

Alcoholics Anonymous
Posts: 775
Joined: Mon May 29, 2017 7:00 pm

Re: Z88DK :- ZX Next Target (+zxn)

Postby Alcoholics Anonymous » Fri Aug 25, 2017 5:27 am


Actually this is no different from using Z88DK as you normally would - the toolchain is able to mix source code of a variety of types (.c, .asm, .c.m4, .asm.m4, .o, .lib, etc) and generate a single cohesive output. When writing pure asm, all that means is you're only going to be giving .asm source as input to zcc.

Z88DK itself supports about 50 different z80, z180 and rabbit targets. That includes familiar targets like the zx spectrum, zx81 and of course the zx next. It also has two independent libraries in it (called the "classic" and "new") and two c compilers (sccz80 and zsdcc). When writing pure asm, you won't be making use of the c compilers but this option is always open if you ever want to save development time for some portion of your code. The libraries make available to you about a thousand assembly language subroutines that are independent of the rom, and these cover a wide range of topics like floating point math, containers (linked lists, etc), disk io (esxdos), software sprite engines, text terminals, and so on. Again, using it is up to you.

Besides assembling your source code, Z88DK can also generate an appropriate output file. Specific output types for the zx next include plain binaries, .tap, .sna (48k or 128k as needed), esxdos dot command or esxdos extended dot command. In the future, Z88DK will be generating a self-contained file that can be loaded directly into all of the zx next's memory banks from an esxdos prompt.

Z88DK can deal with any number of memory banks easily. Z88DK will define a default memory map for the target, which it hands to the linker when it makes the output binaries. For the zx next, the memory model is still not settled so for now Z88DK defines 32 16k memory banks named "BANK_NN" for NN from 0 to 31 in hex, all of whose org is set to default 0xc000. This represents the memory that can be banked into the top 16k. The 128k spectrum would be confined to banks 00 to 07 (and this is the range a .sna snapshot would cover).

Most z80 assembers do not function like modern tools in that they don't implement object files, linking or librarian functions. Z88DK does operate like modern tools though so there will be some small changes to how asm files are organized and written.


Code: Select all

zcc +zxn -vn -m -startup=31 -clib=sdcc_iy [list of asm files separated by space] -o game -create-app
That's it. List all of your asm files in the spot shown. If you have a lot, consider putting them in a separate .lst file, one file per line. Then instead of, or in combination with, listing individual asm files, add the .lst file to the compile line as "@foo.lst".

The entry point of your program must be named "_main" and must be made PUBLIC. These details will be listed below but first an explanation of the compile line:
  • * zcc :- Z88DK's front end will take all your source files and produce an output file of the requested form.

    * +zxn :- choose the zx next target. This will enable the new opcodes and select the startup code from the zx next's set.

    * -vn :- keep the tools quiet. If you want to see what zcc is up to, use -v instead.

    * -m :- generate a map file that shows the value of every symbol.

    * -startup=31 :- select the startup code (defines what streams will be open at startup, see https://github.com/z88dk/z88dk/blob/mas ... loWorld.md ). Startup=31 is minimal, with no drivers present.

    * -clib=sdcc_iy :- select the library to use (in this case newlib rooted in https://github.com/z88dk/z88dk/tree/mas ... EVELOPMENT , you can use any code there in the z80 subdirectories). You don't have to use any library code but this also does some housekeeping.

    * -o game :- the root of the output filename.

    * -create-app :- asks Z88DK to generate a .tap file.

The startup code is provided by Z88DK and you can find it in https://github.com/z88dk/z88dk/tree/mas ... xn/startup . The program starts in the startup code, which is responsible for initialization and setting the memory map. The initialization the startup code does is completely controllable via pragmas and you will want to set some for any non-trivial project. That won't be discussed right now - we'll just be satisfied with the defaults. To give an indication of what the startup code might do: zero the BSS section, initialize the DATA section, move self-modifying code out of ROM, create the command line, initialize the heap, set interrupt mode, determine what to do on exit, etc. Via appropriate pragmas, the crt can be reduced to a couple dozen bytes. You can assemble your project without a crt but you will lose quite a few niceties if you do so so that's not recommended. Once the crt is finished, it calls "_main".

ASM programs must supply "_main" as their entry point. Further, they must make "_main" PUBLIC so that it is visible outside the file it is defined in. In Z88DK, every file's symbols are private to the file unless they are made PUBLIC. If symbols are made PUBLIC they are visible at global scope and can be seen by other asm or c files that import them with EXTERN.

An example:

Code: Select all

SECTION code_user
PUBLIC _main


   ld hl,0
This program just returns 0 in HL and will return to basic. Sections we will talk about shortly.


That depends - the crt is responsible for exiting and what it does can be customized via pragma. The default for most compiles is to return to basic with return value in BC (basic will get this value as the result of USR x used to start the program). The crt will do all the necessary things to make sure the return to basic is successful (restore basic's stack, set im1, restore IY and HL', etc).

If you're making an esxdos dot command, the crt will return to esxdos indicating an error or success. The error can include a canned error message or a custom one.

Other options can cause a controlled crash (reboot), infinite loop, program restart, and so on.

For the zx next target in particular, we may restore some hardware configuration so that the computer returns to a usable state (ie you're not showing layer 2 with no way to see what you're typing in basic).


Z88DK defines a default memory map that is used in all compiles. As mentioned previously, this includes regions for banked memory. The memory map is defined in terms of sections. Sections are just containers that will hold bytes as they are generated by the assembler. You control which sections your code and data get assigned to. If you want something in BANK_06, you put it there with a section directive ("section BANK_06"). The memory map determines how the sections are placed in memory.

Besides the extended memory banks, there is the concept of the main bank, that is where the main program sits when it is loaded. For the zx next / spectrum this corresponds to banks 5,2,0 or the main 48k ram. Z88DK creates a very detailed memory map for the main bank. The short of it is, it defines some sections for your code that you can assign to to make it part of the main binary:

Code: Select all

For read only instructions.

For read only constant data (ie storable in rom).

For self-modifying code that must be run from ram.

For non-zero initial data in ram.

For initially zero data in ram.
The distinctions are necessary so that Z88DK can generate programs that can be stored on ROM. If your program is destined for ROM, your variables can't be there - they must be mapped to ram, for example. So placing your stuff in appropriate sections means Z88DK will be able to generate ROMable software.

Even if you are only going to be programming the zx next and loading into ram so that these distinctions don't matter, it's a very good habit to get into to use appropriate sections. On the zx next this may come into play in a few circumstances :- one is if you want to write code to replace the basic rom, for example. Z88DK will allow you to do that. Another is because layer 2 can be mapped at 0-16K in write only mode, the code underneath must be read-only. So no variables or self-modifying code can be stored there. Z88DK can arrange that automatically IF YOU ASSIGN YOUR CODE TO SECTIONS APPROPRIATELY.

These are not the only sections you can use. You can even make some up if you want to map something to a specific memory address. Such a section will not be in the memory map so the linker will output that section as an independent binary file. You can also make your own memory map and have library code distributed across memory banks. But these are more advanced topics.

Two other sections which may be of interest are "section code_crt_init" which allows you to place initialization code that the crt will run before calling _main (such code must not contain a RET). The other is "section code_crt_exit" which will run after _main has returned (again no RET).


1. Multiple ORG is out in favour of section assignment. Allow the linker to pack your program in memory instead of manually doing it.

2. No master asm file that includes all other asm files. Assemblers do that when they have no concept of object files. Instead logically separate your program into many asm files and control symbol visibility between files with PUBLIC and EXTERN.

3. Macros are handled by m4. To use macros in your asm file, change its suffix from ".asm" to ".asm.m4". https://www.gnu.org/software/m4/manual/m4.html#Intro and more briefly http://mbreen.com/m4.html .

4. Local labels, procs, etc are largely unnecessary for linking assemblers. However, local variables can be useful inside macros. That is handled by m4 and various useful macros that Z88DK defines (ask if needed).

5. "foo EQU 7" is replaced with "defc foo = 7".

6. "ASMPC" means current PC (many other assemblers use $). However, because object files exist in Z88DK, ASMPC can be evaluated at two different times: at assemble time or link time. The tools will try to postpone as late as possible. Assemble time evaluations are not adjusted by final memory location (the linker has not run yet) but instead are an offset within a section within the file.

7. Probably other things.


1. Make a tap file.

Code: Select all

zcc +zxn -vn -m -startup=31 -clib=sdcc_iy game.asm -o game -create-app
This will make a tap file out of the main binary. This will not include any extended memory banks - those will be present as binary files after the compile. The tap format is very simple and allows larger taps to be made by concatenating smaller ones. One of Z88DK's tools, appmake, can be used to turn binaries into taps and to help construct a more customized tap file.

2. Make an sna file.

Code: Select all

zcc +zxn -vn -m -startup=31 -clib=sdcc_iy game.asm -o game -subtype=sna -create-app
Will make a 48k or 128k snapshot depending on whether any data is placed in the upper 16k banks 0-7. The main binary always occupies banks 5,2,0 which is the memory setup of the spectrum after reset. If code or data is placed directly into BANK_00, BANK_02, BANK_05 it is treated separately from the main binary and will have ORG 0xc000. These banks will be merged into the main binary at the correct offsets. To avoid overwrites, it's best to avoid doing this unless you know what you are doing.

3. Make an esxdos dot command.

Code: Select all

zcc +zxn -vn -m -startup=30 -clib=sdcc_iy game.asm -o game -subtype=dot -create-app
(startup=30 places the rom print routine on stdout, which is accessible from asm).

Dot commands must be less than about 7k in size. By default the crt will process the command line as argc, argv and these will be on the stack when _main starts. A pragma can change that to delivering the raw unprocessed command line in HL instead. Return values allow ok, canned error message or custom error message. Ask if you need examples.

4. Make an extended esxdos dot command.

Code: Select all

zcc +zxn -vn -m -startup=30 -clib=sdcc_iy game.asm -o game -subtype=dotx -create-app
The program splits into two parts. One is loaded at 0x2000 as normal and is limited to about 7k. The other is loaded into main ram above ramtop. A ramtop check is made to ensure ramtop is low enough to allow the second part to load. This dot command type allows programs larger than 7k to be started as a dot command. Ask if you need examples.


I'll just put two simple examples here.

"Hello World"
This one shows how to call into the Z88DK library to do some text output via the 64-col driver and stdio's puts function. Output is a .sna.

Code: Select all

zcc +zxn -vn -m -startup=5 -clib=sdcc_iy hello.asm -o hello -subtype=sna -create-app

Code: Select all

SECTION code_user

PUBLIC _main

EXTERN asm_puts


   ld hl,TEXT
   call asm_puts
   jr ASMPC       ;; we can't return from a snapshot

SECTION rodata_user


   defb 0x16, 0x0a, 0x0c, 0x12, 0x31
   defm "Hello", 0x12, 0x30, ", world!"
   defb 0
"ESXDOS Load Screen$"
This one loads a screen from disk using esxdos. Use any screen$ file you want, just change the filename in the asm file below. We'll be creating a snapshot so to load from 48k/esxdos use snapload as in ".snapload loadit.sna". Z88DK defines a lot of constants for the zx next and they can be accessed by including a defines file as shown. This file is automatically created when the zx next library is built and you can see its contents online here: https://github.com/z88dk/z88dk/blob/mas ... e.inc#L677 ( a little more documentation here: https://github.com/z88dk/z88dk/blob/mas ... _esxdos.m4 , in c header form https://github.com/z88dk/z88dk/blob/mas ... x/esxdos.h )

Code: Select all

zcc +zxn -vn -m -startup=31 -clib=sdcc_iy loadit.asm -o loadit -subtype=sna -create-app

Code: Select all

INCLUDE "config_zxn_private.inc"

SECTION code_user

PUBLIC _main


   ; instead of calling esxdos directly we could also call through the z80 library api at
   ; https://github.com/z88dk/z88dk/tree/master/libsrc/_DEVELOPMENT/arch/zx/esxdos/z80
   ; the advantage would be proper handling of errno and maybe easier to read code

   ld a,'*'   ;; use current drive
   ld ix,name   ;; when esxdos is paged in param is in hl, when paged out param is in ix
   ld hl,name   ;; should be ix here because we call from ram but emulator issues require both

   ret c

   push af
   ld ix,0x4000   ;; same as above
   ld hl,0x4000
   ld bc,6912
   pop af
   jr ASMPC


   defm "kv.bin",0
The same program done using the library functions instead. Use the same compile line:

Code: Select all

INCLUDE "config_zxn_private.inc"

SECTION code_user

PUBLIC _main

EXTERN asm_esxdos_f_open
EXTERN asm_esxdos_f_read
EXTERN asm_esxdos_f_close


   ; esxdos by way of the z80 library api at
   ; https://github.com/z88dk/z88dk/tree/master/libsrc/_DEVELOPMENT/arch/zx/esxdos/z80

   ld a,'*'       ;; use current drive
   ld hl,name     ;; the library code will copy hl into ix
   call asm_esxdos_f_open
   ret c

   push hl        ;; l = file handle
   ld a,l         ;; a = file handle
   ld hl,0x4000   ;; the library code will copy hl into ix
   ld bc,6912
   call asm_esxdos_f_read
   pop hl         ;; l = file handle
   call asm_esxdos_f_close

   jr ASMPC


   defm "kv.bin",0
I can't write a manual here but I think this is good enough to get started.
Last edited by Alcoholics Anonymous on Mon Aug 28, 2017 11:08 pm, edited 2 times in total.

Posts: 36
Joined: Tue May 30, 2017 11:14 am

Re: Z88DK :- ZX Next Target (+zxn)

Postby Spec-chum » Mon Aug 28, 2017 10:06 pm

Tried the esxdos example and getting this:

Code: Select all

C:\Users\specc\OneDrive\Coding\Speccy\loadScreen>zcc +zxn -v -m -startup=31 -clib=sdcc_iy loadit.asm -o loadit.sna -subtype=sna -create-app

PROCESSING loadit.asm
type "loadit.asm" >> "C:\Users\specc\AppData\Local\Temp\zcc938D2.asm"
type "C:\Users\specc\AppData\Local\Temp\zcc938D2.asm" >> "C:\Users\specc\AppData\Local\Temp\zcc938D2.tmp"
type "C:\Users\specc\AppData\Local\Temp\zcc938D2.tmp" >> "C:\Users\specc\AppData\Local\Temp\zcc938D2.asm"
z80asm -D__SDCC -D__SDCC_IY -I"D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn"  -s  --cpu=z80-zxn -I"D:\Retro\Speccy\z88dk\lib\config\..\..\/lib" -I"C:\Users\specc\OneDrive\Coding\Speccy\loadScreen"  "C:\Users\specc\AppData\Local\Temp\zcc938D2.asm"

PROCESSING D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn\zxn_crt.asm.m4
m4 -I "D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn" -I "D:\Retro\Speccy\z88dk\lib\config\..\..\/src/m4"  --define=__STARTUP=31  < "D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn\zxn_crt.asm.m4" > "C:\Users\specc\AppData\Local\Temp\zcc938D3"
type "C:\Users\specc\AppData\Local\Temp\zcc938D3" >> "D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn\zxn_crt.asm"
type "D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn\zxn_crt.asm" >> "C:\Users\specc\AppData\Local\Temp\zcc938D3.asm"
type "C:\Users\specc\AppData\Local\Temp\zcc938D3.asm" >> "C:\Users\specc\AppData\Local\Temp\zcc938D3.tmp"
type "C:\Users\specc\AppData\Local\Temp\zcc938D3.tmp" >> "C:\Users\specc\AppData\Local\Temp\zcc938D3.asm"


z80asm -D__SDCC -D__SDCC_IY -I"D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn"  -s  --cpu=z80-zxn -I"D:\Retro\Speccy\z88dk\lib\config\..\..\/lib" -I"D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn"  "C:\Users\specc\AppData\Local\Temp\zcc938D3.asm"

z80asm --cpu=z80-zxn -b -d  -o"loadit.sna" -m -s -L.  -L"D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\lib\sdcc_iy"   -D__SDCC -D__SDCC_IY -I"D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn" -izxn    "C:\Users\specc\AppData\Local\Temp\zcc938D3.o" "C:\Users\specc\AppData\Local\Temp\zcc938D2.o"
Assertion failed!

Program: D:\Retro\Speccy\z88dk\bin\z80asm.exe
File: modlink.c, Line 381

Expression: expr->target_name == NULL

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Errors in source file D:\Retro\Speccy\z88dk\lib\config\..\..\\libsrc\_DEVELOPMENT\target\zxn\zxn_crt.asm:
kv.bin is in source dir.

EDIT: Also tried it without the .sna extension on the output before this attempt.
I'm not insane; my mother had me tested

Posts: 36
Joined: Tue May 30, 2017 11:14 am

Re: Z88DK :- ZX Next Target (+zxn)

Postby Spec-chum » Mon Aug 28, 2017 10:13 pm

Ah, Hello example doing same thing...

EDIT: Changing output and startup types doesn't seem to help

EDIT2: Changing +zxn to +zx seems to help; issue with +zxn, AA?
I'm not insane; my mother had me tested

Alcoholics Anonymous
Posts: 775
Joined: Mon May 29, 2017 7:00 pm

Re: Z88DK :- ZX Next Target (+zxn)

Postby Alcoholics Anonymous » Mon Aug 28, 2017 10:50 pm

loadit.sna is an emulator issue. I fixed the source code above to work on both cspect and zesarux, try that one again.

When esxdos is already paged in at the bottom of memory (eg during a dot command), hl sometimes holds a parameter. If esxdos is not paged in (most of the rest of the time), ix is supposed to hold that parameter. cspect does not do dot commands so it always takes that param in ix. zesarux has been taking that param in hl always (zesarux has been fixed in its source tree but not in the last release). So the solution is to not worry about it and use both ix and hl for the param. The z80 api in the library, which I will do the same example with soon, copies hl into ix too.

For cspect you can load snas with F2. For zesarux you load the snapshot using esxdos: ".snapload loadit.sna" .

Hello.sna is working for me in both zesarux and cspect. I have fixed up the sna generator in appmake today. There's no next specific code in that program (not yet anyway - we haven't enable next opcodes for the library yet) so you can also test the sna in a regular spectrum emulator. If the sna is not working there it may be today's update will fix it. You can also try a tap file by getting rid of "-subtype=sna".

Who is online

Users browsing this forum: No registered users and 2 guests