29 lines
		
	
	
		
			795 B
		
	
	
	
		
			Common Lisp
		
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			795 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
 | |
| 		(call &pln ($0 $1) nil)
 | |
| 
 | |
| 		(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
 | |
| 
 | |
| 		(call &pln ($0 $4) nil) ; print the string
 | |
| 		(halt))
 | |
|   	(label pln 
 | |
| 		(load-immediate $3 &new-line)
 | |
|     	(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 nil)))
 | |
| (data 
 | |
| 	(label terminal-namespace "/dev/term/0")
 | |
|     (label help "Enter a string: ")
 | |
| 	(label new-line "\n")))
 |