Compilation Tutorial 3 - Preparation for Upgrade

zhaozj2021-02-12  134

Compilation Tutorial 3-Upgrade Preparation After the study of 2 tutorials, I should have a profound impact on the assembler? So can't teach blind posts, you can upgrade, but before upgrading, you should not help some things about some things. First, the CPU's internal registers: four 16-bit general-purpose registers: _____________________________ | __ah ________ | ____ al _________ | ax | __bh ________ | ____ bl _________ | bx | __ch ________ | ____ cl _________ | cx | __dh ________ | ____ dl _________ | dx where: In general, AX as multiplication and division The accumulator in the method, the BX can store the address, or the pointer register. The CX can store the number of cycles, and the DX can store the I / O number. AH is two 4 digits, Al is two 4 digits, so AX is 16 bits, and the rest is pushed

4 16-bit pointer register ______________________________ | bp base pointer | _____________________________ | sp stack pointer is used to make the top of the stack pointer | _____________________________ | si source index register | ________________ sometimes used to make these two index devices, store data And the results of the operation | DI target register | ____________________________

4 16-bit internal registers:

______________________________ | cs: code segment register | _____________________________ | ds: data segment register | _____________________________ | es: additional segment register | _____________________________ | ss: stack segment register | _____________________________

Sign Register:

____________________________ ip instruction pointer | ___________________________ | flagsh | flagsl | _____________ | _____________ | status flag of the flag register 16, only nine of which flags, each state flag 6, the three control flags.

FH: ________________ | of | DF | IF | TF | ___ | __ | __ | __ | __ |

FL: ___________________________ | sf | ZF | Empty | AF | Empty | PF | Air | CF ||__ | __ | _ | __ | _ | __ | __ | __ |

Every sign of specific signs I simply tell, if you want to program it, you have to look at the book CF: carry flag, carry / borrow, CF = 1PF: parity, when the command execution results are 8 bits When there is an even number of 1, PF = 1, f otherwise 0AF: auxiliary carry mark, the low byte of the result of the addition and subtraction method, the high-byte of the 5-bit, and the AF = 1.ZF: 0 logo. When the calculation result is 0, the zf = 1sf: symbol flag, the highest bit of his and calculation results. The negative number is 1, the positive number is 1OF: overflow flag, the completion of the completion of the operation is 1 is the status flag, the following is the control flag: DF: direction flag, the step-direction IF of the control data string operation instructions IF: Interrupt Allow flag TF : Track the logo, set to the debugger, people who like crackdown should pay special attention to this

Second, addressing: This thing is not guilty, no way, understand it, I try to say clearly! 1, fixed addressing this mode, the operand is hidden in the instruction, for example, the DAA, the operands are hidden in Al 2, and immediately addressed to represent constants, for example: MOV AX, 9; 9 is immediate MOV AX 1234h; 1234h is immediate,

3, register addressing, for example: MOV AX, CX Perform AX = 9602H, CX = 2081H After execution, AX = 2081H.

4, the memory addressing this mode, the operands are typically the data segments, stack segments, and the memory cells, or expressions given in the memory cells given outside the code segment. In general, the number of destination operands and the original operand cannot be the same as the memory operand. Memory addressing is divided into five types:

Direct addressing: The valid address of the operands are given by the instructions, which is a constant or variable with square brackets. Physical address PA = 16 * (DS) offset address NN, for example: MOV Al, [1000h] transmits the content of the 1000H unit of the DS segment to Al, pay attention to the difference between square brackets and non-plug.

MOV AX, [1000h] transmits the contents of the DS segment to AX, pay attention to the contents of AH, Al. In addition, don't ignore physical addresses, this is very important information, cracking or programming, you must take this thing. MOV Al, ES: [2000H] indicates that the contents of the ES segment is passed to Al, which is called the prefix.

Register indirect addressing: Format: [BX, BP, Si, or Di]. Address by the base register or the index register If the BX, Si, DI used in the instruction is used as the segment address PA = 16 * ( DS) (BX / Si / DI) For example: MOV Al, [BX] sets BX content to 1000 hours, then transmits content of the DS segment to Al If you use BP, use the SS address PA = 16 * (SS) (BP) This addressing method is generally used to operate a continuous memory unit for a one-dimensional array operation, change the value of the registers such as BX.

I will be a bit complicated in the future, pay attention,

STS Address: Format: Offset [BX or BP] For example: MOV Al, 80H [BP] set BP content = 2040h, why is the content of the 20c0 unit of the stack section to Al why? Because the 2040h 80H = 20c0h is not believed in the Windows Calculator in the Windows Calculator. In fact, this statement is equivalent to the effective address EA = (bx) / (bp) offset of the number of MOV Al, [80H BP] operands

Event Address format: Offset [Si or Di] operand EA = (Si) / (di) offset is not the same as the above? Let's take an example of an operand: Mov AX, Array1 [Si] MOV Array2 [Di], is AX understand? Why can't Mov Array2 [DI] Array1 [Si]? Because the two operands cannot be variables.

Don't worry, here I have not given physical address of these two ways, and I will give you a topic, it is easy, think about it!

The base address address is actually the above two combination format: offset [BX / BP Si / Di] PA = 16 * DS (BX / BP Si / DI offset) or 16 * SS ( BX / BP SI / DI Offeter) Note that the BX and BP selection are different, the segment address will be different, the former uses DS, the latter uses SS

转载请注明原文地址:https://www.9cbs.com/read-6358.html

New Post(0)