Monday 17 December 2012

Instruction language of the computer. (By Firdaus MN.)


1.Arithmetic operation.

-Tambah dan tolak ,tiga operand.
add a, b, c  # a gets b + c

-arithmetic operasi mempunyai bentuk sebegini.

}  Rekabentuk Prinsip 1(Design Principle 1: Simplicity favours regularity)
-Kekerapan akan membuatkan implementasi mudah dibuat.
-kesederhanaan akan menjadikan prestasi lebih tinggi untuk nilai yang rendah.
Example 1:

}  C code:
a = b + c + d + e

}  Kompil  MIPS code:
add a, b, c            # sum of b and c ditempatkan di  a
add a, a, d           # sum of b, c and d ditempatkan di  a
add a, a, e           # sum of b, c, d and e ditempatkan di a

Example 2:

}  C code:
                f = (g + h) - (i + j);

}  Kompil MIPS code:

add t0, g, h   # temp t0 = g + h
add t1, i, j   # temp t1 = i + j
sub f, t0, t1  # f = t0 - t1



2.Memori  operand (Memory operand)

i)        Memori utama digunakan untuk data komposit(array,structures,dynamic data).
ii)      Untuk menggunakan operasi arithmetic.
(1)   Memuatkan nilai dari memori kedalam registers.
(2)   Menyimpan keputusan daripada register kepada memory.
iii)    Memori adalah dialamatkan dengan byte.(byte addressed)
(1)   Setiap address mengidentiti 8-bit byte.
iv)    Perkataan di selaraskan didalam memori.
(1)   Address haruslah pendaraban 4.

Example:
}  C code:
        g = h + A[8];
       g in $s1, h in $s2, base address of A didalam $s3
}  Kompil MIPS code:
       Index 8 meggunakan offset  32
   4 bytes per word
lw   $t0,32($s3)                          #load     word
add $s1, $s2, $t0
 

3.2nd compliment signed integers.

            ·        Range: –2n – 1 to +2n – 1 – 1
·        Example
·        1111 1111 1111 1111 1111 1111 1111 11002
= –1×231 + 1×230 + … + 1×22 +0×21 +0×20
= –2,147,483,648 + 2,147,483,644 = –410
·        Using 32 bits
·        –2,147,483,648 to +2,147,483,647


1.     Bit 31 adalah sign bit
      1 untuk no. negative
      0 untuk bukan no. negative
2.     –(–2n – 1) tidah boleh diwakili.
3.     Bukan No. negative mempunyai tidak bertanda(unsigned) yang sama dan 2nd-complement representasi.
4.     Sedikit no. spesifik:
        0:     0000 0000 … 0000
      –1:     1111 1111 … 1111
      Most-negative:     1000 0000 … 0000
      Most-positive:      0111 1111 … 1111









No comments:

Post a Comment