jump to navigation

Multiplication of integer number April 5, 2009

Posted by aghus in Assembly Language, IT, Ngoprek.
trackback

This MIPS assembly code implements simple algorithm for multiplication.

#—– processing multiplication algorithm

addi $t0, $zero, 0 #prepare for product
addi $t7, $zero, 0
addi $t8, $zero, 0

addi $t7, $s4, 0 #prepare for multiplicand
addi $t8, $s5, 0 #prepare for multiplier

addi $s7, $zero, 1 #intialize for repetition
addi $t9, $zero, 16


forshift :
addi $s7,$s7,1
andi $v1,$t8,0x00000001
beqz $v1,ztimes
andi $t7,$t7,0xFFFFFFFF
add $t0,$t0,$t7 #initial value for prod = prod + mcand
ztimes :
sll $t7,$t7,1 #shift left mcand
srl $t8,$t8,1 #shift right mplier
bne $s7, $t9, forshift

addi $t9,$zero,0
addi $t8,$zero,0
addi $t7,$zero,0

b23 :
sll $t0,$t0,1
addi $t7,$t7,1 #shifting to count exponent
andi $t9,$t0,0x00800000
srl $t8,$t0,23
beqz $t8,b23

andi $t0,$t0,0x7FFFFF
addi $t8,$zero,23
sub $t8,$t8,$t7
addi $t8,$t8,127
sll $t8,$t8,23
or $t0,$t0,$t8 # add exponent
or $t0,$t0,$t5 # add sign bit



commercial break🙂
TENUN Pekalongan ?


SMS : 081325744551;
email : elista.collection@yahoo.co.id

Comments»

1. areta - April 8, 2009

what is this algoritma look like ?


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: