Assignment Three – Input/output and Logic Instructions Programming
The Input/output Peripherals programming, and Logic instructions are a central future in many embedded applications. It is essential for any embedded system programmer being able to access and communicate with IO ports. Embedded system logic instructions are also useful for manipulation of bit strings and for dealing with data at the bit level where only a few bits may be of special interest. Logic instructions programming are essential in dealing with input/output tasks. You may need to modify the embedded system that you built in the previous assignment for the implementation of this assignment. The goal for this assignment is to familiarize yourself with the fundamental skills needed in embedded programming.
Create an infinite loop that
Reads the binary setting of the 5-bit DIP switch on the board (SW0 – SW4)
Display the value on the 7-segment display
After some delay, display the binary value on the LEDs
In this part you will implement a Nios II assembly language program shown. The program counts the longest string of 1’s in a word of data. For example, if the word of data is 0x103fe00f, then the required result is 9. Compile and load the program. Fix any errors that you encounter. Once the program is loaded into memory in the computer, single step through the code to see how the program works.
ldw r9, TEST_NUM(r0) mov r10, r0
LOOP: beq r9, r0, end srli r11, r9, 0x01 and r9, r9, r11
addi r10, r10, 0x01 br LOOP
END: br END
TEST_NUM: .word 0x3fabedef
Perform the following:
Take the code in part two which calculates the number of consecutive 1’s and make it into a subroutine called ONES. Have the subroutine use register r4 to receive the input data and register r2 for returning the
Add more words in memory starting from the label TEST_NUM. You can add as many words as you like, but include at least 10 words. To terminate the list include the word 0 at the end—check for this 0 entry in your main program to determine when all of the items in the list have been processed.
Develop a new main program to call the newly-created subroutine in a loop for every word of data that you placed in memory. Keep track of the longest string of 1’s in any of the words, and display this result in the 7-segment when your program completes execution.
Make sure to use breakpoints or single-stepping in the Monitor Program to observe what happens each time the ONES subroutine is
Also, one might be interested in the longest string of 0’s.
Write a new assembly language program to includes two subroutines; one for finding the
largest string of 1’s and another to find the largest string of 0’s. The program should function as
Longest string of 1’s in a word of data—Display the result into a 7-segment
Longest string of 0’s in a word of data—Display the result into another 7-segment
Display the summation of 1 and 2 on the green
Make each calculation in a separate subroutine called ONES, ZEROS, and ALTERNATE. Call each of these subroutines in the loop that you wrote in Part three, and keep track of the largest result for each calculation, from your list of data.
To detect errors in data communication and processing, an additional bit is sometimes added to a binary code word to define its parity. Parity may be used with binary numbers as well as with codes, including ACII for characters, and parity bit may be placed in any fixed position in the code. Write a program to read a binary number equivalents for 32 through 47 with a parity bit added in the rightmost position. Include an odd parity to the bytes for each numbers. Numbers with parity bit to be stored in memory at location oddp.
Output the sequences of the parity result at memory location oddp to LEDG to verify the work.
The parallel ports that you implemented in your embedded system are to be connected to the 7- segment displays. Figure below shows how the display segments are connected to the parallel ports with the ports’ respective memory mapped addresses.
To show each of the numbers from 0 to 9 it is necessary to light up the appropriate display segments. For example, to show 0 on HEX0 you have to turn on all of the segments except for the middle one (segment 6).
The parallel ports connected to the seven-segment displays, HEX7 − 0, of the DE2-115.
//Subroutine to convert the digits from 0 to 9 to be shown on a HEX display.
//Parameters: r4 = the decimal value of the digit to be displayed
//Returns: r2 = bit pattern to be written to the HEX display
SEG7_CODE: movia r15, BIT_CODES add r15, r15, r4 db r2, (r15) ret
BIT_CODES: .byte 0b00111111, 0b00000110, 0b01011011, 0b01001111, 0b01100110
.byte 0b01101101, 0b01111101, 0b00000111, 0b01111111, 0b01100111
.skip 2 //pad with 2 bytes to maintain word alignment
example of code that shows the contents of registers on the 7-segment displays is illustrated below. Note that this code uses the DIVIDE subroutine that was discussed earlier. The code in the figure shows only the steps needed for register r10. Extend the code to display all three result as specified on the 7-segment displays and LEDs as described above.
// now display r10 on HEX1-0, r11 on HEX3-2 and r12 on HEX5-4
DISPLAY: movia r8, Insert HEX3-HEX0 base address mov r4, r10 //display r10 on HEX1-0
call DIVIDE //ones digit will be in r2; tens digit in r3 mov r4, r2 //pass ones digit to SEG7_CODE
mov r14, r2 //save bit code
mov r4, r3 //retrieve tens digit, pass to SEG7_CODE call SEG7_CODE
slli r2, r2, 8
or r14, r14, r2
stw r14, (r8)
code for r12 (not shown)
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of