gpt4 book ai didi

c - MOV 和 MOV ptr 的区别

转载 作者:行者123 更新时间:2023-12-02 08:02:08 25 4
gpt4 key购买 nike

我不明白 MOVMOV ptr 之间的区别。

例如,在这段 C 代码中:

unsigned char x, y;
x = 2;

汇编中的第二行是:

`MOV x, 2`

但是这个 C 代码的第二行:

tabbyte[0] = 15
unsigned char tabbyte[4]

在汇编中是:

MOV byte ptr tabbyte[0], 15

这两个汇编指令有什么区别,应该在什么时候使用它们?

最佳答案

  1. Directives BYTE PTR, WORD PTR, DWORD PTR

    There are times when we need to assist assembler in translating references to data in memory.

    For example, instruction

        mov     [ESI], al  ; Store a byte-size value in memory location pointed by ESI

    suggests that an 8-bit quantity should be moved because AL is an 8-bit register.

    When instruction has no reference to operand size,

        mov     [ESI], 5   ; Error: operand must have the size specified

    To get around this instance, we must use a pointer directive, such as

        mov     BYTE PTR [ESI], 5  ; Store 8-bit value
    mov WORD PTR [ESI], 5 ; Store 16-bit value
    mov DWORD PTR [ESI], 5 ; Store 32-bit value

    These instructions require operands to be the same size.

    In general, PTR operator forces expression to be treated as a pointer of specified type:

        .DATA
    num DWORD 0

    .CODE
    mov ax, WORD PTR [num] ; Load a word-size value from a DWORD

http://www.c-jump.com/CIS77/ASM/Instructions/I77_0250_ptr_pointer.htm

关于c - MOV 和 MOV ptr 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55916891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com