function main () real a is $0 int i is $1 int mode is $11 str term is $10 load_immediate 5.0 -> a load_immediate 5000 -> i load_immediate 0 -> $2 load_immediate -1 -> $3 load_immediate 5.0 -> $5 &loop_body add_real a $5 -> a add_int i $3 -> i jump_ge_int &loop_body i $2 load_heap_immediate "/dev/term/0" -> term load_immediate 0 -> mode syscall OPEN term mode -> term # Terminal term = open("/dev/term/0", 0); nat b is $1 real_to_nat a -> b load_heap_immediate "Enter a string:" -> $7 string_length $7 -> $8 syscall WRITE term $7 $8 # print prompt str user_string is $9 load_immediate 32 -> $8 malloc $8 -> user_string syscall READ term user_string $8 # read in max 32 byte string call pln user_string nat_to_string b -> $4 call pln $4 real_to_string a -> $3 call pln $3 exit 0 function pln (str message is $0) str ts is $1 int mode is $5 int msg_length is $2 str nl is $3 int nl_length is $4 load_heap_immediate "/dev/term/0" -> ts load_immediate 0 -> mode syscall OPEN ts mode -> ts # get terminal device strlen message -> msg_length syscall WRITE ts message msg_length load_heap_immediate "\n" -> nl strlen nl -> nl_length syscall WRITE ts nl nl_length return