我开始学习x86程序集并尝试编写一个看起来像
的分区int a,b,c,d,e
// doing some stuff, variables will all be 32 bit
a = ((b+c)-(d+e)) / 10
所以在汇编中写一个等价物我从视频教程和这个
得到了一些帮助.comm a, 4
.comm b, 4
.comm c, 4
.comm d, 4
.comm e, 4
//add b + c
movl b, %ebx
addl c, %ebx
// add d + e
movl d, %edx
addl e, %edx
// substract (d+e) from (b+c)
subl %edx, %ebx
// clear edx, and put result into eax for division
movl $0, %edx
movl %ebx, %eax
divl $10
// put the result to var a in memory
movl %eax, a
// also put the overflow into var a in mem?
// isnt the overflow overwriting my result in memory?
movl %edx, a
所以在最后两行中,结果写回内存。为什么结果只是被溢出所取代,那也写在同一个位置。 %eax的结果是4个字节,写入mem位置a。之后,溢出,也将4个字节写入与我的结果相同的内存位置。我对装配相对较新,所以我认为我缺少必要的东西。请编辑我的问题标题,我真的找不到更好的标题。