操作符offset

    技术2022-05-19  19

    操作符offset

    操作符offset 在汇编语言中是由编译器处理的符号,它的功能是取得标号的偏移地址。

     

    assume cs:codesg

    codeseg segment

    start:              mov ax,offset start      ; 相当于 mov       ax,   0

    s:            mov ax,offset s        ; 相当于mov        ax,   3

    codesg ends

    end start

     

    看下面代码: 使该程序在运行中将s处的一条指令复制到s0

    ; 体会一下offset的用途, 体会一下代码段内存的访问

    assume cs:codesg

    codeseg segment

    s:            mov       ax,   bx                  ; mov ax, bx 的机器码占两个字节

    mov       si,    offset     s      ;

    mov        di,    offset      s0    ;

    mov        ax, cs:[si]

    mov        cs:[di],    ax           ;

           s0:          nop                                     ; nop的机器码占一个字节

                         nop

    codesg ends

    end s

     


    最新回复(0)