About C / Z80 optimizations (SDCC)

Pagina 18/18
11 | 12 | 13 | 14 | 15 | 16 | 17 |

Van Bengalack

Expert (118)

afbeelding van Bengalack

28-03-2020, 09:04

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?

Van Dolphin101546015

Master (254)

afbeelding van Dolphin101546015

29-03-2020, 16:37

Bengalack wrote:

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.

Van ARTRAG

Enlighted (6338)

afbeelding van ARTRAG

29-03-2020, 17:52

Van Bengalack

Expert (118)

afbeelding van Bengalack

29-03-2020, 18:45

Dolphin101546015 wrote:

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.

Van Timmy

Expert (124)

afbeelding van Timmy

29-03-2020, 18:48

ARTRAG wrote:

Attention to this SDCC bug

https://twitter.com/reidrac/status/1243668138266431488

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.

Van ARTRAG

Enlighted (6338)

afbeelding van ARTRAG

29-03-2020, 20:10

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

Van reidrac

Expert (74)

afbeelding van reidrac

29-03-2020, 21:02

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?

Van PingPong

Prophet (3513)

afbeelding van PingPong

29-03-2020, 21:17

It is a true bug. If ld (hl), x is generated by the compiler and not by user code it is a important bug.

Van Dolphin101546015

Master (254)

afbeelding van Dolphin101546015

30-03-2020, 07:42

ARTRAG wrote:

Attention to this SDCC bug

https://twitter.com/reidrac/status/1243668138266431488

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.

Pagina 18/18
11 | 12 | 13 | 14 | 15 | 16 | 17 |