Implemented multiple return values
This commit is contained in:
parent
d4020da6d9
commit
42f0367a94
15 changed files with 113 additions and 35 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue