Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

MIPS Subroutine for Greatest Common Divisor (GCD) with Test Data, Assignments of Computer Architecture and Organization

Instructions for creating a mips subroutine named gcd that computes the greatest common divisor (gcd) of two integers. The document also includes a test main program that uses the gcd subroutine on 20 pairs of numbers. Students are required to write the subroutine and test program as an assignment for the cda 3101 course.

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-02i
koofers-user-02i 🇺🇸

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download MIPS Subroutine for Greatest Common Divisor (GCD) with Test Data and more Assignments Computer Architecture and Organization in PDF only on Docsity! CDA 3101: HW 3 assignment Assigned Fri. Sept. 16, due in class on Friday, Sept. 23 All problems are from the textbook unless otherwise specified. Turn hardcopy in class, stapled, with your name and ”CDA 3101 Home- work 3” clearly printed on it. For programs, submit a printout with your hardcopy, in class, AND submit the program electronically, via CourseTool. See the class web page for details. You must use CourseTool; you cannot submit your homeworks over email. Zip or tar all programs into a single archive file, so that when we uncompress it we get one file for each program. 1. Problem 2.37 2. Problem 2.15 3. Write a MIPS subroutine gcd(a,b) that computes the greatest com- mon divisor of two integers a and b. Also write a test main program that tries gcd on 20 pairs of numbers. Use this test data (don’t type it in, you can find the raw data on the class web page): 794 956 522 880 172 979 271 252 875 737 136 11 893 199 298 661 284 469 64 988 439 340 314 365 393 591 119 38 458 869 934 264 160 872 237 645 966 664 870 9 That is, try gcd(794,439) which is 1, then try gcd(956,340) which is 4, etc. The answer you get should be: 1 4 2 5 1 1 1 2 1 11 2 11 1 1 1 1 2 1 2 1 Use the .word directive to store an array A and B, and an array of results x. Then call gcd(A(i),B(i)) and check your result with X(i). The pseudo-code for the gcd algorithm is as follows. It should not know anything about the 3 arrays A, B, and X. It should just take in two scalars and return one scalar. Be sure to use the proper MIPS subroutine interface. 1
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved