Computer Instructions_Introduction to Assembly Instructions
- The computer directs the computer to work through instructions.
- The CPU is driven by the clock, constantly reading the PC pointer to the instruction, and increasing the PC pointer, reading the instruction from the memory and executing it.
- Different CPU architectures use different instructions. Currently the most widely used is RISC (Reduced instruction set computer, reduced instruction set)
Machine cycle
Mnemonic
Assembly language
Addressing Model
- Part of the instruction set, determines how many operators the instruction has and how the address is calculated
- Don’t remember which addressing modes there are. This is not important. Different addressing modes have different instruction sets. What you can see by learning addressing modes is how to make good use of binary instructions.
Register addressing
- Operators are registers, using n bits to address 2 to the nth power of registers
Address immediately
Operator has value
Offset addressing
Addressing according to the base address and offset, the final address is calculated on the base address and offset
PC relative addressing
- The position of the next PC pointer depends on the distance from the current position to the Label (the difference between the current code line and the code line where the Label is located)
Instruction type
Memory read and write
- The load/store instruction is used to read/write memory from memory. There are usually multiple versions of implementation. The mnemonic is
load class: lw, lb, lh
store class: sw, sb, sh
computation
- Addition, subtraction, multiplication, division, etc.
Immediate addressing addi, subi, divi, mult, etc...
Register addressing: add, sub, div, mult, etc.
Other addressing methods - Bit operations and/or/xor, etc. (omitted)
-
Floating point
Floating point decimal
Comparison operation
Compare where to compare the size of two values
slt(set if less than)
Conditional jump
- Relative addressing
j LABEL - Register indirect addressing
jr $a0 - All-in-one
jal LABEL
to sum up
- opcode represents the type of instruction, opcode also determines the addressing mode
- Indirect addressing, indirect addressing, offset addressing, don't memorize it by rote, understand
- Floating point numbers exist as integers in computers