辅导案例-CPEN 211

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CPEN 211 Introduction to Microcomputers, 2017
Lab Proficiency Test #4

 Page  1  of  1  

Question 1 [6 marks; part marks possible]: Create a file named “q1.s” and inside it write ARM
assembly to implement the following function which is written in C. You may assume n is greater
than 10 and less than 20, a[0] is initially 0, and m is greater than 0 but less than 100.

int  func(  int  n,  int  *a,  int  m  )    
{  
   int  result  =  n  -­‐  10;    
   int  numCalls  =  a[0]  +  1;  
   a[0]  =  numCalls;  
   if(  n  <=  100  )  {    
       int  tmp  =  func  (  n  +  11,  a,  m  );  
       result  =  func  (  tmp,  a,  m  );  
   }  
   if(  numCalls  <  m  )  {    
       a[numCalls]  =  result;  
   }  
   return  result;  
}  

Upload your Verilog file named “q1.s” via the “Lab Proficiency Test #4” assignment on
Connect before 6:50 pm as the submission site closes at exactly 6:50 pm. Do NOT “zip” your
submission. The file you upload for this question must be called “q1.s” or the autograder script
will not mark it.

Your solution will get zero if any of the following are true:
1.   Your last “Lab Proficiency Test #4” attempt on Connect does not include “q1.s”,
2.   Your q1.s file does not compile the Altera Monitor Program configured to use the DE1-
SoC Computer or the following emulator: https://cpulator.01xz.net/?sys=arm ,
3.   Your q1.s file does not contain a function called func.

Your mark will be computed using an autograder by running several tests that verify the value
returned by your func function is correct, that your code modifies the array “a” correctly, that
you implement a stack to save and restore registers as per the ARM calling conventions discussed
in class and that your code for func uses recursion.









This test consists of only the above question.

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468