Write the memory station under DOS with assembly (2)

zhaozj2021-02-16  49

Basic Principle 2.1 8086/8088 IBM PC Central Processing Unit is the microprocessor Inter 8008,8088 is 8086 is a small version. For writing programs, both are almost identical. The difference between the two The external communication. 8086 and the outside communication are via a 16-bit input and output channel, memory access is also a 16-bit unit, 8088 and 8086 are extremely similar, but it must pass through 16 bits when communicating with the outside. Channel. 2.1.1 The structure of the register 8086/8088 is simple, including a set of general purpose 16-bit registers .ax, bx, cx, dx, bp, si, di. Where AX, BX, CX, DX can also Sub-8-bit registers, such as AX can be divided into AH, Al; BX can be divided into BH, BL; CX can be divided into CH, CL;

DX can be divided into DH, DL. Register BP, Si, and Di is not particularly limited, but it cannot be divided into two bytes. In addition, the register sp is mainly used as a stack pointer. In addition, there are four A very important segment register: CS, DS, SS, ES. Instru -ction Pointer IP is used to control which instructions currently executed by the current CPU. 8086 Design, take into account the 8th The CPU8080 is compatible. The 8-bit computer is to add two bytes (ie 16 bits), so its address space can reach 64K bytes. 16-bit CPUs have selected a completely different ways on the address settings. CPU Segment (segment) is unit, including 64K bytes in each range, and in memory can contain many segments. So, the operating system can be executed within a segment. And the user's program can be executed within another section. In a segment, the package can treat the computer as only 64K byte memory space. So the programs executed on the 8-bit computer can be easily ported to the 16-bit computer. In addition, the memory segment can also be each other. Overlap, thus two different programs can share a piece of memory. The value is set by the register, and the actual address value is 4 digits to the left value (16 digits), then plus 16 The bit displacement, thus constitutes a 20-bit address value. So 8086 can do 20-bit addresses, which may be available to a megabyte memory. In this megabyte memory, IBM PC Keep the top 320k byte to the system's ROM BIOS and display memory, so users can use 640K bytes. 2.1.2 Addressing Mode is a computer on a computer. Many complex operations The key to the key. 8086 provides the following addressing methods: immediate addressing, memory indirect addressing, register indirect addressing, etc. Immediate addressing, direct use of numbers directly. Memory indirect addressing, value in data segment Position. MOV BX, Foo Foo DW 5 Register Indirect Address. There are two registers that can be used in this addressing mode: the base register and index register. The base register is BX and BP, the index register is Si and Di. In this addressing mode, the register stores the address value in the data segment. MOV AX, 0F000H MOV ES, AX MOV SI, 0FFFEH MOV DL, BYTE PTR ES: [ Si] The above program uses an indirect addressing method, and reads data from the register Si in the F000: FFFE location. At the time of access, you can only use an index register of the mima base register. The above addressing methods can be used to make different bindings, so there are many results after the combination. 2.1.3 Sign 8086 has 9 one sign (Flag They can be indicative of various states of the CPU. The following is an introduction to the 9 flags: CF (Carry Flag): When CF is 1, the result of the arithmetic operation is outside the correct length. PF (PRITY FLAG): PF is 1 It means using even check, PF is 0, represents the use of odd calibration. AF (Auxiliary Carry Flag): The same as CF, but it is used at a low 4-bit result. AF usually uses the 20-bit address calculation. Zf (Zero Flag): ZF is 1 means the result of the calculation is 0, otherwise the zf is 0. sf (SIGN FLAG): SF 1 means the highest bit of the calculation result is 1, otherwise SF is 0. TF (TRAP FLAG): TF is 1, the CPU is executed in a single step, and a special interrupt occurs in this mode. If (Interrupt Enable Flag): if is 1, allow the CPU to receive the interruption of the outside, otherwise IF It is 0. DF (Direction Flag): This logo uses in loop instructions, such as: Movs, Movsb, Movsw, CMPS, CMPSB, and Cmpsw. If DF is 1, the loop is increasing forward. If DF 0, then reduce the address after the address. Of (over flag): OF (OF): 1. It means a length considering the correct byte. 2.1.4 All loop instructions are used as CX Counter. One loop will perform repeatedly until the CX is equal to a particular value. The following program uses repeatedly added, completing the multiplication of two numbers. MOV AX, 0 MOV CX, 4 Next:

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

New Post(0)