In those cases when you look, byte ptrand word ptrdo not do much. While harmless, the assembler already “knows” that alboth dlhave byte size and that it bxhas word size.
You need something like byte ptrwhen (for example) you move an immediate value to an indirect address:
mov bx, some offset
mov [bx], 1
- , 1 , , , , . , :
mov byte ptr [bx], 1 ; write 1 into a byte
mov word ptr [bx], 1 ; write 1 into a word
mov dword ptr [bx], 1 ; write 1 into a dword
() :
mov bx, some_offset
assume bx: ptr byte
mov [bx], 1 ; Thanks to the `assume`, this means `byte ptr [bx]`
: ( @NikolaiNFettisov). :
#include <iostream>
int test() {
char bytes[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
_asm mov eax, dword ptr bytes + 1
}
int main() {
std::cout << std::hex << test();
return 0;
}
:
5040302
, dword ptr, 1 , 4. , -, , -, .