헷갈리는 거 정리
mov rax, rbx <=rbx를 rax에 대입
mov rax, [rbx] <=rbx가 가리키는 애를 rax에 대입
mov [rax], rbx <=rbx의 값을 rax이 가리키는 위치에 대입
mov [rax], 0x1 <= 오류. 왜냐하면 operand 사이즈가 정해지지 않았으므로 [rax]에 얼마나 저장해야할지 모름
따라서 만약 8bit 짜리 value를 [rax]에 저장하고 싶으면
mov BYTE PTR [rax], 0x1 이라고 해야함 (뭔소리야 ㅅㅂ)
mov BYTE PTR [ebx], 2 ; Move 2 into the single byte at the address stored in EBX.
mov WORD PTR [ebx], 2 ; Move the 16-bit integer representation of 2 into the 2 bytes starting at the address in EBX.
mov DWORD PTR [ebx], 2 ; Move the 32-bit integer representation of 2 into the 4 bytes starting at the address in EBX.
mov BYTE PTR[0x400000], 0x57 <= 0x400000이 가리키는 위치에 1byte만큼 0x57 저장
[blahblah]는 blahblah가 가리키는 위치의 데이터
시간 날 때마다 더 추가하겠다.
References
What are BYTE PTR, WORD PTR, DWORD PTR and QWORD PTR directives in x86 and x64 assembly? - The Security Buddy
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
www.thesecuritybuddy.com
http://www.c-jump.com/CIS77/ASM/Instructions/I77_0250_ptr_pointer.htm
Directives BYTE PTR, WORD PTR, DWORD PTR
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
www.c-jump.com
https://stackoverflow.com/questions/55916891/difference-between-mov-and-mov-ptr
Difference between MOV and MOV ptr
I don't understand the difference between MOV and MOV ptr. For example, in this C code: unsigned char x, y; x = 2; the second line in assembly is: `MOV x, 2` but the second line of this C cod...
stackoverflow.com
'🖥️ Computer Science > System' 카테고리의 다른 글
[System] 메모리 주소 (x64, x32, 64bit, 32bit) (0) | 2023.03.29 |
---|---|
[Pwnable] 시스템콜(syscall), 셸, 커널모드 vs 유저모드 (0) | 2023.03.26 |
[Assembly] 어셈블리어 필수 명령어 정리본 (스택 관련) (0) | 2023.03.26 |
[System] 컴퓨터 메모리 구조 / 레이아웃 (0) | 2023.03.19 |
[System] 컴퓨터 구조, 폰 노이만 구조, x86-64, 레지스터 (0) | 2023.03.17 |