Getting Started Programming MIPS Assembly
- "But I Don't Understand how to ..."
- Neither did I, but this is doable.
- Start early. You will be in a primitive environment. Things might not work as you want them to.
- Learn how to use the tools while you can.
- Add break points.
- Learn how to set break points
- Find memory locations
- Learn how to print things out.
- Figure out how to print out debugging information.
- You should get help when you need it.
- Why program in assembly?
- I am not a devotee to assembly language.
- In fact, I was one of the people who argued to eliminate the class.
- It does provide some insight for programmers.
- It is required for compiler, operating systems and other programmers.
- But it is NOT portable.
- And it is sometimes hard to do.
- And it is very very cryptic.
- This is one case were documentation is very important.
- I can see 1 comment for each line of code to be too sparse.
- Use three levels of comments.
- Block comments before routines to say what the routine does.
- Comments at each C/C++ line of code, give that code
- Comments on each assembly line of code. What is it doing.
- All that aside, we program in assembly because we NEED to know how it works for this class.
- Why MIPS?
- Wouldn't Intel assembly be better?
- Well, No!
- MIPS assembly fits on one page (MIPS Reference Data in the front of the book)
- It is a semi-modern assembly language.
- And we need it for the chip we will be studying.
- But I can't get a job programming MIPS
- Why would you want to?
- And if you do, you can easily learn whatever language you need.
- And why would you want to?
- Why spim/xspim?
- It is the one I use.
- It is compiled on all of my machines.
- It is supported by the book.
- And I get to set the standard.
- But I like ...
- Go ahead, use whatever you want.
- But it must run on my machine, simulator, ...
- System Issues
- On my 64 bit machines, I had to modify the Configure script. here is a copy of my modified script.
- Naming Conventions.
- To get the color highlighting I liked, I had to add mips.vim to my vi syntax files.
- I had to modify the filetype.vim to use these colors
- This means I need a unique extension for my mips assembly code.
- I call my files .mips, but .s or .asm will do.
- Creating Files
- Use your favorite editor.
- Indentation is very useful.
- label:<tab>op-code<tab>op1,<space>op2
- Starting xspim
- Running xspim
- A quick tour of program 1.