需要改一段C代码适应x64

haelue 2014-09-13 12:46:33
#elif defined(_MSC_VER)
__asm {
pushfd ; Get original EFLAGS
pop eax
mov ecx, eax
xor eax, 200000h ; Flip ID bit in EFLAGS
push eax ; Save new EFLAGS value on stack
popfd ; Replace current EFLAGS value
pushfd ; Get new EFLAGS
pop eax ; Store new EFLAGS in EAX
xor eax, ecx ; Can not toggle ID bit,
jz done ; Processor=80486
mov has_CPUID,1 ; We have CPUID support
done:
}

IDL里面的一段代码,写在“SDL_cpuinfo.c”底下,貌似汇编的,x86下编译通过,x64下编译不通过。该怎么改呢?
...全文
290 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2014-09-18
  • 打赏
  • 举报
回复
4楼高手。 建议楼主通读include\intrin.h的具体内容。
阿呆_ 2014-09-17
  • 打赏
  • 举报
回复
x64专用: #include <intrin.h> int has_CPUID() { unsigned _int64 flg = __readeflags() ^ 0x200000; __writeeflags(flg); return __readeflags() ^ flg ? 1 : 0; }
枫舞的季节 2014-09-17
  • 打赏
  • 举报
回复
使用masm64写成一个函数,然后再链接进来。
「已注销」 2014-09-17
  • 打赏
  • 举报
回复
我见过的 x64 编译器都不支持内联汇编
FancyMouse 2014-09-13
  • 打赏
  • 举报
回复
vc x64已经不允许你写inline assembly了。

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧