About C / Z80 optimizations (SDCC)

Страница 3/17
1 | 2 | | 4 | 5 | 6 | 7 | 8

By PingPong

Prophet (3459)

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

06-09-2019, 22:11

maybe comment are offensive but they are triggered by your previous posts.

By PingPong

Prophet (3459)

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

06-09-2019, 22:20

Grauw, my considerations ARE based on the quality of the z80 code generated.
Years ago, i compared SDCC with hitech C (the version that run on PC, be aware).
Unfortunately i've not (due to hd failure) nor the sources of my msx library nor the samples used in C to test the efficiency of the compiler but i cannot assure you that hitech c outperform easily the SDCC 3.6 and i've not seen so much big improvement in 3.9 today to reach a decent comparison.

ARTRAG that had used this hitech c compiler can confirm the enormous gap.
there is no story.

while it was better to me to integrate SDCC (more easy) in my toolchain i still see the very long road the sdcc had to reach to hitech level.

By Grauw

Ascended (8508)

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

06-09-2019, 22:24

I’m not saying Hitech C doesn’t generate better code, just that it would be interesting to me to see some examples of it Smile. Just how I like poking around at godbolt.org, seeing some similar comparisons for MSX C compilers would be fascinating.

By ARTRAG

Enlighted (6277)

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

06-09-2019, 22:55

Actually I think that independently by the compiler, the most cpu intensive tasks have to go in asm, at least in interactive time games... This is how use the C compiler at least.
The weight of the C sections in terms of performance in those cases is almost marginal.
Moreover I agree that the advantage of using a modern tool integrated in your framework and your emulator can overcome the gain in optimization you could eventually get on code that is not time critical.
my two cents

By zPasi

Champion (473)

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

07-09-2019, 18:38

PingPong wrote:

OK, we see, you are a linux fan. That's your problem.

No, I'm not a Linux-fan and it's not my problem Smile

I have no problem running Hi-Tech C under DosBox, on my Mac! I'm just not convinced it's worth it.

Quote:

try to write a line routine in both compilers then see the asm listing.

I don't need a line routine!

But ok, you made me curious. There are some other things I'll try.

By ARTRAG

Enlighted (6277)

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

14-09-2019, 18:46

It is a long time since I did comparisons among compilers
This is an old simple test for circle compiled in HI-Tech C cross compiler

[code]#include
#include

#define di() asm("di")
#define ei() asm("ei")

void NameTableInit();

void vdpsetreg (unsigned char regno, unsigned char value)
{
di();
outp(0x99, value);
outp(0x99, regno | 0x80);
ei();
}

unsigned char vrampeek(unsigned int addr)
{
di();
outp(0x99, addr & 255);
outp(0x99, (addr >> 8) & 0x3f);
ei();
return inp(0x98);
}

void vrampoke(unsigned int addr, unsigned char byte)
{
di();
outp(0x99, addr & 255);
outp(0x99, 0x40 | ((addr >> 8) & 0x3f));
ei();
outp(0x98, byte);
}

/*
void setpixel(unsigned char x, unsigned char y)
{

unsigned int vddr = (x & 0xf8) + (y & 7) + (int)256 * (y>>3);
unsigned char byte = vrampeek(vddr) | (128 >> (x & 7));
vrampoke(vddr, byte );
}
*/

void sc2()
{
unsigned char r;
unsigned int counter;

static unsigned char vdpregs[ ] = {0x02,0x60,0x06,0xFF, 0x03, 0x36, 0x07,0x04};

for (r =0;r> 8) & 0x3f));
25 line 21
26 000F' 7A ld a,d
27 0010' E6 3F and 03Fh
28 0012' D3 99 out (099h),a
29 ;CIRCLE.C: 22: asm("ei");
30 line 22
22 0014' FB ei ;#
23 ;CIRCLE.C: 23: return (*(port unsigned char *)(0
x98));
24 line 23
25 0015' DB 98 in a,(098h)
26 0017' 6F ld l,a
27 0018' C9 ret
28 ;CIRCLE.C: 24: }

HI-TECH SOFTWARE Z80 Macro Assembler Thu Sep 23 22:43:16 2010

Page 2

29 line 24
30 global _vrampoke
31 signat _vrampoke,8248
32 line 27
33 0019' _vrampoke:
34 ;CIRCLE.C: 28: asm("di");
35 line 28
28 0019' F3 di ;#
29 ;CIRCLE.C: 29: (*(port unsigned char *)(0x99) =
(addr & 255));
30 line 29
31 001A' 7B ld a,e
32 001B' D3 99 out (099h),a
33 ;CIRCLE.C: 30: (*(port unsigned char *)(0x99) =
(0x40 | ((addr >> 8) & 0x3f)));
34 line 30
35 001D' 7A ld a,d
36 001E' E6 3F and 03Fh
37 0020' F6 40 or 040h
38 0022' D3 99 out (099h),a
39 ;CIRCLE.C: 31: asm("ei");
40 line 31
31 0024' FB ei ;#
32 ;CIRCLE.C: 32: (*(port unsigned char *)(0x98) =
(byte));
33 line 32
34 0025' 79 ld a,c
35 0026' D3 98 out (098h),a
36 ;CIRCLE.C: 33: }
37 line 33
38 0028' C9 ret
39 global _sc2
40 signat _sc2,24
41 0000' psect data,class=DATA
42 0000' F245:
43 0000' 02 defb 02h
44 0001' 60 defb 060h
45 0002' 06 defb 06h
46 0003' FF defb -1
47 0004' 03 defb 03h
48 0005' 36 defb 036h
49 0006' 07 defb 07h
50 0007' 04 defb 04h
51 global _NameTableInit
52 signat _NameTableInit,24
53 ;CIRCLE.C: 54: for (r =0;r

By ARTRAG

Enlighted (6277)

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

07-09-2019, 19:22

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

By Grauw

Ascended (8508)

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

07-09-2019, 19:28

By reidrac

Expert (68)

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

07-09-2019, 20:03

PingPong wrote:

maybe comment are offensive but they are triggered by your previous posts.

Do you get easily triggered by things that are not really directed at you? Please, don't answer.

ARTRAG wrote:

It is a long time since I did comparisons among compilers

SDCC is in active development, it would be interesting to see how HI-Tech compares with 3.9. But being closed source and not supporting my operating system (not insulting anyone here!), it really doesn't matter too much how good it is.

Also, the code you are sharing is not really how I would write it in C for SDCC. I guess I know it too well to know its weak points.

Anyway, this thread was about C code and SDCC. I already contributed my 2 cents.

By PingPong

Prophet (3459)

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

07-09-2019, 23:13

I m getting triggered by people that think their operating system must be supported at all otherwise the sw that not support must surely be crap.
Plus you not yet realized that hitech c does not support Windows nor Linux nor mac. That is because we need dosbox.
Instead on judging crap anything that does not run natively in your *beloved* os, try to do an objective comparison about the quality of object code generated.
And to be clear, judging from the progress of sdcc, we can reach the same quality of old hitech probably in the year when computers will acquire some kind of level of A. I. To show some self awareness ;-)

Страница 3/17
1 | 2 | | 4 | 5 | 6 | 7 | 8