Followers

MIPS - Intro

sorry for the long wait all our followers...
we have been busy with other projects...
and now we are back with some interesting notes...
hope you all will like it... =)
MIPS

- its acronym is Microprocessor without Interlocked Pipeline Stages
- reduced instruction set computer (RISC) instruction set computer (ISA) 
- it has 32-bit general purpose registers

1.0 Memory Allocation

-MIPS processor typically divided its memory by 3 parts.....
     i) text segment : hold machine language code for instructions in 
                                    the source file (user program)
    ii) data segment : holds  the data that the program operates on. 
                                   : divided with 2 parts 
           > static data : the size data that allocated is not changes 
                                     when a program access them
           > dynamic data : the data is allocated and deallocated 
                                           by the program executes
   iii) stack segment : resides at the top of user address space

2.0 Register

- 32-bit general purpose registers (0 - 31)
$0 always has zero value
- $at ($1), $k0 ($26) and $k1 ($27) are reserved 
      > for assembler and operating system 
      > not be used by the user programs and compiler
- $a0 - $a3 ($4 - $7) used to pass 1st 4 arguments to routines
- $v0 & $v1 ($2 - $3) used to return values from functions
- $t0 - $t9 ($8 - $15, $24, $25) are caller-saved registers 
      > hold temp values 
- $s0 - $s7 ($16 - $23) called as callee-saved registers
      > hold long-lived values that should be preserved across calls function
- $gp ($28) a global pointer 
      > point to the middle of 64k block of memory in static data segment
- $sp ($29) stack pointer
      > point last location of stack
-$fp ($30) is a frame pointer
- $ra ($31) has return address written jal instruction

3.0 System Call

how a program requests a service from an operating system's kernel  
- include :- 
      > hardware related services (e.g. accessing the hard disk)
      > creating and executing new processes 
      > communicating with integral kernel services (like scheduling)
- provide an essential interface between a process and the operating system

System call function
      
Service
System call code
Arguments
Result
print_int
1
$a0 = integer

print_float
2
$f12 = float

print_double
3
$f12 = double

print_string
4
$a0 = string

read_int
5

$v0 = integer
read_float
6

$f0 = float
read_double
7

$f0 = double
read_string
8
$a0 = buffer
$a1 = length

sbrk (allocate memory)
9
$a0 = amount
$v0 = address
exit
10


print_char
11
$a0 = char

read_char
12

$v0 = char

4.0 Assembly Language 

- made up of plain text file 
- made up of 2 type statements 
     i) assembler directive
          > tell assembler how to translate a program 
          > cannot be translated into machine code 
     ii) executable instruction 
          > a program will be translated into machine code 
          > sometimes called as program code
- contain 4 columns

Column 1
Column 2
Column 3
Column 4
              
1) Column 1 : Label (Optional)

- mark specific point in a program code

2) Column 2 : Opcode (Operation Code)

- basic operation and format of an instruction

3) Column 3 : Operand 

- contain 
     i) registers 
     ii) shift amount
     iii) label to jump into 
     iv) constant
     v) address

4) Column 4 : Comment 

- have ' ' on a line 
- MIPS simulator will skip this comment

Thanks for reading, please leave your comment here.

No comments:

Copyright of Comorarch group.