z88dk on rc2014?

578 views
Skip to first unread message

codifies

unread,
Aug 20, 2017, 3:20:09 PM8/20/17
to RC2014-Z80
...as I understand it there has been significant work on bringing the rc2014

is Filippo github the definitive place to get it?

has anyone written a tutorial for getting this working (ideally on Linux) - what command line options etc ...

Is there any issue with using this to make code that will run from high memory and along side the 56k version of ms basic ?

phillip.stevens

unread,
Aug 20, 2017, 3:58:45 PM8/20/17
to RC2014-Z80
The rc2014 is fully supported by mainline z88dk. Use the main repository and install either the daily build, or clone the GitHub and build it yourself (preferred for Linux builds).

That said, only the subtype=basic-dcio is properly working currently. Other subtypes have some issues with terminal characters being mismatched. This subtype is designed for full-monty hardware with 32k RAM. Code runs from 0x9000, by default.

Another option is to use the cpm build which is also working fully, which is what you'd do if you were running the rc2014 in that mode.

Search this forum for some threads on the topic.

Enjoy, feilipu

codifies

unread,
Aug 20, 2017, 5:18:04 PM8/20/17
to RC2014-Z80

I'd be quite keen to modify or make a new subtype, what did you find most useful in learning how to do this? what files are involved ?

codifies

unread,
Aug 20, 2017, 5:21:02 PM8/20/17
to RC2014-Z80
must have done something wrong, it all compiles fine but....

zcc +rc2014 -subtype=basic-dcio -v -m -SO3 --max-allocs-per-node200000 --c-code-in-asm --list test.c  -o test -create-app
Cannot find definition for target -subtype=basic-dcio

phillip.stevens

unread,
Aug 20, 2017, 5:34:11 PM8/20/17
to RC2014-Z80
It is an underscore. subtype=basic_dcio

It is preferable to use pragma definitions unless there is a major hardware change, as z88dk is very flexible. Moving code, heap, or stack can all be done easily, on a per compile basis.

For 56k ram basic, the code origin can be moved lower like 0x2200, for example.

codifies

unread,
Aug 20, 2017, 6:44:05 PM8/20/17
to RC2014-Z80
is this documented anywhere (all the pragmas)

I make one build but it seemed to want to execute zsdcc when executing zcc, so a broke it somehow, I'll look again after some sleep...

A A

unread,
Aug 20, 2017, 10:52:15 PM8/20/17
to RC2014-Z80


On Sunday, August 20, 2017 at 4:44:05 PM UTC-6, codifies wrote:
is this documented anywhere (all the pragmas)


Yes the pragmas are described here:
https://www.z88dk.org/wiki/doku.php?id=libnew:target_embedded#compile_time_customization

The defaults for the rc2014 are defined in the rc2014 target directory:
https://github.com/z88dk/z88dk/blob/master/libsrc/_DEVELOPMENT/target/rc2014/crt_config.inc

There are three configurations in there depending on what subtype is active (you can guess from the acia and basic names).

When you invoke zcc with "zcc +rc2014 ..." it will read the default options for the rc2014 from rc2014.cfg:
https://github.com/z88dk/z88dk/blob/master/lib/config/rc2014.cfg

The lines from 13 and below for clib and subtype are optional and those options will only be read if a -clib or -subtype is on the command line.   The OPTIONS line is always read but can be overridden by the user compile line.

The clibs are choosing library and compiler.  The subtypes are choosing refinements for the rc2014 compile  So one is doing a compile for basic and another for the acia driver.  The main difference is what devices are attached to stdin,stdout,stderr and whether an interrupt routine is provided.  They're making this distinction with a startup value that is used in the rc2014's master crt:

https://github.com/z88dk/z88dk/blob/master/libsrc/_DEVELOPMENT/target/rc2014/rc2014_crt.asm.m4

This crt is just a switch on the startup value that will select the actual crt code from the startup subdirectory and it will set the memory map and default configuration (the default pragmas).


> I make one build but it seemed to want to execute zsdcc when executing zcc, so a broke it somehow, I'll look again after some sleep...

For the rc2014 the default c compiler is zsdcc.  There are two c compilers in z88dk:  sccz80 and zsdcc.   zsdcc is maintained separately from the z88dk codebase currently because it is a fork (well we don't want it to be) of sdcc  If you download the nightly builds for windows or mac osx, they will contains everything including zsdcc binaries.  However, if you're running linux you have to build zsdcc separately:

https://www.z88dk.org/wiki/doku.php?id=temp:front#sdcc1

You can use sccz80 instead by replacing (or adding) the clib option "-clib=new" to the compile line.

Hope that helps.

phillip.stevens

unread,
Aug 20, 2017, 10:53:56 PM8/20/17
to RC2014-Z80
is this documented anywhere (all the pragmas)

The z88dk process for the subtype=basic_dcio is documented here, and here.

But for the purposes of completeness, here it is again.

Cold Start the RC2014, and set the Memory top? to be 35071 (0x88FF).
The hexload.bas file is then "typed" into the RC2014 either by hand (ahhgh noooo), or by using

python slowprint.py > /dev/ttyUSB0 < hexload.bas

That will automatically start the hexload program running from origin at 0x8900, and it will wait for a z88dk HEX encoded program (asm or C) to be cat'ed to the RC2014.

cat > /dev/ttyUSB0 < eliza.ihx

You could also use slowprint.py for this job, but who has time for that?

The default origin for the rc2014 basic subtype for z88dk is 0x9000, but this can be flexibly changed as desired.

The hexload program origin is 0x8900, and this leaves some free space before the z88dk default origin.

Now, the (really) final z88dk piece is in place. Previously the -subtype=basic did very simple handling of the command line, and did not permit interactive line editing or such like.

But... now... aralbrec has prepared an additional option -subtype=basic_dcio which supports interactive command line editing.

You can build some example C programs like those below.

# in a directory with the source files

:~$ zcc +rc2014 --subtype=basic_dcio -SO3 -clib=sdcc_iy --max-allocs-per-node200000 password.-o password -create-app
:~$ zcc +rc2014 --subtype=basic_dcio -SO3 -clib=sdcc_iy --max-allocs-per-node200000 eliza.c -o eliza -create-app

# with your RC2014 connected

:~$ python slowprint.py > /dev/ttyUSB0 < hexload.bas
:~$ cat > /dev/ttyUSB0 < password.ihx # or
:~$ cat > /dev/ttyUSB0 < eliza.ihx

I've attached compiled versions of two programs (elizapassword), which can be checked by using the hexload.bas.
Note again the starting point for this is the standard "Full Monty" or "Mini" RC2014, with 32kB of RAM, and the standard ROM. The 56kB (64kB) RAM board is also supported, though the additional RAM will not be used, unless some default #pragmas are redefined.

Default #pragmas for each z88dk target, are held in their specific crt_config.inc file (and many other config files) which generate further configuration using the m4 preprocessor, which runs as part of each zcc (z80asm or zsdcc) compilation process. There is information on pragmas in the z88dk wiki.

Create a file to contain pragmas. Call it mypragma.inc, or whatever you like. In the file you'll need the following lines to appear.

#pragma output CRT_ORG_CODE           = 0x2400  // new origin for 56kB RAM module.
#pragma output REGISTER_SP            = 0  // stack origin is 0 (0xFFFF).
#pragma output CLIB_MALLOC_HEAP_SIZE  = -1 // -1 has the crt automatically place the heap between the end
                                           
// of the bss section and the bottom of the stack
                                           
// (now located in its usual position above the bss).

Then from the command line add the following incantation -pragma-include=mypragma.inc to your usual compilation instructions.

Although with startrek.c specifically, the heap should be disabled with CLIB_MALLOC_HEAP_SIZE = 0 so that it doesn't take up memory space.

#pragma output CLIB_MALLOC_HEAP_SIZE  = 0

There are pragmas in startrek.c that do this, but your pragma file above will override those.

Pragma priority is:
  1. specified on the compile line
  2. specified in a pragma file
  3. specified in a .c source file
For compiles where the crt automatically generates a heap ( CLIB_MALLOC_HEAP_SIZE is negative), there is a heap size calculation done at runtime.  If the heap size comes out negative, ie there is no space for a heap, the program will just terminate.  When CLIB_MALLOC_HEAP_SIZE = -1, the crt creates a heap that extends from the end of your program to the bottom of the stack (the bottom of the stack is the current value of SP minus headroom CRT_STACK_SIZE bytes which is typically 256 or 512).  When CLIB_MALLOC_HEAP_SIZE < -1, its absolute value is taken as the address of the last byte of the heap and the crt will try to make a heap from the end of your program to that address.   The other options are 0 which eliminates the heap and a positive value which will create a heap of that size in the bss section.

There are many options for changing the way that z88dk builds the result, and these can be extensively controlled using pragmas. Some reading on the wiki, and searching / reading on z88dk GitHub will help.

Enjoy, feilipu

 

A A

unread,
Aug 20, 2017, 11:04:41 PM8/20/17
to RC2014-Z80
Staring at that ide code has made you into an expert now :D

phillip.stevens

unread,
Aug 20, 2017, 11:12:14 PM8/20/17
to RC2014-Z80
Staring at that ide code has made you into an expert now :D

LOL... nope.

Just a few well worn sheep tracks through a field of z88dk options ;-)



codifies

unread,
Aug 21, 2017, 4:21:06 AM8/21/17
to RC2014-Z80
Thanks guys - hopefully I have enough to get cracking, all I need now is some more free time - damn you real life!!

codifies

unread,
Aug 21, 2017, 12:15:01 PM8/21/17
to RC2014-Z80
I tried ZCCCFG with and without a trailing slash, it wasn't doing this last night....!

[chris@xpslaptop C]$ zcc +rc2014 -v -subtype=basic_dcio -SO3 -pragma-include=pragmas.inc -clib=sdcc_iy --max-allocs-per-node200000 test.c -o test -create-app
at 1: error 119: don't know what to do with file '+rc2014'. file extension unsupported

ZSDCC IS A MODIFICATION OF SDCC FOR Z88DK
Build: 3.6.9 #9958 (Linux) Aug 20 2017

sdcc website:
https://sourceforge.net/projects/sdcc/

patch details:
https://github.com/z88dk/z88dk/blob/master/libsrc/_DEVELOPMENT/sdcc_z88dk_patch.zip

published under GNU General Public License (GPL)

[chris@xpslaptop C]$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/share/apache-ant/bin:/opt/haxe-3.4.2:/home/chris/development/z88dk/bin/

[chris@xpslaptop C]$ echo $ZCCCFG
/home/chris/development/z88dk/lib/config

A A

unread,
Aug 21, 2017, 1:04:59 PM8/21/17
to RC2014-Z80


On Monday, August 21, 2017 at 10:15:01 AM UTC-6, codifies wrote:
[chris@xpslaptop C]$ zcc +rc2014 -v -subtype=basic_dcio -SO3 -pragma-include=pragmas.inc -clib=sdcc_iy --max-allocs-per-node200000 test.c -o test -create-app
at 1: error 119: don't know what to do with file '+rc2014'. file extension unsupported


Did you install an old version of z88dk?  z88dk/lib/config/rc2014.cfg should exist.

The release at sourceforge is about a thousand commits behind, use a zip or clone from github instead:
https://github.com/z88dk/z88dk

But keep your zsdcc and zsdcpp binaries - those are fine.

codifies

unread,
Aug 21, 2017, 1:48:23 PM8/21/17
to RC2014-Z80
noo..... I got it from git hub (clone) about a day ago

ls development/z88dk/lib/config/rc2014.cfg
development/z88dk/lib/config/rc2014.cfg

and it *looks* sane! - jeeze assembly language is such an easy language by comparison !

A A

unread,
Aug 21, 2017, 3:26:45 PM8/21/17
to RC2014-Z80
Do you have Bleu tools installed?  It's got its own version of zcc in it.  It could be you are running the Bleu tools zcc instead of z88dk.

Try a "which zcc" and see where it's being found.  Then try to put z88dk/bin at the front of your path so you will for sure use the z88dk binaries.



On Monday, August 21, 2017 at 11:48:23 AM UTC-6, codifies wrote:

and it *looks* sane! - jeeze assembly language is such an easy language by comparison !


Most z80 tools are very basic but there can be no shortcuts in z88dk - you need the linker, librarian, macro processing, multiple crts and so on because you need to share a large library amongst a lot of different machines with differing memory architectures and so on.  It's not as complicated as it looks at first glance :)

codifies

unread,
Aug 21, 2017, 5:41:15 PM8/21/17
to RC2014-Z80
which points to the only copy of zcc I have...

I'm at a bit of a loss...

A A

unread,
Aug 21, 2017, 9:13:07 PM8/21/17
to RC2014-Z80


On Monday, August 21, 2017 at 3:41:15 PM UTC-6, codifies wrote:
which points to the only copy of zcc I have...
I'm at a bit of a loss...


I'm not sure what it could be either.

If I give zcc an unknown target:

zcc +thing -v -subtype=basic_dcio -SO3 -pragma-include=pragmas.inc -clib=sdcc_iy --max-allocs-per-node200000 test.c -o test -create-app
Can't open config file c:\Projects\z80\z88dk\z88dk\lib\config/thing.cfg

If I don't give it a target as in "+rc2014" being treated as file:

zcc -v -subtype=basic_dcio -SO3 -pragma-include=pragmas.inc -clib=sdcc_iy --max-allocs-per-node200000 test.c -o test -create-app
A config file must be specified with +file as the first argument

And the error you see:

"at 1: error 119: don't know what to do with file '+rc2014'. file extension unsupported"

is nowhere to be found in z88dk (I just did a search on the whole codebase).

There must be another zcc in there?
I will try to compile from scratch on linux later to make sure it works for me.

A A

unread,
Aug 21, 2017, 9:19:24 PM8/21/17
to RC2014-Z80

Typing "zcc -h" should print this:



A config file must be specified with +file as the first argument

zcc - Frontend for the z88dk Cross-C Compiler - vMSC build-20170821

Usage: zcc +[target] {options} {files}

Søren Amtorp

unread,
Aug 23, 2017, 12:11:18 PM8/23/17
to RC2014-Z80
Does the compiler run on linux or is linux used just for building it?


phillip.stevens

unread,
Aug 23, 2017, 7:51:34 PM8/23/17
to RC2014-Z80
Does the compiler run on linux or is linux used just for building it?

The whole z88dk development kit runs on any of:
  • Mac
  • Windows
  • Linux
From Linux I tend to do a pull and build each day I'm working on something.

SDCC is also updated very regularly (daily), and often has updates relevant to the z80.
Personally, I tend to watch their changelog, and rebuild my version monthly, if there's nothing special appearing.

Enjoy

phillip.stevens

unread,
Aug 23, 2017, 8:41:31 PM8/23/17
to RC2014-Z80
In addition, z88dk is such a large "beast" of a solution (multiple compilers and libraries), sometimes it feels a bit unwieldy trying to just get some simple code assembled to arrive at the right Intel hex code, for some simple tests.

At the moment I'm working on some driver code that is currently outside the z88dk system, and I don't need all of the CRTs and Standard Library code to do the testing. Fortunately, there's a solution for that too.

In summary, you need to list the asm files you need into a lst file.
The first file in the list should be a map file, to allow appmake to glue your assembled code into the right places to produce the hex output.

For example. I'm working on the Lawrence Livermore Laboratories floating point code currently, together with a driver for the Am9511A, and a small test program. These three files are listed together with a map file to locate each section of code in tstfloat.lst.

tstfloat_map.asm
am9511a
.asm
z80_lllf
.asm
tstfloat
.asm

The map file contains all the preferred section origins, and needs to come first. These don't need to be special section names. Make up what suits your desire.
Note this specific mapping example below is only useful if you've got a 64kB RAM module using the 32k Basic ROM.
Any other mapping which arrives at real RAM works.

In your code, you then reference these sections. Multiple separate references to sections are concatenated properly, so it is easy to mix code and data into one file, or have code appear in different files, but have them all assembled into the correct places in the output hex.

SECTION apu_data_align_256
ORG $2500
 
SECTION apu_data
ORG $2700
 
SECTION apu_driver
ORG $2800
 
SECTION apu_library
ORG $3000
 
SECTION code_user
ORG $9000

Then to get a complete Intel hex file with all of the binaries located in the right places, with the compilation byproducts removed, there are two commands required. The zcc command just references the .lst file, and specifies that a map file be generated with -m. The appmake command takes the resulting binaries, and using the generated map file, and glues them into Intel hex in the right locations. It then cleans up.

> zcc +rc2014 --no-crt -m @tstfloat.lst -o tstfloat
> appmake +glue -b tstfloat --ihex --clean

The resulting .ihx file can then be uploaded to your RC2014 using hexload or any other method. There is also a complete binary available too.

Also, there is a automatic private include file available, which saves declaring a whole lot of constants for every asm file you create.
It is referenced by this line.

INCLUDE "config_rc2014_private.inc"

Hope this helps.

A A

unread,
Aug 23, 2017, 10:38:22 PM8/23/17
to RC2014-Z80


On Monday, August 21, 2017 at 7:13:07 PM UTC-6, A A wrote:

And the error you see:
"at 1: error 119: don't know what to do with file '+rc2014'. file extension unsupported"

is nowhere to be found in z88dk (I just did a search on the whole codebase).


codifies, I found this error in zsdcpp.   I'm not sure why it sees "+rc2014" yet because that should be removed by zcc.

Can you provide all the output generated from executing this line?  The output should include how each tools is invoked.

zcc +rc2014 -v -subtype=basic_dcio -SO3 -pragma-include=pragmas.inc -clib=sdcc_iy --max-allocs-per-node200000 test.c -o test -create-app

Søren Amtorp

unread,
Aug 24, 2017, 2:33:28 AM8/24/17
to RC2014-Z80
I am not very familiar with git. I have mainly used it on windows from Visual studio. Could you please tell me how I make a pull from linux.

phillip.stevens

unread,
Aug 24, 2017, 2:45:16 AM8/24/17
to RC2014-Z80
There is a how-to on z88dk, but I wrote this to remind me what to do.

https://feilipu.me/2016/09/16/z80-c-code-development-with-eclipse-and-z88dk/

Hope this helps.

codifies

unread,
Aug 24, 2017, 5:24:13 PM8/24/17
to RC2014-Z80
git clone <url of repository>

one of the simpler things you can do with git! YMMV getting it to work mind!

codifies

unread,
Aug 24, 2017, 5:25:15 PM8/24/17
to RC2014-Z80
Thanks I'll take a look!

Søren Amtorp

unread,
Aug 24, 2017, 6:23:35 PM8/24/17
to RC2014-Z80
Well, well - I love those comments. Thanks for telling me how to clone on Linux! Now tell me that making a pull request is exactly the same as  cloning a repository? 

codifies

unread,
Aug 25, 2017, 6:19:10 AM8/25/17
to RC2014-Z80
heck no! to be honest pull requests are more to do with how github.com works and to be honest their docs are probably your best source...

codifies

unread,
Aug 25, 2017, 6:22:15 AM8/25/17
to RC2014-Z80
okay that got it! (I think it works - many thanks!!!)

I had to change

-subtype=rom

to

-subtype=basic_dcio

but I guess thats down to the age of the post.

at the moment my rc2014 is embroiled in a hardware project, but I took a quick break and compiled a hello world
fragment the bin looks sane, but I will have to test at a later date!

again many thanks !



On Thursday, August 24, 2017 at 7:45:16 AM UTC+1, phillip.stevens wrote:

phillip.stevens

unread,
Aug 25, 2017, 8:31:15 AM8/25/17
to RC2014-Z80
okay that got it! (I think it works - many thanks!!!)

I had to change
-subtype=rom
to
-subtype=basic_dcio

but I guess that's down to the age of the post.

These are the valid options, currently, with the startup code they imply.

acia -startup=0 -Cz"+rom --ihex"
basic
-startup=16 -Cz"+rom --ihex"
basic_dcio
-startup=17 -Cz"+rom --ihex"
none
-startup=256 -Cz"+rom --ihex"

But for assembling simple code (without a crt0 or use of the libraries), then the --no-crt option is also valid.

acia is meant to replace the entire ROM from 0x0000, and brings in the entire ACIA for an accelerated terminal. It works, but needs some work to make it deal with line editing, etc. Really it needs the _dcio option code prepared and added. Work in progress.

basic_dcio is the "go to" option for installing with hexload.
It adds line editing to the Grant Searle Microsoft Basic ACIA code, and is the option I use most frequently (except the --no-crt path).

I think that is up to date. And, the links will be always valid, in the case this post ages badly.

Good luck.
 

codifies

unread,
Aug 25, 2017, 12:38:31 PM8/25/17
to RC2014-Z80
thanks, much appreciated, must get star trek a whirl after my hardware hacking!

On Sunday, August 20, 2017 at 8:20:09 PM UTC+1, codifies wrote:
...as I understand it there has been significant work on bringing the rc2014

is Filippo github the definitive place to get it?

has anyone written a tutorial for getting this working (ideally on Linux) - what command line options etc ...

Is there any issue with using this to make code that will run from high memory and along side the 56k version of ms basic ?

Søren Amtorp

unread,
Oct 10, 2017, 5:05:31 AM10/10/17
to RC2014-Z80
I am almost completely moved to Linux now. Gee a lot have happen since I was playing with Linux more than 10 years ago. For sure I am not investing more money in Windows ever.

I just compiled and setup the Z88dk on a ubuntu 14 linux cross compiled to run a Cortex A9 ARM (implemented inside a Cyclone 5 FPGA). Cool stuff I can tell you. The root filesystem I build from the basic root file system for Ubuntu 14.

Any way. I just wanted to add this comment to your excellent instructions in your blog.

I added --depth=1 to the git cloning command since I have little use for the complete revision history to compile the latest version. Maybe you should make a note about this option for those who are not that familiar with git (like me). 

Cheers 

Charlie
Reply all
Reply to author
Forward
0 new messages