About C / Z80 optimizations (SDCC)

Страница 13/18
6 | 7 | 8 | 9 | 10 | 11 | 12 | | 14 | 15 | 16 | 17 | 18

By ro

Scribe (4563)

Аватар пользователя ro

14-09-2019, 18:47

ARTRAG wrote:

Hummm what a crap.... How can I show the correct source ?

I looked into that, it's because of the [] chars in your code. The page rendering engine gets confused, apparently.

By Grauw

Ascended (10312)

Аватар пользователя Grauw

14-09-2019, 19:25

No, it was because of

I reposted it on the following page with < replaced by &lt;.

By ren

Paragon (1910)

Аватар пользователя ren

14-09-2019, 19:36

Perhaps nice if a team site technician (Jorrith?) can add a link to that FAQ to the comment box? (Not that I haven't suggested something along those lines before.. ;))

By DarkSchneider

Paladin (942)

Аватар пользователя DarkSchneider

14-09-2019, 19:51

zPasi wrote:
ARTRAG wrote:

In 2008 sdcc was less efficient than htc v780pl2, at least in struct and union manipulations and in the use of th stak for passing parameters

Struct operations still suck on SDCC, except when the structs are static, then it doesn't matter if a var is member of a struct or not.

Sometimes I've even done this kind of optimizations:

	static mystruct_t mystruct;
  // pmystruct is a pointer
	memcpy(& mystruct, pmystruct, sizeof(mystruct_t));
	x = mystruct.x; 
  // etc ...

Looks silly, but when accessing more than one member of a struct, performs better than mystruct->x.

And this is not easily peepholed.

Using stack for passing parameters is not much a problem. When I look at what Hi-Tech does, it passes max two 16 bit parameters by registers, the rest will go through the stack. Using __z88dk_fastcall SDCC passes one parameter by registers. So, only when there are two parameters, Hi-Tech performs better.

Instead that try to create a static struct pointer and assign it to the struct address you want to access. You may save the memcpy.
The problem could be the same than with MSX-C when passing struct in the stack. Using a global variable reference, that’s why to define it static, is much faster than accessing it from the stack reference.

By PingPong

Prophet (3839)

Аватар пользователя PingPong

14-09-2019, 20:06

Even 4 char vars can be passed in registers

By Timmy

Master (177)

Аватар пользователя Timmy

14-09-2019, 20:15

PingPong wrote:

Even 4 char vars can be passed in registers

Yes, very relevant in hand written optimised assembly... But irrelevant in C.

By Timmy

Master (177)

Аватар пользователя Timmy

14-09-2019, 20:26

Let's replying to some other post earlier in thread:

PingPong wrote:

No, it's only that we are working on a z80 bit cpu. and a relatively slow clock.
We have not the luxury of plenty of GigaHerz available. So every single drop of cpu power should be used.
The reason why C is useful is that some things are hard in asm.
So we expect to pay some performance penalty in exchange of more ease of code. But this should be a reasonable penalty.
and a bad C compiler is what make the word reasonable sound like inaceptable.

Yes, it's always 'inaceptable' for some people. I'm really, absolutely delighted that that person is you! Congratulations!

In fact, if people think that "every single drop of cpu power should be used" then they have a problem with every single MSX programme.

Now I can understand that you think that it is necessary because you think the Spectrum is really a much better computer, and therefore every MSX programme needs to use every single drop of cpu power to compete to the many great Spectrum games.

Fortunately it doesn't work this way. Smile

By PingPong

Prophet (3839)

Аватар пользователя PingPong

14-09-2019, 21:15

It is always relevant. The time wasted in parameter passing is somewhat undesiderable. A sort of overhead. So minimizing it is desiderBle because it allows to use more effectively cpu time.

By PingPong

Prophet (3839)

Аватар пользователя PingPong

14-09-2019, 21:21

I never said that the spectrum is better or worse than msx.
And seeing your point of view about code optimization I suggest you to develop your programs with a i7 processor peraphs with some high level language like javascript or phython

Or do you think that a lot of impressive achievements on those 8 bit machines like speccy msx cpc c64 were obtained by wasting cpu cycles?
Fortunately things did not work In That way.


Enlighted (6692)

Аватар пользователя ARTRAG

14-09-2019, 21:24

ARTRAG wrote:

Interesting info here

The latest CPM version if Hi-Tech C is v4.11, it is freeware with the permission of Microchip (this is why I link it here)
It seems quite a task to make it work. Anyone willing to try it ?
I stay with the v780pl2 version for ms-dos ;-)

Note: The files include the C sources of the COMPILER, not only of the libraries!

btw I have to fix my previous post
Hitech C v4.11 is a cross compiler for ms dos not for cpm

Страница 13/18
6 | 7 | 8 | 9 | 10 | 11 | 12 | | 14 | 15 | 16 | 17 | 18