怎么在c当中嵌套汇编呀?

linhai1978 2003-12-19 09:48:17
我试过这几个-asm xor bx,bx
asm xor bx,bx
_asm xor bx,bx
asm
{
xor bx,bx
}
都没用处
...全文
45 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
linhai1978 2003-12-20
  • 打赏
  • 举报
回复
谢谢大家真的很感谢
lyjyyl 2003-12-20
  • 打赏
  • 举报
回复
在TURBO C中好像不行
lyjyyl 2003-12-20
  • 打赏
  • 举报
回复
用Microsoft C可以实现嵌入汇编代码
Letbeger 2003-12-20
  • 打赏
  • 举报
回复
错了
只是最下面的那段
#include <stdio.h>

char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
void main( void )
{
__asm
{
mov eax, offset world
push eax
mov eax, offset hello
push eax
mov eax, offset format
push eax
call printf
//clean up the stack so that main can exit cleanly
//use the unused register ebx to do the cleanup
pop ebx
pop ebx
pop ebx
}
}
别忘了把你汇编语言的那几个文件放到你tc的目录下
Letbeger 2003-12-20
  • 打赏
  • 举报
回复
如何在c中放入汇编
main()
{
asm mov ax,1;
}

__asm // __asm block
{
mov eax, 01h
int 10h
}
#include <stdio.h>

char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
void main( void )
{
__asm
{
mov eax, offset world
push eax
mov eax, offset hello
push eax
mov eax, offset format
push eax
call printf
//clean up the stack so that main can exit cleanly
//use the unused register ebx to do the cleanup
pop ebx
pop ebx
pop ebx
}
}
别忘了把你汇编语言的那几个文件放到你tc的目录下
redbad2 2003-12-20
  • 打赏
  • 举报
回复
TC里面当然可以嵌入汇编了,各式就像下面:

_asm
{
...
}
aloxy 2003-12-19
  • 打赏
  • 举报
回复
_asm
{
...
}
5852 2003-12-19
  • 打赏
  • 举报
回复
#include <stdio.h>



int power2( int num, int power );



void main( void )

{

printf( "3 times 2 to the power of 5 is %d\n", \

power2( 3, 5) );

}

int power2( int num, int power )

{

__asm

{

mov eax, num ; Get first argument

mov ecx, power ; Get second argument

shl eax, cl ; EAX = EAX * ( 2 to the power of CL )

}

/* Return with result in EAX */

}


70,035

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧