Implemented multiple return values
This commit is contained in:
@ -4,13 +4,14 @@ import sys
|
||||
number(x) {
|
||||
length := 20
|
||||
buffer := mem.alloc(length)
|
||||
tmp := itoa(x, buffer, length)
|
||||
sys.write(1, tmp, buffer + length - tmp)
|
||||
address, count := itoa(x, buffer, length)
|
||||
sys.write(1, address, count)
|
||||
mem.free(buffer, length)
|
||||
}
|
||||
|
||||
itoa(x, buffer, length) {
|
||||
tmp := buffer + length
|
||||
end := buffer + length
|
||||
tmp := end
|
||||
digit := 0
|
||||
|
||||
loop {
|
||||
@ -19,7 +20,7 @@ itoa(x, buffer, length) {
|
||||
tmp[0] = '0' + digit
|
||||
|
||||
if x == 0 {
|
||||
return tmp
|
||||
return tmp, end - tmp
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user