mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
added some ported bench8 test programs
This commit is contained in:
parent
666d62dd7a
commit
b6eef3612f
@ -1 +1 @@
|
|||||||
8.4-dev
|
8.4
|
||||||
|
@ -120,9 +120,9 @@ class TestC64Zeropage: FunSpec({
|
|||||||
val zp1 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, c64target, 999u))
|
val zp1 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, c64target, 999u))
|
||||||
zp1.availableBytes() shouldBe 18
|
zp1.availableBytes() shouldBe 18
|
||||||
val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), false, false, c64target, 999u))
|
val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), false, false, c64target, 999u))
|
||||||
zp2.availableBytes() shouldBe 92
|
zp2.availableBytes() shouldBe 88
|
||||||
val zp3 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, c64target, 999u))
|
val zp3 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, c64target, 999u))
|
||||||
zp3.availableBytes() shouldBe 102
|
zp3.availableBytes() shouldBe 97
|
||||||
val zp4 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target, 999u))
|
val zp4 = C64Zeropage(CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target, 999u))
|
||||||
zp4.availableBytes() shouldBe 207
|
zp4.availableBytes() shouldBe 207
|
||||||
zp4.allocate(listOf("test"), DataType.UBYTE, null, null, errors)
|
zp4.allocate(listOf("test"), DataType.UBYTE, null, null, errors)
|
||||||
|
@ -3,7 +3,6 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- try more benchmarks from https://gglabs.us/node/2293
|
|
||||||
- check that all examples still function correctly
|
- check that all examples still function correctly
|
||||||
|
|
||||||
...
|
...
|
||||||
|
30
examples/bench8/crc16.p8
Normal file
30
examples/bench8/crc16.p8
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
%import textio
|
||||||
|
|
||||||
|
main {
|
||||||
|
|
||||||
|
sub crc16(uword data, uword length) -> uword {
|
||||||
|
uword crc = 0
|
||||||
|
repeat length {
|
||||||
|
crc ^= @(data) << $0008
|
||||||
|
repeat 8 {
|
||||||
|
if crc & $8000
|
||||||
|
crc = (crc<<1)^$1021
|
||||||
|
else
|
||||||
|
crc<<=1
|
||||||
|
}
|
||||||
|
data++
|
||||||
|
}
|
||||||
|
return crc
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
txt.print("calculating...")
|
||||||
|
c64.SETTIM(0,0,0)
|
||||||
|
uword crc = crc16($e000, $2000)
|
||||||
|
txt.print_uwhex(crc, true) ; should be $ffd0
|
||||||
|
txt.nl()
|
||||||
|
txt.print_uw(c64.RDTIM16())
|
||||||
|
txt.print(" jiffies")
|
||||||
|
sys.wait(100)
|
||||||
|
}
|
||||||
|
}
|
42
examples/bench8/crc32.p8
Normal file
42
examples/bench8/crc32.p8
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
%import textio
|
||||||
|
|
||||||
|
main {
|
||||||
|
sub crc32(uword data, uword length) {
|
||||||
|
; because prog8 doesn't have 32 bits integers, we have to split up the calucation over 2 words.
|
||||||
|
; result in cx16.r0 (high word) and cx1.r1 (low word).
|
||||||
|
cx16.r0 = 0
|
||||||
|
cx16.r1 = 0
|
||||||
|
repeat length {
|
||||||
|
cx16.r0 ^= @(data) << $0008
|
||||||
|
repeat 8 {
|
||||||
|
if cx16.r0 & $8000 {
|
||||||
|
sys.clear_carry()
|
||||||
|
rol(cx16.r1)
|
||||||
|
rol(cx16.r0)
|
||||||
|
cx16.r0 ^= $04c1
|
||||||
|
cx16.r1 ^= $1db7
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sys.clear_carry()
|
||||||
|
rol(cx16.r1)
|
||||||
|
rol(cx16.r0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data++
|
||||||
|
}
|
||||||
|
cx16.r0 ^= $ffff
|
||||||
|
cx16.r1 ^= $ffff
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
txt.print("calculating...")
|
||||||
|
c64.SETTIM(0,0,0)
|
||||||
|
crc32($e000, $2000)
|
||||||
|
txt.print_uwhex(cx16.r0, true)
|
||||||
|
txt.print_uwhex(cx16.r1, false)
|
||||||
|
txt.nl()
|
||||||
|
txt.print_uw(c64.RDTIM16())
|
||||||
|
txt.print(" jiffies")
|
||||||
|
sys.wait(100)
|
||||||
|
}
|
||||||
|
}
|
30
examples/bench8/crc8.p8
Normal file
30
examples/bench8/crc8.p8
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
%import textio
|
||||||
|
|
||||||
|
main {
|
||||||
|
|
||||||
|
sub crc8(uword data, uword length) -> ubyte {
|
||||||
|
ubyte crc = 0
|
||||||
|
repeat length {
|
||||||
|
crc ^= @(data)
|
||||||
|
repeat 8 {
|
||||||
|
if crc & $80
|
||||||
|
crc = (crc<<1)^$1d
|
||||||
|
else
|
||||||
|
crc<<=1
|
||||||
|
}
|
||||||
|
data++
|
||||||
|
}
|
||||||
|
return crc
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
txt.print("calculating...")
|
||||||
|
c64.SETTIM(0,0,0)
|
||||||
|
ubyte crc = crc8($e000, $2000)
|
||||||
|
txt.print_ubhex(crc, true) ; should be $a2
|
||||||
|
txt.nl()
|
||||||
|
txt.print_uw(c64.RDTIM16())
|
||||||
|
txt.print(" jiffies")
|
||||||
|
sys.wait(100)
|
||||||
|
}
|
||||||
|
}
|
42
examples/bench8/pow.p8
Normal file
42
examples/bench8/pow.p8
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
%import textio
|
||||||
|
%import floats
|
||||||
|
|
||||||
|
main {
|
||||||
|
const ubyte N_ITER = 10
|
||||||
|
const ubyte SIZE = 32
|
||||||
|
|
||||||
|
float[SIZE] array = 0.0
|
||||||
|
|
||||||
|
sub testpow(float x, uword y) -> float {
|
||||||
|
float tmp = x
|
||||||
|
if y==0
|
||||||
|
return 1
|
||||||
|
repeat y-1 {
|
||||||
|
tmp *= x
|
||||||
|
}
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
txt.print("calculating...")
|
||||||
|
c64.SETTIM(0,0,0)
|
||||||
|
|
||||||
|
float res
|
||||||
|
uword i
|
||||||
|
ubyte j
|
||||||
|
for i in 0 to N_ITER-1 {
|
||||||
|
for j in 0 to SIZE-1 {
|
||||||
|
array[j] += testpow(2.5/(i+1.0), j)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for j in 0 to SIZE-1 {
|
||||||
|
res += array[j]
|
||||||
|
}
|
||||||
|
|
||||||
|
floats.print_f(res)
|
||||||
|
txt.nl()
|
||||||
|
txt.print_uw(c64.RDTIM16())
|
||||||
|
txt.print(" jiffies")
|
||||||
|
sys.wait(100)
|
||||||
|
}
|
||||||
|
}
|
1
examples/bench8/readme.txt
Normal file
1
examples/bench8/readme.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Contains several benchmarks from https://gglabs.us/node/2293 ported to prog8.
|
Loading…
Reference in New Issue
Block a user