-1
我对c语言更加熟悉,但我们如何将以下c语言编码写入汇编语言?我试过但总是失败。关于汇编语言条件选择
if(a==4)
{
routine1();
}
else if(a==5)
{
routine2();
}
else if(a==6)
{
routine3();
}
我对c语言更加熟悉,但我们如何将以下c语言编码写入汇编语言?我试过但总是失败。关于汇编语言条件选择
if(a==4)
{
routine1();
}
else if(a==5)
{
routine2();
}
else if(a==6)
{
routine3();
}
一种可能性是使用goto
重写它,那么它应该是直截了当地移植到你使用任何语言汇编。
if (a != 4) goto not4;
routine1();
goto end;
not4: if (a != 5) goto not5;
routine2();
goto end;
not5: if (a != 6) goto not6;
routine3();
end:
在86它会是这样的命令http://www.gabrielececchetti.it/Teaching/CalcolatoriElettronici/Docs/i8086_instruction_set.pdf
a100
mov al, 0500;move whats in memory location 0500 to al register
mov bl,4; mov 4 into bl register
cmp al,bl;this compares them basically subtracting them so 0 is equal
jz label1;the label is another memory location that you would jump to if they are equal
mov bl,5; if it doesnt jump then the code will continue to run
cmp al,bl
jz label2
mov bl,6
cmp al,bl
jz label3
int 3; to end program or you can use ret
的深度描述也检查出的链接...
label1 call 0200;call instruction runs the code that is at the memory location stated
label2 call 0300
label3 call 0400
希望这有助于记住这个是x86! 快乐编码!
哪种汇编语言? – harold