Autor
| c compiler comparison
| ARTRAG msx master Mensajes: 1802 | Publicado: Febrero 28 2007, 01:34   | Could anyone who use a C compiler (even cross) compile the following code and post the ASM file in otput?
Please specify in the post also the compiler version and the parameter used
/* - SIEVE.C -
The benchmark C source function.
$Name: V3_34K V3_34J V3_34I V3_34H V3_34G $
*/
#include "stdio.h"
/* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983. */
#define TRUE 1
#define FALSE 0
#define SIZE 8190
char flags[SIZE+1];
void main()
{
register int i,k;
int prime,count,iter;
printf("10 iterations\n");
for (iter = 1; iter <= 10; iter++) /* do program 10 times */
{
count = 0; /* initialize prime counter */
for (i = 0; i <= SIZE; i++) /* set all flags true */
flags[i] = TRUE;
for (i = 0; i <= SIZE; i++)
{
if (flags[i]) /* found a prime */
{
prime = i + i + 3; /* twice index + 3 */
for (k = i + prime; k <= SIZE; k += prime)
flags[k] = FALSE; /* kill all multiples */
count++; /* primes found */
}
}
}
printf("%d primes.\n",count); /*primes found in 10th pass */
}
| | ARTRAG msx master Mensajes: 1802 | Publicado: Febrero 28 2007, 09:00   | IAR Z80/64180 C-Compiler V4.06A/W32
All optimizations for speed active
NAME sieve(16)
RSEG CODE(0)
RSEG CSTR(0)
RSEG UDATA0(0)
PUBLIC flags
PUBLIC main
EXTERN printf
EXTERN ?CLZ80L_4_06_L00
RSEG CODE
main:
PUSH BC
PUSH DE
PUSH IY
EXX
PUSH BC
PUSH DE
EXX
PUSH IX
LD IX,0
ADD IX,SP
PUSH AF
LD HL,?0010
PUSH HL
CALL printf
POP AF
LD (IX-2),1
LD (IX-1),0
?0012:
LD C,(IX-2)
LD B,(IX-1)
LD HL,10
OR 128
SBC HL,BC
JP PO,?0030
XOR H
?0030:
JP M,?0011
?0013:
EXX
LD DE,0
EXX
LD DE,0
?0016:
LD HL,8190
OR 128
SBC HL,DE
JP PO,?0031
XOR H
?0031:
JP M,?0015
?0017:
LD HL,flags
ADD HL,DE
LD (HL),1
INC DE
JR ?0016
?0015:
LD DE,0
?0020:
LD HL,8190
OR 128
SBC HL,DE
JP PO,?0032
XOR H
?0032:
JP M,?0019
?0021:
LD HL,flags
ADD HL,DE
LD A,(HL)
OR A
JR Z,?0024
?0023:
LD L,E
LD H,D
INC HL
ADD HL,HL
INC HL
PUSH HL
EXX
POP BC
EXX
ADD HL,DE
PUSH HL
POP IY
?0026:
PUSH IY
POP BC
LD HL,8190
OR 128
SBC HL,BC
JP PO,?0033
XOR H
?0033:
JP M,?0025
?0027:
LD HL,flags
PUSH IY
POP BC
ADD HL,BC
LD (HL),0
EXX
PUSH BC
EXX
POP BC
ADD IY,BC
JR ?0026
?0025:
EXX
INC DE
EXX
?0024:
INC DE
JR ?0020
?0019:
INC (IX-2)
JP NZ,?0012
INC (IX-1)
JP ?0012
?0011:
EXX
PUSH DE
EXX
LD HL,?0029
PUSH HL
CALL printf
POP AF
POP AF
LD SP,IX
POP IX
EXX
POP DE
POP BC
EXX
POP IY
POP DE
POP BC
RET
RSEG CSTR
?0010:
DEFB '10 iterations'
DEFB 10,0
?0029:
DEFB '%d primes.'
DEFB 10,0
RSEG UDATA0
flags:
DEFS 8191
END
| | MicroTech msx lover Mensajes: 123 | Publicado: Febrero 28 2007, 09:01   |
; MSX-C ver 1.20p (code generator)
cseg
pSysHe:
defw 0
pP0Hea:
defw 0
dseg
flags@: defs 8191
start0: defs 2
stop0@: defs 2
start1: defs 2
stop1@: defs 2
cseg
?59999:
defb 49,48,32,105,116,101,114,97,116,105
defb 111,110,115,10,0
?59998:
defb 37,100,32,112,114,105,109,101,115,46
defb 10,0
?59997:
defb 116,105,109,101,114,32,48,32,61,32
defb 37,100,10,0
?59996:
defb 116,105,109,101,114,32,49,32,61,32
defb 37,100,10,0
main@:
ld hl,(64670)
ld (start0),hl
ld bc,?59999
push bc
ld hl,1
call printf
pop bc
ld hl,(64670)
ld (start1),hl
ld de,1
@8:
ld hl,10
call ?CPSHD
jp c,@0
ld bc,0
push de
ld de,0
@2:
ld hl,8190
call ?CPSHD
jp c,@1
ld hl,flags@
add hl,de
ld (hl),1
inc de
jp @2
@1:
ld de,0
@7:
ld hl,8190
call ?CPSHD
jp c,@3
ld hl,flags@
add hl,de
push de
ld a,(hl)
or a
jp z,@4
ld l,e
ld h,d
add hl,de
inc hl
inc hl
inc hl
push bc
ld c,l
ld b,h
ex de,hl
add hl,bc
ex de,hl
@6:
ld hl,8190
call ?CPSHD
jp c,@5
ld hl,flags@
add hl,de
ld (hl),0
ex de,hl
add hl,bc
ex de,hl
jp @6
@5:
pop bc
inc bc
@4:
pop de
inc de
jp @7
@3:
pop de
inc de
jp @8
@0:
ld hl,(64670)
ld (stop1@),hl
push bc
ld bc,?59998
push bc
ld hl,2
call printf
pop bc
pop bc
ld hl,(64670)
ld (stop0@),hl
ld hl,(stop0@)
ex de,hl
ld hl,(start0)
ld a,e
sub l
ld e,a
ld a,d
sbc a,h
ld d,a
push de
ld bc,?59997
push bc
ld hl,2
call printf
pop bc
pop bc
ld hl,(stop1@)
ex de,hl
ld hl,(start1)
ld a,e
sub l
ld e,a
ld a,d
sbc a,h
ld d,a
push de
ld bc,?59996
push bc
ld hl,2
call printf
pop bc
pop bc
ret
public pSysHe
public pP0Hea
public flags@
public start0
public stop0@
public start1
public stop1@
public main@
extrn printf
extrn ?CPSHD
end
I added a couple of instruction to measure execution time by reading (JIFFY) before and after the main loop and I found the following:
Compiler: Ascii C 1.2
Computer: BlueMsx 2.6.1 with machine "MSX2+" with DOS2 cartridge at 60Hz
Execution time: 1008 vdp interrupts so approx 16,8 secs
Compiler: Ascii C 1.2
Computer: BlueMsx 2.6.1 with machine "MSX Turbo-R" at 60Hz
Execution time: 144 vdp interrupts so approx 2,4 secs
Hope this can be useful
MicroTech
| | manuel msx guru Mensajes: 3635 | Publicado: Febrero 28 2007, 10:10   | Can someone try with z88dk? I'll try to add Hi-Tech C for CP/M soon. (But feel free to post it earlier!)
| | ARTRAG msx master Mensajes: 1802 | Publicado: Febrero 28 2007, 11:10   | IAR takes 1006 ints at 60Hz, (plain japanese MSX1 in blue 2.6.1)
but the code has been loaded in ram and
the time has been computed in basic
with the instruction time:
time=0:?usr(0):?time
| | ZilogMonkey msx friend Mensajes: 2 | Publicado: Febrero 28 2007, 12:26   | SDCC (Small Devices C Compiler)...
Comments by compiler removed!
Does there exist a stub for MSX? And I will mesure time on MSX (Amstrad CPC user  )...
.module sieve
.optsdcc -mz80
.globl _main
.globl _flags
.area _DATA
.ds 8191
.area _OVERLAY
.area _GSINIT
.area _GSFINAL
.area _HOME
.area _CODE
_main_start::
_main: push ix
ld ix,#0
add ix,sp
ld hl,#-8
add hl,sp
ld sp,hl
ld hl,#__str_0
push hl
call _printf
pop af
ld -8(ix),#0x01
ld -7(ix),#0x00
00115$: ld a,#0x0A
sub a,-8(ix)
ld a,#0x00
sbc a,-7(ix)
jp M,00118$
ld de,#0x0000
00103$: ld a,#0xFE
sub a,e
ld a,#0x1F
sbc a,d
jp M,00106$
ld hl,#_flags
add hl,de
ld c,l
ld b,h
ld a,#0x01
ld (bc),a
inc de
jp 00103$
00106$: ld -6(ix),#0x00
ld -5(ix),#0x00
ld -2(ix),#0x00
ld -1(ix),#0x00
00111$: ld a,#0xFE
sub a,-2(ix)
ld a,#0x1F
sbc a,-1(ix)
jp M,00131$
ld a,#<_flags
add a,-2(ix)
ld c,a
ld a,#>_flags
adc a,-1(ix)
ld b,a
ld a,(bc)
or a,a
jr Z,00113$
ld c,-2(ix)
ld b,-1(ix)
sla c
rl b
ld a,c
add a,#0x03
ld -4(ix),a
ld a,b
adc a,#0x00
ld -3(ix),a
ld a,-2(ix)
add a,-4(ix)
ld c,a
ld a,-1(ix)
adc a,-3(ix)
ld b,a
00107$: ld a,#0xFE
sub a,c
ld a,#0x1F
sbc a,b
jp M,00110$
ld hl,#_flags
add hl,bc
ld e,l
ld d,h
ld a,#0x00
ld (de),a
ld a,c
add a,-4(ix)
ld c,a
ld a,b
adc a,-3(ix)
ld b,a
jp 00107$
00110$: inc -6(ix)
jr NZ,00135$
inc -5(ix)
00135$:
00113$: inc -2(ix)
jr NZ,00136$
inc -1(ix)
00136$: jp 00111$
00131$: ld c,-6(ix)
ld b,-5(ix)
inc -8(ix)
jr NZ,00137$
inc -7(ix)
00137$: jp 00115$
00118$: push bc
ld hl,#__str_1
push hl
call _printf
pop af
pop af
ld sp,ix
pop ix
ret
_main_end::
__str_0:
.ascii "10 iterations"
.db 0x0A
.db 0x00
__str_1:
.ascii "%d primes."
.db 0x0A
.db 0x00
.area _CODE
.area _CABS
| | ARTRAG msx master Mensajes: 1802 | Publicado: Febrero 28 2007, 14:34   | Softools WinIde 1.68.37
All .debug and other comments have been removed
;26 /* - SIEVE.C -
;27
;28 The benchmark C source function.
;29
;30 $Name: V3_34K V3_34J V3_34I V3_34H V3_34G $
;31
;32 */
;33
;34 #include "stdio.h"
;35
;36 /* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983. */
;37
;38 #define TRUE 1
;39 #define FALSE 0
;40 #define SIZE 8190
;41
;42 char flags[SIZE+1];
;43
;44 void bank1()
;45 {
_bank1::
ld hl,-10
call __fent##
;46 register int i,k;
;47 int prime,count,iter;
;48
;49 printf("10 iterations\n");
ld hl,@4
push hl
call _printf
pop de
;50 for (iter = 1; iter <= 10; iter++) /* do program 10 times */
@5:
ld (ix-10),low 0x1
ld (ix-9),high 0x1
@7:
ld l,(ix-10)
ld h,(ix-9)
ld de,0xa
call __icmp##
jr z,@9
jp nc,@8
@9:
;51 {
;52 count = 0; /* initialize prime counter */
@11:
ld hl,0
ld (ix-8),l
ld (ix-7),h
;53 for (i = 0; i <= SIZE; i++) /* set all flags true */
@13:
ld (ix-2),l
ld (ix-1),h
@15:
ld l,(ix-2)
ld h,(ix-1)
ld de,0x1ffe
call __icmp##
jr z,@17
jr nc,@16
@17:
;54 flags[i] = TRUE;
ld l,(ix-2)
ld h,(ix-1)
ld de,_flags
add hl,de
ld a,0x1
ld (hl),a
;55 for (i = 0; i <= SIZE; i++)
ld l,(ix-2)
ld h,(ix-1)
inc hl
ld (ix-2),l
ld (ix-1),h
jr @15
@16:
@14:
@19:
ld (ix-2),low 0
ld (ix-1),high 0
@21:
ld l,(ix-2)
ld h,(ix-1)
ld de,0x1ffe
call __icmp##
jr z,@23
jr nc,@22
@23:
;56 {
;57 if (flags[i]) /* found a prime */
@25:
ld l,(ix-2)
ld h,(ix-1)
ld de,_flags
add hl,de
ld a,(hl)
or a,a
jr z,@27
;58 {
;59 prime = i + i + 3; /* twice index + 3 */
@28:
ld l,(ix-2)
ld h,(ix-1)
ld e,l
ld d,h
add hl,de
inc hl
inc hl
inc hl
ld (ix-6),l
ld (ix-5),h
;60 for (k = i + prime; k <= SIZE; k += prime)
@30:
ld l,e
ld h,d
ld e,(ix-6)
ld d,(ix-5)
add hl,de
ld (ix-4),l
ld (ix-3),h
@32:
ld l,(ix-4)
ld h,(ix-3)
ld de,0x1ffe
call __icmp##
jr z,@34
jr nc,@33
@34:
;61 flags[k] = FALSE; /* kill all multiples */
ld l,(ix-4)
ld h,(ix-3)
ld de,_flags
add hl,de
xor a,a
ld (hl),a
;62 count++; /* primes found */
ld l,(ix-4)
ld h,(ix-3)
ld e,(ix-6)
ld d,(ix-5)
add hl,de
ld (ix-4),l
ld (ix-3),h
jr @32
@33:
@31:
inc (ix-8)
jr nz,@36
inc (ix-7)
@36:
;63 }
@29:
;64 }
@27:
@26:
;65 }
ld l,(ix-2)
ld h,(ix-1)
inc hl
ld (ix-2),l
ld (ix-1),h
jp @21
@22:
@20:
@12:
;66 printf("%d primes.\n",count); /*primes found in 10th pass */
ld l,(ix-10)
ld h,(ix-9)
inc hl
ld (ix-10),l
ld (ix-9),h
jp @7
@8:
@6:
ld l,(ix-8)
ld h,(ix-7)
push hl
ld hl,@4+15
push hl
call _printf
pop de
pop de
;67 }
@2:
@1 equ 10
ld sp,ix
pop ix
ret
@3 equ 12
.extern _printf 33
.bseg
_flags::
.ds 8191
@4:
.db "10 iterations",10,0,"%d primes.",10,0
.end
| | ARTRAG msx master Mensajes: 1802 | Publicado: Febrero 28 2007, 16:01   | Hitech C v7.8
global small_model
global _main
signat _main,24
psect text,class=CODE
global _printf
signat _printf,26
global _flags
global wrelopbc
global wrelop
global wrelop
global wrelopbc
global wrelop
file "C:\WINDOWS\DESKTOP\SIEVE.C"
line 21
_main:
push ix
ld ix,0
add ix,sp
push bc
push bc
push bc
push iy
;SIEVE.C: 22: register int i,k;
line 25
ld hl,u19
push hl
call _printf
pop bc
;SIEVE.C: 26: for (iter = 1; iter <= 10; iter++)
line 26
ld (ix+-6),01h
ld (ix+-5),0
line 27
l4:
;SIEVE.C: 27: {
;SIEVE.C: 28: count = 0;
line 28
ld (ix+-4),0
ld (ix+-3),0
;SIEVE.C: 29: for (i = 0; i <= 8190; i++)
; _i allocated to bc
line 29
ld bc,0
line 30
l7:
;SIEVE.C: 30: flags[i] = 1;
ld hl,_flags
add hl,bc
ld (hl),01h
line 29
inc bc
ld hl,01FFFh
call wrelopbc
jp m,l7
;SIEVE.C: 31: for (i = 0; i <= 8190; i++)
line 31
ld bc,0
line 32
l10:
;SIEVE.C: 32: {
;SIEVE.C: 33: if (flags[i])
line 33
ld hl,_flags
add hl,bc
ld a,(hl)
or a
jp z,l13
;SIEVE.C: 34: {
line 35
ld hl,03h
add hl,bc
add hl,bc
ld (ix+-2),l
ld (ix+-1),h
;SIEVE.C: 36: for (k = i + prime; k <= 8190; k += prime)
; _k allocated to iy
line 36
add hl,bc
push hl
pop iy
jp L1
line 37
l14:
;SIEVE.C: 37: flags[k] = 0;
ld hl,_flags
push iy
pop de
add hl,de
ld (hl),0
line 36
ld e,(ix+-2)
ld d,(ix+-1)
add iy,de
L1:
ld de,01FFFh
push iy
pop hl
call wrelop
jp m,l14
;SIEVE.C: 38: count++;
line 38
inc (ix+-4)
jp nz,l13
inc (ix+-3)
line 39
l13:
;SIEVE.C: 39: }
line 31
inc bc
ld hl,01FFFh
call wrelopbc
jp m,l10
;SIEVE.C: 41: }
line 26
inc (ix+-6)
jp nz,u21
inc (ix+-5)
u21:
ld de,0Bh
ld l,(ix+-6)
ld h,(ix+-5)
call wrelop
jp m,l4
;SIEVE.C: 42: printf("%d primes.\n",count);
line 42
ld l,(ix+-4)
ld h,(ix+-3)
push hl
ld hl,u29
push hl
call _printf
pop bc
pop bc
;SIEVE.C: 43: }
line 43
pop iy
ld sp,ix
pop ix
ret
psect strings,class=CODE
u19:
defb "10 iterations",10,0
u29:
defb "%d primes.",10,0
psect bss,class=DATA
_flags:
defs 8191
psect text
end
| | PingPong msx master Mensajes: 1069 | Publicado: Febrero 28 2007, 16:07   | I think that instead of read the asm code should be useful to test small 'c' fragment to see how each compiler implements some 'c' things like:
a) pointer indirection:
int* p=(int*)0x0000;
int k = *p;
b) structure indirection:
struct xy
{
int a;
char b;
} s;
s.a = s.b;
c) automatic (stack based) variable indirection
{
int a;
a=0;
}
d) more levels of indirection. such as
(*myptr[c]->someintPtr)++;
e) copy propagation and invariant 'code motion', copy propagation, common subexpression elimination
switch (c)
{
case 1:
doFirstThing();
doSecondThing();
break;
case 2:
DoThirdThing();
DoSecondThing()
}
......
f) peephole optimization, and so on...
In this way we can see what is the best 'c' compiler.
With a sieve program, maybe there are good results on a poor compiler, while in the average the same compiler performs bad.
| | manuel msx guru Mensajes: 3635 | Publicado: Febrero 28 2007, 20:41   | Hi-Tech C CP/M:
psect text
global _main
_main:
global ncsv, cret, indir
call ncsv
defw f31
global _printf
ld hl,19f
push hl
call _printf
ld hl,2
add hl,sp
ld sp,hl
ld (ix+-10),.low.1
ld (ix+1+-10),.high.1
jp l6
l3:
ld (ix+-8),.low.0
ld (ix+1+-8),.high.0
ld (ix+-2),.low.0
ld (ix+1+-2),.high.0
jp l10
l7:
global _flags
ld e,(ix+-2)
ld d,(ix+1+-2)
ld hl,_flags
add hl,de
ld (hl),1
l9:
ld l,(ix+-2)
ld h,(ix+1+-2)
inc hl
ld (ix+-2),l
ld (ix+1+-2),h
l10:
ld e,(ix+-2)
ld d,(ix+1+-2)
ld hl,8190
global wrelop
call wrelop
jp age,l7
l8:
ld (ix+-2),.low.0
ld (ix+1+-2),.high.0
jp l14
l11:
ld e,(ix+-2)
ld d,(ix+1+-2)
ld hl,_flags
add hl,de
ld a,(hl)
or a
jp az,l15
ld e,(ix+-2)
ld d,(ix+1+-2)
ld l,(ix+-2)
ld h,(ix+1+-2)
add hl,de
inc hl
inc hl
inc hl
ld (ix+-6),l
ld (ix+1+-6),h
ld e,(ix+-6)
ld d,(ix+1+-6)
ld l,(ix+-2)
ld h,(ix+1+-2)
add hl,de
ld (ix+-4),l
ld (ix+1+-4),h
jp l19
l16:
ld e,(ix+-4)
ld d,(ix+1+-4)
ld hl,_flags
add hl,de
ld (hl),0
l18:
ld e,(ix+-6)
ld d,(ix+1+-6)
ld l,(ix+-4)
ld h,(ix+1+-4)
add hl,de
ld (ix+-4),l
ld (ix+1+-4),h
l19:
ld e,(ix+-4)
ld d,(ix+1+-4)
ld hl,8190
global wrelop
call wrelop
jp age,l16
l17:
ld l,(ix+-8)
ld h,(ix+1+-8)
inc hl
ld (ix+-8),l
ld (ix+1+-8),h
l15:
l13:
ld l,(ix+-2)
ld h,(ix+1+-2)
inc hl
ld (ix+-2),l
ld (ix+1+-2),h
l14:
ld e,(ix+-2)
ld d,(ix+1+-2)
ld hl,8190
global wrelop
call wrelop
jp age,l11
l12:
l5:
ld l,(ix+-10)
ld h,(ix+1+-10)
inc hl
ld (ix+-10),l
ld (ix+1+-10),h
l6:
ld e,(ix+-10)
ld d,(ix+1+-10)
ld hl,10
global wrelop
call wrelop
jp age,l3
l4:
ld l,(ix+-8)
ld h,(ix+1+-8)
push hl
ld hl,29f
push hl
call _printf
ld hl,2+2
add hl,sp
ld sp,hl
l2:
jp cret
f31 equ -10
psect data
19:
defb 49,48,32,105,116,101,114,97,116,105,111,110,115,10,0
29:
defb 37,100,32,112,114,105,109,101,115,46,10,0
psect bss
_flags:
defs 8191
So, which code is best, so far?
| | ARTRAG msx master Mensajes: 1802 | Publicado: Febrero 28 2007, 20:54   | Very hard to say,
Atm the Ascii C 1.2 and the IAR seem very close,
how many ints HITECH CPM takes?
| | manuel msx guru Mensajes: 3635 | Publicado: Marzo 01 2007, 11:32   | I didn't compile it. Please do  (It results in a COM file, and I didn't have a tool to measure ints for such a program.) | | ARTRAG msx master Mensajes: 1802 | Publicado: Marzo 01 2007, 15:31   | Ok, after having passed quite a lot of time trying to assemble and execute the asm codes posted here
I propose to compile and run this new version of the test sieve, posting both the ASM code and the
results on a plain z80 with video at 60Hz (or 50Hz but in this case resuts needsa conversion 6/5)
/* - SIEVE.C -
The benchmark C source function.
$Name: V3_34K V3_34J V3_34I V3_34H V3_34G $
*/
#include "stdio.h"
/* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983. */
#define TRUE 1
#define FALSE 0
#define SIZE 8190
char flags[SIZE+1];
void main()
{
register int i,k;
int prime,count,iter;
*((int*) 0xFC9E) = 0; /* reset internal timer jiffy */
printf("10 iterations\n");
for (iter = 1; iter <= 10; iter++) /* do program 10 times */
{
count = 0; /* initialize prime counter */
for (i = 0; i <= SIZE; i++) /* set all flags true */
flags[i] = TRUE;
for (i = 0; i <= SIZE; i++)
{
if (flags[i]) /* found a prime */
{
prime = i + i + 3; /* twice index + 3 */
for (k = i + prime; k <= SIZE; k += prime)
flags[k] = FALSE; /* kill all multiples */
count++; /* primes found */
}
}
}
printf("%d primes.\n",count); /*primes found in 10th pass */
printf("%d ints.\n",*((int*) 0xFC9E)); /*ints passed in 10th pass */
}
| | ARTRAG msx master Mensajes: 1802 | Publicado: Marzo 01 2007, 16:14   | Please, consider that mine isn't laziness.
The problem is that some asm files need support functions for comparisons or for printf, so assembling them without modifications and without
affacting the real performance of the compiler becomes quite hard.
| | ARTRAG msx master Mensajes: 1802 | Publicado: Marzo 01 2007, 17:54   | First result of the new C code:
Hitech C v7.8 : 1281 ints!!
Page 1
1 global small_model
2 global _main
3 signat _main,24
4 0000' psect text,class=CODE
5 global _printf
6 signat _printf,26
7 global _flags
8 global wrelopbc
9 global wrelop
10 global wrelop
11 global wrelopbc
12 global wrelop
13 file "..\TESTS\SIEVE.C"
14 line 17
15 0000' _main:
16 0000' DD E5 push ix
17 0002' DD 21 0000 ld ix,0
18 0006' DD 39 add ix,sp
19 0008' C5 push bc
20 0009' C5 push bc
21 000A' C5 push bc
22 000B' FD E5 push iy
23 ;SIEVE.C: 18: register int i,k;
24 line 21
25 000D' 21 0000 ld hl,0
26 0010' 22 FC9E ld (-866),hl
27 ;SIEVE.C: 23: printf("10 iterations\n");
28 line 23
29 0013' 21 0000' ld hl,u19
30 0016' E5 push hl
31 0017' CD 0000* call _printf
32 001A' C1 pop bc
33 ;SIEVE.C: 24: for (iter = 1; iter <= 10; iter++)
34 line 24
35 001B' DD 36 FA 01 ld (ix+-6),01h
36 001F' DD 36 FB 00 ld (ix+-5),0
37 line 25
38 0023' l4:
39 ;SIEVE.C: 25: {
40 ;SIEVE.C: 26: count = 0;
41 line 26
42 0023' DD 36 FC 00 ld (ix+-4),0
43 0027' DD 36 FD 00 ld (ix+-3),0
44 ;SIEVE.C: 27: for (i = 0; i <= 8190; i++)
45 ; _i allocated to bc
46 line 27
47 002B' 01 0000 ld bc,0
48 line 28
49 002E' l7:
50 ;SIEVE.C: 28: flags[i] = 1;
51 002E' 21 0000' ld hl,_flags
52 0031' 09 add hl,bc
53 0032' 36 01 ld (hl),01h
54 line 27
55 0034' 03 inc bc
HI-TECH SOFTWARE Z80 Macro Assembler Sun Feb 29 17:51:39 2004
Page 2
56 0035' 21 1FFF ld hl,01FFFh
57 0038' CD 0000* call wrelopbc
58 003B' FA 002E' jp m,l7
59 ;SIEVE.C: 29: for (i = 0; i <= 8190; i++)
60 line 29
61 003E' 01 0000 ld bc,0
62 line 30
63 0041' l10:
64 ;SIEVE.C: 30: {
65 ;SIEVE.C: 31: if (flags[i])
66 line 31
67 0041' 21 0000' ld hl,_flags
68 0044' 09 add hl,bc
69 0045' 7E ld a,(hl)
70 0046' B7 or a
71 0047' 28 36 jp z,l13
72 ;SIEVE.C: 32: {
73 line 33
74 0049' 21 0003 ld hl,03h
75 004C' 09 add hl,bc
76 004D' 09 add hl,bc
77 004E' DD 75 FE ld (ix+-2),l
78 0051' DD 74 FF ld (ix+-1),h
79 ;SIEVE.C: 34: for (k = i + prime; k <= 8190; k +
= prime)
80 ; _k allocated to iy
81 line 34
82 0054' 09 add hl,bc
83 0055' E5 push hl
84 0056' FD E1 pop iy
85 0058' 18 11 jp L1
86
87 line 35
88 005A' l14:
89 ;SIEVE.C: 35: flags[k] = 0;
90 005A' 21 0000' ld hl,_flags
91 005D' FD E5 push iy
92 005F' D1 pop de
93 0060' 19 add hl,de
94 0061' 36 00 ld (hl),0
95 line 34
96 0063' DD 5E FE ld e,(ix+-2)
97 0066' DD 56 FF ld d,(ix+-1)
98 0069' FD 19 add iy,de
99 006B' L1:
100 006B' 11 1FFF ld de,01FFFh
101 006E' FD E5 push iy
102 0070' E1 pop hl
103 0071' CD 0000* call wrelop
104 0074' FA 005A' jp m,l14
105 ;SIEVE.C: 36: count++;
106 line 36
107 0077' DD 34 FC inc (ix+-4)
108 007A' 20 03 jp nz,l13
109 007C' DD 34 FD inc (ix+-3)
HI-TECH SOFTWARE Z80 Macro Assembler Sun Feb 29 17:51:39 2004
Page 3
110 line 37
111 007F' l13:
112 ;SIEVE.C: 37: }
113 line 29
114 007F' 03 inc bc
115 0080' 21 1FFF ld hl,01FFFh
116 0083' CD 0000* call wrelopbc
117 0086' FA 0041' jp m,l10
118 ;SIEVE.C: 39: }
119 line 24
120 0089' DD 34 FA inc (ix+-6)
121 008C' 20 03 jp nz,u21
122 008E' DD 34 FB inc (ix+-5)
123 0091' u21:
124 0091' 11 000B ld de,0Bh
125 0094' DD 6E FA ld l,(ix+-6)
126 0097' DD 66 FB ld h,(ix+-5)
127 009A' CD 0000* call wrelop
128 009D' FA 0023' jp m,l4
129 ;SIEVE.C: 40: printf("%d primes.\n",count);
130 line 40
131 00A0' DD 6E FC ld l,(ix+-4)
132 00A3' DD 66 FD ld h,(ix+-3)
133 00A6' E5 push hl
134 00A7' 21 0019' ld hl,u29
135 00AA' E5 push hl
136 00AB' CD 0000* call _printf
137 00AE' C1 pop bc
138 00AF' C1 pop bc
139 ;SIEVE.C: 41: printf("%d ints.\n",*((int*) 0xFC9
E));
140 line 41
141 00B0' 2A FC9E ld hl,(-866)
142 00B3' E5 push hl
143 00B4' 21 000F' ld hl,u39
144 00B7' E5 push hl
145 00B8' CD 0000* call _printf
146 00BB' C1 pop bc
147 00BC' C1 pop bc
148 ;SIEVE.C: 42: }
149 line 42
150 00BD' FD E1 pop iy
151 00BF' DD F9 ld sp,ix
152 00C1' DD E1 pop ix
153 00C3' C9 ret
154 0000' psect strings,class=CODE
155 0000' u19:
156 0000' 31 30 20 69 defb "10 iterations",10,0
0004' 74 65 72 61
0008' 74 69 6F 6E
000C' 73 0A 00
157 000F' u39:
158 000F' 25 64 20 69 defb "%d ints.",10,0
0013' 6E 74 73 2E
0017' 0A 00
HI-TECH SOFTWARE Z80 Macro Assembler Sun Feb 29 17:51:39 2004
Page 4
159 0019' u29:
160 0019' 25 64 20 70 defb "%d primes.",10,0
001D' 72 69 6D 65
0021' 73 2E 0A 00
161 0000' psect bss,class=DATA
162 0000' _flags:
163 0000' defs 8191
164 00C4' psect text
HI-TECH SOFTWARE Z80 Macro Assembler Sun Feb 29 17:51:39 2004
Page 5
---------- Symbol Table ----------
(ABS) 0000# CODE 0000 CODE 0000 CODE 0000
CODE 0000 CODE 0000 CODE 0000 DATA 0000
DATA 0000 DATA 0000 L1 006B' _flags 0000'
_main 0000' _printf 0000* bss 0000# l10 0041'
l13 007F' l14 005A' l4 0023' l7 002E'
small_model 0000* strings 0025# text 00C4# u19 0000'
u21 0091' u29 0019' u39 000F' wrelop 0000*
wrelopbc 0000*
4 jump optimizations
| |
| |
| |