MIPS help

Reply

Join Date: Oct 2005
Posts: 2
Reputation: oneohthree is an unknown quantity at this point 
Solved Threads: 0
oneohthree oneohthree is offline Offline
Newbie Poster

MIPS help

 
0
  #1
Oct 25th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC