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