Chapter I Basic knowledge

<> Computer and 0 and 1

The main computers we use now are LSI machines , Large scale and super large scale integrated circuits are used as logic elements .

Integrated circuit , By function , Structural differences , Can be divided into analog integrated circuits , Digital integrated circuit and number / Three categories of modular hybrid integrated circuits . Our computers are mainly built with digital integrated circuits .

Logic gate is the basic unit of digital logic circuit . Common logic gates include “ And ” door ,“ or ” door ,“ wrong ” door ,“ Exclusive or ” wait . More complex logical and numerical operations can be realized through the combination of logic gates .

Logic gate can be controlled by high , Low level , So as to realize logical operation . The fluctuation of power supply voltage has no effect on it , The effect of temperature and process deviation on its reliability is also much smaller than that of analog circuit . So it's relatively stable .

Because a digital computer is made up of logic gates , And the most basic state of logic circuit is two —— On and off . therefore , Digital circuit is based on binary logic algebra . The basic operation rules of binary are simple , Convenient operation , This will simplify the internal structure of the computer , Improve operation speed .

However, the machine code is too cumbersome and error prone , And then came assembly language .

<>CPU

a central processor (CPU) Is the unit that performs most of the processing inside the computer . To control the flow of instructions and data with other parts of the computer ,CPU Mainly depends on chipset , A chipset is a set of microchips on a motherboard .

CPU There are two components :

* control unit : Extract instructions from memory and decode and execute them
* Arithmetic logic unit (ALU): Handling arithmetic and logic operations
cpu Control the operation and operation of the whole computer , His job is to read and write letters in memory

interest , So as to achieve the operation and control of software and hardware . We put the data in memory and divide it into units , In order to better find processing data . Because the computer can only handle the transmission of electrical signals , therefore cpu And memory are connected by wires ( Address bus by function , data bus , Control bus ). How many electrical signals can be transmitted at one time , On behalf of cpu One time processing , How much information to control . If any 10 Root address bus , So it can be transmitted at one time 10 Bit binary data .

Summary
1.cpu Directly used information in memory
2. There is no difference between instructions and data in memory. They are binary numbers ( Through assembly language let cpu distinguish )
3. One storage unit storage 8 individual bit, Namely 8 Bit binary number
1byte=8bit 1kb=1024b 1mb=1024kb 1gb=1024mb

Chapter II register

A typical cpu( After that 8086cpu give an example ) By solver , controller , register , Etc , These devices are connected by internal bus .

<> General register

8086 All registers are 16 position ( Put one binary data in one place , therefore , The maximum storage data is 2 Of 16 Power -1) Of , Can store two bytes .AX,BX,CX,DX Used to store general data , Called general register . Each register can be divided into two 8 Bit register to use , Namely AX Divided into AL( Lower octet ) and AH( High octet ), Other registers and so on . They can represent data separately or jointly .

Basic instruction

* mov ax,81     ; take 81 Enter register ax, Analogical advanced language ax=81
* add ax,8        ; take ax Value plus in 8,ax=ax+8
* mov ax,bx     ; take bx Value in ax,ax=bx
* add ax,bx      ; take bx,ax Add the values in the ax,ax=ax+bx
Case insensitive when writing assembly instructions or registers , But not in mixed case

mov Equivalent to coverage , Whether the destination register has a value or not , During data transmission operation, pay attention to whether the data exceeds the register capacity and the number of operands should be the same (al Can't relate to bx Transfer operation ,8 Bitwise AND 8 Bit correspondence ,16 Bitwise AND 16 Bit correspondence )

<> Physical address and addressing

cpu Want to control the data , First, find the target data , To read and write . that , In huge memory , How to find data quickly and accurately ?
The memory space composed of all memory units is a one-dimensional linear space , Each memory unit has a unique address in space , This address is called the physical address . Equivalent to cpu Better find their house number .

Address adder is a tool for addressing , It divides the physical address into segment address and offset address . The expression of physical address is : Segment address *16+ Offset address = Physical address
wsm What about that ?
To enhance addressing capability and efficiency

Like from 0~999 Determine a number in , The first thing is to determine the hundreds , Then we can determine the tens and ones . Segment address *16( the reason being that 16 Base so multiply 16) The algorithm can also save one digit space

The memory address is not divided into fixed segments , Memory with consecutive addresses can be regarded as a segment according to programming needs .
8086cpu There are four segment registers ,cs,ds,ss,es. When cpu To access memory , The four segment registers provide the segment address of the memory unit .

Let's talk about it first CS and IP, They are cpu The two most critical registers in , Indicated cpu Address of the current instruction to be read ,cs Is a code segment register ,ip Is the instruction pointer register . Any moment ,CPU Will be CS:IP The directed content is executed as an instruction .

<> experiment 1 see CPU And memory , Programming with machine and assembly instructions

Environmental Science :windows2008,dosbox

debug yes DOS,windows Real mode provided by (8086 mode ) Program debugging tools . Use it , Can view CPU Contents of various registers , Memory condition and tracking program operation at machine code level .

Basic instruction

* R       see , change CPU Register contents
* D       View content in memory
* E       Command to overwrite content in memory
* U       Translate machine instructions in memory into assembly instructions
* T       Execute a machine command
* A       To write a machine instruction in the form of an assembly instruction
get into dosbox
( Also available at command Completed in )

r Command to change the contents of the register

d View content in specified address

use e Command to overwrite content

This command writes writable characters and machine codes

a Commands write machine instructions as assembly instructions

Technology
©2019-2020 Toolsou All rights reserved,
Programmer and architect Hua Shan Fiddler Simulate request sending and modifying response data Shortest path Dijkstra (Python3)C Language confession practice small program ( Suitable for beginners ) use VS2019 “Windows Desktop applications ” Module creation Win32 window rk3399_android7.1 debugging USB Summary of Bluetooth module CCTV :Tiktok A lawsuit shows the attitude and determination of safeguarding rights SSM Project's excel File upload and add to database Thoughts on multi tenant system element-ui Of el-date-picker Component get value