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 # from user and store it in r101 call r14 10# function call to the line number 1002 sub r12 r9 r1# subtract r1 from r9 and store it to r1203 jeqz r12 6 # jump to line 6 if r12 == 004 setn r5 0# set r5 == 005 jumpn 7# unconditional jump to the line 706 setn r5 1 # set r5 == 107 write r9# prints r908 write r5# prints r509 halt# halts program 10 setn r3 2 # sets r3 == 211 div r4 r1 r3# divides r3 from r1 and stores to r4

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture