| | |
MIPS help
![]() |
•
•
Join Date: Oct 2005
Posts: 2
Reputation:
Solved Threads: 0
I need to input a list of numbers using mips.
Also, i need to use the list and implement this function:
function dbl(l){
if (L is empty list)
return empty list;
else {
L4 = dbl (L - first element);
Dou = 2 * first element in L;
return (list made by adding Dou to L4);
}
So far I have problems trying to enter in a list of numbers, this is what i have so far:
main:
li $s2,0
li $t1,0 #set to zero
li $s5, -999 #put in -999 to $s5
la $a0, input_int #to print "Please enter a list of integers, -999 to end"
li $v0, 4 #set $v0=4 to print a string
syscall
Loop:
move $t0, $zero #i=0(register $t0=0)
loop1:
sll $t1,$t0,2 #$t1=4*i
add $t2,$a0,$t1
li $v0,5 #to read integer set $v0=5
syscall #after 'syscall', integer read is in $v0
beq $v0,$s5,Double #if the number entered is -999 Exit
move $s0,$v0
sw $s0,0($t2)
addi $t0,$t0,1 #i=i+1
bne $s1,$s5,loop1
Also, i need to use the list and implement this function:
function dbl(l){
if (L is empty list)
return empty list;
else {
L4 = dbl (L - first element);
Dou = 2 * first element in L;
return (list made by adding Dou to L4);
}
So far I have problems trying to enter in a list of numbers, this is what i have so far:
main:
li $s2,0
li $t1,0 #set to zero
li $s5, -999 #put in -999 to $s5
la $a0, input_int #to print "Please enter a list of integers, -999 to end"
li $v0, 4 #set $v0=4 to print a string
syscall
Loop:
move $t0, $zero #i=0(register $t0=0)
loop1:
sll $t1,$t0,2 #$t1=4*i
add $t2,$a0,$t1
li $v0,5 #to read integer set $v0=5
syscall #after 'syscall', integer read is in $v0
beq $v0,$s5,Double #if the number entered is -999 Exit
move $s0,$v0
sw $s0,0($t2)
addi $t0,$t0,1 #i=i+1
bne $s1,$s5,loop1
![]() |
Similar Threads
- Quick MIPS question (Assembly)
- i'm a rookie, please help with MIPS (Assembly)
- MIPS language question2 pls help.. (Assembly)
- MIPS language question pls help.. (Assembly)
- Looking for a tutor for MIPS programming (Assembly)
- Mips Assembly porting from C (Assembly)
- Easy (I hope) MIPS (SPIM) Question (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: Open browser
- Next Thread: Calculator program returning random values
| Thread Tools | Search this Thread |





