ps5pr8.txt - ps5pr8(Problem Set 5 Problem 8 Using a...

This preview shows page 1 out of 1 page.

# # ps5pr8.txt (Problem Set 5, Problem 8) # # Using a function and a loop to determine if a number is prime # 00 read r1 # read input from user 01 call r14 10 # function call to line 10 02 sub r12 r9 r1 # subtracts r1 from r9 and stores to r12 03 jeqz r12 6 # jumps to line 6 if r12 == 0 04 setn r5 0 # set r5 == 0 05 jumpn 7 # unconditional jump to line 7 06 setn r5 1 # set r5 ==1 07 write r9 # prints r9 08 write r5 # prints r5 09 halt # halts program 10 setn r3 2 # sets r3 == 2 11 div r4 r1 r3

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture