The principle of assembly language note transfer instruction

Source: Internet
Author: User

Original address: Http://www.cnblogs.com/dennisOne

? 8086CPU Transfer Instruction classification

    • Unconditional transfer instructions (e.g., JMP)
    • Conditional Transfer Directives
    • loop instructions (e.g. loop)
    • Process
    • Interrupt

? operator offset

Offset in assembly language is the symbol processed by the assembler, its function is to take the offset address of the label.

? jmp directives

Type

Function

Example

JMP Short Label

(short transfer within paragraph)

Assume Cs:codecode Segmentstart:mov ax, 0 jmp short s add ax, 1s:inc axcode endsend start

JMP near PTR label

(near transfer within paragraph)

JMP far PTR designator

(Inter-segment transfer)

Assume Cs:codecode Segmentstart:mov ax, 0 mov bx, 0 jmp far PTR s db down dup (0) code endsend start

JMP 16-bit Reg

(Transfer within paragraph)

Setting: (IP) = (16-bit REG)

The compiler determines the short/near transfer in the segment according to the situation

JMP Word PTR memory cell address

(Transfer within paragraph)

mov ax, 0123Hmov ds:[0], axjmp word ptr ds:[0]

JMP DWORD PTR memory Unit address

(Inter-segment transfer)

mov ax, 0123Hmov ds:[0], Axmov word ptr ds:[2], 0jmp DWORD ptr ds:[0]

JMP 2000:0100

(Inter-segment transfer)

    • To illustrate:

? conditional transfer directives and cyclic directives

All conditional transfer instructions and circular instructions are short-shifted, with the corresponding machine code containing the shifted displacement, not the destination address, not the destination address. The range of modifications to IP is: -128~127.

Type

Function

Jcxz

(conditional transfer Directive)

Loop

(Circular instruction)

? Instructions for shifting according to displacement

1 jmp short label 2 jmp near PTR designator 3 jcxz label 4 Loop label

Several assembly instructions, which modify the IP, are based on the displacement (complement) between the transfer destination address and the transfer start address, rather than the destination address in which the corresponding machine code contains the transfer.

Analyze a strange program:

1 Assume CS:CODESG 2  3 CODESG segment 4         mov ax, 4c00h 5         int 21h 6              7 start:     8         mov ax, 0 9 s:      N Op  ; jmp short s110         nop11             mov         di, offset S13         mov si, offset s214         mov ax, cs:[si]15         mov Cs:[di], ax16             s0:     jmp short S18         s1:     mov ax, 020         int 21h21         mov ax, 022 at             S2:
   JMP Short s124         

By debugging The assembly instructions, you can see why the program can exit normally.

The principle of assembly language note transfer instruction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.