Thread: Booth's Algorithm in MIPS View Single Post
 Go4Expert Member 20Nov2007,16:27 I have been work on this program, but I am having problems in rectifying the errors. Help me..text Code: ```* 12 bits register * 8 bits anwer * 4 bits multiplier and multiplicant * user must enter multiplier and multiplicant * print the results in both decimal and binary .globl main main: li \$v0, 4 #Enter multiplicant la \$a0, msg1 syscall li \$v0, 5 syscall move \$a0, \$v0 li \$v0, 4 #Enter multiplier la \$a0, msg2 syscall li \$v0, 5 syscall move \$a1, \$v0 li \$v0, 0 li \$t1, 0 li \$t0, 12 # twelve bits algorithm: and \$t2, \$a0, 24 #24 bit mask sll \$t2, \$t2, 1 or \$t2, \$t2, \$t1 beq \$t2, 2, check10 beq \$t2, 1, check01 b shift check10: sub \$v0, \$v0, \$a1 b shift check01: add \$v0, \$v0, \$a1 shift: and \$t1, \$a0, 16 #16 bit mask and \$t2, \$v0, 8 #8 bit mas sll \$t2, \$t2, 31 srl \$a0, \$a0, 1 or \$a0, \$a0, \$t2 sra \$v0, \$v0, 1 sub \$t0,\$t0, 1 bnez \$t0, algorithm # Printing the 8 bits results (\$v0,\$a0) li \$v0, 4 la \$a0, msg3 syscall li \$v0,1 move \$v0, \$a0 syscall .data msg1: .asciiz"\nEnter multiplicand" msg2: .asciiz"\nEnter multiplier" msg3: .asciiz"\nThe Eight bits result is"``` Last edited by shabbir; 20Nov2007 at 17:37.. Reason: Code block