This is read wang Shuang wrote the assembly language of the third edition of the book summary of knowledge points. Read the original book if you are interested.
-
Assembly language is a programming language that works on hardware.
-
Let me start with machine language: machine language is a collection of machine instructions. Everyone knows that machine instructions are a list of binary numbers.
-
The Central Processing Unit (CPU) is a chip in a computer that carries out machine instructions to perform operations.
-
Early programs are machine language, programmers use 0 and 1 numerical programming program on paper tape or card, 1 punch holes, 0 do not punch the program through bag making machine or card machine input computer, operation. But reading and writing a bunch of zeros and ones in machine language is too cumbersome. Thus assembly language was born.
-
The body of assembly language is assembly instruction. Assembly instructions differ from machine instructions in the way they are represented. Assembly instruction is an easy – to – remember writing format for machine instructions.
- For example: 1000100111011000 means to send the contents of register BX to AX. The assembly instructions are: mov AX,bx
-
Programmers write programs using assembly instructions. Computers can only read machine instructions, so a compiler is needed to convert assembly instructions into machine instructions. The diagram below:
Assembly language composition
- Assembly instruction: Mnemonic of machine code, having corresponding machine code.
- Pseudoinstruction: without corresponding machine code, the compiler executes, the computer does not execute
- Other symbols: such as +, -, *, /, etc., compiler set, no corresponding machine code
Memory and instructions and data
-
The CPU is the core of the computer. It controls the operation and computation of the whole computer. We need to supply data and instructions to the CPU for its work. Yes, it’s in memory.
-
Instructions and data are binary information. The CPU labels different information differently.
1000100111011000 -> 89D8H (data)
-> mov ax,bx
Memory units and CPU reads and writes to memory
-
The storage unit is divided into several storage units. Each storage unit is numbered from 0. For example, if a storage unit has 128 storage units, the number is 0 to 127.
-
How much information can a storage unit hold?
The smallest unit of an electronic computer is a bit, which is a binary bit. Eight bits make up a Byte. The memory unit of microcomputer memory can store one Byte.
1KB = 1024B 1MB = 1024KB 1GB = 1024MB 1TB = 1024GB
-
To read or write data, the CPU needs to find the address of the specified storage unit. In addition to this, it is necessary to specify which device operation is being performed and which operation is being performed
- Storage unit address (Address information)
- Device selection, read or write commands (control information)
- Read or write data (data information)
-
How does the CPU read and write data?
-
The CPU sends address information 3 over the address line.
-
The CPU issues a memory read command through the control line, selects the memory chip, and notifies it that it is about to read data from it.
-
The memory sends the data 8 in unit 3 to the CPU through the data line
The CPU writes data, such as to unit 3 26
-
The CPU sends address information 3 over the address line.
-
The CPU issues memory write commands through the control line, selects the memory chip, and notifies it that it will write data to it.
-
The CPU sends data 26 to cell 3 of memory through the data cable.
-
How to command a computer to read and write data
-
To make a computer work, machine code should be fed into it.
-
Machine code: 10100001 00000011 00000000
Assembly instruction: MOV AX,[3]
Send the contents of unit 3 into AX
-
Address bus, data bus, control bus
-
Address bus:
- The CPU assigns memory units via an address bus.
- A wire can transmit only two steady states, high or low. Binary means 0 or 1 19 wires can carry 10 bits of binary data. How many different numbers can 10 bits represent? Two to the tenth. The minimum value is 0 and the maximum value is 1023.
-
The data bus
-
Data transfer between CPU and memory or other devices is carried out by data bus. The width of the data bus determines the speed of data transfer between the CPU and the outside world.
The 8-data bus can transmit one 8-bit binary data (one byte) at a time
-
-
Control bus
-
CPU control of external devices is carried out through the control bus.
The width of the control bus determines the ability of the CPU to control external devices.
For example: read signal output control line is responsible for the CPU to transmit read signals. The CPU outputs a low level to the control line indicating that data will be read.
-
Memory address space
- A CPU with an address bus width of 10 can address 1024 memory units, which constitute the memory address space of the CPU.
- The size of the memory address space is limited by the CPU address bus width. For example, if the address bus width of the 8086CPU is 20, it can transmit 2 ^ 20 different address information. The address space of the memory is 1MB.
- We want to program on a computer hardware system. You have to know the allocation of memory address space in the system. So that we know the address of the first cell and the address of the last cell when we read or write data in a certain type of memory. Ensure that read and write operations are performed in the expected storage.
- The CPU ultimately runs the program, and when we program in assembly language, we have to think from the CPU’s point of view. The storage units in all the storage in the system reside in a unified logical storage, whose capacity is limited by the ADDRESSING capabilities of the CPU. This logical storage is what we call the memory address space.
Review the above by the questions (including the answers)
- What is the width of the address bus for a CPU with 8KB addressing capacity?
- How many storage units are there in 1KB of memory, numbered from what to what?
- How many bits and bytes can be stored in 1KB of memory?
- How many bytes are 1GB, 1MB, and 1KB respectively?
- The address bus widths of 8080, 8088, 80286 and 80386 are 16, 20, 24 and 32, respectively. How many (KB) how many (MB) how many (MB) how many (GB)
- The data bus widths of 8080, 8088, 8086, 80286 and 80386 are 8, 8, 16, 16 and 32, respectively. How much (B) how much (B) how much (B) how much (B) how much (B) how much (B) how much (B)
- Read 1024 bytes of data from memory 8086 Read at least how many times? How many times must I read 80386?
- In what form are data and programs stored in memory?
Answer and analysis
-
13. 1KB=1024B, 8KB=1024B*8=2^N, N=13.
-
1024 Storage units 0 to 1023
-
1KB of memory can store 8192 (2^13) bits, 1024 bytes.
8Bit=1Byte, 1024Byte=1KB (1KB=1024B=1024B*8Bit)
-
1073741824 (2^30) bytes for 1GB, 1048576 (2^20) bytes for 1MB, and 1024 (2^10) bytes for 1KB.
-
64KB, 1MB, 16MB, and 4GB
If a CPU has N root address lines, we can say that the width of the address bus of the CPU is N. Such a CPU can find up to 2 to the N memory units. (one memory cell =1Byte).
-
1B, 1B, 2B, 2B, 4B
The 8-data bus can transfer 8 bits of binary data (that is, one byte) at a time.
-
Read 8086 at least 512 times and 80386 at least 256 times.
The width of the 8086 data bus is 16 bits (that is, the data transmitted at one time is 2B). 1024B/2B=512, and similarly, 1024B/4B=256.
-
Store in binary format.
There is no difference between instructions and data in memory, they are binary information.
-