35 lines
846 B
Common Lisp
35 lines
846 B
Common Lisp
((code
|
|
(label main
|
|
(load-immediate $0 &terminal-namespace) ; get terminal device
|
|
(load-immediate $11 0)
|
|
(syscall OPEN $0 $0 $11)
|
|
|
|
(load-immediate $1 &help) ; print help message
|
|
(push $0)
|
|
(push $1)
|
|
(call &pln)
|
|
|
|
(load-immediate $1 32) ; read in a string of max 32 char length
|
|
(malloc $4 $1) ; allocate memory for the string
|
|
(load-offset-32 $7 $0 4) ; load handle
|
|
(syscall READ $7 $2 $1 $4) ; read the string
|
|
|
|
(push $0)
|
|
(push $4)
|
|
(call &pln) ; print the string
|
|
(halt))
|
|
(label pln
|
|
(load-immediate $3 &new-line)
|
|
(pop $1)
|
|
(pop $0)
|
|
(load-offset-32 $7 $0 4) ; load handle
|
|
(string-length $2 $1)
|
|
(syscall WRITE $7 $1 $2)
|
|
(string-length $4 $3)
|
|
(syscall WRITE $7 $3 $4)
|
|
(return)))
|
|
(data
|
|
(label terminal-namespace "/dev/term/0")
|
|
(label help "Enter a string: ")
|
|
(label new-line "\n")))
|