13.07.2015 Views

DSP56xxx C Cross-Compiler User's Guide - Tasking

DSP56xxx C Cross-Compiler User's Guide - Tasking

DSP56xxx C Cross-Compiler User's Guide - Tasking

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MA039–002–00–00Doc. ver.: 1.24<strong>DSP56xxx</strong> v3.6C CROSS–COMPILERUSER’S GUIDE


TABLE OFCONTENTS


IVTable of Contents


Table of ContentsV • • • • • • • •


VITable of Contents


Table of ContentsVII • • • • • • • •


VIIITable of Contents


Table of ContentsIX • • • • • • • •


XTable of Contents


Table of ContentsXI • • • • • • • •


XIITable of Contents


Manual Purpose and StructureXIII • • • • • • • •


XIVManual Purpose and Structure Describes the interoperability between the TASKING and Motorola tool sets.It describes how to create a Motorola CLAS COFF object file and how tolink CLAS/COFF object files and libraries.


Manual Purpose and StructureXV• • • • • • • • • • • • • • • • • • • • •


XVIManual Purpose and Structurescreen fontcommand [option]... filename


Manual Purpose and StructureXVII• • • • • • • •


XVIIIManual Purpose and Structure


SOFTWAREINSTALLATION


1–2Chapter 1


Software Installation 1–3 d:\setup c:\c56c:\c56\bin• • • • • • • •


1–4Chapter 1\c563Project | Directories...Executable Files Pathautoexec.batset C563INC=c:\c563\include My ComputerProperties Environment VariableC563INC Valuec:\c563\include SetOK My ComputerProperties


Software Installation 1–5 Advanced Environment Variables System variablesNew Variable nameC563INC Variable valuec:\c563\include OKSWproduct–version–RPMrelease.i386.rpmswproduct_version–release_i386.debSWproduct–version.tar.gz.rpm.deb.tar.gz /cdrom• • • • • • • •


1–6Chapter 1 cd /cdrom rpm –U SW*.rpm/usr/local––/optrpm –U ––prefix /opt SW*.rpm––.tar.gz /cdrom cd /cdrom dpkg –i sw*.deb/usr/local


Software Installation 1–7 /cdrom cd /cdrom .tar.gz/usr/localtar xzf SWproduct–version.tar.gz –C /usr/local.tar.gz• • • • • • • •


1–8Chapter 1 /usr/local /cdrom cd /cdrom sh install/usr/local*** WARNING ***SWxxxxxx xxxx.xxxx already installed.Do you want to REINSTALL? [y,n]=> Installation stopped on user request


Software Installation 1–9Installation of SWxxxxxx xxxx.xxxx completed.c563c56 • • • • • • • •


1–10Chapter 1


Software Installation 1–11 license.datc:\flexlmc:\flexlm• • • • • • • •


1–12Chapter 1flexlm<strong>Tasking</strong>license.datbin


Software Installation 1–13license.datc:\flexlm/usr/local/flexlm/licenseslicense.datflexlmc:\flexlm\license.dat/usr/local/flexlm/licenses/license.datbinlmrereadStart | Programs | TASKING FLEXlm | FLEXlm ToolsRereadOK• • • • • • • •


1–14Chapter 1 Start | Programs | TASKINGFLEXlm | FLEXlm License Manager ControlStart OK /usr/local/flexlmcd /usr/local/flexlm bin/lmgrd –2 –p –c licenses/license.dat >>& \/var/tmp/license.log &


Software Installation 1–15bin/lmgrd –2 –p –c licenses/license.dat >> \/var/tmp/license.log 2>&1 & Start | Programs | TASKINGFLEXlm | FLEXlm License Manager SetupStart Server at Power–Up OKYes• /etc/rc.local/usr/local/flexlmFLEXLMDIR/bin/lmgrd –2 –p –c FLEXLMDIR/licenses/license.dat >> \/var/tmp/license.log 2>&1 &• • • • • • • •


1–16Chapter 1 /etc/init.drc.lmgrd/usr/local/flexlm#!/bin/shFLEXLMDIR/bin/lmgrd –2 –p –c FLEXLMDIR/licenses/license.dat >> \/var/tmp/license.log 2>&1 & chmod u+x rc.lmgrd /etc/rc3.d/etc/rc?.dln /etc/init.d/rc.lmgrd /etc/rc3.d/Snumrc.lmgrdln /etc/init.d/rc.lmgrd /etc/rc?.d/Knumrc.lmgrdc:\flexlm\license.dat/usr/local/flexlm/licenses/license.datautoexec.batControl Panel –> System| Environmentset LM_LICENSE_FILE=c:\flexlm\license.dat;c:\license.txt


Software Installation 1–17setenv LM_LICENSE_FILE/usr/local/flexlm/licenses/license.dat:/myprod/license.txtsetenv LM_LICENSE_FILE 7594@elliotPlatform Tool to retrieve hostid Example hostidSunOS/Solaris hostid 170a3472Windows tkhostid(or use lmhostid)0800200055327• • • • • • • •


1–18Chapter 1PlatformSunOS/SolarisWindows 95/98Windows NTMethodhostnameGo to the Control Panel, open ”Network”, click on”Identification”. Look for ”Computer name”.Go to the Control Panel, open ”Network”. In the”Identification” tab look for ”Computer Name”.


OVERVIEW


2–2Chapter 2


Overview 2–3 • • • • • • • •


2–4Chapter 2.cc.cxx.cpp.c.asm.src.obj.a.out.dsc


Overview 2–5• • • • • • • •


2–6Chapter 2#pragma optimize1+ (x–3)x + (1–3)


Overview 2–7forwhile• • • • • • • •


2–8Chapter 2


Overview 2–9• • • • • • • •


2–10Chapter 2


Overview 2–11_fract fir_filter(_fract data[], _fract _Y coef[]){long _fract result; int i;}result = 0.0;for ( i = 0; i < 100; i++ ){result += data[i] * (long _fract) coef[i];}return _round(result);result = 0.0;tmp1 = data;tmp2 = coef;for ( i = 0; i < 100; i++ ){result += *tmp1++ * *tmp2++;}iclr a ; Clear result 1,1do #100,L5 ; Hardware do loop 2,5move x:(r0)+,x0 ; Get an element of ’data’ 1,1*move y:(r4)+,y0 ; Get an element of ’coef’ 1,1*mac x0,y0,a ; Multiply and accumulate 1,1*L5: void x0, y0, r0, r4 ; End of loop, indicate registers; unused after looprnd a ; Round result 1,1rts ; Return it 1,3• • • • • • • •


2–12Chapter 2X0Y0clr a ; Clear result 1,1move x:(r0)+,x0 ; Get first element of ’data’ 1,1move y:(r4)+,y0 ; Get first element of ’coef’ 1,1do #100,L5 ; Hardware do loop 2,5mac x0,y0,a ; Multiply and accumulate 1,1*move x:(r0)+,x0 ; Get next element of ’data’ 1,1*move y:(r4)+,y0 ; Get next element of ’coef’ 1,1*L5: void x0, y0, r0, r4 ; End of loop, indicate registers; unused after looprnd a ; Round result 1,1rts ; Return it 1,3clr a x:(r0)+,x0 y:(r4)+,y0 ; Clear result, 1,1; prime loopdo #100,L5 ; Hardware do loop 2,5mac x0,y0,a x:(r0)+,x0 y:(r4)+,y0 ; Multiply and 1,1*; accumulate, and get; next elements of ’data’L5: ; and ‘coef’rnd a ; Round result 1,1rts ; Return it 1,3#pragma optimize#pragma optimize R /* turn DO to REP optim off */for( ... )/* some loop */#pragma optimize r /* turn DO to REP optim on */


Overview 2–13• • • c563 –L4 example.cexample.cfor( ... ) /* depth 1 –> no hardware DO loop */{for( ... ) /* depth 2 –> hardware DO loop */{ /* stack level 2 */for( ... ) /* depth 3 –> hardware DO loop */{ /* stack level 4 */...}}}• • • • • • • •


2–14Chapter 2 struct {} a;a.b = 1;unsigned int b :1;..bset #0,x:Fa..Fa _near


Overview 2–15• .c.srcstdout• .obj• .out.lnl• .abs.map.abs• • • • • • • •


2–16Chapter 2C++ source file.ccC++ compilercp563.icC source file.cC preprocessor&C compilerc563controlprogramcc563library maintainerar563relocatable objectlibrary .alocator descriptionfile .dscassembly file.srcassembleras563relocatable objectmodule .objincrementallinker lk563linker object file.outlocatorlc563CLAS assembly file.asmlist file.lstobject readerpr563CLAS object file.clnlinker map file.lnllocator map file.mapIntel Hexobject file.hexMotorola S–recordobject file.sreIEEE–695 absoluteobject file.absHigh level languagedebugger<strong>Cross</strong>View xfw56xCLAS absoluteobject file (no debug info).cld<strong>DSP56xxx</strong>ExecutionEnvironment


Overview 2–17C++ source file.ccC++ compilercp563.icC source file.cC preprocessor&C compilerc563assembly file.srcassembleras563Motorolaassembly file.asmMotorolaassemblerasm56300CLAS object file.clnMotorolalinkerdsplnkCLAS absoluteobject file (with debug info).cldads56300ExecutionEnvironment• • • • • • • •


2–18Chapter 2.a.obj.out.dsc


Overview 2–19EnvironmentVariableAS56INCAS563INCC56INCC563INCC56LIBC563LIBCC56BINCC563BINCC56OPTCC563OPTLM_LICENSE_FILEDescriptionSpecifies an alternative path for include files for theassembler as56.Specifies an alternative path for include files for theassembler as563.Specifies an alternative path for #include files for theC compiler c56.Specifies an alternative path for #include files for theC compiler c563.Specifies a path to search for library files used bythe linker lk56.Specifies a path to search for library files used bythe linker lk563.When this variable is set, the control program, cc56,prepends the directory specified by this variable tothe names of the tools invoked.When this variable is set, the control program,cc563, prepends the directory specified by thisvariable to the names of the tools invoked.Specifies extra options and/or arguments to eachinvocation of cc56. The control program processesthe arguments from this variable before thecommand line arguments.Specifies extra options and/or arguments to eachinvocation of cc563. The control program processesthe arguments from this variable before thecommand line arguments.Identifies the location of the license data file. Onlyneeded for hosts that need the FLEXlm licensemanager.• • • • • • • •


2–20Chapter 2EnvironmentVariablePATHTMPDIRDescriptionSpecifies the search path for your executables.Specifies an alternative directory where programscan create temporary files. Used by c56, c563,cc56, cc563, as56, as563, lk56, lk563, lc56, lc563,ar56, ar563.


Overview 2–21cexamplescalccexamples• • • • • • • •


2–22Chapter 2Compile Build Rebuild Debug On–line ManualsProject WindowContains severaltabs for viewinginformation aboutprojects and otherfiles.Document WindowsUsed to view and edit files.Output WindowContains several tabs to displayand manipulate results of EDEoperations. For example, to viewthe results of builds or compiles. ProjectSelect Toolchain...Select Toolchain


Overview 2–23 ToolchainsOKBrowse...Scan Disk...Browse...Scan Disk... ProjectSet Current –> calccalc.pjtcexamplescalc.pjtc:\c563\examples\cc56calc.cmakefile ProjectLoad Files...Choose Project Files to Edit• • • • • • • •


2–24Chapter 2 OK ProjectDirectories...Directories


Overview 2–25 OK ProjectProject Options... CPU Selection CPU family/typeOK BuildOptions...Build Options• • • • • • • •


2–26Chapter 2 OK BuildScan All Dependencies Execute ’Make’ commandOutputBuildTASKING program builder vx.yrz Build nnn SN 00000000Compiling ”calc.c”Assembling ”calc.src”Linking to ”calc.out”Creating IEEE–695 absolute file ”calc.abs”


Overview 2–27 Debug application FileLoad Symbolic Debug Info...Load Symbolic Debug Info Load ViewSource | Source lines RunReset Target System RunAnimate• • • • • • • •


2–28Chapter 2calc.abs FileNew Project Space...Create a New Project Space OKProject Properties Add new project to project spaceAdd New Project to Project Space OKProject Properties OK• Add new fileto projectProject PropertiesOK• Scan existing files into projectProjectPropertiesPatternOK


Overview 2–29• Add existing files to projectProjectPropertiesOpen ProjectLoad Files...calc.c cexamples cc563 –g –M calc.c –o calc.abs• • • • • • • •


2–30Chapter 2calc.objcalc.mapcalc.abscalc.abscc563 –g –M calc.c –o calc.abs –v0+ c563 –o /tmp/cc7208b.src –g –M24x calc.c+ as563 –o calc.obj –gs –M24x /tmp/cc7208b.src+ lk563 –o/tmp/cc7208c.out –ddef_targ.dsc –uR_def_targ calc.obj–lc24 –lfp24 –lrt24+ lc563 –ocalc.abs –ddef_targ.dsc –f1 –M /tmp/cc7208c.outcc563 –g –M calc.c –o calc.abs –v0 –tmp+ c563 –o calc.src –g –M24x calc.c+ as563 –o calc.obj –gs –M24x calc.src+ lk563 –ocalc.out –ddef_targ.dsc –uR_def_targ calc.obj–lc24 –lfp24 –lrt24+ lc563 –ocalc.abs –ddef_targ.dsc –f1 –M calc.out


Overview 2–31examplesmakefilereadme.txtcalc cexamplescalc mk563makefilemk563 –n –aTASKING DSP563xx/6xx program builder vx.yrz Build nnnCopyright 1996–year Altium BV Serial# 00000000cc563 –g calc.c –o calc.abscc563 –cs –gn –s intrnsic.ccc563 –cs –gn –s intrpt.c• • • • • • • •


2–32Chapter 2mk563 clean


LANGUAGEIMPLEMENTATION


3–2Chapter 3


Language Implementation 3–3_fractlong _fract_complex_X_Y_L_P_near_internal_external_near_internal_external_reentrant_fast_interrupt_long_interrupt• • • • • • • •


3–4Chapter 3_inline_compatible_callee_save_circ_bank()


Language Implementation 3–5StorageSpecifier_X_Y_L_P_near_internal_externalDescriptionX memory specifier (default)Y memory specifierL memory specifierprogram memorylowest 64 addresses of data memory.For functions: short addressable memoryinternal memoryexternal memory• • • • • • • •


3–6Chapter 3int _X Var_in_X; /* allocate integer variablein X memory */int _near _X Var_in_low_X; /* fast accessible integerin low 64 addressesof X memory */int _X * _Y Ptr_in_Y_to_X; /* allocatepointer in Y memory,used to point to integersin X */char _P string[] = ”<strong>DSP56xxx</strong>”; /* string in program memory*/long _L Long_in_L; /* allocate long variable inL memory */_internal int _X Intern_in_X; /* allocate integer variablein internal X memory */_near_Lunsigned longsigned longfloatlong_fract_L_L_internal_external_internal_external_external_external_internal


Language Implementation 3–7_near,_internal_external_atint _X myvar _at(0x100);int _X *p;int _Y *g;g = p;// pointer to int in X memory// pointer to int in Y memory// the compiler issues a warningextern int _X foo; //extern int in X memoryint _Y foo;//int in Y memoryint _Y example; /* define an int in Y memory */example = 2; /* assign example */move #2,X0move X0,Y:example• • • • • • • •


3–8Chapter 3_near_internal_near_internal


Language Implementation 3–9 move #offset,n7NOPmove x:(r7+n7),a• • • • • • • •


3–10Chapter 3move x:Fvar,amainababvoid a( int x ){printf( ”a has %d\n”, x );}void b( int x ){printf( ”b has %d\n”, x );}void main(void){a( 1 ); //call function a()b( 2 ); //a() and b() are not//simultaneously active}


Language Implementation 3–11 _reentrant • • • • • • • •


3–12Chapter 3int _reentrantmultiply( int first, int second ){return( first * second );}_reentrant _reentrant


Language Implementation 3–13 c56.h #if _MODEL == ’s’ /* static model */...#endif• • • • • • • •


3–14Chapter 3_at()_external unsigned char Display _at( 0x2000 );DisplayDisplay• • • • • • •


Language Implementation 3–15doublelong double_fractlong _fractenum_complexDSP563xx/6xx 16–bit DSP563xx 24–bit DSP563xx 16/24–bitData TypeSize(bit)RangeSize(bit)RangeSize(bit)Rangesigned char 8 –128 to +127 8 –128 to +127 8 –128 to +127unsigned char 8 0 to 255U 8 0 to 255U 8 0 to 255Usigned short 16 –32768 to +32767 16 –32768 to +32767 16 –32768 to +32767unsigned short 16 0 to 65535U 16 0 to 65535U 16 0 to 65535Usigned int 16 –32768 to +32767 24 –8388608 to +8388607 16 –32768 to +32767unsigned int 16 0 to 65535U 24 0 to 16777215U 16 0 to 65535Usigned long 32 –2147483648 to+214748364748 –140737488355328 to+14073748835532732 –2147483648 to+2147483647unsigned long 32 0 to 4294967295UL 48 0 to 281474976710655 32 0 to 4294967295UL_fract 16 [–1, 1] 24 [–1, 1] 16 [–1, 1]long _fract 32 [–1, 1] 48 [–1, 1] 32 [–1, 1]pointer 16 0 to 65535U 24 0 to 16777215U 24 0 to 16777215U_circ pointer 16+16 0 to 65535U 24+24 0 to 16777215U 24+24 0 to 16777215Ufloat/double 16+8 +/– 1.1750E–38+/– 3.4028E+3824+8 +/– 1.1754940E–38+/– 3.4028235E+3816+8 +/– 1.1750E–38+/– 3.4028E+38enum 16 –32768 to +32767 24 –8388608 to +8388607 16 –32768 to +32767_complex 2*16 [–1, 1] for both fields 2*24 [–1, 1] for both fields 2*16 [–1, 1] for both fields• • • • • • • •


3–16Chapter 3DSP5600xData Type Size Range(bit)signed char 8 –128 to +127unsigned char 8 0 to 255Usigned short 16 –32768 to +32767unsigned short 16 0 to 65535Usigned int 24 –8388608 to +8388607unsigned int 24 0 to 16777215Usigned long 48 –140737488355328 to+140737488355327unsigned long 48 0 to 281474976710655_fract 24 [–1, 1]long _fract 48 [–1, 1]pointer 24 0 to 16777215U_circ pointer 0 to 16777215Ufloat/double 24+8 +/– 1.1754940E–38+/– 3.4028235E+38enum 24 –8388608 to +8388607_complex 2*24 [–1, 1] for both fieldscharshortintlongcharcharcharshortintDoublefloat


Language Implementation 3–17_fract/* constant with value 0.3333... */const _fract one_third = 1.0/3;–1,1]+1.0long_fractlong _fract Lfval;_round()• • • • • • • •


3–18Chapter 3_fract f;void main(){f


Language Implementation 3–19unsigned charchar c;unsigned char c;char c;signed char c;signed intsigned intunsigned int• • • • • • • •


3–20Chapter 3unsigned longunsignedlonglongunsigned intlongunsigned intunsigned intlongunsigned longlonglongunsigned intunsigned intintunsignedcharintstatic int h, i, j;static long k, l, m;/* In C the following rules apply:* int * int result: int* long * long result: long** and NOT int * int result: long*/void f(){h = i * j; /* int * int = int */k = l * m; /* long * long = long */}l = i * j;/* int * int = int,* afterwards promoted (sign* or zero extended) to long*/l = (long) i * j; /* long * long = long */l = (long)(i * j); /* int * int = int,* afterwards casted to long*/


Language Implementation 3–21typedef union /* PLL Control Register */{struct{unsigned MF : 12; /* 0: Multiplication Factor */unsigned DF : 4; /* 12: Division Factor */int XTLD : 1; /* 16: XTAL Disable */int PSTP : 1; /* 17: STOP processing State */int PEN : 1; /* 18: PLL Enable */unsigned COD : 2; /* 19: Clock Output Disable */int CSRC : 1; /* 21: Chip Clcok Source */int CKOS : 1; /* 22: CKOUT Clock Source */int rsvd : 1; /* 23: Reserved */} B;int I;} pctl_type;#define PCTL (*(pctl_type*) 0xFFFD) /* PLL Control Register */voidmain( void ){PCTL.B.PEN = 1;PCTL.I = 0x0010;}bset #18,x:


3–22Chapter 3


Language Implementation 3–23static• • • • • • • •


3–24Chapter 3registerregisterregister


Language Implementation 3–25constint i = 100; /* 1 word in P memory and1 word in X memory */_P int j = 3; /* 2 words in P memory */char *t = ”TEXT”; /* 6 words in P memory and6 words in X memory:1 word for p,5 words for ”TEXT” */_P char t[] = ”HELP”; /* 10 words in P memory */_X char c = ’a’; /* 1 word in P memory and1 word in X memory */const int k = 400; /* 1 word in X memory */volatilevolatileconst volatile _X int real_time_clock _at(0x1200);/* define a memory mapped real time clockregister;it is read–only (const);read operations must access the real memorylocation (volatile)*/• • • • • • • •


3–26Chapter 3constconst char romhelp[] = ”help”;/* allocation of 5 words in ROM only */char * const message[] = {”hello”,”alarm”,”exit”};”st ing”[2] = ’r’;


Language Implementation 3–27_P char *_X p; /* pointer residing in X,pointing to P */p_Xchar _P *_X p; /* pointer residing in X,pointing to ROM (P) */_X_X_L float–5 / +3–1.666–5 / +3 = –2, –5 % +3 = +1 ==> (–5 / +3) * +3 + (–5 % +3) = –5–5 / +3 = –1, –5 % +3 = –2 ==> (–5 / +3) * +3 + (–5 % +3) = –5• • • • • • • •


3–28Chapter 3


Language Implementation 3–29 _inline_inlinet.cint w,x,y,z;_inline intadd( int a, int b ){return( a + b );}voidmain( void ){w = add( 1, 2 );z = add( x, y );}asmendasm• • • • • • • •


3–30Chapter 3; t.c 12 w = add( 1, 2 );move #3,r5move r5,x:Fw; t.c 13 z = add( x, y );move x:Fy,y1move x:Fx,badd y1,bmove b1,x:Fz


Language Implementation 3–31 _asm() __asm( ) _asm()_asm(”ori #$03,MR”);// disable interrupts#pragma asmori #$03,MR#pragma endasm_asm()#define _disable_interrupts() _asm(”ori #$03,MR”)• • • • • • • •


3–32Chapter 3 __asm()__asm__asm__asm__asm [volatile] ( instruction_template[ : output_param_list[ : input_param_list[ : regsave]]] );


Language Implementation 3–33volatile__asmChar Type Operand RemarkA address register r0..r7 The compiler excludes theuser stack pointer andreserved address registersN offset register n0..n7 The compiler excludes theuser stack pointer offsetand reserved offsetregistersC address + r0/m0..r7/m7 For circular pointersmodulo registerD accumulator a, b The complete 56–bitaccumulator registersR input register x0, y0, x, y Selection depends onoperand sizer GP register a, b, x0, y0, x1, y1,r0..r7, n0..n7All general–purposeint–sized registers exceptuser stack pointer andoffsetS source register x0, x1, y0, y1, x, y Selection depends onoperand sizei immediate value #value• • • • • • • •


3–34Chapter 3CharTypeOperandRemarkm memory x:Fvar, x:(r7–i) Stack or memory operandnumber other operand same as number Used when in– and outputoperands must be thesameChar Constraint Operand Remarkj A, C n0..n7 Offset register matchingwith address register. Youmust save and restorethese registers.v A, C m0..m7 Modulo register matchingwith address register.e D a1, b1 High part of accumulator.h D a0, b0 Low part of accumulator.k D a2, b2 Extension word ofaccumulator.g R, S x1, x0, y1, y0 Other part of input registeri R, S x, y Long input registermatching with integer–sizedinput register.f m x:,y:,p:,l: Insert memory space forthe operand.p i $0000..$FFFF Force 16–bit sized constantq i $000000..$FFFFFF Force 24–bit sized constanta, a0, a1, a2, b, b0, b1, b2, x, x0, x1, y, y0, y1,r0..r7, n0..n7 (except user stack pointer r and nregister)


Language Implementation 3–35m0..m7__asm__asm__asm__asm__asm__asm__asm__asmmr__asm( ”andi #$FC,mr”);andi $FC,mr__asm( ”\nmylabel”);mylabel• • • • • • • •


3–36Chapter 3D%0int var1;void main(void){__asm( ”move #


Language Implementation 3–37int _Y array[100];void main(void){__asm( ”do #20,_copy \n”” move y:(%0)+,y0 \n”” move y0,y:(%1)+ \n””_copy:\n”: ”=A”, ”=A”: ”0”(&array[20]), ”1”(&array[40]) : ”y0” );}move #Farray+20,r0move #Farray+40,r1do #20,_copymove y:(r0)+,y0move y0,y:(r1)+_copy:• • • • • • • •


3–38Chapter 3#define BLOCKSIZE 10int _Y array[10][BLOCKSIZE];void main(void){__asm( ”do #%5,_copy \n”” move y:(%0)+,%2 \n”” move %2,y:(%1)+ \n”);}”_copy:\n”: ”=A”, ”=A”, ”=r”: ”0”(&array[2]), ”1”(&array[4]), ”i”(2*BLOCKSIZE)move #Farray+20,r0move #Farray+40,r1do #20,_copymove y:(r0)+,n6move n6,y:(r1)+_copy:


Language Implementation 3–39Avoid swap_halves(long li){__asm (”move %e0,%1 \n”” move %h0,%0 \n”” move %1,%h0 \n”: ”=D”(li), ”S” : ”0”(li) );return li;}Fswap_halves:move a1,x0move a0,amove x0,a0rtsvoid circ_get(int *p){int result;}__asm (”move #24–1,%v1 \n”” move x:(%1),%0 \n”” move #–1,%v1 \n”: ”=D”(result) : ”A”(p) );return result;• • • • • • • •


3–40Chapter 3Fcirc_get:move #24–1,m0move x:(r0),amove #–1,m0rts #pragma asmori #$03,MR#pragma endasm__asm()


Language Implementation 3–41 _asmfunc/* prototype of assembly function */extern _asmfunc intspecial_out( int port, long config, int value );void main( void ){long cfg;int y;...if( special_out( 1, cfg, y ) )function */{}}....../* call assembly_asmfunc• • • • • • • •


3–42Chapter 3 • • • • _nop()Function_abs()_asm()__asm()_cache_get_start()_cache_get_end()_cadd()_cdiv()_cmac()_cmul()_csub()_ext()DescriptionAbsolute value of int argumentGenerate inline assemblyGenerate inline assembly with parameter passingGet first address of cache regionGet last address of cache regioncomplex additioncomplex divisioncomplex multiply–accumulatecomplex multiplicationcomplex divisionExtend high order part of accumulator for (unsigned)chars and shorts


Language Implementation 3–43Function_fabs()_fract2int()_fsqrt()_int2fract()_labs()_lfabs()_lfract2long()_long2lfract()_memcpy()_memset()_nop()_pdiv()_pflush()_pflushun()_pfree()_plock()_punlock()_rol()_ror()_round()_sema_clr()_sema_set()_sema_tst()_stop()_strcmp()_strcpy()_strlen()_swi()DescriptionAbsolute value of _fract argumentConvert _fract to intGenerate a JSR to the run–time library function Rfsqrt()Convert int to _fractAbsolute value of long argumentAbsolute value of long _fract argumentConvert long _fract to longConvert long to long _fractCopy block of memory. Compact memcpy replacementFill block of memory. Compact memset replacementNOP instruction, not optimized awayCalculates a/b inline, when it is known that a and b areboth positiveFlush cacheFlush unlocked sectorsGlobal unlockLock 1 sector in cacheUnock 1 sector in cacheRotate leftRotate rightSpecifies rounding (fractional arithmetic operations)Clear semaphoreSet semaphoreTest semaphoreSTOP, stop mode saves power consumptionString compare. Compact strcmp replacementString copy. Compact strcpy replacementString length. Compact strlen replacementSWI (c56) or TRAP (c563), software interrupt• • • • • • • •


3–44Chapter 3Function_vsl()_wait()DescriptionViterbi shift left (c563 only)WAIT, wait mode saves power consumptionc56.hcint _abs( int operand );volatile int ia, ib;ia = _abs( ib );move x:ss_main+23,babs bmove b1,x:ss_main+24; ib; _abs(ib); iavoid _asm( const char * asm );


Language Implementation 3–45#define SAVEINTSTAT _asm( ”move SR,X:(r2)+” ); \_asm( ”ori #$03,MR” )SAVEINTSTAT;move SR,X:(r2)+ori #$03,MR__void __asm( const char * instruction_template[ : output_param_list[ : input_param_list[ : regsave ]]] );__int _P * _cache_get_start( void _cache_region (* fptr )() );• • • • • • • •


3–46Chapter 3int _P * _cache_get_end( void _cache_region (* fptr )() );_complex _cadd( _complex op1, _complex op2 );_complex ca, cb, cc;cc = _cadd( ca, cb );move x:Fca,bmove x:Fca+1,amove x:Fcb,x0move x:Fcb+1,x1add x0,badd x1,amove a,x:Fcc+1 ; ccmove b,x:Fcc ; cc


Language Implementation 3–47_complex _cdiv( _complex op1, _complex op2 );_complex ca, cb, cc;cc = _cdiv( ca, cb );move x:Fca,bmove x:Fca+1,amove x:Fcb,x0move x:Fcb+1,x1jsr F_cdiv ; _cdiv(ca, cb)move a,x:Fcc+1 ; ccmove b,x:Fcc ; cc_complex _cmac( _complex op1, _complex op2,_complex op3 );_complex ca, cb, cc, cd;cd = _cmac( ca, cb, cc );• • • • • • • •


3–48Chapter 3move x:Fca,bmove x:Fca+1,amove x:Fcb,x0move x:Fcb+1,x1move x:Fcc,y0move x:Fcc+1,y1mac x0,y0,bmacr –x1,y1,bmac x0,y1,amacr x1,y0,amove a,x:Fcc+1move b,x:Fcc; cc; cc_complex _cmul( _complex op1, _complex op2 );_complex ca, cb, cc;cc = _cmul( ca, cb );move x:Fca,x0move x:Fca+1,x1move x:Fcb,y0move x:Fcb+1,y1mpy x0,y0,bmacr –x1,y1,bmpy x0,y1,amacr x1,y0,amove a,x:Fcc+1move b,x:Fcc; cc; cc


Language Implementation 3–49_complex _csub( _complex op1, _complex op2 );_complex ca, cb, cc;cc = _csub( ca, cb );move x:Fca,bmove x:Fca+1,amove x:Fcb,x0move x:Fcb+1,x1sub x0,bsub x1,amove a,x:Fcc+1move b,x:Fcc; cc; ccunsigned long _ext( unsigned long operand );volatile unsigned long ula, ulb;ula = _ext( ulb );move x:ss_main+14,bmove x:ss_main+13,b0move #0,b2move b1,x:ss_main+16move b0,x:ss_main+15; ula; ula• • • • • • • •


3–50Chapter 3_fract _fabs( _fract operand );_fractvolatile _fract fa, fb;fb = _fabs( fa );move x:ss_main+11,babs bmove b,x:ss_main+12; fb; _fabs(fb); faint _fract2int( _fract operand );int i;_fract f = 0.5;i = _fract2int(f);move #


Language Implementation 3–51_fract _fsqrt( _fract operand );Rfsqrtvolatile _fract fa, fb;fa = _fsqrt( fb );move x:ss_main+11,bjsr Rfsqrtmove b,x:ss_main+12; fb; _fsqrt(fb); fa_fract _int2fract( int operand );int i = 0x400000;_fract f;f = _int2fract(i);move #


3–52Chapter 3long _labs( long operand );volatile long la, lb;la = _labs( lb );move x:ss_main+18,bmove x:ss_main+17,b0abs b; _labs(lb)move b1,x:ss_main+20 ; lamove b0,x:ss_main+19 ; lalong _fract _lfabs( long _fract operand );long _fractlong _fract lfa, lfb;lfb = _lfabs( lfa );move x:ss_main+8,bmove x:ss_main+7,b0abs b; _lfabs(lfb)move b,x:ss_main+10 ; lfamove b0,x:ss_main+9 ; lfa


Language Implementation 3–53long _lfract2long( _lfract operand );long l;long _fract lf = 0.5;l = _lfract2long(lf);move #


3–54Chapter 3void * _memcpy( void * dest, const void * src,unsigned int size );memcpyunsigned intsize_t_memcpymemcpy/* _memcpy for all memory spaces */_X int a[10];_Y int b[10];void main(void){_memset(a,1,sizeof(a));_memcpy(b,a,sizeof(a));}void * _memset( void * dest, int src,unsigned int size );memsetunsigned intsize_t_memsetmemset


Language Implementation 3–55/* _memset for all memory spaces */_X int a[10];_Y int b[10];_X void * const p = a+5;_Y void * const q = b+5;void main(void){ /* space derived from *//* –––––––––––––––––––––– */_memset(a,1,sizeof(a)); /* space ’a’ resides in */_memset(b,2,sizeof(b)); /* space ’b’ resides in */_memset(p,3,5); /* space ’p’ points to */_memset(q,4,5); /* space ’q’ points to */}void _nop( void );_nop();opt noopnopnopopt opnop_fract _pdiv( _fract op1, _fract op2 );• • • • • • • •


3–56Chapter 3volatile _fract fa, fb;fa = _pdiv( fa, fb );move x:ss_main+12,bmove x:ss_main+11,x0andi #$FE,ccrrep #24div x0,bmove b,x:ss_main+12; fa; fb; _pdiv(fa, fb); favoid _pflush( void );_pflush();pflushvoid _pflushun( void );_pflushun();pflushun


Language Implementation 3–57void _pfree( void );_pfree();pfreevoid _plock( int _P *addr );• • • • • • • •


3–58Chapter 3void foo( void ){void _cache_region creg(void);_plock( _cache_get_start( creg ) );/* loop fits in one sector */#pragma cache_align_now#pragma cache_region_start cregfor ( ... ){...}#pragma cache_region_end creg_punlock( _cache_get_start( creg ) )move #Fcreg,r6nopplock (r6)align cache...move #Fcreg,r6noppunlock (r6)void _punlock( int _P * addr );


Language Implementation 3–59unsigned int _rol( unsigned int operand,unsigned int count );volatile unsigned int uia, uib;/* rotate left, using int variable */uia = _rol( uia, uib );move x:ss_main+22,b ; uiamove x:ss_main+21,a ; uibtst a; uibjeq L3rep a1rol b; _rol(uia, uib)L3: move b1,x:ss_main+22 ; uiaunsigned int _ror( unsigned int operand,unsigned int count );volatile unsigned int uia, uib;/* rotate right, using constant */uia = _ror( uib, 2 )uia = _ror( uia, 3 );• • • • • • • •


3–60Chapter 3move x:ss_main+21,b ; uibror b ; _ror(uib, 2)ror bmove b1,x:ss_main+22 ; uiamove x:ss_main+22,b ; uiarep #3ror b ; _ror(uia, 3)move b1,x:ss_main+22 ; uia_fract _round( long _fract operand );volatile _fract fa, fb;volatile long _fract lfa, lfb;void main( void ){fa = _round(fa);fb = _round(lfa);lfb = _round(lfa);}move x:ss_main+12,brnd bmove b,x:ss_main+12;move x:ss_main+10,bmove x:ss_main+9,b0rnd bmove b,x:ss_main+11;move x:ss_main+10,bmove x:ss_main+9,b0rnd bmove b,x:ss_main+8; fa; _round(fa); fa; _round(lfa); fb; _round(lfa); lfb


Language Implementation 3–61int _sema_clr(volatile int *p, int bitnumber);volatile intpinttypedef volatile int semaphore_t;void f(void){static semaphore_t flag = 1;}while( !_sema_clr( &flag, 0 ) ); /* wait until we reset flag ourselves *//* code to handle device */_sema_set( &flag, 0 );/* free device for other processes */• • • • • • • •


3–62Chapter 3L3: dc $000001org p,”.ptext”:L4: bclr #0,x:L3 ; _sema_clrjcc L4bset #0,x:L3 ; _sema_setrtsint _sema_set(volatile int *p, int bitnumber);volatile intpinttypedef volatile int semaphore_t;void f(void){static semaphore_t flag = 0;}while( _sema_set( &flag, 0 ) ); /* wait until we set flag ourselves *//* code to handle device */_sema_clr( &flag, 0 );/* free device for other processes */L3: dc $000001org p,”.ptext”:L4: bset #0,x:L3 ; _sema_setjcs L4bclr #0,x:L3 ; _sema_clrrts


Language Implementation 3–63int _sema_tst(volatile int *p, int bitnumber);volatile intpinttypedef volatile int semaphore_t;semaphore_t dev_started; /* set by other routines */void f(void){while( ! _sema_tst( &dev_started, 15 ) ); /* wait until device is operational *//* code using device */}org p,”.ptext”:L3: btst #15,x:Fdev_started ; _sema_tstjcc L3rtsvoid _stop( void );_stop();stop• • • • • • • •


3–64Chapter 3int _strcmp( const char * op1, const char * op2 );strcmpchar * sa=”strna”;char * sb=”strnb”;main(){int result;result = _strcmp( sa, sb );}move x:Fsa,r6move x:Fsb,r5move x:(r5)+,y0L5: move x:(r6)+,asub y0,ajne L6add y0,a x:(r5)+,y0jne L5L6:char * _strcpy( char * op1, const char * op2 );strcpy


Language Implementation 3–65char * sa=”strna”;char * sb=”strnb”;main(){_strcpy( sa, sb );}move x:Fsa,r6move x:Fsb,r5L5: move x:(r5)+,atst a a,x:(r6)+jne L5unsigned int _strlen( const char * op1 );strlenunsigned intsize_t_strlenstrlenchar * sa=”strna”;main(){int length;length = _strlen( sa );}move x:Fsa,r5move x:(r5)+,blua (r5)+,n5L4: tst b x:(r5)+,bjne L4lua (r5)–n5,b• • • • • • • •


3–66Chapter 3void _swi( void );_swi();swivoid _vsl( long op1, int op2,long _L * op3 );long _L result;long input = 0x12345678;main(){_vsl(input, 0, &result);_vsl(input, 1, &result);}vsl b,#0,l:Fresultvsl b,#1,l:Fresult


Language Implementation 3–67void _wait( void );_wait();wait• • • • • • • •


3–68Chapter 3 _long_interrupt_fast_interruptvoid _long_interrupt( vector )l_isr(void){ ... }void _fast_interrupt( vector )f_isr( void ){ ... }• • _long_interrupt_fast_interrupt• • • •


Language Implementation 3–69#include int c;void_fast_interrupt( 17 )host_transmit(void){HTX = c;}org p,”.irq17”:$22+R_VBAVALUEirq17:Fhost_transmit:movep x:Fc,x:


3–70Chapter 3 _circint _circ Circ_Buf[5];int _circ *Ptr_to_Circ_Buf = Circ_Buf;Circ_BufPtr_to_circ_Bufwhile( *Ptr_to_Circ_Buf++ );int i = Circ_Buf[3];


Language Implementation 3–71_fract SomeVariable;_fract _circ input_buf[100];void func(void){_fract _circ *inPtr = input_buf;}...*inPtr++ = SomeVariable;...Ffunc:...move #Finput_buf,r3 ; load buffer address; in pointermove #100–1,m3; load modulo valuemove x:FSomeVariable,x0 ; get value of; SomeVariablemove x0,x:(r3)+; store value at; buffer location and; increment pointer. ; more actions with. ; inPtrmove m7,m3; disable modulo of m3; (m7 always contains; –1 in the mixed or; reentrant model)..input_buf• • • • • • • •


3–72Chapter 3 #pragmacache_sector_size _CACHE_SECTOR_SIZE


Language Implementation 3–73 _cache_regionvoid _cache_region sample( void ){...}_cache_regionvoid _cache_region fptr( void ); • • • • • • • •


3–74Chapter 3 void foo( void ){void _cache_region creg( void );_plock( _cache_get_start( creg ) );/* loop fits in one sector */#pragma cache_align_now#pragma cache_region_start cregfor ( ... ){...}#pragma cache_region_end creg_punlock( _cache_get_start( creg ) );}


Language Implementation 3–75void _cache_region sample( void ){...}extern void _cache_region sample( void );void main( void ){void _P *p;}for ( p = _cache_get_start( sample );p < _cache_get_end( sample );p += _CACHE_SECTOR_SIZE ){_plock( p );}. . .for ( p = _cache_get_start( sample );p < _cache_get_end( sample );p += _CACHE_SECTOR_SIZE ){_punlock( p );} _bank()• • • • • • • •


3–76Chapter 3range# address range0 0X8000–0X9FFF1 0XA000–0XBFFF2 0XC000–0XDFFF3 0XE000–0XEFFF_bank• •


Language Implementation 3–77Examplevoid _bank(1,0) foo( void );void _bank(3,1) bar( void );void _bank(3,1) bar( void ){foo();} _packed_packed • • • • • • • •


3–78Chapter 3 _packed char somestring[] = ”Some String”;void example( void ){// allocate space for unpackingchar *p = (char *)malloc( _unpstrlen( somestring) + 1) );_unpackstr( p, somestring );printf( ”unpacked %s, packed %S\n”, p, somestring );free( p );}


Language Implementation 3–79int printpstring( _packed char *p ){int idx = 0;char c;while( c = _pstr_get( p, idx++ ) )putchar( c );return( idx );}void main( void ){int parm;#pragma pack_strings// make packed strings// of all string constantsprintpstring( ”Continue? (Y/N): ” );parm = getchar();printpstring( ”Action: ” );printpstring( parm == ’Y’ ? ”Continuing” :”Stopping” );#pragma nopack_strings}sizeof( _packed char )sizeof( char )_packed char *p = ”123456789”;char *n = ”123456789”;. . .char c;c = _pstr_get( p, 1 ); // c will be ’1’p++;c = _pstr_get( p, 1 ); // c will be ’4’c = *n; // c will be ’1’n++;c = *n; // c will be ’2’• • • • • • • •


3–80Chapter 3 struct S {_X int i; /* referring to storage: not correct */_P char *p; /* used to specify target memory: correct */};_X typedef _P int PINT; /* storage type _P: OK */typedef int _X *DATAPTR; /* logical type _Xstorage type ’default’ */


Language Implementation 3–81 –OT –OW /* force jump chain code */–Ot /* force jump table code */–OT –Ow /* let the compiler decidethe switch method used */#pragma jumptable_memory• • • • • • • •


3–82Chapter 3 c56.h_C56


Language Implementation 3–83 intintsignedunsigned charshortsignedunsigned charshortsignedunsigned charsignedunsigned char unsigned unsignedintunsignedshortunsignedshort• • • • • • • •


3–84Chapter 3_fract output=0.0;_fract _X x[10];_fract _Y c[10];main(){int i;for(i=0; i < 10; i++)output += x[i]*c[i];}output_fract output=0.0;_fract _X x[10];_fract _Y c[10];main(){int i;_fract tmp = output; // copy to temporary variablefor(i=0; i < 10; i++)tmp += x[i]*c[i]; // use temporary variableoutput = tmp; // get value from temporary variable}


Language Implementation 3–85i_fract output=0.0;_fract _X x[10];_fract _Y c[10];main(){int i=0;_fract tmp = output;do{tmp += x[0]*c[i++]; // i++ in expression} while(i


3–86Chapter 3 #pragma optimize 4 // optimize for speed. . . // some C code to be. . . // optimized for speed#pragma endoptimize // back to optimization set// before the pragma optimize _asmfunc_reentrant


Language Implementation 3–87 include.B.I.I• • • • • • • •


3–88Chapter 3#include void main( void ){sr_type a;a = SSISR;a.I = SSISR.I;}// include register// header file// copy whole structure// preferred: copy .I field _fract scale_down( _fract f ){return ( f*0.25 ) /* f >>= 2 */}asr aasr arts


Language Implementation 3–89_fract scale_up( _fract f ){return ( f/0.125 ) /* f


3–90Chapter 3From Value To Resultsigned char, short, int, –1 0.0unsigned char, short, >= 0 _fract, long _fract 0.0int, long_fract, long _fract –1.0 0_fract, long _fract < = –1.0 unsigned char, short, int, long max. value(all ones)>= –1.0 0int i;_fract f;i = 3; f = i; // f will be 0.0. . .i = –5; f = i; // f will be –1.0. . .f = 0.5; i = f; // i will be 0. . .f = –0.1; i = f; // i will be 0. . .f = –1.0; i = f; // i will be –1


Language Implementation 3–91_fractint; 1 |extern int i;; 2 |extern _fract f;. . .; 6 | i = f; // _fract to intmove x:Ff,a ; get f into accu aneg a; negate to set flagsmove #0,a ; result in i is 0jle L3 ; if value was >= 0 result in i is 0jes L3; or if value was > –1.0 if extension; not in use result in i is 0move #>–1,a ; else result in i is –1L3: move a,x:Fi ; store i; 8 | f = i; // int to _fractmove x:Fi,b ; get i into accu btst b; check value of imove #0,b ; result in f is 0.0jge L4 ; if i >= 0 result in f is 0.0move #


3–92Chapter 3typedef union{_fract f;int i;} fract_int;fract_int val = 0x123456; // hex initializationint f( void ){val.f = 0.1; // put fractional value 0.1// in val.freturn( val.i ); // return 0xCCCCC as integer} int f( void ){_fract f = 0.1; // put fractional value 0.1// in freturn( *(int*)&f ); // return 0xCCCCC as integer}


Language Implementation 3–93; 1 |extern int i, j, k;. . .; 10 | k += i * j;move x:Fk,a0move x:Fi,x0move x:Fj,y0asl amac x0,y0,aasr amove a0,x:Fk; get k into a0, this must; be a0 to do the MAC; get i into x0; get j into y0; prepare for mac on integer:; scaling; mac!; get result of mac: scaling; store k; 1 |extern _fract i,j,k;. . .; 10 | k += i * j;move x:Fk,amove x:Fi,x0move x:Fj,y0macr x0,y0,amove a,x:Fk; get k into accu a; get i into x0; get j into y0; mac!; store k_inline• • • • • • • •


3–94Chapter 3


COMPILER USE


4–2Chapter 4


<strong>Compiler</strong> Use 4–3” ”””• • .cc.cxx.cpp• .c• .asm• .src• .a• .obj• .cln• .clb• • • • • • • •


4–4Chapter 4• .out.out• .dscOption Description–? or none Display invocation syntax–Mm–Mr–MsMixed memory model (only allowed for cc56)Reentrant memory model (only allowed for cc56)Static memory model (only allowed for cc56)–M24 24–bit memory model (only allowed for cc563)–M1624 16/24–bit memory model (only allowed for cc563)–M16 16–bit memory model (only allowed for cc563)–M6 DSP566xx memory model (only allowed for cc563)–S Generate Motorola compatible assembly file with COFFdebug, stops at .asm–Tnametarget hardware–V Display version header only–Waarg–Wcarg–Wcparg–Wlcarg–Wlkarg–Wplarg–c++Pass argument directly to the assemblerPass argument directly to the C compilerPass argument directly to the C++ compilerPass argument directly to the locatorPass argument directly to the linkerPass argument directly to the C++ pre–linkerForce .c files to C++ mode–c Do not link: stop at .obj–ccCompile C++ files to .c and stop


<strong>Compiler</strong> Use 4–5Option Description–clDo not locate: stop at .out–clasSet locator output file format to CLAS compatible–csDo not assemble: compile C and C++ files to .src and stop–f file Read arguments from file (”–” denotes standard input)–ieeeSet locator output file format to IEEE–695 (default)–ihexSet locator output file format to Intel Hex–nolibDo not link with the standard libraries–o file Specify the output file–srecSet locator output file format to Motorola S–records–tiofSet locator output file format to TIOF–695–tmpKeep intermediate files–v Show command invocations–v0 Show command invocations, but do not start them–wc++ Enable C and assembler warnings for C++ files• • • • • • • •


4–6Chapter 4” ”””.srcOptionDescription–? Display invocation syntax–A[flag...]Control language extensions–Cflag...–Dmacro[=def]–E[m|l|c|i|p|x]–Hfile–Idirectory–Lnumber–M[m|s|r][x|y|l|p][L]Control compatibility optionsDefine preprocessor macroPreprocess options or emit dependenciesInclude file before starting compilationLook in directory for include filesSpecify depth of hardware stack useSelect memory model: mixed, static or reentrant.Select default memory space: X, Y, L or P. Specifystack not in L memory (only for c56)


<strong>Compiler</strong> Use 4–7Option–M[24|1624|16|6][n][x|y|l|p][L]–Oflag...–R[dname[=sname]]–UmacroDescriptionSelect memory model: 24–bit, 16/24–bit, 16–bit orDSP566xx. Do not use hardware stack extension.Select default memory space: X, Y, L or P. Specifystack not in L memory (only for c563).Control optimizationChange default section nameRemove preprocessor macro–V Display version header only–csizeSpecify size of cache sectors for the DSP563xx–e Remove output file if compiler errors occur–errSend diagnostics to error list file (.err)–f file Read options from file–g[f|l|n|c]...–mmaskEnable symbolic debug information (unless –gn isused)Compile for silicon mask (c563 only)–n Send output to standard output–o file Specify name of output file–ppage–rregisterSpecify number of Patriot memory pagesReserve a register for external use–s Merge C source code with assembly output–siMerge C source code and included files withassembly output–t Display lines/min–u Treat all ’char’ variables as signed–w[num]Suppress one or all warning messages–wstrict Suppress warning messages 196, 303–zpragmaIdentical to ’#pragma pragma’ in the C source• • • • • • • •


4–8Chapter 4DescriptionInclude optionsRead options from fileInclude file before starting compilationLook in directory for include filesPreprocess optionsPreprocess options or emit dependenciesDefine preprocessor macroRemove preprocessor macroAllocation control optionsSpecify depth of hardware stack useChange default section nameSpecify size of cache sectors for the DSP563xxReserve a register for external useCode generation optionsSelect memory model: mixed, static or reentrant.Select default memory space: X, Y or P. Specify stacknot in L memory (only for c56)Select memory model: 24–bit, 16/24–bit, 16–bit orDSP566xx. Do not use hardware stack extension.Select default memory space: X, Y, L or P. Specifystack not in L memory (only for c563).Control optimizationCompile for silicon maskSpecify number of Patriot memory pagesIdentical to ’#pragma pragma’ in the C sourceLanguage control optionsControl language extensionsControl compatibility optionsTreat all ’char’ variables as signed –uOutput file optionsRemove output file if compiler errors occur –eOption–f file–HfileSend output to standard output –n–Idirectory–E[m|l|c|i|p|x]–Dmacro[=def]–Umacro–Lnumber–R[dname[=sname]]–csize–rregister–M[m|s|r][x|y|l|p][L]–M[24|1624|16|6][n][x|y|l|p][L]–Oflag...–mmask–ppage–zpragma–A[flag...]–Cflag...


<strong>Compiler</strong> Use 4–9DescriptionSpecify name of output fileMerge C source code with assembly output –sMerge C source code and included files withassembly outputDiagnostic optionsDisplay invocation syntax –?Display version header only –VSend diagnostics to error list file (.err)Enable symbolic debug information (unless –gn isused)Display lines/min –tSuppress one or all warning messagesSuppress warning messages 196, 303Option–o file–si–err–g[f|l|n|c]...–w[num]–wstrict• • • • • • • •


4–10Chapter 4


<strong>Compiler</strong> Use 4–11Option:Description:Example:c563 –?• • • • • • • •


4–12Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>Language ExtensionsAdvanced language extensionsArguments:Default:Description:char *p;void main( void ) { p = ”hello”; }DS 1constchar i[1];


<strong>Compiler</strong> Use 4–13 BSC 1const char i[1];charshortcharshortintlongsignedunsignedshort a_short;long a_long;void f(void){a_long = 0x123456;a_short = a_long;}movemovel:Fa_long,bb0,x:Fa_shortmovemoveextractmovemovel:Fa_long,bb0,b#$10018,b,bb0,bb0,x:Fa_short[–1.0,1.0>_fract[–1.0,1.0>float_fract_X_near • • • • • • • •


4–14Chapter 4_circ _circ_circint a, *p;void _long_interrupt(28) irq28(void){a = *p++;}/* code contains moves for m–register without –AO*/// e.g this is a C++ comment line.restrictrestrict


<strong>Compiler</strong> Use 4–15charintfloatdoublevoidvoid *p; ((int*)p)++; /* allowed */int i; (char)i=2; /* NOT allowed */Example:c563 –AP test.c• • • • • • • •


4–16Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OutputGenerateMotorola compatible assemblyProject | Project Options...C <strong>Compiler</strong>Code Generation• User stack pointer points to first free location• All functions with _compatible calling convention• Use R6 as user stack pointerArguments:Default:Description:


<strong>Compiler</strong> Use 4–17_compatible Example:c563 –C1 test.c• • • • • • • •


4–18Chapter 4Option:Pragma:Arguments:Default:Description:_cache_regionExample:c563 –c256 test.c


<strong>Compiler</strong> Use 4–19Option:Project | Project Options...C <strong>Compiler</strong>PreprocessingDefine user macrosArguments:Description:Example:NORAM1PI3.1416c563 –DNORAM –DPI=3.1416 test.c• • • • • • • •


4–20Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>PreprocessingPreprocess only and capture outputDescription:Examples:test.cpreoutc563 –E –o preout test.ctest.cmultic563 –El test.c –o multi


<strong>Compiler</strong> Use 4–21test.cc563 –Em test.ctest.src : test.c• • • • • • • •


4–22Chapter 4Option:Description:Example:c563 –e test.c


<strong>Compiler</strong> Use 4–23Option:Description:Example:test.errc563 –err test.c• • • • • • • •


4–24Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>MiscellaneousAdditional optionsArguments:Description:


<strong>Compiler</strong> Use 4–25”This has a single quote ’ embedded”’This has a double quote ” embedded’’This has a double quote ” and \a single quote ’”’ embedded” ”This is a continuation \line”–> ”This is a continuation line”control(file1(mode,type),\file2(type))–>control(file1(mode,type),file2(type)) Example:mycmds–errtest.cc563 –f mycmds• • • • • • • •


4–26Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>DebugGenerate symbolicdebug informationInclude debuginformation for non referenced typesInclude lifetime info for all typesDefault:Description:• •


<strong>Compiler</strong> Use 4–27Examples:c563 –g test.cc563 –gl test.cc563 –gn test.c• • • • • • • •


4–28Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>PreprocessingInclude this file before sourceArguments:Description:Example:c563 –Hstdio.h test.c


<strong>Compiler</strong> Use 4–29Option:Project | Directories...Include Files PathArguments:Description:../includeExample:c563 –I/proj/include test.c• • • • • • • •


4–30Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>Code GenerationUse hardware stack extensionMax. hardware stack use outside interruptfunctionsArguments:Default:Description:Example:c563 –L4 example.cexample.cfor( ... ) /* depth 1 –> no hardware DO loop */{for( ... ) /* depth 2 –> hardware DO loop */{ /* stack level 2 */for( ... ) /* depth 3 –> hardware DO loop */{ /* stack level 4 */...}}}


<strong>Compiler</strong> Use 4–31Option:Project | Project Options...C <strong>Compiler</strong>Code GenerationMemoryModelDefault Data MemoryArguments: Default:• • • • • • • •


4–32Chapter 4Description:Example:c56 –Mr test.cc563 –M16 test.c


<strong>Compiler</strong> Use 4–33Option:Project | Project Options...C <strong>Compiler</strong>Miscellaneouschip maskArguments:Description:Example:c563 –m1 example.c• • • • • • • •


4–34Chapter 4Option:Description:Example:c563 –n test.c


<strong>Compiler</strong> Use 4–35Option:Project | Project Options...C <strong>Compiler</strong>OptimizationOptimizationCustom optimizationOptimizationCustom optimizationPragma:Arguments:Default:Description:#pragmaoptimizeoptimizeoptimizeoptimize#pragma optimize numberoptimize• • • • • • • •


4–36Chapter 4 Example:c563 –OacefghijLnOprsTUvwxyz test.coptimize


<strong>Compiler</strong> Use 4–37Option:Project | Project Options...C <strong>Compiler</strong>OptimizationOptimizationReduceoptimization for debuggingArguments:Default:Description:• • • • • • • •


4–38Chapter 4Example:c563 –O2 test.c


<strong>Compiler</strong> Use 4–39Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationRelaxed alias checking (requires CSE)Pragma:Default:Description:Example:optimize• • • • • • • •


4–40Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationCommon subexpression elimination (CSE)Pragma:Default:Description:


<strong>Compiler</strong> Use 4–41Example:/** Compile with –OC –O0,* Compile with –Oc –O0, common subexpressions are found* and temporarily saved.*/char x, y, a, b, c, d;voidmain( void ){x = (a * b) – (c * d);}y = (a * b) + (c * d);optimize• • • • • • • •


4–42Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationExpression propagation (requires CSE)Pragma:Default:Description:Example:/** Compile with –OE –Oc –O0, normal cse is done* Compile with –Oe –Oc –O0, ’i+j’ is propagated.*/unsigned i, j;intmain( void ){static int a;a = i + j;return (a);}optimize


<strong>Compiler</strong> Use 4–43Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationCode flow optimization and orderrearrangingPragma:Default:Description:• • • • • • • •


4–44Chapter 4Examples:/** Compile with –OF –O0* Compile with –Of –O0, compiler finds first time ’i’* is always < 10, the unconditional jump is removed.*/int i;voidmain( void ){for( i=0; i


<strong>Compiler</strong> Use 4–45/** Compile with –OF –O0, code as written sequential* Compile with –Of –O0, code is rearranged** Code rearranging enables other optimizations to* optimize better, e.g. CSE*/int i;extern void dummy( void );void main (){do{if ( i ){i––;}else{i++;break;}dummy();} while ( i );}optimize• • • • • • • •


4–46Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationRegister allocation graph optimizationPragma:Default:Description:Example:/** Compile with –OG –O0* Compile with –Og –O0, register allocation* graph optimization*/typedef struct{long l;int i;} STRUCT;int f(STRUCT *s_p){return s_p–>i;}


<strong>Compiler</strong> Use 4–47Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationHardware loop generationPragma:Default:Description:Example:/** Compile with –OH –O0, software loop is used* Compile with –Oh –O0, hardware DO loop is used*/int cumu;voidmain( void ){int i;for ( i = 0; i


4–48Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationMove invariant code outside loop(requires CSE)Pragma:Default:Description:Example:/** Compile with –OI –Oc –O0, normal cse is done* Compile with –Oi –Oc –O0, invariant code is found in* the loop, code is moved outside the loop.*/voidmain( void ){char x, y, a, b;int i;}for( i=0; i


<strong>Compiler</strong> Use 4–49optimize• • • • • • • •


4–50Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationCache global variables in functionsPragma:Default:Description:Examples:/** Compile with –OJ –O0, ’sum’ is updated twice* Compile with –Oj –O0, ’sum’ is updated only once*/int sum;voidadd( int a, int b ){sum += a;sum += b;}optimize


<strong>Compiler</strong> Use 4–51Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationGenerate fast loops (increases code size)Hardware loopgenerationPragma:Default:Description:• • • • • • • •


4–52Chapter 4Example:/** Compile with –OL –O0* Compile with –Ol –O0, compiler duplicates the loop* condition, the unconditional jump is removed.*/int i;voidmain( void ){for( ; i


<strong>Compiler</strong> Use 4–53Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationNOP insertionPragma:Default:Description:• • • • • • • •


4–54Chapter 4Example:/** Compile with –ON, NOP is not inserted.* Compile with –On, NOP is inserted.*/int i;voidmain( void ){int a;f(); /* call a function */}for ( i = 0; i < 1; i++)a = i;optimize


<strong>Compiler</strong> Use 4–55Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationGenerate parallel movesPragma:Default:Description:opt opExample:c563 –OO test.coptimize• • • • • • • •


4–56Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationConstant and copy propagation (data flow)Pragma:Default:Description:Example:/** Compile with –OP –O0, ’i’ is actually assigned to ’j’* Compile with –Op –O0, 15 is assigned to ’j’, ’i’ was* propagated*/int i;int j;voidmain( void ){i = 10;j = i + 5;}optimize


<strong>Compiler</strong> Use 4–57Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationOptimize single instruction hardware DO toREP loopsPragma:• • • • • • • •Default:Description:Example:/** Compile with –OR –Oh, a DO loop is used* Compile with –Or –Oh, optimize to REP loops*/voidf( void ){int i, a;for ( i = 0; i


4–58Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationFavor code size above execution speedPragma:Default:Description:Example:int a, b;voidmain( void ){a = ( b != 0 );}bset #0,bmove #>1,b; –Os: 1 word, 4 cycles; –OS: 2 words, 3 cycles


<strong>Compiler</strong> Use 4–59 optimize• • • • • • • •


4–60Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationCode generation for switch statementPragma:Default:Description:Example:/** Compile with –OT –OW –O0, generate jump chain.* Compile with –Ot –OW –O0, generate jump table.*/int i;


<strong>Compiler</strong> Use 4–61voidmain( void ){switch (i){case 1: i = 0;case 2: i = 1;case 3: i = 2;default: i = 3;}}optimize• • • • • • • •


4–62Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationLoop unrollingPragma:Default:Description:Example:/** Compile with –OU, normal loop handling* Compile with –Ou, loop is eliminated, body is duplicated*/int i, j;voidmain( void ){for( i=0; i


<strong>Compiler</strong> Use 4–63Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationSubscript strength reductionPragma:Default:Description:Example:* Compile with –OV –O0, disable subscript strength reduction* Compile with –Ov –O0, begin and end address of ’a’* are determined before the loop and temporarily put in* registers instead of determining the address each* time inside the loop*/int i;int a[4];voidmain( void ){for( i=0; i


4–64Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationCode generation for switch statementPragma:Default:Description:


<strong>Compiler</strong> Use 4–65Example:/** Compile with –OW –OT –O0, always generate jump chain.* Compile with –Ow –OT –O0, choose best switch method, in this* case this is also a jump chain.*/int i;voidmain( void ){switch (i){case 1: i = 0;case 2: i = 1;case 3: i = 2;default: i = 3;}}optimize• • • • • • • •


4–66Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationRegister contents trackingPragma:Default:Description:Example:/** Compile with –OX –O0* Compile with –Ox –O0, register contents tracking,* the overlay scratch section is removed*/int a, b, c;void main(void){a = 2;switch(b){case 1:c = 3;break;case 2:case 3:c = 0;break;}}


<strong>Compiler</strong> Use 4–67Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationPeephole optimizationPragma:Default:Description:• • • • • • • •


4–68Chapter 4Example:/** Compile with –OY –O0, unnecessary instructions found* Compile with –Oy –O0, peephole optimizer searches* for patterns in the generated code which can be* removed/combined. E.g.* asl b* add a,b* can be combined to: addl a,b*/long a;long f(void);voidmain( void ){long b;b = f();a = (a


<strong>Compiler</strong> Use 4–69Option:Project | Project Options...C <strong>Compiler</strong>OptimizationCustom optimizationOptimizationNon–sequential register allocationPragma:Default:Description:• • • • • • • •


4–70Chapter 4Example:/** Compile with –OZ –O0, sequential register allocation, the* same register is used for each allocation.* Compile with –Oz –O0, non sequential register allocation.* Three different registers are used for the allocations.*/int a[3];voidmain( void ){a[0] = 0;a[1] = 1;a[2] = 2;}optimize


<strong>Compiler</strong> Use 4–71Option:Project | Project Options...C <strong>Compiler</strong>MiscellaneousAdditional optionsArguments:Default:.srcDescription:.srcExample:c563 file1.c file2.c –o file3.src –o file2.src• • • • • • • •


4–72Chapter 4Option:Arguments:Default:Description:Example:c563 –p5 test.c


<strong>Compiler</strong> Use 4–73Option:Project | Project Options...C <strong>Compiler</strong>OutputReplace default section namesArguments:Description:Example:mystring.xstringc563 –R.xstring=mystring test.cc563 –R.xstring test.c.xstring.xstringtest• • • • • • • •


4–74Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>Code GenerationReserve address or offset registerArguments:Description:Example:example.cc563 –rr5 –rn5 example.c


<strong>Compiler</strong> Use 4–75Option:Project | Project Options...C <strong>Compiler</strong>OutputMerge C sourcefile with assembly outputPragma:Description:Example:c563 –s test.c; test.c:; 1 |int i;; 2 |; 3 |int; 4 |main( void ); 5 |{extern F_STARTglobal Fmainsourcenosource• • • • • • • •


4–76Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>OutputDisplay lines/minDescription:Example:c563 –t test.cprocessed 180 lines at 8102 lines/min


<strong>Compiler</strong> Use 4–77Option:Project | Project Options...C <strong>Compiler</strong>PreprocessingArguments:Description:• • • • • • • •


4–78Chapter 4Example:c563 –U_MODEL test.c


<strong>Compiler</strong> Use 4–79Option:Project | Project Options...C <strong>Compiler</strong>Code GenerationTreat ’char’ variables as unsignedDescription:charunsigned charcharsigned charExample:charsigned charc563 –u test.c• • • • • • • •


4–80Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>MiscellaneousAdditional optionsDescription:Example:c56 –VTASKING DSP5600x C compiler vx.yrz Build nnnCopyright 1995–year Altium BV Serial# 00000000c563 –VTASKING DSP563xx/6xx compiler vx.yrz Build nnnCopyright 1996–year Altium BV Serial# 00000000


<strong>Compiler</strong> Use 4–81Option:Project | Project Options...C <strong>Compiler</strong>DiagnosticsDisplay allwarningsSuppress all warningsSuppress only certainwarningsSuppress only certain warningsArguments:Description:Example:c563 file1.c –w135• • • • • • • •


4–82Chapter 4Option:Project | Project Options...C <strong>Compiler</strong>MiscellaneousAdditional optionsArguments:Description:Example:–zcache_sector_size–256–zjumptable_memory–x#pragma cache_sector_size 256#pragma jumptable_memory x


<strong>Compiler</strong> Use 4–83 c563 ..\..\source\test.cc563 ../../source/test.c..\..\source../../source Project | Directories...Include Files Pathc563 –I..\..\include demo.cc563 –I../../include demo.c • • • • • • • •


4–84Chapter 4set C563INC=..\..\includec563 demo.cC563INC=../../includeexport C563INCc563 demo.csetenv C563INC ../../includec563 demo.c includeC:\C563\BINC:\C563\INCLUDE/usr/local/c563/bin/usr/local/c563/includeincludec56


<strong>Compiler</strong> Use 4–85 set C563INC=..\..\include;\proj\include setenv C563INC ../../include:/proj/include• • • • • • • •


4–86Chapter 4#pragma pragma–token–list new–line


<strong>Compiler</strong> Use 4–87_cache_region_cache_region_cache_region• • • • • • • •


4–88Chapter 4void foo(int i){while (i > 0){printf(”%d\n”, i);i––;}}Ffoo: move (r7)+do a1,L11move a1,n5move a1,x:(r7–1)move n5,amove #L8,r0jsr Fprintfmove x:(r7–1),asub #1,aL11: void a, r0, n5move (r7)–rtsi


<strong>Compiler</strong> Use 4–89void foo(int i){do{printf(”%d\n”, i);i––;} while (i > 0)}Ffoo: move (r7)+do a1,L5move a1,r5move a1,x:(r7–1)move r5,amove #L3,r0jsr Fprintfmove x:(r7–1),asub #1,aL5: void a, r0, r5move (r7)–rts• • • • • • • •


4–90Chapter 4


<strong>Compiler</strong> Use 4–91int i;voidfunc( ){char * p;char c;char d;if( i )p = &c;elsep = &d;c = 2;d = 3;*p = 4; /* may write to ’c’ or ’d’ *//* ––> aliasing object ’c’ or ’d’ */}i = c; /* ’*p’ might have changed the value of ’c’, *//* so ’c’ may not be used from register *//* contents, but MUST be read from memory *//* ––> alias checking MUST be ON in this case */• • • • • • • •


4–92Chapter 4int i;voidfunc( char *p ){char c;char d;c = 2;d = 3;*p = 4; /* cannot write to ’c’ or ’d’, but to some otherobject */}i = c; /* ’*p’ cannot have changed the value of ’c’, *//* so ’c’ may be used from register contents *//* ––> alias checking may be OFF in this case */typedef union{struct{unsigned int exponent;_fract fraction;} binary;double value;} _FDEF;#define _FBIAS 127doublefrexp_excerpt( double value, int *exp ){double loc_value = value; /* prevent taking address ofargument ’value’ */*exp = ((_FDEF *)&loc_value)–>binary.exponent – _FBIAS;((_FDEF *)&loc_value)–>binary.exponent = _FBIAS;}if ( loc_value == –1.0 ){*exp += 1;return( –0.5 );}return( loc_value );loc_value


<strong>Compiler</strong> Use 4–93• • • • • • • • • • • • • • • • • • • • • • •


4–94Chapter 4• • • • •


COMPILERDIAGNOSTICS


5–2Chapter 5


<strong>Compiler</strong> Diagnostics 5–3S number: internal error – please report• • • • • • • •


5–4Chapter 5c563 –s %1.cIF ERRORLEVEL 1 GOTO STOP_BATCHc563 $*case $? in0) echo ok ;;1|2|3) echo error ;;esac


<strong>Compiler</strong> Diagnostics 5–5 • • • • • • • •


5–6Chapter 5 ”’ ++i{ int i; ++i } 08int i = 0x1234567890;


<strong>Compiler</strong> Diagnostics 5–7char *s = #S ; // error \• • ’’ • • • • • • • •


5–8Chapter 5 #include


<strong>Compiler</strong> Diagnostics 5–9main(){int j;int j; /* error */} #line 9999 L”t45.c” switchchar *p = 0; switch (p) \c• • • • • • • •


5–10Chapter 5


<strong>Compiler</strong> Diagnostics 5–11 #if defined() static struct {inti;} si = {0};while (si) ++si.i; #if 1. f(){lab1:lab1: /* error */} longintdoublestructunionenumunsigned signed int i; /* error */• • • • • • • •


5–12Chapter 5 autoregisterregister struct T { int i; };struct T { long j; }; /* error */ f(){}int i;char i; /* error */ int char i; /* error */


<strong>Compiler</strong> Diagnostics 5–13 breakswitchdoforwhileif (0) break; voidvoid i; /* error */ { long long i; } /* error */ register auto i; continuedoforwhileswitch (i) {default: continue;} int f ( i, j, k ); voidint f(void,int);• • • • • • • •


5–14Chapter 5 switch char c = ’\xabc’; /* error */ int i;int i(); /* error E 64 and warning */ struct {int *a:1;} s;


<strong>Compiler</strong> Diagnostics 5–15 #define id( int f(int, ...);int f(); /* error, old–style */ typedeftypedef int INTFN();INTFN f {return (0);} /* error */ case:default:switch• • • • • • • •


5–16Chapter 5 structunionenumint ;/* error */static int a[2] = { }; /* error */ casedefault:switch int i;int *pi = &i;ff(1 – pi); /* error */ structunion char a[0]; int f(int);int f(int, int);/* error differentparameter list */


<strong>Compiler</strong> Diagnostics 5–17 int f(int [][2]);int f(int [][3]); /* error */ int f(int);int f(long); /* error different typein parameter list */ float d = 10E9999; /* error, too big */ typedef int F(); F f(); /* error */typedef int A[2]; A g(); /* error */ typedef• • • • • • • •


5–18Chapter 5int f(int g, int) {return (g);} /* error */typedef int int_type;int h(int_type) {return (0);} /* error */ structunionextern struct unknown sa, sb;sa = sb; /* ’unknown’ does not have adefined type */ gotof1() { a: ; } /* W 116 */f2() { goto a; } /* error, label ’a:’ isnot defined in f2() */ f() { a: ; } /* ’a’ is not referenced */ unknown i;/* error, ’unknown’ undefined */i = 1; /* as a result, ’i’ is alsoundefined */ case


<strong>Compiler</strong> Diagnostics 5–19int i = 10E88; /* error and warning */ void int f() return 0; /* missing ’{ }’ */int g() { } /* error, ’g’ is not aformal parameter andtherefore, this is not avalid function declaration */ returnvoid returnvoid voidreturn extern{ extern int i = 0; } /* error */int f( i ) int i=0; /* error */• • • • • • • •


5–20Chapter 5 long *pl;int *pi = 0;pl = pi; /* warning */ int *pi;pi += 1.; /* error, pointer on left; needsintegral value on right */int a,b;a = b; /* warning, value of b unknown */ structunionintunsigned struct i { unsigned i : 999; }; /* error */ return int i, j;j = i(); /* error, i is not a function */


<strong>Compiler</strong> Diagnostics 5–21• • • • • • • • structunionstatic union ui {int a;} ui ;ui = (union ui)9; /* cannot cast to union */ff( (int)ui ); /* cannot cast a unionto something else */ func(&r6);func(&bitf.a); const int i = 1;i = 3; /* error, const cannot bemodified */ static int a[1] = {1, 2};/* error,only one object can be initialized */ enumintenum { A = INT_MAX, B }; /* warning,B does not fit in an int anymore */ inta[] = 2;int a[] = {2};


5–22Chapter 5 int i; void func(int,int);func( 1, &i ); /* warning, argument 2 */ structunionf(struct s); /* prototype */main(){struct { int i; } t;f( t ); /* t has other type than s */} structunion struct { struct unknown m; } s; /* error */int f(int*);long *l;f(l); /* warning */ structunionenum


<strong>Compiler</strong> Diagnostics 5–23 sizeof structunionf(struct s); /* prototype */main(){int i;f( i ); /* i is not a struct */} int i = 3;++(unsigned)i; /* error, cast expressionis not an lvalue */ int f( i ) int a; /* error */ structunion int *pi = 44; /* right side not a pointer */• • • • • • • •


5–24Chapter 5 struct {int a; int b;} s;struct {int c; int d; int e;} t;s = t; /* error */ int i;i = &( i = 0 ); char **a;char *b;a = b; /* warning */ (void *) main(){typedef int array[10];array a;array *ap = a; /* warning */} void


<strong>Compiler</strong> Diagnostics 5–25void f(void);main(){int i;}i = (int)f(); /* error */• • • • • • • • _inline_inline int a (int i){a(i);/* recursive call */return i;}main(){a(1);/* error */} _inline void a (){a();}main(){a();} char b[] = L”abc””def”; /* strings havedifferent types */ void


5–26Chapter 5 int *a;static int *b = a; /* error */ int a;static int b = a++; /* error */ int a; /* automatic */static int *b = &a; /* error */


<strong>Compiler</strong> Diagnostics 5–27_inline int a(void);/* prototype */main(){int b;b = a(); /* error */}; int a;int f(void){int i;}if ( a ){i = 0; /* statement not reached */}return i; /* warning */ • • • • • • • •


5–28Chapter 5 struct unknown s = { 0 }; doublelong123.12flfloat structunionstruct s { struct s a; } b; /* error */ typedef i=2; int i = 17000000L;/* warning, value is too largeto fit in an int */


<strong>Compiler</strong> Diagnostics 5–29 int i = 40000U;/* the unsigned value is too largeto fit in a signed int *//* unsigned int i = 40000U; is OK */ #pragma unknown register void• • • • • • • •


5–30Chapter 5int f(void); /* void parameter list */main(){int i;i = f(i); /* error */i = f(); /* OK */} int f(int); /* one parameter */main(){int i;i = f(i,i); /* error, one too many */i = f(i); /* OK */} static #pragma asm#pragma endasm#pragma endasm#pragma asm#pragmaendasm


<strong>Compiler</strong> Diagnostics 5–31 #pragma endasm#pragma asm#pragma asm_noflush int a;int f(void){int i;}if ( a ){i = 0; /* statement not reached */}return i; /* warning */ _asmfunc • • • • • • • •


5–32Chapter 5 _fract a;int f(void){a = .75 + .5; /* 1.25, overflow */} cache_region_startcache_region_end_cache_region _interrupt(n)


<strong>Compiler</strong> Diagnostics 5–33• • • • • • • • _swi() _near _circularlongunsigned long


5–34Chapter 5 _reentrant __asm __asm extern


<strong>Compiler</strong> Diagnostics 5–35 #pragma endoptimize#pragma optimize _fast_interrupt short _fract _circ_circ • • • • • • • •


5–36Chapter 5


<strong>Compiler</strong> Diagnostics 5–37 _bank• • • • • • • •


5–38Chapter 5 _compatible_callee_save


LIBRARIES


6–2Chapter 6


Libraries 6–3printf()scanf()• • • _compatible• • • • • • • • •


6–4Chapter 6 bin lib\src CFLAGS CFLAGS = –I$(SRCDIR) –M24yn –Cacr –AFmk563 lib\563xxlib\566xxstart.asmNOESTACKASFLAGS


Libraries 6–5lib<strong>Compiler</strong> Processor Model LibrariesC Run–time Floatingpointc56 DSP5600x Static libcs.a librt.a libfp.aReentrantlibcr.aMixed libcm.ac563 DSP563xx 16 bit libc16.a librt16.a libfp16.a16/24 bit libc1624.a24 bit libc24.a librt24.a libfp24.aDSP566xx – libc6.a librt6.a libfp6.alibc16.alibsin()cos()• • • • • • • •


6–6Chapter 6FSS read**scanf_doscan**fgetcgetc*_filbuf**_read**fscanfgetsgetchar*getchar_ioread**fgetsfreadgetcFSS write**printf_doprint**fputcputc*_flsbuf**_write**fprintfputsputchar*putcharfflush_iowrite**fputsfwriteputcstdio.h


Libraries 6–7 • • • • • • • •


6–8Chapter 6File Imple– Routine name Description / Reasonmentedassert.h Y ’assert()’ macro Macro definitionconio.h Y _insizekbhit()


Libraries 6–9FileImple–mentedRoutine nameDescription / Reasonctype.hYMost of the routines aredelivered as macro AND asfunction (as prescribed byANSI).YYYYYYYYYYYYYYYYYisalnumisalphaiscntrlisdigitisgraphislowerisprintispunctisspaceisupperisxdigittolowertoupper_tolower_toupperisasciitoasciiNot defined by ANSINot defined by ANSINot defined by ANSINot defined by ANSIerrno.h Y Only Macrosfcntl.hfloat.hYIYopenlimits.h Y Only Macroslocale.hYLLlocaleconvsetlocaleDefinitions of flags used by _openNo OS presentNo OS present• • • • • • • •


6–10Chapter 6Filemath.hsetjmp.hsignal.hstdarg.hImple–mentedYYYYYYYYYYYYYYYYYYYYYYYYYYYLLYYYYRoutine nameacosasinatanatan2ceilcoscoshexpfabsfloorfmodfrexpldexploglog10modfpowsinsinhsqrttantanhlongjmpsetjmpraisesignalva_argva_endva_startDescription / ReasonNo OS presentNo OS presentstddef.h Y Only Macrosstdio.hYYIYYIIclearerrfclosefeofferrorfflushfgetcDue to ’stdarg.h/varargs.h’conflicts, the routines’vprintf()’, ’vfprintf()’,’vsprintf()’ are not ANSI yet.Needs _fcloseNeeds _writeNeeds _read


Libraries 6–11FileImple–mentedIIIIIIIIIIIIIIIIYIIIILLIIYYYYLLRoutine nameDescription / ReasonYIIYIIIIIIfgetposfgetsfopenfprintffputcfputsfreadfreopenfscanffseekfsetposftellfwritegetcgetchargetsperrorprintfputcputcharputsremoverenamerewindscanfsetbufsetvbufsprintfsscanftmpfiletmpnamungetcvfprintfvprintfvsprintf_close_fopen_lseek_open_read_writeNeeds _lseekNeeds _readNeeds _fopenNeeds _writeNeeds _writeNeeds _writeNeeds _readNeeds _fclose/_fopenNeeds _readNeeds _lseekNeeds _lseekNeeds _lseekNeeds _writeNeeds _readNeeds _readNeeds _readNeeds _writeNeeds _writeNeeds _writeNeeds _writeNeeds _lseekNeeds _readDelivered as a random namegenerator, but should usesome process ID.Needs _writeNeeds _writeLow level file close routineLow level file open routineLow level file positioningroutineLow level file open routineLow level input routineLow level output routine• • • • • • • •


6–12Chapter 6FileImple–mentedRoutine nameDescription / Reasonstdlib.hYYYYYYYYYYYYLYYYYYYYYYYabortabsatexitatofatoiatolbsearchcallocdivexitfreegetenvlabsldivmallocqsortstrtodstrtolstrtoulrandreallocsrandCalls _exit() in cstartCalls _exit() in cstartNo OS presentLLLLLLsystemmblenmbstowcsmbtowcwcstombswctombNo OS presentwide chars not supportedwide chars not supportedwide chars not supportedwide chars not supportedwide chars not supported


Libraries 6–13FileImple–mentedRoutine nameDescription / Reasonstring.hYYYYYYYYYLYYYYYYYYYYYYLmemchrmemcmpmemcpymemmovememsetstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrlenstrncatstrncmpstrncpystrpbrkstrrchrstrspnstrstrstrtokstrxfrmwide chars not supportedwide chars not supportedtime.hYYYYYYYYYYasctimeclockctimedifftimegmtimelocaltimemktimestrftimetimereal time clock not supported, butthe DSP timer is used to maintainrelative time• • • • • • • •


6–14Chapter 6#include int _close( int fd );_close.clib\src#include int _filbuf ( FILE * );#include int _flsbuf ( int, FILE * );


Libraries 6–15#include FILE _fopen( const char *filename, const char *mode,FILE *iop );filenameiop#include long _insize( int fd );int _ioread( FILE *fp );_ioread.clib\src• • • • • • • •


6–16Chapter 6int _iowrite( int c, FILE *fp );_iowrite.clib\src#include long_lseek( int fd, long offset, int origin );_lseek.clib\src


Libraries 6–17#include int _open( const char * filename, int flags );#include size_t _packsize( const char * p );#include _packed char *_packstr( _packed char * p,const char * unp );• • • • • • • •


6–18Chapter 6char _pstr_get( _packed char * p,size_t idx );int printpstring( _packed char *p ){int idx = 0;char c;while( c = _pstr_get( p, idx++ ) )putchar( c );return( idx );}void _pstr_put( _packed char * p,size_t idx, char c );


Libraries 6–19#include _packed char p[10];void main( void ){int idx;char c = ’a’;for ( idx = 0; idx < 10; idx++, c++ )_pstr_put( p, idx, c );// build string ”abcd ...”printf( ”%S\n”, p ); // print packed string}#include size_t_read( int fd, char *base, size_t size );#include int _tolower( int c );cc• • • • • • • •


6–20Chapter 6#include int _toupper( int c );cc#include char *_unpackstr( char * unp,const _packed char * p );#include size_t _unpstrlen( const _packed char *p );#include size_t_write( int fd, char *base, size_t size );


Libraries 6–21#include void abort( void );_exit#include int abs( int n );#include double acos( double x ); xxπx∈#include char *asctime( const struct tm *tp );*tpMon Jan 21 16:15:14 1989\n\0• • • • • • • •


6–22Chapter 6#include double asin( double x ); xxππx∈#include void assert( int expr );expr”Assertion failed: expression, file filename, linenum”#include double atan( double x ); xxππ#include double atan2( double y, double x ); y/xππy/xxy


Libraries 6–23#include int atexit( void (*fcn)( void ) );fcn#include double atof( const char *s );#include int atoi( const char *s );#include long atol( const char *s );• • • • • • • •


6–24Chapter 6#include _reentrant void *bsearch( const void *key,const void *base, size_t n, size_t size, int (* cmp)(const void *, const void *) );nptrbasesizecmp#include void *calloc( size_t nobj,size_t size );nobjsize#include double ceil( double x );x


Libraries 6–25#include void clearerr( FILE *stream );#include clock_t clock( void );#include double cos( double x );x#include double cosh( double x );x#include char *ctime( const time_t *tp );*tpasctime( localtime( tp ) );• • • • • • • •


6–26Chapter 6#include doubledifftime( time_t time2, time_t time1 );time2 – time1#include div_t div( int num, int denom );numdenom#include void exit( int status );status#include double exp( double x );


Libraries 6–27#include double fabs( double x );xx#include int fclose( FILE *stream )streamstream#include int feof( FILE *stream );stream#include int ferror( FILE *stream );stream#include int fflush( FILE *stream );stream• • • • • • • •


6–28Chapter 6#include int fgetc( FILE *stream );stream#include int fgetpos( FILE *stream, fpos_t *ptr );streamptrfpos_t#include char *fgets( char *s, int n, FILE *stream );nstreamss#include double floor( double x );x


Libraries 6–29#include double fmod( double x, double y );x/yxy#include FILE *fopen( const char *filename,const char *mode );modemode• • • • • • • •


6–30Chapter 6#include int fprintf( FILE *stream,const char *format, ... );stream#include int fputc( int c, FILE *stream );stream#include int fputs( const char *s,FILE *stream );stream


Libraries 6–31#include size_t fread( void *ptr,size_t size, size_t nobj, FILE *stream );nobjsizestreamptr#include void free( void *p );pp#include FILE *freopen( const char *filename,const char *mode, FILE *stream );modestreamstream• • • • • • • •


6–32Chapter 6#include double frexp( double x, int *exp );x*expxfrexp( 4.0, &var ) #include int fscanf( FILE *stream,const char *format, ... );stream#include intfseek( FILE *stream, long offset, int origin );streamoffsetoriginoffsetftellorigin


Libraries 6–33#include int fsetpos( FILE *stream,const fpos_t *ptr );streamfgetpos*ptr#include long ftell( FILE *stream );stream#include size_t fwrite( const void *ptr,size_t size, size_t nobj,FILE *stream );nobjsizestreamptr#include int getc( FILE *stream );stream• • • • • • • •


6–34Chapter 6#include int getchar( void );#include char *getenv( const char *name );name#include char *gets( char *s );#include struct tm *gmtime( const time_t *tp );*tp


Libraries 6–35#include int isalnum( int c );c#include int isalpha( int c );c#include int isascii( int c );c#include int iscntrl( int c );c#include int isdigit( int c );c• • • • • • • •


6–36Chapter 6#include int isgraph( int c );c#include int islower( int c );c#include int isprint( int c );c#include int ispunct( int c );c#include int isspace( int c );c


Libraries 6–37#include int isupper( int c );c#include int isxdigit( int c );c#include long labs( long n );#include double ldexp( double x, int n );x· #include ldiv_t ldiv( long num, long denom );numdenom• • • • • • • •


6–38Chapter 6#include struct lconv *localeconv( void );struct lconv#include struct tm *localtime( const time_t *tp );*tp#include double log( double x );ln(x), x>0#include double log10( double x );log10(x), x>0#include void longjmp( jmp_buf env, int val);val


Libraries 6–39#include void *malloc( size_t size );size#include int mblen( const char *s, size_t n );ssnss• • • • • • • •


6–40Chapter 6#include size_t mbstowcs( wchar_t *pwcs,const char *s, size_t n );spwcsnsize_t)#include int mbtowc( wchar_t *pwc,const char *s, size_t n );swchar_tpwcpwcnss#include void *memchr( const void *cs, int c,size_t n );ncsc


Libraries 6–41#include int memcmp( const void *cs,const void *ct, size_t n );ncsctcs < ctcs = = ctcs > ct#include void *memcpy( void *s,const void *ct, size_t n );nctss#include void *memmove( void *s,const void *ct, size_t n );nctss#include void *memset( void *s, int c,size_t n );nscs• • • • • • • •


6–42Chapter 6#include time_t mktime( struct tm *tp );*tp#include double modf( double x, double *ip );xx*ip.#include int offsetof( type, member );member#include void perror( const char *s );serrnostrerrorerrno


Libraries 6–43#include double pow( double x, double y );x=0y


6–44Chapter 6–0**CharacterPrinted asd, i int, signed decimalo int, unsigned octalx, X int, unsigned hexadecimal in lowercase or uppercaserespectivelyu int, unsigned decimalcint, single character (converted to unsigned char)s, S char * or _packed char * respectively, the characters from thestring or packed string respectively are printed until a NULLcharacter is found. When the given precision is met before,printing will also stopf doublee, E double; [–]m.dddddde±xx or [–]m.ddddddE±xx, where thenumber of d’s is specified by the precision.


Libraries 6–45CharacterPrinted asg, G double; uses %e or %E if the exponent is less than –4 orgreater than or equal to the precision; otherwise uses %f.n int *, the number of characters written so far is written into theargument. This should be a pointer to an integer in defaultmemory. No value is printed.ppointer (hexadecimal 32–bit value)% No argument is converted, a ’%’ is printed.floatfloatlong _fractlong _fract#include _fract fvalue = 0.987654321;long _fract lfvalue = (float)1.0/3;void main(void){printf(”fvalue is: %8.6f\n”, (float) fvalue);printf(”lfvalue is: %8.6f\n”, (float) lfvalue);printf(”lfvalue in hex is: %12lx\n”, _lfract2long(lfvalue));}#include int putc( int c, FILE *stream );stream• • • • • • • •


6–46Chapter 6#include int putchar( int c );#include int puts( const char *s );#include _reentrant void qsort(const void *base, size_t n, size_t size,int (* cmp)(const void *, const void *) );nbasesizecmp


Libraries 6–47#include int raise( int sig );sig#include int rand( void );#include void *realloc( void *p,size_t size );p*p• • • • • • • •


6–48Chapter 6#include int remove( const char *filename );#include int rename( const char *oldname,const char *newname );#include void rewind( FILE *stream );stream


Libraries 6–49#include int scanf( const char *format, ...);dinouxshortintlongefgdoublefloatlong double• • • • • • • •


6–50Chapter 6CharacterdiouxcScanned asint, signed decimal.int, the integer may be given octal (i.e. a leading 0 is entered)or hexadecimal (leading ”0x” or ”0X”), or just decimal.int, unsigned octal.int, unsigned decimal.int, unsigned hexadecimal in lowercase or uppercase.single character (converted to unsigned char).s, S char * or _packed char * respectively, a string of non whitespace characters. The argument should point to an array ofcharacters or packed characters respectively, large enough tohold the string and a terminating NULL character.f floate, E float; [–]m.dddddde±xx or [–]m.ddddddE±xx, where thenumber of d’s is specified by the precision.g, G float; uses %e or %E if the exponent is less than –4 or greaterthan or equal to the precision; otherwise uses %f.n int *, the number of characters written so far is written into theargument. No scanning is done.p pointer; hexadecimal 32–bit value which must be enteredwithout 0x– prefix.[...] Matches a string of input characters from the set between thebrackets. A NULL character is added to terminate the string.Specifying []...] includes the ’]’ character in the set of scanningcharacters.[^...] Matches a string of input characters not in the set between thebrackets. A NULL character is added to terminate the string.Specifying [^]...] includes the ’]’ character in the set.% Literal ’%’, no assignment is done.


Libraries 6–51#include voidsetbuf( FILE *stream, char *buf );streambuf#include int setjmp( jmp_buf env );env• • • • • • • •


6–52Chapter 6#include char *setlocale( int category,const char *locale );categorylocalecategory#include intsetvbuf( FILE *stream, char *buf,int mode, size_t size );streammodebufsize


Libraries 6–53#include void (*signal( int sig,void (*handler)(int)))(int);handlerhandlerhandler abort sig(*handler)(sig)handler#include double sin( double x );x#include double sinh( double x );x• • • • • • • •


6–54Chapter 6#include int sprintf( char *s,const char *format, ... );#include double sqrt( double x );x√xx ≥ 0#include void srand( unsigned int seed );seed#include int sscanf( char *s,const char *format, ... );


Libraries 6–55#include char *strcat( char *s, const char *ct );ss#include char *strchr( const char *cs, int c );ccs#include int strcmp( const char *cs,const char *ct );csctcs < ct,cs == ctcs > ct#include int strcoll( const char *cs,const char *ct );csctcs < ct,cs = = ctcs > ct• • • • • • • •


6–56Chapter 6#include char *strcpy( char *s,const char *ct );ctss#include size_t strcspn( const char *cs,const char *ct );csct#include char *strerror( size_t n );n


Libraries 6–57#include size_tstrftime( char *s, size_t smax,const char *fmt,const struct tm *tp );*tpsfmtfmtprintfssmaxssmax• • • • • • • •


6–58Chapter 6#include size_t strlen( const char *cs );cs#include char *strncat( char *s,const char *ct, size_t n );ctsns#include int strncmp( const char *cs,const char *ct, size_t n );ncsctcs < ct,cs == ctcs > ct#include char *strncpy( char *s,const char *ct, size_t n );ctsnns


Libraries 6–59#include char *strpbrk( const char *cs,const char *ct );csct#include char *strrchr( const char *cs,int c );ccs#include size_t strspn( const char *cs,const char *ct );csct#include char *strstr( const char *cs,const char *ct );ctcs• • • • • • • •


6–60Chapter 6#include double strtod( const char *s,char **endp );sendp*endp#include char *strtok( char *s,const char *ct );scts#include long strtol( const char *s,char **endp, int base );sbasebasebaseendp*endp


Libraries 6–61#include unsigned long strtoul(const char *s, char **endp, int base );sbasebasebaseendp*endp#include size_tstrncmp( char *ct, const char *cs, size_t n );csctnct#include int system( const char *s );sss• • • • • • • •


6–62Chapter 6#include double tan( double x);x#include double tanh( double x);x#include time_t time( time_t *tp );*tptp#include FILE *tmpfile( void );wb+


Libraries 6–63#include char *tmpnam( char s[L_tmpnam] );tmpnamtmpnam(NULL)tmpnam(s)ssL_tmpnam#include int toascii( int c );c#include int tolower( int c );cc#include int toupper( int c );• • • • • • • •


6–64Chapter 6#include int ungetc( int c, FILE *fin );#include va_arg( va_list ap, type );type#include va_end( va_list ap );#include va_start( va_list ap, lastarg );apva_listlastarg


Libraries 6–65#include int vfprintf( FILE *stream,const char *format, va_list arg );#include int vprintf( const char *format,va_list arg );#include int vsprintf( char *s,const char *format, va_list arg );• • • • • • • •


6–66Chapter 6#include size_t wcstombs( char *s,const wchar_t *pwcs, size_t n );pwcssnsize_t)#include int wctomb( char *s, wchar_t wchar );wcharsswcharwchar


Libraries 6–67printf()fprintf()vfprintf()vsprintf()_doprint()_doprint()scanf_doscan()_doscan()_doprint()lib/563xx/libc16_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()lib/563xx/libc16_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()lib/563xx/libc24_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()• • • • • • • •


6–68Chapter 6lib/566xx/libc6_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()lib/5600x/libcm_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()lib/5600x/libcr_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()lib/5600x/libcs_doprnts.obj _doprint()_doprntm.obj _doprint()_doscans.obj _doscan()cc563 –M24 hello.obj c:\c563\lib\563xx\libc24\_doprntm.objexit


Libraries 6–69.rttext.petext.zerotext.fptext• • • • • • • •


6–70Chapter 6


RUN–TIMEENVIRONMENT


7–2Chapter 7


Run–time Environment 7–3cstart.inccstart.incsrclibstart.asmmystart.asmcstart.inccstart.inc.asmcc56 –c mystart.asm –DNODSTACKcc563 –c mystart.asm• • • • • • • •


7–4Chapter 7startcstart.incabort().dscetcstackstackheapheap5600x: BCR563xx: SR OMR BCR AAR0 AAR1 AAR2 AAR3 DCR566xx: SR OMR BCRcstart.inc


Run–time Environment 7–5tableFmainmain()F_exitexit()cstart.incMacroNODSTACKNOESTACKNOCACHENOCOPYNOARGVPLLVALUE=valBCRVALUE=valLOW_DYNAMICNARROW_BUSUSP=R6DescriptionDo NOT initialize the dynamic stack pointer(only in static model for the DSP5600x).Do NOT initialize stack extension hardware(DSP563xx only).Do NOT enable cache (DSP563xx only).Do NOT produce code to clear BSS sections andinitialize DATA sections.Do NOT produce code to provide a dummy argumentvector to function main().Set clock phase locked loop register to val. If notdefined, the PLL is not initialized.Set external memory waitstates to val. If not defined,zero wait states is selected for all memory(not on DSP563xx).Select 16–bit arithmetic mode (DSP563xx only).Select 16–bit address bus mode (DSP563xx only).Select register R6 for user stack pointer.cstart.inc• • • • • • • •


7–6Chapter 7cstart.incstartstart.asmF_STARTnull_xnull_y_at()


Run–time Environment 7–7extern int f(int,...);extern int g(int,int,...);extern int h(int,int,int,...);int a0;int a1;int a2;void foo(void){f(a0, ”a0 on stack as is this string”);g(a0, a1, ”a0 via accumulator – remainder on stack”);h(a0, a1, a2, ”a0 via A, a1 via B – remainder on stack”);}_asmfunc• • • • • • • •


7–8Chapter 7Return type Register Descriptionchar A accumulatorshort/int A accumulatorlong A accumulator_fract A accumulatorlong _fract A accumulatorfloat AB floating point stack (see section 7.8 forfloating point information)pointer R0 scratch address registersspointer R0 address registerscircular pointer R0/M0 address registers_compatible


Run–time Environment 7–9_compatibleFamilyMemberParameterRegistersRegisters to bepreserved by calleeReturn RegisterDSP5600xNone (all on stack)When returning astruct/union, Apoints to the addressto store it.B1, B0, X1, X0, Y1,Y0, R0..R5, R7(R7 is replaced byR6 if R7 is used foruser stack pointer)A, except whenreturning astruct/union; inthat case A pointsto the addresswhere it is storedDSP563xxDSP566xxA,B (rest on stack)When returning astruct/union, R7points to the addressto store it.Y1, Y0, R2/N2,R3/N3, R7/N7(R7/N7 are replacedby R6/N6 if R7 isused for user stackpointer)A, except whenreturning astruct/union; inthat case R7points to theaddress where it isstored_callee_save_callee_save#ifndef _CALLEE_SAVE#define _who_saves#else#define _who_saves _callee_save#endifint i;_who_saves void __inc(void){i++;}• • • • • • • •


7–10Chapter 7F__inc: movemovemovertsx:Fi,r3(r3)+r3,x:FiF__inc: movemovemovemovemovemoverts(r7)+r3,x:(r7)x:Fi,r3(r3)+r3,x:Fix:(r7)–,r3Section Name Possible Attributes Comment.p[n][i|e]text near, internal, external code.fptextcode from the floating point library.l[n][i|e]const near, internal, external constant initialized L data, notcopied from copy table.p[n][i|e]const near, internal, external constant initialized P data, notcopied from copy table.x[n][i|e]const near, internal, external constant initialized X data, notcopied from copy table.y[n][i|e]const near, internal, external constant initialized Y data, notcopied from copy table.lovloverlayed area in L memory fornon–reentrant (static) functions.povloverlayed area in P memory fornon–reentrant (static) functions


Run–time Environment 7–11Section NamePossible AttributesComment.xovloverlayed area in X memory fornon–reentrant (static) functions.yovloverlayed area in Y memory fornon–reentrant (static) functions.l[n][i|e]data near, internal, external initialized L data, copied from copytable in P.p[n][i|e]data near, internal, external initialized P data, copied from copytable in P.x[n][i|e]data near, internal, external initialized X data, copied from copytable in P.y[n][i|e]data near, internal, external initialized Y data, copied from copytable in P.l[n][i|e]bss near, internal, external cleared L data.p[n][i|e]bss near, internal, external cleared P data.x[n][i|e]bss near, internal, external cleared X data.y[n][i|e]bss near, internal, external cleared Y data• • • • • • • •


7–12Chapter 7lib/src/cstart.incdelay()lib/src/clock.c


Run–time Environment 7–13 • • • • • • • •


7–14Chapter 7_fract


Run–time Environment 7–15_reentrant• • • • • • • •


7–16Chapter 7system stackSSHSSLhigh memoryloop addressloopregister (LA)counter (LC)sp($sp)system stackgrows upprogramcounter (PC)statusregister (SR)fp($fp)low memoryuser stack(reentrant functions)high memorytemporarystorageuspstack pointeradjustlocal n...local 1saved registersstacksizeuser stackgrows uplow memoryreturn addressparameter 1...parameter nufpframesize.dscetcstackstack


Run–time Environment 7–17length=sizeF_lc_bsF_lc_esF_lc_bsF_lc_esUSPUSPUSPUFPUSPUFPUSPUFPUSPF_lc_ub_se• • • • • • • •


7–18Chapter 7Project | Project Options...Linker/LocatorControl FileStack extension sizeF_lc_ub_sereserved label=se length=SESIZE;Project | Project Options...C <strong>Compiler</strong>Code GenerationUse hardware stack extensionProject | Project Options...C <strong>Compiler</strong>Code GenerationUse hardware stack extensionMax. hardware stack use outside interrupt functions


Run–time Environment 7–19malloc()calloc()free()realloc()heapheaplength=sizemalloc()F_lc_bhF_lc_ehsbrk()malloc()• • • • • • • •


7–20Chapter 7 floatdoublelong doubledoublelong doublefloat floatfFfloatlLfloatdoublelong doublefloat_fractfloat. _fractlong _fractlong _fractlong _fract


Run–time Environment 7–21_fract. Bit number Binary encoding Bit Weight (2 n ) Bit number Binary encoding Bit Weight (2 n ) • • • • • • • •


7–22Chapter 7Largest positive mantissa24–bit data models16–bit data modelsSmallest positive mantissa24–bit data models16–bit data modelsFloating point zero 24–bit data models16–bit data modelsSmallest negative mantissa24–bit data models16–bit data modelsLargest negative mantissa24–bit data models16–bit data modelsReserved mantissas24–bit data models16–bit data models$7FFFFF$7FFF$400000$4000$000000$0000$BFFFFF$BFFF$800000$8000+0.99999988079071044921875+0.99996948242875+0.5+0.50.00.0–0.50000011920928955078125–0.500030517578125–1.0–1.0$000001 through $3FFFFF$C00000 through $FFFFFF$0001 through $3FFF$C000 through $FFFFAssumed fixed point exponent24–bit data models16–bit data modelsSmallest exponent24–bit data models16–bit data modelsLargest exponent24–bit data models16–bit data modelsReserved exponents24–bit data models16–bit data models$00007F$007F$000000$0000$0000FF$00FF2 +0 = +1.02 –1272 +128$000100 through $FFFFFF$0100 through $FFFF


Run–time Environment 7–23 Floating point number Mantissa Exponent Decimal ValueLargest positive24–bit data model16–bit data modelSmallest positive24–bit data model16–bit data modelFloating point zero24–bit data model16–bit data modelSmallest negative24–bit data model16–bit data modelLargest negative24–bit data model16–bit data model$7FFFFF$7FFF$400000$4000$000000$0000$BFFFFF$BFFF$800000$8000$0000FF$00FF$000000$0000$000000$0000$000000$0000$0000FF$00FF+3.402823E+38+3.403E+38+2.938736E–39+2.939E–39+0.0+0.0–2.938736E–39–2.939E–39–3.402823E+38–3.403E+38• • • • • • • •


7–24Chapter 7 CharacteristicMantissa Precision24–bit models16–bit models2–ComplementFormat23 bits15 bitsIEEE Format24 bitsHidden Leading One No YesMantissa Format24–bit models16–bit models24–bit Two’sComplement Fraction16–bit Two’sComplement Fraction23 bit Unsigned MagnitudeFractionExponent Width 8 bits 8 bits (single)Maximum Exponent +128 +127 (single)Minimum Exponent –127 –127 (single)Exponent Bias +127 +127 (single)Format Width24–bit models16–bit models48 bits32 bits32 bits (single)Rounding Round to Nearest Round to Nearest (default)Round to +/–InfiniteRound to ZeroInfinity Arithmetic Saturation Limiting Affine OperationsDenormalized Numbers No (Forced to Zero) Yes (With MinimumExponent)ExceptionsDivide by ZeroOverflowUnderflowDivide by ZeroOverflowUnderflowInvalid OperationsInexact Arithmetic


Run–time Environment 7–25• • • • • • • •


7–26Chapter 7


Run–time Environment 7–27Operation Function Input operand(s) ResultAdd addf2 fac, ftm1 facSubtract subf2 fac, ftm1 facMultiply mulf2 fac, ftm1 facDivide divf2 fac, ftm1 facMultiply–Accumulate + macpf2 fac, ftm1, ftm2 facMultiply–Accumulate – macnf2 fac, ftm1, ftm2 facCompare cmpf2 fac, ftm1 CCRNegate negf2 fac fac• • • • • • • •


7–28Chapter 7Operation Function Input operand(s) ResultSigned Integer to Float cif12 A facSigned Long to Float cif22 A facUnsigned Integer to Float cuf12 A facUnsigned Long to Float cuf22 A facFract to Float crf12 A facLong Fract to Float crf22 A facFloat to Signed Integer cfi21 fac AFloat to Signed Long cfi22 fac AFloat to Unsigned Integer cfu21 fac AFloat to Unsigned Long cfu22 fac AFloat to Fract cfr21 fac AFloat to Long Fract cfr22 fac A


Run–time Environment 7–29FACMantissaA2 – sign extension of A1(unused)A1 – mantissaA0 – zeroFTM1 X1 X0FTM2 Y1 Y0ExponentB2 – sign extension of B1(unused)B1 – exponentB0 – zero Address Binary encoding Address Binary encoding • • • • • • • •


7–30Chapter 7Functionaddf2subf2mulf2divf2macpf2macnf2cmpf2negf2Modified register(s)A, B, X, R0, N0A, B, X, Y, R0, N0A, B, X0, R0, N0 (DSP563xx)A, B, X0, R0 (other)A, B, X, R0, N0 (DSP563xx)A, B, X, R0 (other)A, B, X, Y, R0, N0 (DSP563xx)A, B, X, Y, R0 (other)A, B, X, Y, R0, N0 (DSP563xx)A, B, X, Y, R0 (other)noneA, B, R0, N0 (DSP563xx)A, B, R0 (other)Functioncif12cif22cuf12cuf22crf12crf22cfi21cfi22cfu21cfu22Modified register(s)A, B, R0, N0 (DSP563xx)A, B, R0 (other)A, B, R0, N0 (DSP563xx)A, B, R0 (other)A, B, X, R0, N0 (DSP563xx)A, B, X, R0 (other)A, B, X, R0, N0 (DSP563xx)A, B, X, R0 (other)A, B, R0, N0 (DSP563xx)A, B, R0 (other)A, B, R0, N0 (DSP563xx)A, B, R0 (other)A, B, Y1 (DSP563xx)A, B, Y, R0, N0 (other)A, B, Y1 (DSP563xx)A, B, Y, R0, N0 (other)A, B, Y, R0, N0A, B, Y1


Run–time Environment 7–31Functioncfr21cfr22Modified register(s)A, B, Y, R0, N0A, B, Y, R0, N0c = a + b;move x:Fa,bmove x:Fa+1,amove x:Fb,x0move x:Fb+1,x1jsr Rfpaddf2move a,x:Fc+1move b,x:Fc; pass floating point a in fac; pass floating point b in ftm1; perform add; store result from fac in cfloat a;long b;a = b;move x:Fb+1,amove x:Fb,a0jsr Rfpcif22move a,x:Fa+1move b,x:Fa; pass long b in A; convert from long to float; store result from fac in a• • • • • • • •


7–32Chapter 7d = a + b – c;move x:Fa,b ; pass floating point a in facmove x:Fa+1,amove x:Fb,x0 ; pass floating point b in ftm1move x:Fb+1,x1jsr Rfpaddf2 ; perform add; The intermediate floating point; result stays in fac !move x:Fc,x0 ; pass floating point c in ftm 1move x:Fc+1,x1jsr Rfpsubf2 ; perform subtractmove a,x:Fd+1 ; store result from fac in dmove b,x:Fd


Run–time Environment 7–33e = (a + b) – (c * d)move (r7)+move (r7)+move x:Fa,bmove x:Fa+1,amove x:Fb,x0move x:Fb+1,x1jsr Rfpaddf2move #–2,n7move (r7)+move a,x:(r7+n7)move (r7)–move b,x:(r7+n7)move x:Fc,bmove x:Fc+1,amove x:Fd,x0move x:Fd+1,x1jsr Rfpmulf2move b,x0move a,x1move (r7)+move x:(r7+n7),amove (r7)–move x:(r7+n7),bjsr Rfpsubf2move a,x:Fe+1move b,x:Femove (r7)+n7; reserve user stack space; pass floating point a in fac; pass floating point b in ftm1; perform add; user stack offset; first stack element; push result mantissa from; fac on stack; second stack element; push result exponent from; fac on stack; pass floating point c in fac; pass floating point d in ftm1; perform multiply; store result from fac in ftm1; first stack element; pop mantissa result from; stack to fac; second stack element; pop exponent result from; stack to fac; perform subtract; store result from fac in e; free reserved user stack space• • • • • • • •


7–34Chapter 7


SUPPORT FORUSER–DESIGNEDTARGET BOARDS


8–2Chapter 8


Support for User–designed Target Boards 8–3 mytarget.asmlib\src\def_targ.asm mytarget.asm mytarget.asmbin\as563 lib\src\mytarget.asm –O>NULbin\ar563 –r lib\563xx\libc24.a mytarget.obj >NULbin\as563 lib\src\mytarget.asm –M16 –O>NULbin\ar563 –r lib\563xx\libc16.a mytarget.obj >NULbin\ar563 –r lib\563xx\libc1624.a mytarget.obj >NULdel mytarget.obj etc*.mem*.dscmytarget.asmmytarget.dscmytarget.memmytarget.dsc*.dsc.memmytarget.mem.cpu• • • • • • • •


8–4Chapter 8mytarget.mem.mem Project | Project Options...Linker/LocatorControl FileUsersupplied, no library startup codeTargetUser defined target namemytargetmytarget.asmmytarget.dsc Project | Project Options...Linker/LocatorControl FileUsersupplied target definitionTargetmytarget.dscUse project specificlinker/locator control file (.dsc)


FLEXIBLE LICENSEMANAGER (FLEXlm)


A–2Appendix A


Flexible License Manager (FLEXlm) A–3 • • • • • • • • • •


A–4Appendix A • • • •


Flexible License Manager (FLEXlm) A–5 <strong>Tasking</strong>license.dat/usr/local/flexlmbinlicensesc:\flexlmbinbinlmgrdlm*license.datc:\flexlm/usr/local/flexlm/licenseslicenseslicense.datlicense.datlicenseslicense.datlicense.datSERVER HOSTNAME HOSTID PORTDAEMON <strong>Tasking</strong> /usr/local/flexlm/bin/<strong>Tasking</strong>FEATURE SW008002–32 <strong>Tasking</strong> 3.000 EXPDATE NUSERS PASSWORD SERIAL• • • • • • • •


A–6Appendix ASERVER elliot 5100520c 7594DAEMON <strong>Tasking</strong> /usr/local/flexlm/bin/<strong>Tasking</strong>FEATURE SW008002–32 <strong>Tasking</strong> 3.000 1–jan–00 4 0B1810310210A6894 ”123456”license.datc:\flexlm\license.dat/usr/local/flexlm/licenses/license.datset LM_LICENSE_FILE=setenv LM_LICENSE_FILE


Flexible License Manager (FLEXlm) A–7lmrereadlicense.datlmgrd >/usr/tmp/license.log &binKeywordsRESERVEINCLUDEEXCLUDEGROUPTIMEOUTNOLOGFunctionEnsure that TASKING software will always be available toone or more users or on one or more host computer systems.Specify a list of users who are allowed exclusive access tothe TASKING software.Specify a list of users who are not allowed to use theTASKING software.Specify a group of users for use in the other commands.Allow licenses that are idle for a specified time to be returnedto the free pool, for use by someone else.Causes messages of the specified type to be filtered out ofthe daemon’s log output.DAEMON/usr/local/flexlm/<strong>Tasking</strong>.optDAEMONDAEMON <strong>Tasking</strong> /usr/local/<strong>Tasking</strong> /usr/local/flexlm/<strong>Tasking</strong>.opt• • • • • • • •


A–8Appendix ARESERVEINCLUDEEXCLUDEGROUPTIMEOUTNOLOGREPORTLOGnumber feature {USER | HOST | DISPLAY | GROUP} namefeature {USER | HOST | DISPLAY | GROUP} namefeature {USER | HOST | DISPLAY | GROUP} namename feature timeout_in_seconds{IN | OUT | DENIED | QUEUED}file#SWxxxxxx–xxQUEUEDSWxxxxxx–xxGROUPRESERVE 1RESERVE 3RESERVE 1EXCLUDEEXCLUDENOLOGpinheads moe larry curleySWxxxxxx–xx USER patSWxxxxxx–xx USER leeSWxxxxxx–xx HOST terrySWxxxxxx–xx USER joeSWxxxxxx–xx GROUP pinheadsQUEUED


Flexible License Manager (FLEXlm) A–9• • • • • • • •


A–10Appendix ANameSynopsisDescription• SERVER• DAEMON• FEATURE• FEATURESETOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.datFEATUREFEATURESET


Flexible License Manager (FLEXlm) A–11NameSynopsisDescriptionParametersOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.dat• • • • • • • •


A–12Appendix ANameSynopsisDescriptionOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.dat


Flexible License Manager (FLEXlm) A–13NameSynopsisDescriptionOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.dat• • • • • • • •


A–14Appendix A


Flexible License Manager (FLEXlm) A–15NamehostidSynopsisDescriptiongethostidlmhostid – Copyright (C) 1989, 1999 Globetrotter Software, Inc.The FLEXlm host ID of this machine is ”1200abcd”Options• • • • • • • •


A–16Appendix ANameSynopsisDescription–c fileOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.dat


Flexible License Manager (FLEXlm) A–17• • • • • • • •NameSynopsisDescriptionSERVEROptionsLM_LICENSE_FILElicense.dat


A–18Appendix ANameSynopsisDescription• • • DAEMONOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.dat


Flexible License Manager (FLEXlm) A–19• • • • • • • •


A–20Appendix ANameSynopsisDescriptionParametersOptionsLM_LICENSE_FILEc:\flexlm\license.dat/usr/local/flexlm/licenses/license.dat


Flexible License Manager (FLEXlm) A–21 NameSynopsisDescriptionParameters• • • • • • • •


A–22Appendix A Start | Programs| TASKING FLEXlm | FLEXlm ToolsHOSTIDTIMETCPSettings


Flexible License Manager (FLEXlm) A–23 Start |Programs | TASKING FLEXlm | FLEXlm ToolsControlSetup• • • • • • • •


A–24Appendix AControlStartUse NTServicesStart Server at Power–UPLicensesAdvanced


Flexible License Manager (FLEXlm) A–25 (DAEMON) DAEMONDAEMON_• • • • • • • • • • •


A–26Appendix ANNN


Flexible License Manager (FLEXlm) A–27N• • • • • • • •


A–28Appendix A


Flexible License Manager (FLEXlm) A–29DAEMON/etc/services• • • • • • • •


A–30Appendix ASERVER/etc/hostsDAEMONDAEMON


Flexible License Manager (FLEXlm) A–31acceptPIDpipemallocPIDDAEMONDAEMONDAEMON• • • • • • • •


A–32Appendix AreadlistheadDAEMON


Flexible License Manager (FLEXlm) A–33 FLEXlm license error, encryption code in license file isinconsistentLM_LICENSE_FILEFEATURE SWiiiiii–jj• • • • • • • •


A–34Appendix ALM_LICENSE_FILEFLEXlm license error, no such feature exists lmreread –c /usr/local/flexlm/licenses/license.datLM_LICENSE_FILE


Flexible License Manager (FLEXlm) A–35 LM_LICENSE_FILE LM_LICENSE_FILELM_LICENSE_FILEps wwax | grep lmgrd | grep –v grepps –ef | grep lmgrd | grep –v grep• • • • • • • •


A–36Appendix A/usr/local/flexlm/licenses/license.datLM_LICENSE_FILElmgrd –c /usr/local/flexlm/licenses/license.dat \–l /usr/local/flexlm/licenses/license.log &LM_LICENSE_FILElicense.datLM_LICENSE_FILELM_LICENSE_FILEkill PIDPID


Flexible License Manager (FLEXlm) A–37 • • • • • • • •


A–38Appendix A


Flexible License Manager (FLEXlm) A–39License Description PricingNode Locked This license can only be used on aspecific system. It cannot bemoved to another system.The pricing for thislicense will be thecurrent product pricing.FloatingThis license requires a network(license server and a TCP/IP (orIPX/SPX) connection betweenclients and server) and can be usedon any host system (using thesame operating system) in thenetwork.The pricing for thislicense will be 50%higher than the nodelocked license.• • • • • • • • •


A–40Appendix A• • •


Flexible License Manager (FLEXlm) A–41• • • • • • • •


A–42Appendix Asu username –c”/path/lmgrd –c /path/license.dat \–l /path/log”license.datsu username –c”umask 022; /path/lmgrd \–c /path/license.dat –l /path/log”


Flexible License Manager (FLEXlm) A–43 /etc/hosts• • • • • • • •


A–44Appendix A• •


MOTOROLACOMPATABILITY


B–2Appendix B


Motorola Compatibility B–3 describes the interoperability between the TASKING andMotorola tool sets. That means, how to create an application with the TASKING<strong>DSP56xxx</strong> C compiler, which can be debugged with the Motorola debugger; orhow to link Motorola object files and library files with the TASKING linker. | \V (.c) ||c563 ||| |– cc563 (control program)V (.src) ||as563 ||| |V (.asm) /• • • • • • • •


B–4Appendix B.srcTool Optioncc563 –Sc563 –Cgas563 –S .asmcc563 –g –Wc–Cg –Wa–S –c –o file.asm file.c


Motorola Compatibility B–5_packeddemo.ccc563 –S –g demo.cg563c demo.asm –g –o demo.cld –mx–memoryc563 –g –C1 demo.cas563 –S demo.srcasm56300 –c –Bdemo.cln demo.asmdsplnk –g –c –Bdemo.cld crt0563x.cln demo.cln –Llib563cx.clbcc563 –S –g –My demo.cg563c demo.asm –g –o demo.cldc563 –C1 –g –My demo.cas563 –S demo.srcasm56300 –c –Bdemo.cln demo.asmdsplnk –g –c –Bdemo.cld crt0563y.cln demo.cln –Llib563cy.clb• • • • • • • •


B–6Appendix B _packed librt24.clblibfp24.clblibc24.clblibrt6.clblibfp6.clblibc6.clblibrt.clblibfp.clblibcm.clblibcs.clblibcr.clb


Motorola Compatibility B–7malloc()F_lc_bhF_lc_ehF_lc_bhF_lc_ehreservesymbol F_lc_bhsymbol F_lc_ehy:$3000..$3fffy:$3000y:$4000$3000$4000malloc() .cln.clbutil.clnprog.cutil.clncc563 –g prog.c util.cln lib563x.clb• • • • • • • •


B–8Appendix B crt0563x.cln Project | Directories |Executable Files Path Project | Select Toolchain...Project |Project Options... Project |Directories | Library Files Path Project | Project Options |Motorola DebuggerOK


Motorola Compatibility B–9 Rebuild Debug stdoutstreams enableredirect stdout file.txtgo file.txtreservesymbol F_lc_bhsymbol F_lc_ehx$2000..$3fffx:$2000x:$3000bench• • • • • • • •


B–10Appendix B


INDEX


Index–2Index


IndexIndex–3• • • • • • • •


IndexIndex–4


IndexIndex–5• • • • • • • •


IndexIndex–6


IndexIndex–7• • • • • • • •


IndexIndex–8


IndexIndex–9• • • • • • • •


IndexIndex–10


IndexIndex–11• • • • • • • •


IndexIndex–12


IndexIndex–13• • • • • • • •


IndexIndex–14


IndexIndex–15• • • • • • • •


IndexIndex–16


IndexIndex–17• • • • • • • •


Index–18Index

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!