Hi,
i am trying to write an alternative MIPS program the multiplying two given integers 6 and 8 i have already written

# Program to multiply 6 by 8 answer = 48
.text
main: addi $t1, $0, 6 # store integer 6 in $t1
addi $t2, $0, 8 # store integer 8 in $t2
mult $t1, $t2 # multiply $t1(6) by $t2 (8)
mflo $t0 # result stored in $t0
addi $v0, $0, 1 # print the integer in $t0
add $a0, $0, $t0
syscall
addi $v0, $0, 10 # exit
syscall

but need another way and 8 by 6 doesn't count.

i am only just starting out and any help would be great, i don't think i eed the whole code but some ideas would be good.

Recommended Answers

All 3 Replies

A common fast way to do a multiply by 8 is just shift left by 3 bits.

okay thanks heaps any idea where i can find out some info on shift left???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.