Monday 2 December 2013

LANGUAGE OF THE COMPUTERS

Machine Language vs Assembly Language


machine instruction statement

assembly language

0000 0001 0010 1011 1000 0000 0010 0000
add $t0,$t1,$t2






The instruction means: 
  • add the integers in registers $t1 and $t2 and put the result in register $t0.

  • Assembly language —(assembler)—> Machine language
                             translator

 Instruction Set
  • Instructions are the language of the machine

    Instructions Set Architecture (ISA)
  • Defines a "family" of microprocessors
  • Examples: Intel x86 (IA32), Sun Sparc, DEC Alpha, IBM/360, IBM PowerPC, M68K, DEC VAX
  •  ISA includes:
    ◦Instruction set
    ◦Rules for using instructions --> Mnemonics, functionality, addressing modes
    ◦Instruction encoding

    The Organization of A Computer

    • There are five basic components:
      1. Input - devices that writes data to memory
      2. Output - devices that read data from memory and convey result of the computation
      3. Datapath (ALU) - performs arithmetic operations
      4. Memory - the storage area (keeping data that are needed by the running programs)
      5. Control - the component of a processor that sends the signals which determine the operations of the datapath,memory,input and output
        by : Nor Izzati



    Microprocessor Operations
    The process of processor completing three basic steps to execute one machine instruction is called machine cycle



    MIPS is a reduced instruction set computer (RISC) instruction set architecture


    Register
    • 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 mfhi ("move from Hi") and mflo
             ("move from Lo")
    • stack grows from high memory to low memory
    • Register
      Number
      Alternative
      Name
      Description

                 0
      zero
      the value 0
      1
      $at
      (assembler temporary) reserved by the assembler
      2-3
      $v0 - $v1
      (values) from expression evaluation and function results
      4-7
      $a0 - $a3
      (arguments) First four parameters for subroutine.
      Not preserved across procedure calls
      8-15
      $t0 - $t7
      (temporaries) Caller saved if needed. Subroutines can use w/out saving.
      Not preserved across procedure calls
      16-23
      $s0 - $s7
      (saved 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
      (temporaries) 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
      global pointer.
      Points to the middle of the 64K block of memory in the static data segment.
      29
      $sp
      stack pointer
      Points to last location on the stack.
      30
      $s8/$fp
      saved value / frame pointer
      Preserved across procedure calls
      31
      $ra
      return address
                                  This is from Figure 9.9 in the Goodman&Miller text


      System Calls

      • used to read or print values or strings from input/output window, and indicate program end 
      •  use syscall operating system routine call 
      •  first supply appropriate values in registers $v0 and $a0-$a1 
      •  result value (if any) returned in register $v0
                                            System call functions
      Service Code
      in $v0
      Arguments Results
      print_int
      1
      $a0 = integer to be printed
      print_float
      2
      $f12 = float to be printed
      print_double
      3
      $f12 = double to be printed
      print_string
      4
      $a0 = address of string in memory
      read_int
      5
      integer returned in $v0
      read_float
      6
      float returned in $v0
      read_double
      7
      double returned in $v0
      read_string
      8
      $a0 = memory address of string input buffer
      $a1 = length of string buffer (n)
      sbrk
      9
      $a0 = amount address in $v0
      exit
      10



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 
  • have a format that comprises of four columns:



4 comments:

  1. Bagus. Sangat membantu. Thanks :)

    ReplyDelete
  2. Awesome. Thans for the info. :)

    ReplyDelete
  3. bagus3... maklumat yang berguna.. haaa..

    ReplyDelete