Debian Codegraph @

examples/trigono.a

raw
1 ;ACME 0.94.12
2 ;!to "trigono.o", plain
3 * = $c000
4
5 PI = 3.14159265358979323846
6
7 !raw "cos[0,pi/2] scaled to 0-255 range"
8 !align $f, 0, 0 ; make output file look better in hex editor :)
9
10 !for x, 0, 255 {
11 !byte cos(float(x) / 255 * PI/2) * 255 + 0.5
12 }
13 ; "float()" makes sure this calculation is done in float mode now
14 ; "/255*half_PI" converts interval [0,255] to interval [0,PI/2]
15 ; "cos()" returns cosine. Wow.
16 ; "*255" converts interval [0,1] to interval [0,255]
17 ; "+0.5" ensures correct rounding to integer
18
19 !align $f, 0, 0
20 !raw "sin[-pi/2,pi/2] scaled to full range of 16b.16b fixed point"
21 !align $f, 0, 0
22
23 !for x, 0, 1023 {
24 !32 sin(float(x - 512) / 1024 * PI) * 65536 + 0.5
25 }
26
27 ;undefined = 0.0 / 0.0 ; throws error when active
28 ;range = arcsin(-10) ; throws error when active
29 !by 1 / 2 * 2 ; should give 0
30 !by 1 / 2 * 2.0 ; should give 0
31 !by 1 / 2.0 * 2 ; should give 1
32 !by 1 / 2.0 * 2.0 ; should give 1
33 !by 1.0 / 2 * 2 ; should give 1
34 !by 1.0 / 2 * 2.0 ; should give 1
35 !by 1.0 / 2.0 * 2 ; should give 1
36 !by 1.0 / 2.0 * 2.0 ; should give 1