C中嵌入汇编的问题!(100分)

Z

zyy04

Unregistered / Unconfirmed
GUEST, unregistred user!
C中嵌入汇编的问题!使用规则,请举例说明(如:如何将变量值传入寄存器,和
由寄存器传值给变量)
 
unsigned char uc;
_asm mov al,10h
_asm out 70h,al
_asm in al,71h;
_asm mov uc,al;
 
看一下我的程序哪儿有问题呀(linux下编译不能通过!)
#include <stdio.h>
int main()
{ int i,dirc,place;
i=12345;
dirc=0;
place=2;
asm mov cx,word ptr place;
asm mov ax,dirc;
asm cmp ax,1;
asm jne Right;
asm rol i,cl;
asm jmp end;
Right:
asm ror i,cl;
Rnd:
printf("%d/n",i);
return 0;
}
 
jmp end中end是你写错了吗,在linux中有什么错误?
 
源文件如下(完全的):
#include <stdio.h>
int main()
{
int i,dirc,place;
i=12345;
dirc=0;
place=2;
asm mov cx,word ptr place;
asm mov ax,dirc;
asm cmp ax,1;
asm jne right;
asm rol i,cl;
asm jmp rnd;
right:
asm ror i,cl;
rnd:
printf("%d/n",&amp;i);
return 0;
}
编译和错误信息:
gcc -o a test.c
test.c: In function `main':
test.c:9: parse error before `mov'
test.c:16: parse error before `ror'
 

asm mov ax,dirc;
应为
asm mov ax,word ptr dirc 因为dire为整数,而非unsigned int。
其他的应该没有错!!!
 
多人接受答案了。
 
顶部