2026-01-12 19:03:49 +01:00
|
|
|
import stdlib.sl
|
|
|
|
|
import float.sl
|
2025-12-20 22:34:27 +01:00
|
|
|
|
|
|
|
|
# C-style externs (auto ABI handling)
|
|
|
|
|
extern long labs(long n)
|
|
|
|
|
extern void exit(int status)
|
2026-01-12 19:03:49 +01:00
|
|
|
extern double atan2(double y, double x)
|
2025-12-20 22:34:27 +01:00
|
|
|
|
2026-01-08 15:28:10 +01:00
|
|
|
word main
|
2025-12-20 22:34:27 +01:00
|
|
|
# Test C-style extern with implicit ABI handling
|
|
|
|
|
-10 labs puti cr
|
2026-01-12 19:03:49 +01:00
|
|
|
|
2026-02-16 14:32:13 +01:00
|
|
|
# Basic math (scaled to avoid libc printf dependency)
|
|
|
|
|
1.5 2.5 f+ # 4.0
|
|
|
|
|
1000000.0 f*
|
|
|
|
|
float>int puti cr # Prints 4000000 (6 decimal places of 4.0)
|
|
|
|
|
|
2026-01-12 19:03:49 +01:00
|
|
|
# External math library (libm)
|
|
|
|
|
10.0 10.0 atan2 # Result is pi/4
|
2026-02-16 14:32:13 +01:00
|
|
|
4.0 f* # Approx pi
|
|
|
|
|
1000000.0 f*
|
|
|
|
|
float>int puti cr # Prints scaled pi value
|
2026-01-12 19:03:49 +01:00
|
|
|
|
2025-12-20 22:34:27 +01:00
|
|
|
# Test extern void
|
|
|
|
|
0 exit
|
2026-01-08 15:28:10 +01:00
|
|
|
end
|