mips number of clock cycles and how improving code

Posted by Hooman on Programmers See other posts from Programmers or by Hooman
Published on 2013-06-29T18:32:47Z Indexed on 2013/06/29 22:28 UTC
Read the original article Hit count: 363

Filed under:

I'm really new in MIPS and I have these questions which I found so many dissimil answers for them ... if someone can help, it would be great. Thanks

How many clock cycles does this code take?

#Macro Instructions
li  $t0, 32         #  1 or 2 cycles ?      
                    #                lui $at, Upper 16-bits of value 
                    #                ori Rd, $at, Lower 16-bits of value
                    #                -----------------------------------
                    #                ori Rt, $0, value
                    #
                    #  Which set of instructions will be executed?


div $t2, $t2, $t0   #  41 cycles?          
                    #                bne Rt, $0,
                    #                break $0
                    #                ok: div Rs, Rt
                    #                mflo Rd

#Integer Instruction

lw  $t2, 0($t13)    #  1  cycles?
sw  $t2, 0($t3)     #  1  cycles?

How those 4 lines of codes can be significantly improved? by avoiding to use Macros or ... ?

© Programmers or respective owner

Related posts about assembly