Assembly
Variables : Registers
Unlike high
level language like C++ or Java,assembly cannot use variable because to keep
hardware simple.
- Assembly
Operands are Registers
- Limited number of special locations built directly into the hardware.
- Operation can only be performed on Registers.
- Limited number of special locations built directly into the hardware.
- Operation can only be performed on Registers.
- Benefit
1) Since registers are directly in hardware,they are very fast(faster than 1 bilionth of a
second).
1) Since registers are directly in hardware,they are very fast(faster than 1 bilionth of a
second).
- Drawback
1) Since registers are in hardware,there are a predetermined number of them.
- Solution : MIPS code must be very carefully put together to efficiently use registers.
1) Since registers are in hardware,there are a predetermined number of them.
- Solution : MIPS code must be very carefully put together to efficiently use registers.
- There are
32 registers in MIPS,because smaller is faster.Each MIPS registers is 32 bits
wide.Groups of 32 bits called a word in MIPS.
Arithmetic
Operations
- Add and
subtract, three operands.
- Two sources and one destinations.
- Two sources and one destinations.
- All
arithmetic operations have this form
- Design
Principle 1 : Simplicity Favours regularity
1) Regularity makes implementation simpler.
2) Simplicity enables higher performance at lower cost.
1) Regularity makes implementation simpler.
2) Simplicity enables higher performance at lower cost.
- Registers
are numbered from 0 to 31
- Each
register can be referred to by number or name.
- $0,$1,$2….until
$31
- In
Assembly Language, The register have no type.Operation determines how register
contents are treated.
- Comments
in assembly,hash(#) is used for MIPS comments
1) anything from hash mark to end of line is a comment an will be ignored.
1) anything from hash mark to end of line is a comment an will be ignored.
-
In assembly language,each statement, excutes exactly one of a short list of
simple commands.
1 2,3,4
where :
MIPS
Addition and Subtraction
- Syntax of
Instructions:
1 2,3,4
where :
1) Operation by name.
2)Operand getting result(destination).
3)1st Operand for operation(source 1).
4) 2nd Operand for operation(soruce 2).
2)Operand getting result(destination).
3)1st Operand for operation(source 1).
4) 2nd Operand for operation(soruce 2).
- Syntax is
rigid
1) 1 operator , 3 operands.
2) Because to keep hardware simple via regularity.
1) 1 operator , 3 operands.
2) Because to keep hardware simple via regularity.
- Addition
in Assembly
1) example: add $s0, $s1, $s2(in MIPS).
2) Equivalent to: a = b + c(in C).
3)Where MIPS registers $s0, $s1, $s2 are associated with C variables a,b,c.
1) example: add $s0, $s1, $s2(in MIPS).
2) Equivalent to: a = b + c(in C).
3)Where MIPS registers $s0, $s1, $s2 are associated with C variables a,b,c.
- Subtraction
in Assembly
1) example: sub $s3, $s4, $s5(in MIPS).
2) Equivalent to: d = e - f(in C).
3)Where MIPS registers $s3, $s4, $s5 are associated with C variables d,e,f.
1) example: sub $s3, $s4, $s5(in MIPS).
2) Equivalent to: d = e - f(in C).
3)Where MIPS registers $s3, $s4, $s5 are associated with C variables d,e,f.
0 comments:
Post a Comment