CHAPTER 7 : INTRODUCTION TO MIPS AND QTSPIM SIMULATOR
THE ORGANIZATION OF A
COMPUTER
-The 5 basic components of a computer are input , output ,
memory,datapath (old term called as ALU) and control with system bus that act
as the communication channel for all other components . Figure 7-1 illustrates
the organization of a computer .
1. Datapath – is also called as ALU that
perform arithmetic operations
2. Control – the components of a processor
that send the signals that determine the operation of the datapath ,memory
,input and output.
3. Memory – the storage area where
programs are kept when the program is running and contains data needed by the
running program
4. Input – devices that write data to
memory
5. Output – devices that read data from
memory and convey result of the computation
MICROPROCESSOR
OPERATIONS
-Every instruction starts by using the
program counter to supply the instruction memory . After the instruction is fetched , the register
operands used by an instruction are specified by field of that instruction
.Once the register operands have been fetched, the operation stated in machine
instruction is performed .
Machine cycle :-
FETCH
*Use the program counter (PC) to supply the
instruction address
*Fetch the instruction from memory
*Update the PC
|
DECODE
*Decode
the instruction
|
EXECUTE
*Read registers
*Execute instruction
*If necessary , write results to memory
|
INTRODUCTION
TO MIPS R2000
*MIPS or Microprocessor without Interlocked
Pipeline Stages is a reduced instruction set computer (RISC) instruction set
architecture.
*The first commercial MIPS model,R2000 was
announced in 1985.It had 32-bit general purpose registers , but no condition
code register which the designers considered it a potential bottleneck.
MEMORY
ALLOCATION
·
Text
segment – this hold the machine language code for instruction in the source
file (user program)
·
Data
segment – this hold the data that the program operates on . It is devided
into two parts . Static data
contains data that are statically allocated whose size does not change as the
program access them . On top of static data is dynamic data . This data is allocated and deallocated by the
program execute .
·
Stack segment
– this segment recides at the top of user address space . In a high level
language program ,local variables and parameters are pushed and popped on the
stack as the operating systems expands and shrink the stack segment toward the
data segment.
MIPS REGISTER CONVENTIONS
REGISTER NAME
(MNEMONIC NAME)
|
REGISTER NUMBER
|
USAGE
|
$zero
|
$0
|
Constant
0
|
$at
|
$1
|
Assembler
temporary (reserved)
|
$v0-$v1
|
$2-$3
|
Expression
evaluation and results of
|
$a0-$a3
|
$4-$7
|
Arguments
to asubroutine
|
$t0-$t7
|
$8-$15
|
Temporary
(not preserved across a function call)
|
$s0-4s7
|
$16-$23
|
Saved
temporary (preserved across a function call)
|
$st8-$t9
|
$24-$25
|
More
temporary
|
$gp
|
$28
|
Global
pointer (preserved on call)
|
$sp
|
$29
|
Stack
pointer(preserved on call)
|
$fp
|
$30
|
Frame pointer(preserved
on call)
|
$ra
|
$31
|
Return
address (automatically used in some instructions)
|
DATA REPRESENTATION
-In order to understand how to manipulate data and perform computation in
MIPS
Program, you must understand how data is represented by a computer in a
view of MIPS programming language.
ASCII
representation of character
NUMBER REPRESENTATION
-Although computers operate on binary numbers,in MIPS number is
represented in decimal system or hexadecimal system.When you need to insert
number into a register , you have to remember what kind of number system that
you want to write in the program.For example, to load number 16 into register
$5 , we have two ways to represent decimal 16 in MIPS :
1.
Ori $5 , $0 , 16 #load number 16 into register
$5
2.
Ori $5 , $0 , 0x10 #load number 16 into register
$5
QtSPIM
-QtSPIM is a self-contained simulator that runs MIPS32 programs
that emulates MIPS processor.MIPS processor has 32 general purpose registers ,
each holding 32 bits.The simulator runs on all Microsoft Windows,Mac OS x and
Linux.
OPENING QtSPIM
1.
Register
display – It list all 32 general purpose registers with the content where
can choose to display in hex , binary , or decimal by right click the mouse on
the register display . For beginner , choose Int Regs[16] to look the content of the register . Initially , the
content of the registers is zero except for the stack pointer , which points to
an empty stack.
2.
Data
display – Contain user User Data Segment , User Stack and Kernel Data
Segment.It shows the MIPS memory that hold data programmed by the user and
usual data that has been pushed into the stack.
3.
Text
Display – The first column is the addresses of the memory location of the
machine instruction displayed in hexadecimal on the second column . Whereas,the
third column is the assembly code to represent the machine instruction .
4.
SPIM
Messages – It shows the messages from the simulator whether the assembly
code has error(s) or not
No comments:
Post a Comment