# MIPS - LED light sequence

1. May 18, 2013

### 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 realise 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 (Text): .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

2. May 19, 2013

### CWatters

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.

3. May 19, 2013

### Jd303

Can you time delay in MIPS?

4. May 19, 2013

### CWatters

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.