About C / Z80 optimizations (SDCC)

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

By PingPong

Prophet (3460)

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

08-09-2019, 15:24

I will be happy if SDCC will reach some point of evolution even if there is no way to improve further.
Plus, a good thing would be if one manage to compile with SDCC the same source and do a comparison.

By PingPong

Prophet (3460)

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

08-09-2019, 15:51

following there is the same source compiled with SDCC 3.9

external references are not resolved so it does not link but by interest was only to get .asm file for comparison.

By PingPong

Prophet (3460)

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

08-09-2019, 15:43

;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.9.0 #11195 (MINGW64)
;--------------------------------------------------------
	.module sdcctest
	.optsdcc -mz80
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _main
	.globl _circle
	.globl _plotpoints
	.globl _sc2
	.globl _vrampoke
	.globl _vrampeek
	.globl _vdpsetreg
	.globl _pset
	.globl _inp
	.globl _outp
	.globl _exec_time
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area _DATA
_sc2_vdpregs_65536_180:
	.ds 8
_exec_time::
	.ds 2
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area _INITIALIZED
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
	.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area _HOME
	.area _GSINIT
	.area _GSFINAL
	.area _GSINIT
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:51: static unsigned char vdpregs[] = {0x02,0x60,0x06,0xFF, 0x03, 0x36, 0x07,0x04};
	ld	hl, #_sc2_vdpregs_65536_180
	ld	(hl), #0x02
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0001)
	ld	(hl), #0x60
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0002)
	ld	(hl), #0x06
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0003)
	ld	(hl), #0xff
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0004)
	ld	(hl), #0x03
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0005)
	ld	(hl), #0x36
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0006)
	ld	(hl), #0x07
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0007)
	ld	(hl), #0x04
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area _HOME
	.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area _CODE
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:19: void vdpsetreg (unsigned char regno, unsigned char value)
;	---------------------------------
; Function vdpsetreg
; ---------------------------------
_vdpsetreg::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:21: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:22: outp(0x99, value);
	ld	hl, #3+0
	add	hl, sp
	ld	d, (hl)
	ld	e,#0x99
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:23: outp(0x99, regno | 0x80);
	ld	hl, #2+0
	add	hl, sp
	ld	a, (hl)
	set	7, a
	ld	d,a
	ld	e,#0x99
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:24: ei();
	ei	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:25: }
	ret
_Done_Version:
	.ascii "Made with FUSION-C 1.2 (ebsoft)"
	.db 0x00
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:27: unsigned char vrampeek(unsigned int addr)
;	---------------------------------
; Function vrampeek
; ---------------------------------
_vrampeek::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:29: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:30: outp(0x99, addr & 255);
	ld	hl, #2+0
	add	hl, sp
	ld	d, (hl)
	ld	e,#0x99
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:31: outp(0x99, (addr >> 8) & 0x3f);
	ld	hl, #2+1
	add	hl, sp
	ld	a, (hl)
	and	a, #0x3f
	ld	d,a
	ld	e,#0x99
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:32: ei();
	ei	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:33: return inp(0x98);
	ld	a, #0x98
	push	af
	inc	sp
	call	_inp
	inc	sp
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:34: }
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:36: void vrampoke(unsigned int addr, unsigned char byte)
;	---------------------------------
; Function vrampoke
; ---------------------------------
_vrampoke::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:38: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:39: outp(0x99, addr & 255);
	ld	hl, #2+0
	add	hl, sp
	ld	d, (hl)
	ld	e,#0x99
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:40: outp(0x99, 0x40 | ((addr >> 8) & 0x3f));
	ld	hl, #2+1
	add	hl, sp
	ld	a, (hl)
	and	a, #0x3f
	set	6, a
	ld	d,a
	ld	e,#0x99
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:41: ei();
	ei	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:42: outp(0x98, byte);
	ld	hl, #4+0
	add	hl, sp
	ld	d, (hl)
	ld	e,#0x98
	push	de
	call	_outp
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:43: }
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:46: void sc2()
;	---------------------------------
; Function sc2
; ---------------------------------
_sc2::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:54: for (r =0;r<sizeof(vdpregs);r++)
	ld	bc, #_sc2_vdpregs_65536_180+0
	ld	d, #0x00
00104$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:55: vdpsetreg(r,vdpregs[r]);
	ld	l, d
	ld	h, #0x00
	add	hl, bc
	ld	a, (hl)
	push	bc
	push	de
	push	af
	inc	sp
	push	de
	inc	sp
	call	_vdpsetreg
	pop	af
	pop	de
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:54: for (r =0;r<sizeof(vdpregs);r++)
	inc	d
	ld	a, d
	sub	a, #0x08
	jr	C,00104$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:60: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:61: NameTableInit();
	call	_NameTableInit
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:63: vrampoke (0x2000,0xF1);
	ld	a, #0xf1
	push	af
	inc	sp
	ld	hl, #0x2000
	push	hl
	call	_vrampoke
	pop	af
	inc	sp
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:64: for (counter=1;counter<3*256*8;counter++)
	ld	bc, #0x0001
00106$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:65: outp(0x98,0xF1);
	push	bc
	ld	de, #0xf198
	push	de
	call	_outp
	pop	af
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:64: for (counter=1;counter<3*256*8;counter++)
	inc	bc
	ld	a, b
	sub	a, #0x18
	jr	C,00106$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:67: vrampoke (0x0000,0x00);
	xor	a, a
	push	af
	inc	sp
	ld	hl, #0x0000
	push	hl
	call	_vrampoke
	pop	af
	inc	sp
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:68: for (counter=1;counter<3*256*8;counter++)
	ld	bc, #0x0001
00108$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:69: outp(0x98,0x00);
	push	bc
	xor	a, a
	ld	d,a
	ld	e,#0x98
	push	de
	call	_outp
	pop	af
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:68: for (counter=1;counter<3*256*8;counter++)
	inc	bc
	ld	a, b
	sub	a, #0x18
	jr	C,00108$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:70: }
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:74: void plotpoints(unsigned int x, unsigned int y, unsigned int cx, unsigned int cy)
;	---------------------------------
; Function plotpoints
; ---------------------------------
_plotpoints::
	call	___sdcc_enter_ix
	push	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:76: pset((unsigned char)cx+x,(unsigned char)cy+y);
	ld	c, 10 (ix)
	ld	l, 6 (ix)
	ld	a, c
	add	a, l
	ld	e, a
	ld	a, 8 (ix)
	ld	-2 (ix), a
	ld	a, 4 (ix)
	ld	-1 (ix), a
	ld	a, -2 (ix)
	add	a, -1 (ix)
	ld	b, a
	push	hl
	push	bc
	push	de
	ld	a, e
	push	af
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
	pop	de
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:77: pset((unsigned char)cx-x,(unsigned char)cy+y);
	ld	a, -2 (ix)
	sub	a, -1 (ix)
	ld	d, a
	push	hl
	push	bc
	push	de
	ld	a, e
	push	af
	inc	sp
	push	de
	inc	sp
	call	_pset
	pop	af
	pop	de
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:78: pset((unsigned char)cx-x,(unsigned char)cy-y);
	ld	a, c
	sub	a, l
	ld	h, a
	push	hl
	push	bc
	ld	l, d
	push	hl
	call	_pset
	pop	af
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:79: pset((unsigned char)cx+x,(unsigned char)cy-y);
	push	hl
	push	bc
	push	hl
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:81: pset((unsigned char)cx+y,(unsigned char)cy+x);
	ld	a, c
	add	a, -1 (ix)
	ld	h, a
	ld	a, -2 (ix)
	add	a, l
	ld	b, a
	push	hl
	push	bc
	push	hl
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:82: pset((unsigned char)cx-y,(unsigned char)cy+x);
	ld	a, -2 (ix)
	sub	a, l
	ld	d, a
	push	bc
	push	de
	ld	l, d
	push	hl
	call	_pset
	pop	af
	pop	de
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:83: pset((unsigned char)cx-y,(unsigned char)cy-x);
	ld	a, c
	sub	a, -1 (ix)
	ld	h, a
	push	hl
	push	bc
	ld	l, d
	push	hl
	call	_pset
	pop	af
	pop	bc
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:86: }
	pop	af
	pop	ix
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:89: void circle(unsigned int cx, unsigned int cy, unsigned int radius)
;	---------------------------------
; Function circle
; ---------------------------------
_circle::
	call	___sdcc_enter_ix
	push	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:92: x = 0; y = radius;
	ld	c, 8 (ix)
	ld	b, 9 (ix)
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:93: d = 3 - 2*radius;
	ld	l, c
	ld	h, b
	add	hl, hl
	ld	a, #0x03
	sub	a, l
	ld	-2 (ix), a
	ld	a, #0x00
	sbc	a, h
	ld	-1 (ix), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:94: while (x<y)
	ld	de, #0x0000
00104$:
	ld	a, e
	sub	a, c
	ld	a, d
	sbc	a, b
	jp	PO, 00132$
	xor	a, #0x80
00132$:
	jp	P, 00106$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:96: plotpoints(x, y, cx, cy);
	push	bc
	push	de
	ld	l, 6 (ix)
	ld	h, 7 (ix)
	push	hl
	ld	l, 4 (ix)
	ld	h, 5 (ix)
	push	hl
	push	bc
	push	de
	call	_plotpoints
	pop	af
	pop	af
	pop	af
	pop	af
	pop	de
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:97: if ( d<0 )
	bit	7, -1 (ix)
	jr	Z,00102$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:98: d = d + 4*x + 6;
	ld	l, e
	ld	h, d
	add	hl, hl
	add	hl, hl
	ld	a, l
	add	a, -2 (ix)
	ld	l, a
	ld	a, h
	adc	a, -1 (ix)
	ld	h, a
	ld	a, l
	add	a, #0x06
	ld	-2 (ix), a
	ld	a, h
	adc	a, #0x00
	ld	-1 (ix), a
	jr	00103$
00102$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:101: d = d + 4*(x-y) + 10;
	ld	a, e
	sub	a, c
	ld	l, a
	ld	a, d
	sbc	a, b
	ld	h, a
	add	hl, hl
	add	hl, hl
	ld	a, -2 (ix)
	add	a, l
	ld	l, a
	ld	a, -1 (ix)
	adc	a, h
	ld	h, a
	ld	a, l
	add	a, #0x0a
	ld	-2 (ix), a
	ld	a, h
	adc	a, #0x00
	ld	-1 (ix), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:102: y--;
	dec	bc
00103$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:104: x++;
	inc	de
	jr	00104$
00106$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:106: if (x==y)
	ld	a, c
	sub	a, e
	jr	NZ,00109$
	ld	a, b
	sub	a, d
	jr	NZ,00109$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:107: plotpoints(x, y, cx, cy);
	ld	l, 6 (ix)
	ld	h, 7 (ix)
	push	hl
	ld	l, 4 (ix)
	ld	h, 5 (ix)
	push	hl
	push	bc
	push	de
	call	_plotpoints
	pop	af
	pop	af
	pop	af
	pop	af
00109$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:108: }
	pop	af
	pop	ix
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:113: void main(void)
;	---------------------------------
; Function main
; ---------------------------------
_main::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:119: sc2();
	call	_sc2
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:121: *(int*)0xFC9E = 0;
	ld	hl, #0x0000
	ld	(0xfc9e), hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:123: for (px=0;px<96;px+=2)
	ld	c, #0x00
00105$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:125: circle(127,95, px);
	ld	e, c
	ld	d, #0x00
	push	bc
	push	de
	ld	hl, #0x005f
	push	hl
	ld	l, #0x7f
	push	hl
	call	_circle
	pop	af
	pop	af
	pop	af
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:123: for (px=0;px<96;px+=2)
	inc	c
	inc	c
	ld	a, c
	sub	a, #0x60
	jr	C,00105$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:127: exec_time = (*(int*)0xFC9E);
	ld	hl, #0xfc9e
	ld	a, (hl)
	ld	iy, #_exec_time
	ld	0 (iy), a
	inc	hl
	ld	a, (hl)
	ld	1 (iy), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:129: while(1) {}
00103$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:130: }
	jr	00103$
	.area _CODE
	.area _INITIALIZER
	.area _CABS (ABS)

By PingPong

Prophet (3460)

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

08-09-2019, 15:54

c code

//
// Fusion-C
// My First Program in C
//


#include "stdio.h"
#include "stdlib.h"
#include "fusion-c/header/msx_fusion.h"

#define  di() __asm di __endasm;
#define  ei() __asm ei __endasm;

__sfr __at 0x99 port99;
__sfr __at 0x98 port98;

extern void outp (unsigned char port, unsigned char value);
extern unsigned char inp (unsigned char port);

void pset(unsigned char x, unsigned char y);

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

unsigned char vrampeek(unsigned int addr)
{
	di();
	port99 = addr & 255;
	port99 = 0x99, (addr >> 8) & 0x3f;
	ei();
    return port98;
}

void vrampoke(unsigned int addr, unsigned char byte)
{
	di();
    port99 = addr & 255;
	port99 = (0x99, 0x40 | ((addr >> 8) & 0x3f));
	ei();
	port98 = 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<sizeof(vdpregs);r++)
		vdpsetreg(r,vdpregs[r]);

    // vrampoke (0x1800,0);
	// for (counter=1;counter<256*3;counter++)
        // outp(0x98,counter & 255);
	di();
	NameTableInit();

    vrampoke (0x2000,0xF1);
	for (counter=1;counter<3*256*8;counter++)
        outp(0x98,0xF1);

    vrampoke (0x0000,0x00);
	for (counter=1;counter<3*256*8;counter++)
        outp(0x98,0x00);
}



void plotpoints(unsigned int x, unsigned int y, unsigned int cx, unsigned int cy)
{
	pset((unsigned char)cx+x,(unsigned char)cy+y);
	pset((unsigned char)cx-x,(unsigned char)cy+y);
	pset((unsigned char)cx-x,(unsigned char)cy-y);
	pset((unsigned char)cx+x,(unsigned char)cy-y);

	pset((unsigned char)cx+y,(unsigned char)cy+x);
	pset((unsigned char)cx-y,(unsigned char)cy+x);
	pset((unsigned char)cx-y,(unsigned char)cy-x);
	pset((unsigned char)cx+y,(unsigned char)cy-x);

}


void circle(unsigned int cx, unsigned int cy, unsigned int radius)
{
	int x, y, d;
	x = 0; y = radius;
	d = 3 - 2*radius;
	while (x<y)
	{
		plotpoints(x, y, cx, cy);
    	if ( d<0 )
    		d = d + 4*x + 6;
      	else
      	{
			d = d + 4*(x-y) + 10;
			y--;
		}
    	x++;
	}
	if (x==y)
		plotpoints(x, y, cx, cy);
}


int exec_time;

void main(void)
{

	unsigned char px;

    
	sc2();

    *(int*)0xFC9E = 0;

	for (px=0;px<96;px+=2)
	{
		circle(127,95, px);
	}
	exec_time = (*(int*)0xFC9E);
	
	while(1) {}
}

By PingPong

Prophet (3460)

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

08-09-2019, 15:55

asm

;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.9.0 #11195 (MINGW64)
;--------------------------------------------------------
	.module sdcctest
	.optsdcc -mz80
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _main
	.globl _circle
	.globl _plotpoints
	.globl _sc2
	.globl _vrampoke
	.globl _vrampeek
	.globl _vdpsetreg
	.globl _pset
	.globl _outp
	.globl _exec_time
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
_port99	=	0x0099
_port98	=	0x0098
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area _DATA
_sc2_vdpregs_65536_180:
	.ds 8
_exec_time::
	.ds 2
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area _INITIALIZED
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
	.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area _HOME
	.area _GSINIT
	.area _GSFINAL
	.area _GSINIT
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:54: static unsigned char vdpregs[] = {0x02,0x60,0x06,0xFF, 0x03, 0x36, 0x07,0x04};
	ld	hl, #_sc2_vdpregs_65536_180
	ld	(hl), #0x02
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0001)
	ld	(hl), #0x60
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0002)
	ld	(hl), #0x06
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0003)
	ld	(hl), #0xff
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0004)
	ld	(hl), #0x03
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0005)
	ld	(hl), #0x36
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0006)
	ld	(hl), #0x07
	ld	hl, #(_sc2_vdpregs_65536_180 + 0x0007)
	ld	(hl), #0x04
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area _HOME
	.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area _CODE
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:22: void vdpsetreg (unsigned char regno, unsigned char value)
;	---------------------------------
; Function vdpsetreg
; ---------------------------------
_vdpsetreg::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:24: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:25: port99 = value;
	ld	iy, #3
	add	iy, sp
	ld	a, 0 (iy)
	out	(_port99), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:26: port99 = regno | 0x80;
	ld	iy, #2
	add	iy, sp
	ld	a, 0 (iy)
	or	a, #0x80
	out	(_port99), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:27: ei();
	ei	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:28: }
	ret
_Done_Version:
	.ascii "Made with FUSION-C 1.2 (ebsoft)"
	.db 0x00
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:30: unsigned char vrampeek(unsigned int addr)
;	---------------------------------
; Function vrampeek
; ---------------------------------
_vrampeek::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:32: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:33: port99 = addr & 255;
	ld	iy, #2
	add	iy, sp
	ld	a, 0 (iy)
	out	(_port99), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:34: port99 = 0x99, (addr >> 8) & 0x3f;
	ld	a, #0x99
	out	(_port99), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:35: ei();
	ei	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:36: return port98;
	in	a, (_port98)
	ld	l, a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:37: }
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:39: void vrampoke(unsigned int addr, unsigned char byte)
;	---------------------------------
; Function vrampoke
; ---------------------------------
_vrampoke::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:41: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:42: port99 = addr & 255;
	ld	iy, #2
	add	iy, sp
	ld	a, 0 (iy)
	out	(_port99), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:43: port99 = (0x99, 0x40 | ((addr >> 8) & 0x3f));
	ld	c, 1 (iy)
	ld	b, #0x00
	ld	a, c
	and	a, #0x3f
	or	a, #0x40
	out	(_port99), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:44: ei();
	ei	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:45: port98 = byte;
	ld	hl, #4+0
	add	hl, sp
	ld	a, (hl)
	out	(_port98), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:46: }
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:49: void sc2()
;	---------------------------------
; Function sc2
; ---------------------------------
_sc2::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:57: for (r =0;r<sizeof(vdpregs);r++)
	ld	bc, #_sc2_vdpregs_65536_180+0
	ld	d, #0x00
00104$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:58: vdpsetreg(r,vdpregs[r]);
	ld	l, d
	ld	h, #0x00
	add	hl, bc
	ld	a, (hl)
	push	bc
	push	de
	push	af
	inc	sp
	push	de
	inc	sp
	call	_vdpsetreg
	pop	af
	pop	de
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:57: for (r =0;r<sizeof(vdpregs);r++)
	inc	d
	ld	a, d
	sub	a, #0x08
	jr	C,00104$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:63: di();
	di	
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:64: NameTableInit();
	call	_NameTableInit
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:66: vrampoke (0x2000,0xF1);
	ld	a, #0xf1
	push	af
	inc	sp
	ld	hl, #0x2000
	push	hl
	call	_vrampoke
	pop	af
	inc	sp
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:67: for (counter=1;counter<3*256*8;counter++)
	ld	bc, #0x0001
00106$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:68: outp(0x98,0xF1);
	push	bc
	ld	de, #0xf198
	push	de
	call	_outp
	pop	af
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:67: for (counter=1;counter<3*256*8;counter++)
	inc	bc
	ld	a, b
	sub	a, #0x18
	jr	C,00106$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:70: vrampoke (0x0000,0x00);
	xor	a, a
	push	af
	inc	sp
	ld	hl, #0x0000
	push	hl
	call	_vrampoke
	pop	af
	inc	sp
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:71: for (counter=1;counter<3*256*8;counter++)
	ld	bc, #0x0001
00108$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:72: outp(0x98,0x00);
	push	bc
	xor	a, a
	ld	d,a
	ld	e,#0x98
	push	de
	call	_outp
	pop	af
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:71: for (counter=1;counter<3*256*8;counter++)
	inc	bc
	ld	a, b
	sub	a, #0x18
	jr	C,00108$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:73: }
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:77: void plotpoints(unsigned int x, unsigned int y, unsigned int cx, unsigned int cy)
;	---------------------------------
; Function plotpoints
; ---------------------------------
_plotpoints::
	call	___sdcc_enter_ix
	push	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:79: pset((unsigned char)cx+x,(unsigned char)cy+y);
	ld	c, 10 (ix)
	ld	l, 6 (ix)
	ld	a, c
	add	a, l
	ld	e, a
	ld	a, 8 (ix)
	ld	-2 (ix), a
	ld	a, 4 (ix)
	ld	-1 (ix), a
	ld	a, -2 (ix)
	add	a, -1 (ix)
	ld	b, a
	push	hl
	push	bc
	push	de
	ld	a, e
	push	af
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
	pop	de
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:80: pset((unsigned char)cx-x,(unsigned char)cy+y);
	ld	a, -2 (ix)
	sub	a, -1 (ix)
	ld	d, a
	push	hl
	push	bc
	push	de
	ld	a, e
	push	af
	inc	sp
	push	de
	inc	sp
	call	_pset
	pop	af
	pop	de
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:81: pset((unsigned char)cx-x,(unsigned char)cy-y);
	ld	a, c
	sub	a, l
	ld	h, a
	push	hl
	push	bc
	ld	l, d
	push	hl
	call	_pset
	pop	af
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:82: pset((unsigned char)cx+x,(unsigned char)cy-y);
	push	hl
	push	bc
	push	hl
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:84: pset((unsigned char)cx+y,(unsigned char)cy+x);
	ld	a, c
	add	a, -1 (ix)
	ld	h, a
	ld	a, -2 (ix)
	add	a, l
	ld	b, a
	push	hl
	push	bc
	push	hl
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
	pop	bc
	pop	hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:85: pset((unsigned char)cx-y,(unsigned char)cy+x);
	ld	a, -2 (ix)
	sub	a, l
	ld	d, a
	push	bc
	push	de
	ld	l, d
	push	hl
	call	_pset
	pop	af
	pop	de
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:86: pset((unsigned char)cx-y,(unsigned char)cy-x);
	ld	a, c
	sub	a, -1 (ix)
	ld	h, a
	push	hl
	push	bc
	ld	l, d
	push	hl
	call	_pset
	pop	af
	pop	bc
	inc	sp
	push	bc
	inc	sp
	call	_pset
	pop	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:89: }
	pop	af
	pop	ix
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:92: void circle(unsigned int cx, unsigned int cy, unsigned int radius)
;	---------------------------------
; Function circle
; ---------------------------------
_circle::
	call	___sdcc_enter_ix
	push	af
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:95: x = 0; y = radius;
	ld	c, 8 (ix)
	ld	b, 9 (ix)
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:96: d = 3 - 2*radius;
	ld	l, c
	ld	h, b
	add	hl, hl
	ld	a, #0x03
	sub	a, l
	ld	-2 (ix), a
	ld	a, #0x00
	sbc	a, h
	ld	-1 (ix), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:97: while (x<y)
	ld	de, #0x0000
00104$:
	ld	a, e
	sub	a, c
	ld	a, d
	sbc	a, b
	jp	PO, 00132$
	xor	a, #0x80
00132$:
	jp	P, 00106$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:99: plotpoints(x, y, cx, cy);
	push	bc
	push	de
	ld	l, 6 (ix)
	ld	h, 7 (ix)
	push	hl
	ld	l, 4 (ix)
	ld	h, 5 (ix)
	push	hl
	push	bc
	push	de
	call	_plotpoints
	pop	af
	pop	af
	pop	af
	pop	af
	pop	de
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:100: if ( d<0 )
	bit	7, -1 (ix)
	jr	Z,00102$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:101: d = d + 4*x + 6;
	ld	l, e
	ld	h, d
	add	hl, hl
	add	hl, hl
	ld	a, l
	add	a, -2 (ix)
	ld	l, a
	ld	a, h
	adc	a, -1 (ix)
	ld	h, a
	ld	a, l
	add	a, #0x06
	ld	-2 (ix), a
	ld	a, h
	adc	a, #0x00
	ld	-1 (ix), a
	jr	00103$
00102$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:104: d = d + 4*(x-y) + 10;
	ld	a, e
	sub	a, c
	ld	l, a
	ld	a, d
	sbc	a, b
	ld	h, a
	add	hl, hl
	add	hl, hl
	ld	a, -2 (ix)
	add	a, l
	ld	l, a
	ld	a, -1 (ix)
	adc	a, h
	ld	h, a
	ld	a, l
	add	a, #0x0a
	ld	-2 (ix), a
	ld	a, h
	adc	a, #0x00
	ld	-1 (ix), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:105: y--;
	dec	bc
00103$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:107: x++;
	inc	de
	jr	00104$
00106$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:109: if (x==y)
	ld	a, c
	sub	a, e
	jr	NZ,00109$
	ld	a, b
	sub	a, d
	jr	NZ,00109$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:110: plotpoints(x, y, cx, cy);
	ld	l, 6 (ix)
	ld	h, 7 (ix)
	push	hl
	ld	l, 4 (ix)
	ld	h, 5 (ix)
	push	hl
	push	bc
	push	de
	call	_plotpoints
	pop	af
	pop	af
	pop	af
	pop	af
00109$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:111: }
	pop	af
	pop	ix
	ret
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:116: void main(void)
;	---------------------------------
; Function main
; ---------------------------------
_main::
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:122: sc2();
	call	_sc2
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:124: *(int*)0xFC9E = 0;
	ld	hl, #0x0000
	ld	(0xfc9e), hl
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:126: for (px=0;px<96;px+=2)
	ld	c, #0x00
00105$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:128: circle(127,95, px);
	ld	e, c
	ld	d, #0x00
	push	bc
	push	de
	ld	hl, #0x005f
	push	hl
	ld	l, #0x7f
	push	hl
	call	_circle
	pop	af
	pop	af
	pop	af
	pop	bc
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:126: for (px=0;px<96;px+=2)
	inc	c
	inc	c
	ld	a, c
	sub	a, #0x60
	jr	C,00105$
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:130: exec_time = (*(int*)0xFC9E);
	ld	hl, #0xfc9e
	ld	a, (hl)
	ld	iy, #_exec_time
	ld	0 (iy), a
	inc	hl
	ld	a, (hl)
	ld	1 (iy), a
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:132: while(1) {}
00103$:
;C:\Fusion_C\MSX_Fusion-C-V1.2\Working Folder\sdcctest.c:133: }
	jr	00103$
	.area _CODE
	.area _INITIALIZER
	.area _CABS (ABS)

By PingPong

Prophet (3460)

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

08-09-2019, 16:04

look at vrampoke & vrampeek functions. SDCC generate some kind of lengtly code:
this segment

ld	c, 1 (iy)
	ld	b, #0x00
	ld	a, c
	and	a, #0x3f
	or	a, #0x40
	out	(_port99), a

is simply extremely stupid.
ld c, then ld b, 00 then ld a, c (so first ld c could be ld a, .....

By ARTRAG

Enlighted (6279)

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

08-09-2019, 16:05

The comparison is interesting, anyway, according to z88dk's developers, this is the best C compiler for Z80. A set of tests from 2017 is here:
https://github.com/z88dk/z88dk/tree/master/libsrc/_DEVELOPME...

The Hi-Tech C is V750 and not its latest version v780pl2
About SDCC they have used version 3.6.5 and not 3.9

By Thom

Hero (592)

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

08-09-2019, 16:09

I have no idea which is the better one, but it looks like the Hi-Tech Libraries Source Codes are available:
https://github.com/z88dk/z88dk/issues/972
or
https://github.com/arpruss/ozdev/tree/master/libsrc

By akumajo

Resident (37)

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

08-09-2019, 16:26

I'm glad to see that there is a growing community of programmers using SDCC and even more pleased to see that a specific version for Z80 has just been released. I just tried ZSDCC and I admit it was really won me over ; The generated code is clean and optimized. Thank you for this topic that will allow many of us to improve in writing C programs with SDCC and/or ZSDCC!

Yes, currently Fusion-C use SDCC version 3.6.5

By Juan Luis

Expert (71)

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

08-09-2019, 16:37

PingPong wrote:

look at vrampoke & vrampeek functions. SDCC generate some kind of lengtly code:
this segment

ld	c, 1 (iy)
	ld	b, #0x00
	ld	a, c
	and	a, #0x3f
	or	a, #0x40
	out	(_port99), a

is simply extremely stupid.
ld c, then ld b, 00 then ld a, c (so first ld c could be ld a, .....

It's true. The contents of iy+1 could be loaded in a directly. And what is 'ld b,#00' instruction for? B register doesn't seem to be used later.

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