Assembly (1) First acquaintance with assembly

I. Overview

Assembly language is a programming language that works directly on the hardware. You must first understand the structure of the hardware system before you can use assembly language to program it effectively.

1. The production of assembly language

Only machine instructions can be read by a computer. What are machine instructions?

  • In terms of machine instruction expansion, it is a command that a machine can execute correctly

Example 1:
       Command: 01010000 (PUSH AX)

Level pulse:
Insert picture description here

Example 2:
       S = 768 + 12288-1280

Machine code:
      101100000000000000000011
      000001010000000000110000
      001011010000000000000101

The main body of assembly language is assembly instructions , which are easy to remember writing format of machine instructions (assembly instructions are the mnemonics of machine instructions).
Example 1:
Machine instruction: 1000100111011000
This instruction sends the contents of register BX to register AX

Assembly instruction realization:
assembly instruction: MOV AX, BX

  • 寄存器: Simply speaking, it is a device that can store data in a CPU. There are multiple registers in a CPU. AX is the code name of one of the registers, BX is the code name of the other register

How does the computer execute assembly instructions as machine instructions?

Insert picture description here

2. The composition of assembly language

Assembly language is composed of the following three categories:

  1. Assembly instructions (mnemonics for machine code)
  2. Pseudo-instruction (executed by the compiler)
  3. Other symbols (recognized by the compiler)

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

3. Memory

The CPU is the core component of the computer. It controls the operation of the entire computer and performs calculations. If you want a CPU to work, you must provide it with指令和数据

Instructions and data are stored in memory, which is usually called memory

4. Instructions and data

In the memory, there is no difference between instructions and data. They are all binary information . Instructions and data are application concepts.
Binary information:
1000100111011000 is
regarded as data -> 89D8H is
regarded as instruction -> MOV AX,BX

5. Storage unit

The memory is divided into several storage units, and each storage unit is numbered sequentially starting from 0

A memory has 128 storage units, numbered from 0 to 127, as shown in the following figure: the
Insert picture description here
unit of measurement of the storage unit:

1KB=1024B
1MB=1024KB
1GB=1024MB
1TB=1024GB

6. CPU reads and writes to the memory

If the CPU wants to read and write data, it must interact with external devices (a chip in standard terms) in three types of information:

  • Address of the storage unit (address information)
  • Device selection, read or write command (control information)
  • Data to be read or written (data information)

The CPU transmits the address, data and control information to the memory chip through wires. There are wires in the computer that connect the CPU and other chips, usually called a bus.

bus:

  • Physically

    • A collection of wires
  • logically

    • Address bus
    • Data Bus
    • Control bus

Diagram of the logical division of the bus:
Insert picture description here

6.1 Address bus
  • The cpu uses the address bus to determine the storage unit to be operated
  • The bus is not only one wire, but a combination of many wires
  • The number of address buses determines the range of memory cells that the cpu can access. If a cpu has N address lines, it means that the width of the cpu's address bus is N, and the maximum number of memory cells that can be accessed is 2 to the Nth power.

When the computer receives a 101000000000001100000000machine instruction, meaning that instruction is read into the data register from the AX unit 3 when, cpu operation of a memory cell, you must know the address of this memory, cpu through to the address bus Determine the storage unit to be operated

6.2 Data bus
  • Data transfer between CPU and memory or other devices is carried out through the data bus
  • The width of the data bus determines the data transfer speed between the CPU and the outside world
6.3 Control bus
  • The CPU's control of external devices is carried out through the control bus. Here the control bus is a general term, and the control bus is a collection of different control lines.
  • How many control buses there are, it means how many kinds of control the CPU provides to external devices

Insert picture description here

7. Memory address space

The width of the address line of a CPU is 10, then 1024 memory units can be addressed, and these 1024 memory units that can be found constitute the memory address space of this CPU

8. Motherboard

In every PC, there is a main board, there are core devices and some main devices on the main board, these devices are connected by bus (address bus, data bus, control bus)

9. 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. The interface card inserted in the expansion slot directly controls these devices to work

10. Various types of memory chips

From the perspective of read and write attributes, it is divided into two categories:

  • Random Access Memory (RAM)
  • Read only memory (ROM)

From the function and connection classification:

  • Random access memory RAM
  • ROM with BIOS
  • RAM on the interface card

ROM with BIOS

  • BIOS: Basic Input/Output System, basic input output system.
    BIOS is a software system provided by the manufacturers of motherboards and various interface cards (such as graphics cards, network cards, etc.), through which the hardware devices can be used for the most basic input and output. A ROM storing the corresponding BIOS is inserted on the motherboard and some interface cards
    Insert picture description here

Guess you like

Origin blog.csdn.net/haiyanghan/article/details/113758606