mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
145 lines
3.4 KiB
Plaintext
145 lines
3.4 KiB
Plaintext
; floating point tests
|
|
|
|
%output prg, basic
|
|
|
|
%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
|
|
var .float my_float
|
|
memory .word some_address = $ccdd
|
|
memory .byte some_addressb = $ccee
|
|
var .byte bytevar = $cc
|
|
var .word wordvar = $cdef
|
|
|
|
|
|
sub printflt (float: AY) -> (?) {
|
|
c64.MOVFM!(AY)
|
|
goto c64.FPRINTLN
|
|
; c64.FOUT!()
|
|
; c64scr.print_string!(AY)
|
|
;goto c64.CHROUT('\n')
|
|
}
|
|
|
|
|
|
start:
|
|
; assign some float values to the memory
|
|
AY = &flt_pi
|
|
some_address = & flt_pi
|
|
some_address = 4123.2342342222
|
|
[$c000.word] = & flt_pi
|
|
|
|
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
|
|
|
|
; print some floating points from source and compare them with ROM
|
|
|
|
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)
|
|
|
|
reg_to_float:
|
|
c64.CHROUT!('\n')
|
|
|
|
A=33
|
|
X=44
|
|
Y=55
|
|
|
|
my_float = A
|
|
printflt(&my_float)
|
|
|
|
my_float = X
|
|
printflt(&my_float)
|
|
|
|
my_float = Y
|
|
printflt(&my_float)
|
|
|
|
XY = 11122
|
|
my_float = XY
|
|
printflt(&my_float)
|
|
|
|
AX = 33344
|
|
my_float = AX
|
|
printflt(&my_float)
|
|
|
|
AY = 55566
|
|
my_float = AY
|
|
printflt(&my_float)
|
|
|
|
return
|
|
}
|