Bubble Sorting Dengan MIPS Instruction

berikut ini adalah program bubble sorting dengan menggunakan MIPS instruction…

.data
.data 0x10010000
array:.word 0x17,0x7,0x0a,0x61,0x19,0x65,0x75
.text
.globl main

main: addu $s0, $ra, $0
li $s1, 0x10010000
addi $s2,$s1, 24
add $t0,$s1,$0

loop1:add $t1,$t0,$0
loop2:addi $t1,$t1,4
lw $t2, ($t0)
lw $t3, ($t1)
slt $t4,$t3,$t2
beq $t4,$0,skip

sw $t3,($t0)
sw $t2,($t1)

skip: bne $t1,$s2,loop2
addi $t0,$t0,4
bne $t0,$s2,loop1

addu $ra, $0,$s0
jr $ra

jalankan dengan menggunakan simulasi SPIM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: