pointers - 在 Win64 下,设置了 MSB(即保存负值)的指针总是无效吗?

标签 pointers assembly 64-bit win64

我正在重写一些快速字符串函数。
此练习的目标是消除跳跃,以避免错误预测。
该代码仅在用户空间中运行。

Win64 指针的计算结果是否始终为正 Int64 值?

function BothValid(a,b: pointer): boolean;
// a= rcx
// b= rdx
asm
  lea    rax, [rcx-4]
  lea    r8,  [rdx-4]
  or     r8,  rax
  js @OneOrMoreNullPointers 
  ....       

上述测试空指针的方法是否始终有效?

最佳答案

没关系,找到相关链接:https://msdn.microsoft.com/en-us/library/windows/hardware/hh439648%28v=vs.85%29.aspx

For a 32-bit process, the virtual address space is usually the 2-gigabyte range 0x00000000 through 0x7FFFFFFF. For a 64-bit process, the virtual address space is the 8-terabyte range 0x000'00000000 through 0x7FF'FFFFFFFF.

portions of the 248-terabyte range from 0xFFFF0800'00000000 through 0xFFFFFFFF'FFFFFFFF are used for system space.

Code running in user mode has access to user space but does not have access to system space.

在 32 位中,您可以将用户空间的大小增加到最大 3 GB;在这种情况下,用户空间指针可以具有负 int 值。

所以,是的,Win64 中的用户空间指针始终为正数。
内核空间指针始终为负数。

关于pointers - 在 Win64 下,设置了 MSB(即保存负值)的指针总是无效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31169945/

相关文章:

c# - IntPtr 和 UIntPtr 的区别

arrays - C: 'the incompatible pointer types passing' 警告很重要?/将多维数组传递给函数

复制一维元素二维数组

assembly - MASM32中令人困惑的括号

delphi - 64 位 XE2 中的 Integer()

Java - 将指向对象的指针传递给函数

c++ - 汇编程序和C++的关系

assembly - 获取字节中特定位的值

c# - 适用于 Windows x64 上大文件的良好 ISAM 库或其他简单文件管理器

windows - 如何在 Windows 上的 x86-64 架构上的程序集中注册结构化异常处理程序?