Control transfer instructions, string operation instructions 80386 Control Transfer instructions include: transfer instructions, cyclic instructions, process calls, and return instructions. A. Transfer instructions include unconditional transfer instructions JMP and conditional transfer instructions, and unconditional transfer instructions are divided into direct transfer in segments, indirect transfer in segments, direct transfer between segments, indirect transfer between segments. Since the 80386 has a protection mode and real mode, in real mode, the range of metastasis in segment is from -128 to 127, and the maximum range between the metastasis is 64K. In the protection mode, you need to use a 48-bit pointer, ie CS: EIP (16-bit 32 bits). There are a lot of conditional transfer instructions including JCXZ, JECXZ, JBE, JAE, JA, JB, etc., which are similar to 8086. B. Circular Directive LOOP, LOOPZ, LOO0PE, LOOPNZ, LOOPNE, TASM Support Help, LoopWe, Loopwz, Loopww, LoopWne, Loopd, Loopwd, Loopde, Loopdne, Loopdnz. When CX is used as a counter, Loop, LoopWe, LoopWz, Loopwnz, LoopWne; when using ECX as a counter, the following example can explain the problem: ABC PROC MOV CX, 100H AA:; Add Your Codes Here Loop Aa Abc End
C. Process call and return call Call, RET These two instructions are the same as 8086, but is in real mode and protection mode under 80386. In real mode, whether it is called or during paragraphs, 32-bit pointers are used, that is, CS: IP, their usage is the same as 8086. In protection mode, inter-segment calls and segment calls are used in 48-bit pointers, ie ECS: IP. RET is used to return, and the specific implementation process will be more complicated. After the management mechanism of the address of 80386 will be introduced, first introduce the following CALL instructions in 8086: a. Direct transfer, specific format: CALL process name. At this time, the CS does not enter the stack, the inner stack in the IP, and then the difference between the addition of the destination address and the CALL instruction will be transferred to the destination address, the detailed process: SP-2 => Sp; drop the stack pointer SP 2 (sp) <= IP; point the IP to the IP offset address; go to the destination address b. Indirect transfer within the segment, the specific format: Call Oprd, then here oprd here Register or memory unit, its specific implementation process: SP-2 => sp; put the stack pointer SP 2 (SP) <= IP; put the IP input IP <= (oprd); to the destination address, CS does not enter the stack c. Direct transfer, specific format: CALL process name [FAR], at this time, the CS, IP must be put into the stack, the detailed implementation process: SP-2 => sp; reduce the stack pointer 2 (SP <= CS; put the CS in the stack SP-2 => sp; reduce the stack pointer 2 (SP) <= IP; put the IP in the stack; load the new CS, IP ip <= process portal offset address CS <= Segment address D of the process in the process D. During the interior, the specific format: Call Oprd [FAR], at this time, the CS, IP must be set, OPRD is 32 bits, you know that there is no 32-bit register in 8086. Therefore, the OPRD here must be a storage unit. The high 16 bits are the value of CS, and the low 16 bits are IP values, and the detailed implementation process: SP-2 => sp; reduce the stack pointer 2 (SP) <= CS; CS into the stack SP-2 => sp; reduce the stack pointer 2 (SP) <= IP; put the IP in the stack; load new CS, IP ip <= (OPRD 2, OPRD 3) CS <= (OPRD, OPRD1) E. Segment Return Format: RET.