Register
By operating the data bus and controlling the bus and the address bus to read data, it must be a very flexible way. If you perform complex operations on a certain storage unit, reading constantly obviously requires optimization, such as adding cache, thing or intermediate variable. Of course, here we can only add hardware, such as registers (it seems that the machine code will be related to registers)
General registers: Even if you think of registers as variables in a storage unit, you need to give them a nice and meaningful name.
1. Data Register
Ah & Al = AX (accumulator, all I/O commands use this register to transmit data with external devices.
BH & BL = Bx (base): base register, often used for address index
Ch & CL = Cx (count) used as an implicit counter in string processing commands.
DH & DL = DX (data): a data register, often used for data transmission.
The four 16-bit registers can be divided into high 8-bit (ah, BH, CH, DH) and low 8-bit (Al, BL, Cl, DL ), these two groups of 8-bit registers can be respectively addressable and used separately.
2. pointer registers and address change registers
SP (Stack pointer): A stack pointer that can be used with SS to point to the current stack position.
BP (base pointer): base address pointer register, which can be used as a relative base address location of SS.
Si (source index): Source Address Change register, which can be used to store the source address change pointer relative to the DS segment
Di (destination index): the destination address change register, which can be used to store the destination address change pointer relative to the es segment.
These four 16-bit registers can only perform access operations based on 16 bits. They are mainly used to form the address of the operand and to calculate the valid address of the operand in stack operations and address change operations.
Of course, the so-called general purpose is just to change the meaning, but the program ape specification may require us to use it according to the Register rules (just like the temporary variable I), it does not matter if we do not comply with it, however, in case the control bus is not enough, it may be implemented according to the so-called functions (good wit, like in some JVMs, using int instead of byte... does not provide byte-related commands at all). Other customer experience (optimization) may be useless (no divergence, and more )--
Several Assembly commands: the understanding of the bus makes me believe that the command should be made up of three, or else I will learn it again.
Move ax, 18; AX = 18
Move will be converted to machine code passed to the control bus, ax should be the address bus (in short), and 18 is the data bus, so easy ....
Move ax, Bx: AX = Bx
As mentioned above, there is a small problem that the BX is not deleted. Why do I want it to be deleted because it is move or not copy? (I admit that I will not delete it even if I implement it, but I just think about it, and I think it's strange)
Add ax, 8: AX = AX + 8
Add is the control, ax is the address, and 8 is the data
Let's take a look at Chapter 1. The CPU processes the memory and uses the bus. The above examples do not read the memory, but store the temporary variables (registers, the bus should not be used here. I just compared it .... therefore, the register is not a storage device (find a step under O (Clerk _ Clerk) O ~), Maybe all the memory is mapped to a physical address (table) by a strange force, so far there is no register in this table
Physical address: even if there are a large number of hardware, the unique physical address is still maintained (how to assign the specific address to the hardware ...)
16-bit CPU:
1. the scanner can process up to 16 bits of data at a time.
2. register up to 16 bits
3. Register and receiver channels are 16-bit
8086cpu physical address Retrieval Method
20-bit address bus: the storage facilities are mapped to physical addresses (1, 2, 3, 4) by mysterious power. We can find them through the address bus. 20 1 represents the 20 power of 2, that is, the range of the physical address (when it is too large, it cannot be found ....)
16-bit CPU Structure: The data popped out at a time is 16 bits, and the difference between 4 bits passed directly to the address bus... compared with the physical address = segment address x16 + offset address, I care more about whether this formula is common, or if my address bus is a 64 kB class? Or 32-bit CPU is the physical address ....
Segment Concept
Now that we have decided to use the x16 + offset solution of the physical address = segment address, we can see that there are multiple expressions for the physical address.
Check the register again
As a temporary variable, registers simplify the storage of necessary data, however, if there is a register dedicated to storing segments .... maybe I will stop complaining.
Segment register: Obviously, this register (variable) is a tool for simplifying the addressing of variables. According to the operation method, four very convenient registers are provided, it is very likely not to mention this change.
CS (code segment): code segment register
DS (Data Segment): Data Segment register
SS (stack segment): Stack segment register
ES (extra segment): additional segment register
CS and IP: IP-> variable I
Assume that the program runs and the execution of one byte and one byte (admit it, loop), there must be a counting variable, such as IP
Through examples in the book, we found that the data transmitted by the Data Bus is always different... it seems that some parsing will be done when the data bus is passed (it may also be related to the encoding rules, who cares)
Modify CS and IP Address: JMP improves customer performance compared to move
JMP ax-> IP = AX
JMP-> cs = 1; AX = 2;
View CPU and memory: you can find
The register is like a global variable. It is displayed in front of the window and there should be no concurrency...
Taking Assembly commands as an execution loop, the bytes used for execution are not fixed. assembly should be a simple encapsulation of execution.
2. Registers