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 # get the user's number 01 call r14 10 # set register r14 to 02, then jump to line 10 02 sub r12 r1 r13 # r12 equals r1 minus r13 03 jeqz r12 06 # if r12 equals 0, jump to line 06 04 setn r7 0 # set r7 to 0 05 jumpn 07 # jump to line 07 06 setn r7 1 # set r7 equal to 1 07 write r13 # print the value of r13 08 write r7 # print the value of r7 09 halt # halt the program 10 setn r2 2 # begins loop; set r2 to 2 11 copy r13 r1 # copy the value of r1 to r13

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture