CDA3101 Programming Assignment 2
Date assigned : Feb . 6 th , 201 8
Due date : Feb . 14 th , 201 8,, 11::559 pm
A 24 – hour grace period with 20%% penalty is given.. No submission is accepted after the grace period..
Instructions
Transform the following code into MIPS instructions.. Your programs should run correctly on the QtSPIM simulator.. Submit your assembly solution ( project2 .ss ) containing the neatly written//oorganized MIPS code in e – Learning ( Canvas ) website before the deadline..
Important
• Y ou should use comments (‘‘##’’ followed by text)) in order to make your programs more readable..
• The name of the file submitted MUST be “ proje ct2 .ss ”
• You MUST verify that your submission in Canvas is successful by downloading your submissi on from Canvas and successfully testing it again using SPIM simulator.. This will ensure that you uploaded the right file in eLearning and the upload is successful..
Problem Statement
Given three positive integers x,, k and n ( 1 < n < 1000 ) , write a program t o compute [ (xx^^kk)) mod n ] using f ast modular exponentiation . More references about fast modular expo nentiation can be found in the following websites..
https::////ddiscuss..ccodechef..ccom//qquestions//220451//aa – tutorial – on – fast – modulo – multiplication – exponential – squaring
https::////wwww..kkhanacademy..oorg//ccomputing//ccomputer – science//ccryptography//mmodarithmetic//aa//ffast – modular – exponentiation
Your assembly implementation should exactly follow the pseudo code sequence given below . Please do not perform any optimization at pseudo code level or at assembly level..
Note :
You can assume the three input values are 32 – bit integer s . In other words,, the program should work with three inputs whic h are less than or equal to the number that can be represen ted by 32 bits . However,, x to the power of k (xx^^kk)) may exceed 32 bits (ee..gg..,, 2^^1100))..
Tips::
For printing to//rreading from console,, you should first load correct value to register $vv0,, and then call “ syscall”” method.. If there is an input,, the value would be returned in $vv0..