Jeśli chcesz wziąć udział w dyskusjach na forum - zaloguj się. Jeżeli nie masz loginu - poproś o członkostwo.
Vanilla 1.1.4 jest produktem Lussumo. Więcej informacji: Dokumentacja, Forum.
n = OS.rtclok[2]
#include <stdio.h>
#include <peekpoke.h>
#define p 10000
#define r 16129
#define tick (PEEK(0x14))
#define tack (PEEK(0x13) * 256)
#define rndp (PEEK(0xd20a))
void main(void)
{
register unsigned int stop, i, x, y;
register unsigned int b = 0;
register unsigned char n;
n = tick;
while (tick == n) { ; }
printf("\nMonte-Carlo PI cc65 V2.18\n");
asm(" lda #0");
asm(" sta $13");
asm(" sta $14");
for (i = 0 ; i < p; ++i)
{
n = (rndp | 128) ^ 128;
x = n * n;
n = (rndp | 128) ^ 128;
y = n * n;
if ((x + y) <= r)
++b;
}
b *= 4;
stop = tick + tack;
printf("%d%c%c%c%c%c%c\n", b, 30, 30, 30, 30, 255, 46);
printf("%d ticks\n", stop);
infinite:
goto infinite;
}
#include <stdio.h>
#define p 10000
#define r 16129
#define tick 0x14
#define tack 0x13
#define rndp 0xd20a
void main(void)
{
register unsigned int stop, i, x, y;
register unsigned int b = 0;
register unsigned char n;
n = *(char*)tick;
while (*(char*)tick == n) { ; }
printf("\nMonte-Carlo PI cc65 V2.18\n");
asm(" lda #0");
asm(" sta $13");
asm(" sta $14");
for (i = 0 ; i < p; ++i)
{
n = (*(char*)rndp | 128) ^ 128;
x = n * n;
n = (*(char*)rndp | 128) ^ 128;
y = n * n;
if ((x + y) <= r)
++b;
}
b *= 4;
stop = *(char*)tick + 256 * *(char*)tack;
printf("%d%c%c%c%c%c%c\n", b, 30, 30, 30, 30, 255, 46);
printf("%d ticks\n", stop);
infinite:
goto infinite;
}
#include <stdio.h>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#define RTCLOK (*(volatile unsigned char*)0x14)
#define RANDOM (*(volatile unsigned char*)0xd20a)
#define SQR(z, n, t) n*n,
const unsigned sqr[] = { BOOST_PP_REPEAT_FROM_TO(0, 128, SQR,) };
int main(void)
{
unsigned i, count = 0;
RTCLOK = 0;
for (i = 0; i < 10000; ++i)
{
unsigned x, y;
x = sqr[RANDOM & 127];
y = sqr[RANDOM & 127];
if (x + y <= 127 * 127)
++count;
}
printf("%u\x1e\x1e\x1e\x1e\xff.\n%u ticks\n", count * 4, RTCLOK);
for (;;);
}
#include <stdio.h>
#define p 10000
#define r 16129
#define RTCLOK1 (*(volatile unsigned char*)0xa1)
#define RTCLOK2 (*(volatile unsigned char*)0xa2)
#define RANDOM (*(volatile unsigned char*)0xd41b)
void main(void)
{
register unsigned int stop, i, x, y;
register unsigned int b = 0;
register unsigned char n;
//SID's Random Number Generator
asm(" lda #$ff"); //maximum frequency value
asm(" sta $D40E"); //voice 3 frequency low byte
asm(" sta $D40F"); //voice 3 frequency high byte
asm(" lda #$80"); //noise waveform, gate bit off
asm(" sta $D412"); //voice 3 control register
n = RTCLOK2;
while (RTCLOK2 == n) { ; }
printf("\nMonte-Carlo PI cc65 V2.18\n");
RTCLOK1 = 0; RTCLOK2 = 0;
for (i = 0 ; i < p; ++i)
{
n = (RANDOM | 128) ^ 128;
x = n * n;
n = (RANDOM | 128) ^ 128;
y = n * n;
if ((x + y) <= r)
++b;
}
b *= 4;
stop = RTCLOK2 + 256 * RTCLOK1;
printf("%u\n%u ticks\n", b, stop);
infinite:
goto infinite;
}
jhusak 9 Jun 2012:
Nie bierz się za atalana. To jest projekt, w którym masochiści piszą:)rudla 11 Jun 2012:
About Atalan:10 REM * SCREEN-FILL BENCHMARK
11 GRAPHICS 24
12 POKE 19,0:POKE 20,0
13 SCREEN=PEEK(88)+256*PEEK(89)
14 FOR I=0 TO 31
15 FOR J=0 TO 239
16 POKE SCREEN+J,255
17 NEXT J
18 SCREEN=SCREEN+240
19 NEXT I
20 TIME=PEEK(20)+256*PEEK(19)
21 GRAPHICS 0
22 PRINT TIME;" JIFFIES"
BYTE RTCLOCK=20, ; addr of sys timer
SAVMSCL=88, ; lsb of screen addr
SAVMSCH=89, ; msb
I,J,TIME ; declare variables
CARD SCREEN
PROC BENCH()
GRAPHICS(24)
RTCLOCK=0
SCREEN=SAVMSCL+256*SAVMSCH
FOR I=0 TO 31
DO
FOR J=0 TO 239
DO
POKE(SCREEN+J,255)
OD
SCREEN==+240
OD
TIME=RTCLOCK
GRAPHICS(0)
PRINTF("%E %U JIFFIES",TIME)
RETURN
schess1 = $3000
schess2 = $4000
stext = $5000
RTCLOCK = $14
org $2000
mwa #dl8 $230 ;Set Display List pointer
mva #0 RTCLOCK
lda #$ff
ldx #$1f
ldy #0
loop sta schess1,y
iny
bne loop
inc loop+2
dex
bne loop
mva RTCLOCK stext
mva #$ff $2fc
anykey cmp $2fc
beq anykey
mwa #dl0 $230 ;Set Display List pointerb
jmp * ;End
.local dl8
.byte $70,$70 ;2x8 empty scanlines
.byte $4f,a(schess1)
:94 .byte $0f
.byte $4f,a(schess2)
:92 .byte $0f
.byte $41,a(dl8) ;Wait VBL, jump DL
.endl
.local dl0
.byte $70,$70 ;2x8 empty scanlines
.byte $42,a(stext)
.byte $02
.byte $41,a(dl0) ;Wait VBL, jump DL
.endl
ilmenit:
Z testów, które były zrobione dla mnie aktualnie najlepszy jest ten "fake sieve", ponieważ ma wiele różnych rzeczy (dużą tablicę, mnożenie *3, operacje na typach word, wiele różnych zmiennych używanych jednocześnie).prime = i*2 + 3; //CC65
prime := i shl 1 + 3; //MadP
; Monte-Carlo PI in MADS
org $2000
.var time .word
.var i,b,radius,x,y,result .word = $80
.var fac1,fac2 .byte = $e0
mwa #16129 radius
mwa #0 i
mwa #0 b
wait
mwa #0 $13
loop #while .word i < #10000
inw i
lda $d20a
and #$7f
sta fac1
sta fac2
multi
mwa result x
lda $d20a
and #$7f
sta fac1
sta fac2
multi
mwa result y
adw x y
sbw x radius
bcs loop
inw b
#end
mva #0 x
lda b+1
sta fac1
lda #4
sta fac2
multi
mva result x+1
lda b
sta fac1
lda #4
sta fac2
multi
mwa result y
adw x y
mva $14 time
mva $13 time+1
jsr printf
.by 'pi %',$1e,$1e,$1e,$1e,$ff,$2c,$9b
.by 'fps % ',$9b,0
dta a(x)
dta a(time)
jmp *
.proc wait
lda:cmp:req $14
rts
.endp
.proc multi
lda #$00
ldx #$08
clc
m0 bcc m1
clc
adc fac2
m1 ror
ror fac1
dex
bpl m0
ldx fac1
stx result
sta result+1
rts
.endp
.link 'printf.obx'
sbw radius n z
bcc loop
inw b
sbw n radius
bcs loop
inw b
/*
;
; Ullrich von Bassewitz, 2009-08-17
;
; CC65 runtime: 8x8 => 16 unsigned multiplication
;
*/
.proc imulCL
ptr1 = ecx
ptr4 = eax
ldy #8
lda #0
lsr ptr4 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptr1
@L1: ror @
ror ptr4
dey
bne @L0
sta ptr4+1
rts
.endp
org $2000
.var time .word
.var i,b,radius,x,y,result .word = $80
.var fac1,fac2 .byte = $e0
mwa #16129 radius
mwa #0 i
mwa #0 b
wait
mwa #0 $13
loop #while .word i < #10000
inw i
lda $d20a
and #$7f
sta fac1
sta fac2
imulCL
mwa result x
lda $d20a
and #$7f
sta fac1
sta fac2
imulCL
mwa result y
adw x y
sbw x radius
bcs loop
inw b
#end
mva #0 x
lda b+1
sta fac1
lda #4
sta fac2
imulCL
mva result x+1
lda b
sta fac1
lda #4
sta fac2
imulCL
mwa result y
adw x y
mva $14 time
mva $13 time+1
jsr printf
.by 'pi %',$1e,$1e,$1e,$1e,$ff,$2c,$9b
.by 'fps % ',$9b,0
dta a(x)
dta a(time)
jmp *
.proc wait
lda:cmp:req $14
rts
.endp
.proc multi
lda #$00
ldx #$08
clc
m0 bcc m1
clc
adc fac2
m1 ror
ror fac1
dex
bpl m0
ldx fac1
stx result
sta result+1
rts
.endp
.proc imulCL
ldy #8
lda #0
lsr fac1 ; Get first bit into carry
@L0: bcc @L1
clc
adc fac2
@L1: ror @
ror fac1
dey
bne @L0
sta fac2
sta result+1
lda fac1
sta result
rts
.endp
.link 'printf.obx'
org $2000
.var time .word
.var i,b,radius,x,y .word = $80
.var fac1,fac2 .byte = $e0
.var result .word =$e0
mwa #16129 radius
mwa #0 i
mwa #0 b
wait
mwa #0 $13
loop #while .word i < #10000
inw i
lda $d20a
and #$7f
sta fac1
sta fac2
imulCL
mwa result x
lda $d20a
and #$7f
sta fac1
sta fac2
imulCL
mwa result y
adw x y
sbw x radius
bcs loop
inw b
#end
mva #0 x
lda b+1
sta fac1
lda #4
sta fac2
imulCL
mva result x+1
lda b
sta fac1
lda #4
sta fac2
imulCL
adw x result
mva $14 time
mva $13 time+1
jsr printf
.by 'pi %',$1e,$1e,$1e,$1e,$ff,$2c,$9b
.by 'fps % ',$9b,0
dta a(x)
dta a(time)
jmp *
.proc wait
lda:cmp:req $14
rts
.endp
.proc imulCL
ldy #8
lda #0
lsr fac1 ; Get first bit into carry
@L0: bcc @L1
clc
adc fac2
@L1: ror @
ror fac1
dey
bne @L0
sta fac2
rts
.endp
.link 'printf.obx'
org $2000
.var i,a,b .word = $80
mwa #0 a
mwa #0 b
mwa #0 i
wait
mva #0 $14
loop inw a
mwa a b
inw b
mwa b a
inw i
lda $14
cmp #100
bne loop
jsr printf
.by '% iterations',$9b,0
dta a(i)
jmp *
.proc wait
lda:cmp:req $14
rts
.endp
.link 'printf.obx'