- #1
Jd303
- 35
- 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:
Any help would be greatly appreciated as I really have no clue what is wrong. Thanks in advance
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