Add greeter example
This commit is contained in:
parent
de92f53f89
commit
86b642ba25
91
examples/greet.mas
Normal file
91
examples/greet.mas
Normal file
@ -0,0 +1,91 @@
|
||||
org 100
|
||||
|
||||
one, hex 1
|
||||
newline, hex 0A
|
||||
exclamation, chr !
|
||||
|
||||
questionCounter, adr question
|
||||
question, chr W
|
||||
chr h
|
||||
chr a
|
||||
chr t
|
||||
hex 20
|
||||
chr i
|
||||
chr s
|
||||
hex 20
|
||||
chr y
|
||||
chr o
|
||||
chr u
|
||||
chr r
|
||||
hex 20
|
||||
chr n
|
||||
chr a
|
||||
chr m
|
||||
chr e
|
||||
chr ?
|
||||
hex 0A
|
||||
hex 00
|
||||
|
||||
greetingCounter, adr greeting
|
||||
greeting, chr H
|
||||
chr e
|
||||
chr l
|
||||
chr l
|
||||
chr o
|
||||
chr ,
|
||||
hex 20
|
||||
hex 00
|
||||
|
||||
responseCounter, hex 0
|
||||
|
||||
// ask the user their name
|
||||
askLoopStart, loadi questionCounter
|
||||
skipcond 800
|
||||
jump askLoopEnd
|
||||
output
|
||||
load questionCounter
|
||||
add one
|
||||
store questionCounter
|
||||
jump askLoopStart
|
||||
askLoopEnd, clear
|
||||
|
||||
// read in their response until newline
|
||||
readLoopStart, input
|
||||
storei responseCounter
|
||||
|
||||
subt newline
|
||||
skipcond 800
|
||||
jump readLoopEnd
|
||||
|
||||
load responseCounter
|
||||
add one
|
||||
store responseCounter
|
||||
|
||||
jump readLoopStart
|
||||
readLoopEnd, clear
|
||||
|
||||
// greet the user
|
||||
greetLoopStart, loadi greetingCounter
|
||||
skipcond 800
|
||||
jump greetLoopEnd
|
||||
output
|
||||
load greetingCounter
|
||||
add one
|
||||
store greetingCounter
|
||||
jump greetLoopStart
|
||||
greetLoopEnd, clear
|
||||
|
||||
// play back response
|
||||
clear
|
||||
store responseCounter
|
||||
playbackLoopStart, loadi responseCounter
|
||||
skipcond 800
|
||||
jump playbackLoopEnd
|
||||
output
|
||||
load responseCounter
|
||||
add one
|
||||
store responseCounter
|
||||
jump playbackLoopStart
|
||||
playbackLoopEnd, clear
|
||||
|
||||
halt
|
Loading…
Reference in New Issue
Block a user