Chinaunix首页 | 论坛 | 博客
  • 博客访问: 180771
  • 博文数量: 80
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 835
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-29 10:30
文章分类
文章存档

2009年(12)

2008年(60)

2007年(8)

我的朋友

分类: 项目管理

2008-07-03 11:34:54

1. Introduction

In ADS and SDT environment, arm asm is usually used, it can be compiled by arm compiler, armcc.

While for linux programming environment, we use GNU GCC compiler that supports GNU asm (GAS).

These two kinds of asm compiler has different syntax, so it’s important to replant one kind of code to another.

In this document, the most important things that should be kept in mind during the replanting stage is put.

In arm asm, “;” is used to comment off a line.

In GAS, we use “@”, “#” or “//” can be used to comment off a line, and “/*  */” can be used to comment off more than one line.

The example below show the difference,

For ADS environment

;

; ---------------------------------------------------------------------------

;Static Global Data section variables

;---------------------------------------------------------------------------

;

; -------------------------- NONE -------------------------------------------

For GAS environment

@

/* ---------------------------------------------------------------------------

@Static Global Data section variables

@---------------------------------------------------------------------------

*/

// -------------------------- NONE -------------------------------------------

(1). Define a constant:

ADS:  @TIMER1_CTRL              EQU     0x0A800008

GAS:  .equ              TIMER1_CTRL,  0x0A800008

(2). Define a label or symbal:

ADS:  LABEL_ONE

GAS:  LABEL_ONE:

(3).

ADS:  DCD

GAS:  .long

(4). Define a function:

ADS:  myfunc FUNCTION

XXXX  

XXXX

ENDFUNC

Or

myfunc PROC

XXXX  

XXXX

ENDP

GAS:  myfunc:

XXXX  

XXXX

(5). Define a global function or variable

ADS:  @EXPORT SspSipStopTimer1

GAS:  .global     SspSipStopTimer1

(6).

ADS:  DCD

GAS:  .long

(7). Code section

ADS:  AREA WORD, CODE, READONLY

          XXXX

          XXXX

          END

GAS:  .text

          XXXX

          XXXX

          .end

(8). Data section

ADS:  AREA BLOCK, DATA, READWRITE

          XXXX

          XXXX

          END

GAS:  .data

          XXXX

          XXXX

          .end

(9).

ADS:  :OR:

GAS:  |

(10).

ADS:  :SHL:

GAS:  <<

(11).

ADS:  :SHR:

GAS:  >>

(12).

ADS:  CODE32:

GAS:  .arm

(13).

ADS:  CODE16:

GAS:  .thumb

(14).

ADS:  %:

GAS:  .fill

(15).

ADS:  LTORG:

GAS:  .ltorg

(16).

ADS:  INCLUDE:

GAS:  .include

(17).

ADS:  IF:DEF:

GAS:  .IFDEF

(18).

ADS:  ELSE

GAS:  .ELSE

(19).

ADS: ENDIF

GAS: .ENDIF

(20).

ADS: &

GAS: +0x

(1). For GAS, the normal inline asm syntax is like,

__asm__("asm statements" : outputs : inputs : registers-modified);

(2). It can be explained by,

__asm__ __volatile__(

"movl %1, %%eax;\n\r"  /*1st line code, add */

"movl %%eax, %0;" /*2nd line code*/

:"=r"(b)      /* output */    

:"r"(a)       /* input */

:"%eax");     /*if have, show the registers that should not be effected */

(3). The example below shows how to do the replanting.

For ADS environment

    __asm{

            rsbs    dumy, var2, 0

            movmi   L_var_out, L_var1, lsl var2

            movpl   L_var_out, L_var1, asr dumy

         }

For GAS environment

       __asm__ __volatile__(

            " rsbs    %0, %3, #0;\n\r"

            " movmi   %1, %2, lsl %3;\n\r"

            " movpl   %1, %2, asr %0"

            :"=r" (dumy), "=r" (L_var_out)

            :"r" (L_var1), "r" (var2)

);

or

    asm volatile(

               " rsbs    %0, %3, #0;\n\r"

            " movmi   %1, %2, lsl %3;\n\r"

            " movpl   %1, %2, asr %0"

            :"=r" (dumy), "=r" (L_var_out)

            :"r" (L_var1), "r" (var2)

       );

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