BYTE PTR, WORD PTR, DWORD PTR, and QWORD PTR are directives in x86 and x64 assembly that specify the referenced data is 8-bit, 16-bit, 32-bit, or 64-bit in size. For example,
mov DWORD PTR [rax],0x1
The above assembly instruction specifies that the 32-bit value 0x1 will be moved to the memory location specified by [RAX]. In other words, the RAX register stores a memory address here. The 32-bit value 0x1 will be moved to the memory location specified by the RAX register.
Why do we need BYTE PTR, WORD PTR, DWORD PTR, and QWORD PTR directives in x86 and x64 assembly?
Let’s say we want to move the value 0x1 to the memory location specified by the RAX register. Now, we may write:
mov [rax],0x1
But, the above instruction does not specify the operand size. So, we do not know whether the memory location referenced by the RAX register will store 8-bit, 16-bit, 32-bit, or a 64-bit value. So, we need to specify the operand size to the assembler. We do so using the BYTE PTR, WORD PTR, DWORD PTR, and QWORD PTR directives in x86 and x64 assembly.
So, if we want to move an 8-bit value to the memory location specified by the RAX register, we should write:
mov BYTE PTR [rax],0x1
And, if we want to assign a 16-bit, 32-bit or 64-bit value, we should write like the following:






0 Comments