You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
797 B
40 lines
797 B
4 years ago
|
(
|
||
|
; This program asks for a name and prints a greeting
|
||
|
|
||
|
(sym name r7)
|
||
|
|
||
|
(mkbf r0 "Your name: ")
|
||
|
(call prompt r0) (del @r0)
|
||
|
(ld name res0)
|
||
|
|
||
|
(ld @cout '\n')
|
||
|
|
||
|
(mkbf r1 "Hello, ")
|
||
|
(call print r1) (del @r1)
|
||
|
(call print name) (del @name)
|
||
|
(ld @cout '!')
|
||
|
(ld @cout '\n')
|
||
|
(halt)
|
||
|
|
||
|
(proc print buf
|
||
|
(bfsz r1 @buf)
|
||
|
(:next)
|
||
|
(cmp r0 r1 (eq? (ret)))
|
||
|
(bfrd @cout @buf r0)
|
||
|
(inc r0)
|
||
|
(j :next)
|
||
|
)
|
||
|
|
||
|
(proc prompt msg
|
||
|
(call print msg)
|
||
|
(sym dest r7)
|
||
|
(mkbf dest)
|
||
|
(:char)
|
||
|
(ld r0 @cin (eof? (ret dest)))
|
||
|
(cmp r0 '\n' (eq? (ret dest)))
|
||
|
(ld @cout r0)
|
||
|
(bfpush @dest r0)
|
||
|
(j :char)
|
||
|
)
|
||
|
)
|