Sunteți pe pagina 1din 31

TMS320C54XX INSTRUCTIONS & PROGRAMMING

Load

& Store Instructions: Load Instructions 1. LD Load Acc with shift The LD instruction loads the acc with a data memory value or an immediate value This instruction supports different shift quantities. Also supports acc to acc moves with shift

Syntax: 1. LD Smem, dst 2. LD #lk, dst


2. LDM: Load acc from a MMR. LDM MMR, dst 3. Load TREG/DP/ASM/ARP The load inst. Loads a value into TREG or into the following fields of the status register: DP,ASM,ARP

Store Instructions: ST Store TREG, TRN or immediate value into memory 1. ST T, Smem 2. ST TRN, Smem 3. ST #lk, Smem

1.
2. 3.

STH Store acc high into memory STH src, Smem STH src, ASM, Smem STH src, SHIFT1, Xmem

1. 2.

STL Store acc low into memory STL src, Smem STL src,ASM, Smem

STLM Store acc low into MMR STLM src, MMR STM Store immediate value into MMR STM #lk,MMR

Conditional Store Inst : CMPS, STRCD Parallel Load & Store Inst : ST||LD Parallel Load & Multiply Inst :LD||MAC Parallel Store & add/subtract Inst : ST||ADD, ST||SUB Parallel Store & Multiply Inst : ST||MAC, ST||MPY Misc Load type & store type Inst: MVDD, MVPD

Arithmetic Operations
Add Inst : ADD, ADDC Subtract : SUB, SUBB Multiply : MPY, MPYA Multiply & Accumulate : MACD, MAC Multiply & Subtract : MAS, MASA

Logical

Operations

AND Inst : AND, ANDM OR : OR, ORM XOR : XOR, XORM Shift : ROL, SFTL Test : BIT, CMPM

Program Control Instructions:

Branch Inst : B, BACC Call : CALL, CALA Interrupt : INTR, TRAP Return : RET, FRET Repeat : RPT, RPTB Stack : PUSHD, POPD Miscellaneous : IDLE, RESET

ASSEMBLER DESCRPITION

i. ii. iii.

The assembler translates assembly language source files into machine language object files. Source files can contain the following assembly language elements: assembler directives macro directives assembly language instructions

i.

ii.

iii.

iv.

The assembler does the following: processes the source statements in a text file to produce a relocatable C54x object file Allows to segment the code into sections and maintain a section program counter (SPC) for each section of object code Defines and references global symbols Assembles conditional blocks

Naming alternate files & directories for assembler input:

The .copy, .include and .mlib directives tell the assembler to use code from external files. ii. The .copy and .include directives tell the assembler to read source statements from another file, and the .mlib directive names a library that contains macro functions. Syntax: .copy filename
i.

Source Statement Format:

i. ii. iii.

iv.

TMS320C54x assembly language source programs consist of source statements that can contain assembler directives assembly language instructions macro directives comments

Source Statement Syntax


A

source statement can contain four ordered fields. Mnemonic Syntax: [label][:] mnemonic [operand list] [;comment] All statements must begin with a label, a blank, an asterik or a semicolon. A statement containing an assembler directive must be specified entirely on one line.

Labels are optional; if used, they must begin in column 1 One or more blanks must separate each field. Tab characters are equivalent to blanks Comments are optional. Comments that begin in column1 can begin with an asterik or a semicolon, but comments that begin in any other column must begin with a semicolon

Label Field

Labels are optional for all assembly language instructions and for most assembler directives. A label must begin in column 1 of a source statement. A label can contain up to 32 alphanumeric characters (A-Z,a-z,0-9,_ and $). Labels are case sensitive, and the first character cannot be a number. A label can be followed by a colon, the colon is not treated as part of the label name.

If a label is not used, the first character position must contain a blank, a semicolon, or an asterik.

Mnemonic Instruction Fields:


In mnemonic assembly, the label field is followed by the mnemonic and operand fields. Mnemonic Field: This field follows the label field. This field must not start in column 1; if it does, it will be interpreted as a label.

It can contain one of the following opcodes: machine instruction mnemonic (ABS, STH) assembler directive (.data, .list) macro directive macro call

Operand Field
The

operand field is a list of operands that follow the mnemonic field. An operand can be a constant, a symbol, or a combination of constants and symbols in an expression The assembler allows to specify that a constant, symbol or an expression should be used as an address, an immediate value, or an indirect value.

Comment Field
A

comment can begin in any column and extends to the end of the source line. A comment can contain any ASCII character, including blanks. A source st. that contains a comment alone is valid. Comments that begin in column1 can begin with an asterik or a semicolon, but comments that begin in any other column must begin with a semicolon

Assembler directives

Assembler directives supply data to the program and control the assembly process. Assembler directives enable you to do the following: Assemble code and data into specified sections Reserve space in memory for uninitialized variables Assemble conditional blocks Declare global variables Specify libraries from which the assembler can obtain macros

Directives

that define sections .bss symbol, size in words [, blocking][, alignment ] Reserve size words in the .bss (un initialized data) section .data Assemble into the .data (initialized data) .sect section name Assemble into a named (initialized) section .text Assemble into the .text (executable code) section symbol .usect section name, size in words [, blocking] [,alignment] Reserve size words in a named (un initialized) section

Directives that initialize constants (data and memory) .bes size in bits Reserve size bits in the current section; note that a label points to the last addressable word in the reserved space .byte value1 [, ... , valuen] .char value1 [, ... , valuen] Initialize one or more successive words in the current section
.double value1 [, ... , valuen] .ldouble value1 [, ... , valuen] Initialize one or more 64-bit, IEEE doubleprecision,floating-point constants

.double

value1 [, ... , valuen] .ldouble value1 [, ... , valuen] Initialize one or more 64-bit, IEEE doubleprecision,floating-point constants .int value1 [, ... , valuen] Initialize one or more 16-bit integers 4-67 .long value1 [, ... , valuen] Initialize one or more 32-bit integers

Directives that reference other files .copy []filename[] Include source statements from another file .def symbol1 [, ... , symboln] Identify one or more symbols that are defined in the current module and may be used in other modules .global symbol1 [, ... , symboln] Identify one or more global (external) symbols .include []filename[] Include source statements from another file

Directives That Define Sections


These directives associate portions of an assembly language program with the appropriate sections: .bss reserves space in the .bss section for uninitialized variables. .data identifies portions of code in the .data section. The .data section usually contains initialized data. .sect defines initialized named sections and associates subsequent code or data with that section. A section defined with .sect can contain executable code or data.

.text

identifies portions of code in the .text section. The .text section usually contains executable code. .usect reserves space in an uninitialized named section. The .usect directive is similar to the .bss directive, but it allows to reserve space separately from the .bss section.

1 ************************************************** 2 * Start assembling into the .text section * 3 ************************************************** 4 000000 .text 5 000000 0001 .word 1,2 000001 0002 6 000002 0003 .word 3,4 000003 0004 7 8 ************************************************** 9 * Start assembling into the .data section * 10 ************************************************** 11 000000 .data 12 000000 0009 .word 9, 10 000001 000A 13 000002 000B .word 11, 12 000003 000C 14

15 ************************************************** 16 * Start assembling into a named, * 17 * initialized section, var_defs * 18 ************************************************** 19 000000 .sect var_defs 20 000000 0011 .word 17, 18 000001 0012 21 22 ************************************************** 23 * Resume assembling into the .data section * 24 ************************************************** 25 000004 .data 26 000004 000D .word 13, 14 000005 000E 27 000000 .bss sym, 19 ; Reserve space in .bss 28 000006 000F .word 15, 16 ; Still in .data 000007 0010 29

30 ************************************************** 31 * Resume assembling into the .text section * 32 ************************************************** 33 000004 .text 34 000004 0005 .word 5, 6 000005 0006 35 000000 usym .usect xy, 20 ; Reserve space in xy 36 000006 0007 .word 7, 8 ; Still in .text 000007 0008

.text initializes words with the values 1, 2, 3, 4, 5, 6, 7, and 8. .data initializes words with the values 9, 10, 11, 12, 13, 14, 15,and 16. .bss reserves 19 words. .usect reserves 20 words. The .bss and .usect directives do not end the current section or begin new sections; they reserve the specified amount of space, and then the assembler resumes assembling code or data into the current section.

S-ar putea să vă placă și