Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ converted to assembly help

Status
Not open for further replies.

tlk2bobby

Programmer
Sep 23, 2008
1
0
0
Hi all,

I'm new to assembly so I wondering if you can help me out. I have got a simple code and I need to learn how to translate it to assembly.

A Fibonacci number series contains the sum of the last two natural numbers. The series starts from 0.

So, the series will be 0, 1, 1, 2, 3, 5, 8, 13, 21...
up to 15 times.

Here is my first attempt.

Code:
.data

.text
.globl main
main:

_start
li $t0, 0          #a = 0         use move 
$t0, $t1  to copy
li $t1, 1                          #b = 1
li $t4, 0                        #counter
                                 #loop start     loop:
add $t3, $t1, $t0                #c = a + b
move $t0, $t1                    #a = b
move $t1, $t3                    #b = c
                                   
li $v0, 1
syscall

add $t4, $t4, 1
bne $t4, 15, loop
jal loop

li $vo, 1

add $a0, $a0, $t1
li $v0, 1


loop:
        add $t0 , $t1, $

    syscall


end:
       
        jr $ra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top