prog8/python/testsource/floats.ill

149 lines
3.4 KiB
Plaintext
Raw Normal View History

2017-12-21 13:52:30 +00:00
; floating point tests
2018-01-12 22:25:00 +00:00
%output basic
2017-12-21 13:52:30 +00:00
2018-01-03 20:43:19 +00:00
%import c64lib
2017-12-21 13:52:30 +00:00
~ main_testing {
2018-01-03 20:43:19 +00:00
start:
2018-08-06 01:35:43 +00:00
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 str myfloatstr = "1234.998877"
var float myfloatzero = 0
var float myfloatsmall1 = 1.234
var float myfloatsmall2 = 2.6677
2017-12-21 13:52:30 +00:00
return
}
~ main {
2018-08-06 01:35:43 +00:00
byte bbvar
float@
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
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
2018-01-03 20:43:19 +00:00
start:
2017-12-23 13:36:23 +00:00
; assign some float values to the memory
2018-01-05 21:52:23 +00:00
AY = &flt_pi
some_address = & flt_pi
2017-12-24 23:15:04 +00:00
some_address = 4123.2342342222
2018-01-05 21:52:23 +00:00
[$c000.word] = & flt_pi
2017-12-21 13:52:30 +00:00
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
2018-01-05 21:52:23 +00:00
printflt(&flt_pi)
printflt(&c64.FL_PIVAL)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_minus32768)
printflt(&c64.FL_N32768)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_1)
printflt(&c64.FL_FONE)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_half_sqr2)
printflt( & c64.FL_SQRHLF)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_sqr2)
printflt(&c64.FL_SQRTWO)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_minus_half)
printflt(&c64.FL_NEGHLF)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_log_2)
printflt(&c64.FL_LOG2)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_10)
printflt(&c64.FL_TENC)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_1e9)
printflt(&c64.FL_NZMIL)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_half)
printflt(&c64.FL_FHALF)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_one_over_log_2)
printflt(&c64.FL_LOGEB2)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_half_pi)
printflt(&c64.FL_PIHALF)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(&flt_double_pi)
printflt(&c64.FL_TWOPI)
2017-12-25 02:42:20 +00:00
2018-01-05 21:52:23 +00:00
printflt(& flt_point25)
printflt(&c64.FL_FR4)
2017-12-21 13:52:30 +00:00
2018-01-03 20:43:19 +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
2018-01-05 21:52:23 +00:00
printflt(&my_float)
my_float = X
2018-01-05 21:52:23 +00:00
printflt(&my_float)
my_float = Y
2018-01-05 21:52:23 +00:00
printflt(&my_float)
2017-12-25 01:29:14 +00:00
XY = 11122
my_float = XY
2018-01-05 21:52:23 +00:00
printflt(&my_float)
2017-12-25 01:29:14 +00:00
AX = 33344
my_float = AX
2018-01-05 21:52:23 +00:00
printflt(&my_float)
2017-12-25 01:29:14 +00:00
AY = 55566
my_float = AY
2018-01-05 21:52:23 +00:00
printflt(&my_float)
2017-12-21 13:52:30 +00:00
return
}