tms320c54 assembly
Post on 06-Apr-2018
219 Views
Preview:
TRANSCRIPT
-
8/2/2019 Tms320c54 Assembly
1/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 shiftquantities.
Also supports acc to acc moves with shift
-
8/2/2019 Tms320c54 Assembly
2/31
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 thefollowing fields of the status register:DP,ASM,ARP
-
8/2/2019 Tms320c54 Assembly
3/31
Store Instructions:
ST Store TREG, TRN or immediatevalue into memory
1. ST T, Smem
2. ST TRN, Smem3. ST #lk, Smem
STH Store acc high into memory1. STH src, Smem
2. STH src, ASM, Smem
3.
STH src, SHIFT1, Xmem
-
8/2/2019 Tms320c54 Assembly
4/31
STL Store acc low into memory
1. STL src, Smem2. STL src,ASM, Smem
STLM Store acc low into MMRSTLM src, MMR
STM Store immediate value into MMR
STM #lk,MMR
-
8/2/2019 Tms320c54 Assembly
5/31
Conditional Store Inst : CMPS, STRCD
Parallel Load & Store Inst : ST||LDParallel Load & Multiply Inst :LD||MAC
Parallel Store & add/subtract Inst :
ST||ADD, ST||SUBParallel Store & Multiply Inst : ST||MAC,
ST||MPY
Misc Load type & store type Inst: MVDD,MVPD
-
8/2/2019 Tms320c54 Assembly
6/31
Arithmetic Operations
Add Inst : ADD, ADDC
Subtract : SUB, SUBB
Multiply : MPY, MPYA Multiply & Accumulate : MACD, MAC
Multiply & Subtract : MAS, MASA
-
8/2/2019 Tms320c54 Assembly
7/31
Logical Operations
AND Inst : AND, ANDM
OR : OR, ORM XOR : XOR, XORM
Shift : ROL, SFTL
Test : BIT, CMPM
-
8/2/2019 Tms320c54 Assembly
8/31
Program Control Instructions:
Branch Inst : B, BACC
Call : CALL, CALA
Interrupt : INTR, TRAPReturn : RET, FRET
Repeat : RPT, RPTB
Stack : PUSHD, POPD
Miscellaneous : IDLE, RESET
-
8/2/2019 Tms320c54 Assembly
9/31
ASSEMBLER DESCRPITION
The assembler translates assemblylanguage source files into machinelanguage object files.
Source files can contain the followingassembly language elements:
i. assembler directives
ii. macro directives
iii. assembly language instructions
-
8/2/2019 Tms320c54 Assembly
10/31
The assembler does the following:
i. processes the source statements in a textfile to produce a relocatable C54x objectfile
ii. Allows to segment the code into sectionsand maintain a section program counter(SPC) for each section of object code
iii. Defines and references global symbolsiv. Assembles conditional blocks
-
8/2/2019 Tms320c54 Assembly
11/31
Naming alternate files & directories for
assembler input:i. The .copy, .include and .mlib directivestell the assembler to use code fromexternal files.
ii. The .copy and .include directives tell theassembler to read source statementsfrom another file, and the .mlib directive
names a library that contains macrofunctions.
Syntax: .copy filename
-
8/2/2019 Tms320c54 Assembly
12/31
Source Statement Format:
TMS320C54x assembly language sourceprograms consist of source statementsthat can contain
i. assembler directives
ii. assembly language instructions
iii.
macro directivesiv. comments
-
8/2/2019 Tms320c54 Assembly
13/31
Source Statement Syntax
A source statement can contain four orderedfields.
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 assemblerdirective must be specified entirely on oneline.
-
8/2/2019 Tms320c54 Assembly
14/31
Labels are optional; if used, they mustbegin in column 1
One or more blanks must separate eachfield.
Tab characters are equivalent to blanks
Comments are optional. Comments thatbegin in column1 can begin with anasterik or a semicolon, but comments thatbegin in any other column must beginwith a semicolon
-
8/2/2019 Tms320c54 Assembly
15/31
Label Field Labels are optional for all assembly language
instructions and for most assemblerdirectives.
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 firstcharacter cannot be a number.
A label can be followed by a colon, the colonis not treated as part of the label name.
-
8/2/2019 Tms320c54 Assembly
16/31
If a label is not used, the first characterposition must contain a blank, asemicolon, or an asterik.
-
8/2/2019 Tms320c54 Assembly
17/31
Mnemonic Instruction Fields:
In mnemonic assembly, the label field isfollowed by the mnemonic and operandfields.
Mnemonic Field:
This field follows the label field.
This field must not start in column 1; if itdoes, it will be interpreted as a label.
-
8/2/2019 Tms320c54 Assembly
18/31
It can contain one of the following
opcodes: machine instruction mnemonic (ABS,
STH)
assembler directive (.data, .list) macro directive
macro call
-
8/2/2019 Tms320c54 Assembly
19/31
Operand Field
The operand field is a list of operands thatfollow the mnemonic field.
An operand can be a constant, a symbol,or a combination of constants and symbolsin an expression
The assembler allows to specify that aconstant, symbol or an expression shouldbe used as an address, an immediatevalue, or an indirect value.
-
8/2/2019 Tms320c54 Assembly
20/31
Comment Field
A comment can begin in any column andextends to the end of the source line.
A comment can contain any ASCIIcharacter, including blanks.
A source st. that contains a comment aloneis valid.
Comments that begin in column1 can
begin with an asterik or a semicolon, butcomments that begin in any other columnmust begin with a semicolon
-
8/2/2019 Tms320c54 Assembly
21/31
Assembler directives Assembler directives supply data to the
program and control the assembly process.Assembler directives enable you to do thefollowing:
Assemble code and data into specifiedsections
Reserve space in memory for uninitializedvariables
Assemble conditional blocks Declare global variables
Specify libraries from which the assembler
can obtain macros
-
8/2/2019 Tms320c54 Assembly
22/31
Directives that define sections
.bss symbol, size in words [, blocking][, alignment ]Reserve size words in the .bss (un initializeddata) section
.data Assemble into the .data (initialized data)
.sect section name Assemble into a named(initialized) section
.text Assemble into the .text (executable code)
sectionsymbol .usect section name, size in words
[, blocking] [,alignment] Reserve size words in a
named (un initialized) section
-
8/2/2019 Tms320c54 Assembly
23/31
Directives that initialize constants (data andmemory)
.bes size in bits Reserve size bits in thecurrent section; note that a label points tothe 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 double-
precision,floating-point constants
-
8/2/2019 Tms320c54 Assembly
24/31
.double value1 [, ..., valuen]
.ldouble value1 [, ..., valuen] Initialize oneor more 64-bit, IEEE double-precision,floating-point constants
.int value1 [, ..., valuen] Initialize one ormore 16-bit integers 4-67
.longvalue1 [, ..., valuen] Initialize one or
more 32-bit integers
-
8/2/2019 Tms320c54 Assembly
25/31
Directives that reference other files
.copy []filename[] Include sourcestatements from another file
.def symbol1 [, ..., symboln] Identify one ormore symbols that are defined in the
current module and may be used in othermodules
.global symbol1 [, ..., symboln] Identify oneor more global (external) symbols
.include []filename[] Include sourcestatements from another file
-
8/2/2019 Tms320c54 Assembly
26/31
Directives That Define SectionsThese directives associate portions of anassembly 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 containsinitialized data.
.sect defines initialized named sections andassociates subsequent code or data withthat section. A section defined with .sectcan contain executable code or data.
-
8/2/2019 Tms320c54 Assembly
27/31
.text identifies portions of code in the .text
section.The .text section usually contains
executable code.
.usect reserves space in an uninitializednamed section.
The .usect directive is similar to the .bss
directive, but it allows to reserve spaceseparately from the .bsssection.
-
8/2/2019 Tms320c54 Assembly
28/31
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
-
8/2/2019 Tms320c54 Assembly
29/31
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
-
8/2/2019 Tms320c54 Assembly
30/31
30 **************************************************31 * Resume assembling into the .text section *32 **************************************************33 000004 .text34 000004 0005 .word 5, 6000005 000635 000000 usym .usect xy, 20 ; Reserve space in xy
36 000006 0007 .word 7, 8 ; Still in .text000007 0008
-
8/2/2019 Tms320c54 Assembly
31/31
.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 thenthe assembler resumes assembling code or datainto the current section.
top related