Lots of great information in this thread! Thanks.
vscode-question:
I mix C and asm-code extensively. In akumajo's examples above, it's all about inlining. I typically do not use inline - I split .c code files and .s files. One major reason for this is that z80-assembly syntax highlighting in vscode does not show up on z80-code in c-files. (the great "Z80 Assembly Meter"-extension does not work in inlines in C either). But, does anyone know how to get both C + z80 syntax-highlighting working at the same time?
But, does anyone know how to get both C + z80 syntax-highlighting working at the same time?
I using VSCode for it, but setup not so trivial.
Attention to this SDCC bug
I using VSCode for it, but setup not so trivial.
Any hints on what's involved? In theory? Just wonder if I should bother go down that line.
This is not a bug, I believe. This is exactly how z88dk works with fastcall. It is a fastcall, used for z88dk only, because it does not use the stack and the parameter is moved into HL directly.
I think it's better to ask the SDCC people to make a specific modifier for people who write in SDCC instead.
I'm not into the subject, but I think that the problems is that it is passing a wrong value
Juan says that SDCC is overwriting the parameter when loading a variable value in HL
Hi! Yes, it is passing the value in L, but then overwrites it when storing in a global variable using HL.
It should have moved L to A, for example, and then store A.
According to the manual, __z88dk_fastcall is fully supported (this macro is used to "tag" functions that must use this calling convention), so this is a bug (probably in the peephole optimizer).
This is the first time I trust SDCC to use this calling convention in the code it is generating (I used it in the past to call my own ASM written functions using fastcall), and it seemed to work fine. Well, bugs happen; but in the compiler is kind of annoying.
Anyway, SDCC 4.0 seems to generate better code than 3.9, although I'm not fan of upgrading the compiler when a project is that advanced like this one I'm finishing; but hey! that's why we test our code, isn't it?
It is a true bug. If ld (hl), x is generated by the compiler and not by user code it is a important bug.
Methink, he dont understand meaning of __z88dk_fastcall, and what he doing, when call function over __z88dk_fastcall, and after it using C code inside, with indirect addressing.
But nothing strange here btw, I get more strange behaviours with SDCC sometimes, and thinking to switch it with C++ compiller future, cos anyway I write mostly inline ASM.
Hello,
If you want SDCC to become more efficient, you can support this feature request: https://sourceforge.net/p/sdcc/feature-requests/253/?page=1.
The idea would be to extend the use of __z88dk_fastcall to :
- Allow to use it for more than one parameter (it doesn't make sense to be able to pass an int32 via registers, but not 4 int8)
- Allowing to choose in which register to put each parameter (which would allow for example to call from C a Bios routine that would take its parameters from A and E).
That's it :)
PS: I take this opportunity to thank you for your site, which is a gold mine for those looking for information about MSX.