• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

What does this do? (probably assembly)

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Arjuna

Registered
Joined
Nov 24, 2002
What does the following do?

.globl a1p1

a1p1: add $1, $2, $3
llo $5, 8
lhi $5, 8
divu $1, $5
mflo $1
sub $1, $4, $1
jr $31
 
That doesn't look like Intel assembly. PowerPC maybe? Looks like it, but I'm not an expert.

My guess is it adds some stuff in 2 registers and then stores the result in a third, does something else, does some division, does some floating point multiplication, subtracts some stuff in 2 registers and stores the result in a third, then jumps due to some condition I can't think of to a pointer in the register noted by $31.
 
Looks like MIPS to me (or a close relative of MIPS).

llo and lhi are load into lower and upper half of the word respectively. divu is divide unsigned. mflo is multiply float. jr is jump register (often used for a procedure return).
 
I read a thing a while ago on PowerPC assembly on IBM's site, they said alot of instructions take 3 operands: two source registers and a destination register. Looks like add and sub might be doing that, thats why I thought it might be PPC. Does mips do that two?
 
Arjuna said:
What does the following do?

.globl a1p1

a1p1: add $1, $2, $3
llo $5, 8
lhi $5, 8
divu $1, $5
mflo $1
sub $1, $4, $1
jr $31

I just happen to have all the MIPS assembly language commands in front of me, and it appears to be MIPS

anything starting with a $ is a register. Those are variables.

add = add. $1 = $2 + $3

divu = divide unsigned. lo = $1/$5 hi = $1 mod $5

I'm guessing llo means load the low number into $5 or something like that. MIPS has mfhi, for move from Hi, and mflo. No llo, or lhi.

mflo = move from low. $1 = lo

sub = subtract. $1=$4-$1

jr = jump register. jump to line $31 (value in register) to execute code there.
 
Back