# How Do You Program a Sequential LED Light Pattern in MIPS Assembly?

• Jd303
In summary, the programmer is trying to make LEDs light up one at a time and then extinguish the previous one. However, something is going wrong and the code is not working as intended.
Jd303
Hi all,
I've only just started MIPS and have been stuck on this introductory lab for a while now.

I have 8 LEDs each lit by there corresponding bit being a 1.
Hence 0010 0101 at the input would light up LEDS 1, 3 and 6.

I need to make LEDs 1-5 light up one at a time and extinguish the previous one
Hence a sequence like this:
0000 0001
0000 0010
0000 0100
0000 1000
0001 0000
0000 0001 As you can see here it should then go back to the first LED being lit.

I realize you can do this with shift left logical, or multiplication. But as it is introductory I have to do this by adding a register with itself to do the same as multiplying a register by 2.

I think this addition is where something is going wrong as my $7 for some reason equates to 0. Here is my code: Code:  .set noreorder .text .globl start .ent start start: lui$9, 0xbf90 		# Load upper half of port address
nop
li $6, 0xff li$7, 0x01
repeat: lbu $8, 0x0($9)		# Read from the input port
or $8,$8, $6 and$8, $8,$7
sb  $8, 0x0($9) 	# Write to the output port
nop			# Another nop for the sb
bne $7, 5, ELSE nop addi$7, $7, -4 b repeat # Repeat the read and write cycle nop # Needed after branch ELSE: add$7, $7,$7
b repeat 		# Repeat the read and write cycle
nop 			# Needed after branch
.end start 			# Marks the end of the program

Any help would be greatly appreciated as I really have no clue what is wrong. Thanks in advance

I'm no programmer but just looking at the comments in your code I see no time delay mentioned. So is it possible it's working fine but too fast? Each LED would only be ON for 1/5th of the time so they appear off? Just a thought.

Can you time delay in MIPS?

As I said I'm not very familiar with MIPS but most processors have some sort of timer capable of generating interrupts. Google suggests this is in "coprocessor 0” but perhaps wait for someone who knows what they are taking about.

Hello, it seems like you are trying to create a light sequence using MIPS assembly language. It looks like your code is on the right track, but there are a few things that may be causing issues.

Firstly, in your repeat loop, you are using the bne (branch if not equal) instruction to check if $7 is equal to 5. However, in the comments above, you mention that you want to turn on LEDs 1-5, which would mean$7 should be equal to 31 (0001 1111 in binary). So you may want to change that part of your code to bne $7, 31, ELSE. Secondly, it seems like you are using the add instruction to increment$7, but in your comments you mention using multiplication or shift left logical. If you want to use multiplication, you can use the mul instruction and if you want to use shift left logical, you can use the sll instruction. These may be simpler alternatives to using the add instruction.

Lastly, it's hard to say why \$7 is equating to 0 without seeing the rest of your code. It could be due to a mistake in your code or a problem with your hardware setup. I would suggest double checking your code and making sure your hardware is set up correctly. You may also want to try debugging your code using a simulator to see where the issue is occurring.

I hope this helps and good luck with your lab! Don't hesitate to ask for more help or clarification if needed.

## 1. How does the MIPS - LED light sequence work?

The MIPS - LED light sequence works by using a microprocessor to control the flow of electricity to each LED light. The microprocessor is programmed with a specific sequence of instructions, which determines the pattern and timing of the LED lights.

## 2. What is the purpose of the MIPS - LED light sequence?

The purpose of the MIPS - LED light sequence is to provide a visual representation of data or information. It can also be used for decorative or entertainment purposes.

## 3. Can the MIPS - LED light sequence be customized?

Yes, the MIPS - LED light sequence can be customized by changing the programming of the microprocessor. This allows for different patterns and timings to be created.

## 4. How many LED lights can be controlled by the MIPS - LED light sequence?

The number of LED lights that can be controlled by the MIPS - LED light sequence depends on the capacity of the microprocessor. Some microprocessors can control hundreds or even thousands of LED lights.

## 5. Is the MIPS - LED light sequence energy-efficient?

Yes, the MIPS - LED light sequence is energy-efficient because LED lights use less electricity compared to traditional incandescent bulbs. Additionally, the microprocessor can be programmed to turn off specific LED lights when not in use, further reducing energy consumption.

• Engineering and Comp Sci Homework Help
Replies
7
Views
2K
• Engineering and Comp Sci Homework Help
Replies
6
Views
3K
• Engineering and Comp Sci Homework Help
Replies
5
Views
16K
• General Engineering
Replies
1
Views
12K
Replies
16
Views
5K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K