- May 15, 2020
CS 271 Computer Architecture and Assembly Language
1.Calculate Greatest Common Divisor (GCD) and Least Common Multiple (LCM) for
2.Your GCD and LCM will be evaluated by 20 benchmarks.
◦ Some benchmarks will be provided in the project templates.
◦ The other benchmarks will be hidden.
◦ Data types and values of Benchmarks may change when your code is tested.
1. Designing and implementing GCD and LCM calculator.
2. Apply all skills that you have learned in this course to optimize your code.
3. Optimize a size of codes.
4. Optimize a number of instructions to reduce execution time.
5. Choose a proper algorithm for fast calculations.
6. Consider worst-case scenarios and handle them.
Write a program to calculate Greatest Common Divisor (GCD) and Least Common Multiple
(LCM) for multiple inputs. 20 benchmarks will be provided. 6 benchmarks for 2 inputs, 6
benchmarks for 3 inputs, and 8 benchmarks for 4 inputs. Data types and values of
benchmarks may differ when code is tested. You need to consider worst-case scenarios. Your
code must handle these corner cases. The correctness of implementation has higher priority
than the performance.
1. Find GCD and LCM for the given benchmarks.
2. Measure program execution time by “rdtsc” instructions.
3. Print all the results for each benchmarks.
4. Print the result 0~18,446,744,073,709,551,616 (264)
5. Make one separate module for print_result
6. Consider corner cases and handle them.
GCD and LCM
1. Benchmarks will be 2 Inputs, 3 inputs, and 4 inputs with different types of data (BYTE,
WORD, and DWORD).
2. Integers will be provided.
◦ For negative integers, handle them as positive integers and then calculate GCD and
3. You need to print results for each benchmark up to 64 bits as a decimal.
Conner Case Design
You need to handle corner cases. If your program finds corner cases, print ‘0’ for those
◦ If the result is larger than 64 bits (overflow), print 0.
◦ If benchmarks (inputs) are larger than 32 bits, print 0.
◦ Manage Data type properly. The names of given Benchmarks will not be changed, but data
types and values will be.