DOC PREVIEW
UW-Madison ECE 353 - Homework

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE 353 Introduction to Microprocessor Systems Spring 2008 (Schulte) 1 HOMEWORK ASSIGNMENT #3 Due Friday, March 14th, 2008 Remember to follow the Documentation Standards for all code! Use the sample Keil project as the starting point for all coding questions. 1. (10 points) Implementing Lookup Tables Write code that given a 4-bit input, X, uses a lookup table to compute Y = X4. Assume the value for X is in the memory location pointed to by the contents of R0 and that Y should be stored in the memory location pointed to by the contents of R1. Be sure to limit the value for X to 4 bits to avoid overflowing the table. Your code should allocate memory and initialize memory for the lookup table and for X and Y. Although you are not required to create a complete program, it would be good idea to assemble and test your code. Turn in your code for the lookup table. 2. (10 points) ARM Coding Write code fragments that efficiently perform the following operations under the constraints given. 1. Determine the value in R2 is divisible by 16, when it is viewed as a signed (two’s complement) integer. If the value in R2 is divisible by 16, then R3 should be set to 0x00000001. Otherwise R3 should be set to 0xFFFFFFFF. 2. Reverse the order of the bits in R0 and store the result in R1. For example, if R0 contains 0x12345678, then R1 should contain 0x1E6A2648. Although you are not required to create complete programs, it would be a good idea to assemble and test your code. 3. (10 points) Flowcharts Using the conventions for drawing flowcharts discussed in class draw a flowchart for the num_ones subroutine given in Problem 4. 4. (20 points) Subroutines Write a subroutine called num_ones that determines the length of the largest string of ones in R2 and returns the result in R3. For example, if R2 contains 0x67F9ABC4, then R3 should contain 0x00000008, since the largest string of ones in R2 is eight bits. Your subroutine may not disturb any of the caller’s registers (i.e., it should use the stack to save and restore any registers it uses). Write a driver program in main.s that tests your subroutine for the following input values 0x8FF70FF2, 0x123FEDC4, 0x00000000, 0x7C01ABCD, 0xAB849210, 0xFFFFFFFF, 0x070E0F30. Be sure to EXPORT your subroutine name. Important: Submit your program source code files for main.s and num_ones.s using your homework team’s dropbox in Learn@UW. Also, submit a paper copy of main.s and num_ones.s with the rest of the assignment.ECE 353 Introduction to Microprocessor Systems Spring 2008 (Schulte) 2 5. (10 points) Branches versus Conditional Execution Consider the operations described by if (R2 < R3) begin R2 = -1; R3 = NOT R3; end else if (R2 > R3) begin R3 = R2; R2 = 17; end else begin R2 = NOT R2; R3 = R2 + R3; end Write two code fragments implementing the behavior shown above. 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. Submit your source code, and answer the following questions. A. What are the relative advantages/disadvantages of the two approaches? B. In general, what sorts of situations favor using branches and what sorts of situations favor conditional execution? 6. (20 points) Implementing the atoi() function Write a subroutine that functions like the C language atoi function – one online reference for this function is http://www.cplusplus.com/reference/clibrary/cstdlib/atoi.html. Your subroutine should take as input the ASCIIZ (zero-terminated) string, x_str, and return the 32-bit binary value, x_int, that x_str represents when viewed as an integral number. Your subroutine should behave just like the C language atoi function in terms of how it handles negative numbers, invalid characters, and whitespace. However to simplify your program, you may assume that all integer inputs are within the range of representable numbers. Some examples are given below. x_str = “ 123456” x_int = 0x0001E240 // converting a positive integer x_str = “123456X77” x_int = 0x0001E240 // ignores stuff after 6 x_str = “ -897234” x_int = 0xFFF24F2E // converting a negative integer x_str = “ABC12394” x_int = 0x00000000 // invalid string returns 0 x_str = “90194313216” // you don’t have to handle this case, since it can’t be // represented as a 32-bit integer. You are to write a subroutine named atoi (in a file named atoi.s) that implements atoi, assuming that the address of x_str is passed in R1 and the integer result, x_int, is returned in R0. You should write a driver program in main.s that tests your subroutine with a reasonable number of test cases, including invalid strings and strings that represent negative numbers. Your subroutine may not disturb any of the caller’s registers (i.e., it should use the stack to save and restore any registers it uses). Be sure to EXPORT your subroutine name from atoi.s. Your code should be reasonably efficient. You may write your own subroutine(s) that are called by atoi – just be sure place them in the atoi.s file.ECE 353 Introduction to Microprocessor Systems Spring 2008 (Schulte) 3 Important: Submit your program source code files atoi.s and main.s using your homework team’s dropbox in Learn@UW. Also, submit a paper copy of atoi.s and main.s with the rest of the assignment. 7. (10 points) Stack Topologies Given the data declaration below, write code to initialize R13 to use the stack_space region for an empty ascending stack. stack_size EQU 512 stack_start SPACE stack_size Use a single STR instruction to implement a PUSH of register R0 onto the stack, assuming an empty ascending stack with R13 as the stack pointer. Use a single LDR instruction to implement a POP into register R0, assuming an empty ascending stack with R13 as the stack pointer. 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://eceserv0.ece.wisc.edu/~morrow/ECE353/objectives.pdf) in a specific problem. Explicitly state which particular educational objective you are attempting to test. Provide a complete, detailed solution to your


View Full Document

UW-Madison ECE 353 - Homework

Download Homework
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?