Showing posts with label MIPS. Show all posts
Showing posts with label MIPS. Show all posts

Thursday, December 8

CHAPTER 5: MIPS SIMULATOR

As we know, MIPS is the language for assembly language. But how do we use this language?

Like a pen, we need a piece of paper to write. Paper is the tools for the pen to be functioned. So is the MIPS. MIPS need a software as its platform to function.

5.1 SPIM
   
Spim is a self-contained simulator that runs MIPS32 programs. It reads and executes assembly language(MIPS) programs written for this processor and provides a simple debugger and minimal set of operating system services.
   
There is a few types of Spim and the one that we will learn is QtSpim.

List of Spim
1. spimsal (older version of spim)
2. Spim
3. xSpim
4. PCSpim
5. QtSpim

5.1 QtSpim

QtSpim is the latest version of spim and have been widely used nowaday. It is simpler and easier than previous version. Let's watch a video on how to use QtSpim Simulator!

Hopefully you guys find this information useful. That's all for me, thank you.

Reference 1
Reference 2


Saturday, October 29

CHAPTER 4: MIPS (Million Instructions Per Second)

Well hello! *do i need to introduce myself??

       For this chapter, I will be the one who will explain to you what is MIPS. So, what you will learn here is:

      1. MIPS Architecture
      2. Register       3. Comment (#)      4. Assembly Instruction     5. Memory Operand


4.1 MIPS Architecture
          
    - a unit of computing speed equivalent to a million instructions per second.
    - an early RISC processor. RISC processors typically support fewer and much simpler instructions.

4.2 Register

    - limited number of special location built directly into the hardware
    - needd to perform the operation (cannot perform without it)
    - very fast since registers are directly in hardware
    - only 32 registers in MIPS
  • why? smaller the register, faster the performance
    - 1 register is 32 bits wide (32 bits = a word)
    - 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

4.3 Comment

      In programming language, we create comment by putting '//' at the front. Hence,in assembly language (coding in MIPS), we use put '#' (hashtag) before the words.

#comment

    - hash (#) is used for MIPS comments
  • anything from hash mark to the end of line is a comment
  • will be ignored in the coding

4.4 Assembly Instructions

    - in assembly language, instruction is a statement
    - each instruction is executed exactly one with a simple command
    

     Syntax of instructions:

     The arrangement of coding ::       1(ON)  2(Ds),3(S1),4(S2)

     1(ON) ---> operation name (ADD, SUB, etc)
     2(S0)  ---> operand for getting result or we called it ('destination')
     3(S1)  ---> 1st operand for operation called ('source1')
     4(S2)  ---> 1st operand for operation called ('source2')

     example :   add  $s0,$s1,$s2 
    
     - Syntax is rigid
  • 1 operator (add,sub, etc), 3 operands >> to keep hardware simple and fast

     :: Addition in assembly
         Example:               add  $s0,$s1,$s2  (in MIPS)
         is equal to:            a = b + c (in C)
   
     :: Subtraction in assembly
         Example:               sub  $s3,$s4,$s5  (in MIPS)
         is equal to:            d = e - f (in C)

4.5 Memory Operand
    
     - Main memory used for omposite data
     - To apply arithmetic operations
  • load values from memory into registers
  • store result from register to emory
     - memory is byte addressed
  • each address identifies an 8-bit byte
     - words are aligned in memory
  • address must be a multiple of 4

That's all from me. Hope you enjoys reading mine! Ppyong~


                

[EXTRA] CHAPTER 6: LANGUAGE OF THE COMPUTERS - Instruction Set Architecture (ISA)

Based on what I have introduced in the previous post, this time it will be about instruction set. If all I talked about was briefly the languages that computers use, now I will share about how it is being laid out in programs.


The high-level language is used to write out the Instruction Set Architecture (ISA). But first,

WHAT IS AN INSTRUCTION SET?

Instruction set is basically a set of commands that is to be carried out by the Central Processing Unit (CPU) of the computer in terms of machine language.

Simple instructions are made up of bit strings. Inside every instructions there are several important specifications that needs to be encoded.

1. Opcode

The first 6-bit of an instruction set is the opcode (“operation code”). It tells us what operation the CPU must carry out. Mnemonic language is used rather than hexadecimal code for simplicity and readability. 

2. Parameters

The rest of the instruction set contains parameters for the operation to work on. It can have registers, values and etc.


Now, ISA is the main interface between programming language and software with the main hardware component inside a computer. ISAs have unique assembly language that specifies how the program will run in a computer. 


WHERE INSTRUCTIONS ARE STORED?


Since instructions are sets of bit strings, there are mostly many instructions for every program and this requires some space in the memory. Inside the memory, the instructions are lined up in a consecutive manner with an address for each line of instruction. 

The relationship between CPU and Memory

Besides memory, a register also holds data temporarily. Registers can retrieve data whenever it is needed like how a memory works, though only a small volume can be stored. 

Example of instruction set:

MIPS Instruction Set

It uses 32-bit instructions which has R-Type Instructions, I-Type Instructions and J-Type Instructions. The opcode identifies the instruction which allow us to identify the instruction type.

x86 Instruction Set

It is one of the series of computer microprocessor developed by Intel for Intel 8086 CPU. It provides backward compatibility for older piece of hardware or software without the need to modify. Therefore x86 is the most prevalent ISA for desktop use. 



Glossary:

Mnemonic language: In assembly language, mnemonic is used to abbreviate various operations.
Parameters: Characteristics to customize a program.
Address: A unique number given to specify a particular set of instruction in memory.
Registers: Very small volume of memory located in the CPU itself.
Bit string: A sequence of bits that is represented by binary data. 


References:

Source 1
Source 2
Source 3

Picture credits:

https://www.eeweb.com/electronics-quiz/instruction-set-architecture
http://blog.biicode.com/bitscan-cpp-library-bit-strings/
http://math.hws.edu/javanotes/c1/s1.html


Ok so hope that summarizes what ISA is all about. Feel free to check out other topics for this syllabus! Your comments are highly welcome.

Til' next time, thanks for reading!