Embedded system

profilem-jaz
eece_237_s15_-_lab_2.pdf

EECE 237 Spring 2015 Homework Assignment #2 – Numerical Representations, Function Calls Assignment: Create an assembly language function that displays the binary and hexadecimal representations of a 16 bit value (passed in as a parameter) on our LCD screen. Use the provided .c main file and assembly language subroutine example as a basis for your code. The main_Lab2_ s15.c file provided initializes the board, displays a header message, and then displays a “Ready:” prompt and waits for a button press. When the button is pressed, the code reads an internal system timer, yielding a 16 bit number to be converted to hex and binary. This number is then displayed in decimal on the first line of the display, and the assembly language functions are called, with the number passed in as a parameter. The assembly language functions in the demo code just calls the LCD_write function to demonstrate how to write to the LCD display. Your code (in the first assembly language function) will take the value passed in and displays its Hexadecimal representation on the first line (starting at column 11). The second assembly language function will display the Binary representation on the second line of the LCD. The output should look like this: When your second assembly language function completes, it will return the number of one bits it displayed to the main .c code, which will display it (and the original number) and wait for a button press. It will then retrieve a new number and call your functions again, running the conversion/display sequence in a repetitive loop. NOTES: • Start with the sample files (main_Lab2_ s15.c, Lab2_demo_s15.s) posted on the course’s BbLearn page • Your code must do the hex and binary conversions and display using a loop and some form of bitwise or arithmetic

test – no table lookups or library function calls can be used • All 16 bits of the number must be displayed, with the most significant bit on the left (see image above) • The function must execute properly (doing a new conversion/display) when called repeatedly by the main .c code • The .c code file should not be modified – only turn in your .s file

This part gets written by the C code (I gave you)

This part gets written by the hex_display Assembly Language function

This part gets written by the binary_display Assembly Language function

Deliverables: Source code for solution program: ASM source file - submitted via BbLearn page. (Do not submit other project files). The files MUST be named as follows:

<first initial>_<last name>_hw2.s

for example, mine would be d_word_hw2.s The source code files must contain your name, etc. in the header block at the top of the page, and should be commented enough to be easy to read (minimum of 1 comment for every 3 assembly instructions).

Due Date: Thursday, April 9th – Assignment must be submitted by 8pm.

C Code

- waits for button press

- generates random(ish) #

- displays it in decimal

- calls hex_display assembly language function

- calls binary_disp assembly language function

-waits for button press

- displays original number and number on ones returned from binary_disp

Assembly Language Code

hex_display - displays number in hex - returns

binary_display - displays number in binary - counts number of one bits - returns number of one bits