MSVC2013起x64汇编函数参数符号化访问失效问题咨询
x64汇编函数参数符号化访问在MSVC2013后失效的问题
在编写x64汇编函数时,前4个参数通过寄存器传递的逻辑正常,但此前可以通过符号化地址访问参数,从MSVC2013版本开始,符号化访问功能失效,目前只能直接通过栈偏移访问(例如指令mov ecx,[rsp+28h+4*8]),这明显是汇编功能的倒退。想确认是否遗漏了参数处理的某些规则——毕竟这种符号化访问方式在x86汇编中已经正常使用数十年。
代码示例
;void YUV_RGB(unsigned char *OutData, const unsigned char *y, const unsigned char *u, const unsigned char *v, unsigned PixelCount) public YUV_RGB IF @Version LT 1200 YUV_RGB proc \ uses rdi rsi rbx, OutData: ptr BYTE, y: ptr BYTE, u: ptr BYTE, v: ptr BYTE, PixelCount: DWORD ; on stack ELSE ; The ASM from MSVC2013 seems to be much more worse than previous one. YUV_RGB proc \ uses rdi rsi rbx ENDIF mov rdi,rcx ; [OutData] mov rsi,rdx ; [y] IF @Version LT 1200 mov ecx,PixelCount ELSE mov ecx,[rsp+28h+4*8] ;28h stays for 5th arg; rbp,rdi,rsi,rbx are now on the stack ENDIF ..................... ret YUV_RGB endp
已查阅Microsoft ml64文档,但文档对proc宏的功能描述不够完善;Stack Overflow上有类似话题,但未解决第4个及以上参数的便捷符号化访问问题。目前已有可行解决方案,但仍怀疑是否遗漏了关键规则。
附加编译问题
使用/W3编译选项时会出现错误,不使用该选项则编译正常:
Z:\prog\latex\sources.cc\images>ml64 /c /nologo /W3 img_tool_MSVC64.asm Assembling: img_tool_MSVC64.asm img_tool_MSVC64.asm(695) : error A2071:initializer magnitude too large for specified size img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : OutData img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : y img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : u img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : v
不使用/W3时编译正常:
Z:\prog\latex\sources.cc\images>ml64 /c /nologo img_tool_MSVC64.asm Assembling: img_tool_MSVC64.asm Z:\prog\latex\sources.cc\images>
旧版本ml64即使使用/W3也可正常编译,仅会出现未引用参数的警告:
Z:\prog\latex\sources.cc\images>ml64 /c /nologo /W3 img_tool_MSVC64.asm Assembling: img_tool_MSVC64.asm img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : OutData img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : y img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : u img_tool_MSVC64.asm(695) : warning A6004:procedure argument or local not referenced : v
内容的提问来源于stack exchange,提问作者Jára
相关产品推荐
相关产品推荐

