prog8/testsource/floats.ill

145 lines
3.4 KiB
Plaintext
Raw Normal View History

2017-12-21 13:52:30 +00:00
; floating point tests
2017-12-28 22:03:59 +00:00
output prg, basic
2017-12-21 13:52:30 +00:00
import "c64lib"
~ main_testing {
start
var .float myfloat1 = 1234.56789
var .float myfloat2 = 9876.54321
var .float myfloatneg1 = -555.666
var .float myfloat_large1 = 987654.1111
var .float myfloat_large2 = -123456.2222
var .text myfloatstr = "1234.998877"
var .float myfloatzero = 0
var .float myfloatsmall1 = 1.234
var .float myfloatsmall2 = 2.6677
return
}
~ main {
var .float flt_pi = 3.141592653589793
var .float flt_minus32768 = -32768
var .float flt_1 = 1
var .float flt_half_sqr2 = 0.7071067811865476
var .float flt_sqr2 = 1.4142135623730951
var .float flt_minus_half = -.5
var .float flt_log_2 = 0.6931471805599453
var .float flt_10 = 10
var .float flt_1e9 = 1000000000
var .float flt_half = .5
var .float flt_one_over_log_2 = 1.4426950408889634
var .float flt_half_pi = 1.5707963267948966
var .float flt_double_pi = 6.283185307179586
var .float flt_point25 = .25
2017-12-24 23:15:04 +00:00
var .float my_float
2017-12-21 13:52:30 +00:00
memory .word some_address = $ccdd
memory .byte some_addressb = $ccee
2017-12-24 23:15:04 +00:00
var .byte bytevar = $cc
var .word wordvar = $cdef
2017-12-21 13:52:30 +00:00
2017-12-30 20:36:42 +00:00
sub printflt (float: AY) -> (?) {
2017-12-25 02:42:20 +00:00
c64.MOVFM!(AY)
2017-12-27 11:39:19 +00:00
goto c64.FPRINTLN
2017-12-25 02:42:20 +00:00
; c64.FOUT!()
2017-12-31 02:19:06 +00:00
; c64scr.print_string!(AY)
2017-12-27 11:39:19 +00:00
;goto c64.CHROUT('\n')
2017-12-25 02:42:20 +00:00
}
2017-12-21 13:52:30 +00:00
start
2017-12-23 13:36:23 +00:00
; assign some float values to the memory
2017-12-21 13:52:30 +00:00
AY = #flt_pi
2017-12-24 23:15:04 +00:00
some_address = # flt_pi
some_address = 4123.2342342222
2017-12-21 13:52:30 +00:00
[$c000.word] = # flt_pi
2018-01-01 16:56:55 +00:00
my_float ++
my_float += 1
my_float += 0.5
my_float += 999.222
my_float --
my_float -= 1
my_float -= 0.5
my_float -= 999.222
2017-12-23 13:36:23 +00:00
; print some floating points from source and compare them with ROM
2017-12-25 02:42:20 +00:00
printflt(#flt_pi)
printflt(#c64.FL_PIVAL)
printflt(#flt_minus32768)
printflt(#c64.FL_N32768)
printflt(#flt_1)
printflt(#c64.FL_FONE)
printflt(#flt_half_sqr2)
printflt( # c64.FL_SQRHLF)
printflt(#flt_sqr2)
printflt(#c64.FL_SQRTWO)
printflt(#flt_minus_half)
printflt(#c64.FL_NEGHLF)
printflt(#flt_log_2)
printflt(#c64.FL_LOG2)
printflt(#flt_10)
printflt(#c64.FL_TENC)
printflt(#flt_1e9)
printflt(#c64.FL_NZMIL)
printflt(#flt_half)
printflt(#c64.FL_FHALF)
printflt(#flt_one_over_log_2)
printflt(#c64.FL_LOGEB2)
printflt(#flt_half_pi)
printflt(#c64.FL_PIHALF)
printflt(#flt_double_pi)
printflt(#c64.FL_TWOPI)
printflt(# flt_point25)
printflt(#c64.FL_FR4)
2017-12-21 13:52:30 +00:00
reg_to_float
2017-12-25 01:29:14 +00:00
c64.CHROUT!('\n')
2017-12-25 01:29:14 +00:00
A=33
X=44
Y=55
my_float = A
2017-12-25 02:42:20 +00:00
printflt(#my_float)
my_float = X
2017-12-25 02:42:20 +00:00
printflt(#my_float)
my_float = Y
2017-12-25 02:42:20 +00:00
printflt(#my_float)
2017-12-25 01:29:14 +00:00
XY = 11122
my_float = XY
2017-12-25 02:42:20 +00:00
printflt(#my_float)
2017-12-25 01:29:14 +00:00
AX = 33344
my_float = AX
2017-12-25 02:42:20 +00:00
printflt(#my_float)
2017-12-25 01:29:14 +00:00
AY = 55566
my_float = AY
2017-12-25 02:42:20 +00:00
printflt(#my_float)
2017-12-21 13:52:30 +00:00
return
}