dsPIC30F Language Tools Quick Reference Card
™
ASM30
MPLAB® ASM30 Assembler Assembler Command Line Options pic30-as [options|sourcefiles]...
Listing Output Option
Description The -a option supports the following suboptions: Omit false conditionals Omit debugging directives Include high-level source Include assembly Include macro expansions Omit forms processing Include symbols Include section information
-a[sub-option][=file] c d h l m n s i
Informational Output Option
Description Warnings treated as errors Suppress warnings Warnings issued (default) No signed overflow warnings Show help Show target-specific help Show statistics after assembly Show version number Maximum message output
--fatal-warnings --no-warn --warn -J --help --target-help --statistics --version --verbose
Output File Creation Option
Description Set name of output to objfile Set output file type. Coff is default. Substitute short branches where possible Don’t substitute short branches (default) Generate object file even after errors Write dependency information to file
-o objfile -omf={coff|elf} --relax --no-relax -Z -MD file
Other Options Option
Description
--defsym sym=value -I dir -p=proc
Define sym with value Add dir to .include directories Set target processor to proc
Special Operators Operator tblpage(name) tbloffset(name) psvpage(name) psvoffset(name) paddr(label) handle(label) .sizeof.(name) .startof.(name)
Description Get page for table read/write operations Get pointer for table read/write operations Get page for PSV data window operations Get pointer for PSV data window operations Get 24-bit address of label in program memory Get 16-bit reference to label in program memory Get size of section name in address units Get starting address of section name
ASM30
ASM30 Reserved Symbol Names Note: Reserved symbol names can be upper or lower case W0 W8 WREG LT LTU
W1 W9 A GT GTU
W2 W10 B LE LEU
W3 W11 OV NOV OA
W4 W12 C NC OB
W5 W13 Z NZ SA
W6 W14 N NN SB
W7 W15 GE GEU
Assembler Directives Sections Directive
Description
.section name [,type] [,attr1,attr2,...,attrn]
.text .bss .data
Set section name with type and attr type: attr: code address(a) data near bss xmemory persist ymemory psv reverse(n) eedata align(n) .section .text,code .section .bss,bss .section .data,data
Constant Initialization Directive .ascii .asciz .byte .pbyte .word .pword .long .float .double
Description String with no trailing zero byte String with trailing zero byte 8-bit value 8-bit value including upper byte of program memory 16-bit value 24-bit value including upper byte of program memory 32-bit value 32-bit single precision floating point 64-bit double precision floating point
Symbols Directive .bss sym, len .comm sym, len .extern sym .global sym .weak sym .equ sym, expr .equiv sym, expr
Description Reserve len bytes for uninitialized symbols Declare common Defined as global in another module Symbol available in other modules Mark symbol as weak Set value of sym to expr Like .equ, but issues error if sym already defined
ASM30
ASM30 Section Location Directive
Description
.align algn[,byte[,max-skip]] .palign algn[,byte[,max-skip]] .fill repeat[,size[,byte]] .pfill repeat[,size[,byte]] .org new-lc[,byte] .porg new-lc[,byte] .skip size[,byte] .space size[,byte] .pskip size[,byte] .pspace size[,byte]
Pad to algn boundary Pad to algn boundary in program memory specifying upper byte Fill repeat bytes Fill repeat bytes in program memory, specifying upper byte Set location counter Set location counter in code section specifying upper byte Fill bytes Fill bytes in program memory specifying upper byte
Conditional Directive .if expr .ifdef sym .ifndef sym .else .endif .err msg
Description Start of conditional Conditional if sym defined Conditional if sym not defined Alternative to conditional End of conditional Print message
MPLAB LINK30 Object Linker pic30-ld [options] file...
Command Line Options Option
Description
-l libname Search for library libname -M Print map file on standard output -r Generate relocatable output -S Strip debug symbols -T file Read linker script -u sym Start with undefined reference to sym -v Print version information -( -llib1 ... -llibn -) Resolve circular references in libraries --no-check-sections Do not check section addresses overlap --cref Output cross reference table --defsym sym=expr Define symbol --heap size Set heap to size bytes --help Print list of command line options -Map file Write a map file --no-data-init Don’t create initialized data template --no-handles Don’t create handle jump table --no-pack-data Use only lower 16-bits for data storage -omf={coff|elf} Set output file type. Coff is default. --report-mem Write memory report to standard output --stack size Set minimum stack to size bytes (default=16) --warn-once Warn only once per undefined symbol --warn-section-align Warn if alignment changes start of section
LINK30
Utilities
Object File Utilities Executables Name pic30-ar pic30-bin2hex pic30-nm pic30-objdump pic30-ranlib pic30-strings pic30-strip pic30-lm
Description Manage libraries Convert executable to Intel HEX file List symbols from an object file Display information about object files Generate library index Print character sequences from file Discard all symbols from an object or archive file License manager
pic30-objdump Utility pic30-objdump [ -options ] file
Options Option -a -d -D -z -f -g -h -j name -l -S -M symbolic -omf={coff|elf} -r -s -t -x --start-address=adr --stop-address=adr -V -H
Description Display archive header information Disassemble sections that contain instructions Disassemble all sections Disassemble blocks, even if zeroes Display summary information from headers Display debugging information Display summary information from section headers Display information only for section name Label display with file names and line numbers Display source intermixed with disassembly Perfom symbolic disassembly Set output file type. Coff is default. Print relocation entries of file Display full contents of section(s) Print symbol table entries of file Display all available header information same as: -a -f -h -r -t Start displaying data at adr for -d, -r, -s Stop displaying data at adr for -d, -r, -s Print the version number Print summary of options
MPLAB LIB30 Archiver/Librarian pic30-ar option [mods [relpos] [count]] archive [member...]
Options Option d p r t x
Description Delete modules from the archive Print specified members of archive Insert the files member... into archive (with replacement) Display a table listing the contents of archive or files in member Extract members from archive
Utilities
Utilities Modifiers Modifier a b c i o P S U v V
Description Add new files after existing member of archive Add new files before existing member of archive Create the archive Insert new files before existing member of archive Preserve original dates of members when extracting Use full path Do not generate archive symbol table Insert only those newer than existing Verbose version Show version number
MPLAB SIM30 Simulator sim30
[command-file-name]
Commands Command LP LF DM DF DA DB DW DC DP DH DS AF MS MC FS FC BS BC RP RC VO VF IO IF PS LD LC LS Q S E H HE HW
filename [adr] filename [adr] [start] [end] [start] [end]
freq start end/val[val] start [end] start end/val [val] start [end] adr1 ...[adrN] adr1 ...[adrN]
value devicename filename filename
Description Load Program memory Load File registers Display program Memory Display File registers Display Accumulators Display Breakpoints Display W registers Display pC disassembled Display Profile Display Help on all Display Status register fields Alter clock Frequency Program Memory Set Program Memory Clear File register Set File register Clear Breakpoint Set Breakpoint Clear Reset Processor Reset Clock Verbose On Verbose ofF Turn simulated I/o file On Turn simulated I/o file ofF PC Set Load Device Load COFF or ELF file Load SCL file Quit Step Execute Halt Halt on Error Halt on Warning
SIM30
C30
MPLAB C30 Compiler pic30-gcc [options] files
Integer Data Types Type
Bits
Min
char, signed char
8
-128
127
unsigned char
8
0
255
short, signed short
16
-32768
32767
unsigned short
16
0
65535
int, signed int
16
-32768
32767
unsigned int
16
0
65535
long, signed long
32
-231
231 - 1
unsigned long
32
0
232 - 1
63
Max
long long, signed long long
64
-2
263 - 1
unsigned long long
64
0
264 - 1
IEEE Floating Point Data Types Bits
E min
E max
N min
N max (approx)
float
32
-126
127
2-126
2128
double*
32
-126
127
2-126
2128
long double
64
-1022
1023
2-1022
21024
Type
* double is equivalent to long double if -fno-short-double is used.
Attributes of Variables Option
Description
section (name)
near far space(xmemory) space(ymemory) space(auto_psv) space(psv) space(eedata) address(addr) reverse(n) persistent unordered
Specify that variable is located in section name. Example: int x __attribute__ ((section("foo")))=0; Variable is allocated in first 8 KB of data memory Variable can be located anywhere in data memory Variable placed in X memory Variable placed in Y memory Variable placed in compiler managed PSV memory Variable placed in PSV memory Variable placed in EEDATA memory Specify absolute address for variable Align end on n- aligned boundary uninitialized variable not zeroed at startup allocate space on best-fit
Attributes of Functions Option noreturn weak near far shadow interrupt address(addr)
Description Indicate the function cannot return Declaration emitted as weak symbol rather than global Function within 32K range Function anywhere in memory Use shadow registers rather than stack for saving registers W0-W3 Specify function is an interrupt handler Specify absolute address for function
C30
C30 General Options Option
Description Stop after assembly Stop after preprocessing stage Place output in file Stop after compilation Print commands executed during compilation Description of the command line options Define symbol name Undefine symbol name Pass options to linker
-c -E -o file -S -v --help -D name[=value] -U name -Wl,option1,...,optionN
Memory Model Command Line Options Option
Memory Definition
-msmall-data -msmall-scalar -mlarge-data -msmall-code -mlarge-code -mconst-in-data -mconst-in-code
Put all data in first 8 KB of data memory (default) Put all scalars in first 8 KB of data memory (default) Greater than 8 KB of data memory Up to 32 Kwords of program memory (default) Greater than 32 Kwords of program memory Local constants in data memory Local constants in program memory (PSV) (default)
Options for Debugging Option
Description
-g Produce debugging information -omf={coff|elf} Set output file type. Coff is default. -save-temps Do not delete intermediate files
Options for Controlling Optimization NOTE: Enabling optimizations may affect debugging
Option -O0 -O1 -O2 -O3 -Os -mpa
Description Do not optimize (default) Minimal optimization Optimize to balance size and speed Optimize for speed Optimize for size Enable procedural abstraction optimization
Built-In Functions Function int __builtin_divsd(const long num, const int den); unsigned __builtin_divud(const unsigned long num, const unsigned den); long __builtin_mulss(const int p0, const int p1); long __builtin_mulsu(const int p0, const unsigned p1); long __builtin_mulus(const unsigned p0, const int p1); unsigned long __builtin_muluu(const unsigned p0, const unsigned p1); unsigned __builtin_tblpage(const void *p); unsigned __builtin_tbloffset(const void *p); unsigned __builtin_psvpage(const void *p); unsigned __builtin_psvoffset(const void *p);
C30
dsPIC30F Program Memory Map RESET Instruction
User Memory Space
Reserved Oscillator Fail Trap Vector Address Error Trap Vector Stack Error Trap Vector Math Error Trap Vector Reserved Reserved Reserved Interrupt 0 Vector Interrupt 1 Vector
Interrupt 52 Vector Interrupt 53 Vector Alternate Vector Table
000002 000004
000014
00007E 000080 0000FE 000100
User Flash Program Memory 017FFE 018000 Reserved (Read 0’s) 7FEFFE 7FF000 Data Flash 7FFFFE 800000 Reserved
Configuration Memory Space
Unit ID
8005BE 8005C0 8005FE 800600
Reserved
Configuration Registers
F7FFFE F80000 F8000E F80010
Reserved
Device ID
dsPIC30F
FEFFFE FF0000 FFFFFE
dsPIC30F
dsPIC30F Architecture Indirect Mode Syntax Function
Syntax
No Modification Pre-Increment Pre-Decrement Post-Increment Post-Decrement Register Offset
[Wn] [++Wn] [--Wn] [Wn++] [Wn--] [Wn+Wb]
Byte Inst EA = [Wn] EA = [Wn += 1] EA = [Wn -= 1] EA = [Wn] += 1 EA = [Wn] -= 1 EA = [Wn + Wb]
Word Inst EA = [Wn] EA = [Wn += 2] EA = [Wn -= 2] EA = [Wn] += 2 EA = [Wn] -= 2 EA = [Wn + Wb]
DSP MAC Indirect Addressing Modes Addressing Mode No Modification Post-Inc by 2 Post-Inc by 4 Post-Inc by 6 Post-Dec by 2 Post-Dec by 4 Post-Dec by 6 Register Offset
X Memory
Y Memory
EA = [Wx] EA = [Wx]+= 2 EA = [Wx]+= 4 EA = [Wx]+= 6 EA = [Wx]-= 2 EA = [Wx]-= 4 EA = [Wx]-= 6 EA = [W9 + W12]
EA = [Wy] EA = [Wy]+= 2 EA = [Wy]+= 4 EA = [Wy]+= 6 EA = [Wy]-= 2 EA = [Wy]-= 4 EA = [Wy]-= 6 EA = [W11 + W12]
Registers Register ACCA, ACCB CORCON DCOUNT DOEND DOSTART PC PSVPAG RCOUNT SPLIM SR TBLPAG W0 through W15 WREG
Description 40-bit DSP Accumulators CPU Core Configuration register DO Loop Count register DO Loop End Address register DO Loop Start Address register Program Counter Program Space Visibility Page Address register Repeat Loop Count register Stack Pointer Limit value register ALU and DSP engine Status register Table Memory Page Address register Working register array Synonym for W0
Symbols Used in Instruction Set Tables Symbol f Wb Wd Wm,Wn Wn Wnd Wns Ws Wx Wxd Wy Wyd
Description File Register Address Base Working Register Destination Working Register (direct and indirect) Working Register Pair (dividend, divisor) Both Source and Destination Working Register (direct) Destination Working Register (direct) Source Working Register (direct) Source Working Register (direct and indirect) Source Addressing Mode and Working Register for X Data Destination Working Register for X Data Source Addressing Mode and Working Register for Y Data Destination Working Register for Y Data
dsPIC30F
dsPIC30F Instruction Set Asm ADD
ADDC
AND
ASR
BCLR BRA
BSET BSW.C BSW.Z BTG BTSC BTSS BTST BTST.C
Operand f{,WREG} #lit10,Wn Wb,#lit5,Wd Wb,Ws,Wd Acc Ws,#Slit4,Acc f{,WREG} #lit10,Wn Wb,#lit5,Wd Wb,Ws,Wd f{,WREG} #lit10,Wn Wb,#lit5,Wd Wb,Ws,Wd f{,WREG} Ws,Wd Wb,#lit4,Wnd Wb,Wns,Wnd f,#bit4 Ws,#bit4 Expr Wn C,Expr GE,Expr GEU,Expr GT,Expr GTU,Expr LE,Expr LEU,Expr LT,Expr LTU,Expr N,Expr NC,Expr NN,Expr NOV,Expr NZ,Expr OA,Expr OB,Expr OV,Expr SA,Expr SB,Expr Z,Expr f,#bit4 Ws,#bit4 Ws,Wb Ws,Wb f,#bit4 Ws,#bit4 f,#bit4 Ws,#bit4 f,#bit4 Ws,#bit4 f,#bit4 Ws,#bit4 Ws,Wb
Description Destination = f + WREG Wn = lit10 + Wn Wd = Wb + lit5 Wd = Wb + Ws Add Accumulators Add signed lit4 to Accumulator Dest = f + WREG + (C) Wn = lit10 + Wn + (C) Wd = Wb + lit5 + (C) Wd = Wb + Ws +(C) Destination = f .AND. WREG Wn = lit10 .AND. Wn Wd = Wb .AND. lit5 Wd = Wb .AND. Ws Dest = arith right shift f Wd = arith right shift Ws Wnd = arith right shift Wb by lit4 Wnd = arith right shift Wb by Wns Bit clear f Bit clear Ws Branch always Computed branch Branch if carry Branch if >= 1 Branch if unsigned >=1 Branch if > 1 Branch if unsigned > 1 Branch if