Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Help 

Need Assembler help please

Hi,
I know i have little chance to get free help in here you all gold diggers but it's worth a try.
So I need some help in assembly coding for MIPS-32.
I need to write 2 "programs":
One that exchanges the values from s0 and s1, for example if s0=4 and s1=3 then the "program" should exchange them so the result would be s0=3 ans s1=4.
This is my try but i think it's to easy to be true.(apparently i needed to use $zero. somwhere)

lw $t0, $s1
lw $t1, $s2
sw $t0, $s2
sw $t1, $s1

The other "program" need to take the absolute value from t0 to put it in t1, so t1 should be a positive umber or zero equal to t0 norm.(apparently i need to use something like bltz reg, addr commands)

It's probably not the best description of what i need to do but i needed to translate it and it wasn't the easiest part, let me know if you can help me please!👍
I haven't touched MIPS but I just looked at the instruction set,
So this should work.
Code
lw $s0, 4
lw $s1, 3
mflo $t1,$s0
mflo $s0,s1
mflo $s1,$t1

As for your second problem.
Code
bltz $s0, negative
j positive
negative:
lw $s1,-1
mult $s0,$s1
mlfo $s0,$lo
positive:
#Should be now positive


Here is the instruction set.
http://www.mrc.uidaho.edu/mrc/people/jff...IPSir.html

Edit: mflo not mflw
Hey Thanks a lot, just one question tho.. I never seen the mlfw command :(


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Assembly] by iTHXAug 13, 2022 05:14 PM 10 581 Aug 13, 2022 05:14 PM
Last Post: nulluser123
[Assembly] by ToyBoyAug 1, 2021 06:20 PM 0 180 Aug 1, 2021 06:20 PM
Last Post: ToyBoy
[Assembly] by Rolex™Feb 9, 2017 08:31 AM 3 332 Feb 9, 2017 08:31 AM
Last Post: Rolex™