Getting started with 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

执行指令
PC++
从PC位置获取指令
分析指令

Insert picture description here
Insert picture description here
Insert picture description here

Mnemonic

Assembly language
Insert picture description here

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
    Insert picture description here

Address immediately

Operator has valueInsert picture description here

Offset addressing

Addressing according to the base address and offset, the final address is calculated on the base address and offset
Insert picture description here

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)
  • Insert picture description here

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 decimalInsert picture description here

Insert picture description here
Insert picture description here
Insert picture description here

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

Guess you like

Origin blog.csdn.net/yasuofenglei/article/details/108639190