Last active
September 26, 2022 00:22
-
-
Save israellot/1cd1ee394dfeb1090e2333872149be53 to your computer and use it in GitHub Desktop.
Example of pointer access with int vs uint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe int PointerAccessInt(byte* ptr,int x,int y) | |
{ | |
return ptr[x]& ptr[x+y]; | |
} | |
public static unsafe int PointerAccessUInt(byte* ptr,uint x,uint y) | |
{ | |
return ptr[x]& ptr[x+y]; | |
} | |
/* | |
Program:PointerAccessInt(long,int,int):int: | |
movsxd rax, esi | |
movzx rax, byte ptr [rdi+rax] | |
add esi, edx | |
movsxd rsi, esi | |
movzx rdi, byte ptr [rsi+rdi] | |
and eax, edi | |
ret | |
Program:PointerAccessUInt(long,int,int):int: | |
mov eax, esi | |
movzx rax, byte ptr [rdi+rax] | |
add esi, edx | |
movzx rdi, byte ptr [rsi+rdi] | |
and eax, edi | |
ret | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment