
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Computer Organization; Subject: Computer Science; University: Columbus State University; Term: Spring 2006;
Typology: Lab Reports
1 / 1
This page cannot be seen from the preview
Don't miss anything!

// Program for CPSC 2105 Lab 04 // Written by Ed Bosworth // Written on Wednesday, April 5, 2006. // Clear Store M // Set the result to zero (really redundant) Input // Get the number for the computation Store N // Put the number into N Skipcond 800 // Skip the next if the input is positive. Jump End // Just quit if the number is not positive. JnS F // Call the function. End, Load M // Function should return value in M Output // Output the result Halt // and quit. N, HEX 0000 M, HEX 0000 One, HEX 0001 F, HEX 0000 L1, Load N // Get N back into the AC Subt One // Subtract 1 to see if N > 1. Skipcond 800 // Skip if N > 1 Jump LE1 // Go here for N <= 1 GT1, Load N Add M Store M // Set M = M + N Load N Subt One Store N // N is decremented JNS F // Recursive call JumpI F LE1, Load One // If N == 1 then the result is 1. Store M JumpI F