New version of Cowgol dev environment on Z80 CP/M

749 views
Skip to first unread message

ladislau szilagyi

unread,
Feb 25, 2025, 3:12:45 AMFeb 25
to RC2014-Z80
I published a new version of the Cowgol development environment on Z80 CP/M,


It is aligned to the current version of Cowgol language ( https://github.com/davidgiven/cowgol )

The Cowgol compiler can be executed on any 64KB Z80 machine running CP/M.

Enhanced versions are available for 128KB/512KB RAM computers, including those running ROMWBW.

An (incomplete) list of popular retro-computers running the Cowgol compiler:
 
-RC2014 provided with SC108, SC114, SC118, SC150, SC152 or the Phillip Stevens memory module, or the 512KB RAM + 512KB ROM module, or -RCBUS-based systems provided with SC707, SC714, or -Z80ALL (which has 4 x 32KB RAM) or -Simple80 (2 x 64KB RAM) or -ROMWBW on 512KB RAM Z80 systems (256 KB RAM available for Cowgol)
Ladislau

ladislau szilagyi

unread,
Feb 27, 2025, 7:43:34 AMFeb 27
to RC2014-Z80
Added Colossal Cave Adventure game, translated to Cowgol (see https://github.com/Laci1953/Cowgol_on_CP_M/tree/main/GAMES/Adventure)

This is an early functional version of the game, probably there are still bugs to be fixed. The main purpose of this experiment was to use the @extern attribute of subroutines, in order to have a large source file divided into several smaller source files, each using the @external mechanism. It also validated the capability of the tools belonging to the Cowgol toochain. As a detail about the size of this project: the Z80 assembler source file containing the game, built by the compiler, has ~13000 lines, its size is > 200 KB.

Ladislau

Mark Pruden

unread,
Mar 1, 2025, 6:32:45 PMMar 1
to RC2014-Z80
i will definitely check this one out. The game is one of the landmarks in computer game history, i came across this map of the various versions and ports. which is quite an eye opener.

Tim Radde

unread,
Mar 1, 2025, 7:13:37 PMMar 1
to RC2014-Z80
Colossal Cave or Adventure was amazing back in the day.  It was just so different and so much fun.  Many places had to lock out when it could be run as people were playing during the day and soaking up all the CPU.  :)

ladislau szilagyi

unread,
Mar 2, 2025, 7:22:34 AMMar 2
to RC2014-Z80
Hi Mark,

my Adventure game is aligned to the DAIM0350 version from your map.

I took it from https://github.com/Quuxplusone/Advent, and tried to port-it to the Cowgol language.

But... I'm still testing it.

It loads ok, I can save/restore games, but, as you already know , there are a lot of features to be verified...

Overall, I am happy that I could port this game to Cowgol language, given its size & complexity.

regards,
Ladislau

ladislau szilagyi

unread,
Mar 3, 2025, 1:57:02 AMMar 3
to RC2014-Z80
Hi ,

after fixing some bugs, it seems the game can be played safely... I published the corrected version.

Here is a run sample, including some hints:

c>advent


                Welcome to ADVENTURE!
                =====================
        -Original development by Willie Crowther.
        -Major features added by Don Woods.
        -Conversion to BDS  C by J. R. Jaeger
        -Unix standardization by Jerry D. Pohl.
        -OS/2 Conversion by Martin Heller
        -Conversion to TurboC 2.0 by Daimler

            Would you like instructions?

>y


Somewhere nearby is Colossal Cave, where others have
found fortunes in treasure and gold, though it is rumored
that some who enter are never seen again.  Magic is said
to work in the cave.  I will be your eyes and hands.  Direct
me with commands of 1 or 2 words.  I should warn you that I
look at only the first five letters of each word, so you'll
have to enter "Northeast" as "ne" to distinguish it from
"North".  (Should you get stuck, type "help" for some
general hints).

You are inside a building, a well house for a large spring.
There are some keys on the ground here.
There is a shiny brass lamp nearby.
There is tasty food here.
There is a bottle of water here.
>help
I know of places, actions, and things.  Most of my vocabulary
describes places and is used to move you there.  To move, try
words like forest, building, downstream, enter, east, west,
north, south, up or down.  I know about a few special
objects, like a black rod hidden in the cave.  These objects
can be manipulated using some of the action words I know.
Usually you will need to give both the object and action
words (In either order), but sometimes I can infer the
object from the verb alone.  Some objects also imply verbs;
in particular, "inventory" implies "take inventory", which
causes me to give you a list of what you're carrying.  The
objects have side effects; for instance, the rod scares the
bird.  Usually people having trouble moving just need
to try a few more words.  Usually people trying unsuccessfully
to manipulate an object are attempting something beyond their
(or my!) capabilities and should try a completely different
tack.  To speed the game you can sometimes move long distances
with a single word.  For example, "building" usually gets you
to the building from anywhere above ground except when lost
in the forest.  Also, note that cave passages turn a lot, and
that leaving a room to the north does not guarantee entering
the next from the south.
Good luck!
>eat food
Thank you.  It was delicious!
>drink water
The bottle of water is now empty.
>take keys
ok.
>take lamp
ok.
>light lamp
Your lamp is now on.
>inventory
You are currently holding the following:
Set of keys.
Brass lantern
>go west
You are standing at the end of a road before a small brick
building.  Around you is a forest.  A small stream flows out
of the building and down a gully.
>
...

Enjoy,
Ladislau

ladislau szilagyi

unread,
Mar 6, 2025, 10:14:25 AMMar 6
to RC2014-Z80
I published here: https://github.com/Laci1953/Cowgol_on_CP_M/tree/main/GAMES/KnightsTour 

the Knights Tour program, written in Cowgol.

A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square exactly once. The computer will keep trying to generate such tours, until successfully completing one! It works on any VT100 compatible terminal.

Ladislau

ladislau szilagyi

unread,
Mar 9, 2025, 8:53:53 AMMar 9
to RC2014-Z80
Hi,

Of course, I couldn't miss the opportunity to implement TETRIS in the Cowgol language!

It is published here: https://github.com/Laci1953/Cowgol_on_CP_M/tree/main/GAMES/Tetris

It can be executed on any Z80 machine provided with a VT100 compatible terminal.

Ladislau

ladislau szilagyi

unread,
Mar 10, 2025, 12:59:27 PMMar 10
to RC2014-Z80
Hi,


, a program to solve the 8 queens puzzle.

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. There are 92 solutions. This is a good example of a reentrant C routine called from Cowgol (remember, the Cowgol language does not allow recursion!) Run sample: D>queens Solution 1 * _ _ _ _ _ _ _ _ _ _ _ * _ _ _ _ _ _ _ _ _ _ * _ _ _ _ _ * _ _ _ _ * _ _ _ _ _ _ _ _ _ _ _ * _ _ * _ _ _ _ _ _ _ _ _ * _ _ _ _ Solution 2 * _ _ _ _ _ _ _ _ _ _ _ _ * _ _ _ _ _ _ _ _ _ * _ _ * _ _ _ _ _ _ _ _ _ _ _ * _ _ _ _ * _ _ _ _ _ * _ _ _ _ _ _ _ _ _ _ * _ _ _ ... Solution 92 _ _ _ _ _ _ _ * _ _ _ * _ _ _ _ * _ _ _ _ _ _ _ _ _ * _ _ _ _ _ _ _ _ _ _ * _ _ _ * _ _ _ _ _ _ _ _ _ _ _ _ * _ _ _ _ _ * _ _ _ D>

Ladislau

ladislau szilagyi

unread,
Mar 23, 2025, 3:01:34 AMMar 23
to RC2014-Z80
Hi,

Interestingly, the Cowgol executables tend to be smaller than those written in C !

Example: comparing the size of Adventure (Colossal Cave) game (C vs. Cowgol).

Adventure (C language) memory map:         TOTAL 0B41BH ~= 45 KB
Adventure (Cowgol language) memory map: TOTAL 09A14H ~= 38.5 KB

This could be important for very large programs...

Ladislau


Alan Cox

unread,
Mar 23, 2025, 9:01:37 AMMar 23
to rc201...@googlegroups.com
On Sun, 23 Mar 2025 at 07:01, ladislau szilagyi <ladislau...@gmail.com> wrote:
Hi,

Interestingly, the Cowgol executables tend to be smaller than those written in C !

Example: comparing the size of Adventure (Colossal Cave) game (C vs. Cowgol).

Adventure (C language) memory map:         TOTAL 0B41BH ~= 45 KB
Adventure (Cowgol language) memory map: TOTAL 09A14H ~= 38.5 KB

This could be important for very large programs...

Ladislau
 
Using which C compiler ?

The Fuzix advent is 28K so can run in 32K RAM but I suspect it's keeping more stuff on disk than yours is.

ladislau szilagyi

unread,
Mar 23, 2025, 10:05:40 AMMar 23
to RC2014-Z80
Hi Alan,

I'm using the HiTech v3.09 C compiler. 
I personally consider-it the best C compiler for Z80... when using the -O (optimize) option it produces a quite compact code. 

For Adventure, the C sources I use are here: https://github.com/Laci1953/RC2014-CPM/tree/main/ADVENTURE

Both sets use a lot of stuff stored on the disk (advent1.txt... advent4.txt).

I suppose your version keeps even more stuff on disk... or use a compressed sort-of database containing the possible paths ?!?

Ladislau

ladislau szilagyi

unread,
Mar 24, 2025, 12:52:53 AMMar 24
to RC2014-Z80
Hi again Alan,

at a closer look, our two Adventure C-language versions (implementations) are quite different; in fact, DAIM0350 and RAUS0350 are very distanced in the https://mipmip.org/advfamily/advfamily.html "family tree".

But, back to my initial statement (Cowgol code is smaller) ... I presume that this is a typical case of code generated by two different approaches:

- HiTech C, where local variables are stored on the stack
- Cowgol, where local variables are static ( kind-of , because they are not fully static, e.g. if A calls B and C, but B does not call C and C does not call B, B and C local variables overlap each other)

... and the 'local storage' results in more compact code, due to the Z80 registers & instruction set.

In fact, I "translated" very strictly the DAIM0350 Adventure C source into Cowgol source, conserving all the data-related structures.
And, the difference in executables size is significant (45KB vs. 38.5KB). 

Interestingly, more optimization could be done on the Cowgol code (so the code might be even slimmer...).

E.g. the Cowgol compiler's second step occasionally fails to assign the right registers : 

Suppose I want to assign a value to a variable ( VARA := 1; ). The compiler produces often :

 LD IY,1
 LD (VARA),IY

instead of

 LD BC,1
 LD (VARA),BC

because it (wrongly) picks IY or IX (instead of BC or DE) to be used... and this results in more bytes being used (and slower exec time...)

This is not the only vulnerability of the current Cowgol compiler... I tried to compensate some of them by post-processing (with COWFIX) the temporary output of the compiler (the assembler source produced by COWLINK), but post-processing is sometimes difficult and time consuming...

In many cases I did optimize the assembler output of the compiler, in other cases I could not (see COWFIX source comments).

As a comment, COWFIX was absolutely necessary to be inserted in the Cowgol compiler toolchain, because the original output of the compiler contained some 'exotic' statements, such as 'POP B' instead of 'POP BC', and I used the occasion to do some code additional optimizations too, e.g:

 RET Z

instead of:

 JP NZ,label
 RET
label:
 
Ok, enough with such boring details, thanks for following this thread,

Ladislau

ladislau szilagyi

unread,
Mar 24, 2025, 12:10:08 PMMar 24
to RC2014-Z80
Hi,

because the Cowgol compiler statically allocates all the local variables of a subroutine, in theory it is impossible to write recursive Cowgol subroutines.

But, in practice, using the Cowgol language @asm feature, this becomes possible!


an example (computing the 'factorial' of an integer : n! = product of all integers less or equal to n).

The key factor of this implementation is, of course, using the stack, and a pointer to the function calling itself...

Ladislau

Wayne Warthen

unread,
Mar 24, 2025, 11:20:17 PMMar 24
to RC2014-Z80
Hi Ladislau,

I am trying to update the Cowgol disk image for RomWBW.  I have everything working with the latest files except a couple of things:
  • The HEXDUMP example builds OK, but when run it always reports that the target file to dump is not found.  See my log below.  This example worked under your prior Cowgol distribution.  Can you confirm it is working for you?
  • The readme.txt in the EXAMPLES folder refers to files ONE.COW and TWO.COW which I am unable to find.
Thanks, Wayne

K>COWGOL -M HEXDUMP.COW
COWGOL COMPILER (CP/M-80) V2.0
Copyright (C) David Given
0:COWFE     HEXDUMP.COW $CTMP1.$$$
COWFE: 22kB free
96kB free extended memory
  > HEXDUMP.COW
    > stdcow.coh
      > cowgol.coh
        > common.coh
      < cowgol.coh
    < stdcow.coh
      > file.coh
        > commfile.coh
      < file.coh
    < stdcow.coh
      > strings.coh
    < stdcow.coh
      > malloc.coh
    < stdcow.coh
  < HEXDUMP.COW
    > argv.coh
  < HEXDUMP.COW
done: 17kB free
77kB free extended memory
0:COWBE $CTMP1.$$$ HEXDUMP.COO
COWBE: 27kB free
__main
Exit
ExitWithError
AlignUp
get_char
print_char
MemSet
print
print_nl
UIToA
IToA
print_i32
print_i16
print_i8
print_hex_i8
print_hex_i16
print_hex_i32
AToI
MemZero
file_i_init
fill
fcb_i_gbpb
fcb_i_blockin
fcb_i_blockout
fcb_i_changeblock
fcb_i_convert_a_to_error
FCBOpenIn
FCBOpenUp
FCBOpenOut
FCBClose
FCBSeek
FCBPos
FCBExt
fcb_i_nextchar
FCBGetChar
FCBPutChar
FCBPutString
FCBGetBlock
FCBPutBlock
StrCmp
ToLower
StrICmp
StrLen
CopyString
MemCopy
DumpBlocks
CheckMemoryChain
RawAlloc
Alloc
AddFreeBlock
Free
GetFreeMemory
StrDup
FCBPutHex8
FCBPutHex16
FCBPutHex32
print_d32
GetString
ArgvInit
ArgvNext
Hexdump
done: 19kB free
0:COWLINK COWGOL.COO HEXDUMP.COO -o $CTMP1.$$$
COWLINK: 49kB free
Adding input file: COWGOL.COO
Adding input file: HEXDUMP.COO
Analysing...
Workspace sizes:
  #0: 231 bytes
Creating output file: $CTMP1.$$$
Copying from input file: COWGOL.COO
Copying from input file: HEXDUMP.COO
done: 44kB free
0:COWFIX $CTMP1.$$$ $CTMP2.$$$
ERA $CTMP1.$$$
0:Z80AS -J -N -OHEXDUMP.OBJ $CTMP2.$$$
Z80AS Macro-Assembler V4.8

Errors: 0

Jump optimizations done: 59
Finished.
ERA $CTMP2.$$$
0:LINK -Z -M.MAP -Ptext=100H,data,bss -C100H -OHEXDUMP.COM HEXDUMP.OBJ
ERA $$EXEC.$$$

K>HEXDUMP HEXDUMP.COM
hexdump: cannot open HEXDUMP.COM

K>

ladislau szilagyi

unread,
Mar 25, 2025, 4:15:06 AMMar 25
to RC2014-Z80
Hi Wayne,

very strange... it seems that the "open file" routine fails.

Unfortunately, I do not have now any 512KB RC2014 working (my single 512+512KB board crashed last summer...), I am now using only a 128KB RC2014 and Bill Shen's Z80ALL.
I suppose ROMWBW does not work on these...

Therefore, I verified the new Cowgol version ONLY on 128KB RC2104 and Z80ALL. 

The fact that the hexdump.cow Cowgol compilation using the new version went well on ROMWBW is good news for me... this means that I used the appropriate memory allocation routines for ROMWBW (otherwise the new COWFE.COM wouldn't have worked...) 

Let's now see what is the problem with hexdump... I copied on the EXAMPLES folder the 'hexdump.hex' file which I just built on Z80ALL with the new Cowgol version.
Please try to LOAD-it and execute-it, let's see how it works.
If it works, I would need to build a simpler test (something like just opening a file from Cowgol, to see if it works...)

Do you have available the old Cowgol environment on ROMWBW? It would be easier to figure out what's wrong with the new one...

Thanks,
Ladislau

ladislau szilagyi

unread,
Mar 25, 2025, 4:30:23 AMMar 25
to RC2014-Z80
Hi Wayne,

try to compile and execute this basic test:

test.cow
---------------------
sub print_char(c: uint8) is
@asm "ld a, (", c, ")";
@asm "ld e, a";
@asm "ld c, 2";
@asm "call 5";
end sub;

sub print(ptr: [uint8]) is
var ch: uint8;
@asm "ld hl,(", ptr, ")";
@asm "1:";
@asm "ld a,(hl)";
@asm "or a";
@asm "ret z";
@asm "ld (", ch, "), a";
@asm "push hl";
print_char(ch);
@asm "pop hl";
@asm "inc hl";
@asm "jr 1b";
end sub;

print("Hello!");
---------------

Compile-it with:
>cowgol -o test.cow

Let's see if this works...

thanks,
Ladislau

ladislau szilagyi

unread,
Mar 25, 2025, 4:49:27 AMMar 25
to RC2014-Z80
Hi Wayne,

you have now in the EXAMPLES folder a simple "file open" test: filetest.cow. No includes needed.

Compile-it with:
>cowgol -o filetest.cow

When executed, it will try to open the file 'filetest.cow'. If it fails to open-it, it will issue the error message "cannot open !!!", otherwise it will silently exit.
Let's see how it behaves...

thanks,
Ladislau

Wayne Warthen

unread,
Mar 25, 2025, 2:08:42 PMMar 25
to RC2014-Z80
Thanks Ladislau.  I will puruse everything you mentioned.

I should clarify that I am building and running DYNMSORT and ADVENT with no problems.  So, things are generally working.  I am surprised about the issue with HEXDUMP.

I do have the old Cowgol files available and they are still working (including HEXDUMP).

Thanks, Wayne

Wayne Warthen

unread,
Mar 25, 2025, 2:47:20 PMMar 25
to RC2014-Z80
The precompiled HEXDUMP.HEX you provided is working fine.

I can build and run TEST.COW using COWFEWBW and it is working.  See below.

I can build and run FILETEST.COW using COWFEWBW and it is working.  See below.

I tried building HEXDUMP using the generic COWFE and that worked fine as well.

Very odd.  Not sure what to make of this.

Thanks, Wayne


--------
L>cowgol -o test.cow

COWGOL COMPILER (CP/M-80) V2.0
Copyright (C) David Given
0:COWFE     TEST.COW $CTMP1.$$$

COWFE: 22kB free
96kB free extended memory
  > TEST.COW
done: 22kB free
94kB free extended memory
0:COWBE $CTMP1.$$$ TEST.COO
COWBE: 27kB free
__main
print_char
print
done: 26kB free
0:COWLINK COWGOL.COO TEST.COO -o $CTMP1.$$$

COWLINK: 49kB free
Adding input file: COWGOL.COO
Adding input file: TEST.COO
Analysing...
Workspace sizes:
  #0: 4 bytes

Creating output file: $CTMP1.$$$
Copying from input file: COWGOL.COO
Copying from input file: TEST.COO
done: 47kB free
0:COWFIX $CTMP1.$$$ $CTMP2.$$$ -O
ERA $CTMP1.$$$
0:Z80AS -J -N -OTEST.OBJ $CTMP2.$$$

Z80AS Macro-Assembler V4.8

Errors: 0

Jump optimizations done: 1
Finished.
ERA $CTMP2.$$$
0:LINK -Z -Ptext=100H,data,bss -C100H -OTEST.COM TEST.OBJ
ERA $$EXEC.$$$

L>test
Hello!
L>
--------

--------
L>cowgol -o filetest.cow

COWGOL COMPILER (CP/M-80) V2.0
Copyright (C) David Given
0:COWFE     FILETEST.COW $CTMP1.$$$

COWFE: 22kB free
96kB free extended memory
  > FILETEST.COW
done: 20kB free
88kB free extended memory
0:COWBE $CTMP1.$$$ FILETEST.COO
COWBE: 27kB free
__main
MemSet

file_i_init
fill
fcb_i_gbpb
fcb_i_blockin
fcb_i_blockout
fcb_i_changeblock
fcb_i_convert_a_to_error
FCBOpenIn
FCBOpenUp
FCBOpenOut
FCBClose
FCBSeek
FCBPos
FCBExt
fcb_i_nextchar
FCBGetChar
FCBPutChar
print_char
print
done: 23kB free
0:COWLINK COWGOL.COO FILETEST.COO -o $CTMP1.$$$

COWLINK: 49kB free
Adding input file: COWGOL.COO
Adding input file: FILETEST.COO
Analysing...
Workspace sizes:
  #0: 191 bytes

Creating output file: $CTMP1.$$$
Copying from input file: COWGOL.COO
Copying from input file: FILETEST.COO
done: 46kB free
0:COWFIX $CTMP1.$$$ $CTMP2.$$$ -O
ERA $CTMP1.$$$
0:Z80AS -J -N -OFILETEST.OBJ $CTMP2.$$$

Z80AS Macro-Assembler V4.8

Errors: 0

Jump optimizations done: 18
Finished.
ERA $CTMP2.$$$
0:LINK -Z -Ptext=100H,data,bss -C100H -OFILETEST.COM FILETEST.OBJ
ERA $$EXEC.$$$

L>filetest

L>
--------

ladislau szilagyi

unread,
Mar 25, 2025, 2:51:04 PMMar 25
to RC2014-Z80
Hi Wayne,

if Adventure runs, that means the file I/O is OK! 

I'm suspecting the issue is related to argv.coh...

Ladislau

ladislau szilagyi

unread,
Mar 25, 2025, 3:14:45 PMMar 25
to RC2014-Z80
Hi Wayne,

try hexdump1.cow (in the folder EXAMPLES).

It does not contain any include... I think it will run OK.

Ladislau

Wayne Warthen

unread,
Mar 25, 2025, 8:16:07 PMMar 25
to RC2014-Z80
Yes, HEXDUMP1 builds and runs correctly.

Thanks, Wayne

ladislau szilagyi

unread,
Mar 26, 2025, 2:52:34 AMMar 26
to RC2014-Z80
Hi Wayne,

it seems COWFE for ROMWBW has a problem with include files (.coh)... what puzzles me is the fact that this happens only with argv.coh !

I uploaded on the folder EXAMPLES a new COWFEWBW.HEX (I added filling with zero, as initial step, all the 32KB memory banks provided by ROMWBW)

Please use this new COWFE to compile & run HEXDUMP.COW.

Thanks,
Ladislau

Wayne Warthen

unread,
Mar 26, 2025, 4:51:00 PMMar 26
to rc201...@googlegroups.com
On Tue, Mar 25, 2025 at 11:52 PM ladislau szilagyi <ladislau...@gmail.com> wrote:
it seems COWFE for ROMWBW has a problem with include files (.coh)... what puzzles me is the fact that this happens only with argv.coh !

I uploaded on the folder EXAMPLES a new COWFEWBW.HEX (I added filling with zero, as initial step, all the 32KB memory banks provided by ROMWBW)

Please use this new COWFE to compile & run HEXDUMP.COW.

This new COWFE builds and runs all of the examples fine! (including HEXDUMP)

Thanks, Wayne 

Wayne Warthen

unread,
Mar 26, 2025, 4:59:07 PMMar 26
to rc201...@googlegroups.com
Hmmm... maybe I spoke too soon.  I tried building ADVENT and it seems to be stuck running COWFE.  Either it is stalled or it is taking a very long time.

-Wayne

ladislau szilagyi

unread,
Mar 27, 2025, 12:38:26 AMMar 27
to RC2014-Z80
Hi Wayne,

I think the time has come for me to start repairing my 512KB RC2014 !

I dropped it down the stairs last summer, I need to get to work fixing it.

Now I'm out of town for a couple of days, I will come back with some news the next week.

thanks,
Ladislau

Wayne Warthen

unread,
Mar 27, 2025, 12:33:40 PMMar 27
to RC2014-Z80
There's no rush Ladislau.

Thanks, Wayne

ladislau szilagyi

unread,
Mar 29, 2025, 11:56:31 AMMar 29
to RC2014-Z80
Hi Wayne,

I succeeded to repair my 512KB RC2014, then installed ROMWBW v3.5.0, modified & tested the cowfe, it works now as designed.
I compiled and tested the following apps: hexdump, advent, startrek. They work OK now.
(I split the startrek source in two files, to allow-it to be compiled also on romwbw, which has a smaller TPA, compared to the usual RC2014 version...).
My GitHub page is updated with the correct version of all the implied files.

regards,
Ladislau

Wayne Warthen

unread,
Mar 29, 2025, 4:51:50 PMMar 29
to RC2014-Z80
Thank you Ladislau.  Everything is working perfectly for me now!

I am about to push a new RomWBW Release Candidate with the updated Cowgol files.

Thanks, Wayne

ladislau szilagyi

unread,
Jul 3, 2025, 12:00:05 PMJul 3
to RC2014-Z80
I just published a small Cowgol Compiler User Manual, see https://github.com/Laci1953/Cowgol_on_CP_M/blob/main/Cowgol%20compiler%20manual.pdf

Ladislau

Wayne Warthen

unread,
Jul 4, 2025, 12:50:26 PMJul 4
to RC2014-Z80
Very nice Ladislau.  I will include this in the RomWBW documentation going forward.

I noticed the document title page specifically says "hosted on Z80 computers running CP/M 2.2".  Doesn't it work on all versions of CP/M and even CP/M-like OSes?  It also seems to work fine on Z180 and Z280 CPUs.

Thanks, Wayne

ladislau szilagyi

unread,
Jul 5, 2025, 12:54:08 AMJul 5
to RC2014-Z80
Hi Wayne,
I did not tested-it on CP/M 3.0 or other versions of CP/M or CP/M - like OSes, or Z180, Z280... however, I do not know any obstacle that might affect-it to run on these versions.
thanks,
Ladislau

Wayne Warthen

unread,
Jul 5, 2025, 9:27:43 PMJul 5
to RC2014-Z80
Understood.  Thanks.

ladislau szilagyi

unread,
Aug 10, 2025, 2:58:54 PMAug 10
to RC2014-Z80
I published a new version of the Cowfix tool ( cowfix.hex in https://github.com/Laci1953/Cowgol_on_CP_M/tree/main/EXE ).

Cowfix is part of the Cowgol toolchain, used to optimize the Z80 code produced by the compiler.

The old Cowfix was written in C. I translated-it to Cowgol and gained therefore some space, which I used to increase the size of the tables used internally by COWFIX. Now, it can handle larger files, compared with the old one.

An interesting detail: to handle the case of optimizing a series of JP->JP->... JP instructions, I needed a recursive routine.
But Cowgol does not allow recursive subroutines...
I solved this issue by calling from the main Cowgol source file a reentrant C routine.


thanks,
Ladislau


ladislau szilagyi

unread,
Sep 10, 2025, 4:27:45 AM (13 days ago) Sep 10
to RC2014-Z80
Hi,

I'm still improving Cowfix...
I just published a new version (15'th one), obtaining faster execution time & adding some useful statistics.

Here is a sample (while compiling the Adventure game):

>cowgol -o misc.coo string.coo ranfile.coo advent.cow advtrav.cow advmain.cow
COWGOL COMPILER (CP/M-80) V2.0

...compiling advent.cow advtrav.cow advmain.cow...then producing a temporary Z80 assembler file named $CTMP1.$$$ ...

0:COWLINK COWGOL.COO MISC.COO STRING.COO RANFILE.COO ADVENT.COO ADVTRAV.COO ADVMAIN.COO -o $CTMP1.$$$
COWLINK: 45kB free
Adding input file: COWGOL.COO
Adding input file: MISC.COO
Adding input file: STRING.COO
Adding input file: RANFILE.COO
Adding input file: ADVENT.COO
Adding input file: ADVTRAV.COO
Adding input file: ADVMAIN.COO
Analysing...
Workspace sizes:
  #0: 3417 bytes

Creating output file: $CTMP1.$$$
Copying from input file: COWGOL.COO
Copying from input file: MISC.COO
Copying from input file: STRING.COO
Copying from input file: RANFILE.COO
Copying from input file: ADVENT.COO
Copying from input file: ADVTRAV.COO
Copying from input file: ADVMAIN.COO
done: 13kB free

...then Cowfix will filter, fix & optimize $CTMP1.$$$ to produce the final Z80 assembler file named $CTMP2.$$$

0:COWFIX $CTMP1.$$$ $CTMP2.$$$ -O

... with optimization statistics...

COWFIX v15 fixing syntax and optimizing code
PASS 1
PASS 2
PASS 3
32 fixed PUSH statements
23 fixed POP statements
1032 fixed JR statements
581 fixed DWORD statements
103 fixed too long DB statements
862 not needed labels dropped
88 RET statements added
58 fixed JP to JP statements
15 fixed statement groups involving conditionals
28 dropped not needed LD statements

13707 input source lines processed
DONE!
ERA $CTMP1.$$$

... then assembling $CTMP2.$$$

0:Z80AS -J -N -OADVENT.OBJ $CTMP2.$$$

Z80AS Macro-Assembler V4.8
Errors: 0
Jump optimizations done: 832
Finished.
ERA $CTMP2.$$$

... then building the executable ADVENT.COM ...

0:LINK -Z -Ptext=100H,data,bss -C100H -OADVENT.COM ADVENT.OBJ
ERA $$EXEC.$$$

c>
c>advent


                Welcome to ADVENTURE!
                =====================
        -Original development by Willie Crowther.
        -Major features added by Don Woods.
        -Conversion to BDS  C by J. R. Jaeger
        -Unix standardization by Jerry D. Pohl.
        -OS/2 Conversion by Martin Heller
        -Conversion to TurboC 2.0 by Daimler

            Would you like instructions?

>

thanks,
Ladislau

Wayne Warthen

unread,
Sep 12, 2025, 1:02:38 PM (10 days ago) Sep 12
to RC2014-Z80
Hi Ladislau,

I am in the process of updating RomWBW with your updated COWFIX.COM.  During testing, I am successful with building and running ADVENT.  However, I am getting errors when I try to build either DYNMSORT or HEXDUMP.  Below is the output of the HEXDUMP compilation.

Thanks, Wayne

K>submit hexdump

K$COWGOL -M HEXDUMP.COW

COWGOL COMPILER (CP/M-80) V2.0
Copyright (C) David Given
0:COWFE     HEXDUMP.COW $CTMP1.$$$
COWFE: 17kB free

96kB free extended memory
  > HEXDUMP.COW
    > stdcow.coh
      > cowgol.coh
        > common.coh
      < cowgol.coh
    < stdcow.coh
      > file.coh
        > commfile.coh
      < file.coh
    < stdcow.coh
      > strings.coh
    < stdcow.coh
      > malloc.coh
    < stdcow.coh
  < HEXDUMP.COW
    > argv.coh
  < HEXDUMP.COW
done: 11kB free

77kB free extended memory
0:COWBE $CTMP1.$$$ HEXDUMP.COO
COWBE: 21kB free
done: 13kB free

0:COWLINK COWGOL.COO HEXDUMP.COO -o $CTMP1.$$$
COWLINK: 43kB free
Adding input file: COWGOL.COO

Adding input file: HEXDUMP.COO
Analysing...
Workspace sizes:
  #0: 231 bytes

Creating output file: $CTMP1.$$$
Copying from input file: COWGOL.COO
Copying from input file: HEXDUMP.COO
done: 38kB free
0:COWFIX $CTMP1.$$$ $CTMP2.$$$
COWFIX v15 fixing syntax
3 fixed PUSH statements
3 fixed POP statements
59 fixed JR statements

2 input source lines processed
DONE!
ERA $CTMP1.$$$

0:Z80AS -J -N -OHEXDUMP.OBJ $CTMP2.$$$
Z80AS Macro-Assembler V4.8
O                               __Hbss

Errors: 1


Jump optimizations done: 59
Finished.

ladislau szilagyi

unread,
Sep 13, 2025, 7:04:27 AM (9 days ago) Sep 13
to RC2014-Z80
Hi Wayne,

I fixed the bug, the corrected executable is here: https://github.com/Laci1953/Cowgol_on_CP_M/tree/main/EXE

thanks,
Ladislau

Wayne Warthen

unread,
Sep 13, 2025, 10:25:24 AM (9 days ago) Sep 13
to RC2014-Z80
Thanks Ladislau.  That seems to be working nicely.

-Wayne

ladislau szilagyi

unread,
Sep 15, 2025, 4:00:08 AM (8 days ago) Sep 15
to RC2014-Z80
I added to the 'Cowgol language manual' a new chapter, explaining how to port a C program to Cowgol.

Some links to Cowgol programs ported from C are also included.

I hope this will be helpful for those who want to experiment with writing Cowgol programs starting from existing sources written in the C language.

thanks,
Ladislau

7alken

unread,
Sep 15, 2025, 8:18:56 AM (7 days ago) Sep 15
to RC2014-Z80
hi Ladislau, interesting all, reading still, trying to grasp, quite limited time, but will peek again :-)
Petr

ladislau szilagyi

unread,
Sep 15, 2025, 8:27:43 AM (7 days ago) Sep 15
to RC2014-Z80
Hi Petr,
If you find something puzzling, strange or unusual in the documents (or source code) that I published, I'm here to explain (or correct...).
Thanks anyway for your interest in this topic!
Ladislau
Reply all
Reply to author
Forward
0 new messages