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

Click For Summary

Discussion Overview

The discussion revolves around programming a sequential LED light pattern using MIPS assembly language. Participants are exploring how to light up LEDs one at a time while extinguishing the previous one, specifically focusing on the implementation details and potential issues in the provided code.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • The original poster describes their goal of lighting LEDs 1-5 sequentially and provides a code snippet that they believe is malfunctioning due to an issue with the addition operation affecting register $7.
  • Some participants suggest that the absence of a time delay in the code might cause the LEDs to appear off, as they could be switching too quickly for the human eye to perceive.
  • One participant inquires about the possibility of implementing a time delay in MIPS, indicating a lack of familiarity with the architecture.
  • Another participant mentions that many processors have timers that can generate interrupts, suggesting that this feature might be found in "coprocessor 0," but they recommend waiting for more knowledgeable input.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the cause of the issue, with some focusing on the code's logic while others propose the need for a time delay. The discussion remains unresolved regarding the specific problem with the code.

Contextual Notes

There are limitations in the provided code, such as the lack of a time delay and potential misunderstandings about the behavior of the addition operation in the context of the LED pattern. The discussion does not clarify how to implement the time delay or address the specific malfunction of register $7.

Who May Find This Useful

This discussion may be useful for individuals learning MIPS assembly programming, particularly those interested in hardware interfacing and sequential control of outputs like LEDs.

Jd303
Messages
34
Reaction score
0
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
	nop			# Needed after load
	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
 
Physics news on Phys.org
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.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
Replies
6
Views
3K
Replies
5
Views
17K
  • · Replies 1 ·
Replies
1
Views
13K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
5K