HiSoft C programmers?
Re: HiSoft C programmers?
Modern C compilers will do a much better job of converting C code into Z80, not to mention providing a much nicer workflow than actually trying to code on a Spectrum. I don't think I'd spend much time using a period toolkit without a really good reason to do so.
Re: HiSoft C programmers?
I think it depends on the compiler.
ZX Basic --> Quick Basic --> Borland Pascal --> Borland C
When I learned to convert my program from pascal to C, because it was the "path to professionalism", I found out that the resulting code contains the name function.
Is bigger. Pascal was able to remove unused functions from the code.
I got the same / equivalent source code written with different syntax and worse executable.
I don't understand why the syntax should matter when both do the same thing and the only difference is made by the compiler.
It doesn't matter if the parameters are cleaned up inside the function or outside, because they are both parameters on the stack.
The fact that the division of two int numbers produces an int number is a small thing that we only have to watch during the conversion.
ZX - Can it be programmed directly on a real ZX?
PC - Can it be programmed comfortably from a PC?
read - Is the code readable?
auto - Can you make your code more readable and automatically remove comments or spaces with a script before use?
small - Is the code small?
fast - Is the code fast?
team - It is the work of a large team of people and used by a large number of people, so has anyone caught the bugs yet?
self - Can the compiler adjust when you come across something you need and it implicitly can't do it?
Atari - Can you compile your hw independent code with less effort on Atari as well?
Why not support C means damning all programs written in it?
I'm just saying that C is at a disadvantage, because the only advantage it has is that it is spread across platforms. But Basic and Forth have that too.
Selling variables via the stack even if recursion is not used is simply expensive, so then I try to make various exceptions to selling via registers, but this can only work if the function no longer calls another non-recursive function.
Then the variable must be cleaned up on the stack or in memory. On the Z80, C already has a design flaw.
Boriel Basic does not have to solve this, it is better than the C compiler.
The programmer has already chosen a solution in Basic that avoids recursion.
Forth is even better than Basic. The programmer chooses the algorithm by giving it parameters in TOS and NOS.
Forth already has the path swept, it does not have to find out what should be in the registers like C.
The pain of Forth will be that it needs 2 trays, so the emulated one will be slow.
The pain for the Forth compiler will be that due to the way Forth works as an interpreter, effective code for the interpreter will require a different approach/algorithm than the code I want to compile.
For me, the Z88dk simply has this disadvantage, thanks to its versatility, if you try to use it, you won't even be able to compile hello word.
You will google what parameter to write when compiling "+zx"! How to solve the fact that it changes my fonts to 4*8 when I don't want them.
How to compile a 16-bit float, because the instruction you found on the net no longer works.
If you don't speak English and you probably can't find the right forum, then end it yourself.
It's easier to write it in assembly than in C...
Documentation and some sort of training site will be more important than a compiler they can't use.
Otherwise, the fact that it was written by someone smarter than me becomes a disadvantage.
ZX Basic --> Quick Basic --> Borland Pascal --> Borland C
When I learned to convert my program from pascal to C, because it was the "path to professionalism", I found out that the resulting code contains the name function.
Is bigger. Pascal was able to remove unused functions from the code.
I got the same / equivalent source code written with different syntax and worse executable.
I don't understand why the syntax should matter when both do the same thing and the only difference is made by the compiler.
It doesn't matter if the parameters are cleaned up inside the function or outside, because they are both parameters on the stack.
The fact that the division of two int numbers produces an int number is a small thing that we only have to watch during the conversion.
ZX - Can it be programmed directly on a real ZX?
PC - Can it be programmed comfortably from a PC?
read - Is the code readable?
auto - Can you make your code more readable and automatically remove comments or spaces with a script before use?
small - Is the code small?
fast - Is the code fast?
team - It is the work of a large team of people and used by a large number of people, so has anyone caught the bugs yet?
self - Can the compiler adjust when you come across something you need and it implicitly can't do it?
Atari - Can you compile your hw independent code with less effort on Atari as well?
Code: Select all
| | ZX | PC | read | auto | small | fast | team | self | Atari |
+----------------------+------+-----+------+------+-------+------+------+------+-------+
|HiSoft | 80 | ? | 100 | | ? | ? | yes | no | yes? |
|Z88dk.zcc | 0 | 100 | 100 | | 20 | 40 | yes | no | yes |
|ZX Basic | 100 | 100 | 80 | yes | 90-110| 10 | yes | no? | yes? |
|compiled Boriel Basic | 100? | 100 | 100 | | 30 | 50 | yes? | no | yes? |
|Forth | 90 | ? | 50 | | 100 | 20 | no | yes | yes |
|compiled M4 Forth | 0 | 100 | 40 | | 40 | 70 | no! | yes? | no |
|Assembler | 90 | 100 | 20 | | 80 | 100 | yes | yes | no |
I'm just saying that C is at a disadvantage, because the only advantage it has is that it is spread across platforms. But Basic and Forth have that too.
Selling variables via the stack even if recursion is not used is simply expensive, so then I try to make various exceptions to selling via registers, but this can only work if the function no longer calls another non-recursive function.
Then the variable must be cleaned up on the stack or in memory. On the Z80, C already has a design flaw.
Boriel Basic does not have to solve this, it is better than the C compiler.
The programmer has already chosen a solution in Basic that avoids recursion.
Forth is even better than Basic. The programmer chooses the algorithm by giving it parameters in TOS and NOS.
Forth already has the path swept, it does not have to find out what should be in the registers like C.
The pain of Forth will be that it needs 2 trays, so the emulated one will be slow.
The pain for the Forth compiler will be that due to the way Forth works as an interpreter, effective code for the interpreter will require a different approach/algorithm than the code I want to compile.
For me, the Z88dk simply has this disadvantage, thanks to its versatility, if you try to use it, you won't even be able to compile hello word.
You will google what parameter to write when compiling "+zx"! How to solve the fact that it changes my fonts to 4*8 when I don't want them.
How to compile a 16-bit float, because the instruction you found on the net no longer works.
If you don't speak English and you probably can't find the right forum, then end it yourself.
It's easier to write it in assembly than in C...
Documentation and some sort of training site will be more important than a compiler they can't use.
Otherwise, the fact that it was written by someone smarter than me becomes a disadvantage.
Z80 Forth compiler (ZX Spectrum 48kb): https://codeberg.org/DW0RKiN/M4_FORTH
Re: HiSoft C programmers?
@_dw,
Many of your z88dk observations are answered in Derek's comprehensive guide. Z88dk was a mystery until I worked through it. The website documentation isn't great
https://github.com/z88dk/z88dk/blob/mas ... Started.md
Many of your z88dk observations are answered in Derek's comprehensive guide. Z88dk was a mystery until I worked through it. The website documentation isn't great
https://github.com/z88dk/z88dk/blob/mas ... Started.md
Re: HiSoft C programmers?
yes,
i tried Hisoft C on mgt but i still had to learn C.
i did some type-in from the booklet and i cant stand that GUI
smaller character would be nice and edit as a normal txt file would be nice.
other compilers on speccy, like the modula2, are a bit easier in using it.
but if you can make a nice and strict STRUCT on hisoft?
i did not try
yet
C is from the beginning when 32k to 64k was normal, cp/m works from disk counting as extra memory.
i think C and Z80 fit wel together if you exploit it better, z88 proves such possibilities
it will need a multple interrupt manager, which is possible as proven by Toni Baker in the earlier ZX years
Re: HiSoft C programmers?
I think I searched those pages, but they don't help me for what I needed.PeterJ wrote: ↑Sun Dec 17, 2023 7:55 pm @_dw,
Many of your z88dk observations are answered in Derek's comprehensive guide. Z88dk was a mystery until I worked through it. The website documentation isn't great
https://github.com/z88dk/z88dk/blob/mas ... Started.md
I think I expected printf("%i",i); will print a number, the command is ignored instead. I accidentally found that it should be printf("%d",i);
It doesn't help with 16-bit float either, I would have to find someone who has contact with the authors.
Here is the dump for z88dk.zcc without the parameter. I would expect to find "+zx" there. But it's not there... How do you want to start? You will find many libraries for assembler and prove to understand and modify them. This is where the complexity can kill you. It happened to me. I'm not good enough for C.
Spoiler
Code: Select all
dworkin@dw-A15:~/Programovani/ZX/Forth$ z88dk.zcc
zcc - Frontend for the z88dk Cross-C Compiler - v19766-9ffe2042c-20220722
Usage: /snap/z88dk/4598/bin/zcc +[target] {options} {files}
Options:
-v -verbose Output all commands that are run (-vn suppresses)
-h -help Display this text
-o Set the basename for linker output files
-specs Print out compiler specs
CPU Targetting:
-m8080 Generate output for the i8080
-m8085 Generate output for the i8085
-mz80 Generate output for the z80
-mz80n Generate output for the z80n
-mz180 Generate output for the z180
-mr2ka Generate output for the Rabbit 2000
-mr3k Generate output for the Rabbit 3000
-mgbz80 Generate output for the Gameboy Z80
Target options:
-subtype Set the target subtype
-clib Set the target clib type
-crt0 Override the crt0 assembler file to use
-startuplib Override STARTUPLIB - compiler base support routines
--no-crt Link without crt0 file
-startup Set the startup type
-zorg Set the origin (only certain targets)
-nostdlib If set ignore INCPATH, STARTUPLIB
-pragma-redirect Redirect a function
-pragma-define Define the option in zcc_opt.def
-pragma-output Define the option in zcc_opt.def (same as above)
-pragma-export Define the option in zcc_opt.def and export as public
-pragma-need NEED the option in zcc_opt.def
-pragma-bytes Dump a string of bytes zcc_opt.def
-pragma-include Process include file containing pragmas
Lifecycle options:
-m4 Stop after processing m4 files
-E --preprocess-only Stop after preprocessing files
-c --compile-only Stop after compiling .c .s .asm files to .o files
-a --assemble-only Stop after compiling .c .s files to .asm files
-S --assemble-only Stop after compiling .c .s files to .asm files
-x Make a library out of source files
-create-app Run appmake on the resulting binary to create emulator usable file
M4 options:
-Cm Add an option to m4
-copy-back-after-m4 Copy files back after processing with m4
Preprocessor options:
-Cp Add an option to the preprocessor
-D Define a preprocessor option
-U Undefine a preprocessor option
-I Add an include directory for the preprocessor
-iquote Add a quoted include path for the preprocessor
-isystem Add a system include path for the preprocessor
Compiler (all) options:
-compiler Set the compiler type from the command line (sccz80,sdcc)
--c-code-in-asm Add C code to .asm files
--opt-code-speed Optimize for code speed
-debug Enable debugging support
Compiler (sccz80) options:
-Cc Add an option to sccz80
-set-r2l-by-default (sccz80) Use r2l calling convention by default
-O Set the peephole optimiser setting for copt
Compiler (sdcc) options:
-Cs Add an option to sdcc
--opt-code-size Optimize for code size (sdcc only)
-SO Set the peephole optimiser setting for sdcc-peephole
--fsigned-char Use signed chars by default
Compiler (clang/llvm) options:
-Cg Add an option to clang
-clang Stop after translating .c files to llvm ir
-llvm Stop after llvm-cbe generates new .cbe.c files
-Co Add an option to llvm-opt
-Cv Add an option to llvm-cbe
-zopt Enable llvm-optimizer (clang only)
Assembler options:
-Ca Add an option to the assembler
-z80-verb Make the assembler more verbose
Linker options:
-Cl Add an option to the linker
-L Add a library search path
-l Add a library
-bn Set the output file for the linker stage
-reloc-info Generate binary file relocation information
-m -gen-map-file Generate an output map of the final executable
-s -gen-symbol-file Generate a symbol map of the final executable
--list Generate list files
Appmake options:
-Cz Add an option to appmake
Misc options:
-g Generate a global defc file of the final executable (-g -gp -gpf:filename)
-alias Define a command line alias
--lstcwd Paths in .lst files are relative to the current working dir
-custom-copt-rules Custom user copt rules
-no-cleanup Don't cleanup temporary files
Argument Aliases:
Z80 Forth compiler (ZX Spectrum 48kb): https://codeberg.org/DW0RKiN/M4_FORTH
Re: HiSoft C programmers?
@_dw,
I think you have decided C isn't for you. It's great there are so many languages to keep everyone happy.
I think you have decided C isn't for you. It's great there are so many languages to keep everyone happy.
Re: HiSoft C programmers?
I don't know when you last looked at Z80 C's calling conventions, but passing by register instead of the stack (known as fastcall) has been supported by various compilers for many years. z88dk had this in 2010. The issue on the Z80 is that there aren't many registers, and passing a single 32 bit value via registers uses 4 of them. But that's the same with any language._dw wrote: ↑Sun Dec 17, 2023 7:49 pm Selling variables via the stack even if recursion is not used is simply expensive, so then I try to make various exceptions to selling via registers, but this can only work if the function no longer calls another non-recursive function.
Then the variable must be cleaned up on the stack or in memory. On the Z80, C already has a design flaw.
For non-fastcall, having the called function clear up the stack before returning (known as callee convention) vastly reduces the amount of code and time needed to handle function returns. That's also been supported by z88dk for more than a decade.
Z80 C might have had a design flaw in 1984, but a lot's happened in 40 years.
I originally wrote the z88dk getting started guide in 2017. If you have read it, and it doesn't address your questions, by all means let me know. I maintain that documentation and want it to answer people's questions. Ask on the z88dk forum, where it's a bit more on topic than here._dw wrote: ↑Sun Dec 17, 2023 7:49 pm For me, the Z88dk simply has this disadvantage, thanks to its versatility, if you try to use it, you won't even be able to compile hello word.
You will google what parameter to write when compiling "+zx"! How to solve the fact that it changes my fonts to 4*8 when I don't want them.
How to compile a 16-bit float, because the instruction you found on the net no longer works.
If you don't speak English and you probably can't find the right forum, then end it yourself.
It's easier to write it in assembly than in C...
Documentation and some sort of training site will be more important than a compiler they can't use.
Otherwise, the fact that it was written by someone smarter than me becomes a disadvantage.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Re: HiSoft C programmers?
Well that's fair enough. But then it's not really fair that you criticise the language when you readily admit that the language isn't the actual problem. Unjustified and inaccurate criticism just puts potential users off.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Re: HiSoft C programmers?
fastcall is an attempt to solve the problem with slow random access to unsorted data on the storage, but it must logically fail and it is not as savior as it sounds. You only keep data effectively in registers when you process them and you have to have some priorities, which is more important. Straightener for a bender.dfzx wrote: ↑Sun Dec 17, 2023 9:12 pm I don't know when you last looked at Z80 C's calling conventions, but passing by register instead of the stack (known as fastcall) has been supported by various compilers for many years. z88dk had this in 2010. The issue on the Z80 is that there aren't many registers, and passing a single 32 bit value via registers uses 4 of them. But that's the same with any language.
Basic does not have this when it has global data. Fastcall is the default.
Forth doesn't have this either because it DOES NOT mix data and return values in one stack, and the design of an effective algorithm is a matter for the programmer, so the compiler doesn't decide how it should go in the data register.
The assembler is the best part, the programmer will figure it all out himself and the compiler will take care of the correct addresses.
Thank you for your work!dfzx wrote: ↑Sun Dec 17, 2023 9:12 pmFor non-fastcall, having the called function clear up the stack before returning (known as callee convention) vastly reduces the amount of code and time needed to handle function returns. That's also been supported by z88dk for more than a decade.
Z80 C might have had a design flaw in 1984, but a lot's happened in 40 years.
I originally wrote the z88dk getting started guide in 2017. If you have read it, and it doesn't address your questions, by all means let me know. I maintain that documentation and want it to answer people's questions. Ask on the z88dk forum, where it's a bit more on topic than here.
As I said, the basic switch +zx should already be listed in the help list. There, one will wonder first when it doesn't have a "man".
I would like to know how to compile the "original C" benchmark "n-body" for 16 bit floats, for comparison.
https://github.com/z88dk/z88dk/wiki/Benchmarks#n-body
Last edited by _dw on Sun Dec 17, 2023 10:12 pm, edited 1 time in total.
Z80 Forth compiler (ZX Spectrum 48kb): https://codeberg.org/DW0RKiN/M4_FORTH
Re: HiSoft C programmers?
z88dk is just a compiler; it does not teach the language.
It's almost like me blaming all those japanese games for not teaching me Japanese. Or text adventures in English.
Well, the text adventure actually helped, but I needed a dictionary and it still didn't helped with idioms and grammar.
Z88dk is very secretive in explaining. And they change stuff still very often; on the other hand, you could say it's still alive and kicking.
One day when I have more time I might start writing a new tutorial too. But I've also already wrote one on the previous spectrum site. I don't really like writing tutorials because English isn't my first language, and I tend to write very, very slowly, and my health is just not as good as before.
I also wrote a step by step post to build z88dk in the z88dk forums, but it's intended just for myself for reading it back later.
One of the reason I'm not writing big documents right now is that they are still planning for a new big version for the last 8 months. Perhaps they will never finish that new major version. I am not holding my breath.
Anyway, if you have any problems with z88dk, ask them in the z88dk forums. It's easier to collect them there, but if you have specific questions then I won't mind answering it on this forum too. But preferably not in a thread about HiSoft C.
It's almost like me blaming all those japanese games for not teaching me Japanese. Or text adventures in English.
Well, the text adventure actually helped, but I needed a dictionary and it still didn't helped with idioms and grammar.
Z88dk is very secretive in explaining. And they change stuff still very often; on the other hand, you could say it's still alive and kicking.
One day when I have more time I might start writing a new tutorial too. But I've also already wrote one on the previous spectrum site. I don't really like writing tutorials because English isn't my first language, and I tend to write very, very slowly, and my health is just not as good as before.
I also wrote a step by step post to build z88dk in the z88dk forums, but it's intended just for myself for reading it back later.
One of the reason I'm not writing big documents right now is that they are still planning for a new big version for the last 8 months. Perhaps they will never finish that new major version. I am not holding my breath.
Anyway, if you have any problems with z88dk, ask them in the z88dk forums. It's easier to collect them there, but if you have specific questions then I won't mind answering it on this forum too. But preferably not in a thread about HiSoft C.
Re: HiSoft C programmers?
@Timmy,
Derek's C guide is very good. I'm not sure we need another one. I've read some of your previous guides though, they are great!
Derek's C guide is very good. I'm not sure we need another one. I've read some of your previous guides though, they are great!
Re: HiSoft C programmers?
Ok, if someone thinks that what I wrote is rude, I apologize.
Please don't let it ruin the Christmas atmosphere. Nothing I said was intended to offend anyone.
Please don't let it ruin the Christmas atmosphere. Nothing I said was intended to offend anyone.
Z80 Forth compiler (ZX Spectrum 48kb): https://codeberg.org/DW0RKiN/M4_FORTH
Re: HiSoft C programmers?
I agree.
But both Derek and I know that z88dk had a direction change recently about its libraries. It's affecting z88dk quite a bit, and we've also found some new optimisation techniques.
I might also want to write more about building for other platforms as well, like the MSX and the Game Boy.
Preferably I don't want to write myself, of course. And a lot of this is already on the forums, but it's not easily accessible, apparently.
Re: HiSoft C programmers?
about the DiscIple version: (is not +D, but maybe ??)
https://spectrumcomputing.co.uk/page.ph ... 58&page=13
https://spectrumcomputing.co.uk/page.ph ... 58&page=14
https://spectrumcomputing.co.uk/page.ph ... 58&page=15
https://spectrumcomputing.co.uk/page.ph ... 58&page=13
https://spectrumcomputing.co.uk/page.ph ... 58&page=14
https://spectrumcomputing.co.uk/page.ph ... 58&page=15