Chinaunix首页 | 论坛 | 博客
  • 博客访问: 38943
  • 博文数量: 10
  • 博客积分: 236
  • 博客等级: 二等列兵
  • 技术积分: 110
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-20 21:15
文章分类
文章存档

2013年(3)

2012年(7)

我的朋友

分类: LINUX

2012-12-01 16:32:41

I was busying studying my Linux , who called Ubuntu.Assemble compiled is interesting. I has known to use the ORDER::AS to compile the AT&T and ORDER ::nasm to compile the Intel ASSEMBLE,since I use learnt the program.
But ,how to use the Assemble to insert the C program ?I read many book borrowed from my school library.It is a joke what the same as many books.Copy the book from another book.And more ,some as written one sentence just one line.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
OFFTEN SHOW ERROR:
ERROR::ONE
inline.c: 在函数‘main’中:
inline.c:9:1: 错误: expected ‘)’ before ‘:’ token


solution:
(MAYBE HERE::)__asm__ __volatile__
[
   attention:: _ _ asm _ _ (space)  _ _ volatile _ _  (Enlarge , is RIGHT)
                         _asm_ _ volatile_ (maybe it is your writed,is WRONG)
]
ERROR::TWO
inline.c: Assembler messages:
inline.c:6: Error: junk at end of line, first unrecognized character is `\'



solution:
[
"movl %1,%%eax;\\n\\t"  (WRONG)
"movl %1,%%eax;\n\t"  (RIGHT)
OR
"movl %1,%%eax;\n\r"(RIGHT)
]
ERROR:THREE
inline.c: 在函数‘main’中:
inline.c:14:3: 警告: 隐式声明与内建函数‘printf’不兼容 [默认启用]


[
whether you added the head C file ::stdio.h
]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Now ,I copy some from the Book  and Internet ,and integrate what I  do test on my computer.
PIC As following:
---------------------
inline.c
---------------------

[this code can be run]
you can add::return 0 at the tail of the program.


[
order :
1、gcc -S inline.c 
 #produce a file called inline.s  written by assemble  you can use
                 [ cat -n inline.s]
to show this file
2、gcc -o inline inline.s
3、./inline 
#show this result as you see.
]


Order show as the PICTURE,YOU SEE.
Thank you for you read.

阅读(1101) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~