mips quick tutorial - MIPS Architecture and Assembly...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
MIPS Architecture and Assembly Language Overview Adapted from: (SPIM).html [ Register Description ] [ I/O Description ] Data Types and Literals Data types: Instructions are all 32 bits byte(8 bits), halfword (2 bytes), word (4 bytes) a character requires 1 byte of storage an integer requires 1 word (4 bytes) of storage Literals: numbers entered as is. e.g. 4 characters enclosed in single quotes. e.g. 'b' strings enclosed in double quotes. e.g. "A string" Registers 32 general-purpose registers register preceded by $ in assembly language instruction two formats for addressing: using register number e.g. $0 through $31 using equivalent names e.g. $t1, $sp special registers Lo and Hi used to store result of multiplication and division not directly addressable; contents accessed with special instruction mfhi ("move from Hi") and mflo ("move from Lo") stack grows from high memory to low memory This is from Figure 9.9 in the Goodman&Miller text Register Number Alternative Name Description 0 zero the value 0 1 $at ( a ssembler t emporary) reserved by the assembler 2-3 $v0 - $v1 ( v alues) from expression evaluation and function results 4-7 $a0 - $a3 ( a rguments) First four parameters for subroutine.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Not preserved across procedure calls
Image of page 2
8-15 $t0 - $t7 ( t emporaries) Caller saved if needed. Subroutines can use w/out saving. Not preserved across procedure calls
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
16-23 $s0 - $s7 ( s aved values) - Callee saved. A subroutine using one of these must save original and restore it before exiting. Preserved across procedure calls 24-25 $t8 - $t9 ( t emporaries) Caller saved if needed. Subroutines can use w/out saving. These are in addition to $t0 - $t7 above. Not preserved across procedure calls. 26-27 $k0 - $k1 reserved for use by the interrupt/trap handler 28 $gp g lobal p ointer. Points to the middle of the 64K block of memory in the static data segment. 29 $sp s tack p ointer Points to last location on the stack. 30 $s8/$fp s aved value / f rame p ointer Preserved across procedure calls 31 $ra r eturn a ddress See also Britton section 1.9, Sweetman section 2.21, Larus Appendix section A.6 Program Structure just plain text file with data declarations, program code (name of file should end in suffix .s to be used with SPIM simulator) data declaration section followed by program code section Data Declarations placed in section of program identified with assembler directive .data declares variable names used in program; storage allocated in main memory (RAM) Code placed in section of text identified with assembler directive .text
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern