PDA

View Full Version : Have you ever programmed for MIPS?



Maragato
10-01-2004, 08:06 PM
I'm doing it to university and it is a pain. I hate assembly, anyone has a funny history or fact about coding in it? By the way if you have some source examples they will be very welcome cause I still kinda lost :)

curlious
10-03-2004, 08:47 AM
Here is somthing I did for school this weekend.

.data
nameArray: .asciiz "Troy Curless"

success: .asciiz "Sucess"

failure: .asciiz "Failure"

.text
.ent main
main:
subu $sp,$sp,36 #Activation record 12 + 24.
sw $fp,36($sp) #Save the frame pointer on the stack for the main function.
addu $fp,$sp,36
la $s0,nameArray #address of nameArray in $a0 to pass to printchar:
la $s1,success #Success message
la $s2,failure #Failed message

add $a0,$s0,$zero
jal printchar #call printchar function
add $a0,$s1,$zero #prep for function call
addi $ra,$ra,12 #adjust return register
beq $v0,$zero,fail #branch to print failure if 0 failure
jal printchar #print success
fail:
add $a0,$s2,$zero #else prep load failure into arg register
jal printchar #call printchar(failure)
slt $v1,$zero,$v0 #set on successful print
j exit
.end main

printchar:
sw $ra,-12($fp)

sw $s0,0($fp)
sw $s1,-4($fp)
sw $s2,-8($fp)

li $v0,4
syscall
li $v0,1
lw $s0,0($fp)
lw $s1,-4($fp)
lw $s2,-8($fp)

# Now do housekeeping for the main function.
lw $ra,-12($fp) #Load the old return address from the stack
jr $ra #Return to caller.
.end printchar

exit:

Maragato
10-03-2004, 05:22 PM
In fact I need to discover how to save an int into a specific memory position. I know google ive fast searched it but I couldnt find, my C project is killing me, I have few time for mips :p

Govtcheez
10-03-2004, 06:31 PM
I've got my old MIPs textbook I could sell you cheap, if you don't mind waiting a week for me to get it from my parents' house (and if I can find it). It's a hell of a book

I think this is it
http://www.amazon.com/exec/obidos/ASIN/1558604286/qid=1096849819/sr=2-2/ref=pd_ka_2_2/103-0365094-4120670

Maragato
10-03-2004, 06:49 PM
I've got my old MIPs textbook I could sell you cheap, if you don't mind waiting a week for me to get it from my parents' house (and if I can find it). It's a hell of a book

I think this is it
http://www.amazon.com/exec/obidos/ASIN/1558604286/qid=1096849819/sr=2-2/ref=pd_ka_2_2/103-0365094-4120670

I got it free from a friend :) but I'm too occupied to read it right now, so I wonder if I can make the project just by reading some code examples. :)

Salem
10-04-2004, 01:25 AM
> I hate assembly, anyone has a funny history or fact about coding in it?
Well write the silly thing in C then.
Then do "gcc -S" on it to get the assembler and tweak it to match what you want to do.

Maragato
10-04-2004, 04:28 AM
> I hate assembly, anyone has a funny history or fact about coding in it?
Well write the silly thing in C then.
Then do "gcc -S" on it to get the assembler and tweak it to match what you want to do.


I wish I could, but I need to learn this stuff :)

GanglyLamb
10-04-2004, 06:59 AM
I'm doing it to university and it is a pain. I hate assembly,


my C project is killing me, I have few time for mips


Quote:
Originally Posted by Govtcheez
I've got my old MIPs textbook I could sell you cheap, if you don't mind waiting a week for me to get it from my parents' house (and if I can find it). It's a hell of a book

I think this is it
http://www.amazon.com/exec/obidos/A...0365094-4120670 (http://www.amazon.com/exec/obidos/ASIN/1558604286/qid=1096849819/sr=2-2/ref=pd_ka_2_2/103-0365094-4120670)


I got it free from a friend :) but I'm too occupied to read it right now, so I wonder if I can make the project just by reading some code examples. :)
And to conclude that Maragato is constantly contradicting in this thread->


Quote:
Originally Posted by Salem
> I hate assembly, anyone has a funny history or fact about coding in it?
Well write the silly thing in C then.
Then do "gcc -S" on it to get the assembler and tweak it to match what you want to do.



I wish I could, but I need to learn this stuff :)
You say you dont have time, that you hate assembly, you donīt want to read that book and you say you cant just learn it by looking at codesnippets....

ONE suggestion for you: get right onto it and study the damn thing. The faster you start learning it the faster all your problems will be over;).

::edit::
also i think that that book has an index ( like any other book actually ) so take the book and just look into the things you need to accomplish this project...dont worry about the rest for now just make sure you know the things needed for your project...

DrakkenKorin
10-04-2004, 07:23 AM
...

::edit::
also i think that that book has an index ( like any other book actually ) so take the book and just look into the things you need to accomplish this project...dont worry about the rest for now just make sure you know the things needed for your project...
not only that but there's a section in that book (appendix) that deals with mips and common usages - we used the same book for my comp org class.

curlious
10-04-2004, 04:28 PM
lol if anyone looked at my code they would have seen its a little buggy, luckily I fixed it before turning it in.

Dalren
10-04-2004, 05:18 PM
First, the book that Govt was offering is a great book, I used it in my Comp Arch. class and it is great if you want to learn how computers work on a level just above logic gates.

Second, how can you dislike mips, compared to x86 asm its wonderful

VirtualAce
10-04-2004, 08:41 PM
What's wrong with x86?

Maragato
10-05-2004, 08:32 PM
What's wrong with x86?
All, X86 asm is a hell, instructions are messud up, you cant freely use the registers, some instructions doesnt work on some registers... Common problems of a CISC machine.