Assembly Language: Alice Andrea Briceño Murcia
Assembly Language: Alice Andrea Briceño Murcia
Assembly Language: Alice Andrea Briceño Murcia
1
ARCHITECTURE
Computer’s Architecture
3
“
We motivate the design of the MIPS
architecture using four principles:
(1) Simplicity favors regularity;
(2) Make the common case fast;
(3) Smaller is faster;
(4) Good design demands good compromises.
4
ASSEMBLY
LANGUAGE
5
1.
INSTRUCTIONS
6
Design Principle 1: Simplicity favors
regularity.
7
Design Principle 2: Make the common case
fast.
t variable temporary to
store intermediate
result.
Using multiple assembly
language instruction to
perform more complex
operations is an example of
the second design principle
of computer architecture.
Thus, MIPS is a reduced
instruction set computer
architecture
8
2.
OPERANDS
Registers, Memory and Costants
9
Registers, Memory and Costants
10
Design Principle 3: Smaller is faster.
“
Instructions need to access operands quickly so
that they can run fast. But operands stored in
memory take a long time to retrieve. Therefore,
most architectures specify a small number of
registers that hold commonly used
operands. The MIPS architecture uses 32 registers,
called the register set or register file. The fewer
the registers, the faster they can be accessed.
11
The Register Set
12
add instruction with register operands
13
TRANSLATING HIGH-LEVEL CODE TO ASSEMBLY
LANGUAGE
14
MEMORY
Memory
MIPS uses the load word instruction, After the load word instruction (lw)
lw, to read a data word from memory is executed, $s3 holds the value
into a register. Code Example loads 0xF2F1AC07, which is the data value
memory word 1 into $s3. the base stored at memory address 1.
address is $0, which holds the value
0, and the offset is 1, so the lw
instruction reads from memory
address ($0 + 1) = 1.
17
WRITING WORD-ADDRESSABLE MEMORY
Similarly, MIPS uses the store word These examples have used $0 as the
instruction, sw, to write a data base address for simplicity, but
word from a register into memory. remember that any register can be
Code Example writes the contents of used to supply the base address.
register $s7 into memory word 5.
18
BYTE-ADDRESSABLE MEMORY
19
ACCESSING BYTE-ADDRESSABLE MEMORY
Code Example 6.8 shows how to read and write words in the
MIPS byte-addressable memory. The word address is four times
the word number. The MIPS assembly code reads words 0, 2,
and 3 and writes words 1, 8, and 100.
20
Big- and little-endian
memory addressing
In big-endian machines,
bytes are numbered starting
with 0 at the big (most
significant) end. In
little-endian machines,
bytes are numbered starting
with 0 at the little (least
significant) end.
Load word and store word, lw and sw, also illustrate the use of constants in MIPS
instructions. These constants are called immediates, because their values are
immediately available from the instruction and do not require a register or memory
access.
22
Design Principle 4: Good design demands
good compromises.
A single instruction format would be simple but not flexible. The MIPS instruction set
makes the compromise of supporting three instruction formats.
23
FIN