ps5pr9.txt - ps5pr9(Problem Set 5 Problem 9 Calling a distance function twice 00 read r1 get first number from user and store it in r1 01 read r2 get

ps5pr9.txt - ps5pr9(Problem Set 5 Problem 9 Calling a...

This preview shows page 1 out of 1 page.

# # ps5pr9.txt (Problem Set 5, Problem 9) # # Calling a distance function twice # 00 read r1 # get first number from user and store it in r1 01 read r2 # get second number from user and store it in r2 02 read r3 # get third number from user and store it in r3 03 copy r12 r2 # set r12 = r2 04 copy r13 r3 # set r13 = r3 05 call r14 15 # Copy the next address into r14 and then jump to mem. addr. 15 06 copy r5 r4 # set r5 = r4 07 copy r2 r3 # set r2 = r3 08 call r14 15 # Copy the next address into r14 and then jump to mem. addr. 15 09 sub r6 r5 r4 # set r6 = r5 - r4 10 jltz r6 13 # if r6 < 0, jump to line 13 11 write r13 # print the value of r13 12 jumpn 14 # jump to line 14 13 write r12 # print the value of r12 14 halt 15 sub r4 r1 r2 # set r4 = r1 - r2 16 jltz r4 18 # if r4 < 0, jump to line 18 17 jumpr r14 # jump to address in r14 18 neg r4 r4 # set r4 = -r4 19 jumpr r14 # jump to address in r14

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture