Following MIPS program that computes xn using loops. This program will first ask user to enter the base, and then asks the user to enter power. Then it prints the result.

MIPS (originally an acronym for Microprocessor without Interlocked Pipeline Stages) is a reduced instruction set computer (RISC) instruction set (ISA) developed by MIPS Technologies (formerly MIPS Computer Systems, Inc).

.data
txt1:  .asciiz   "Please enter a integer : "
txt2:  .asciiz   "Please enter the power of the integer : "
txt3:  .asciiz   "The result is : "

.text
.globl main
main:
    la $a0, txt1
    li $v0, 4
    syscall
    
    li $v0, 5
    syscall
    
    move $t0, $v0
    
    la $a0, txt2
    li $v0, 4
    syscall
    
    li $v0, 5
    syscall 
   
    move $t1, $v0
    
    add $t2, $t2, 1
loop:
    beqz $t1, print
    mul $t2, $t2, $t0
    add $t1, $t1, -1
    j loop
    
print:
    la $a0, txt3
    li $v0, 4
    syscall
    
    move $a0, $t2
    li $v0, 1
    syscall
        
exit: 
    li $v0, 10
    syscall
Tagged with: MIPS AssemblySource Code
 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Related News Feeds

Set your Twitter account name in your settings to use the TwitterBar Section.