ccz80 2.0.4

by wolf_ on 12-01-2009, 12:42
Topic: Software
Tags: Utilities
Languages:

A new version of ccz80 has been released today. New in this version:

  • Fixed the evaluation of the !-operator for values of the word type
  • Added the label __end_program at the end of the generated assembler code, to locate free space in memory

Relevant link: ccz80 website

Comments (8)

By cesco

Champion (453)

cesco's picture

12-01-2009, 14:55

It always looked like a very good compromise between C and Assembly, but as far as I can remember it had some problems with the MSX support... as it was preliminary and still lacking many things... how is it now ?

Do anyone knows about performance comparisons between this tool and the usual Z80 assemblers ?

By Dinoneno

Resident (41)

Dinoneno's picture

13-01-2009, 13:23

For MXS and all others plataforms it's necessary write functions in assembler. There are a little library generic not useful for great works, only for simply programs. If you know a functions library of routines in assembler for MSX (with the source code) we can try make the conversion to functions to ccz80 language. It should be not very hard.

By example, the code generated by ccz80 I think is a little more direct, and so, more fast y short that z88dk. This is an example:

Source code for z88dk:

char i;
int sum = 0;

void main(void)
{
// Add numbers 1 to 100
for (i = 0; i <= 100; ++i) sum += i;
}

Assembler code generated by z88dk (also, we must add the code of #z80_crt0.hdr file, I supose):

;* * * * * Small-C/Plus z88dk * * * * *
; Version: 20070909.1
;
; Reconstructed for the z80 Module Assembler
;
; Module compile time: Tue Jan 13 13:06:16 2009

MODULE prueba.c

INCLUDE "#z80_crt0.hdr"

._sum
defw 0

._main
ld hl,0 ;const
ld a,l
call l_sxt
ld a,l
ld (_i),a
jp i_6
.i_4
ld hl,_i
call l_gchar
inc hl
ld a,l
ld (_i),a
.i_6
ld hl,_i
call l_gchar
ld de,100 ;const
ex de,hl
call l_le
jp nc,i_5
ld hl,(_sum)
push hl
ld hl,_i
call l_gchar
pop de
add hl,de
ld (_sum),hl
jp i_4
.i_5
ret

; --- Start of Static Variables ---

._i defs 1

; --- Start of Scope Defns ---

XDEF _i
XDEF _main
XDEF _sum

; --- End of Scope Defns ---

; --- End of Compilation ---

Source code in ccz80:

byte i;
word sum = 0;

for (i = 0; i <= 100; ++i) sum += i;
return;

Assembler code generated by ccz80 (using the /asm option):

; Code generated by:
; ccz80 version 2.0.4
; Cross Compiler for Z80
; © 2009 Emilio Guerrero
; http://www.telefonica.net/web2/emilioguerrero
; martes, 13 de enero de 2009 [13:07:33]

org #4000

; File C:\Ficheros\Fuentes\ccz80\comparar.ccz80

; for ( i = 0 ; i <= 100 ; ++ i )

; for initialization
xor a ; Get constant number 0
ld (_i),a
__start_for_00000:

; for evaluation
ld a,(_i)
ld b,a ; Get byte variable i
ld a,100 ; Get constant number 100
cp b
jp c,__end_for_00000 ; Jump when expression is false

; for sentences

; sum += i ;
ld bc,(_i)
ld b,0 ; Get byte variable i
ld hl,(_sum)
add hl,bc
ld (_sum),hl

; for setup
ld hl,_i ; Get byte variable i
inc (hl)

jp __start_for_00000 ; Jump to for start
__end_for_00000:

; return ;
ret

; End file C:\Ficheros\Fuentes\ccz80\comparar.ccz80

; Variables declaration

_i:
defb 0
_sum:
defw 0

; Start free memory
__end_program:

By pitpan

Prophet (3128)

pitpan's picture

13-01-2009, 14:43

Well. I think that the code above clearly demonstrates that direct assembler has speed and size advantages:

ld hl,0000h
ld d,l
ld b,100
@@LOOP:
ld e,b
add hl,de
djnz @@LOOP

About 10 bytes? Smile

By Dinoneno

Resident (41)

Dinoneno's picture

13-01-2009, 14:56

Of course, assembler pure is the best! But, it's more easy use compilators if you develop a large program, as you know. Also you can write functions with assembler in ccz80.

By pitpan

Prophet (3128)

pitpan's picture

14-01-2009, 14:06

I totally agree with your remark, dinoneno. Especially when critical execution times are not required, high-level languages are the best option without doubt. And as several games have proven, the combination of high-level language structure and optimized assembler for the critical routines is a good solution.

By Dinoneno

Resident (41)

Dinoneno's picture

27-03-2009, 20:10

New version ccz80 2.0.5 with more improvements. View http://www.telefonica.net/web2/emilioguerrero/ccz80/ccz80.html in section News.

By Dinoneno

Resident (41)

Dinoneno's picture

05-08-2009, 19:53

By AuroraMSX

Paragon (1900)

AuroraMSX's picture

09-08-2009, 14:49

Well. I think that the code above clearly demonstrates that direct assembler has speed and size advantages:

ld hl,0000h
ld d,l
ld b,100
@@LOOP:
ld e,b
add hl,de
djnz @@LOOP

About 10 bytes? 3 bytes is enough:

ld hl,5050

Tongue

My MSX profile