Implemented echo example
This commit is contained in:
parent
fcc4f8d2d9
commit
86175d7a53
9 changed files with 70 additions and 58 deletions
18
examples/echo/echo.q
Normal file
18
examples/echo/echo.q
Normal file
|
@ -0,0 +1,18 @@
|
|||
import mem
|
||||
import sys
|
||||
|
||||
main() {
|
||||
length := 4096
|
||||
address := mem.alloc(length)
|
||||
|
||||
loop {
|
||||
n := sys.read(0, address, length)
|
||||
|
||||
if n <= 0 {
|
||||
mem.free(address, length)
|
||||
return
|
||||
}
|
||||
|
||||
sys.write(1, address, n)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue