Croissant Runtime
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.
crsn/examples/stdio.csn

28 lines
705 B

4 years ago
(
; we don't have strings yet 👌
(ld @stdout 'P') (ld @stdout 'r') (ld @stdout 'e') (ld @stdout 's') (ld @stdout 's') (ld @stdout ' ')
(ld @stdout 'q') (ld @stdout ' ')
(ld @stdout 't') (ld @stdout 'o') (ld @stdout ' ')
(ld @stdout 'q') (ld @stdout 'u') (ld @stdout 'i') (ld @stdout 't')
(ld @stdout '…') (ld @stdout ' ')
4 years ago
(:loop)
(ld r0 @stdin)
; exit by pressing 'q'
(cmp r0 'q'
(=? (ld @stdout '\n')
(halt)))
; uppercase ASCII
4 years ago
(cmp r0 'a' (<? (j :badchar)))
(cmp r0 'z' (>? (j :badchar)))
(sub r0 ' ')
4 years ago
(ld @stdout r0)
(j :loop)
4 years ago
(:badchar)
(ld @stdout '🐈') ; show a kitty if not ASCII
4 years ago
(j :loop)
)