Assembly language notes 01_Overview 1 (Summary of small turtle notes)

1. Machine language

Machine language is a collection of machine instructions

Machine language is a collection of machine instructions.

The machine instruction is 01 string

Machine instructions are the only instructions that a computer (CPU) understands and are composed of 0 and 1.

Three ways of expressing instructions

  1. Machine instruction: 01010000

  2. Assembly language: PUSH AX

  3. Level pulse: 8 pulses in sequence

2. The production of assembly language

The difference between assembly instructions and machine instructions lies in the way the instructions are expressed

The difference between assembly instructions and machine instructions lies in the way the instructions are expressed.

Assembly language is a symbolic language, and the correspondence relationship with machine language is basically a one-to-one correspondence.

A machine language instruction corresponds to an assembly language instruction.

ollydbg

Assembly language process

The assembly instructions are processed by the compiler (similar to replacement, not completely replacement), turned into machine code, and handed over to the computer.

3. The composition of assembly language

The core of assembly language is assembly instructions, which determine the characteristics of assembly language.

Directives and other symbols can be grouped into one category.

Assembly instructions

Mnemonic for machine instructions.

Pseudo-instruction

Executed by the compiler.

Other symbols

Recognized by the compiler.

4. Memory

The role of the CPU: control the entire computer and perform calculations

The CPU is the core component of the computer , which controls the operation of the entire computer and performs calculations .

Information requirements for CPU work: instruction + data

If you want a CPU to work, you must provide instructions and data to it .

Information requirements for CPU to read and write memory

To read and write data, the CPU must interact with external devices (the standard is the chip) for three types of information:

  1. Address information: the serial number (address) of the storage unit .

  2. Control information: device selection, read or write command.

  3. Data information: data read or written.

Classification of memory

Classified by read and write attributes

Random access memory RAM

ROM

The difference between RAM and ROM

After power off, the data in RAM will be lost, but the data in ROM will not.

Classified by function and connection

Random access memory RAM

ROM with BIOS

RAM on the interface card

5. BIOS

BIOS is the basic IO system

Basic Input/Output System, basic input and output system.

BIOS is a software system provided by manufacturers of motherboards and various interface cards (graphics cards, network cards, etc.).

The knowledge of the motherboard and interface card is at the back.

BIOS is in the ROM of the motherboard and some interface cards

The BIOS is not only available on the motherboard, but a ROM that stores the corresponding BIOS is inserted on the motherboard and some interface cards.

The role of BIOS

The most basic input and output can be performed by the corresponding hardware device through the BIOS.

The interface you see when booting up is that the BIOS is working. It is checking whether the CPU, memory, hard disk, keyboard, etc. are plugged in properly.

If the virus enters the BIOS, the anti-virus software will not be able to kill it.

6. Internal memory

Internal memory is memory, a big RAM

Generally speaking, the memory stick and memory are internal memory, a large RAM.

The role of internal memory

The function of the memory in the PC is second only to the CPU. Without the memory, no matter how good the CPU is, it cannot work.

Disk is different from memory. If the data or program on the disk is not read into the memory, it cannot be used by the CPU.

Graphics cards, network cards, BIOS, etc. all have its (memory) memory.

The CPU and memory read and write very fast, but the memory and disk read and write speeds are relatively slow.

The content of memory storage and its function

The memory stores instructions and data.

instruction

The instructions tell the CPU how to operate .

data

Data tells the CPU what operating what .

The relationship between instructions and data

  • Instructions and data are application concepts.
  • In the memory or disk, there is no difference between instructions and data, they are all binary information.

Depending on how the programmer uses it , the binary information processed by the CPU can be assembly code (instruction) or data, as follows:

  • 1000100111011000

    • 89D8H

      Data, the H at the end means Hex, hexadecimal. B stands for binary, and decimal has no suffix.

    • MOV AX,BX

      Program, paste the contents of register BX into register AX.

7. Register

A register is a device that can store data in a CPU. There are multiple registers in a CPU.

Register is a kind of memory that is lower than memory and L2 cache and closer to the CPU.

Storage unit

The storage unit is a part of the memory

The memory is divided into several storage units.

Each storage unit stores one byte

1 byte (Byte) = 8 bits (bit) 1B=8b

The storage unit is numbered starting from 0

The storage units are numbered sequentially starting from 0. Computers start counting from 0.

E.g:

A memory has 128 storage units. Number 0-127.

There is a memory in the graphics card, called the video memory, and the data is stored in the video memory. The GPU in the graphics card maps the data in the video memory to the screen. The GPU is much faster than the CPU. 3D games have very high requirements for graphics cards.

8. Bus

The information that computers transmit and process is all electrical signals , and electrical signals must be transmitted by wires.

In the computer, there are special wires connecting the CPU and other chips, which are called buses.

Bus classification

At the physical level, the bus is a collection of wires.

Logical classification:

Address bus

The CPU specifies the memory unit through the address bus. Therefore, the CPU can address as many memory cells as the address bus can transmit as many different pieces of information.

One CPU has NNN address buses, the width of the address bus isNNN , it can find2 N 2^N2N memory units.

Addressability

The addressing capacity is 8KB, that is, 8*1024 bytes can be found, and the bus width is 13.

Data Bus

A few data buses can transmit a few bits at most.

Control bus

The control bus is a collection of different control lines. The CPU controls external devices through the control bus.

How many control buses there are means how many kinds of control the CPU provides to external devices.

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-CxE7nGnr-1616637193286)(https://i.loli.net/2019/02/09/5c5e86697bacc.png )] Memory is not only a memory stick, but also video memory, network card memory, etc., which are arranged linearly.

9. Motherboard

Every PC has a motherboard.

There are core devices (CPU, memory) and some main devices on the motherboard, which are connected by buses (address bus, data bus, control bus).

10. Interface card

In a computer system, all devices that can be controlled by a program must be controlled by the CPU.

The CPU cannot directly control external devices, such as displays, speakers, and printers.

What directly controls these devices to work is the interface card inserted in the expansion slot.

11. Memory Address Space

The memory address space allocation of different computer systems is different.

The logic of all types of memory is the same

All types of memories are physically independent devices:

But they are logically the same in two points:

  1. Are connected to the CPU bus

  2. When the CPU reads or writes them, it issues memory read and write commands through the control bus.

What is the memory address space

The width of the address bus of a CPU is 10, and that can address 1024 memory units. These 1024 memory units that can be found constitute the memory address space of this CPU.

The various types of memory combined into one memory logically :

For the CPU, the storage units in various memories in the system are all in a unified logical memory, and its capacity is limited by the addressing ability of the CPU. This logically unified memory is what we call the memory address space.

Each physical memory logically occupies an address segment, and the CPU operates on the segment to operate on the physical memory.

It is the CPU that runs the program in the end. When we program in assembly language, we must consider the problem from the perspective of the CPU.

summary

  1. The assembly instruction is the mnemonic of the machine instruction, which corresponds to the machine instruction one-to-one.
  2. Each type of CPU has its own assembly instruction set.
  3. The information that the CPU can directly use is stored in the memory.
  4. There is no difference between instructions and data in the memory, they are all binary information.
  5. The storage units are numbered sequentially starting from 0.
  6. A storage unit can store one byte, that is, 8 bits (8b), 8 bits of binary.
  7. 1GB = 1024MB 1MB = 1024KB 1KB = 1024Byte 1Byte = 8bit
  8. Each CPU chip has many pins, which are connected to the bus. It can also be said that these pins lead to the bus. A CPU can lead to three kinds of bus widths marking the performance of different aspects of the CPU.
    • The width of the address bus determines the addressing ability of the CPU
    • The width of the data bus determines the amount of data transfer between the CPU and other devices during a data transfer
    • The width of the control bus determines the ability of the CPU to control other devices in the system

Guess you like

Origin blog.csdn.net/david2000999/article/details/115197660