Chinaunix首页 | 论坛 | 博客
  • 博客访问: 182244
  • 博文数量: 42
  • 博客积分: 606
  • 博客等级: 中士
  • 技术积分: 440
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-14 15:51
文章分类

全部博文(42)

文章存档

2013年(3)

2012年(39)

我的朋友

分类: 嵌入式

2012-03-15 10:08:39



一,编译环境:gcc-2.95.3 ; Core 9 ; vivi-0.1.4(带网络版)

二,错误描述:
编译VIVI时,出现错误提示:

/opt/host/armv4l/bin/armv4l-unknown-linux-as -D__ASSEMBLY__ -I/home/echokuki/s3c2410/Experimentbck/Bootloaderv1/Bootloader/include -I/opt/host/armv4l/include/ -mapcs-32 -march=armv4 -msoft-float -o arch/s3c2410/head.o arch/s3c2410/head.s


/opt/host/armv4l/bin/armv4l-unknown-linux-as: unrecognized option '-__ASSEMBLY__'
make: *** [arch/s3c2410/head.o] Error 1

导致不能生成目标文件。


三,引用,参考:

一 GNU AS简介

   GNU AS是GNU汇编器,主要用于把汇编代码转换成二进制代码,并存放到一个object文件中。GNU AS工具本身的使用方法比较简单,主要参考文档《Using as--the GNU Assembler》(2.14)。首先看一下1.1 Structure of this Manual。

    This manual is intended to describe what you need to know to use gnu as. We cover the syntax expected in source files, including notation for symbols, constants, and expressions;the directives that as understands; and of course how to invoke as.

    This manual also describes some of the machine-dependent features of various flavors of the assembler.

    On the other hand, this manual is not intended as an introduction to programming in assembly language—let alone programming in general! In a similar vein, we make no attempt to introduce the machine architecture; we do not describe the instruction set, standard mnemonics, registers or addressing modes that are standard to a particular architecture. You may want to consult the manufacturer’s machine architecture manual for this information.


    大致意思如下:本手册要介绍如何使用gnu as,涵盖了源代码文件使用的语法(符号、常量、表达式的表示方法)、as识别的指令、如何调用as。
    本手册还描述as汇编器所支持的一些机器依赖的特性。
    另外,本手册并不介绍如何编写汇编程序。同样的思路,不回尝试去介绍机器架构,不会描述机器指令集、针对于某特定架构的标准寄存器或寻址模式。这些知识的获取,你可以参考厂商的机器架构手册。

    从上述描述可以看出,这篇文档仅仅讲述编译器as如何使用,不会教你如何编写汇编程序。原来在instruction和directive上还有所疑惑。 现在可以区分了。instrcution是CPU架构相关,比如ARM体系结构会包含指令集体系结构,这时所给出的指令集就是instruction set。而directive是汇编器相关,也就是说为了更好的使用汇编语言进行编程,汇编器会增加一部分指令,提高可读性,这部分指令就是 directive。不同的指令集体系结构对应的instruction不同,比如ARM和X86的instruction不同;不同的汇编器对应的 directive也不同,比如GNU AS和ADS汇编器对应的directive不同。

二 命令行选项

    这个需要的时候现查现看。

三 语法

1 预处理 Preprocessing


    The as internal preprocessor:
    ·adjusts and removes extra whitespace. It leaves one space or tab before the keywords on a line, and turns any other whitespace on the line into a single space.
    removes all comments, replacing them with a single space, or an appropriate number of newlines.
    converts character constants into the appropriate numeric values.

    意思如下:as的内部预处理主要包括三个方面的工作。一是调整和去除额外的间隔符。保留每行的关键字前的一个空格或者TAB,其他任意的间隔符都转换为一个空格。二是去除所有注释,代之以一个空格,或者新行的合适的数字。三是把字符常量转换成相应的数字值。

    它不能做宏处理和文件包含处理,如果你需要用,那么可以交给C 预处理器来处理。交给CPP处理的文件包含格式是不同的,需要用#include,跟C的一样(AS中用.include)。那么CPP如何识别这样的文 件呢?答案是通过后缀。man gcc可以获得,

       file.s
           Assembler code.

       file.S
           Assembler code which must be preprocessed.


四,结论
 
     这也就是在vivi的[arch/s3c2410/head.S]中扩展名为什么是大写字母S,而不是小写字母s的原因了。vivi的配置机制的结果引用就是通过#include "config.h"来完成的,对它的处理则是通过CPP完成的预处理。
      
五,解决
      重命名arch/s3c2410/head.s为arch/sc32410/head.S,命令:“#mv arch/s3c2410/head.s arch/head.S”。

转自:

阅读(1144) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:C语言中的宏定义

给主人留下些什么吧!~~