User Tag List

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: IMOKS Tutorial to the baby step basics of MIPS

  1. #1
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    IMOKS Tutorial to the baby step basics of MIPS

    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.
    Last edited by IMIGHTOVERKILL; 07-02-2009 at 10:16 AM.
    Join Date
    11-10-2008!I joined exactly one year before MW2 !

  2. #2
    senior newbie XD

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    oooh thnxs, needed this

    When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car. \,,/, rock on \,,/,

  3. #3
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    this is good i kno all the common Mips already still trying to learn the others
    Get At Me Bl4Ck.KiD... Aka BK
    Future Rapper - Spits Fire
    Psp Coder - Mips, C
    Web Designer - HTML, Javascript, Some PHP
    Computer Programmer - Currently Learning C/C++, Visual Basic, Pascal, Brainfuck, Python, Ruby

  4. #4
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    Quote Originally Posted by Bl4Ck.KiD... View Post
    this is good i kno all the common Mips already still trying to learn the others
    Have any ideas what I could do next as all I have thought of so far, is packet stuff, advanced MIPS commands and functions, using and writing to the stack, and explaining the basics of function re-writing which idk but Im sure theres plenty more I could do.
    Join Date
    11-10-2008!I joined exactly one year before MW2 !

  5. #5
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    Quote Originally Posted by As Known As View Post
    Have any ideas what I could do next as all I have thought of so far, is packet stuff, advanced MIPS commands and functions, using and writing to the stack, and explaining the basics of function re-writing which idk but Im sure theres plenty more I could do.
    thats what i would read up about if you make those
    Get At Me Bl4Ck.KiD... Aka BK
    Future Rapper - Spits Fire
    Psp Coder - Mips, C
    Web Designer - HTML, Javascript, Some PHP
    Computer Programmer - Currently Learning C/C++, Visual Basic, Pascal, Brainfuck, Python, Ruby

  6. #6
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    Im still a little puzzled on this but i am getting the hang of it...i am a big noob at this and the only code i ever made by myself was inf CE on socom........and i sometimes make inf ammo but they end up as DMAs......
    CoDeZ DnT RuIN gAmEz....tHe BaStErDZ wHo aBuZe tHeM dO:soda:
    [02-11, 16:46] CoDeX I want to be an
    aborted fetus!
    [02-11, 16:45] Papa fritos THE BONG OF DESTINY!!!!!!
    [02-11, 16:45] DeathWish NO!
    [02-11, 16:45] Papa fritos No

  7. #7
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    nice work u guys even though it easy lol
    My Ftb2 Acc(storm.j.3.s.u.s) Ranked 18 Overall:laugh:
    PART OF 1337
    ♣™ßaßy.j.3.s.U.sâ„¢♣LEGENDOFSOCOMFTB2ONLINE CODER

  8. #8
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    good post there,im getting the hang of it.but still dont know how to make a code yet.

  9. #9
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    Well follow them dude its simple read guides trust me

  10. #10
    IMOKS Tutorial to the baby step basics of MIPS

    User Info Menu

    Re: IMOKS Tutorial to the baby step basics of MIPS

    Finally a tut that doesn't have a single error! Good job, this will help beginners.

    -FBD

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •