


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Spring 2012 (Morrow) 1
1. (10 points) Branches versus Conditional Execution Consider the operations described by if ((R1) is less than (R0)) begin (R2) 2 ’s-complement of (R0) (R3) (R1) * 17 end else if ((R1) was greater than (R0)) begin (R2) 0xDEADBEEF; (R3) (R1) * 0. end else begin (R2) (R0) 2 (R3) 1’s-complement of (R1) end Note that the begin/end pairs demarcate the code that is conditioned on the preceding if/else. Write two code fragments efficiently implementing the behavior. The first one is required to use unconditional instructions except branches may be conditional. The second can use conditional instructions, but no branches at all. Assume that R1 and R0 have signed values in the conditions and calculations. Do not use any load instructions or pseudo-instructions in either code fragment. Submit your source code, and answer the following questions. A. What are the relative advantages/disadvantages of the two approaches? B. What sorts of the situations would clearly favor one or the other approach. Although you are only submitting these code fragments, it would be prudent for you to incorporate them into a complete program so you can assemble and test your code. 2. (10 points) Assembly Language Coding
Write code fragments that efficiently perform the following operations.
Spring 2012 (Morrow) 2
3. (10 points) Assembly Language Coding
You are to write a subroutine named umax (in a file named teamX_umax.s ) that will determine the maximum value of a variable number of unsigned byte elements. Your subroutine will be passed parameters as listed in the header below;
; Name: umax ; Description: Finds the maximum value in a variable length data ; structure. The starting address of the data structure ; is contained in R1. The first word of the structure ; is the unsigned number of elements in the structure, ; followed by the data. Each data element is an unsigned ; byte. ; The number of elements may be 0. In that case, return ; the largest possible unsigned byte value. ; Assumes: R1 = starting address of the data structure ; Returns: R0 = maximum value found ; Modifies: None imin
Your subroutine may not disturb any of the caller’s registers. You will want to write a driver program in main.s that tests your subroutine – that’s how we’ll test it. Be sure to EXPORT your subroutine name. A sample of how the data structure should be defined is shown below.
MyStruct DCD 3 DCB 1, 3, 2
Important: Submit ONLY your source code file teamX_umax.s using the dropbox in Learn@UW. Also, submit a paper copy of teamX_umax.s with the rest of the assignment.
4. (15 points) Implementing the strrchr() function with a stack frame Write a subroutine that functions like the C language strrchr function – one online reference is
http://www.cplusplus.com/reference/clibrary/cstring/strrchr/. Your subroutine will search an
ACIIZ string (starting at the end) for the first instance of a given character. If an instance of the given character is found in the string, return the address of that instance in R0. If no instance is found, return null (0) in R0. The string could be zero-length, in that case return null in R0.
You are to write a subroutine named strrchr (in a file named teamX_strrchr.s ) that implements the strrchr function. Your subroutine will use stack passing for the arguments, with the assumption that they were pushed in right-to-left order (generally the C convention). This means that the target character is pushed first (as a word! – all stack parameters are pushed as words), and str ’s address is pushed last. Set up a standard stack frame in your subroutine to access the parameters. In the subroutine, you must assume that the passed string address is in fact pointing to a properly terminated ASCIIZ string.
You may not disturb any of the caller’s registers except R0. You will want to write a driver program in main.s that tests your subroutine with a reasonable number of test cases – that’s how we’ll test it. Be sure to EXPORT your subroutine name. Your code should be reasonably
Spring 2012 (Morrow) 4
6. (5 points) ARM7TDMI Stack Initialization
Review the initialization code in the file aduc7026.s in the sample uVision3 project.
Any Fibonacci number can be calculated as F(n) = F(n-1) + F(n-2) for n ≥ 2, with F(0) and F(1) defined as 0 and 1, respectively. You must perform this calculation recursively for an arbitrary n. Your procedure will use stack parameter passing and have an interface as follows: Subroutine name: fibonacci Input parameters: n - single unsigned word on stack Return: R0 = F(n) Terminate the recursion when the input parameter is 1or 0. Place your subroutine source code in a file named teamX_fib.s. Your subroutine may not modify any of the caller’s registers, and may not use any memory variables. Do not declare or use a data area in your teamX_fib.s file. Do not place any other code in this file; place your driver code for testing your subroutine in a separate file that is not submitted. Be sure to EXPORT your subroutine name. We will use a separate driver file that links to your subroutine to completely test it and verify its accuracy – you should do the same before submitting your work.
Your code should be reasonably efficient – the intent is not to have a provably minimal implementation, but deductions will be made for significant inefficiencies.
Important: Submit ONLY your subroutine source code file teamX_fib.s using your homework team’s dropbox in Learn@UW. Also, submit a paper copy of teamX_fib.s with the rest of the assignment.
8. (10 points) Exam Question Design one original quiz question operating at Bloom’s Taxonomy level 3 for any material covered in Module 3. This must test one of the educational objectives (see http://morrow.ece.wisc.edu/ECE353/objectives.pdf) in a specific problem. Explicitly state which particular educational objective you are attempting to test (i.e. paste a copy of the objective into your document). Provide a complete, detailed solution to your question.