Hey Guys,

I'm extremely new to the coding in Assembly language MIPS - currently I'm using QtSpim. And I was wondering how I can go about multiplying two numbers that I input and display that number, as well as, find an average of numbers and displaying that.

Any info would be really appreciated - thanks

Recommended Answers

I don't know about MIPS Assembly, but in SPARC Assembly move the two registers or numbers into %o0 and %o1 and call .mul
The result will be returned in %o0, move %o0 to %o1 you can then call printf after you have set a string into %o0.

String: acsiz "%d\n"

Jump to Post

All 2 Replies

I don't know about MIPS Assembly, but in SPARC Assembly move the two registers or numbers into %o0 and %o1 and call .mul
The result will be returned in %o0, move %o0 to %o1 you can then call printf after you have set a string into %o0.

String: acsiz "%d\n"

Example:

mov 3, %o0
mov 2, %o1

call .mul
nop

mov %o0, %o1
set String, %o0

call printf, 2
nop

ret
restore

You would need to add some more code above to make it work, like a .golbal , .section and a save. Hope this helps.

The average of the two numbers uses add and div methods in the same way.

Hey thanks for the help!

But how would I go about doing the average? I guess it would work more or less the same way - add x numbers and then call div(?)??

Be a part of the DaniWeb community

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