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

25 lines
609 B

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