Embedded: ARM symbol definition pseudo-operation detailed explanation

Pseudo-operations, macro-instructions and pseudo-instructions of ARM assembly language

Statements in ARM assembly language source programs are generally composed of instructions, pseudo-operations, macro instructions, and pseudo-instructions.
Pseudo-operations are some special instruction mnemonics in ARM assembly language programs. Its role is mainly to prepare for the completion of assembly programs. , which is processed by the assembler when the source program is assembled, rather than being executed by the machine while the computer is running.

A macro instruction is an independent program code that can be inserted into a source program, and it is defined by a pseudo-operation. Macros must be defined in advance before being used. Macros can call each other or recursively call themselves. Use the macro by directly writing the macro name, and set the corresponding input parameters according to the format of the macro instruction. The macro definition itself does not generate code, but inserts the macro body into the source program when calling it.

Pseudo-instructions are also special instruction mnemonics in ARM assembly language programs, and are not executed by the machine during processor operation. They will be replaced by appropriate machine instructions into ARM or Thumb instructions during assembly to achieve real instruction operations.

Introduction to Integrated Development Environment IDE with Two Compilation Modes

ADS/SDT IDE development environment

It was developed by ARM, using the compiler of CodeWarrior;

IDE development environment integrated with GNU development tools

It consists of GNU assembler as, cross compiler gcc, and linker ld.

ARM Pseudo-operations and Macro-instructions in ADS Compilation Environment

The pseudo-operations in the ADS compilation environment are as follows:

  • Symbol Definition pseudo-operation
  • Data Definition Pseudo-Operations
  • Assembly Control Pseudo-Operations
  • Frame Description pseudo-operation
  • Information Reporting (Reporting) pseudo-operation
  • Other (Miscellaneous) Pseudo-Operations

symbol definition pseudo-op

  1. Global variable definition directives GBLA, GBLL, GBLS
  2. Local variable definition directives LCLA, LCLL, LCLS
  3. Variable assignment directives SETA, SETL, SETS
  4. Register list definition directive RLIST

GBLA, GBLL and GBLS

The GBLA, GBLL and GBLS pseudo-operations are used to declare global variables in an ARM program and initialize them by default.

The GBLA pseudo-operation declares a global arithmetic variable and initializes it to 0

The GBLL pseudo-operation declares a global logical variable and initializes it to {FALSE}

The GBLS pseudo-operation declares a global string variable and initializes it to the empty string ""

grammatical format

<GBLX>  Variable

​ Among them:
<GBLX>is one of the three pseudo-operations of GBLA, GBLL or GBLS; Variable is the name of the global variable. It must be unique within its scope, that is, the same variable name can only appear once within its scope.

Example of use

GBLA  A1  ;定义一个全局的数值变量,变量名为A1
 A1    SETA  0x0F ;将该变量赋值为0x0F
            
GBLL  A2   ;定义一个全局的逻辑变量,变量名为A2
 A2    SETL  {TRUE} ;将该变量赋值为真
        
GBLS  A3 ;定义一个全局的字符串变量,变量名为A3
 A3    SETS “Testing”  ;将该变量赋值为“Testing”

LCLA, LCLL and LCLS

The LCLA, LCLL and LCLS pseudo-operations are used to declare local variables in an ARM program and initialize them by default.

The LCLA pseudo-op declares a local arithmetic variable and initializes it to zero.

The LCLL pseudo-op declares a local logical variable and initializes it to {FALSE}

The LCLS pseudo-op declares a local string variable and initializes it to the empty string ""

grammatical format

<LCLX>  Variable

in:

<LCLX>It is one of 3 pseudo-operations of LCLA, LCLL or LCLS; Variable is the name of a local variable. It must be unique within its scope, that is, the same variable name can only appear once within its scope.

Example of use

  LCLA   Test4 ;声明一个局部的数值变量,变量名为Test4
  Test4  SETA  0xaa  ;将该变量赋值为0xaa

  LCLL   Test5     ;声明一个局部的逻辑变量,变量名为Test5
  Test5  SETL {TRUE} ;将该变量赋值为真

  LCLS   Test6  ;定义一个局部的字符串变量,变量名为Test6
  Test6  SETS  “Testing” ;将该变量赋值为“Testing”

SETA, SETL and SETS

The SETA, SETL, and SETS pseudo-operations are used to assign values ​​to global or local variables in an ARM program.

The SETA pseudo-operation assigns a value to a global or local arithmetic variable

The SETL pseudo-operation assigns a value to a global or local logical variable

The SETS pseudo-operation assigns a value to a global or local string variable

grammatical format

<SETX>  Variable  expr

in:

<SETX>It is one of the three pseudo-operations of SETA, SETL or SETS; Variable is the name of a variable defined using GBLA, GBLL, GBLS, LCLA, LCLL or LCLS, and must be unique within its scope; expr is an expression, that is, the name assigned to the variable value.

Register list definition directive RLIST

Format: name RLIST {general purpose register list}

Function: used to define a name for a general-purpose register list,

 reglist RLIST {R0-R3, R8, R12}
		…
	STMFD	SP!, reglist			
; 将列表reglist存储到堆栈中
		…
	LDMIA	R4, reglist			
; 将列表reglist加载到R4中

references:

Meng Xianglian. Embedded System Principles and Application Tutorial (Second Edition) [M]. Beijing: Tsinghua University Press, 2017.

Guess you like

Origin blog.csdn.net/m0_52316372/article/details/128466131