acme/examples/trigono.a

37 lines
1.1 KiB
Plaintext
Raw Normal View History

;ACME 0.94.12
;!to "trigono.o", plain
* = $c000
PI = 3.14159265358979323846
!raw "cos[0,pi/2] scaled to 0-255 range"
!align $f, 0, 0 ; make output file look better in hex editor :)
!for x, 0, 255 {
!byte cos(float(x) / 255 * PI/2) * 255 + 0.5
}
; "float()" makes sure this calculation is done in float mode now
; "/255*half_PI" converts interval [0,255] to interval [0,PI/2]
; "cos()" returns cosine. Wow.
; "*255" converts interval [0,1] to interval [0,255]
; "+0.5" ensures correct rounding to integer
!align $f, 0, 0
!raw "sin[-pi/2,pi/2] scaled to full range of 16b.16b fixed point"
!align $f, 0, 0
!for x, 0, 1023 {
!32 sin(float(x - 512) / 1024 * PI) * 65536 + 0.5
}
;undefined = 0.0 / 0.0 ; throws error when active
;range = arcsin(-10) ; throws error when active
!by 1 / 2 * 2 ; should give 0
!by 1 / 2 * 2.0 ; should give 0
!by 1 / 2.0 * 2 ; should give 1
!by 1 / 2.0 * 2.0 ; should give 1
!by 1.0 / 2 * 2 ; should give 1
!by 1.0 / 2 * 2.0 ; should give 1
!by 1.0 / 2.0 * 2 ; should give 1
!by 1.0 / 2.0 * 2.0 ; should give 1