CSc 116 notes

Previous page Back    Next  Next page  Contents

3) MIPS architecture


Memory organization

The purpose of memory is to store groups of bits, and deliver them (to the processor for loading into registers) upon demand. Most present-day computers store information in multiples of 8 bits, called a byte (or octet). Most also assign a numeric address to each byte. This is convenient because characters can be stored in bytes. Memory addresses are 32-bit numbers, ranging from 0x00000000 to 0xFFFFFFFF. This is a large amount of memory, most computers do not have actual memory for all of this "address space." Memory can hold both program instructions and data. One function of the operating system is to assign blocks of memory for the instructions and data of each process (running program). Another thing a good operating system does is to allow many processes to run concurrently on the computer.

The SPIM simulator always assigns your program to these fixed, even numbered locations, for your convenience:

A word generally means the number of bits that can be transferred at one time on the data bus, and stored in a register. In the case of MIPS, a word is 32 bits, that is, 4 bytes. Words are always stored in consecutive bytes, starting with an address that is divisible by 4. Caution: other processors, other definitions. Some people refer to 16 bits as a word, to others it may mean 64 bits.

Storage order of words

How should one store a word (say, a register holding a number) in 4 bytes? There are two equally valid schemes: starting with the lowest numbered byte,

(These terms come from Gulliver's Travels by Jonathan Swift, in which two parties are at war over whether hard-boiled eggs should be opened at the little end or the big end of the egg.)

MIPS processors can be either! However, the SPIM simulator uses the method of its host processor, since our lab uses intel processors, it is little-endian.
One result of this is that character data appear to be stored "backwards" within words. Here is a representation of part of memory, storing the characters "Help" (0x706c6548 - looks backwards in SPIM) and then the number 32766  (0x00007ffe).

0x10000000 0x48 ("H")
0x10000001 0x65 ("e")
0x10000002 0x6c ("l")
0x10000003 0x70 ("p")
0x10000004 0xfe
0x10000005 0x7f
0x10000006 0x00
0x10000007 0x00

Processor organization

What a processor does, its function, can be completely described in terms of its registers, where it stores information, and what it does in executing each instruction. in the MIPS, all registers hold 32 bits.

Registers

The program counter (PC) always holds the address of the next instruction. Normally it is incremented every time an instruction is executed. This controls the flow of the program.

There are 32 general purpose registers, numbered 0..31. In assembly language, they also have symbolic names, which are shown in the register window of the SPIM simulator. These names suggest conventions for use of the registers. Registers may be referred to by name or number in assembly language, for instance, register 4 can be referred to as $4 or $a0, and is usually used for an argument to a procedure.

The first and last registers are special:

The conventions for usage we will adhere to are (a compiler for a high-level language may or may not adhere to these):

Instruction set

Instructions can be grouped into the following catagories. The rest of the course covers the operations performed by the instructions, and how to use them in writing programs. Here I will just give an example of each type of instruction.

There are also floating point instructions and registers, for real numbers.


Prepared by Lin Jensen, Bishop's University, 12 January 1999, updated 14 December 2004

Previous page Back   Next  Next page       Contents