Hello. Here we
go again. This time we’re going to discuss about no other but the language of the computer. Everybody
does know that computers do not understand the daily English language human
use. The users communicate with the computers by using specific machine
language. Nah, now that’s the exact topic that we’re going to be discussing
about here.
Now we’re
introducing the Instruction Set Architecture or globally known as ISA. This ISA thing is seldom officially defining
a ‘family’ of microprocessors that builds up a set of instruction to be used to
communicate to a machine. The examples of ISA that are widely used are Intel
x86 (IA32), Sun Spare, DEC Alpha, IBM/360, IBM PowerPC, M68K and DEC VAX. Formally
and normally, the interface between a user and a microprocessor is defined by
this instruction set. Internally, ISA includes instruction set, instruction
encoding and some important rules of instruction using that are mnemonics,
functionally and also the addressing modes.
Next is the
introduction to the SPIM and MIPS. Generally, SPIM is the backward spelling of
MIPS. SPIM is the simulator of MIPS that reads assembly language files of MIPS
and then translates it to machine language. SPIM also executes the translated
the machine language instructions before showing the contents of registers and
memory. SPIM also works as the debugger that is able to support break-points
and single-stepping. Other than that, SPIM provides basic operating system such
as services and simple input/output. Besides, please be glad to use SPIM
simulator because it is available for free online.
Right then
after that, we’re discussing about the arithmetic operations in instruction
language which includes addition, subtraction and many other. There will be
three operands needed to operate the addition and subtraction where two
operands acts as the sources whereas another one is the destination. For the
code of [a,b,c], explaining a is the destination keeping the result of b plus
c. As simple as that!
Now we move
on to register operands. Arithmetic instructions of computer surely use
register operands. For your information, MIPS has 32x32-bit of register files
that are used for accessed data which numbered from 0 to 31. A 32-bit data is
called a ‘word’. For temporary values, the assembler is named as $t0, $t1, $t2,
$t3, $t4, $t5, $t6, $t7, $t8 or $t9. On the other hand, the assembler is named
as $s0, $s1, $s2, $s3, $s4, $s5, $s6 or either $s7 if it’s a saved variable. Take
note that the second Design Principle says that a smaller number produces a
faster output. If a simple one states [add a,b,c ] like the previous example I gave
explains ‘a’ stores the value of ‘b’ + ‘c’,
then [add $s0, $s1, $s2] means that $s0 takes the value of ‘$s1’ adds ‘$s2’.
To compare,
registers are a lot faster than to be accessed than the memory. Os why use
memory?
Next, let’s
move on to the memory operands. Composite data like arrays, structures and
dynamic data uses main memory. It is used for applying operations of arithmetic
such as values loading from memory into registers and also result storing from
register to the memory. In addition, memory is addressed in byte where each address
identifies an 8-bit byte. Don’t forget that the addresses must be in a multiple
of 4 single addresses to form a word aligned in memory.
The next one
is about the representing instructions. Instructions are encoded in binary
which is called as machine code or computer code. MIPS instructions are encoded
as 32-bit instruction words. There are 3 instructions
formats altogether, composing R-Format, I-Format and J-Format.
These are
some simple formula and explanations over the all three instruction formats. The
first one is the r-format instruction. Remember that when all operands
in the MIPS code are registers, then the code must be not another but the
r-format. The example of MIPS code using r-format instruction is as below.
Add $8, $9, $10
The second
one is the j-format instruction. A code that uses this type of instruction
format is the code that has one and only operand. For example is as below. As you
see, the code contains one operand only.
J 10000
Last but not
least is the i-format instruction. The
rule of this type of format is the other than stated for r-format and j-format
instructions.
bne $8, $9,
-100
lw $8, 100 ($9)
addi $8, $9,
100
The next
essential thing you need to know about language of the computers is addressing. The first type is the
branch addressing where the instructions specify opcode, two registers and
target address. Most of the branch targetsa re near the branch itself, either from
the front or backward. If the branch target is too far ffset, the assembler
will rewrite the code. For example,
beq $s0, $s1, L1 -> bne $s0, $s1, L2
jL1
Next one is
the jump addressing. Jump including ‘j’ and ‘jal’ targets can be anywhere to
find in the text segment. To summarize, the addressing mode of computer instructions include all 5 mode
altogether. There are register addressing, pseudodirect addressing, base
addressing, immediate addressing and PC-relative addressing.
The code is
said to be using register addressing mode when the code has the sources
and destinations are all registers. The example is as follows.
add $8, $9, $10
Next, a machine
code having one and only operand will be directly categorized as the pseudodirect
addressing mode. Example:
j 10000
After that,
let’s move on to the base addressing mode. A code using base addressing
mode has its final operand having brackets on it. Example:
lw $8, 100 ($9)
The fourth
one is the immediate addressing mode. If the final operand in the code is a
constant, then the code is using this kind of addressing mode. Example:
addi $8,$9,
100
Finally, let’s
talk about PC-relative addressing mode. The code’s output is a branch. For
this mode, the code usually includes the operation of Branch on Equal (beq),
Branch on Not Equal (bne) and so on that has the initial b. The example is as
follow:
bne $8, $9,
-100
In
conclusion, we have three instruction formats and five addressing modes to be
understood of. They are all as simple as a b c. You just need to put your
interest and confide in yourself to improve. Okay, see you later in the next
entry!
^_^
No comments:
Post a Comment