Please Register or Login -By Tension

Please Donate 10$ to help NRU and get VIP Access:
www.NooBzAreUs.niceboard.org/Donate.forum
"Help the site be better and have a /.net !!"

We have True Slot Freeze,WiFi Boot,Server Boot,God Menus, and more!


Where N00BS become L33T!
 
HomePortalCalendarGalleryFAQSearchMemberlistUsergroupsRegisterLog in
Latest topics
» No Recoil/Perfect Shot
Fri Sep 30, 2011 2:09 pm by CjZaZy.ReApEr

» ><>shot kills<><
Fri Sep 30, 2011 2:08 pm by CjZaZy.ReApEr

» ><>Boucing shyt<><
Fri Sep 30, 2011 2:07 pm by CjZaZy.ReApEr

» lock on/ throw shyt
Fri Sep 30, 2011 2:06 pm by CjZaZy.ReApEr

» SUPPESR 1/2 EVERY GUN
Fri Sep 30, 2011 2:06 pm by CjZaZy.ReApEr

» Every thing on your gun
Fri Sep 30, 2011 2:05 pm by CjZaZy.ReApEr

» Always 32x Zoom Range
Fri Sep 30, 2011 2:05 pm by CjZaZy.ReApEr

» Lockon Distance Primary
Fri Sep 30, 2011 2:03 pm by CjZaZy.ReApEr

» Knife Freeze []
Fri Sep 30, 2011 2:01 pm by CjZaZy.ReApEr

Affiliates
www.FTB2Krazy.tk
 
Top posters
Tension
 
CHIV3S
 
looneyhead
 
TyrantHunTer15
 
CjZaZy.ReApEr
 
-FtB2..KrAzY-
 
SocomGuy99
 
WeeZyxBaBy
 
IIvIIr.L0VE
 
ARMY-OF-HELL
 
Statistics
We have 33 registered users
The newest registered user is panban

Our users have posted a total of 433 messages in 241 subjects

Share | 
 

 Imok's Guide of Basic MIPS!

Go down 
AuthorMessage
Tension
Admin & 1337
Admin & 1337
avatar

Posts : 234
Join date : 2009-08-17

PostSubject: Imok's Guide of Basic MIPS!   Mon Sep 21, 2009 8:39 pm

For everyone trying to act like a real coder read this and maybe you can prove you actually know more than a nop in your next fight.

Hello, everyday I see more and more people wanting to learn MIPS to code PSP games. Well there are alot of guides out there that explain how to write the subroutine which is filling in the blanks. Well in this mini tutorial I will explain the basics of MIPS commands so those begginer tutorials are a bit easier to understand. This isnt really usefull if you already know MIPS its more of a thing to help those who are just beggining. Lets get to it!

Hex basics
First the basics of hex, you should learn this as if you know next to nothing then well it may just be a little harder.MIPS address's are counted by fours so for example it will go like so. Also hex if you did not know is made up of numbers 0-9 And the letters A-F.
Code:


00000000
00000004
00000008
0000000c
00000010;Once you count 0..4..8..c..then you add one to that byte etc so it goes up to 10 then 14...
00000014
00000018
0000001c
00000020
00000024
00000028
0000002c
00000030
That above example should easy enough to follow and I shouldnt really need to explain much more on that subject matter.

Data Types

Data types are the types of data you have so as bytes, words, hlafwords etc.
All Instructions are 32 bits (searchers should know this!)
A byte is 8 bits
A Halfword is 2bytes(18 bits)
A word is 4 bytes(32 bit instruction)

basics of registers

Registers are extremely Important in any type of assembly including MIPS, so I think this is something extremely important to cover up. Registers are used to hold and contain different types of data such as packets, information, offsets etc. You can call data from one register and bring it into another. You also use them in subrotuines with the most commonly used among begginers which would be tX.

Register Name|Purpose|Example(s)

Temporary | Temporary contains data to be called and used elsewhere goes $t0-t9 | ori t0, zero, $0001

Values | Contains the function values and the result $v0-v1 | beq v1, zero, $00000158

Saved | Saves the called data and please remember that when using these registers in a subrotuine you must save the original data and restore it back before exiting $s0-s7 | andi s2, t1, $7f19

Arguments | Commonly used for packets such as a3 when using the data pointer for where the packet is recived or sent etc. Not Commonly used for begginers $a0-a3 | addiu a0, zero, $0003

Stack pointer | used to point data and allocate it onto the stack. Many begginers wont understand this so I will expplain my example! (sp) | sw t0, $0000(sp) Kinda hard to explain without the whole routine but this short mini example stores the contents of t0 onto the stack pointer which would of been defined before +0000.
Thats all I think you guys should know about registers for know as theres still more to explain such as more about the stack, frame pointers but I will explain those in a tutorial in the future.

The basic MIPS Commands

Commands tell the assembler what function to perform and what to do etc such as add this data into the value, or load this address from here etc. I will only explain the basic ones in this tutorial as I dont want people who are just starting to learn to become too confused.

nop - No operation -Disables a function or object in the memory, also where codes are written to as these address's have no value and therefor can not corrupt other memory.(unless the rotuine is wrong) the Value of this is 00(00000000)

lui - Load upper Imediate -This command will load the upper half of an address or the data of a value. Say you have the address aaaabbbb It would load the upper Immediate which is the first half of that string. So it would be. XXXX0000 Loading the X's like so.
lui t0, $aaaa ;Where as this loads the first half of the data(either an address or value into a temporary register)

lw -Load word- Loads the word just like lui, except this loads the second half of the data wheter that is an address or a value into a register for further use. The word is the second half so it is. 0000XXXX where as X is the second half. aaaabbbb
lw t2, $bbbb ;This loads the second half of the data into another temporary register. Now Im going to show you how to load a compelte string of data using these two commands!

lui t0, $aaaa ;loads the first half into t0
lw t2, $bbbb(t0) (aaaabbbb) ;loads the second half of the data into t2, and then places the word into that register and binds it with t0 to make a complete string of data.
This fully loads the data aaaabbbb into temporary registers and when it is used in the subrotuine the processor will know you mean the address aaaabbbb. nice eh? And very easy to do!

ori - or imediate -This will place data or replace the current value of a function or address. It basically loads the value onto its location or the register. Such as..
ori t0, zero, $0001 ;This loads the data of one into a temporary register. What is the 'zero' '0' there for? Well it keeps the value constent so lemme explain this. Instead of being XXXX0001 It will define the data as 00000001 Even though it is not really shown that way. This is so if you dont want to place another hlaf of data into that value it will only keep it 01.

addiu - add unsigned imediate - Can be used to incremate or add data to a value etc, also used to change the address of what your loading, also works somewhat like an ori.
addiu sp, sp, -$0020(ffe0 is the value that it comes out to be *as the data ff makes it negative*) This subtracts 20 from the stack pointer to later have added back on but heres an easier example. addiu t4, zero, $0004 That adds four to that register(s).

jr ra- jump register return address -This jumps the return to the return address to finish off the routine. most if not almost all subrotuines have to be returned back to their starting point to their hook to execute the routine. jr ra is basically all you really half to know as it can be used for hooks etc. Now this can be used in some fancy ways such as returning data to a register or location of a reciving function so that data is NEVER recived so say you have a function that recives data, jr ra that location and it should stop it from you reciving it

Again this tutorial was made for begginers and people who have very little experiance with MIPS and would like to improve. This will make it ALOT easier on teachers who are instructings MIPS to people and have to start from the basics but don't know how to do it then point that person here. Also if YOU are new to MIPS and think there is something I should definetly cover for begginers, then let me know! And I will add it if it helps the begginers.
Hopefully it will help someone out in the future. Enjoy and I will most likely update this every now and then if I need too.
Back to top Go down
View user profile http://nruretiredforum.forumotion.com
TyrantHunTer15
Global Moderator
Global Moderator


Posts : 41
Join date : 2009-09-16

PostSubject: Re: Imok's Guide of Basic MIPS!   Mon Sep 21, 2009 8:46 pm

this dont make a ny sense im like wtf

ill try to get the hang of it

but ill just dot GFX work

_________________
Back to top Go down
View user profile
Tension
Admin & 1337
Admin & 1337
avatar

Posts : 234
Join date : 2009-08-17

PostSubject: Re: Imok's Guide of Basic MIPS!   Mon Sep 21, 2009 8:51 pm

TyrantHunTer15 wrote:
this dont make a ny sense im like wtf

ill try to get the hang of it

but ill just dot GFX work
I did the same thing,but no..I know its to long but you haf to read it all then when you are using Ps2dis and reading Porting,Sub Routine,Joker,DMA, you'll know the basics like me..

And this is not makin codes this is just what you NEED to know TO make a code..
Back to top Go down
View user profile http://nruretiredforum.forumotion.com
Sponsored content




PostSubject: Re: Imok's Guide of Basic MIPS!   

Back to top Go down
 
Imok's Guide of Basic MIPS!
Back to top 
Page 1 of 1
 Similar topics
-
» Item Guide--Name and Gifting Level
» Ten Basic Checkmates to Know
» Guide: Mystery Manor Achievements: Requirements and Rewards
» Yet another guide to create opening chess book [PolyGlot]
» Visual Basic Chess

Permissions in this forum:You cannot reply to topics in this forum
 :: Tutorial Center :: PSP Turorials-
Jump to: