25 lines
343 B
Plaintext
Raw Normal View History

2024-07-26 12:50:47 +02:00
import mem
import sys
2024-07-26 16:19:13 +02:00
number(x) {
2024-07-26 12:50:47 +02:00
length := 20
buffer := mem.alloc(length)
2024-07-31 13:37:46 +02:00
tmp := itoa(x, buffer, length)
sys.write(1, tmp, buffer + length - tmp)
2024-07-30 20:02:55 +02:00
mem.free(buffer, length)
}
itoa(x, buffer, length) {
2024-08-05 10:54:18 +02:00
tmp := buffer + length
2024-07-26 12:50:47 +02:00
digit := 0
loop {
x, digit = x / 10
tmp -= 1
tmp[0] = '0' + digit
if x == 0 {
2024-07-31 13:37:46 +02:00
return tmp
2024-07-26 12:50:47 +02:00
}
}
}