[英]Assembly to C code
该汇编代码:
cmp [Variable1], 10
jae AlternateBlock
call SomeFunction
jmp AfterIfBlock
cmp [Variable1], 345
jne AfterIfBlock
call SomeOtherFunction
等于这个C代码?:
if (variable1 >= 10)
{
goto AlternateBlock;
SomeFunction();
goto AfterIfBlock;
}
else if (Variable1 != 345)
{
goto AfterIfBlock;
SomeOtherFunction();
}
更简洁地说:
if( variable1 < 10 ) {
SomeFunction();
} else if( variable1 == 345 ) {
SomeOtherFunction()
}
说明:
cmp [Variable1], 10
jae AlternateBlock ; if variable1 is >= 10 then go to alternate block
call SomeFunction ; else fall through and call SomeFunction(). ie. when variable1 < 10
jmp AfterIfBlock ; prevent falling through to next conditional
cmp [Variable1], 345
jne AfterIfBlock ; if variable1 is not equal to 345 then jump to afterifblock
call SomeOtherFunction ; else fall through to call SomeOtherFunction
如果您花一些时间来理解它,您应该会看到它在语义上与C代码等效。 也许这会有所帮助。
cmp [Variable1], 10
jb @f
call SomeFunction
jmp end
@@:
cmp [Variable1], 345
jnz end
call SomeOtherFunction
end:
不,可能更像是这样:
if (variable1 < 10)
SomeFunction();
else if (Variable1 == 345)
SomeOtherFunction();
但是您尚未将标签包括在汇编器中,所以我不确定。 我假设标签是这样的:
cmp [Variable1], 10
jae AlternateBlock
call SomeFunction
jmp AfterIfBlock
@@AlternateBlock:
cmp [Variable1], 345
jne AfterIfBlock
call SomeOtherFunction
@@AfterIfBlock:
不,这不对。 如果variable1
小于10,则汇编代码将调用SomeFunction
,而C代码则不会,它将跳转到AlternateBlock
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.