在MUL上携带标志大于2^128?
如果以下代码导致大于2^128的东西会产生(输出)吗?
mov rdx, -1 //rdx = 0xff...f
mov rax, -1 //rax = 0xff...f
mov rbx, -1 //rbx = 0xff...f
mul rbx //result will be bigger than 128 bits therefore will be pushed out of rdx
jc end
...
end: ret
因此,我的问题归结为使用合并的寄存器RAX:rdx用于 mul
操作时的行为。 JC
会在RDX寄存器上自动看柔软,或者在结果大于RAX时触发?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅Intel的手册...
如果结果的上半部分(RDX,EDX,DX或AH)为零,则MUL清除CF,则设置为零。
mul
具有两个相同宽度的输入。只有输出是双宽。CF不用于测量整个事物的溢出,因为两个64位乘法无法导致129位结果,因此在这种意义上是不可能的。
cf实际上表示下半场的溢出。原始8086没有非湿型乘数(
imul ecx,esi
),因此您必须使用mul
或imul
,即使您没有t关心高半结果。知道结果仍然适合一个寄存器是有用的,尤其是在16位的世界中,比最宽的可用寄存器较大的值比x86-64更为普遍。Refer Intel's Manual please... https://www.felixcloutier.com/x86/mul#flags-affected
MUL clears the CF if the upper half of the result (RDX, EDX, DX, or AH) is zero, else it's set.
mul
has two inputs of the same width. Only the output is double-width.CF is not used to measure overflow of the whole thing, as two 64 bit multiplicands cannot result into a 129 bit result, so an overflow in that sense is not possible.
CF actually indicates overflow of the low half. Original 8086 didn't have non-widening multiply (
imul ecx, esi
), so you had to usemul
orimul
even if you didn't care about the high-half result. Knowing that the result still fit in one register was potentially useful, especially in a 16-bit world where values wider than the widest available register were more common than on x86-64.