Home
ZiLOG Developer Studio II--ZNEO User Manual
Contents
1. Synopsis tinclude lt zneo h gt intrinsic void SET VECTOR int vectnum void hndlr void where vectnumis the interrupt vector number for which the interrupt handler hndir is to be set hndlris the interrupt handler function pointer The nndlr function must be declared to be of the interrupt type with parameters and return as void no parameters and no return UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 141 zZiLOG The compiler supports the following values for vectnum for ZNEO ADC P7AD CO PWM_FAULT Cl PWM_TIMER C2 RESET C3 SPI nc SYSEXC POAD TIMERO PIAD TIMERI P2AD TIMER2 P3AD UARTO RX P4AD UARTO_TX PSAD UARTI RX P6AD UARTI TX Returns None Example include lt zneo h gt extern void interrupt isr timer0 void void main void SET VECTOR TIMERO isr timer0 setup TIMERO vector TDI TDI test and disable interrupts is a ZiLOG intrinsic function that supports users creating their own critical sections of code It returns the previous interrupt status and disables interrupts It is intended to be paired with a later call to RI which will restore the previ ously existing interrupt status See RI on page 139 for a discussion of that function The interrupt status which is returned from TDI consists of the flags register extended to 16 bits for efficient stack st
2. nwl DL 1 fw1 DL 2 SEGMENT CODI nw2 DS 4 fw2 DS 4 The ZNEO instruction set provides different encodings for many instructions depending on whether an address or immediate data can be represented as an 8 16 or 32 bit value In most cases the ZNEO assembler selects the encoding that results in the smallest repre sentation of the instruction In doing so the assembler makes use of the address space information for labels occurring in instructions Labels in a 32 bit address space EROM or ERAM are encoded as 32 bit values while labels in 16 bit address spaces ROM RAM or IODATA are encoded as 16 bit values An otherwise undeclared label is assumed to be in a 16 bit address space If you want to override the assembler s encoding you can indicate the address space for a label or for an absolute address with a colon followed by the name of an address space For example LD LD RO myLabel RO myLabel EROM if myLabel undeclared gets 16 bit encoding forces 32 bit encoding In particular absolute addresses in the range 8000H FFFFH are considered as 32 bit unsigned values If an address in internal RAM or the IO space is intended you can obtain the desired result in either of the following ways OR OR COO1H IODATA RO FFFF C0001 R0 SEGM ENT NEAR DATA An address SEGM ENT FAR DATA ADD ADD SUB SUB An address Specify the requir
3. This warning is generated because the line of code is processed by the real printf or sprintf function so that the primary goal of the inline processing reducing the code size by removing these functions is not met When this message is displayed you have three options Deselect the Generate Printfs Inline check box see Generate Printfs Inline on page 64 so that all calls to printf and sprintf are handled by the real printf or sprintf functions Recode to pass a string literal For example the code in the example can be revised as follows define MSG1 x 4d char buff sizeof MSG1 4 sprintf buff MSG1 x OK UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Keep the Generate Printfs Inline check box selected and ignore the warning This loses the primary goal of the option but results in the faster execution of the calls to printf or sprintf that can be processed at compile time a secondary goal of the option 252 Bad format string passed to s printf This warning occurs when the compiler is unable to parse the string literal format and the inline generation of printf calls is requested A normal call to printf or sprintf is generated which might also be unable to parse the format 253 Too few parameters for s printf format This error is generated when there are fewer parameters to a call to printf or sprintf than the format stri
4. User Manual zZiLOG Recent Files Select Recent Files from the File menu and then select a file from the resulting submenu to open a recently opened file Recent Projects Select Recent Projects from the File menu and then select a project file from the resulting submenu to quickly open a recently opened project Exit Select Exit from the File menu to exit the application Edit Menu The Edit menu provides access to basic editing text search and breakpoint and bookmark manipulation features The following options are available e Undo on page 45 Redo on page 45 e Cut on page 45 e Copy on page 45 Paste on page 45 e Delete on page 45 e Select All on page 45 e Show Whitespaces on page 45 e Find on page 45 Find Again on page 46 e Find in Files on page 46 e Replace on page 47 e Go to Line on page 48 e Manage Breakpoints on page 49 Toggle Bookmark on page 50 e Next Bookmark on page 50 Previous Bookmark on page 50 e Remove All Bookmarks on page 50 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual ziLoc Undo Select Undo from the Edit menu to undo the last edit made to the active file Redo Select Redo from the Edit menu to redo the last edit made to the active file Cut Select Cut from the Edit menu to delete selected text from the acti
5. void main void Unlike the hosted environment in which the closest allowed form for main is as follows int main void Double Treated as Float The ZNEO C Compiler does not support a double precision floating point type The type double is accepted but is treated as if it were float Library Files Not Required for Freestanding Implementation As noted in Freestanding Implementation on page 150 only four of the standard library header files are required by the standard to be supported in a freestanding compiler such as the ZNEO C Compiler However the compiler does support many of the other standard library headers as well The supported headers are listed here The support offered in the ZiLOG libraries is fully compliant with the Standard except as noted here lt assert h gt e lt ctype h gt e lt errno h gt e lt math h gt The ZiLOG implementation of this library is not fully ANSI compliant in the general limitations of the handling of floating point numbers namely ZiLOG does not fully support floating point NANs INFINITYs and related special values These special values are part of the full ANSI IEEE 754 1985 floating point standard that is referenced in the ANSI C Standard 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 152 zZiLOG e lt stddef h gt e lt stdio h gt ZiLOG supports only the portions of stdio h that make sense in the embedded e
6. 721 Help file lt name gt not found The named help file could not be found You may need to reinstall the development system software 723 lt name gt has not been ordered The named group section or address space does not have an order assigned to it 724 Symbol lt name gt lt file gt is not defined The named symbol is referenced in the given file but not defined Only the name of the file containing the first reference is listed within the parentheses it can also be referenced in other files 726 Expression structure could not be stored Out of memory Memory to store an expression structure could not be allocated 727 Group structure could not be stored Out of memory Memory to store a group structure could not be allocated 730 Range structure could not be stored Out of memory Memory to store a range structure could not be allocated 731 File lt file gt is not found The named input file or a library file name or the structure containing a library file name was not found 732 Error encountered opening file lt file gt The named file could not be opened 736 Recursion is present in call graph A loop has been found in the call graph indicating recursion 738 Segment lt segment gt is not defined The referenced segment name has not been defined 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 250 zZiLOG 739 Invalid space lt space g
7. Appendix A Running ZDS II from the Command Line UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 306 zZiLOG UMO17103 0207 Appendix A Running ZDS II from the Command Line ZiLOG Developer Studio ll ZNEO User Manual 307 zZiLOG Appendix B Using the Command Processor The Command Processor allows you to use commands or script files to automate the exe cution of a significant portion of the functionality of the integrated development environ ment IDE This section covers the following topics e Sample Command Script File on page 311 Supported Script File Commands on page 312 e Running the Flash Loader from the Command Processor on page 333 You can run commands in one of the following ways Using the Command Processor toolbar in the IDE to run a single command Commands entered into the Command Processor toolbar are executed after you press the Enter or Return key or click the Run Command button The toolbar is described in Command Processor Toolbar on page 21 Using the batch command to run a command script file from the Command Processor toolbar in the IDE For example batch c path to command file runall cmd batch commands txt Passing a command script file to the IDE when it is started You must precede the script file with an at symbol when passing the path and name of the command script file to the IDE on the command line For example zds2ide c pat
8. Select the Match Case check box if you want the search to be case sensitive Select the Regular Expression check box if you want to use regular expressions Select the direction of the search with the Up or Down button Sa OV cs dm Click Find Next to jump to the next occurrence of the search text or click Mark All to insert a bookmark on each line containing the search text NOTE After clicking Find Next the dialog box closes You can press the F3 key or use the Find Again command to find the next occurrence of the search term without displaying the Find dialog box again Find Again Select Find Again from the Edit menu to continue searching in the active file for text pre viously entered in the Find dialog box Find in Files NOTE This function searches the contents of the files on disk therefore unsaved data in open files is not searched To find text in multiple files use the following procedure 1 Select Find in Files from the Edit menu The Find in Files dialog box is displayed as shown in Figure 42 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Find in Files Find X In file types c h asm s inc Cancel In folder C Program FilesziLOG zDSIl ZNEO 4 10 samples T utorial y x Match whole word only Look in Subfolders Match case Output to pane 2 Figure 42 Find in Files Dialog Box 2 Enter the te
9. UM017103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 101 zZiLOG Customize Toolbars Commands Toolbars Menu bar Iv Show Tooltips New File MV Cool Look Build t Find Large Buttons o Rem Debug Command Processor Bookmarks Debug Windows Cancel Help Figure 75 Customize Dialog Box Toolbars Tab To create a new toolbar use the following procedure 1 Select Customize from the Tools menu The Customize dialog box is displayed 2 Click on the Toolbars tab 3 Click New The New Toolbar dialog box is displayed as shown in Figure 76 New Toolbar Toolbar name OK m oo Cancel Figure 76 New Toolbar Dialog Box 2 Using the Integrated Development Environment UMO17103 0207 102 ZiLOG Developer Studio Il ZNEO User Manual 4 Inthe Toolbar Name field type the name of the new toolbar 5 Click OK The new toolbar is displayed as a gray box You can change the name by selecting the new toolbar in the toolbars list box typing a new name in the Toolbar Name field and pressing the Enter key 6 Click the Commands tab 7 Drag buttons from any category to your new toolbar NOTE To delete the new toolbar select the new toolbar in the Toolbars list box and click Delete 8 Click OK to apply your changes or click Cancel to close the dialog box without making any changes Customize Command
10. 12340 octal number 12340 negative octal number 1 2340 octal number with underscore Character Constants A single printable ASCII character enclosed by single quotes can be used to represent an ASCII value This value can be used as an operand value For example A ASCII code for A 3 ASCII code for 3 Operator Precedence Table 10 shows the operator precedence in descending order with operators of equal precedence on the same line Operators of equal precedence are evaluated left to right Parentheses can be used to alter the order of evaluation Table 10 Operator Precedence Level 1 O Level 2 Y unary low Level 3 e Level 4 t amp d gt gt lt lt Level 5 lt gt lt gt NOTE Shift Left lt lt and OR have the same operator precedence and are evaluated from left to right If you need to alter the order of evaluation add parentheses to ensure the desired operator precedence For example ld r0 d 1 2 1 2 1 lt lt 1 The constant expression in the preceding instruction evaluates to 2A H If you want to perform the Shift Left operations before the OR operation use parentheses as follows ld r0 1 lt lt 2 1 lt lt 2 1 lt lt 1 The modified constant expression evaluates to 6 H UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 179 zZiLOG Address Spaces and Instruction Encoding
11. Tests for any hexadecimal digit 0 to 9 and A to F Synopsis include lt ctype h gt int isxdigit int c Example int r char c f r isxdigit c Computes the absolute value of a long int j Synopsis include lt stdlib h gt long labs long 3 Example long i 193250 long j j labs i UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual L zr ZiLOG Idexp Idexpf Multiplies a floating point number by an integral power of 2 A range error can occur Synopsis tinclude lt math h gt double ldexp double x int exp float ldexpf float x int exp Returns The value of x times 2 raised to the power of exp Example double x 1 235 int exp 2 double y y ldexp x exp Idiv Computes the quotient and remainder of the division of the numerator numer by the denominator denom If the division is inexact the sign of the quotient is that of the mathematical quotient and the magnitude of the quotient is the largest integer less than the magnitude of the mathematical quotient Synopsis include lt stdlib h gt ldiv_t ldiv long numer long denom Example long x 25000 long y 300 ldiv t t long q long r t ldiv x y q t quot r t rem Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 368 log logf Computes the natural logarithm of x A domain error occurs if the
12. map maxhexlen 64 quiet warnoverlap NOxref unresolved fatal sort NAME ascending warn debug NOigcase In this command the linker output file format is selected to be OMF695 which is based on the IEEE 695 object file format and INTEL32 which is the Intel Hex 32 format This setting is generated from options selected in Output page see page 78 The quiet debug and noigcase options are generated from the settings on the General page see page 54 The other options shown here are all generated from the settings selected in the Warnings and Output pages see page 77 and page 78 RANGE ROM 0 7fff RANGE RAM Sffb000 Sffbfff RANGE EROM 8000 S1ffff RANGE ERAM 800000 S81ffff F P F P The ranges for the four address spaces are defined here These ranges are taken from the settings in Address Spaces page see page 74 CHANGE NEAR TEXT NEAR DATA CHANGE FAR TEXT FAR DATA The NEAR TEXT and FAR TEXT segments are renamed to NEAR DATA and FAR DATA segments respectively by the above command This allows the linker to merge them with the material that has already been placed into the NEAR DATA and FAR DATA segments The NEAR TEXT and FAR TEXT segments contain constant strings in RAM and ERAM respectively This reduces the number of initialized segments from four to two and the C startup then only needs to initialize two segments ORDER FAR BSS FAR DATA ORDER NEAR BSS NEAR DATA Th
13. ES 1 include C PROGRA 1 ZiLOG ZDSII_ 1 0 include std C PROGRA 1 ZiLOG ZDSII_ 1 0 include zilog a list NOlistmac name pagelen 56 pagewidth 80 quiet warn debug NOigcase cpu Z16F2811AL FORMAT OMF695 INTEL32 map maxhexlen 64 quiet warnoverlap NOxref unresolved fatal sort NAME ascending warn debug NOigcase RANGE ROM 0000 RANGE RAM SFFBO RANGE IODATA SF RANGE EROM 008 RANGE ERAM 800 00 007FFF 00 SFFBFFF FCOO0 SFFFFFF 000 SOLFFFF 000 S81FFFF T NEAR DATA CHANGE NEAR TEX CHANGE FAR TEXT ORDER FAR BSS ORDER COPY NEAR DATA COPY FAR DATA E z E FAR_DATA FAR DATA EAR BSS NEAR DATA EROM ROM define 0 xit 0 5 Using the Linker Locator UMO17103 0207 234 ZiLOG Developer Studio ll ZNEO Z zZiLOG User Manual define low near romdata copy base of NEAR DATA define low neardata base of NEAR DATA define len neardata length of NEAR DATA define low far romdata copy base of FAR DATA define low fardata base of FAR DATA define len fardata length of FAR DATA define low nearbss base of NEAR BSS define len nearbss length of NEAR BSS
14. FLT DIG FLT MANT DIG FLT MAX FLT MAX EXP FLT MAX 10 EXP FLT MIN FLT MIN EXP FLT MIN 10 EXP FLT RADIX UMO17103 0207 Number of decimal digits of precision Number of base FLT RADIX digits in the floating point mantissa Maximum represented floating point numbers Maximum integer such that FLT_RADIX raised to that power approximates a floating point number in the range of represented numbers Maximum integer such that 10 raised to that power approximates a floating point number in the range of represented value int log10 DBL MA X and so on Minimum represented positive floating point numbers Minimum negative integer such that FLT RADIX raised to that power approximates a positive floating point number in the range of represented numbers Minimum negative integer such that 10 raised to that power approximates a positive floating point number in the range of represented values int log10 DBL MIN and so on Number of decimal digits of precision Number of base FLT RADIX digits in the floating point mantissa Maximum represented floating point numbers Maximum integer such that FLT RADIX raised to that power approximates a floating point number in the range of represented numbers Maximum integer such that 10 raised to that power approximates a floating point number in the range of represented value int log10 FLT MAX and so on Minimum represented positive floating point numbers Minimum neg
15. Figure 39 Save As Dialog Box 2 Use the Save In drop down list box to navigate to the appropriate directory 3 Enter the new file name in the File Name field 4 Use the Save as Type drop down list box to select the file type 5 Click Save A copy of the file is saved with the name you entered Save All Select Save All from the File menu to save all open files and the currently loaded project Print Select Print from the File menu to print the active file UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Print Preview Select Print Preview from the File menu to display the file you want to print in Preview mode in a new window 1 Inthe Edit window highlight the file you want to show a Print Preview 2 From the File menu select Print Preview The file is shown in Print Preview in a new window As shown in Figure 40 main c is in Print Preview mode sample ZDS II ZNEO main c ge Zoom In Zoom Out Figure 40 Print Preview Window 3 To print the file click Print To cancel the print preview click Close The file returns to its edit mode in the Edit window Print Setup Select Print Setup from the File menu to display the Print Setup dialog box which allows you to determine the printer s setup before you print the file 2 Using the Integrated Development Environment UMO17103 0207 44 ZiLOG Developer Studio Il ZNEO
16. Maximum Bytes per Hex File Line Appendix B Using the Command Processor option linker relist option linker exeform option linker padhex option linker maxhexlen UMO17103 0207 309 ZiLOG Developer Studio Il ZNEO User Manual 310 zZiLOG Table 12 Script File Commands Continued ZDS II Menus ZDS II Commands Dialog Box Options Script File Commands Page Settings Debugger page Use Page Erase Before Flashing Target target set page 331 Setup target options page 331 Add target create page 330 Copy target copy page 330 Delete Debug Tool debugtool set page 317 Setup debugtool set page 317 Export Makefile makfile page 321 makefile Build Build build page 314 Rebuild All rebuild page 328 Stop Build stop page 329 Set Active Configuration set config page 329 Manage Configurations set config page 329 delete config page 318 Debug Stop Debugging quit page 328 Reset reset page 328 Go go page 320 Break stop page 329 Step Into stepin page 329 Step Over step page 329 Step Out stepout page 329 Tools Flash Loader page 333 Calculate File Checksum checksum page 315 Show CRC crc page 315 UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual Z 311 ZiLOG SAMPLE COMMAND SCRIPT FILE A script file is a text based file that contains a collection of commands The file can be created with
17. Synopsis include lt string h gt char strncpy char sl const char s2 size t n Returns The value of s1 Example char ptr char s1 40 Production char s2 Languages ptr strncpy s1 s2 4 strpbrk Locates the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2 Synopsis finclude lt string h gt char strpbrk const char sl const char s2 Returns A pointer to the character or a null pointer if no character from s2 occurs in sl UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual Zu zZiLOG Example char ptr char s1 COMPASS char s2 PASS ptr strpbrk s1 s2 strrchr Locates the last occurrence of c converted to a char in the string pointed to by s The terminating null character is considered to be part of the string Synopsis finclude lt string h gt char strrchr const char s int c Returns A pointer to the character or a null pointer if c does not occur in the string Example char ptr char s1 COMPASS ptr strrchr sl p strspn Finds the first substring from a given character set in a string Synopsis finclude lt string h gt size t strspn const char sl const char s2 Returns The length of the segment Example char s1 cabbage char s2 abc size t res res strspn sl s2 Appendix C C Standard Library UMO17103 0207 ZiLOG Develo
18. The assembler provides a set of directives to group data elements together similar to high level programming language constructs like a C structure or a Pascal record These direc tives allow you to declare a structure or union type consisting of various elements assign UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual L 19s zZiLOG labels to be of previously declared structure or union type and provide multiple ways to access elements at an offset from such labels The assembler directives associated with structure and union support are listed in the fol lowing table Assembler Directive Description STRUCT Group data elements in a structure type ENDSTRUCT Denotes end of structure or union type UNION Group data elements in a union type TAG Associate label with a structure or union type WITH A section in which the specified label or structure tag is implicit ENDWITH Denotes end of with section STRUCT and ENDSTRUCT Directives A structure is a collection of various elements grouped together under a single name for convenient handling The STRUCT and ENDSTRUCT directives can be used to define the layout for a structure in assembly by identifying the various elements and their sizes The STRUCT directive assigns symbolic offsets to the elements of a structure It does not allo cate memory It merely creates a symbolic template that can be used rep
19. You do not have to type the extension zdsproj The extension is added automatically NOTE The following characters cannot be used in a project name amp 4 Click Select to return to the New Project dialog box 5 Inthe Project Type field select Standard for a project that uses c files Select Assembly Only for a project that will include only assembly source code 6 In the CPU Family drop down list box select Z16F_Series 7 In the CPU drop down list box select a CPU 8 Inthe Build Type drop down list box select Executable to build an application or select Static Library to build a static library The default is Executable which creates an IEEE 695 executable format 10d For more information see Project Settings Output Page on page 78 9 Click Continue to change the default project settings using the New Project Wizard To accept all default settings click Finish NOTE For static libraries click Finish For Standard projects the New Project Wizard dialog box Figure 35 is displayed For Assembly Only executable projects continue to step 11 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 38 zZiLOG New Project Wizard Standard C Startup Module Check to link the object file for the standard C startup module into your application If you plan to provide your own startup code uncheck the option C Runtime Library Chec
20. data has grown beyond your FFCODO FFFFFF 008000 01 FFFF system s capability and to Extended RAM ERAM automatically locate your code 800000 87FFFF or data All options can be modified later Project gt Settings E za vasi 5 Fi xj e Figure 5 New Project Wizard Dialog Box Target Memory Configuration Step 14 Click Finish ZDS II creates a new project named sample Two empty folders are displayed in the Project Workspace window Standard Project Files and External Dependencies on the left side of the integrated development environment IDE Add a File to the Project In this section you add the provided C source file main c to the sample project 1 From the Project menu select Add Files The Add Files to Project dialog box Figure 6 is displayed UMO17103 0207 1 Getting Started ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Add Files To Project Look in E Tutorial e em e FE El main c File name i Files of type Source Files c asm s sre Cancel Figure 6 Add Files to Project Dialog Box 2 Inthe Add Files to Project dialog box return to the tutorial directory by navigating to lt ZDS Installation Directory NsamplesNTutorial 3 Select the main c file and click Add The main c file is then displayed under the Standard Project Files folder in the Project Workspace window on the left side of the IDE see Figure 7 1 Getting Started U
21. dow that 1s not actually related to that variable at all Generate Printfs Inline Normally a call to printf or sprintf parses the format string at run time to gener ate the required output When the Generate Printfs Inline check box is selected the format string is parsed at compile time and direct inline calls to the lower level helper functions are generated This results in significantly smaller overall code size because the top level routines to parse a format string are not linked into the project and only those lower level routines that are actually used are linked in rather than every routine that could be used by a call to printf The code size of each routine that calls printf orsprintf is slightly larger than if the Generate Printfs inline check box is deselected but this is more than offset by the significant reduction in the size of library functions that are linked to your application UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 65 zZiLOG To reduce overall code size by selecting this check box the following conditions are nec essary e Allcallstoprintf and sprintf must use string literals rather than char variables as parameters For example the following code allows the compiler to reduce the code size sprintf Timer will be reset in d seconds reset time But code like the following results in larger code char ti
22. 00845F 00843D 0084F5 008062 008494 008474 008000 008460 008468 00801A 0084AC 0084F6 00843E 0082FA 0084DA FFB0OO0 FFB036 FFB035 FFBO42 EROM C 008000 RAM R FFBO0O ROM T 0000 SEGMENTS WITHIN SPACE EROM Type 100zcog TEXT normal data sputch TEXT normal data uputch TEXT normal data CODE normal data ei TEXT normal data getchar TEXT normal data main TEXT normal data mstring TEXT normal data NEAR DATA segment copy putchar TEXT normal data sio TEXT normal data t putch TEXT normal data RAM Type NEAR BSS normal data NEAR DATA normal data ROM Type flash option0_ absolute data flash optionl absolute data flash option2 absolute data flash option3 absolute data VECTORS 04 absolute data VECTORS 08 absolute data VECTORS 0C absolute data VECTORS 10 absolute data VECTORS 14 absolute data VECTORS 18 absolute data VECTORS 1C absolute data __ VECTORS 20 absolute data VECTORS 24 absolute data VECTORS 28 absolute data VECTORS 2C absolute data VECTORS 30 absolute data 5 Using the Linker Locator HdHddddddddduddmdnmunduwd i L zs ZiLOG UM017103 0207 ZiLOG Developer Studio Il ZNEO User Manual 236 7 zZiLOG __ VECTORS 34 absolute data T 0034 T 0037 4h VECTORS 38 absolute data T 0038 T 003B 4h _ VECTORS 3C absolute data T 003C T 003F 4h VECTORS 40 absolute data
23. Assembler Command Line Options on page 299 Compiler Command Line Options on page 301 Librarian Command Line Options on page 304 Linker Command Line Options on page 304 BUILDING A PROJECT FROM THE COMMAND LINE To build a project from the command line use the following procedure 1 Add the ZDS II bin directory for example C Program Files ZiLOG ZDSII Z8Encore 4 11 0 Vbin to your path by setting the PATH environment variable The make utility is available in this directory Open the project using the IDE Export the make file for the project using the Export Makefile command in the Project menu Open a DOS window and change to the intermediate files directory Build the project using the make utility on the command line in a DOS window To build a project by compiling only the changed files use the following command make f sampleproject Debug mak To rebuild the entire project use the following command make rebuildall f sampleproject Debug mak Appendix A Running ZDS II from the Command Line UMO17103 0207 298 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG RUNNING THE COMPILER FROM THE COMMAND LINE To run the compiler from the command line 1 Open the make file in a text editor 2 Copy the options in the CFLAGS section 3 Ina Command Prompt window type the path to the compiler the options from the CFLAGS section on a single line and without backslashes and your C file Fo
24. C Startup Module on page 72 and also add the modified source code file to your project using the Add Files command from the Project menu Assembly Program Setup The Assembly program setup for the Copy to RAM Program Configuration is similar to the Default Program Configuration with some additional guidelines as described in this section Write all the executable program code nonstartup code under the CODE segment This segment belongs to EROM address space To set up this configuration you need to copy the CODE segment from EROM to RAM address space Do this by performing steps 2 and 3 from the C Program Setup for this configuration as described in C Program Setup on page 274 In step 3 add the code to your assembly startup code instead of the standard C startup Special Case Partial Copy to RAM A special case of this configuration is when you want to copy program code from just one assembly segment into RAM while retaining the rest of the code in EROM This allows you to investigate whether there might be power or speed savings to be realized by parti tioning your application in this way Do this by performing the following steps 1 Use a distinct segment name for the particular segment For example Define main TEXT space EROM segment main TEXT code goes here 2 Tocopythe main TEXT segment from EROM to the RAM address space perform steps 2 and 3 from the C Program Setup Special Case for this configura
25. E QuickStart y Tutorial File name Files of type Project Files zdsproj y Cancel Figure 1 Select Project Name Dialog Box Use the Look In drop down list box to navigate to the directory where you want your project to reside For this tutorial place your project in the following directory lt ZDS Installation Directory NsamplesNTutorial If ZiLOG Developer Studio was installed in the default directory the actual path would be C Program FilesNZiLOGNZDSII ZNEO 4 10 1 samples Tutorial In the File Name field type sample for the name of your project 1 Getting Started ZiLOG Developer Studio ll ZNEO User Manual ziLoc The ZNEO developer s environment creates a project file By default project files have the zdsproj extension for example project name gt z sproj You do not have to type the extension zdsproj in this field It is added automatically Click Select to return to the New Project dialog box 6 7 Inthe Project Type field select Standard because the sample project uses c files 8 In the CPU Family drop down list box select ZI6F Series 9 In the CPU drop down list box select Z16F2811 AL 10 In the Build Type drop down list box select Executable to build an application See Figure 2 New Project Project Name C Program FilesziLOG ZDSIl ZNEO 4 11 0 samples T utorial El Project Type Standard vi CPU Family Z16F Series Y CPU Z16F2811AL Bui
26. E and f conversions the maximum number of significant digits for the g and G conversions or the maximum number of characters to be written from a string in s conversion The precision takes the form of a period followed by an optional decimal integer if the integer is omitted it is treated as zero The amount of padding specified by the precision overrides that specified by the field width An optional h specifies that a following d i 0 u x or X conversion character applies to a short_int or unsigned_short_int argument the argument has been promoted according to the integral promotions and its value is converted to short_int or unsigned short int before printing An optional ell specifies that a following d 1 o u x or X conversion character applies to a long int or unsigned long int argument An optional L specifies that a following e E f g or G conversion character applies to along double argument If an h 1 or L appears with any other conversion character it is ignored A character that specifies the type of conversion to be applied A field width or precision or both can be indicated by an asterisk instead of a digit string In this case an int argument supplies the files width or precision The arguments specifying field width or precision displays before the argument if any to Appendix C C Standard Library UMO17103 0207 373 ZiLOG Developer Studio Il ZNEO User Manual 374 7 zZiLOG be co
27. Figure 31 Command Output Window MENU BAR The menu bar lists menu items used in the ZNEO developer s environment Clicking a menu bar item displays a list of selection items If an option on a menu item ends with an ellipsis selecting the option displays a dialog box The following items are listed on the menu bar e File Menu on page 35 e Edit Menu on page 44 UMO17103 0207 2 Using the Integrated Development Environment View Menu on page 50 Project Menu on page 51 Build Menu on page 89 Debug Menu on page 92 Tools Menu on page 94 Window Menu on page 108 Help Menu on page 109 File Menu ZiLOG Developer Studio ll ZNEO User Manual zZiLOG The File menu enables you to perform basic commands in the developers environment New File on page 35 Open File on page 35 Close File on page 36 New Project on page 36 Open Project on page 40 Save Project on page 41 Close Project on page 41 Save on page 42 Save As on page 42 Save All on page 42 Print on page 42 Print Preview on page 43 Print Setup on page 43 Recent Files on page 44 Recent Projects on page 44 Exit on page 44 New File Select New File from the File menu to create a new file in the Edit window Open File Select Open File from the File menu to display the Open dialog box Figure 32 which a
28. Press the Enter key The ASCIZ value displays in the Value column 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 290 zZiLOG Locals Window Click the Locals Window button to show or hide the Locals window The Locals window Figure 106 displays all local variables that are currently in scope Updated values appear in red The 0x prefix indicates that the values are displayed in hexadecimal format If you want the values to be displayed in decimal format select Hexadecimal Display from the con text menu NOTE Ifthe Locals window displays unexpected values deselect the Use Register Variables check box See Use Register Variables on page 63 CROFFFBO42 R 0000007E R 0000008F R 00000097 R 0000009F R 00000047 R 00000060 R 000000B9 Figure 106 Locals Window Call Stack Window Click the Call Stack Window button to show or hide the Call Stack window Figure 107 If you want to copy text from the Call Stack Window select the text and then select Copy from the context menu lx Call Stack D main line 49 file C Program FilesVZiLOGXZDSII ZSEncore 4 8 0 samples Z8F08xx_ledBlink src main c Figure 107 Call Stack Window The Call Stack window allows you to view function frames that have been pushed onto the stack Information in the Call Stack window is updated every time a debug operation is processed UMO017103 0207 7 Using the Debugger ZiLOG Developer Studi
29. Synopsis include lt sio h gt int putch char ch UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual L 3 ziLoc Returns A zero is returned on success a nonzero is returned on failure Example char ch c int err err putch ch NOTE Before using this function the init uart function needs to be called to initialize and select the UART The default UART is UARTO RI RI restore interrupt is a ZILOG intrinsic function that restores interrupt status It is intended to be paired with an earlier call to TDI which has previously saved the exist ing interrupt status See TDI on page 141 for a discussion of that function The interrupt status which is passed as a parameter to RI consists of the flags register extended to 16 bits for efficient stack storage This function is an intrinsic function and is inline expanded by default If the reduceopt compiler option is selected then this function is not inline expanded and is implemented as a regular function instead Synopsis include lt zneo h gt intrinsic void RI unsigned short istat Example tinclude lt zneo h gt void main void unsigned short istat istat TDI Test and Disable Interrupts Do Something RI istat Restore Interrupts select_port select port is a ZiLOG function that selects the UART The default is UARTO The init uart function can
30. This command blocks the execution of other commands until the build process is complete The following is the syn tax ofthe rebuild command rebuild reset The reset command resets execution of program code to the beginning of the program This command starts a debug session if one has not been started The following is the syn tax ofthe reset command reset By default the reset command resets the PC to symbol main If you deselect the Reset to Symbol main Where Applicable check box on the Debugger tab of the Options dia log box see Options Debugger Tab on page 107 the PC resets to the first line of the program savemem The savemem command saves the memory content of the specified range into an Intel hex file a binary file or a text file The functionality is similar to the Save to File command available from the context menu in the Memory window see Save Memory to a File on page 287 The following is the syntax of the savemem command savemem SPACE lt displayed spacename FORMAT lt HEX BIN TEXT gt PATHN name STARTADDRESS lt hexadecimal address gt ENDADDRESS lt hexadecimal address gt If STARTADDRESS and ENDADDRESS are not specified all the memory contents of a spec ified space are saved For example savemem SPACE RDATA FORMAT BIN c temp file bin STARTADDRESS 20 ENDADDRESS 100 savemem SPACE ROM FORMAT HEX c temp file hex savemem SPA
31. To go back to the Default Program Configuration for production code remove this direc tive from the Additional Linker Directives dialog box Special Case Partial Download to ERAM A special case of this configuration is to download program code from just one C source file into ERAM while retaining the rest of the code in EROM This example is included for completeness because similar cases of partitioning the code are discussed for the other configurations that are covered in this chapter Do this by performing the following steps 1 Select the Distinct Code Segment for Each Module check box in the Advanced page in the Project Settings dialog box see page 65 This option directs the C Compiler to generate different code segment names for each file 2 Use the linker CHANGE directive to move the particular segment to ERAM For example to download the code for main c to ERAM add the following linker command in the Additional Linker Directives dialog box see Additional Directives on page 68 change main TEXT ERAM To go back to the Default Program Configuration for production code remove this directive from the Additional Linker Directives dialog box Assembly Program Setup The Assembly program setup for the Download to ERAM Program Configuration 1s simi lar to the Default Program Configuration with some additional guidelines as described in this section Write all the executable program code
32. User Manual zZiLOG bit addresses can access only two 32KB areas one in low memory and one in high memory so data intensive applications might also need to use some 32 bit addressed memory for data Program code is always fetched using the 32 bit program counter so there are no addressing restrictions for program code Placing as little program code as possible in the 16 bit addressable for data space leaves more memory available in that space for data The ZNEO microcontroller I O and special function registers are located in the highest 8KB of its 24 bit address space and extra chip selects are available for external I O in the space immediately below internal I O Locating I O functions in the high memory 16 bit addressable space allows efficient access to I O devices ZDS II uses five configurable memory ranges to associate a functional purpose to each part of the target system s physical memory map You can configure the address ranges for each function in the Linker page of the Project Settings dialog box see Project Set tings Address Spaces Page on page 74 Each address range has a corresponding mne monic that is used with the assembly language SPACE keyword The five address ranges and their SPACE mnemonics are Constant data ROM This range is typically 00 0000H 00 1FFFH for devices with 32 KB of internal Flash 00 0000H 00_3FFEH for devices with 64 KB of internal Flash and 00 0000H 00 7FFFH for devices with 128 K
33. VALUE AA STARTADDRESS 1000 ENDADDRESS 2FFF go The go command executes the program code from the current program counter until a breakpoint or optionally a symbol is encountered This command starts a debug session if one has not been started The go command can take one of the following forms e go resumes execution from the current location e go symbol resumes execution at the function identified by symbol This version of the go command can only be used during a debug session The following are examples go go myfunc list bp The list bp command displays a list of all of the current breakpoints of the active file The following is the syntax ofthe 1ist bp command list bp loadmem The 10admem command loads the data of an Intel hex file a binary file or a text file to a specified memory space at a specified address The functionality is similar to the Load UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual 321 ziLoc from File command available from the context menu in the Memory window see Load a File into Memory on page 288 The following is the syntax of the 1oadmem command loadmem SPACE lt displayed spacename FORMAT HEX BIN TEXT gt lt PATH name gt STARTADDRESS lt hexadecimal address gt If STARTADDRESS is not specified the data is loaded at the memory lower address For
34. allows you to execute IDE and debugger commands with the following controls Run Command Button on page 21 e Stop Command Button on page 21 Command Field on page 21 Figure 18 Command Processor Toolbar See Supported Script File Commands on page 312 for a list of supported commands Run Command Button The Run Command button executes the command in the Command field Output from the execution of the command is displayed in the Command tab of the Output window Stop Command Button The Stop Command button stops any currently running commands Command Field The Command field allows you to enter a new command Click the Run Command button or press the Enter key to execute the command Output from the execution of the com mand is displayed in the Command tab of the Output window To modify the width of the Command field do the following 1 Select Customize from the Tools menu 2 Click in the Command field A hatched rectangle highlights the Command field 3 Use your mouse to select and drag the side of the hatched rectangle The new size of the Command field is saved with the project settings 2 Using the Integrated Development Environment UMO17103 0207 22 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Debug Toolbar The Debug toolbar Figure 19 allows you to perform debugging functions with the fol lowing buttons Download Code Button on page 22 Verify Download Button
35. as they normally are printf Conversion Characters d i 0 u x X The int argument is converted to signed decimal d or 1 unsigned octal 0 unsigned decimal u or unsigned hexadecimal notation x or X the letters abcdef are used for x conversion and the letters ABCDEF for X conversion The precision specifies the minimum number of digits to appear if the value being converted can be represented in fewer digits it is expanded with leading zeros The default precision is 1 The result of converting a zero value with a precision of Zero is no characters UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual Z 375 zZiLOG f The double argument is converted to decimal notation in the style ddd ddd where the number of digits after the decimal point is equal to the precision specification If the precision is missing it is taken as 6 if the precision is explicitly zero no decimal point appears If a decimal point appears at least one digit appears before it The value is rounded to the appropriate number of digits e E The double argument is converted in the style d ddde dd where there is one digit before the decimal point and the number of digits after it is equal to the precision when the precision is missing six digits are produced if the precision is zero no decimal point appears The value is rounded to the appropriate number of digits The E conversion character produces a num
36. define low farbss base of FAR BSS define len farbss length of FAR BSS define near heaptop highaddr of RAM define far heaptop highaddr of ERAM define far stack highaddr of ERAM define near stack highaddr of RAM define near heapbot top of RAM define far heapbot top of ERAM DEFINE SYS CLK SRC 2 DEFINE SYS_CLK FREQ 20000000 DEFINE EXTCT INIT PARAM ScO DEFINE __EXTCSO_ INIT PARAM 8012 DEFINE X EXTCS1 INIT PARAM 8001 DEFINE _ EXTCS2 INIT PARAM 0000 DEFINE X EXTCS3 INIT PARAM 0000 DEFINE X EXTCS4 INIT PARAM 0000 DEFINE X EXTCS5 INIT PARAM 0000 DEFINE PFAF INIT PARAM Sff DEFINE PGAF INIT PARAM Sff DEFINE PDAF INIT PARAM ff00 DEFINE PAAF INIT PARAM 0000 DEFINE PCAF INIT PARAM 0000 DEFINE PHAF INIT PARAM 0300 DEFINE PKAF INIT PARAM SOf C PROGRA 1 ZiLOG ZDSII_ 1 0 samples QUICKS 1 Debug 2Z16F2800100ZC0G C PROGRA 1 ZiLOG ZDSII_ 1 0 lib zilog startupexkS obj main obj NZ216F2800100Z2COG o0bj C PROGRA 1 ZiLOG ZDSII 1 0 lib std chelpSD 1lib C PROGRA 1 ZiLOG ZDSII_ 1 0 lib std crtSD 1lib C PROGRA 1 ZiLOG ZDSII_ 1 0 lib std fpSD 1lib SPACE ALLOCATION UMO17103 0207 5 Using the Linker Locator C 008502 R FFBO42 T 013F 503h 43h 140h ZiLOG Developer Studio ll ZNEO User Manual 0082F9 0084AB 008493 008019 008467 008473 008061 0084D9 008502
37. nonstartup code under the CODE segment This segment belongs to EROM address space To set up this configuration you need to move the CODE segment from EROM to the ERAM address space Do this by adding the fol lowing linker command in the Additional Linker Directives dialog box see Additional Directives on page 68 ERAM The linker will then allocate code segment in ERAM To go back to the Default Program Configuration for production code remove this direc tive from the Additional Linker Directives dialog box 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 265 zZiLOG Special Case Partial Download to ERAM A special case of this configuration is to download program code from just one assembly segment into ERAM while retaining the rest of the code in EROM Do this by performing the following steps 1 Use a distinct segment name for the particular segment For example Define main TEXT space EROM segment main TEXT code goes here 2 Usethe linker CHANGE directive to move the particular segment to ERAM For example To download the code for the main TEXT segment to ERAM add the following linker command in the Additional Linker Directives dialog box see Additional Directives on page 68 change main TEXT ERAM To go back to the Default Program Configuration for production code remove this directive from the Additional Link
38. not match those of the previous definition UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 153 zZiLOG 004 Incorrect number of arguments for macro lt name gt An attempt was made to call a macro but too few or too many arguments were given 005 Unbalanced parentheses in macro call An attempt was made to call a macro with a parenthesis embedded in the argument list that did not match up 006 Cannot redefine lt name gt keyword An attempt was made to redefine a keyword as a macro 007 Illegal directive The syntax of a preprocessor directive is incorrect 008 Illegal if directive syntax The syntax of a if preprocessor directive is incorrect 009 Bad preprocessor file Aborted An unrecognizable source file was given to the compiler 010 Illegal macro call syntax An attempt was made to call a macro that does not conform to the syntax rules of the language 011 Integer constant too large An integer constant that has a binary value too large to be stored in 32 bits was encountered 012 Identifier lt name gt is undefined The syntax of the identifier is incorrect 013 Illegal include argument The argument to a include directive must be of the form pathname or filename 014 Macro lt name gt requires arguments An attempt was made to call a macro defined to have arguments and was given none 015 Illegal define directive syntax The syntax of the defi
39. on page 22 Reset Button on page 23 Stop Debugging Button on page 23 Go Button on page 23 Run to Cursor Button on page 23 Break Button on page 23 Step Into Button on page 23 Step Over Button on page 23 Step Out Button on page 23 Set Next Instruction Button on page 24 Insert Remove Breakpoint Button on page 24 Enable Disable Breakpoint Button on page 24 Disable All Breakpoints Button on page 24 Remove All Breakpoints Button on page 24 Figure 19 Debug Toolbar Download Code Button The Download Code button downloads the executable file for the currently open project to the target for debugging The button also initializes the communication to the target hard ware if it has not been done yet Use this button anytime during a debug session NOTE The current code on the target is overwritten Verify Download Button The Verify Download button determines download correctness by comparing executable file contents to target memory UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 23 zZiLOG Reset Button The Reset button resets the program counter to the beginning the program If not in Debug mode a debug session is started By default and if possible clicking the Reset button resets the program counter to symbol main If you deselect the Reset to Symbol main Where Applic
40. startup For example E Jg B E a g g g W E UVUUUUUUUUUUUOUUOy w B RO EXTCT INIT PARAM EXTCT RO Setup EXTCT RO EXTCSO Setup EXTCSO EXTCS5 RO 4 EXTCSO INIT PARAM 16 EXTCS1 INIT PARAM RO _ EXTCS2 INIT PARAM lt lt 16 EXTCS3 INIT PARAM RO _ EXTCS4 INIT PARAM lt lt 16 EXTCS5 INIT PARAM Setup Port Alternate functions RO PAAF INIT PARAM PAAF RO RO PCAF INIT PARAM PCAF RO RO PDAF INIT PARAM PDAF RO RO PFAF INIT PARAM PFAFL RO RO PGAF INIT PARAM PGAFL RO RO PHAF INIT PARAM PHAF RO RO PKAF INIT PARAM PKAFL RO Following the above guidelines an assembly user can achieve the Default Program Configuration for production code Download to ERAM Program Configuration The Download to ERAM Program Configuration Figure 90 can be used only during development and not for production code It is similar to the Default Program Configura tion the only difference is that aside from the startup code the rest of the executable pro gram is downloaded into ERAM and executed from ERAM Because ERAM cannot retain values across power cycles this configuration is meant for development only By using this configuration you can avoid erasing and burning the exe cutable code in Flash multiple times as part of the development cycle UMO17103 0207 6
41. the Debug and Release configurations are predefined For more information on project configura tions such as adding your own configuration see Set Active Configuration on page 90 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG The Project Settings dialog box has different pages you must use to set up the project Project Settings General Page on page 54 Project Settings Assembler Page on page 56 Project Settings Code Generation Page on page 57 not available for Assembly Only projects Project Settings Listing Files Page on page 59 not available for Assembly Only projects Project Settings Preprocessor Page on page 61 not available for Assembly Only projects Project Settings Advanced Page on page 62 not available for Assembly Only projects Project Settings Librarian Page on page 66 available for Static Library projects only Project Settings Commands Page on page 66 available for Executable projects only Project Settings Objects and Libraries Page on page 70 available for Executable projects only Project Settings Address Spaces Page on page 74 available for Executable projects only Project Settings Warnings Page on page 77 available for Executable projects only Project Settings Output Page on page 78 available for Executable p
42. the memory range settings to let you know when your code or data has grown beyond your system s capability The system also uses memory ranges to automatically locate your code or data See Programmer s Model of ZNEO Memory on page 253 for details about address range functions The ZDS II address ranges are Constant data ROM This range is typically 000000 001FFF for devices with 32 KB of internal Flash 000000 003FFF for devices with 64 KB of internal Flash and 000000 007FFF for devices with 128 KB of internal Flash The lower boundary must be 00_000H The upper boundary can be lower than 007FFF but no higher 2 Using the Integrated Development Environment UMO17103 0207 76 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG e Program space EROM This range is typically 002000 007FFF for devices with 32 KB of internal Flash 004000 00FFFF for devices with 64 KB of internal Flash or 008000 01FFFF for devices with 128 KB of internal Flash Specify a larger range only if the target system provides external nonvolatile memory NOTE To use any external memory provided on the target system you must configure the memory s chip select in the Configure Target dialog box See Project Settings Debugger Page on page 81 Extended RAM ERAM Specify an ERAM range only if the target system provides external random access memory below FF8000 The ERAM field does not accept a starting address below 800000 e
43. zZiLOG build The build command builds the currently open project This command blocks the execu tion of other commands until the build process is complete The following is the syntax of the build command build cancel all The cancel all command clears all breakpoints in the currently loaded project The fol lowing is the syntax ofthe cancel a11 command cancel all Starting in version 4 11 0 you can also use the cancel all command to clear all break points including access breakpoints For example cancel all To clear a specified breakpoint see cancel bp on page 314 To set access breakpoints see bp on page 313 cancel bp cd The cancel bp command clears the breakpoint at the bp list index Use the 1ist bp command to retrieve the index of a particular breakpoint The following is the syntax of the cancel bp command cancel bp index For example cancel bp 3 Starting in version 4 11 0 you can also use the cancel bp when command to clear an access breakpoint set at a specified address The following is the syntax ofthe cancel bp when command cancel bp when lt address gt To clear all access breakpoints see cancel all on page 314 To set access breakpoints see bp on page 313 The cd command changes the working directory to dir The following is the syntax of the cd command Gd lt dir gt For example cd c Ntemp cd another dir UMO017103 0207 Appendix B Using
44. 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 199 zZiLOG ELIF ABC XYZ 3 and ABC is not 0 lt Code Body 2 gt ELSE otherwise code body 3 lt Code Body 3 gt ENDIF IFDEF Checks for label definition Only a single label can be used with this conditional If the label is defined the result is true otherwise the result if false Syntax IFDEF lt label gt lt code_body gt ELSE lt code_body gt ENDIF Example IFDEF XYZ process code body if XYZ is defined lt Code Body gt ENDIF IFSAME Checks to see if two string constants are the same If the strings are the same the result is true otherwise the result is false If the strings are not enclosed by quotes the comma is used as the separator 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 200 zZiLOG NOTE MACROS Syntax IFSAME lt string_const gt lt string_const gt code body ELSE code body ENDIF IFMA Used only within a macro this directive checks to determine if a macro argument has been defined If the argument is defined the result is true Otherwise the result is false If arg number is 0 the result is TRUE if no arguments were provided otherwise the result is FALSE IFMA refers to argument numbers that are one based that is the first argument is
45. 1 2 Reserve 2 words Initialize the first word with a 1 and the second with a 2 DW 1234 Reserve 1 word and initialize it with 21234 NOTE There is no trailing null for the DW declaration type Each letter gets 16 bits with the upper 8 bits zero UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual y AE zZiLOG DW24 Declaration Type Synonyms word24 trio DW24 Syntax DW24 word data 24 bits Examples dw24 123456 Reserve one 24 bit entity and initialize it with 2123456 trio 789abc Reserve one 24 bit entity and initialize it with 798abc DEFINE Defines a segment with its associated address space alignment and origin You must define a segment before you can use it unless it is a predefined segment If a clause is not given use the default for that definition For more information on the SEGMENT directive see SEGMENT on page 189 For a list of predefined segments see Predefined Seg ments on page 168 Synonym define Syntax segment definition gt DEFINE lt ident gt lt space clause gt align_clause gt lt org clause gt Examples DEFINE near_code Uses the defaults of the current space byte alignment and relocatable DEFINE irq table ORG SFFF8 Uses current space byte alignment and absolute starting address at memory location SFFF8 ALIGN Clause Allows you to select the alignmen
46. 15 minutes In this tour you do the following Create a New Project on page 2 e Add a File to the Project on page 6 e Set Up the Project on page 8 Save the Project on page 14 When you complete this tour you will have a sample lod file that is used for debugging NOTE Be sure to read Menu Bar on page 34 to learn more about all the dialog boxes and their options discussed in this tour For the purpose of this tutorial your ZNEO developer s environment directory will be referred to as lt ZDS Installation Directory which equates to the following lt ZILOGINSTALL gt ZDSII_ZNEO_ lt version gt 1 Getting Started UM017103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG where ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files ZiLoG version is the ZDS II version number For example version might be 4 11 0 or 2 0 4 9 Create a New Project 1 2 5 UMO17103 0207 Start the ZDS II program if it is not already running To create a new project select New Project from the File menu The New Project dialog box is displayed From the New Project dialog box click on the Browse button L to navigate to the directory where you want to save your project The Select Project Name dialog box is displayed as shown in Figure 1 Select Project Name Look in G samples e 3 ex E3 E Assembly
47. 16 1 Allocate 16 bytes and initialize them to 1 BLKL Declaration Type Syntax BLKL count lt init_value gt xamples E BLKL 16 Allocate 16 uninitialized longs B BLKW Declaration Type KL 16 1 Allocate 16 longs and initialize them to 1 Syntax BLKW count lt init_value gt Examples BLKW 16 Allocate 16 uninitialized words BLKW 16 1 Allocate 16 words and initialize them to 1 DB Declaration Type Synonyms byte ascii DEFB FCB STRING STRING byte asciz 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 184 zZiLOG Syntax DB byte data 8 bits Examples DB Hello World Reserve and initialize 11 bytes DB 1 2 Reserve 2 bytes Initialize the first word with a 1 and the second with a 2 DB 12 Reserve 1 byte Initialize it with 12 NOTE There is no trailing null for the DB declaration type A trailing null is added for asciz declaration types DL Declaration Type Synonyms long long Syntax DL long 32 bits Examples DL 1 2 Reserve 2 long words Initialize the first with a 1 and last with a 2 DL 12345678 Reserve space for 1 long word and initialize it to 12345678 DW Declaration Type Synonyms word word int Syntax DW word data 16 bits Examples DW Hello World Reserve and initialize 11 words DW Hello Reserve and initialize 5 words DW
48. 172 General Structures 1 oue es er E etr ane aca nes ob ena n ds 172 Assembler Rules 0 00 c nett eee teens 173 EXPTESSIONS A n ed ed tian 175 Arithmetic Operators 2 0 ccc eee teen en eens 176 Relational Operators 0 0 es 176 Boolean Operators 2 252 sss eres A bee Dew eae TR aes 176 LOW and LOW16 Operators sseseeeeeeee eee 176 Decimal NUMmbDEES iii id aa doa ewe 177 Hexadecimal Numbers ooooooocococo eee n ene nee 177 Binary N mbers 2 3 esee Re EA da e he ades b ades 177 Octal NUMDELS sie ree RR US DR TR EU b pb use ep D e ERU ER 177 Character Constants 0 cece cece eet ence ence eens 178 Operator Precedence xis eevee err eR a See hae NACE 178 Address Spaces and Instruction Encoding 00 0 cece neces 179 ucc CPP bdok abhi ds dolida 181 A A 181 COMMENT an DERE RUP AER RP CE a ERU RATER RU eR 182 Gum 182 Data Dir ctives csset ree RR ER RERO GT deere he UR ERBEN DURER 182 DEFINE 14 2o R32 ped Acor ct 185 DS EET 186 END e RITE 186 Table of Contents UMO17103 0207 viii ZiLOG Developer Studio Il ZNEO User Manual or 187 INCLUDE e t oer eter vernos tuae i oe ness ncsuees 187 LIST EA Av qued od Med odd Erg Rata idi ate kde od ipic 188 NOLIST Hera I II 188 ORG srta tarada ida 188 SEGMENT tran ERA AA AE 189 SHORT STACK FRAME currar ais is rs 189 TRIB A A OR Re eR Eee Rao 190 fh A Pere eee G eee eee ree EN 190 VECTOR ida A uN SRA Dic
49. 31 2006 then ZDATE expands to 20060531 This macro gives a means to test for a particular ZiLOG release or to test that the compiler is released after a new feature has been added This macro is defined and set to 1 on all ZILOG compilers to indicate that the compiler is provided by ZiLOG This macro is defined and set to 1 for the ZNEO compiler and is otherwise undefined All predefined macro names begin with two underscores and end with two underscores 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 128 zZiLOG Examples The following program illustrates the use of some of these predefined macros include lt stdio h gt void main ifdef ZILOG printf ZiLOG Compiler endif ifdef ZNEO printf For ZNEO endif ifdef ZDATE _ printf Built on d n ZDATE endif CALLING CONVENTIONS The C Compiler imposes a strict set of rules on function calls Except for special run time support functions any function that calls or is called by a C function must follow these rules Failure to adhere to these rules can disrupt the C environment and cause a C pro gram to fail Function Call Mechanism A function caller function performs the following tasks when it calls another function called function 1 Save any of the registers RO R7 that are in use and may be needed after the call these registers may be overwritten in the ca
50. 82895 seconds 0 014991 Figure 97 Clock Window 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 282 zZiLOG Memory Window Click the Memory Window button to open up to ten Memory windows Figure 98 Space Io Data e Address IXMO0FFCOOO I f00FFCOO0 I 00FFCO06 I 00FFCOOC I 00FFCU12 I 00FFCO18 I O0FFCO1E I 00FFCU24 I FFCU2 I 00FFC030 Figure 98 Memory Window Each Memory window displays data located in the target s memory The ASCII text for memory values is shown in the last column The address is displayed in the far left column with an I to denote the IOData address space or with an M to denote the Memory address space Use the Memory window to do the following e Change Values on page 282 e View the Values for Other Memory Spaces on page 283 e View or Search for an Address on page 283 e Fill Memory on page 284 e Save Memory to a File on page 285 e Load a File into Memory on page 286 e Perform a Cyclic Redundancy Check on page 286 NOTE The Page Up and Page Down keys on your keyboard are not functional in the Memory window Instead use the up and down arrow buttons to the right of the Space and Address fields Change Values To change the values in the Memory window do the following 1 Inthe window highlight the value you want to change The values begin in the second column after the Address column UMO17103
51. AE A ned be cid dl 365 ISSPACG ced bes ee ERN a A ias 365 ien ME 366 D egjrc M 366 LADOS 4 ree see Rd rea C ee d eda nU d RACER Ga eere i e Rod adi 366 ldexp ldexpf 222 RR REID EH RR ER Dese ea a ha 367 ldiV ERR ePPRHO SOPHIE Tee HEB ei 367 Inna PPP 368 logl10 Jogl0f 2 obe id 368 lonj bee Hee Eae eder Suede debet dede deeds qus 368 mallorca idea ines t ceo LA A M E dE UE 369 A ce eedoshcdoa Sets ce eda adi aad Otani E E a daa ah AE Medel aah dnd 370 Table of Contents UMO17103 0207 xiv ZiLOG Developer Studio Il ZNEO User Manual MEMCMP RT 370 MEMCPY eleressbtvueReeLvuet e RI RHET IRR PEE RU ae been ee PEE 371 PCM OVE ii A A RA A id 371 MESET a a ue a 371 modf modff A ques RR REF ARR EP EE qe M e Ed eee 372 DOW DOW sit teen qe SHE SV eR ee dae ue Vade viae 372 Drintf 132 oc a ane ee IE uM NER hes Sede E nete eu e duree qs 373 je iren ET 375 PU PET LM 376 nro MT 376 A aH Awe See AG OEE SURE SONG SEE SS OG Re aa 377 Iealloe 44 ceeds banda bese oh babar h ie iq bn P ita 377 i iia ed 378 Semp odio ad A BRE Read Ree eee SAGE dies 381 SO eidem e oe eoe e eee eA Eod d a doe aces 382 SESTO REESE A a a e a E EN ge a EEA 382 Spiti EM 383 euin MM 383 Stand o EE M E es 384 Don PM 384 duc MP 384 SUCHE ierde dd hd dad b tbt da die dates deba dades duds dub dedidit 385 DU PT EET 385 SUCDY led er9 Ree Hoss SOS ESS Cae hee eels Gee ees seared nes end des 386 SCS DI CMT MC 386 A E ener eee r Ries 387 duc da C KCN 3
52. Compiler ZiLOG Developer Studio ll ZNEO User Manual Z 161 ziLoc 171 Argument type is not compatible with formal parameter An attempt was made to call a function with an argument whose type is not compatible with the type of the corresponding formal parameter 172 Identifier lt name gt is not a structure or union tag An attempt was made to use the dot operator on an expression whose type was not structure or union 173 Identifier lt name gt is not a structure tag The tag of a declaration of a structure object does not have type structure 174 Identifier lt name gt is not a union tag The tag of a declaration of a union object does not have type union 175 Structure or union tag lt name gt is not defined The tag of a declaration of a structure or union object is not defined 176 Only one storage class may be given in a declaration An attempt was made to give more than one storage class in a declaration 177 Type specifier cannot have both unsigned and signed An attempt was made to give both unsigned and signed type specifiers in a declaration 178 unsigned and signed may be used in conjunction only with int long or char An attempt was made to use signed or unsigned in conjunction with a type specifier other than int long or char 179 long may be used in conjunction only with int or double An attempt was made to use long in conjunction with a type specifier other than in
53. Configuration C Program Setup The C program setup for Copy to ERAM Program Configuration is similar to the Default Program Configuration with some additional steps as described in this section The C Compiler by default generates the executable program code under one unified seg ment named CODE The CODE segment belongs to EROM address space To set up this configuration you need to place the CODE segment in ERAM at run time and EROM at load time Do this by adding the following linker commands in the Additional Linker Directives dialog box see Additional Directives on page 68 1 6 Configuring Memory for Your Program UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 270 ZitoG change code ERAM Run time CODE is in ERAM space copy code EROM Load time CODE is in EROM space 3 define low code copy copy base of CODE define low code base of CODE define len code length of CODE The linker COPY directive only designates the load addresses and the run time addresses for the segment The actual copying of the segment must be performed by the startup code For example if you are using the small model copy and modify the C startup provided in the installation under src boot common startupexs asm rewriting the relevant section as follows Copy CODE into ERAM EA RO low code copy EA Rl low code LD R2 len code 1 JP clabl
54. Encore XP Z8 Encore MC Crimzon eZ80 and ZNEO are trademarks or registered trademarks of ZiLOG Inc All other products and or service names mentioned herein may be trademarks of the companies with which they are associated UMO17103 0207 Revision History ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Revision Date Level Sections Description January 1 All Initial release 2006 June 2006 2 ZDS II System Requirements on page xxiii Updated FAQ html file on page xxv Developer s Environment Tutorial on page 1 Chapter 2 Using the Integrated Development Environment Warning and Error Messages on page 152 Label Field on page 172 Chapter 6 Configuring Memory for Your Program Perform a Cyclic Redundancy Check on page 286 erc on page 315 Changed FAQ txt to FAQ html Updated screenshots Updated various sections including the description of the memory map for CR 7124 Added messages Updated Updated text and figures for CRs 7123 and 7124 Added new section Added new section Revision History UMO17103 0207 iv ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Revision Date Level Sections Description February 3 Entire manual Changed the description of the Project 2007 Chapter 2 Using the Integrated Development Environment Chapter 4 Using the Macro Assembler Appendix B Using the Command P
55. Enter the end address in the End Address field If the end address is not a 4K increment it is rounded up to a 4K increment 4 Click Read The checksum is displayed in the CRC field Calculate File Checksum Use the following procedure to calculate the file checksum 1 Select Calculate File Checksum from the Tools menu The Calculate Checksum dialog box Figure 73 is displayed Calculate Checksum File N ame El Checksum Close Figure 73 Calculate Checksum Dialog Box 2 Click on the Browse button E to select the hex file for which you want to calculate the checksum The IDE adds the bytes in the files and displays the result in the checksum field See Figure 74 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 100 zZiLOG Calculate Checksum File Name C Program FilesziLOG zDSIl ZNED 4 10 1 samples ES Checksum 04038042 Close Figure 74 Calculate Checksum Dialog Box 3 Click Close Customize The Customize dialog box contains the following tabs e Customize Toolbars Tab on page 100 e Customize Commands Tab on page 102 Customize Toolbars Tab The Toolbars tab Figure 75 lets you select the toolbars you want to display on the ZNEO developer s environment change the way the toolbars are displayed or create a new tool bar NOTE You cannot delete customize or change the name of the default toolbars
56. File Extension IEEE 695 format OMF695 lod Intel 32 bit INTEL32 hex The default setting is IEEE 695 Syntax FORMAT lt type gt Example FORMAT OMF695 INTEL32 GROUP The GROUP command provides a method of collecting multiple address spaces into a single manageable entity Syntax GROUP lt groupname gt lt name gt lt name gt lt groupname gt can only be a group lt name gt can only be an address space HEADING The HEADING command enables or disables the form feed 1 characters in the map file output Syntax NO heading 5 Using the Linker Locator UMO17103 0207 220 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG LOCATE The LOCATE command specifies the address where a group address space or segment is to be located If multiple locates are specified for the same space the last specification takes precedence A warning is flagged on a LOCATE of an absolute segment NOTE The LOCATE of a segment overrides the LOCATE of an address space A LOCATE does not override an absolute segment Syntax LOCATE lt name gt AT expression lt name gt can be a group address space or segment expression is the address to begin loading Example LOCATE ROM AT 1000 NOTE Refer to Linker Expressions on page 226 for the format to write an expression MAP The MAP command causes the linker to create a link map file The link map file contai
57. If freed space is referenced the behavior is undefined Synopsis finclude lt stdlib h gt void free void ptr Example char buf buf char calloc 40 sizeof char free buf frexp frexpf Breaks a floating point number into a normalized fraction and an integral power of 2 It stores the integer in the int object pointed to by exp Synopsis tinclude lt math h gt double frexp double value int exp float frexpf float value int exp Returns The value x such that x is a double frexp or float frexpf with magnitude in the interval 1 2 1 or zero and value equals x times 2 raised to the power exp If value is zero both parts of the result are zero Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 362 7 zZiLOG Example double y x 16 4 int n y frexp x amp n getchar NOTE gets Waits for the next character to appear at the serial port and return its value Synopsis include lt stdio h gt int getchar void Returns The next character from the input stream pointed to by stdin If the stream is at end of file the end of file indicator for the stream is set and getchar returns EOF If a read error occurs the error indicator for the stream is set and get char returns EOF Example int i i getchar The UART needs to be initialized using the ZILOG init uart function See jnit uart on page 137 Reads characters from
58. Latin root kilo kHz See kilohertz kilohertz kHz A unit of frequency denoting one thousand 103 Hz L LD Load library A file that contains a collection of object modules that were created by an assembler or directly by a C compiler LSB Least significant bit M MAC An acronym for Media Access Control the method a computer uses to transmit or receive data across a LAN Megahertz MHz A unit of frequency denoting one million 10 Hz memory 1 All of the addressable storage space in a processing unit and other internal memory that is used to execute instructions 2 The volatile main storage in computers MHz See Megahertz also Hertz MI Minus MLD Multiply and Load MPYA Multiply and Add MPYS Multiply and Subtract MSB Most significant bit N n Number This letter is used as place holder notation NC No Connection NE Not Equal Glossary UMO17103 0207 404 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG NEG Negate NMI Nonmaskable interrupt NOP An acronym for No Operation an instruction whose sole function is to increment the program counter but that does not affect any changes to registers or memory O Op Code Operation Code a quantity that is altered by a microprocessor s instruction Also abbreviated OPC OR Bitwise OR OV Overflow P PC Program counter pipeline The act of initiating a bus cycle while another bus cycle is in progress T
59. Linker Locator zZiLOG lib Version 1 0 12 06 2005 Base Top Size T 0034 T 0037 4h lib Version 1 0 12 06 2005 Base Top Size T 0038 T 003B 4h lib Version 1 0 12 06 2005 Base Top Size T 003C T 003F 4h lib Version 1 0 12 06 2005 Base Top Size T 0040 T 0043 4h lib Version 1 0 12 06 2005 Base Top Size T 0044 T 0047 4h lib Version 1 0 12 06 2005 Base Top Size T 0048 T 004B 4h UMO17103 0207 242 ZiLOG Developer Studio Il Library chelpSD lib Version 1 0 12 06 2005 Library chelpSD lib Library chelpSD lib Version Library chelpSD lib Version Library chelpSD lib Library chelpSD lib Version ZNEO User Manual zZiLOG Module common vect4c asm 16 59 45 Name Segment VECTORS 4C Module common vect50 asm 16 59 45 Name Segment X VECTORS 50 Module common vect54 asm 16 59 45 Name Segment VECTORS 54 Module common vect58 asm 16 59 45 Name Segment VECTORS 58 Module common vect5c asm 16 59 45 Name Segment VECTORS 5C Module common vect60 asm 16 59 45 Name Segment VECTORS 60 UMO17103 0207 5 Using the Linker Locator Library ZiLOG Developer Studio ll ZNEO User Manual L mo zZiLOG Library Library Module common vect64 asm 16 59 45 Name Segment VECTORS 64 Module common vect68 asm 16 59 45 Name Segment VECTORS 68 Module common vect6c
60. Processor History Commands to keep 15 m Clear OK Cancel Help Comcel Hee Figure 78 Options Dialog Box General Tab Options Editor Tab Use the Editor tab to change the default settings of the editor for your assembly C and default files 1 From the Tools menu select Options The Options dialog box is displayed 2 Click on the Editor tab Figure 79 UMO17103 0207 2 Using the Integrated Development Environment Options General Editor Debugger ZiLOG Developer Studio ll ZNEO User Manual 105 zZiLOG File Type c Files De Tabs Tab Size la C Insert Spaces Keep Tabs Iv Auto Indent Font Color Default Text Selection Number Dperator Comment Keyword L Hue Foreground Background Font Courier Size 10 Sample AaBbCckuYyZz Select Font Figure 79 Options Dialog Box Editor Tab 3 Select a file type from the File Type drop down list box You can select C files assembly files or other files and windows 4 Inthe Tabs area do the following Use the Tab Size field to change the number of spaces that a tab indents code Select the Insert Spaces button or the Keep Tabs button to indicate how to format indented lines Select the Auto Indent check box if you want the IDE to automatically add indentation to your files 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 1
61. Project Workspace Window on page 26 e Edit Window on page 27 Output Windows on page 32 Debug Windows on page 279 Project Workspace Window The Project Workspace window Figure 22 or Figure 22 on the left side of the developer s environment allows you to view your project files zd xd Standard Project Files main c C Program y External Dependencies standardtemp Figure 21 Project Workspace Window for Standard Projects UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG CI Assembly Only Project Files 4 External Dependencies assemblytemp Figure 22 Project Workspace Window for Assembly Only Projects The Project Workspace window provides access to related functions using context menus To access context menus right click a file or folder in the window Depending on which file or folder is highlighted the context menu provides some or all of the following func tions Dock the Project Workspace window Hide the Project Workspace window Add files to the project Remove the highlighted file s from the project Build project files or external dependencies Build or compile the highlighted file Undock the Project Workspace window allowing it to float in the Edit window Edit Window The Edit window area Figure 23 on the right side of the developer s environment allows you to edit the files in your pr
62. RECURS MAC 1 a LABELS a recursive macro that demonstrates using MACEXIT to termi RG1 ARG2 IF ARG1 MACEXIT S MAC ARG1 1 ARG2 G2 ENDMACRO RECURS MAC Labels are considered symbolic representations of memory locations and can be used to reference that memory location within an expression See Local Labels on page 204 for the form of a legal label The following sections describe labels Anonymous Labels on page 204 e Local Labels on page 204 Importing and Exporting Labels on page 204 e Label Spaces on page 204 4 Using the Macro Assembler UMO17103 0207 204 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Anonymous Labels The ZDS Il assembler supports anonymous labels Table 11 lists the reserved symbols pro vided for this purpose Table 11 Anonymous Labels Symbol Description Anonymous label This symbol can be used as a label an arbitrary number of times B Anonymous label backward reference This symbol references the most recent anonymous label defined before the reference F Anonymous label forward reference This symbol references the most recent anonymous label defined after the reference Local Labels Any label beginning with a dollar sign or ending with a question mark is consid ered to be a local label The scope of a local label ends when a SCOPE directive is encoun tered thus allowing the label name
63. Relocatable Constant data tables and strings ROM TEXT ROM 1 byte Relocatable Constant strings VECTORS ROM 1 byte Absolute Interrupt vector table NEAR DATA RAM 1 byte Relocatable Initialized near data NEAR BSS RAM 1 byte Relocatable Uninitialized near data NEAR TEXT RAM 1 byte Relocatable Near strings FAR DATA RAM 1 byte Relocatable Initialized far data FAR BSS RAM 1 byte Relocatable Uninitialized far data FAR TEXT RAM 1 byte Relocatable Far strings IOSEG IODATA 1 byte Relocatable IO data User Defined Segments You can define a new segment using the following directives DEFINE MYSEG SPACE ROM SEGMENT MYSEG MYSEG becomes the current segment when the assembler processes the SEGMENT direc tive and MYSEG remains the current segment until a new SEGMENT directive appears MYSEG can be used as a segment name in the linker command file You can define a new segment in ERAM space using the following directives DEFINE MYDATA SPACE ERAM SEGMENT MYDATA The DEFINE directive creates a new segment and attaches it to a space For more informa tion about using the DEFINE directive see DEFINE on page 185 The SEGMENT direc tive attaches code and data to a segment The s EGM ENT directive makes that segment the current segment Any code or data following the directive resides in the segment until another
64. SUCCESS macro 348 exp function 345 359 Expand Macros check box 57 expf function 345 359 Exponential functions 345 359 Exporting project as make file 88 from the command line 297 Expressions arithmetic operators 176 binary numbers 177 Boolean operators 176 character constants 178 decimal numbers 177 hexadecimal numbers 177 in assembly 175 linker 226 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Lo as zZiLOG LOW operator 176 LOW16 operator 176 octal numbers 177 operator precedence 178 relational operators 176 Extended RAM 76 255 EXTERN directive 204 External Flash Base field 84 External Flash check box 84 96 External references resolving 218 F fabs function 346 360 fabsf function 346 360 False macro 340 FAQ html location of xxv far 134 FAR BSS segment 143 169 FAR DATA segment 143 169 FAR TEXT segment 143 169 FILE 127 File adding 6 52 opening 8 reading 8 viewing 8 File extensions hex 80 lod 80 st 170 map 220 247 obj 170 171 wsp 41 zdsproj 3 File menu 35 Close File 36 Close Project 41 Exit 44 New File 35 New Project 36 Index Open File 35 Open Project 40 Print 42 Print Preview 43 Print Setup 43 Recent Files 44 Recent Projects 44 Save 42 Save All 42 Save As 42 Save Project 41 shortcuts 110 File Name field Open dialog box 42 Save As dialog box 89 Select Project Name dialog box 37 File Offset field 97 File toolbar 17 File Type drop d
65. Sela el venere eeHenePPPLDEBRI aa 314 CO MEME ILE 314 uid cue MIC EE 315 CIC EPI ET 315 debugtool COPY Vaio A TX EE vers eae EU A SS ean 315 debugtool create nic soo e VETERE peed ere ad TESTE 316 debustool get ieren errare Een e Poe EUN e Je be ae ade LR aes 316 debugtool help 0 ccc cnet teen eee 316 debuptool list gina tote e Ee ce et ose eae de yaa ka la 316 debugtoolsave sss s 316 debustool Set rr chine his deid a EBENE 317 debugtool Set p ii a ehe ora DH ede D I Capite 317 defines yeh one Rx UR ER Hee ea HOS eh CRI ERR EE UE s 317 delete config iiis te etr a t e e doe dri I Dres etr eds ees 318 examine for Expressions lssssseeeeeee e 318 examine for Variables oo oooooooooooooomomorrrnnono ooo 319 oum 320 fillmem 5 oer ereere ener E UC OST a 320 O a Rd ees been oe Tarpeia Ad es 320 ura PIMLI 320 ide ira bra das de Sa eerte dd 320 reia o a da a dd 321 makfile or makefile 2 60 0 cee ee eR e e ee e 321 aded P T 322 Open pro ect e beveekkeRMeSDA ie dao 322 A ee be por det qes ede eal Vac etes ADR rete qi eared ADI Duabus 323 A ain a giana dans aah uae aN a Geabtea dee eee 327 n n 2ci todd coartada edi 327 Table of Contents UMO17103 0207 xii ZiLOG Developer Studio Il ZNEO User Manual np 328 qnx DTT 328 TOSCE oc rn 328 SAVE frees sue dead nha Gee bee bad qe hoped eR ned des eR 328 SCUCONME 4 ono oii e d he oki dace qut taces a d
66. Size T 0000 1 0 12 06 2005 Top Size T 0001 1 0 12 06 2005 Top Size T 0002 1 0 12 06 2005 Top Size T 0003 Z 237 ZiLOG dh 8h 1 0 12 06 2005 16 57 59 Segment NEAR BSS R FFBOOS8 Segment NEAR DATA R FFB036 Module COMMONNEI C Library crtSD lib Version 1 0 1 Name Base Segment ei TEXT C 008460 Module COMMON FLASHO C Library chelpSD lib Version 16 59 45 Name Base Segment flash option0 segment T 0000 Module COMMON FLASH1 C Library chelpSD lib Version 16 59 45 Name Base Segment flash optionl segment T 0001 Module COMMON FLASH2 C Library chelpSD lib Version 16 59 45 Name Base Segment flash option2 segment T 0002 Module COMMON FLASH3 C Library chelpSD lib Version 16 59 45 Name Base Segment flash option3 segment T 0003 Module COMMON GETCHAR C Library crtSD lib Version Name Base Segment getchar TEXT C 008468 5 Using the Linker Locator C 008473 UMO17103 0207 238 ZiLOG Developer Studio Il ZNEO User Manual Z zZiLOG Module COMMON PRINT GLOBALS C Library crtSD lib Version 1 0 12 06 2005 16 58 01 Name Base Top Size Segment NEAR BSS R FFBO15 R FFBO35 21h Segment NEAR DATA R FFBO3F R FFBO42 4h Module COMMONNPRINT PUTCH C Library crtSD lib Version 1 0 12 06 2005 16 58 01 Segment t putch TEXT C 0084DA C 0084F5 1ch Module COMMON PRINT PUTROMSTRING C Library crtSD lib Version 1 0 12 06 2005 16 58 02 Segment mstring TEXT C 00
67. Synopsis include lt ctype h gt int toupper int c Returns If the argument is a lowercase letter the toupper function returns the corresponding uppercase letter if any otherwise the argument is returned unchanged Example char c a int a i toupper c va arg Expands to an expression that has the type and value of the next argument in the call The parameter ap is the same as the va list ap initialized by va start Each invocation of va arg modifies ap so that successive arguments are returned in turn The parameter type is a type name such that the type of a pointer to an object that has the specified type can be obtained simply by fixing a to type If type disagrees with the type of the actual next argument as promoted according to the default argument conversions into int unsigned int or double the behavior is undefined Synopsis include lt stdarg h gt type va arg va list ap type UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 395 zZiLOG Returns The first invocation ofthe va_arg macro after that ofthe va_start macro returns the value of the argument after that specified by parmN Successive invocations return the val ues of the remaining arguments in succession Example The function f1 gathers into an array a list of arguments that are pointers to strings but not more than MAXARGS arguments then passes the array as a single argument
68. Target Dialog Box 20 eee eens 82 Target Flash Settings Dialog Box 0 00 cece eee eee eee 84 Create New Target Wizard Dialog Box 00 0 cence eee eee 85 Target Copy or Move Dialog Box 2 0 0c eee eee esee 86 Setup Ethernet Smart Cable Communication Dialog Box 87 Setup USB Communication Dialog Box 0 asasaran 88 Save As Dialog BOX sede nek ead a 88 Select Configuration Dialog Box 00sec eee eee eee 90 Manage Configurations Dialog BOX 006 c eee eee ee 91 List of Figures List of Figures ZiLOG Developer Studio ll ZNEO User Manual Figure 70 Add Project Configuration Dialog Box 06 0 cece eee eee 9 Figure 71 Flash Loader Processor Dialog Box 0 00 esses 95 Figure 72 Show CRC Dialog Box 2 cece eee eee eens 99 Figure 73 Calculate Checksum Dialog Box 0 0 c cece eee eee eens 99 Figure 74 Calculate Checksum Dialog Box 0 0 e cee eee eee eee 100 Figure 75 Customize Dialog Box Toolbars Tab 0 000 e eee eee 101 Figure 76 New Toolbar Dialog Box 1 0 2 0 00 c cc eee eens 101 Figure 77 Customize Dialog Box Commands Tab 0000 eee eee 103 Figure 78 Options Dialog Box General Tab 000 0 104 Figure 79 Options Dialog Box Editor Tab 00 eee eee ee 105 Figure 80 Color Dialog Box 0 0 2 cece eee een eee 106 Fi
69. The type of an operand to a conditional expression was not arithmetic structure union or pointer type 111 Integer constant too large Reduce the size of the integer constant 112 Expression not compatible with function return type An attempt was made to return a value from function that cannot be promoted to the type defined by the function declaration 113 Function cannot return value of type array or function An attempt was made to return a value of type array or function 114 Structure or union member may not be of function type An attempt was made to define a member of structure or union that has type function 115 Cannot declare a typedef within a structure or union An attempt was made to declare a typedef within a structure or union 116 Illegal bit field declaration An attempt was made to declare a structure or union member that is a bit field and is syntactically incorrect 117 Unterminated quoted string Within a quoted string an end of line was encountered 118 Escape sequence ASCII code too large to fit in char The binary value of an escape sequence requires more than 8 bits of storage UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual Z 157 zZiLOG 119 Character not within radix An integer constant was encountered with a character greater than the radix of the constant 120 More than one character in string constant A string constant was encountered having more t
70. Updated values appear in red 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 288 zZiLOG The 0x prefix indicates that the values are displayed in hexadecimal format If you want the values to be displayed in decimal format select Hexadecimal Display from the con text menu NOTE Ifthe Watch window displays unexpected values deselect the Use Register Variables check box See Use Register Variables on page 63 Use the Watch window to do the following e Add New Variables on page 288 e Change Values on page 288 e Remove an Expression on page 288 e View a Hexadecimal Value on page 288 e View a Decimal Value on page 289 e View an ASCII Value on page 289 e View a NULL Terminated ASCII ASCIZ String on page 289 Add New Variables To add new variables in the Watch window use one of the following procedures e Click once on new watch in the Expression column type the expression and press the Enter key e Select the variable in the source file drag and drop it into the Watch window Change Values To change values in the Watch window do the following 1 In the window highlight the value you want to change 2 Type the new value and press the Enter key The changed value is displayed in red Remove an Expression To remove an expression from the Watch window do the following 1 In the Expression column click once on the expression you
71. Values on page 230 e Hexadecimal Numeric Values on page 231 e Or on page 231 e lt lt Shift Left on page 231 e gt gt Shift Right on page 231 e Subtract on page 231 e TOP OF on page 231 e Bitwise Exclusive Or on page 232 e Not on page 232 The following note applies to many of the lt expression gt commands discussed in this sec tion NOTE To use BASE TOP COPY BASE COPY TOP LOWADDR HIGHADDR LENGTH and FREEMEM lt expression gt commands you must have completed the calculations on the expression This is done using the SEQUENCE and ORDER commands Do not use an expression of the segment or space itself to locate the object in question UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual 227 zZiLOG Examples Correct example using segments SEQUENCE seg2 segl Calculate seg2 before segl OCATE segl AT TOP OF seg2 1 Do not do this cannot use expression of segl to locate segl OCATE segl AT TOP OF seg2 LENGTH OF segl Add The Add operator is used to perform the addition of two expressions Syntax lt expression gt lt expression gt 8 And The amp And operator is used to perform a bitwise amp of two expressions Syntax expression amp expression BASE OF The BASE OF operator provides the lowest used address of a group a
72. ZiLOG Developer Studio Il ZNEO User Manual zZiLOG e Groups A group is a collection of logical address spaces They are typically used for convenience in locating a set of address spaces together e Segments Each address space consists of various segments Segments are named logical partitions of data or code that form a continuous block of memory Segments with the same name residing in different modules are concatenated together at link time Segments are assigned to an address space and can be relocatable or absolute Relocatable segments can be randomly allocated by the linker absolute segments are assigned a physical address within its address space See Segments on page 168 for more information about using predefined segments defining new segments and attaching code and data to segments The linker performs the following functions Reads in relocatable object modules and library files and linker commands Resolves external references Assigns absolute addresses to relocatable segments of each address space and group Generates a single executable module to download into the target system Generates a map file INVOKING THE LINKER The linker is automatically invoked when your project is open and you click the Build but ton or Rebuild All button on the Build toolbar see Build Toolbar on page 18 The linker then links the corresponding object modules of the various source files in your project
73. a label 403 Symbol not a segment The segment has not been previously defined or is defined as some other symbol type 404 Illegal EQU The name used to define an equate has been previously defined or equates and label symbols in an equate expression have not been previously defined 405 Label not defined The label has not been defined either by an XREF or a label definition 406 Illegal use of XREF s symbol XDEF defines a list of labels in the current module as an external symbol that are to be made publicly visible to other modules at link time XREF specifies that a list of labels in the operand field are defined in another module UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual Z m ZiLOG 407 Illegal constant expression The constant expression is not valid in this particular context This error normally occurs when an expression requires a constant value that does not contain labels 408 Memory allocation error Not enough memory is available in the specified memory range 409 Illegal elif directive There is no matching if forthe elif directive 410 Illegal else directive There is no matching if forthe else directive 411 Illegal endif directive There is no matching if forthe endif directive 412 EOF encountered within an if End of file encountered within a conditional directive 416 Unsupported illegal directives General purpose error when the assem
74. addresses for the segments The actual copying of the data needs to be performed by the user code as shown above Assembly users can perform their own external interface setup in the startup code This can be made easier if you take advantage of some definitions provided by the Configure Target dialog box see Setup on page 82 An example can be found in the C startup provided in the installation under src boot common startupexs asm The ZDS IL IDE generates the following linker directives based on your settings in the Target Configure dialog box DEFINE EXTCT INIT PARAM c0 EFINE EXTCSO0 INIT PARAM 8012 EFINE _ EXTCS1 INIT PARAM 8001 EFINE _ EXTCS2 INIT PARAM 0000 EFINE _ EXTCS3 INIT PARAM 0000 EFINE _ EXTCS4 INIT PARAM 0000 o O O Og 6 Configuring Memory for Your Program UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 262 zZiLOG J G G l G O UU EFINE PFAF INIT EFINE PGAF NIT EFINE PDAF NIT EFINE PAAF NIT EFINE PCAF NIT EFINE PHAF NIT EFINE PKAF Hi H Ho H H H NIT EFINE EXTCS5 INIT PA PARAM PARAM PARAM PARAM PARAM PARAM PARAM 0000 SFE Sff Sff00 0000 0000 0300 SOf You can initialize the external interface registers based on these defines as part of your
75. an unsigned char in the initial n charac ters of the object pointed to by s Synopsis include lt string h gt void memchr const void s int c size t n Returns A pointer to the located character or a null pointer if the character does not occur in the object Example char pl char str COMPASS c p pl memchr str c sizeof char memcmp Compares the first n characters of the object pointed to by s2 to the object pointed to by s1 Synopsis finclude string h int memcmp const void s1 const void s2 size t n Returns An integer greater than equal to or less than zero according as the object pointed to by s1 is greater than equal to or less than the object pointed to by s2 Example char s1 COMPASS char s2 IDE int res res memcmp s1 s2 sizeof char UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 371 zZiLOG memcpy Copies n characters from the object pointed to by s2 into the object pointed to by s1 If the two regions overlap the behavior is undefined Synopsis finclude lt string h gt void memcpy void sl const void s2 size t n Returns The value of s1 Example char s1 10 char s2 10 COMPASS memcpy s1 s2 8 memmove Moves n characters from the object pointed to by s2 into the object pointed to by s1 Copying between objects that overlap takes place correctly Synopsis include lt string
76. and s nvrblock is in RAM COPY BASE The COPY BASE operator provides the lowest used address of a copy segment group or address space The value of COPY BASE is treated as an expression value Syntax COPY BASE OF lt name gt lt name gt can be either a group address space or segment COPY TOP The COPY TOP operator provides the highest used address of a copy segment group or address space The value of COPY TOP is treated as an expression value Syntax COPY TOP OF lt name gt lt name gt can be a group address space or segment I Divide The Divide operator is used to perform division UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual L z ZiLOG Syntax lt expression gt lt expression gt FREEMEM The FREEMEM operator provides the lowest address of unallocated memory of a group address space or segment The value of FREEMEM is treated as an expression value Syntax FREEMEM OF lt name gt lt name gt can be a group address space or segment HIGHADDR The HIGHADDR operator provides the highest possible address of a group address space or segment The value of HIGHADDR is treated as an expression value Syntax HIGHADDR OF lt name gt lt name gt can be a group address space or segment LENGTH The LENGTH operator provides the length of a group address space or segment The value of LENGTH is treated as an expression
77. argument is negative A range error occurs if the argument is zero Synopsis include lt math h gt double log double x float logf float x Returns The natural logarithm Example double x 2 56 double y y log x log10 log10f Computes the base ten logarithm of x A domain error occurs if the argument is negative A range error occurs if the argument is zero Synopsis include lt math h gt double log10 double x float logl0f float x Returns The base ten logarithm Example double x 2 56 double y y log10 x longjmp Restores the environment saved by the most recent call to set jmp in the same invocation of the program with the corresponding jmp buf argument If there has been no such call or if the function containing the call to set jmp has executed a return statement in the interim the behavior is undefined UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 369 zZiLOG All accessible objects have values as of the time 1ongjmp was called except that the values of objects of automatic storage class that do not have volatile type and have been changed between the set jmp and long jmp call are indeterminate As it bypasses the usual function call and returns mechanisms the 1ong3jmp function exe cutes correctly in contexts of interrupts signals and any of their associated functions However if the 1o0ngjmp function is invoked from a n
78. as all text on the same line as the final delimiter You must not use a label on this directive Synonym COMMENT Syntax COMMENT delimiter text delimiter Example COMMENT An insightful comment of great meaning This text is a comment delimited by a dollar sign and spanning multiple source lines The dollar sign is a delimiter that marks the line as the end of the comment block Defines to the assembler which member of the ZNEO family is targeted From this direc tive the assembler can determine which instructions are legal as well as the locations of the interrupt vectors within the ROM space VECTOR segment NOTE The CPU directive is used to determine the physical location of the interrupt vectors Syntax cpu definition gt CPU cpu name Example CPU Z16F2811 Data Directives Data directives allow you to reserve space for specified types of data UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll Syntax data directive gt type value list type gt DB gt DL gt DW gt DW24 gt BLKB gt BLKL gt BLKW lt value_list gt gt lt value gt gt lt value _list gt lt value gt lt value gt gt lt expression gt lt string_const gt BLKB Declaration Type ZNEO User Manual Z 183 zZiLOG Syntax BLKB count lt init_value gt Examples BLKB 16 Allocate 16 uninitialized bytes BLKB
79. as highest allocated RAM address far heaptop Top of heap for large model is set as highest address of ERAM near heaptop Top of heap for small model is set as highest address of RAM SYS CLK FREQ System clock frequency as selected in Configure Target dialog box _SYS_CLK_SRC System clock source as selected in Configure Target dialog box Sample Linker Command File The sample default linker command file for large compilation model is discussed here as a good example of the contents of a linker command file in practice and how the linker com mands it contains work to configure your load file The default linker command file is automatically generated by the ZDS II IDE If the project name is test zdspro for example the default linker command file name is test debug 1linkcmd You can add 3 Using the ANSI C Compiler UMO17103 0207 148 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG additional directives to the linking process by specifying them in the Additional Linker Directives dialog box see Additional Directives on page 68 Alternatively you can define your own linker command file by selecting the Use Existing button see Use Exist ing on page 69 The most important of the linker commands and options in the default linker command file are now discussed individually in the order in which they are typically found in the linker command file FORMAT OMF695 INTEL32
80. asm 16 59 45 Name Segment VECTORS 6C EXTERNAL DEFINITIONS chelpSD lib Version 1 0 12 06 2005 Base Top Size T 0064 T 0067 4h chelpSD lib Version 1 0 12 06 2005 Base Top Size T 0068 T 006B 4h chelpSD lib Version 1 0 12 06 2005 Base Top Size T 006C T 006F 4h Address Module Segment Symbol 0 exit print buff print fmt print leading char print len print out print putch print putromstring print sputch print uputch print xputch EXTCSO INIT PARAM EXTCS1 INIT PARAM EXTCS2 INIT PARAM EXTCS3 INIT PARAM EXTCS4 INIT PARAM 5 Using the Linker Locator 00000000 User Defined E R FFBO15 PRINT GLOBALS NEAR BSS R FFB022 PRINT G R FFBO33 OBALS N GLOBALS Lr AR BSS AR BSS PRINT Ej R FFBO32 PRINT GLOBALS NEAR BSS R FFB034 PRINT G C 0084DA PRINT PUTCH C 0084AC C 008494 PRINT SPUTCH C 008474 PRINT UPUTCH OBALS N Lr AR BSS t putch TEXT PRINT PUTROMSTR mstring TEXT Sputch TEXT uputch TEXT R FFBO3F PRINT GLOBALS NEAR DATA 00008012 User Defined 00008001 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 244 7 ZiLOG EXTCS5_INIT_PARAM 00000000 User Defined EXTCT_INIT_PARAM 000000C0 User Defi
81. be supplied from the target application board NOTE The Clock Frequency value is used even when the Simulator is selected as the Debug Tool The frequency is used when converting clock cycles to elapsed times in seconds which can be viewed in the Debug Clock window when running the simulator 5 Click Configure Flash The Target Flash Settings dialog box is displayed 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 84 zZiLOG Target Flash Settings Internal Flash M Intemal Flash External Flash Micron AMD a STMicro E Atmel KR Intel Custom Figure 62 Target Flash Settings Dialog Box Select the Internal Flash check box if you want to use internal Flash The internal Flash memory configuration is defined in the CpuFlashDevice xml file The device is the currently selected microcontroller or microprocessor If you want to use external Flash select which Flash devices you want to program The Flash devices are defined in the FlashDevice xml file The device is the current external Flash device s memory arrangement The external Flash device options are predefined Flash memory arrangements for specific Flash devices such as the Micron MT28F008B3 The Flash Loader uses the external Flash device option arrangements as a guide for erasing and loading data to the appropriate blocks of Flash memory In the External Flash Base field type where you want
82. bits to the right the value is to be shifted Syntax lt expression gt gt gt lt expression gt Subtract The Subtract operator is used to subtract one expression from another Syntax expression expression TOP OF The TOP OF operator provides the highest allocated address of a group address space or segment excluding any segment copies when lt name gt is a segment The value of TOP OF Is treated as an expression value 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 232 Syntax TOP OF lt name gt lt name gt can be a group address space or segment If you declare a segment to begin at TOP OF another segment the two segments share one memory location TOP OF give the address of the last used memory location in a segment not the address of the next available memory location For example LOCATE segment2 at TOP OF segmentl starts segment2 at the address of the last used location of segment1 To avoid both seg ments sharing one memory location use the following syntax LOCATE segment2 at TOP OF segmentl 1 Bitwise Exclusive Or The operator is used to perform a bitwise exclusive OR on two expressions Syntax expression expression Not The Not operator is used to perform a one s complement of an expression Syntax expression SAMPLE LINKER MAP FILE IEEE 695 OMF Linker Version 6 20 05120604 Copyri
83. command 316 debugtool list script file command 316 debugtool save script file command 316 debugtool set script file command 317 debugtool setup script file command 317 Dec button 97 Decimal numbers in assembly 177 Decimal numeric values 230 Decimal values viewing 289 Default Type of Char drop down list box 66 DEFINE 169 185 218 Defines field 57 defines script file command 317 Delete button 18 86 delete config script file command 318 Delete Source Target After Copy check box 86 Developer s environment memory requirements xxiii menus 34 software installation 1 system requirements xxiii toolbars 16 tutorial 1 DI 136 Diagnostics function 353 Directives COMMENT 182 ENDSTRUCT 193 ENDWITH 196 SSHORT STACK FRAME 189 STRUCT 193 TAG 194 UNION 196 WITH 196 ALIGN 181 BLKB 183 BLKL 183 Index BLKW 183 conditional assembly directives 198 CPU 182 data 182 DB 184 DEFINE 169 185 definition 181 DL 184 DS 186 DW 184 185 END 186 ENDMACRO 200 EQU 187 EXTERN 204 IF 198 IFDEF 199 IFMA 200 IFSAME 199 in assembly 173 181 INCLUDE 187 LIST 188 MACEXIT 203 MACRO 200 MAXBRANCH 300 NOLIST 188 ORG 188 SCOPE 204 SEGMENT 169 189 TITLE 190 VAR 190 VECTOR 191 XDEF 192 XREF 192 204 Disable All Breakpoints button 24 Disable All button 49 295 Disable Breakpoint command 296 Disable Warning on Flash Optionbits Program ming check box 108 Disassembly window 291 Di
84. complete for a given purpose A character set might include punctuation marks or other symbols CIEF Clear IE Flag clock A specific cycle designed to time events used to synchronize events in a system CLR Clear CMOS Complementary Metal Oxide Semiconductor A type of integrated circuit used in processors and for memory compile 1 To translate a computer program expressed in a high level language into a program expressed in a lower level language such as an intermediate language assembly language or a machine language 2 To prepare a machine language program from a computer program written in another programming language by making use of the overall logic structure of the program or by generating more than one computer instruction for each symbolic statement as well as performing the function of an assembler compiler A computer program for compiling COPF Clear Overflow Protection Flag UMO17103 0207 Glossary ZiLOG Developer Studio ll ZNEO User Manual 401 zZiLOG CPU Abbreviation for Central Processing Unit 1 The portion of a computer that includes circuits controlling the interpretation and execution of instructions 2 The portion of a computer that executes programmed instructions performs arithmetic and logical operations on data and controls input output functions D debug To detect trace and eliminate mistakes DI Disable interrupt E El Enable interrupt emulation The process of dupl
85. configure the device These Flash option bytes can be set in C using the following syntax tinclude lt zneo h gt LASH OPTIONO val FLASH OPTIONI val FLASH OPTION2 val FLASH OPTION3 val nj ll where e FLASH OPTIONO is the Flash option byte at address 0 FLASH OPTIONI is the Flash option byte at address 1 FLASH OPTION is the Flash option byte at address 2 e FLASH OPTIONS is the Flash option byte at address 3 For example tinclude zneo h FLASH OPTIONO OxFF FLASH OPTION1 OxFF FLASH OPTION2 OxFF FLASH OPTION3 OxFF void main void This example sets the Flash option bytes at address 0 1 2 and 3 as OxFF The Flash option bytes can be written only once in a program They are set at load time When you set these bytes you need to make sure that the settings match the actual hardware For more information see the product specification specific to your device Supported New Features from the 1999 Standard The ZNEO compiler implements the following new features introduced in the ANSI 1999 standard also known as ISO IEC 9899 1999 e C Style Comments on page 125 e Trailing Comma in Enum on page 126 e Empty Macro Arguments on page 126 Long Long Int Type on page 126 C Style Comments Comments preceded by and terminated by the end of a line as in C are supported 3 Using the ANSI C Compiler UMO17103 0207 126 ZiLOG Developer Studio Il ZNEO User Ma
86. define far heaptop highaddr of ERAM define far stack highaddr of ERAM define near heapbot top of RAM define near heaptop highaddr of RAM define near stack highaddr of RAM These are the linker symbol definitions described in Table 7 They allow the compiler to know the bounds of the different memory areas that must be initialized in different ways by the C startup module c NsampleNtest C PROGRA 1 ZiLOG ZD3E4C 1 0 lib startupL obj foo obj C PROGRA 1 ZiLOG ZD3E4C 1 0 lib chelpLD lib A C PROGRA 1 ZiLOG ZD3E4C 1 0 lib crtLD lib C PROGRA 1 ZiLOG ZD3E4C 1 0 lib fpLD 1lib This final command shows that in this example the linker output file is named test lod The source object file foo obj is to be linked with the other modules that are required to make a complete executable load file In this case those other modules are the C startup modules for the large model startupl obj the C helper library for the large model with debug chelpld 1ib the C run time library for the large model with debug crt1d 1ib and the floating point library for that same configuration pld lib An important point to understand in using the linker is that if you use the ZiLOG default version of the C run time library the linker will link in only those functions that are actu ally called in your program This is because the ZiLOG default library is organized with only one functio
87. different extension e lt source gt 1st contains a readable version of the source and object code generated by the assembler The assembler creates lt source gt 1st unless you deselect the Generate Listing File Ist check box in the Assembler page of the Project Settings dialog box See Generate Assembly Listing Files 1st on page 57 e source obj is an object file in relocatable OMF695 format The assembler creates lt source gt obj N Caution Do not use source input files with 1st or ob extensions The assembler does not assemble files with these extensions and therefore the data contained in the files is lost Source Listing lst Format The listing file name is the same as the source file name with a 1st file extension Assembly directives allow you to tailor the content and amount of output from the assembler UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 171 zZiLOG Each page of the listing file 1st contains the following Heading with the assembler version number Source input file name e Date and time of assembly Source lines in the listing file are preceded by the following e Include level e Plus sign if the source line contains a macro e Line number e Location of the object code created e Object code The include level starts at level A and works its way down the alphabet to indicate nested includes The format and conten
88. e select port on page 139 e SET VECTOR on page 140 e TDI on page 141 DI DI is a ZiLOG intrinsic function that disables all interrupts This function is an intrinsic function and is inline expanded by default If the reduceopt compiler option is selected then this function is not inline expanded and is implemented as a regular function instead Synopsis tinclude lt zneo h gt intrinsic void DI void Example tinclude lt zneo h gt UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual zZiLOG 137 void main void DI Disable interrupts El ET is a ZiLOG intrinsic function that enables all interrupts This function is an intrinsic function and is inline expanded by default If the reduceopt compiler option is selected then this function is not inline expanded and is implemented as a regular function instead Synopsis tinclude lt zneo h gt intrinsic void El void Example tinclude lt zneo h gt void main void EI Enable interrupts getch getch is a ZILOG function that waits for the next character to appear at the serial port and returns its value This function does not wait for end of line to return as getchar does getch does not echo the character received Synopsis include lt sio h gt char getch void Returns The next character that is received at the selected UART Example char c
89. example loadmem SPACE RDATA FORMAT BIN c temp file bin STARTADDRESS 20 loadmem SPACE ROM FORMAT HEX c temp file hex loadmem SPACE ROM FORMAT TEXT c temp file txt STARTADDRESS 1000 log The log command manages the IDE s logging feature The log command can take one of three forms log pathN filename APPEND sets the path and file name for the log file If APPEND is not provided an existing log file with the same name is truncated when the log is next activated e log on activates the logging of data e log off deactivates the logging of data For example log buildall log log on log off makfile or makefile The makf ile and makefile commands export a make file for the current project The syntax can take one of two forms makfile pathN file name gt makefile lt path file name gt If path is not provided the current working directory is used For example makfile myproject mak makefile c projects test mak Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 322 7 zZiLOG new project The new project command creates a new project designated by project_name target and the type supplied If the full path is not supplied the current working directory is used By default existing projects with the same name are replaced Use NOREPLACE to prevent the overwriting of existing projects The synt
90. function The term printing character refers to a member of a set of characters each of which occupies one printing position on a display device The term control character refers to a member of a set of characters that are not printing characters Character Testing int isalnum int c Tests for alphanumeric character int isalpha int c Tests for alphabetic character int iscntrl int c Tests for control character int isdigit int c Tests for decimal digit Appendix C C Standard Library int isgraph int c int islower int c int isprint int c int ispunct int c int isspace int c int isupper int c int isxdigit int c ZiLOG Developer Studio ll ZNEO User Manual 341 zZiLOG Tests for printable character except space Tests for lowercase character Tests for printable character Tests for punctuation character Tests for white space character Tests for uppercase character Tests for hexadecimal digit Character Case Mapping int tolower int c Tests character and converts to lowercase if uppercase int toupper int c Tests character and converts to uppercase if lowercase Limits limits h The lt limits h gt header defines macros that expand to various limits and parameters Macros CHAR BIT Maximum number of bits for smallest object that is not a bit field byte CHAR MAX Maximum value for an object of type char CHAR MIN Minimum value for an object of type char INT MAX
91. greater than equal to or less than the string pointed to by s2 Appendix C C Standard Library UMO17103 0207 386 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Example char s1 Production char s2 Programming int res res strcmp s1 s2 strcpy Copies the string pointed to by s2 including the terminating null character into the array pointed to by s1 If copying takes place between objects that overlap the behavior is unde fined Synopsis finclude lt string h gt char strcpy char sl const char s2 Returns The value of s1 Example char s1 80 s2 s2 strcpy sl Production strcspn Computes the length of the initial segment of the string pointed to by s1 that consists entirely of characters not from the string pointed to by s2 The terminating null character is not considered part of s2 Synopsis finclude lt string h gt size t strcspn const char sl const char s2 Returns The length of the segment Example size t pos char s1 xyzabc char s2 abc pos strcspn s1 s2 UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 387 zZiLOG strlen Computes the length of the string pointed to by s Synopsis finclude lt string h gt size t strlen const char s Returns The number of characters that precede the terminating null character Example char s1 COMPASS size t i i strlen s1 str
92. handling 340 diagnostics 340 error reporting 339 floating point 342 general utilities 348 input 347 limits 341 location 134 338 mathematics 343 nonlocal jumps 346 nonstandard 134 nonstandard input functions 135 nonstandard output functions 135 output 347 reserved words 134 standard 337 standard definitions 339 string handling 350 variable arguments 346 HEADING command 219 Help menu 109 About 110 Help Topics 109 Technical Support 110 Hex button 97 Hex code size of 247 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 419 zZiLOG Hex file creating 247 size of 247 hex file extension 80 Hexadecimal Display check box 108 Hexadecimal numbers in assembly 177 in linker expressions 231 viewing 288 HIGHADDR operator 229 HUGE VAL macro 343 348 Hyperbolic cosine computing 358 Hyperbolic functions 345 Hyperbolic sine computing 382 Hyperbolic tangent calculating 393 I IDE definition 16 IEEE 695 format 80 219 IF directive 198 IFDEF directive 199 IFMA directive 200 202 IFSAME directive 199 In File Types list box 47 In Folder list box 47 INCLUDE directive 187 include directive 60 338 Include Serial in Programming check box 97 Included in Project button 72 Includes field 57 Increment Dec field 97 init uart function 137 Input output macro 347 Insert Breakpoint command 293 Insert Spaces button 105 Insert Remove Breakpoint button 20 24 293 Inserting breakpoints 293 Installation
93. in 64K of code space so that no branches of more than a 16 bit offset are required Use the directive to override the command line option to impose either a stricter or more lenient requirement metrics Keeps track of how often an instruction is used This is a static rather than a dynamic measure of instruction frequency name Displays the name of the source file being assembled nodebug Does not create a debug information file for the symbolic debugger This is the default setting nogenobj Does not generate an object file with the obj extension The default setting is genobj noigcase Enables case sensitivity of user defined symbols The default setting is igcase nolist Does not create a list file The default setting is 1 ist nolistmac Does not expand macros in the output listing The default setting is Listmac noquiet Displays title and other information This is the default nosdiopt Does not perform span dependent optimizations All size optimizable instructions use the largest instruction size The default is sdiopt nowarns Suppresses the generation of warning messages to the screen and listing file A warning count is still maintained The default is to generate warning messages pagelength n Sets the new page length for the list file The page length must immediately follow the with no space between The default is 56 For example pagelength 60 pagewidth n Set
94. in RAM address space The address of a local or parameter is a 16 bit address The global variables can be manually placed into the ERAM ROM or EROM address space by using the Far Rom and Erom address specifiers respectively The local variables nonstatic and parameters are always allocated in RAM address space and any address specifiers if used on them are ignored Use of the small memory model does not impose any restriction on your code size The limitations of the small model are due to the somewhat limited amount of 16 bit addressable RAM Current ZNEO CPU parts offer up to 4KB of internal RAM and the ZDS II GUI restricts the total RAM linker address space internal and external to 16KB If the local data and parameters exceed the available RAM size then the small memory model cannot be used If the local data and parameters are within the RAM size but along with global data they exceed the RAM size then the small model can still be used but only by selectively placing the global data in the extended RAM ERAM address space using the Far keyword Because ERAM is always located in external memory this solution requires adding external memory to your system Large memory model In the large memory model global variables are allocated in the ERAM address space The address of these variables is 32 bits The locals and parameters are allocated on stack which is located in ERAM address space The address of a local or parameter
95. in the Address Hex field Select the number of bytes that you want the serial number to occupy in the Bytes drop down list box Type the decimal interval that you want the serial number incremented by in the Increment Dec field If you want the serial number to be decremented type in a negative number After the current serial number is programmed the serial number is then incremented or decremented by the amount in the Increment Dec field Select the Erase Before Flashing check box This option erases the Flash before writing the serial number Click Burn Serial to write the serial number to the current device or click Program or Program and Verify to program the Flash memory with the specified hex file and write the serial number 15 If you want to check a serial number that has already been programmed at an address do the following a b Select the Enable check box Type the address that you want to read in the Address Hex field 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 98 zZiLOG c Select the number of bytes to read from Bytes drop down list box d Click Read Serial to check the serial number for the current device 16 Program the Flash memory by clicking one of the following buttons Click Program to write the hex file to Flash memory and perform no checking while writing Click Program and Verify to write the he
96. in the format Mmm dd yyyy a character string literal where the names of the months are the same as those generated by the asctime function and the first character of dd is a space character if the value is less than 10 FILE This macro expands to the current source file name a string literal LINE This macro expands to the current line number a decimal constant _ STDC This macro is defined as the decimal constant and indicates conformance with ANSI C TIME This macro expands to the compilation time in the format hh mm ss a string literal None of these macro names can be the subject of a define or a tundef preprocessing directive The values of these predefined macros except for LINE and FILE remain constant throughout the translation unit The following additional macros are predefined by the ZNEO C Compiler CONST IN ROM _ MODEL UNSIGNED CHARS _ _ ZDATE ZILOG ZNEO This macro indicates that the const variables are placed in ROM This macro which is optional in some other ZiLOG processor architectures must always be defined for the ZNEO This macro indicates the memory model used by the compiler as follows 0 Small Model 3 Large Model This macro is defined if the plain char type is implemented as unsigned char This macro expands to the build date of the compiler in the format YYYYMMDD For example if the compiler were built on May
97. in which ZiLOG Developer Studio was installed By default this would be C Program FilesVZiLOGNZDSII ZNEO version where lt version gt might be 4 11 0 or 540 50 STANDARD HEADER FILES Each library function is declared in a header file The header files can be included in the source files using the 4 include preprocessor directive The header file declares a set of related functions any necessary types and additional macros needed to facilitate their use Header files can be included in any order each can be included more than once in a given scope with no adverse effect Header files need to be included in the code before the first reference to any of the functions they declare or types and macros they define The following sections describe the standard header files UMO17103 0207 Errors lt errno h gt on page 339 Standard Definitions lt stddef h gt on page 339 Diagnostics lt assert h gt on page 340 Character Handling lt ctype h gt on page 340 Limits lt limits h gt on page 341 Floating Point lt float h gt on page 342 Mathematics lt math h gt on page 343 Nonlocal Jumps lt setjmp h gt on page 346 Variable Arguments lt stdarg h gt on page 346 Input Output lt stdio h gt on page 347 General Utilities lt stdlib h gt on page 348 String Handling lt string h gt on page 350 Appendix C C Standard Library ZiLOG Developer Studio ll Z
98. in which they are located C Program Setup This is the default setup provided by the development tools You do not have to perform any additional steps to achieve this configuration A point to note is that ifthe C program is a large model program the data and stack reside in ERAM by default so selecting the large model is not appropriate unless the target has external random access memory that you have configured in the target setup and added to the ERAM linker address range Assembly Program Setup As an assembly user you can choose either to use the default segments or to define and use your own segments in various address spaces To avoid problems you need to observe the following guidelines to achieve the same configuration as that used in the default C program configuration Locate the reset vector routine in the internal memory portion of ROM For example vector reset startup define ROMSEG space ROM org 70 segment ROMSEG Startup startup code here any external memory interface initialization should be done here any RAM ERAM data copying should be done here Locate the rest of the executable program in EROM For example segment CODE program code goes here e Locate the initialized constant data in ROM EROM Only allocate space for data in RAM ERAM using the DS assembler directive and make sure to not perform any initializations using the DB DW DL directive for such data Any initializ
99. int c Example int r char c 4 r isdigit c isgraph Tests for any printing character except space Synopsis include lt ctype h gt int isgraph int c Example int r char c r isgraph c islower Tests for any lowercase letter a to Z Synopsis include lt ctype h gt int islower int c Example int r char c a r islower c UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 365 zZiLOG isprint Tests for any printing character including space Synopsis include lt ctype h gt int isprint int c Example int r char Gs 1 r isprint c ispunct Tests for any printing character except space or a character for which isalnum is true Synopsis include lt ctype h gt int ispunct int c Example int r char c a r ispunct c isspace Tests for the following white space characters space form feed new line n carriage return v horizontal tab t or vertical tab v Synopsis finclude lt ctype h gt int isspace int c Example int x char c r isspace c Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 366 zZiLOG isupper Tests for any uppercase letter A to Z Synopsis include lt ctype h gt int isupper int c Example int r char c a r isupper c isxdigit labs
100. int ptr no 0 if n ptrs MAXARGS n ptrs MAXARGS va start ap n ptrs while ptr no lt n ptrs array ptr no va arg ap char va end ap f2 n ptrs array Each call to f1 has in scope the definition of the function of a declaration such as void El Its ses va_start Is executed before any access to the unnamed arguments The parameter ap points to an object that has type va_list The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function defini tion the one just before the The va start macro initializes ap for subsequent use by va_arg and va end Synopsis include lt stdarg h gt void va start va list ap parmN Example The function f1 gathers into an array a list of arguments that are pointers to strings but not more than MAXARGS arguments then passes the array as a single argument to function f2 The number of pointers is specified by the first argument to fl include lt stdarg h gt extern void f2 int n char arrayl define MAXARGS 31 void fl int n ptrs 1 va list ap char array MAXARGS int ptr no 0 if n ptrs MAXARGS n ptrs MAXARGS UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual L ar ZiLOG va_start ap n_ptrs while ptr_no lt n ptrs array ptr_no va arg ap char va_end ap f2 n ptrs array Each call to f1 h
101. is a predefined configuration of defaults set to enable the debugging of program code For more information on project configurations such as adding your own configuration see Set Active Configuration on page 90 Wi Project Settings Configuration Debug hd ile Assembler fal 5 RES CPU Family Z16F Series E Listing Files CPU Z16F2811AL m h Preprocessor Build Si Advanced lv Show aminas El me V Generate Debug Information Commands 33 Objects and Libraries Intermediate Files Directory Address S iis pus C Program Files ZiLOG ZDSII_ZNEO_4 11 0 sampl 3 Output Eh Debugger Cae Hop Figure 8 General Page of the Project Settings Dialog Box 3 Click on the Assembler page 1 Getting Started UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 10 zZiLOG 4 Make sure that the Generate Assembly Listing Files Ist check box is selected See Figure 9 Wi Project Settings Configuration Debug m Sak General H El C Sk Code Generation ils Listing Files Defines 3 Preprocessor zi BF2811AL 1 216F_SERIES 1 SBR Advanced fig Linker Listing Files E Commands V Generate Assembly Listing Files Ist 3 Objects and Libraries Expand Macros Page Width go SBR Address Spaces 3 Warnings Output Debugger Cancel Help Figure 9 Assembler Page of the Project Settings Dialog Box 5 Click on the Code Generation page UMO17103 0207 1 Getting Start
102. is present In the preceding example the backslash at the end of the first line allows the lt module list gt to extend over several lines in a linker command file The backslash to continue the lt module list gt over multiple lines is not supported when this command is entered on the DOS command line CHANGE NOTE The CHANGE command is used to rename a group address space or segment The CHANGE command can also be used to move an address space to another group or to move a seg ment to another address space Syntax CHANGE lt name gt lt newname gt lt name gt can be a group address space or segment lt newname gt is the new name to be used in renaming a group address space or segment the name of the group where an address space is to be moved or the name of the address space where a segment is to be moved The linker recognizes the special space NULL NULL is not one of the spaces that an object file or library contains in it Ifa segment name is changed to NULL using the CHANGE command to the linker the segment is deleted from the linking process This can be useful if you need to link only part of an executable or not write out a particular part of the executable The predefined space NULL can also be used to prevent initialization of data while reserving the segment in the original space using the COPY command See also the examples for the COPY command page 217 Examples To change the na
103. like spaces and tabs Find Ctrl F To find a specific value in the designated file Find Again F3 To repeat the previous search Replace Ctrl H To replace a specific value to the designated file Go to Line Ctrl G To jump to a specified line in the current file Toggle Bookmark Ctrl F2 To insert a bookmark in the active file for the line where your cursor is located or to remove the bookmark for the line where your cursor is located Next Bookmark F2 To position the cursor at the line where the next bookmark in the active file is located The search for the next bookmark does not stop at the end of the file the next bookmark might be the first bookmark in the file Previous Bookmark Shift F2 To position the cursor at the line where the previous bookmark in the active file is located The search for the previous bookmark does not stop at the beginning of the file the previous bookmark might be the last bookmark in the file Remove All Ctrl Shift F2 To delete all of the bookmarks in the currently loaded Bookmarks project Project Menu Shortcuts There is one shortcut for the options on the Project menu Shortcut Alt F7 Option Description Settings To display the Project Settings dialog box Build Menu Shortcuts These are the shortcuts for the options on the Build menu Option Shortcut Build F7 Description To build your file and or project Stop Build Ctrl Break To stop the build of y
104. ll ZNEO User Manual 49 zZiLOG Manage Breakpoints To view go to enable disable or remove breakpoints in an active project select Manage Breakpoints from the Edit menu You can access the dialog box see Figure 45 during Debug mode and Edit mode Breakpoints 001 C Program Files ZiLOG ZDSII_ZNEO_4 10 1 samples Go to Code 002 C Program Files ZiLOG ZDSII_ZNEO_4 10 1 samples 003 C Program Files ZiLOG ZDSII_ZNEO_4 10 1 samples Enable Al Disable All Remove Remove All 7 gt Cancel Figure 45 Breakpoints Dialog Box The Breakpoints dialog box lists all existing breakpoints for the currently loaded project A check mark in the box to the left of the breakpoint description indicates that the break point is enabled Go to Code To move the cursor to a particular breakpoint you have set in a file highlight the break point in the Breakpoints dialog box and click Go to Code Enable All To make all listed breakpoints active click Enable All Individual breakpoints can be enabled by clicking in the box to the left of the breakpoint description Enabled break points are indicated by a check mark in the box to the left of the breakpoint description Disable All To make all listed breakpoints inactive click Disable All Individual breakpoints can be disabled by clicking in the box to the left of the breakpoint description Disabled break points are indicated by an empty box to the left of the
105. loaded onto the target system and debugged using the ZiLOG Developer Studio II This section describes the following Linker Functions on page 213 Invoking the Linker on page 214 Linker Commands on page 215 Linker Expressions on page 226 Sample Linker Map File on page 232 Troubleshooting the Linker on page 246 Warning and Error Messages on page 248 LINKER FUNCTIONS The following five major types of objects are manipulated during the linking process Libraries Object libraries are collections of object modules created by the Librarian Modules Modules are created by assembling a file with the assembler or compiling a file with the compiler and then assembling it Address spaces Each module consists of various address spaces Address spaces correspond to either a physical or logical block of memory on the target processor For example a Harvard architecture that physically divides memory into program and data stores has two physical blocks each with its own set of addresses Logical address spaces are often used to divide a large contiguous block of memory in order to separate data and code In this case the address spaces partition the physical memory into two logical address spaces The memory range for each address space depends on the particular ZNEO family member For more information about address spaces on ZNEO see Address Spaces on page 168 5 Using the Linker Locator UMO17103 0207 214
106. name gt is either a group address space or segment name list is a comma separated list of group address space or segment names Example SEQUENCE NEAR DATA NEAR TEXT NEAR BSS NOTE If the sequenced segments do not all receive space allocation in the first pass through the available address ranges then the sequence of segments 1s not maintained SORT The SORT command sorts the external symbol listing in the map file by name or address order The default is to sort in ascending order by name Syntax SORT ADDRESS NAME gt IS ASCENDING UP DESCENDING DOWN 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 224 zZiLOG NAME indicates sorting by symbol name ADDRESS indicates sorting by symbol address Examples The following examples show how to sort the symbol listing by the address in ascending order SORT ADDRESS ASCENDING or SORT ADDRESS UP SPLITTABLE The SPLITTABLE command allows but does not force the linker to split a segment into noncontiguous pieces to fit into available memory slots Splitting segments can be helpful in reducing the overall memory requirements of the project However problems can arise if a noncontiguous segment is copied from one space to another using the COPY command The linker issues a warning if it is asked to COPY any noncontiguous se
107. numbered one Syntax IFMA arg number code body ELSE code body gt ENDIF Macros allow a sequence of one or more assembly source lines to be represented by a sin gle assembler symbol In addition arguments can be supplied to the macro in order to specify or alter the assembler source lines generated once the macro is expanded The fol lowing sections describe how to define and invoke macros Macro Definition A macro definition must precede the use of the macro The macro name must be the same for both the definition and the ENDMACRO line The argument list contains the formal argu ments that are substituted with actual arguments when the macro is expanded The argu ments can be optionally prefixed with the substitution character in the macro body During the invocation of the macro a token substitution is performed replacing the formal arguments including the substitution character if present with the actual arguments Syntax lt macroname gt MACRO lt arg gt lt arg gt lt macro_body gt ENDMAC RO lt macroname gt UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual Z 201 ZiLOG Example store MACRO regl reg2 reg3 ADD regl reg2 LD reg3 regl ENDMAC store NOTE The following example contains a subtle error BadMac MACRO a b c DL a b c MACEND BadMac Recall that b and c are reserved words on ZNEO used for co
108. reserved words are not case sensitive Assembler Rules Reserved Words The following list contains reserved words that the assembler uses You cannot use these words as symbol names or variable names Also reserved words are not case sensitive ALIGN ASCII ASCIZ ASECT ASG BES BLOCK BSS BYTE ship COPY Cpu DATA DEF define double DW24 ELIF ELSE ELSEIF EMSG ENDIF ENDM ENDMAC ENDMACRO ENDSTRUCT EQU EVAL EVEN EXTERN FCALL file float FRAME GLOBAL IF IFNTRUE INCLUDE INT LIST LONG MACEND MACRO MAXBRANCH MLIST MMSG MNOLIST NEWBLOCK NOLIST ORG PAGE PUBLIC REF SBLOCK SECT SET SHORT STACK FRAME SPACE STRING STRUCT 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il UMO17103 0207 4 Using the Macro Assembler ZNEO User Manual 174 Z a TAG TEXT trio USECT VAR VECTOR wmsg WORD word24 ALIGN ASCII ASCIZ ASECT B BFRACT BLKB BLKL BLKP BLKW BYTE C CHIP COMMENT COND CONDLIST CPU DB DBYTE DD DEFB DEFINE DF DL DS DW DW24 ELIF ELSE ELSEIF END ENDC ENDIF ENDM ENDMAC ENDMODULE ENDS EQ EQU EQUAL ERROR EXIT EXTERN EXTE
109. sequences for processing data controlling the configuration and controlling the operations Computer architecture may also include word lengths instruction codes and the interrelationships among the main parts of a computer or group of computers Arithmetic Logical Unit ALU the element that can perform the basic data manipulations in the central processor Usually the ALU can add subtract complement negate rotate AND and OR array 1 An arrangement of elements in one or more dimensions 2 In a programming language an aggregate that consists of data objects with identical attributes each of which may be uniquely referenced by subscription ASCII Acronym for American Standard Code for Information Interchange The standard code used for information interchange among data processing systems data communications systems and associated equipment in the United States ASM Assembler File assembly 1 The manufacturing process that converts circuits in wafer form into finished packaged parts 2 A short term for assembly language Glossary UMO17103 0207 400 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG B baud A unit of measure of transmission capacity The speed at which a modem can transmit data The number of events or signal changes that occur in one second Because one event can encode more than one bit in high speed digital communications baud rate and bits per second are not always synonymous especiall
110. space for both internal and external memory and I O Several address ranges within this space can be configured for various purposes providing a great deal of flexibility for creating a program configuration tailored to your target design and application needs The cost of this flexibility is that you need to understand how to set up the project settings and initialization to support your pre ferred configuration This chapter gives you the information needed to configure your project to support the programming model that best fits your needs This chapter covers the following topics e ZNEO Memory Layout on page 251 e Programmer s Model of ZNEO Memory on page 253 Program Configurations on page 258 The first two sections describe the relationship between the ZNEO CPU s physical mem ory layout and the functional address ranges available to the programmer Understanding this relationship is the key to correctly configuring your project The last section presents several examples of program configuration covering the configurations that are expected to be most commonly used ZNEO MEMORY LAYOUT The ZNEO CPU has a unique memory architecture with a unified 24 bit physical address space ZNEO CPU effective addresses are 32 bits wide but current devices ignore bits 31 24 The physical address space can address four types of memory and I O as fol lows Internal nonvolatile memory e Internal RAM Internal I O memory a
111. standard library to the contents of the standard headers lt float h gt lt limits h gt lt stdarg h gt and lt stddef h gt The ZNEO compiler release supports more of the standard library than is required of a freestanding implementation as listed in Run Time Library on page 133 The ZNEO C Compiler supports language extensions for easy programming of the ZNEO processor architecture which include support for different address spaces and interrupt function designation The language extensions are described in Language Extensions on page 114 This chapter describes the various features of the ZNEO C Compiler It consists of the fol lowing sections Language Extensions on page 114 e Type Sizes on page 126 Predefined Macros on page 127 Calling Conventions on page 128 Calling Assembly Functions from C on page 131 Calling C Functions from Assembly on page 132 e Command Line Options on page 133 e Run Time Library on page 133 Stack Pointer Overflow on page 142 e Startup Files on page 142 Segment Naming on page 143 e Linker Command Files for C Programs on page 144 e ANSI Standard Compliance on page 150 Warning and Error Messages on page 152 The ZNEO C Compiler is optimized for embedded applications in which execution speed and code size are crucial 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 114 zZiL
112. the Command Processor checksum ZiLOG Developer Studio ll ZNEO User Manual 315 zZiLOG The checksum command calculates the checksum of a hex file The following is the syn tax of the checksum command checksum lt filename gt For example if you use the following command checksum ledblink hex The file checksum for OxCEA3 crc the example is The CRC command performs a cyclic redundancy check CRC The syntax can take one of two forms ere calculates the CRC for the whole Flash memory cre STARTADDR ESS lt address gt ENDADDR ESS lt endaddress gt calculates the CRC for 4K increment blocks STARTADDRESS must be on a 4K boundary if the address is not on a 4K boundary ZDS II produces an error message rounded up to a 4K increment For example crc STARTADDRESS 1000 ENDADDR debugtool copy ENDADDRESS must be a 4K increment if the end address is not a 4K increment it is ESS 1FFE The debugtool copy command creates a copy of an existing debug tool with the given new name The syntax can take one of two forms e debugtool copy NAM creates a copy of the active debug tool named the value given for NAME e debugtool copy NAM debug tool name gt creates a copy of the SOURCE debug tool named the value given for NAME For example debugtool copy NAME Sim3 SOURC Appendix B Using the Command Processor E lt
113. the external Flash to start In the Units drop down list box select the number of Flash devices present For example if you have two devices stacked on top of each other select 2 in the Units list box Click OK to return to the Configure Target dialog box 6 Click OK Add Click Add to display the Create New Target Wizard dialog box Figure 63 UMO17103 0207 2 Using the Integrated Development Environment Create New Target Wizard This wizard will allow you to quickly create a new Target Simply enter a unique Target name and select the communication method that the debugger connects with the Target You can use the Finish button at any time to end the Target Creation Process The Cancel button will end the process without creating a Target ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Create Target Please enter a Target Name A V Place Target File in Project Directory Cancel Figure 63 Create New Target Wizard Dialog Box Type a unique target name in the field select the Place Target File in Project Directory check box if you want your new target file to be saved in the same directory as the cur rently active project and click Finish Copy Click Copy to display the Target Copy or Move dialog box Figure 64 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 86 zZiLOG Target Copy or Move Source
114. the following options e Add Files on page 52 e Remove Selected File s on page 52 Settings on page 52 Export Makefile on page 88 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 52 zZiLOG Add Files To add files to your project use the following procedure 1 From the Project menu select Add Files The Add Files to Project dialog box is displayed as shown in Figure 46 Use the Look In drop down list box to navigate to the appropriate directory where the files you want to add are saved Add Files To Project Look in 6 Tutorial v ex Eg E main c File name Files of type Source Files c asm s sre Cancel Figure 46 Add Files to Project Dialog Box Click on the file you want to add or highlight multiple files by clicking on each file while holding down the Shift key 4 Click Add to add these files to your project Remove Selected File s Select Remove Selected File s from the Project menu to delete highlighted files in the Project Workspace window Settings Select Settings from the Project menu to display the Project Settings dialog box which allows you to change your active configuration as well as set up your project Select the active configuration for the project in the Configuration drop down list box in the upper left corner of the Project Settings dialog box For your convenience
115. the input stream into the array pointed to by s until end of file is encountered or a new line character is read The new line character is discarded and a null character is written immediately after the last character read into the array Synopsis finclude lt stdio h gt char gets char s Returns The value of s if successful If a read error occurs during the operation the array contents are indeterminate and a null pointer is returned Example char r char buf 80 r gets buf UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 363 zZiLOG if r NULL No input NOTE The UART needs to be initialized using the ZILOG init uart function See init uart on page 137 isalnum Tests for any character for which isalpha or isdigit is true Synopsis include ctype h int isalnum int c Example ine char c a r isalnum c isalpha Tests for any character for which isupper or islower is true Synopsis finclude ctype h int isalpha int c Example int r char c a r isalpha c iscntrl Tests for any control character Synopsis finclude ctype h int iscntrl int c Example int r char c NULL r iscntrl c Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 364 zZiLOG isdigit Tests for any decimal digit Synopsis include lt ctype h gt int isdigit
116. these boundaries NOTE Refer to Linker Expressions on page 226 for the format to write an expression NODEBUG The NODEBUG command suppresses the linker from generatin option is applicable only if the executable file is IEEE 695 Syntax NODI NOMAP The NOMAP command suppresses generation of a link map file link map file EBUG Syntax NOMAP 5 Using the Linker Locator g debug information This The default is to generate a UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 222 7 zZiLOG NOWARN The NOWARN command suppresses warning messages The default is to generate warning messages Syntax NOWARN ORDER The ORDER command establishes a linking sequence and sets up a dynamic RANGE for contiguously mapped address spaces The base of the RANGE of each consecutive address space is set to the top of its predecessor Syntax ORDER lt name gt lt name list gt lt name gt can be a group address space or segment lt name list gt is a comma separated list of other groups address spaces or segments However a RANGE is established only for an address space Example ORDER GDATA GTEXT T where GDATA and GTEXT are groups In this example all address spaces associated with GDATA are located before that is at lower addresses than address spaces associated with GTEXT RANGE The RANGE command sets the lower and upper bounds of a gro
117. tinclude lt math h gt double cosh double x float coshf float x Returns The hyperbolic cosine value Example double y 1234 double x x cosh y div Computes the quotient and remainder of the division of the numerator numer by the denominator denom If the division is inexact the sign of the quotient is that of the mathematical quotient and the magnitude of the quotient is the largest integer less than the magnitude of the mathematical quotient UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual AE zZiLOG Synopsis tinclude lt stdlib h gt div t div int numer int denom Returns A structure of type div t comprising both the quotient and the remainder The structure contains the following members in either order int quot quotient int rem remainder Example int x 25 int y 3 div t t int aq int r t div x y q t quot r t rem exp expf Computes the exponential function of x A range error occurs if the magnitude of x is too large Synopsis include lt math h gt double exp double x float expf float x Returns The exponential value Example double y 1234 double x x exp y Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 360 zZiLOG fabs fabsf floor fmod Computes the absolute value of a floating point number x Synopsis t
118. to Target on page 92 Download Code on page 93 Verify Download on page 93 Stop Debugging on page 93 Reset on page 93 Go on page 93 Run to Cursor on page 93 Break on page 93 Step Into on page 93 Step Over on page 94 Step Out on page 94 Set Next Instruction on page 94 NOTE For more information on the Debugger see the Using the Debugger chapter on page 251 Connect to Target The Connect to Target command starts a debug session and initializes the communication to the target hardware This command does not download the software or reset to main Use this button to access target registers memory and so on without loading new code or to avoid overwriting the target s code with the same code This command is not enabled when the target is the simulator UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 93 zZiLOG Download Code The Download Code command downloads the executable file for the currently open project to the target for debugging The command also initializes the communication to the target hardware if it has not been done yet Use this command anytime during a debug ses sion This command is not enabled when the target is the simulator NOTE The current code on the target is overwritten Verify Download Select Verify Download from the Debug menu to determine download co
119. to define two functions with the same name 102 Constant integer expression expected A non integral expression was encountered where only an integral expression can be 103 Constant expression overflow In the process of evaluating a constant expression value became too large to be stored in 32 bits 104 Function return type mismatch for lt name gt A function prototype or function declaration was encountered that has a different result from a previous declaration 105 Argument type mismatch for argument lt name gt The type of an actual parameter does not match the type of the formal parameter of the function called 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 156 zZiLOG 106 Cannot take address of un subscripted array An attempt was made to take the address of an array with no index The address of the array is already implicitly calculated 107 Function call argument cannot be void type An attempt was made to pass an argument to a function that has type void 108 Identifier lt name gt is not a variable or enumeration constant name In a declaration a reference to an identifier was made that was not a variable name or an enumeration constant name 109 Cannot return a value from a function returning void An attempt was made to use a function defined as returning void in an expression 110 Expression must be arithmetic structure union or pointer type
120. user defined SHORT STACK FRAME The ZNEO LD and LEA instructions permit a special encoding when an argument is an offset from the frame pointer and the offset can be expressed as a signed 6 bit value 32 to 31 Normally the ZNEO assembler chooses the smaller encoding whenever possible otherwise the assembler chooses the more general 14 bit encoding 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 190 zZiLOG Also when the ZNEO assembler encounters a LINK instruction allocating more than 256 bytes of stack frame it silently substitutes a sequence of LINK and LEA or SUB instruc tions to obtain the desired result For especially tight code you might prefer to be alerted with an error message when an offset from the frame pointer on an LD or LEA instruction cannot be encoded in a 6 bit field or when the stack size requested in a LINK instruction cannot be encoded in the 8 bit field allowed for a LINK instruction The SHORT STACK FRAME directive supports such a preference Syntax shortfp directive gt SHORT STACK FRAME ON OFF Example SHORT STACK FRAME ON Turn short stack frames on Section of code that needs to be very tight SHORT STACK FRAME OFF Turn short stack frames off TITLE Causes a user defined TITLE to be displayed in the listing file The new title remains in effect until the next TITLE directive The operand must be a stri
121. want to remove 2 Press the Delete key to clear both columns View a Hexadecimal Value To view the hexadecimal values of an expression do the following 1 Type hex expression in the Expression column UMO017103 0207 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual L uo zZiLOG For example type hex tens NOTE You can also type just the expression for example type tens to view the hexadecimal value of any expression Hexadecimal format is the default 2 Press the Enter key The hexadecimal value displays in the Value column To view the hexadecimal values for all expressions select Hexadecimal Display from the context menu View a Decimal Value To view the decimal values of an expression do the following 1 Type dec expression in the Expression column For example type dec huns 2 Press the Enter key The decimal value displays in the Value column To view the decimal values for all expressions select Hexadecimal Display from the context menu View an ASCII Value To view the ASCII values of an expression do the following 1 Type ascii expression in the Expression column For example type ascii ones 2 Press the Enter key The ASCII value displays in the Value column View a NULL Terminated ASCII ASCIZ String To view the NULL terminated ASCII ASCIZ values of an expression do the following 1 Type asciz expression in the Expression column For example type asciz ones 2
122. 0 Label lt name gt is already declared An attempt was made to define two labels of the same name in the same scope 131 Label lt name gt not declared A goto statement was encountered with an undefined label 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 158 zZiLOG 132 continue statement not within loop body A continue statement was found outside a body of any loop 133 break statement not within switch body or loop body A break statement was found outside the body of any loop 134 case statement must be within switch body A case statement was found outside the body of any switch statement 135 default statement must be within switch body A default statement was found outside the body of any switch statement 136 Case value lt name gt already declared An attempt was made to declare two cases with the same value 137 Expression is not a pointer An attempt was made to dereference a value of an expression whose type is not a pointer 138 Expression is not a function locator An attempt was made to use an expression as the address of a function call that does not have a type pointer to function 139 Expression to left of or gt is not a structure or union An attempt was made to use an expression as a structure or union or a pointer to a structure or union whose type was neither a structure or union or a pointer to a structure or union 140 I
123. 01 Fill Memory Dialog Box 00 ccc cece eee eens 284 Figure 102 Save to File Dialog Box 1 0 ect enes 285 Figure 103 Load from File Dialog Box 2 0 0 cece cece eens 286 Figure 104 Show CRC Dialog Box 00 ccc cee eee 287 Figure 105 Watch Window 2 eee eee e 287 UMO17103 0207 xix ZiLOG Developer Studio ll ZNEO User Manual Figure 106 Locals Window sssssseeeeee Ie 290 Figure 107 Call Stack Window 00 cee cece ete ee 290 Figure 108 Symbols Window 000 0 cece eee eee 291 Figure 109 Disassembly Window 0 c cece eee eee eee eens 291 Figure 110 Simulated UART Output Window 2 0 00 eee eee eee 292 Figure 111 Setting a Breakpoint 00 0c eens 294 Figure 112 Viewing Breakpoints 0 00 0 c cece eee eens 294 UM017103 0207 List of Figures List of Tables Table 1 Default Storage Specifiers Table 2 Pointer Conversion Table 3 Nonstandard Headers Table 4 ZNEO Startup Files Table 5 Segments Table 6 Linker Referenced Files Table 7 Linker Symbols Table 8 ZNEO Address Spaces Table 9 Predefined Segments Table 10 Operator Precedence Table 11 Anonymous Labels Table 8 Assembler Command Line Options Table 9 Compiler Command Line Options Table 10 Librarian Command Line Options Table 11 Linker Command Line Options Table 12 Script File Commands Table 13 Command Line Examples Table 14 Assemble
124. 0207 352 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG abs acos frexp frexpf iscntrl ispunct Idexp Idexpf malloc memset puts setjmp srand strcpy strncpy strtod strtof tolower vprintf getchar isdigit isspace Idiv memchr modf modff qsort sin sinf sscanf strcspn strpbrk strtok toupper vsprintf gets isgraph isupper log logf memcmp pow powf rand sinh sinhf strcat strlen strrchr strtol va arg isalnum islower isxdigit log10 log10f memcpy printf realloc sprintf strchr strncat strspn tan tanf va end isalpha isprint labs longjmp memmove putchar scanf sqrt sqrtf strcmp strncmp strstr tanh tanhf va_start Computes the absolute value of an integer j If the result cannot be represented the behav ior is undefined Synopsis dinclude lt stdlib h gt int abs int j Returns The absolute value Example int I 5632 int j j abs 1 acosf Computes the principal value of the arc cosine of x A domain error occurs for arguments not in the range 1 1 Synopsis tinclude lt math h gt double acos double x float acosf float x UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual Z ss zZiLOG Returns The arc cosine in the range 0 pi Example double y 0 5635 double x x acos y asin asinf Computes the principal value of the arc sine of x A domain
125. 0207 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual 281 zZiLOG NOTE There are several SFRs that when read are cleared or clear an associated register To prevent the debugger from changing the behavior of the code a special group of SFRs was created that groups these state changing registers The group is called SPECIAL CASE If this group is selected the behavior of the code changes and the program must be reset To use the FLASH OPTIONBITS group you need to reset the device for the changes to take effect Use the FLASH OPTIONBITS group to view the values of all of the Flash option bit registers except the following Temperature sensor trim registers Precision oscillator trim registers Flash capacity configuration registers To change special function register values do the following 1 In the Special Function Registers window highlight the value you want to change 2 Type the new value and press the Enter key The changed value is displayed in red Clock Window Click the Clock Window button to show or hide the Clock window The Clock window displays the number of states executed since the last reset You can reset the contents of the Clock window at any time by selecting the number of cycles 1705 in Figure 97 type 0 and press the Enter key Updated values are displayed in red NOTE The Clock window will only display clock data when the Simulator is the active debug tool clock
126. 0207 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual 283 ziLoc 2 Type the new value and press the Enter key The changed value is displayed in red View the Values for Other Memory Spaces To view the values for other memory spaces use one of the following procedures Replace the initial letter with a different valid memory prefix and press the entry key For example type I for the IOData memory space Select the space name in the Space drop down list View or Search for an Address To quickly view or search for an address in the Memory window do the following 1 In the Memory window highlight the address in the Address field as shown in Figure 99 Space Memory Address iEo0000000 Figure 99 Memory Window Starting Address 2 Type the address you want to find and press the Enter key For example find 60 The system moves the selected address to the top of the Memory window as shown in Figure 100 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 284 ZitoG Space Memory e Address M 00000060 Figure 100 Memory Window Requested Address Fill Memory Use this procedure to write a common value in all the memory spaces in the specified address range for example to clear memory for the specified address range To fill a specified address range of memory do the following 1 Select the memory space in the Space drop down l
127. 06 zZiLOG 5 Ifyou want to change the color for any of the items in the Color list box click the item make sure the Use Default check boxes are not selected and then click on the color in the Foreground or Background field to display the Color dialog box Figure 80 If you want to use the default foreground or background color for the selected item enable the Use Default check box next to the Foreground or Background check box see Figure 79 on page 105 Basic colors EEE Eee ee EEE Ee NM Custom colors IB BREE EE I5 83 8 3 BJ Define Custom Colors gt gt Figure 80 Color Dialog Box 6 Click OK to close the Color dialog box 7 To change the default font and font size click Select Font The Font dialog box is displayed as shown in Figure 81 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 107 zZiLOG Font Font style Regular Courier New C Fixedsys i HES Tr IBMPCDOS O Lucida Console Ip MS Gothic Terminal WST_Czec Sample AaBbYyzz Script Westem Y Figure 81 Font Dialog Box You can change the font font style font size and script style 8 Click OK to close the Font dialog box 9 Click OK to close the Options dialog box Options Debugger Tab The Debugger tab Figure 82 has nine check boxes Select the Save Project Before Start of Debug Session check box to save the current project before enterin
128. 1 Installing ZDS II 1 Instructions in assembly 173 Index INT_MAX 341 Integer arithmetic functions 350 Intel Hex32 Records format 80 Intel Hex32 format 80 Intermediate Files Directory field 56 Internal Flash check box 84 96 Internal RAM 76 255 interrupt handlers 120 interrupt keyword 120 IODATA address space 76 168 255 IOSEG segment 169 IP Address field 87 ISA Mode Enabled check box 83 isalnum function 340 363 isalpha function 340 363 iscntrl function 340 363 isdigit function 340 364 isgraph function 341 364 islower function 341 364 isprint function 341 365 ispunct function 341 365 isspace function 341 365 isupper function 341 366 isxdigit function 341 366 J jmp_buf 346 K kbhit function 138 Keep Tabs button 105 L Labels 204 B 204 F 204 anonymous 204 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 420 zZiLOG assigning to a space 204 exporting 204 importing 204 in assembly language 203 local 204 local 204 labs function 350 366 Large memory model 119 Largest integer computing 360 LDBL DIG 343 LDBL MANT DIG 343 LDBL MAX 343 LDBL MAX 10 EXP 343 LDBL MAX EXP 343 LDBL MIN 343 LDBL MIN 10 EXP 343 LDBL MIN EXP 343 Idexp function 345 367 Idexpf function 345 367 Idiv function 350 367 ldiv t 348 LENGTH operator 229 Librarian command line options 304 options 325 Librarian page 66 Libraries defining 216 functions 351 object 213 Librar
129. 1 Save As Dialog BOX coi A as 42 Print Preview Window AAA re OE A are e 8 Je Ie dia Ha ce E e 43 Find Dialog Box lssssseeeeseeeeee e 46 Find in Files Dialog Box sseeeeeeeseeee ene 47 Replace Dialog BOX 2 ere debe dee a AE E HER RR Rn 48 Go to Line Number Dialog Box 2 0 ccc eee ees 48 Breakpoints Dialog Box ssseesleeeeeeeee teen eens 49 Add Files to Project Dialog Box 0 0 cece cee ees 52 General Page of the Project Settings Dialog Box ooooooomoo 54 Assembler Page of the Project Settings Dialog Box 56 Code Generation Page of the Project Settings Dialog Box 58 Listing Files Page of the Project Settings Dialog Box 60 Preprocessor Page of the Project Settings Dialog Box 61 Advanced Page of the Project Settings Dialog Box 4 63 Commands Page of the Project Settings Dialog Box 67 Additional Linker Directives Dialog Box ooooccccocccconoooo 68 Select Linker Command File Dialog Box 0 0000 ce eee 69 Objects and Libraries Page of the Project Settings Dialog Box 71 Address Spaces Page of the Project Settings Dialog Box 75 Warnings Page of the Project Settings Dialog Box 77 Output Page of the Project Settings Dialog Box 0 79 Debugger Page of the Project Settings Dialog Box 81 Configure
130. 10 Reserve 10 bytes of storage END Informs the assembler of the end of the source input file If the operand field is present it defines the start address of the program During the linking process only one module can UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual Z 187 zZiLOG define the start address otherwise an error results The END directive is optional for those modules that do not define the start address Synonym end Syntax end directive gt END lt expression gt Example END start Use the value of start as the program start address EQU Assigns symbolic names to numeric or string values Any name used to define an equate must not have been previously defined Other equates and label symbols are allowed in the expression provided they are previously defined Synonyms equ EQU EQUAL equal Syntax label EQU expression Examples length EQU 6 lst dimension of rectangle width EQU 11 2nd dimension of rectangle area EQU length width area of the rectangle reg EQU r7 symbolic name of a register INCLUDE Allows the insertion of source code from another file into the current source file during assembly The included file is assembled into the current source file immediately after the directive When the EOF End of File of the included file is reached the assembly resumes on the line aft
131. 25 Regular Expression check box 46 48 Relational operators in assembly 176 Release configuration 90 Relocatable segments 168 170 214 Remainder computing 360 Remove All Breakpoints button 20 24 Remove All button 50 296 Remove Breakpoint command 296 Remove button 49 296 Replace All button 48 Replace button 48 Replace dialog box 47 48 Replace With field 48 Replace With list box 48 Reserved words in assembly 173 in headers 134 Reset button 20 23 Reset to Symbol main Where Applicable check box 107 reset script file command 328 Return values 132 Revision history iii RI function 139 Index rom 134 ROM address space 75 168 254 ROM_DATA segment 144 169 ROM_TEXT segment 144 169 Run Command button 21 Run to Cursor button 23 Run time library 133 337 formatting 133 337 functions 351 nonstandard headers 134 standard headers 337 using functions 338 using headers 338 S Sample program 1 Save All button 18 Save As dialog box 42 88 Save as Type drop down list box 42 Save button 17 Save Files Before Build check box 103 Save In drop down list box 42 88 Save Project Before Start of Debug Session check box 107 Save to File dialog box 285 Save Restore Project Workspace check box 104 SAVEMEM script file command 328 Saving a project 14 scanf function 347 378 conversion characters 380 SCHAR_MAX 341 SCHAR_MIN 341 SCOPE directive 204 Script file commands 312 definition 311 example 311 writing 311 Searc
132. 4 running from the command line 298 run time library 133 337 warning messages 152 writing C programs 113 Compiling a project 89 Computing string length 387 Concatenating strings 384 387 Concatenation character 201 Concatenation functions 350 Conditional assembly 197 Conditional assembly directives 198 IF 198 IFDEF 199 IFMA 200 202 IFSAME 199 Configuration Name field 91 Configurations adding new 91 Debug 90 Release 90 setting 90 Configure Target dialog box 82 Connect to Target button 19 CONST IN ROM 127 Constant data 75 254 Context menus Call Stack window 290 Disassembly window 292 in Edit window 29 31 in Project Workspace window 27 Locals window 290 Simulated UART Output window 292 Watch window 288 289 Converting letter case 393 394 Converting strings 390 392 COPY BASE OF command 217 COPY BASE operator 228 Copy button 18 85 COPY command 217 247 Copy Settings From list box 91 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 412 zZiLOG COPY TOP OF command 217 COPY TOP operator 228 Copying characters 371 388 Copying functions 350 Copying strings 386 Copying values 371 cos function 344 358 cosf function 344 358 cosh function 345 358 coshf function 345 358 cosine calculating 358 CPU directive 182 CPU drop down list box 54 CPU Family drop down list box 54 CPU Family list box 3 37 CPU list box 3 37 CPU selection 54 CpuflashDevice xml file 84
133. 4 00 vect10 0000 vectlc 0000 vect20 0000 vect54 0000 vect58 T 007C startupexs R FFBOOA MAIN C 008460 EI R FFBOOO startupexs T 013 007FFFFF 0081FFFF 0081FFFF C 0083F6 SIO C 00846 8 GETCHAR C 00831A SIO C 0083CC SIO 00000000 00000000 00000036 0000000D 00000000 00000000 00000000 000084F6 O0FFBOOO0 O0FFB036 C 00801A MAIN E startupexs lt E lt El Q H lt lt lt lt lt lt lt Ej Ei Ed EH E b Bd ee Q H O lt lt lt lt lt ZiLOG Developer Studio Il ZNEO User Manual ECTORS 64 ORS 60 RS 24 CTORS 4C CTORS 48 CTORS 44 RS 40 CTORS 3C CTORS 38 ORS 34 CTORS 30 Q H O Q H ECTORS_50 VECTORS 04 lt lt lalala ECTORS 28 ECTORS 08 ECTORS 14 ECTORS 10 ECTORS 1C ECTORS 20 ECTORS 54 ECTORS 58 startup ei NEAR BSS startup NEAR BSS TEXT User Defined User Defined User Defined Sio TEXT Ser Ser ser ser ser ser ser ser ser ser get C 008062 Z16F2800100ZCOG 100zcog T C 00815A Z16F2800100ZC0G 100zcog TEXT char TEXT sio TEXT sio TEXT Defined Defined Defined Defined Defined Defined Defined ECTORS 5C ECTORS 18 EXT Defined Defined Defined main TEXT Z 245 ZiLOG UM017103 0207 246 ZiLOG Developer Studio Il ZNEO User
134. 84AC C 0084D9 2eh Module COMMONAPRINT_SPUTCH C Library crtSD lib Version 1 0 12 06 2005 16 58 01 Segment sputch TEXT C 008494 C 0084AB 18h Module COMMONAPRINT_UPUTCH C Library crtSD lib Version 1 0 12 06 2005 16 58 01 Segment uputch TEXT C 008474 C 008493 20h Module COMMON PUTCHAR C Library crtSD lib Version 1 0 12 06 2005 16 58 02 Segment putchar TEXT C 00843E C 00845F 22h UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual AE zZiLOG Module COMMON SIO C Library crtSD lib Version 1 0 12 06 2005 16 58 03 Name Base Top Size Segment NEAR DATA R FFBO3E R FFBO3E 1h Segment sio TEXT C 0082FA C 00843D 144h Module commonlucase asm Library chelpSD lib Version 1 0 12 06 2005 16 59 45 Name Base Top Size Segment CODE C 008000 C 008019 lah Module common Nvect08 asm Library chelpSD lib Version 1 0 12 06 2005 16 59 45 Name Base Top Size Segment VECTORS 08 T 0008 T 000B 4h Module commonNvectO0c asm Library chelpSD lib Version 1 0 12 06 2005 16 59 45 Name Base Top Size Segment VECTORS OC T 000C T 000F 4h Module commonivect10 asm Library chelpSD lib Version 1 0 12 06 2005 16 59 45 Name Base Top Size Segment VECTORS 10 T 0010 T 0013 4h Module commonNvecti4 asm Library chelpSD lib Version 1 0 12 06 2005 16 59 45 Name Base Top Size Segment X VECTORS 14 T 0014 T 0017 4h 5 Using the L
135. 87 pau o oc ena Ir ECCE c CEDE 387 SUDODY iii aet a a altes dui Rob de d AS 388 SUDDIK amp tic ceres ee ese O oO e ER Ret edd d CES d 388 SHELL 389 A RA 389 MA a a 390 Strtod Stro T uo ire on ad babe eoe OR doles s be BH 390 SOK 2 sete aia dioica ag d ose eee Pees h Hed aoe baie hae eS sae 391 SOL ii A dese awe od A oan E soars 392 tanm tani posse see encarta do teen een sein en ee ne on ead NN 393 tanb tanhf s e ee pcan gOS A der e oor 393 TOO WEE 21h60 REA be Dau dad Qe dese baie qoid dea dte dur det 393 invece EET 394 DE I rS 394 UMO17103 0207 Table of Contents ZiLOG Developer Studio ll ZNEO User Manual Vd cendi octo RUPES au Nadu mt facete d e ede d 395 va Stat ooer rora L9 wewewr ee Ren bide PER PR d PETIERE ER 396 VPD ire aed oe diee oc ibd ee eode tu CR I dot ACIE thoes UR CR EO Red 397 VSDEIDUE i cedere LE d aa ed de didus Eee d a rb RES DER 397 Glossary ooo ioc rad QUEE A Face Pee TP E E UPC Td 399 linge pm 407 Table of Contents UMO17103 0207 XV ZiLOG Developer Studio ll ZNEO User Manual xvi zZiLOG UMO17103 0207 Table of Contents ZiLOG Developer Studio ll List of Figures List of Figures ZNEO User Manual Figure 1 Select Project Name Dialog Box 0 cece cee o 2 Figure 2 New Project Dialog Box 2 cece cette eens 3 Figure 3 New Project Wizard Dialog Box Build Options Step 4 Figure 4 New Project Wizard Dialog Box Target and De
136. 96 CRC 98 CRC script file command 315 Create New Target Wizard dialog box 85 Creating a project 2 lt ctype h gt header 340 Current drop down list box 87 Customer service xxiv Customer support xxiv Customize dialog box 100 Commands tab 102 103 Toolbars tab 100 101 Cut button 18 Cyclic redundancy check 98 D Data directives in assembly 182 Data type sizes 126 _ DATE 127 DB directive 184 DBL DIG 342 DBL MANT DIG 342 DBL MAX 342 Index DBL MAX 10 EXP 342 DBL MAX EXP 342 DBL MIN 342 DBL MIN 10 EXP 342 DBL MIN EXP 342 Deallocating space 361 DEBUG command 218 Debug configuration 90 Debug information generating 218 221 247 Debug menu 92 Break 93 Connect to Target 92 Download Code 93 Go 93 Reset 93 Run to Cursor 93 Set Next Instruction 94 shortcuts 112 Step Into 93 Step Out 94 Step Over 94 Stop Debugging 93 Verify Download 93 Debug mode RUN 278 STEP 278 STOP 278 switching to 277 Debug Output window 33 Debug Tool area 87 Debug toolbar 22 Debug windows 51 Debug Windows toolbar 24 25 Debugger description 81 277 status bar 278 Debugger page 81 Debugger script file commands 312 example 311 writing 311 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 413 ZiLOG Debugger tab Options dialog box 107 debugtool copy script file command 315 debugtool create script file command 316 debugtool get script file command 316 debugtool help script file
137. AP on page 220 MAXHEXLEN on page 220 MAXLENGTH on page 221 NODEBUG on page 221 NOMAP on page 221 NOWARN on page 222 ORDER on page 222 RANGE on page 222 SEARCHPATH on page 223 SEQUENCE on page 223 SORT on page 223 SPLITTABLE on page 224 UNRESOLVED IS FATAL on page 224 WARN on page 225 WARNING IS FATAL on page 225 WARNOVERLAP on page 225 NOTE Only the lt outputfile gt lt module list and the FORMAT commands are required All commands and operators are not case sensitive 5 Using the Linker Locator UMO17103 0207 216 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG lt outputfile gt lt module list gt NOTE This command defines the executable file object modules and libraries involved in the linking process lt module list gt 1s a list of object module or library path names to be linked together to create the output file lt output file gt is the base name of the output file gener ated The extension of the output file name is determined by the FORMAT command Example sample c ZDSII_ ZNEO 4 11 0 lib zilog startups obj test obj c ZDSII_ZNEO 4 11 0 lib standard chelpsd lib c ZDSII_ZNEO 4 11 0 lib standard crtsd lib c ZDSII_ZNEO 4 11 0 lib standard fpsd lib This command links the two object modules and three library modules to generate the linked output file sample 1od in IEEE 695 format when the format OMF695 command
138. B of internal Flash The lower boundary must be 00 0000H The upper boundary can be lower than 00 7FFFH but no higher Data in this range is addressable using 16 or 32 bits The ROM address range includes the ZNEO CPU option bytes and vector table The C Compiler uses the ROM range for constant data data tables and startup code The assembly language programmer can place any executable code in the ROM range if desired The ROM range typically includes only internal Flash but can include external nonvolatile memory if for example internal Flash is disabled NOTE To use any external memory provided on the target system you must configure the memory s chip select in the Configure Target dialog box See Project Settings Debugger Page on page 81 UMO17103 0207 Program space EROM Identifies any 32 bit addressed nonvolatile memory space outside the ROM range This range is typically 00 2000H 00 7FFFH for devices with 32 KB of internal Flash 00 4000H 00 FFFFH for devices with 64 KB of internal Flash and 00 8000H 01 FFFFH for devices with 128 KB of internal Flash Specify a larger range only if the target system provides external nonvolatile memory 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 255 zZiLOG The EROM range extends to the highest nonvolatile memory address in the target system ZDS II requires the highest EROM address to fall below the specified ERAM if presen
139. CE ROM FORMAT TEXT c temp file txt STARTADDRESS 1000 ENDADDRESS 2FFF UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual 329 zZiLOG set config The set config command activates an existing build configuration for or creates a new build configuration in the currently loaded project The following is the syntax of the set config command set config config name copy from config name The set config command does the following Activates config name if it exists Creates a new configuration named config name if it does not yet exist When complete the new configuration is made active When creating a new configuration the Command Processor copies the initial settings from the copy from config name parameter if provided If not provided the active build configuration is used as the copy source If config name exists the copy from config name parameter is ignored NOTE The active selected configuration is used with commands like option tool name value and build step The step command performs a single step stepover from the current location of the pro gram counter If the count is not provided a single step is performed This command starts a debug session if one has not been started The following 1s the syntax of the step com mand step stepin The stepin command steps into the function at the PC If there is no function at the cur rent PC
140. CT directive it must match the label that is used for the STRUCT directive The intent is to allow for code readability with some checking by the assembler An example structure definition is as follows DATE STRUCT MONTH Dsl DAY DS YEAR DS 2 DSIZE ENDSTRUCT DATE Directives allowed between STRUCT and ENDSTRUCT are directives that specify size principally DS ALIGN ORG and TAG and their aliases Also BLKB BLKW and BLKL directives with one parameter are allowed because they indicate only size The following directives are not allowed within STRUCT and ENDSTRUCT Initialization directives DB DW DL DF and DD and their aliases BLKB BLKW and BLKL with two parameters because they perform initialization Equates EQU and SET Macro definitions MACRO Segment directives SEGMENT and FRAME Na e Nested STRUCT and UNION directives e CPU instructions for example LD and NOP TAG Directive The TAG assembler declares or assigns a label to have a structure type This directive can also be used to define a structure union element within a structure The TAG directive does not allocate memory The TAG directive to define a structure union element has the following form stag STRUCT offset parent name_1 DS countl UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual Lo 195 zZiLOG n
141. Compiler UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 130 zZiLOG Run Time Stack SP Temporaries Low Address Locals FP Callers Frame Pointer 31 0 Return Address 31 0 Parameter 1 Figure 84 Call Frame Layout High Address Special Cases Some function calls do not follow the mechanism described in Function Call Mecha nism on page 128 Such cases are described in this section Returning Structure If the function returns a structure the caller allocates the space for the structure and then passes the address of the return space to the called function as an additional and first argu ment To return a structure the called function then copies the structure to the memory block pointed to by this argument Not Allocating a Local Frame The compiler does not allocate a local stack frame for a function in the following case e The function does not have any local stack variables stack arguments or compiler generated temporaries on the stack and e The function does not return a structure and e The function is compiled without the debug option UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 131 zZiLOG CALLING ASSEMBLY FUNCTIONS FROM C The ZNEO C Compiler allows mixed C and assembly programming A function written in assembly can be called from C if the assembly function follows the C calling conventions as described in Calli
142. Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 263 zZiLOG This program configuration requires that the target system contain external RAM that has been configured in the target setup and added to the ERAM linker address range Address Range Space Contents IODATA I O Access 16 Bit Addressable Data Small Model Stack RAM Data Large Model Stack ERAM Data Code EROM Data Copy of ERAM Initializers Copy of RAM Initializers ROM Data 16 Bit Startup Code Addressable Vector Table Data Option Bytes Figure 90 Programmer s Model Download to ERAM Program Configuration C Program Setup The C program setup for the Download to ERAM Program Configuration is similar to the Default Program Configuration with some additional steps as described in this section The C Compiler by default generates the executable program code under one unified seg ment named CODE The CODE segment belongs to EROM address space To set up this configuration you need to move this CODE segment from EROM to ERAM address 6 Configuring Memory for Your Program UMO17103 0207 264 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG change code change code UMO17103 0207 space Do this by adding the following linker command in the Additional Linker Direc tives dialog box see Additional Directives on page 68 ERAM The linker will then allocate code segment in ERAM
143. DLIST ON OFF END lt expression gt lt ident gt EQU lt expression gt RROR lt string_const gt XIT lt string_const gt FCALL lt ident gt FILE lt string_const gt FRAME lt ident gt lt ident gt lt space gt GLOBALS ON OFF INCLUDE lt string_const gt LIST ON OFF lt macro_def gt lt macro_invoc gt MACDELIM lt char_const gt MACLIST ON OFF NOLIST ORG lt int_const gt lt public_definition gt lt scalar_definition gt SCOPE lt segment_definition gt SEGMENT ident SUBTITLE lt string_const gt SYNTAX lt target_microprocessor gt TITLE lt string_const gt lt ident gt VAR lt expression gt WARNING lt string_const gt Ej m lt type gt lt elements gt lt initvalue gt lt initvalue gt DB DL DW DW24 lt int_const gt lt instances gt lt value gt lt int_const gt lt expression gt lt string_const gt 4 Using the Macro Assembler lt expression gt binary op lt i gt lt int_const gt lt char_const gt lt label gt lt string_const gt lt ident gt lt ident_list gt lt macro_def gt lt macro_invoc gt 4 Using the Macro Assembler ZiLOG Developer Studio Il ZNEO User Manual zZiLOG lt expression gt lt expression gt lt binary_op gt lt expression gt lt unary_op gt lt expression gt lt int_const gt lt label gt HIGH lt expression gt LOW lt expression
144. Default Type of Char option compiler chartype Settings Librarian page Output File Name option librarian outfile Table 17 on page 325 Settings Commands page Always Generate from Settings option linker createnew Table 18 Additional Directives option linker useadddirective on Edit Additional Linker option linker directives page 326 Directives dialog box Use Existing option linker linkctlfile Settings Objects and Additional Object Library Modules option linker objlibmods Table 18 Libraries page Standard option linker startuptype on Included in Project option linker startuptype page 326 Use Standard Startup Linker option linker startuplnkcmds Commands C Runtime Library option linker usecrun Floating Point Library option linker fplib Settings Address Spaces Constant Data ROM option linker rom Table 18 page Internal Ram RAM option linker ram on SFRs and IO IOData option linker iodata page 326 Program Space EROM option linker erom Extended RAM ERAM option linker eram Settings Warnings page Treat All Warnings as Fatal option linker warnisfatal Table 18 Treat Undefined Symbols as Fatal option linker undefisfatal on Warn on Segment Overlap option linker warnoverlap page 326 Settings Output page Output File Name option linker of Table 18 Generate Map File option linker map on Sort Symbols By option linker sort page 326 Show Absolute Addresses in Assembly Listings Executable Formats Fill Unused Hex File Bytes with OxFF
145. Directives check box 2 Click Edit The Additional Linker Directives dialog box Figure 54 is displayed Additional Linker Directives These options below provide limited customization of the linker command file generated for this build configuration Text entered below will be inserted without modification into the linker command file Figure 54 Additional Linker Directives Dialog Box 3 Add new directives or edit existing directives 4 Click OK You can use the Additional Directives check box if you need to make some modifications or additions to the settings that are automatically generated from your project settings but you still want all your project settings and newly added project files to take effect automat ically on each new build You can add or edit your additional directives in the Additional Linker Directives dialog box The manually inserted directives are always placed in the same place in your linker command file after most of the automatically generated directives and just before the final directive that gives the name of the executable to be built and the modules to be included in the build This position makes your manually inserted directives override any conflict ing directives that occur earlier in the file so it allows you to override particular directives that are autogenerated from the project settings The RANGE and ORDER linker directives are exceptions to this rule they do not override earlier RANGE
146. EQ 147 SYS CLK SRC 147 _ VECTOR segment 144 or 231 not 232 Numerics 16 Bit Data Width check box 83 A abs function 350 352 Absolute segments 170 186 definition 168 214 locating 220 Absolute value computing 352 360 366 Access breakpoints clearing all 314 clearing at specified address 314 setting 313 acos function 344 352 acosf function 344 352 Activate Breakpoints check box 108 Add button 84 add file script file command 312 Add Files to Project dialog box 7 52 Add Project Configuration dialog box 91 Adding breakpoints 293 Adding files to a project 6 52 Additional Directives check box 68 Additional Linker Directives dialog box 68 Additional Object Library Modules field 71 Address button 80 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 408 ZiLOG Address Hex field 97 Address range syntax 76 Address spaces 168 allocation order 223 definition 167 213 grouping 219 linking sequence 222 locating 220 moving 216 renaming 216 setting maximum size 221 setting ranges 76 222 ZNEO 168 Addresses finding 283 viewing 283 ALIGN clause 185 ALIGN directive 181 Allocating space 369 Always Generate from Settings button 67 Always Rebuild After Configuration Activated check box 103 Anonymous labels 204 Another Location button 86 Another Location field 86 ANSI C Compiler command line options 301 comments 125 data type sizes 126 error messages 152 running from the command line 298 run ti
147. ERRARE ida ias 18 Find Toolbar 11222 e debe s od ds 20 Command Processor Toolbar oooococccccccooccocor eh 21 Debug Toolbar ion bs S eo ee n oe EIE EE 22 Debug Windows Toolbar ssssseeeee e 24 unn dea a ac nie a a eo 26 Project Workspace Window 0 cece eee e 26 Edit Window 0 406 cae baa a t s RA P EET ER A AERE REN 27 Output Windows o oooooococrr ee ha 32 Men B t ok RI VEU A pee REN te ED edu bars 34 File Men 2 26 hss nes o eee den esd ERATIS E ER M don Ee e Gta 35 Edt MON TP 44 View Ment PM 50 Project Menus ia id Ad 51 Build Men set eae Eb t rer e ee Aet ete dire dic 89 Deb g Menu bent penr e A AA none neds 92 Tools Menu csi ja sere e e ad pire ead 94 Window Menu 0 cece ccc s 108 Help Men sidad da diese decies sr dde ads 109 Table of Contents UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual Shortcut Keys aed user etn bhai e teet pare eb eer e p eae ee du ae 110 File Menu Shortcuts o oo ooooooooorrrr e 110 Edit Men Shortcuts 1 00 a ae 110 Project Menu Shortcuts o oooooooooorrrrr en en ene eens 111 Build Menu Shortcuts 200 eh 111 Debug Menu Shortcuts o oooooooooorrrrr n 112 3 Using the ANSI C Compiler eeeeeeeeeeeeeee enhn nnn 113 Language Extensions iiss step bay aed ae rA oe CAE E TR SIR RA end 114 Additional Keywords for Storage Specification o ooooooooooomomo 115 Memory Models cuina i
148. FAILURE Expands to integral expression which indicates unsuccessful termination status HUGE VAL Expands to a positive double expression not necessarily represented as a float NULL Expands to a null pointer constant RAND MAX Expands to an integral constant expression the value of which is the maximum value returned by the rand function Functions String Conversion The atof atoi and atol functions do not affect the value of the errno macro on an error If the result cannot be represented the behavior is undefined UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 349 zZiLOG double atof const char nptr Converts string to double int atoi const char nptr Converts string to int long int atol const char nptr Converts string to long double strtod const char nptr char endptr Converts string pointed to by nptr to a double long int strtol const char nptr char endptr int base Converts string to a long decimal integer that is equal to a number with the specified radix The following additional string conversion functions are provided float atoff const char nptr Converts string to float float strtof const char nptr char endptr Converts string pointed to by nptr to a double Pseudorandom Sequence Generation int rand void Gets a pseudorandom number void srand unsigned int seed Initializes pseudorandom series Memory Management The ord
149. G inserting 293 jumping to 295 making active 295 making inactive 295 moving to 295 placing 293 removing 296 setting 293 viewing 294 Breakpoints dialog box 49 294 Broadcast Address field 87 bsearch function 349 356 Build button 19 Build menu 89 Build 89 Clean 89 Compile 89 Manage Configurations 91 Rebuild All 89 Set Active Configuration 90 shortcuts 111 Stop Build 89 Update All Dependencies 90 Build Output window 14 32 33 Build toolbar 18 19 Build Type list box 3 37 build script file command 314 Building a project 13 89 from the command line 297 Burn Serial button 97 C C calling assembly from 131 calling from assembly 132 escape sequences 123 preserving routines 132 return values 132 run time library 133 337 writing programs 113 Index C run time initialization file 142 C Startup Module area 72 Calculate Checksum dialog box 99 100 Call Stack window 290 Call Stack Window button 25 Calling assembly from C 131 calloc function 349 357 cancel all script file command 314 cancel bp when script file command 314 cancel bp script file command 314 Cascade the files 109 Case sensitivity in assembler 55 173 in linker 55 C Compiler command line options 301 comments 125 data type sizes 126 error messages 152 running from the command line 298 run time library 133 337 warning messages 152 writing C programs 113 ed script file command 314 ceil function 346 357 ceilf function 346 357 C
150. GORY lt Category gt OPTION Option lt token name gt lt value to set gt target options CATEGORY lt Category gt lt token name gt lt value to set gt target options lt token name gt lt value to set gt To select a target use the following syntax target options NAME Target Name target save The target save command saves a target To save the selected target use the following syntax Larget Save To save a specified target use the following syntax target save NAME Target Name For example target save Name Sim3 target set The target set command sets the given data item to the given data value for the active target or activates a particular target The syntax can take one of two forms target set data item new value gt Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 332 7 zZiLOG Sets data item to new value for the active debug tool Use target setup to view available data items and current values For example target set frequency 20000000 target set lt target name gt Activates the target with the given name Use target list to view available targets target setup The target setup command displays the current configuration The following is the syntax ofthe target setup command target setup wait The wait command instructs the Command Processor to wai
151. HANGE command 216 247 Changing object size 377 char enumerations 124 CHAR BIT 341 CHAR MAX 341 CHAR MIN 341 Character case mapping functions 341 Character constants in assembly 178 Character strings in assembly 175 Character testing functions 340 Character handling functions 340 checksum script file command 315 Chip Select Registers drop down list box 82 Clear button 104 Clock Frequency MHz area 83 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 411 ZiLOG Clock window 281 Clock Window button 25 Close Dialog When Complete check box 97 Code line indicators 279 CODE segment 144 169 Command field 21 Command line building a project from 297 examples 323 running the assembler from 298 299 running the compiler from 298 301 running the librarian from 304 running the linker from 298 304 running ZDS II from 297 Command Output window 34 Command Processor running the Flash Loader from 333 sample command script file 311 script file commands 312 Command Processor toolbar 21 Command script file commands 312 example 311 writing 311 Commands linker command file 215 running 307 Commands tab 102 Commands to Keep field 104 COMMENT directive 182 Comments 125 in assembly language 172 Comparing characters 370 387 Comparing strings 385 386 Comparison functions 351 Compile Assemble File button 19 Compiler command line options 301 comments 125 data type sizes 126 error messages 152 Index options 32
152. Il ZNEO User Manual 356 Returns The converted value Example char str 1234567 long int x x atol str bsearch Searches an array of nmemb objects the initial member of which is pointed to by base for a member that matches the object pointed to by key The size of each object is specified by size The array has been previously sorted in ascending order according to a comparison func tion pointed to by compar which is called with two arguments that point to the objects being compared The compar function returns an integer less than equal to or greater than zero if the first argument is considered to be respectively less than equal to or greater than the second Synopsis include lt stdlib h gt void bsearch const void key const void base size t nmemb size t size int compar const void const void Returns A pointer to the matching member of the array or a null pointer if no match is found Example include lt stdlib h gt int list 2 5 8 9 int k 8 int compare const void x const void y int main void int result result bsearch amp k list 4 sizeof int compare int compare const void x const void y int a int x int b int y if a lt b return 1 UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual Z 357 zZiLOG 1f a b return 0 return 1 The compare function pr
153. Inserting Breakpoints 0 0 e nee eae 293 Viewing Breakpoints lsseeseeeeeeeeee nee ences 294 Moving to a Breakpoint 0 eee eee ene eee 295 Enabling Breakpoints 0 00 cece cence ene nee eae 295 Disabling Breakpoints 00 c ccc ett eee eens 295 Removing Breakpoints 0 0c cece es 296 Appendix ARunning ZDS II from the Command Line cece ees 297 Building a Project from the Command Line 0 c eee eee eee ee 297 Running the Compiler from the Command Line 002 0 e eee eee 298 Running the Assembler from the Command Line 2 00 0 eee eee 298 UMO17103 0207 Table of Contents ZiLOG Developer Studio ll ZNEO User Manual ziLoc Running the Linker from the Command Line 0 e eee eee eee 298 Assembler Command Line Options 0 0000 c ccc teens 299 Compiler Command Line Options 0 0 cc cece cee eee eens 301 Librarian Command Line Options 00 eect eee 304 Linker Command Line Options 0 000 o 304 Appendix BUsing the Command Processor 0c cece ccc c cree eceees 307 Sample Command Script File 0 0 eect een nees 311 Supported Script File Commands 0 0 0 0 c cect ete eees 312 OOS canica roe ates Nae aves tas 312 A Kidadatd 312 A Bae Ge ies d dora ae A 313 DUM ea Ces 314 cancel all i eo pim e ten e e beer ence ga en eke Pag 314 cancel DD iue
154. Integral type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales Appendix C C Standard Library UMO17103 0207 340 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Diagnostics lt assert h gt The lt assert h gt header declares two macros Macros NDEBUG The lt assert h gt header defines the assert macro It refers to the NDEBUG macro that is not defined in the header If NDEBUG is defined as a macro name before the inclusion of this header the assert macro is defined simply as define assert ignore void 0 assert expression Tests the expression and if false prints the diagnostics including the expression file name and line number Also calls exit with nonzero exit code if the expression is false Character Handling lt ctype h gt NOTE UMO17103 0207 The lt ctype h gt header declares several macros and functions useful for testing and map ping characters In all cases the argument is an int the value of which is represented as an unsigned char or equals the value of the EOF macro If the argument has any other value the behavior is undefined Macros TRUE Expands to a constant 1 FALSE Expands to a constant 0 These are nonstandard macros Functions The functions in this section return nonzero true if and only if the value of the argument c conforms to that in the description of the
155. Internal RAM RAM This range is typically FFB700 FFBFFF for devices with 2 KB of internal RAM or FFB000 FFBFFF for devices with 4 KB of internal RAM Despite its name this range can be expanded up to FF8000 FFBFFF if the target system provides external random access memory to fill out this address range This field does not allow a high RAM address boundary above FFBFFF Special Function Registers and IO IODATA Typically FFCO00 FFFFFF The microcontroller reserves addresses FFE000 and above for its special function registers on chip peripherals and I O ports The ZDS II GUI expects addresses FFC000 to FFDFFF to be used for external I O if any on the target system Address range settings must not overlap The following is the syntax used in the address range fields low address gt high address gt lt low address high address gt where low address gt is the hexadecimal lower boundary of a range and lt high address gt is the hexadecimal higher boundary of the range The following are legal memory ranges 0000 7fff ffb000 ffbfff 008000 01ffff 050000 07ffff The last example line shows how a comma is used to define holes in a memory range for the linker The linker does not place any code or data outside of the ranges specified here If your code or data cannot be placed within the ranges a range error is generated The C Compiler does not support gaps holes within the ERAM or RA
156. L 225 WARNOVERLAP 225 Linker expressions subtract 231 amp and 227 multiply 230 t add 227 divide 228 shift left 231 gt gt shift right 231 bitwise exclusive or 232 or 231 not 232 BASE OF 227 COPY BASE 228 COPY TOP 228 decimal numeric values 230 FREEMEM 229 hexadecimal numeric values 231 Index HIGHADDR 229 LENGTH 229 LOWADDR 229 TOP OF 231 Linker map file sample 232 Linker locator error messages 248 Linker locator warning messages 248 Linking sequence creating 222 list bp script file command 320 LIST directive 188 Listing file assembly 171 Load Debug Information Current Project check box 108 Load from File dialog box 286 Load Last Project on Startup check box 104 LOADMEM script file command 320 Local labels in assembly 204 Local macro label 202 Locals window 290 Locals Window button 25 LOCATE command 220 Locator detailed description 213 error messages 248 warning messages 248 lod file extension 80 log function 345 368 log script file command 321 log10 function 345 368 log10f function 345 368 Logarithm computing 368 Logarithmic functions 345 logf function 345 368 long long int type 126 LONG MAX 341 LONG MIN 341 longjmp function 346 368 Look In drop down list box Add Files to Project dialog box 52 Open dialog box 41 Select Linker Command File dialog box 69 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 422 zZiLOG Loo
157. M ranges UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual ziLoc Project Settings Warnings Page Figure 58 shows the Warnings page Wi Project Settings Configuration Debug p Sak General E Warni n Sie Assembler Treat All Warnings as Fatal flc Sis Code Generation v Treat Undefined Symbols as Fatal xh Listing Files 5 v Warn on Segment Overlap Preprocessor Sil Advanced El Linker SSR Commands h Objects and Libraries h Address Spaces E Sak Output Debugger Cancel Help Figure 58 Warnings Page of the Project Settings Dialog Box Treat All Warnings as Fatal When selected this check box causes the linker to treat all warning messages as fatal errors When the check box is selected the linker does not generate output file s if there are any warnings while linking By default this check box is deselected and the linker proceeds with generating output files even if there are warnings Selecting this check box displays any warning as an error regardless of the state of NOTE the Show Warnings check box in the General page see Show Warnings on page 55 Treat Undefined Symbols as Fatal When selected this check box causes the linker to treat undefined external symbol warnings as fatal errors If this check box is selected the linker quits generating output 2 Using the Integrated Development Environme
158. MO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG sample ZDS Il ZNEO le File Edit View Project Build Debug Tools Window Help D sea g mexa ma D tsuo 0 89 eL m m d LA SS ixl xd EY Standard Project Files main c y Extemal Dependencies E sample Ts To o fh Build Debug A Find in Files A Find in Files 2 A Messages A Command K gt For Help press F1 Figure 7 Sample Project NOTE To view any ofthe files in the Edit window during the tutorial double click on the file in the Project Workspace window Set Up the Project Before you save and build the sample project check the settings in the Project Settings dialog box 1 From the Project menu select Settings The Project Settings dialog box is displayed It provides various project configuration pages that can be accessed by selecting the page name in the pane on the left side of the dialog box There are several pages grouped together for the C Compiler and Linker that allow you to set up subsettings for that tool For more information see Settings on page 52 2 Inthe Configuration drop down list box in the upper left corner of the Project Settings dialog box make sure the Debug build configuration is selected Figure 8 UMO17103 0207 1 Getting Started ZiLOG Developer Studio ll ZNEO User Manual zZiLOG For your convenience the Debug configuration
159. MTYPE ethernet debugtool save The debugtool save command saves a debug tool configuration to disk The syntax can take one of two forms debugtool save saves the active debug tool UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual debugtool save NAME Debug Tool Name gt saves the given debug tool For example debugtool save NAME USBSmartCable debugtool set Z 317 ZiLOG The debugtool set command sets the given data item to the given data value for the active debug tool or activates a particular debug tool The syntax can take one of two forms debugtool set data item gt new value gt sets data item to new value for the active debug tool Use debugto available data items and current values For example debugtool set ipAddress 123 456 7 89 debugtool set lt debug tool name gt activates the debug tool with the given name Use debugtool li available debug tools debugtool setup ol setup to view st to view The debugtool setup command displays the current configuration of the active debug tool The following is the syntax of the debugtool setup command debugtool setup defines The defines command provides a mechanism to add to remove from or replace define strings in the compiler preprocessor defines and assembler defines options This command provides a more flexible method to modify the defines option
160. Manual Z ZiLOG near heapb near heapt near stack putch putchar Select por SetState State ot op _SYS CLK FR _SYS CLK SR _sysclk ini SysClkFreq SysClkSrc System ini _Ticks timer init timer isr EQ C 00FFBO42 User Defined OOFFBFFF User Defined OOFFBFFF User Defined C 0083AC SIO sio TEXT C 00843E PUTCHAR putchar TEXT C 0082FA SIO sio TEXT C 0080A0 216F2800100ZCOG 100zcog TEXT R FFBO11 Z16F2800100Z2COG NEAR BSS 01312D00 User Defined 00000002 User Defined C 00819C 216F2800100ZCOG 100zcog TEXT R FFBO09 Z16F2800100Z2COG NEAR BSS R FFBOO8 Z16F2800100Z2COG NEAR BSS C 0082B0 Z16F2800100ZCOG 100zcog T R FFBOOD Z216F2800100ZC0G NEAR BSS C 008272 216F2800100ZCOG 100zcog TEXT C 0081FC Z216F2800100ZC0G 100zcog TEXT E E XT 125 external symbol s START ADDRE Se T 007C set in module N NsrcNMbootNcommonNstartupexs asm Eri ND OF LINK MAP 0 Errors 0 Warnings TROUBLESHOOTING THE LINKER Review these questions to learn more about common situations you might encounter when using the linker UMO17103 0207 How do I speed up the linker on page 247 How do I generate debug information without generating code on page 247 How much memory is my program using on page 247 How do I create a hex file on page 247 How do I determine the size of my actual hex code on page 247 5 Using the Linker Loc
161. Maximum value for an object of type int INT MIN Minimum value for an object of type int LONG MAX Maximum value for an object of type long int LONG MIN Minimum value for an object of type long int SCHAR MAX Maximum value for an object oftype signed char SCHAR MIN Minimum value for an object of type signed char SHRT_MAX Maximum value for an object of type short int SHRT_MIN Minimum value for an object of type short int UCHAR_MAX Maximum value for an object of type unsigned char UINT MAX Maximum value for an object oftype unsigned int ULONG MAX Maximum value for an object oftype unsigned long int USHRT MAX Maximum value for an object oftype unsigned short int MB LEN MAX Maximum number of bytes in a multibyte character Ifthe value of an object of type char sign extends when used in an expression the value of CHAR MIN is the same as that of SCHAR MIN and the value of CHAR MAX is the same as that of SCHAR MAX Ifthe value of an object of type char does not sign extend Appendix C C Standard Library UMO17103 0207 342 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG when used in an expression the value of CHAR MIN is 0 and the value of CHAR MAX is the same as that of UCHAR MAX Floating Point lt float h gt The lt float h gt header defines macros that expand to various limits and parameters Macros DBL DIG DBL MANT DIG DBL MAX DBL MAX EXP DBL MAX 10 EXP DBL MIN DBL MIN EXP DBL MIN 10 EXP
162. ND Synonyms and AND Bitwise inclusive OR Synonyms or OR Bitwise exclusive XOR Synonyms xor XOR i Complement Boolean NOT Synonyms not NOT LOW and LOW16 Operators The LOW and LOW16 operators can be used to extract the least significant byte or 16 bit word from an integer expression The LOW operator extracts the byte starting at bit 0 of the expression the LOW16 operator extracts the 16 bit word starting at bit 0 of the expression UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual Z 177 zZiLOG For example x equ 5123456 LOW X 8 bits of X starting at bit 0 56H LOW16 X 16 bits of X starting at bit 0 3456H Decimal Numbers Decimal numbers are signed 32 bit integers consisting of the characters 0 9 inclusive between 2147483648 and 2147483647 Positive numbers are indicated by the absence of a sign Negative numbers are indicated by a minus sign preceding the number Underscores _ can be inserted between digits to improve readability For example 1234 decimal 1234 negative decimal 1 000 000 decimal number with underscores 123 A NOT an integer but a name Underscore can be neither first i i nor last character Hexadecimal Numbers Hexadecimal numbers are signed 32 bit integers ending with the h or H suffix or starting with a character and consisting of the characters 0 9 and A F A hexadecimal number can h
163. NEO User Manual 339 zZiLOG Errors lt errno h gt The errno h header defines macros relating to the reporting of error conditions Macros EDOM Expands to a distinct nonzero integral constant expression ERANGE Expands to a distinct nonzero integral constant expression errno A modifiable value that has type int Several libraries set errno to a positive value to indicate an error errno is initialized to zero at program startup but it is never set to zero by any library function The value of errno can be set to nonzero by a library function even if there is no error depending on the behavior specified for the library function in the ANSI Standard Additional macro definitions beginning with E and an uppercase letter can also be speci fied by the implementation Standard Definitions stddef h The following types and macros are defined in several headers referred to in the descrip tions of the functions declared in that header as well as the common lt stddef h gt stan dard header Macros NULL Expands to a null pointer constant offsetof type identifier Expands to an integral constant expression that has type size t and provides the offset in bytes from the beginning of a structure designated by type to the member designated by identifier Types ptrdiff t Signed integral type of the result of subtracting two pointers size t Unsigned integral type of the result of the sizeof operator wchar t
164. New Button on page 17 Open Button on page 17 Save Button on page 17 Save All Button on page 18 e Cut Button on page 18 e Copy Button on page 18 e Paste Button on page 18 e Delete Button on page 18 e Print Button on page 18 e Workspace Window Button on page 18 e Output Window Button on page 18 Doha 5m x SA Figure 15 File Toolbar New Button The New button creates a new file Open Button The Open button allows you to open an existing file Save Button The Save button saves the active file 2 Using the Integrated Development Environment UMO17103 0207 18 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Save All Button The Save All button saves all open files and the currently loaded project Cut Button The Cut button deletes selected text from the active file and puts it on the Windows clip board Copy Button The Copy button copies selected text from the active file and puts it on the Windows clip board Paste Button The Paste button pastes the current contents of the clipboard into the active file at the cur rent cursor position Delete Button The Delete button deletes selected text from the active file Print Button The Print button prints the active file Workspace Window Button The Workspace Window button shows or hides the Project Workspace window Output Window Button The Output Window button shows o
165. O User Manual 109 zZiLOG The Windows menu contains the following options e New Window on page 109 e Close on page 109 e Close All on page 109 Cascade on page 109 Tile on page 109 Arrange Icons on page 109 New Window Select New Window to create a copy of the file you have active in the Edit window Close Select Close to close the active file in the Edit window Close All Select Close All to close all the files in the Edit window Cascade Select Cascade to cascade the files in the Edit window Use this option to display all open windows whenever you cannot locate a window Tile Select Tile to tile the files in the Edit window so that you can see all of them at once Arrange Icons Select Arrange Icons to arrange the files alphabetically in the Edit window Help Menu The Help menu contains the following options e Help Topics on page 109 e Technical Support on page 110 e About on page 110 Help Topics Select Help Topics to display the ZDS II online help 2 Using the Integrated Development Environment UMO17103 0207 110 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Technical Support Select Technical Support to access ZiLOG s Technical Support web site About Select About to display installed product and component version information SHORTCUT KEYS This section lists the shortcut keys for the ZiLOG Developer Studio II The fo
166. O User Manual 121 zZiLOG The following values for vectnum are supported ADC P7AD CO PWM_FAULT Cl PWM_TIMER C2 RESET C3 SPI Dc SYSEXC POAD TIMERO PIAD TIMERI P2AD TIMER2 P3AD UARTO RX P4AD UARTO TX P5AD UARTI RX P6AD UARTI TX Placement Directives The ZNEO C Compiler provides language extensions to declare a variable at an address and to align a variable at a specified alignment Placement of a Variable The following syntax can be used to declare a global or static variable at an address char placed char At Oxb9ff placed char is assigned an address Oxb9ff far struct char ch int 31 ss At 0x080eff ss is assigned an address 0x080eff rom char init char At Ox2fff 33 init char is in rom and initialized to 33 NOTE Only placed variables with the rom or erom storage class specifiers can be initialized The placed variables with near and far storage class specifier cannot be initialized The uninitialized placed variables are not initialized to zero by the compiler startup routine Placement of Consecutive Variables The compiler also provides syntax to place several variables at consecutive addresses For example char chl At Oxbef0 char ch2 At char ch3 At 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 122 zZiLOG NOTE This places ch1 at address Oxbef0 ch2 at the next address Oxbef1 after ch1 and ch3 at the next ad
167. O User Manual zZiLOG Configuration Debug m a General Hd Assembler 2 Rl c Sk Code Generation h Listing Files 3 Preprocessor aR Advanced f amp Linker SS Commands 2 Objects and Libraries h Address Spaces A Warnings gt Debugger ut Output File Name jc Program FilesziLOG zDSIl ZNEO 4 11 0 samples T utorials Iv Generate Map File Sort Symbols By Name Address Show Absolute Addresses in Assembly Listings Executable Formats IEEE 695 Intel Hex32 Records Fil Unused Hex File Bytes with OxFF Maximum Bytes per Hex File Line 64 Figure 59 Output Page of the Project Settings Dialog Box Output File Name You can change the name including the full path name of your executable in the Output File Name field After your program is linked the appropriate extension is added Generate Map File This check box determines whether the linker generates a link map file each time it is run The link map file is named with your project s name with the map extension and is placed in the same directory as the executable output file See MAP on page 220 and How much memory is my program using on page 247 Inside the map file symbols are listed in the order specified by the Sort Symbols By area see Sort Symbols By on page 80 NOTE The link map is an important place to look for memory restriction or layout problems 2 Using the Integrated Development Envir
168. O User Manual ZitoG Table 9 Compiler Command Line Options Continued Option Name Description model model Selects the memory model Select S for a small memory model or L for a large memory model The default is S modsect Generate distinct code segment name for each module noasm Does not assemble the compiler generated assembly file nodebug Does not generate symbol debug information This is the default nogenprint A call to printf or sprintf parses the format string at run time to generate the required output nokeepasm Deletes the compiler generated assembly file This is the default nokeeplst Does not keep the assembly listing file 1st This is the default nolist Does not produce a source listing All errors are identified on the console This is the default nolistinc Does not show include files in the compiler listing file This 1s the default nomodsect Does not generate distinct code segment name for each module The code segment is named as code for every module This is the default noquiet Displays the title information This is the default noregvar Turns off the use of register variables quiet Suppresses title information that is normally displayed to the screen Errors and warnings are still displayed regvar Turns on the use of register variables This 1s the default stdinc path UMO17103 0207 Sets the path for the standar
169. ODO FFFF and 32 bit address FF C000 FF FFFF are also mapped to the Near storage specifier and no separate keyword is provided For example define TOCTLO unsigned char volatile Near 0xE306 TOCTLO 0x12 Rom The variable with the Rom storage specifier is allocated in the space corresponding to the ROM assembler address space which is defined in the linker address space project set tings These variables lie within the 16 or 32 bit addressable range 0000 7FFF The lower portion of this address space is used for Flash option bytes and interrupt vector table For example Rom int ri ri is placed in ROM address space Erom The variable with the Erom storage specifier is allocated in 32 bit addressed internal or external nonvolatile memory This space corresponds to the EROM assembler address UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 117 zZiLOG space defined in the linker address space project settings These variables lie within the range extending from 00 8000 to the highest nonvolatile memory address For example Erom int eri eri is placed in EROM address space _Far The variable with the Far storage specifier is allocated in 32 bit addressed external vola tile random access memory This space corresponds to the ERAM assembler address space defined in the linker address space project settings These variables lie within the 32 b
170. OG LANGUAGE EXTENSIONS To give you additional control over the way the ZNEO C Compiler allocates storage and to enhance its ability to handle common real time constructs the compiler implements the following extensions to the ANSI C standard UMO17103 0207 Additional Keywords for Storage Specification on page 115 The compiler divides the ZNEO CPU memory into four memory spaces Near ROM Extended ROM Near RAM and Extended Far RAM It provides the following keywords with which you can control the storage location of data in these memory spaces Near near Far far _ Rom rom _Erom erom These keywords can also be used to specify the memory space to which a pointer is pointing to Memory Models on page 119 The compiler supports two memory models small and large These models allow you to control where data are stored by default Each application can only use one model The model can affect the efficiency of your application Some of the memory allocation defaults associated with a memory model can be overridden using the keywords for storage specification Interrupt Support on page 120 The ZNEO CPU supports various interrupts The C Compiler provides language extensions to designate a function as interrupt service routine and provides features to set each interrupt vector Placement Directives on page 121 The placement directives allow users to place objects at specifi
171. Output window see Figure 13 sample ZDS II ZNEO File Edit View Project Build Debug Tools Window T c E GR X Ra x amp Debug Standard Project Files main c External Dependencies El FORMAT H C Pro E SIO H C Program E STDARG H C Pro E STDIO H C Progr E Zconst h C Progra El zneo h C Program Figure 13 Build Output Window When the Build completed message is displayed in the Build Output window you have successfully built the sample project and created a sample lod file to debug Save the Project You need to save your project From the File menu select Save Project UMO17103 0207 1 Getting Started ZiLOG Developer Studio ll ZNEO User Manual ziLoc 2 Using the Integrated Development Envi ronment This section discusses how to use the integrated development environment IDE Toolbars on page 16 e Windows on page 26 e Menu Bar on page 34 Shortcut Keys on page 110 To effectively understand how to use the developer s environment be sure to go through the Developer s Environment Tutorial on page 1 After the discussion of the toolbars and windows this section discusses the menu bar see Figure 14 from left to right File Edit View Project Build Debug Tools Window and Help and the dialog boxes accessed from the menus For example the Project Settings dialog box is discussed as a part of the Project me
172. Program Configura tion you avoid that work On the other hand the amount of internal memory is rather lim UMO17103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio Il ZNEO User Manual 267 zZiLOG ited on many ZNEO devices so the Download to RAM Program Configuration might tend to be limited to small applications or portions of applications during development C Program Setup The C program setup for Download to RAM Program Configuration is similar to the Default Program Configuration with some additional steps as described in this section The C Compiler by default generates the executable program code under one unified seg ment named CODE The CODE segment belongs to EROM address space To set up this configuration you need to move the CODE segment from EROM to the RAM address space Do this by adding the following linker command in the Additional Linker Direc tives dialog box see Additional Directives on page 68 change code RAM The linker will then allocate code segment in RAM To go back to the Default Program Configuration for production code remove this direc tive from the Additional Linker Directives dialog box Special Case Partial Download to RAM A special case of this configuration is when you want to download program code from just one C source file into RAM while retaining the rest of the code in EROM This allows you to experiment with different partitions of your code for
173. RNAL FCB FILE FP FRACT GE GLOBAL GLOBALS GREGISTER GT IF IFDEF IFDIFF IFE IFEQ IFFALSE IFMA IFN IFNDEF IFNDIFF IFNFALSE IFNMA IFNSAME IFNTRUE IFNZ IFSAME IFTRUE IFZ INCLUDE E EADZERO LFRACT LIST LONG LOW LOW16 LT MACCNTR MACDELIM MACEND MACEXIT MACFIRST MACLIST MACNOTE MAXBRANCH MESSAGE MI NB NC NE NEWPAGE NOCONDLIST NOLIST NOMACLIST NOSPAN NOV NZ OFF ON ORG ORIGIN OV PAGE PL POPSEG PRINT PT public PUSHSEG PW RO R10 R11 R12 R13 R14 R15 R2 R3 R4 R5 R6 R7 RB R9 RRO RR1 RR10 RR11 RR12 RR13 RR14 ZiLOG Developer Studio ll ZNEO User Manual Z 175 RR15 RR2 RR3 RR4 RR5 RR6 RR7 RR8 RR9 SCOPE SECTION SEGMENT SET SP STRING SUBTITLE TITLE UBFRACT UFRACT UGE UGT ULE ULFRACT ULT VAR VECTOR WARNING word XDEF XREF Z NOTE Additionally do not use the instruction mnemonics or assembler directives as symbol or variable names Assembler Numeric Representation Numbers are represented internally as signed 32 bit integers The assembler detects an expression operand that is out of range for the intended field and generates appropriate error messages Character Strings Character strings consist of printable ASCH characters enclosed by double or single quotes A double quote used within a string delimited by double quotes and a single quote used within a string delimited by single quotes must be preceded by a back slash A single quoted string consisting of a single character is trea
174. SE box rom Address Spaces page Constant Data ROM field string address range in the format lt low gt lt high gt sort Output page Sort Symbols By buttons string startuptype Objects and Libraries page C Startup Module area string standard or included undefisfatal Warnings page Treat Undefined Symbols as Fatal check box TRUE FALSE usecrun Objects and Libraries page Use C Runtime Library check TRUE FALSE box warnisfatal Warnings page Treat All Warnings as Fatal check box TRUE FALSE warnoverlap Warnings page Warn on Segment Overlap check box TRUE FALSE print The print command writes formatted data to the Command Output window and the log f the log is enabled Each expression is evaluated and the value is inserted into the format string which is equivalent to that supported by a C language printf The follow ing is the syntax of the print command print format string expressionl expression2 expressionN For example PRINT the pc is x REG PC print pc x sp x REG PC REG SP pwd The pwd command retrieves the current working directory The following is the syntax of the pwd command pwd Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 328 7 zZiLOG quit The quit command ends the current debug session The following is the syntax of the quit command quit rebuild The rebuild command rebuilds the currently open project
175. SEGMENT directive is encountered For more information about the SEGMENT directive see SEGMENT on page 189 A segment can also be defined with a boundary alignment and or origin 4 Using the Macro Assembler UMO17103 0207 169 ZiLOG Developer Studio Il ZNEO User Manual 170 zZiLOG Alignment Aligning a segment tells the linker to place all instances of the segment in your program on the specified boundary NOTE Although a module can enter and leave a segment many times each module still has only one instance of a segment Origin When a segment is defined with an origin the segment becomes an absolute segment and the linker places it at the specified physical address in memory Assigning Memory at Link Time At link time the linker groups those segments of code and data that have the same name and places the resulting segment in the address space to which it is attached However the linker handles relocatable segments and absolute segments differently e Relocatable segments If a segment is relocatable the linker decides where in the address space to place the segment Absolute segments If a segment is absolute the linker places the segment at the absolute address specified as its origin NOTE At link time you can redefine segments with the appropriate linker commands OUTPUT FILES The assembler creates the following files and names them the name of the source file but with a
176. SERIAL Read the serial number Flash READSERIAL REPEAT Read the serial number and repeat Flash BURNSERIAL Program the serial number Flash BURNSERIAL REPEAT Program the serial number and repeat Flash ERASE Erase Flash memory Flash ERASE REPEAT Erase Flash memory and repeat Flash BURN Program Flash memory Flash BURN REPEAT Program Flash memory and repeat Flash BURNVERIFY Program and verify Flash memory Flash BURNVERIFY REPEAT Program and verify Flash memory and repeat Flash VERIFY Verify Flash memory Flash VERIFY REPEAT Verify Flash memory and repeat MA Caution The Flash Loader dialog box and the Command Processor interface use the same parameters If an option is not specified with the Command Processor interface the current setting in the Flash Loader dialog box is used If a setting is changed in the Command Processor interface the Flash Loader dialog box settings are changed Examples The following are valid examples FLASH BURN R or FLASH Options INTMEM FLASH Options c testing test hex EPEAT flash options intmem flash options c testing test hex flash burn repeat The file test hex is loaded into internal Flash memory After the Flashing is completed you are prompted to program an additional unit FLASH VERIFY The file test hex is verified against internal Flash memory FLASH SETUP The current Flash Loader parameters settings are displayed in the Command Output wind
177. Setup in the Debug Tool area the Setup USB Communication dialog box is displayed as shown in Figure 66 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 88 zZiLOG Setup USB Communication Serial Number No Connection Detected DK Cancel OK Figure 66 Setup USB Communication Dialog Box Use the Serial Number drop down list box to select the appropriate serial number Click OK Export Makefile Export Makefile exports a buildable project in external make file format To do this com plete the following procedure 1 From the Project menu select Export Makefile The Save As dialog box Figure 67 is displayed Save in c Tutorial O e Eg File name I Save as type Make Files mak Y Cancel Figure 67 Save As Dialog Box 2 Use the Save In drop down list box to navigate to the directory where you want to save your project The default location is in your project directory UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG 3 Type the make file name in the File Name field and click Save You do not have to type the extension mak The extension is added automatically The project is now available as an external make file Build Menu With the Build menu you can build individual files as well as your project You can also use this menu
178. T 0040 T 0043 4h _ VECTORS 44 absolute data T 0044 T 0047 4h __ VECTORS 48 absolute data T 0048 T 004B 4h VECTORS 4C absolute data T 004C T 004F 4h VECTORS 50 absolute data T 0050 T 0053 4h VECTORS 54 absolute data T 0054 T 0057 4h VECTORS 58 absolute data T 0058 T 005B 4h VECTORS 5C absolute data T 005C T 005F 4h VECTORS 60 absolute data T 0060 T 0063 4h __ VECTORS 64 absolute data T 0064 T 0067 4h __ VECTORS 68 absolute data T 0068 T 006B 4h _ VECTORS 6C absolute data T 006C T 006F 4h ROM TEXT normal data T 0070 T 007B ch startup normal data T 007C T 013F c4h SEGMENTS WITHIN MODULES Module src boot common startupexs asm File startupexkS obj Version 1 0 12 06 2005 16 57 27 Name Base Top size Segment VECTORS 04 T 0004 T 0007 4h Segment NEAR BSS R FFBOOO0 R FFBOO3 4h Segment startup T 007C T 013F c4h Module SOURCE MAIN C File main obj Version 1 0 12 07 2005 13 51 42 Name Base Top Size Segment main TEXT C 00801A C 008061 48h Segment NEAR BSS R FFBOOA R FFB007 4h Segment ROM TEXT T 0070 T 007B ch Module SOURCE Z16F2800100ZCOG C File Z16F2800100Z2COG obj Version 1 0 12 07 2005 13 51 43 Name Base Top Size Segment 100zcog TEXT C 008062 C 0082F9 298h Segment VECTORS 18 T 0018 T 001B 4h UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual R FFBO14 R FFBO3D 2 06 2005 16 58 06 Top Size C 008467 1 0 12 06 2005 Top
179. Use Selected Target 216F28114L C Target File EN Delete Source Target After Copy Destination Name for New Target pa 16F28114L Place Target File in Project Directory C ZDS Default Directory C Another Location a El Cancel Figure 64 Target Copy or Move Dialog Box 1 Select the Use Selected Target button if you want to use the target listed to the right of this button description or select the Target File button to use the Browse button Lb to navigate to an existing target file If you select the Use Selected Target button enter the name for the name for the new target in the Name for New Target field 2 Select the Delete Source Target After Copy check box if you do not want to keep the original target 3 Inthe Place Target File In area select the location where you want the new target file saved in the project directory ZDS default directory or another location 4 Click OK Delete Click Delete to remove the currently highlighted target The following message is displayed Delete target name Target Click Yes to delete the target or No to cancel the command UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 87 zZiLOG Debug Tool Select the appropriate debug tool in the Current drop down list box e Ifyou select EthernetSmartCable and click Setup in the Debug Tool area the Setup Ethernet Smart Cable Communication dial
180. Verify Download button Removed PL and PW for CR 3684 Added Table 12 on page 308 Added the checksum fillmem loadmem and savemem commands Updated the sample command script file Updated Added new sections Added note for CR 5661 Added new shortcuts Revision History ZiLOG Developer Studio ll ZNEO User Manual Table of Contents Pr fac 0 0e yea a tae ee xxiii ZDS II System Requirements 0 ccc ee xxiii Supported Operating Systems noaua neonan xxiii Recommended Host System Configuration 0 0 0 cece cece momo xxiii Minimum Host System Configuration 0 0 0 0 cece eee eee eee Xxiv When Using the USB Smart Cable o ooooooocococorocrrr eese xxiv When Using the Ethernet Smart Cable 0 20 0 cece eee XX1V ZiLOG Technical Support 00 cece eens xxiv Before Contacting Technical Support oooocoococcococcoconc XXV 1 Getting Started coser bb Ere na xn oec Om on ec rn ic 1 Installing ZDS AD 20 esee v ER EREENPR di il 1 Developer s Environment Tutorial oooooooooooooorrrrr ees 1 Create a New Project ooooooocoocoo hh 2 Add a File to the Project muii O a E OE RR 6 Set Up the Project ooooooocooconcorcooccn e hh hn 8 Save the ProJect loce bewebbRRUNLRE id lee beaks incida a 14 2 Using the Integrated Development Environment ooooooomomocmomo m o 15 Toolbars aa 16 File Toolbar e hrs 17 Build Toolbar 5 215 pia go Rt
181. YEARS TAG DATE EWYEARS DS DSIZE N N The TAG directive in the last example above creates the symbols NEWYEARS MONTH NEWYEARS DAY and NEWYEARS YEAR The space for NEWYEARS is allocated by the Ds directive 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 196 zZiLOG UNION Directive The UNION directive is similar to the STRUCT directive except that the offset is reset to zero on each label A UNION directive cannot have an offset or parent union The key word to terminate a UNION definition is ENDSTRUCT The UNION directive has the following form stag UNION name_1 DS countl name _2 DS count2 name TAG stagx count name n DS count3 ssize ENDSTRUCT stag An example of the UNION directive usage is as follows BYTES STRUCT BO DS 1 Bl DS 1 B2 DS 1 B3 DS 1 BSIZE ENDSTRUCT BYTES LONGBYTES UNION LDATA BLKL 1 BDATA TAG BYTES SIZE ENDSTRUCT LONGBYTES WITH and ENDWITH Directives Using the fully qualified names for fields within a structure can result in very long names The WITH directive allows the initial part of the name to be dropped The WITH and ENDWITH directives have the following form WITH name directives ENDWITH name The identifier name may be the name of a
182. Z8Encore eZ80Acclaim Crimzon or Z8GP version is the ZDS II version number For example version might be 4 11 0 or 5 0 0 e Troubleshooting section Troubleshooting the Linker on page 246 Preface UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual xxvi zZiLOG UMO17103 0207 Preface ZiLOG Developer Studio ll ZNEO User Manual zZiLOG I Getting Started This section provides a tutorial of the developer s environment so you can be working with the ZDS II graphical user interface GUI in a short time This section covers the fol lowing topics Installing ZDS II on page 1 e Developer s Environment Tutorial on page 1 NOTE You can use this tutorial to install and start using ZDS II without any attached hardware If you have a development kit use the included Quick Start Guide to set up your hardware and install ZDS II For steps to create a new project using target hardware see New Project on page 36 INSTALLING ZDS II If you have not already installed ZDS II perform the following procedure 1 Insert the CD in your CD ROM drive 2 Follow the setup instructions on your screen Install the application in the location where you want it DEVELOPER S ENVIRONMENT TUTORIAL This tutorial shows you how to use the basic features of ZILOG Developer Studio To begin this tour you need a basic understanding of Microsoft Windows Estimated time for completing this exercise is
183. ZDATE 127 ZDS definition xxiv latest released version xxiv ZDS Default Directory button 86 ZDS II installing 1 running from the command line 297 zdsproj file extension 3 ZILOG 127 ZiLOG functions DI 136 EI 137 getch 137 init uart 137 kbhit 138 putch 138 RI 139 select port 139 SET VECTOR 140 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 431 ZiLOG TDI 141 ZiLOG header files lt sio h gt 135 lt zneo h gt 134 ZiLOG web site URL xxiv _ ZNEO 127 ZNEO address spaces 168 ZNEO developer s environment IDE window 16 memory requirements xxiii menus 34 software installation 1 system requirements xxiii toolbars 16 tutorial 1 ZNEO memory ERAM 76 255 EROM 76 254 IODATA 76 255 RAM 76 255 ROM 75 254 lt zneo h gt header 134 Index ZiLOG Developer Studio ll ZNEO User Manual Z 432 ZiLOG UMO17103 0207 Index
184. ZiLOG ZiLOG Developer Studio II ZNEO User Manual UMO17103 0207 VAF ZiLOG This publication is subject to replacement by a later edition To determine whether a later edition exists or to request copies of publications visit www zilog com Feedback For any comments detail technical questions or reporting problems please visit ZILOG s Technical Support at http support zilog com Document Disclaimer 02007 by ZiLOG Inc All rights reserved Information in this publication concerning the devices applications or technology described is intended to suggest possible uses and may be superseded ZiLOG INC DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY OF THE INFORMATION DEVICES OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT ZiLOG ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION DEVICES OR TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE Devices sold by ZiLOG Inc are covered by warranty and limitation of liability provisions appearing in the ZiLOG Inc Terms and Conditions of Sale ZiLOG Inc makes no warranty of merchantability or fitness for any purpose Except with the express written approval of ZiLOG use of information devices or technology as critical components of life support systems is not authorized No licenses are conveyed implicitly or otherwise by this document under any intellectual property rights Z8 Z8 Encore Z8
185. a a Di EA HR aie AA e Di ada 142 Segment Naming ii a deis 143 Linker Command Files for C Programs 2 0 0 cece cee eee 144 Linker Referenced Files 0 0 0 cece cent enna 146 Linker Symbols econ pet Kebab thawed decade eed dad 147 UMO17103 0207 Table of Contents ZiLOG Developer Studio ll ZNEO User Manual nA vii Sample Linker Command File 0 0 0c ccc ees 147 ANSI Standard Compliance 0 0 ccc eh 150 Freestanding Implementation 0 cece eee ene ees 150 Deviations from ANSIC 1 eee ene n eens 150 Warning and Error Messages 00 cece cece e nents 152 Preprocessor Warning and Error Messages 0 eee eee eee ne ess 152 Front End Warning and Error Messages 0 0 cee eect eee ee eee 155 Optimizer Warning and Error Messages 00 0 cee eee ee ee 164 Code Generator Warning and Error Messages 00 ce cece erences 166 4 Using the Macro Assembler ccc cece eee c ec cece eee rece eee ceees 167 Address Spaces and Segments 0 0 cece cette eese 167 Allocating Processor Memory 0000 cece cece ne 168 Address Spaces NS RN 168 Segments o ERREUR 168 Assigning Memory at Link Time 00 0000 cece eee eens 170 Ouiput Files aiii ie 170 Source Listing lst Format ooooooooooorrorrr e 170 Object Code obj File o oooooooooooororrrrr tte 171 Source Language Structure o ooooooooooror ehe
186. able check box on the Debugger tab of the Options dialog box see page 107 the program counter resets to the first line of the program Stop Debugging Button The Stop Debugging button ends the current debug session To stop program execution click the Break button Go Button The Go button executes project code from the current program counter If not in Debug mode when the button is clicked a debug session is started Run to Cursor Button The Run to Cursor button executes the program code from the current program counter to the line containing the cursor in the active file or the Disassembly window The cursor must be placed on a valid code line a C source line with a blue dot displayed in the gutter or any instruction line in the Disassembly window Break Button The Break button stops program execution at the current program counter Step Into Button The Step Into button executes one statement or instruction from the current program counter following the execution into function calls When complete the program counter resides at the next program statement or instruction unless a function was entered in which case the program counter resides at the first statement or instruction in the function Step Over Button The Step Over button executes one statement or instruction from the current program counter without following the execution into function calls When complete the program counter resides at the next program s
187. able initialization See Language Extensions on page 114 for full details of the operations performed in the standard startup module Some of these steps carried out in the standard startup module might not be required for every application so if code space is extremely tight you might want to make some judi cious modifications to the startup code The source code for the startup module is located in the following file lt ZDS Installation Directory NsrcNboootNcommonNstartupX asm Here lt ZDS Installation Directory gt is the directory in which ZiLOG Developer Studio was installed By default this is C Program Files ZiLOG ZDSII_ZNEO lt ver sion where lt version gt might be 4 11 0 0r5 0 0 The Xin startupX asmis s for the small model or 1 for the large model Included in Project If the Included in Project button is selected then the standard startup module is not linked to your application In this case you are responsible for including suitable startup code either by including the source code in the Project Workspace window or by including a precompiled object module in the Additional Object Library Modules field If you modify the standard startup module to tailor it to your project you need to select the Included in Project button for your changes to take effect Use Standard Startup Linker Commands If you select this check box the same linker commands that support the standard startup module are inserted into y
188. ace debug Turns on debug information generation UMO017103 0207 Appendix A Running ZDS II from the Command Line ZiLOG Developer Studio ll ZNEO User Manual L as ZiLOG Table 11 Linker Command Line Options Continued Option Name Description define symbol expr Defines a symbol and sets it to the constant value For example define DEBUG 0 This option is equivalent to the C define statement The alternate syntax define myvar is the same as define myvar 1 format intel intel32 omf695 Sets the format of the hex file output of the linker to intel or intel32 Intel Hex records or om 695 IEEE695 format igcase Suppresses case sensitivity of user defined symbols When this option is used the linker converts all symbols to uppercase This is the default setting locate segment at expr Specifies the address where a group address space or segment is to be located nodebug Turns off debug information generation noigcase Enables case sensitivity of user defined symbols The default setting is igcase order segment list or space list Establishes a linking sequence and sets up a dynamic range for contiguously mapped address spaces range space address range Sets the lower and upper bounds of a group address space or segment sequence segment list or space list Allocates a group address space or segment in the order specified
189. adecimal numbers 177 instructions 173 labels 203 line continuation 172 line definition 172 line length 172 macro expansion 57 numeric representation 175 octal numbers 177 operator precedence 178 preserving registers 132 relational operators 176 reserved words 173 return values 132 source line 172 structure 172 structures 192 syntax 205 unions 192 assert function 353 assert macro 340 lt assert h gt header 340 atan function 344 354 atan2 function 344 354 atan2f function 344 354 atanf function 344 354 atof function 349 355 atoff function 349 355 atoi function 349 355 Index atol function 349 355 Auto Indent check box 105 Automatically Reload Externally Modified Files check box 104 B Backslash used in assembly 172 BASE OF 217 227 batch script file command 307 312 Beginning a project 2 Binary numbers in assembly 177 BLKB directive 183 BLKL directive 183 BLKW directive 183 Blue dots 20 23 24 279 293 Bookmarks adding 30 deleting 31 example 30 finding 31 32 inserting 30 jumping to 31 32 moving to 31 32 next bookmark 31 previous bookmark 32 removing 31 setting 30 using 29 Boolean operators in assembly 176 bp when script file command 313 bp script file command 313 Break button 23 Breakpoints 294 activating 295 adding 293 deactivating 295 deleting 296 disabling 295 enabling 295 finding 295 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 410 zZiLO
190. ailable library the C run time library The subset of the run time library dedicated to floating point operations also has a separate control to allow for special han dling as explained in Floating Point Library on page 73 Use C Runtime Library The C run time library included with ZDS II provides selected functions and macros from the Standard C Library ZiLOG s version of the C run time library supports a subset of the Standard Library adapted for embedded applications as described more fully in the Using the ANSI C Compiler chapter on page 113 If your project makes any calls to standard library functions you need to select the Use C Runtime Library check box unless you prefer to provide your own code for all library functions that you call As noted in Additional Object Library Modules on page 71 you can also set up your application to call a mixture of ZiLOG provided functions and your own customized library functions To do so select the Use C Runtime Library check box Calls to standard library functions will then call the functions in the ZiLOG default library except when your own custom ized versions exist ZiLOG s version of the C run time library is organized with a separate module for each function or in a few cases for a few closely related functions Therefore the linker links only those functions that you actually call in your code This means that there is no unnec essary code size penalty when you select t
191. ains in it If a segment name is changed to NULL using the CHANGE command to the linker the segment is deleted from the linking process This can be useful if you need to link only part of an executable or not write out a particular part of the executable The predefined space NULL can also be used to prevent initialization of data while reserving the segment in the original space using the COPY command Refer to Linker Expressions on page 226 for the format to write an expression DEBUG The DEBUG command causes the linker to generate debug information for the debugger This option is applicable only if the executable file is IEEE 695 Syntax DEBUG DEFINE The DEFINE command creates a user defined public symbol at link time This command is used to resolve external references XREF used in assemble time Syntax DEFINE lt symbol name gt lt expression gt lt symbol name gt is the name assigned to the public symbol lt expression gt is the value assigned to the public symbol UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual 219 zZiLOG Example DEFINE copy size copy top of data seg copy base of data seg NOTE Refer to Linker Expressions on page 226 for the format to write an expression FORMAT The FORMAT command sets the executable file of the linker according to the following table File Type Option
192. ame_2 DS count2 tname TAG stagx count ssize ENDSTRUCT stag The TAG directive to assign a label to have a structure type has the following form mame TAG stag Apply stag to tname tname DS ssize Allocate space for tname Once applied to label tname the individual structure elements are applied to tname to pro duce the desired offsets using tname as the structure base For example the label tname name 2 is created and assigned the value tname stag name 2 If there are any alignment requirements with the structure the TAG directive attaches the required alignment to the label The optional count on the TAG directive is meaningful only inside a structure definition and implies an array of the TAG structure NOTE Keeping the space allocation separate allows you to place the TAG declarations that assign structure to a label in the header file in a similar fashion to the STRUCT and XREF directives You can then include the header file in multiple source files wherever the label is used Make sure to perform the space allocation for the label in only one source file Examples of the TAG directive are as follows DATE STRUCT MONTH DS 1 DAY DS 1 YEAR DS 2 DSIZE ENDSTRUCT DATE NAMELEN EQU 30 EMPLOYEE STRUCT NAME DS NAMELEN SOCIAL DS 10 START TAG DATE SALARY DS 1 ESIZE ENDSTRUCT EMPLOYEE EW
193. amily 21 BF Series CPU Z16F2811AL m Build M Show Warnings Iv Generate Debug Information Intermediate Files Directory fc Program FilesziLOG zDSIl ZNEO 4 11 0 sampl mu Figure 47 General Page of the Project Settings Dialog Box CPU Family The CPU Family drop down list box allows you to select the appropriate ZNEO family CPU The CPU drop down list box defines which CPU you want to define for the ZNEO target To change the CPU for your project select the appropriate CPU in the CPU drop down list box NOTE Selecting a CPU does not automatically select include files for your C or assembly source code Include files must be manually included in your code Selecting a new CPU automatically updates the compiler preprocessor defines assembler defines UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 55 zZiLOG and where necessary the linker address space ranges and selected debugger target based on the selected CPU Show Warnings The Show Warnings check box controls the display of warning messages during all phases of the build If the check box is enabled warning messages from the assembler compiler librarian and linker are displayed during the build If the check box is disabled all these warnings are suppressed Generate Debug Information The Generate Debug Information check box makes the build generate debug information that c
194. an be used by the debugger to allow symbolic debugging Enable this option if you are planning to debug your code using the debugger The check box enables debug infor mation in the assembler compiler and linker Enabling this option usually increases your overall code size by a moderate amount for two reasons First if your code makes any calls to the C run time libraries the library ver sion used is the one that was built using the Limit Optimizations for Easier Debugging set ting see the Limit Optimizations for Easier Debugging on page 58 Second the generated code sets up the stack frame for every function in your own program Many functions those whose parameters and local variables are not too numerous and do not have their addresses taken in your code would not otherwise require a stack frame in the ZNEO architecture so the code for these functions is slightly smaller if this check box is disabled NOTE This check box interacts with the Limit Optimizations for Easier Debugging check box on the Code Generation page see Limit Optimizations for Easier Debugging on page 58 When the Limit Optimizations for Easier Debugging check box is selected debug information is always generated so that debugging can be performed The Generate Debug Information check box is grayed out disabled when the Limit Optimizations for Easier Debugging check box is selected If the Limit Optimizations for Easier Debugging check box is later deselect
195. an on the stack when possible This usually makes the resulting code smaller and faster and therefore the default is that this check box is enabled However in some applications this check box might produce larger and slower code when a function contains a large number of local variables The effect of this check box on overall program size and speed can only be assessed glo bally across the entire application which the compiler cannot do automatically Usually the overall application size is smaller but there can be exceptions to that rule For example in an application that contains 50 functions this check box might make 2 functions larger and the other 48 functions smaller Also if those two functions run slower with the check box enabled but the others run faster then whether the overall program speed is improved or worsened depends on how much time the application spends in each function 2 Using the Integrated Development Environment UMO17103 0207 64 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Because the effect of applying this option must be evaluated across an application as a whole user experimentation is required to test this for an individual application Only a small fraction of applications benefit from deselecting the Use Register Variables check box NOTE This check box interacts with the Limit Optimizations for Easier Debugging check box on the C page see Limit Optimizations for Easier Debuggin
196. and ORDER UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 69 zZiLOG directives but combine with them Use caution with this override capability because some of the autogenerated directives might interact with other directives and because there is no visual indication to remind you that some of your project settings might not be fully taking effect on later builds If you need to create a complex linker command file contact ZILOG Technical Support for assistance See ZiLOG Technical Support on page xxiv If you have selected the Additional Directives check box your manually inserted direc tives are not erased when you build your project They are retained and re inserted into the same location in each newly created linker command file every time you build your project NOTE In earlier releases of ZDS II it was necessary to manually insert a number of directives if you had a C project and did not select the Standard C Startup Module This is no longer necessary The directives needed to support a C startup module are now always added to the linker command file The only time these directives are not added is if the project is an Assembly Only project Use Existing Use the following procedure if you do not want a new linker command file to be generated when you build your project 1 Select the Use Existing button 2 Click on the Browse button Lb The Select Link
197. and any additional object library modules specified in the Objects and Libraries page in the Project Settings dialog box see page 70 The linker uses the linker command file to control how these object modules and libraries are linked The linker command file is automatically generated by ZDS II if the Always Generate from Settings button is selected see Always Generate from Settings on page 67 You can add additional linker commands with the Additional Linker Directives dialog box page 68 If you want to override the automatically generated linker command file select the Use Existing button see Use Existing on page 69 The linker can also be invoked from the DOS command line or through the ZDS II Com mand Processor For more information on invoking the linker from the DOS command line see the Running ZDS II from the Command Line appendix on page 297 To invoke the linker through the ZDS II Command Processor see the Using the Command Proces sor appendix on page 307 UMO017103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual Z 215 zZiLOG LINKER COMMANDS This section describes the commands of a linker command file lt outputfile gt lt module list gt on page 216 CHANGE on page 216 COPY on page 217 DEBUG on page 218 DEFINE on page 218 FORMAT on page 219 GROUP on page 219 HEADING on page 219 LOCATE on page 220 M
198. and documentation e Super VGA video adapter e CD ROM drive for installation e USB high speed port when using USB Smart Cable Ethernet port when using the Ethernet Smart Cable e Internet browser Internet Explorer or Netscape Preface UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual xxiv zZiLOG Minimum Host System Configuration Windows 98 SE Pentium II 233 MHz processor 96 MB RAM 25 MB hard disk space application only Super VGA video adapter CD ROM drive for installation USB high speed port when using USB Smart Cable Ethernet port when using the Ethernet Smart Cable Internet browser Internet Explorer or Netscape When Using the USB Smart Cable High speed USB fully compatible with original USB Root direct or self powered hub connection NOTE The USB Smart Cable is a high power USB device When Using the Ethernet Smart Cable Ethernet 10Base T compatible connection ZILOG TECHNICAL SUPPORT For technical questions about our products and tools or for design assistance please use our web page http www zilog com You must provide the following information in your support ticket Product release number Located in the heading of the toolbar Product serial number Type of hardware you are using Exact wording of any error or warning messages Any applicable files attached to the e mail To receive ZilOG Developer Studio II ZDS II product updates and notifications re
199. any editor that can save or export files in a text based format Each com mand must be listed on its own line Anything following a semicolon is considered a comment The following is a sample command script file change to correct default directory cd m ZNEO test focustests open project focusl zdsproj log focusl log Create log file log on Enable logging rebuild reset bp done go wait 2000 Wait 2 seconds print pc x reg PC log off Disable logging quit Exit debug mode close project wait 2000 open project focus2 zdsproj reset bp done go wait 2000 Wait 2 seconds log focus2 log Open log file log on Enable logging print pc x reg PC log off Disable logging quit exit Exit debug mode This script consecutively opens two projects sets a breakpoint at label done runs to the breakpoint and logs the value of the PC register After the second project is complete the script exits the IDE The first project is also rebuilt Appendix B Using the Command Processor UMO17103 0207 312 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG SUPPORTED SCRIPT FILE COMMANDS The Command Processor supports the following script file commands UMO17103 0207 add file delete config savemem batch examine for Expressions set config bp examine for Variables step build exit stepin cancel all fillmem stepout cancel bp go stop cd list bp target copy check
200. ary Cancel Figure 102 Save to File Dialog Box 4 Inthe File Name field enter the path and name of the file you want to save the memory to or click the Browse button El to search for a file or directory 5 Type the start address in hexadecimal format in the Start Address Hex field and type the end address in hexadecimal format in the End Address Hex field This specifies the address range of memory to save to the specified file 6 Select whether to save the file as text hex hexadecimal or binary 7 Click OK to save the memory to the specified file 7 Using the Debugger UMO17103 0207 286 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Load a File into Memory Use this procedure to load or to initialize memory from an existing binary hexadecimal or text file Perform the following steps to load a file into the code s memory 1 2 3 3 6 T Select the memory space in the Space drop down list Right click in the Memory window list box to display the context menu Select Load from File The Load from File dialog box is displayed as shown in Figure 103 Load From File File Name E File Format C Text Start Address Hex ex Hex C Binary Cancel Figure 103 Load from File Dialog Box In the File Name field enter the path and name of the file to load or click the Browse button b to search for the file In the Start Address Hex field enter the start add
201. as e ea Patr a bad se wa 119 Interrupt Support 2 m e 120 Placement Directives 0 0 ehh 121 String Placement vit a sad Rep Rua ete ec e doped aue 122 Inlhne Assembly ueno IR EN EE Fr UR RU PEE 123 Char and Short Enumerations 0 00000 c eee ees 124 Setting Flash Option Bytes in C 20 eee eens 125 Supported New Features from the 1999 Standard 0000 c eee eee 125 Type Sizes m 126 Predefined Macros 0 cece cece tenet e ene n ene eens 127 ID cun a a lis OG Beene og Baleares PAA alle e e 128 Calling Conventions 2 0 0 eee een e een eeae 128 Function Call Mechanism 00 cece cece eee ene 128 Special Cases iik cad ead ER da da qd hace bad ER a 130 Calling Assembly Functions from C 1 0 eee eee nee 131 Function Naming Convention n n aeaa 000 c cette eee eee ene 131 Argument Locations ussas annaa ehh 131 Ret in Values 2222s 64080 e de edd seda db was 132 Preserving Registers 0 0 0 0 ccc tenet ene e ene 132 Calling C Functions from Assembly 0 0 000 cece teens 132 Assembly Pile 2 ur dara ree t eatin pers Reames Midas Lewd a 132 Referenced C Function Prototype 0 ccc cece eh 133 Command Line Options 0 eh 133 Run Time Library 0 0 hh 133 ZALOG Header Files ee coal anaitikia deed ed bred d dus 134 ZALOG F nctions a a e aea Re ideo ccs 136 Stack Pointer Overflow o ooooooooororrrrrrr ea 142 Startup Flu ii
202. as in scope the definition of the function of a declaration such as void fl rnt 4 vprintf Equivalent to printf with the variable argument list replaced by arg which has been ini tialized by the va start macro and possibly subsequent va arg calls The vprintf function does not invoke the va end function Synopsis include lt stdarg h gt finclude lt stdio h gt int vprintf const char format va list arg Returns The number of characters transmitted or a negative value if an output error occurred Example va list va initialize the variable argument va here vprintf d d d va vsprintf Equivalent to sprintf with the variable argument list replaced by arg which has been initialized by the va start macro and possibly subsequent va arg calls The vsprintf function does not invoke the va end function Synopsis include lt stdarg h gt include lt stdio h gt int vsprintf char s const char format va_list arg Returns The number of characters written in the array not counting the terminating null character Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 398 zZiLOG Example va list va char buf 80 initialize the variable argument va here vsprint buf d d d va UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual Z soo zZiLOG Glossary A ABS Absolute Value A D A
203. ase Figure 68 Select Configuration Dialog Box 2 Highlight the configuration that you want to use and click OK There are two standard configuration build configurations e Debug This configuration contains all the project settings for running the project in Debug mode Release This configuration contains all the project settings for creating a Release version of the project For each project you can modify the settings or you can create your own configurations These configurations allow you to easily switch between project setting types without hav ing to remember all the setting changes that need to be made for each type of build that might be necessary during the creation of a project All changes to project settings are stored in the current configuration setting NOTE To add your own configuration s see Manage Configurations on page 91 Use one of the following methods to activate a build configuration e Use the Select Configuration dialog box See Set Active Configuration on page 90 e Use the Build toolbar See Select Build Configuration List Box on page 19 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Use the Project Settings dialog box to modify build configuration settings See Settings on page 52 Manage Configurations For your specific needs you can add different configurations for your projects To add a cus
204. assembled The options on the Assembler page Figure 48 are described in this section Wi Project Settings Configuration Debug 5e General SOMN E gt E Includes x 2 fill C B AE Sil Code Generation ES 3 Listing Files Defines Sil Preprocessor 21 6F28114L 1 Z16F SERIES 1 Sil Advanced El Linker Listing Files 5s Commands V Generate Assembly Listing Files lst 2 Objects and Libraries we TM 80 pand Macros Page Width 3 Address Spaces Eh Warnings Page Lenath 56 3 Output 3d Debugger Cancel Help Figure 48 Assembler Page of the Project Settings Dialog Box UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 57 zZiLOG Includes The Includes field allows you to specify the series of paths for the assembler to use when searching for include files The assembler first checks the current directory then the paths in the Includes field and finally the default ZDS II include directories The ZDS II default include directory is lt ZDS Installation Directory NincludeNstd where ZDS Installation Directory gt is the directory in which ZiLOG Developer Studio was installed By default this would be C Program FilesNVZiLOGNZDSII ZNEO version where lt version gt might be 4 11 0 or 2 00 Defines The Defines field is equivalent to placing symbol EQU value in your assembly source code It is useful for conditional
205. ata Code Optional Unused Large Model Stack ERAM Data Code Optional External RAM Optional Unused External Flash Optional Code Default EROM Data Internal Flash ROM Data Startup Code Vector Table Option Bytes Figure 88 Typical ZNEO Programmer s Model General UMO17103 0207 16 Bit Addressable Data Not to Scale 16 Bit ddressable Data 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual Z 257 ZiLOG The following default segments are provided by the assembler and associated with spe cific address spaces as shown in the following table Address Range Space Segment ROM ROM DATA ROM TEXT VECTORS EROM CODE EROM DATA EROM TEXT RAM NEAR DATA NEAR BSS NEAR TEXT ERAM FAR DATA FAR BSS FAR TEXT IODATA IOSEG For a detailed description of these segments see Predefined Segments on page 168 You can define your own segments in these address spaces using the DEFINE assembler directive For example DEFINE romseg SPACE ROM Defines the new segment romseg SEGMENT romseg Sets the current segment to romseg See User Defined Segments on page 169 for further details Unconventional Memory Layouts It might be necessary for a target design to locate memory or I O in an address range that the ZDS II GUI does not directly accommodate Some GUI address range limitations can b
206. ata from stdin int sprintf char s const char format Writes formatted data to string int sscanf const char s const char format Reads formatted data from string int vprintf const char format va list arg Writes formatted data to a stdout int vsprintf char s const char format va_list arg Writes formatted data to a string Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 348 zZiLOG Character Input Output int getchar void Reads a character from stdin char gets char s Reads a line from stdin int putchar int c Writes a character to stdout int puts const char s Writes a line to stdout General Utilities lt stdlib h gt The lt stdlib h gt header declares several types functions of general utility and macros Types div t Structure type that is the type of the value returned by the div function ldiv t Structure type that is the type of the value returned by the Idiv function size t Unsigned integral type of the result of the sizeof operator wchar t Integral type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales Macros EDOM Expands to distinct nonzero integral constant expressions ERANGE Expands to distinct nonzero integral constant expressions EXIT SUCCESS Expands to integral expression which indicates successful termination status EXIT
207. ath SR Advanced fe fi Linker SS Commands User Include Path 2 Objects and Libraries m SA Address Spaces 3 Warnings Eh Output 7 Debugger Cancel Help Figure 51 Preprocessor Page of the Project Settings Dialog Box 2 Using the Integrated Development Environment UMO17103 0207 61 62 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Preprocessor Definitions The Preprocessor Definitions field is equivalent to placing define preprocessor direc tives before any lines of code in your program It is useful for conditionally compiling code Do not put a space between the symboliame and equal sign however multiple symbols can be defined and must be separated by commas Standard Include Path The Standard Include Path field allows you to specify the series of paths for the compiler to use when searching for standard include files Standard include files are those included with the include lt file h gt preprocessor directive If more than one path is used the paths are separated by semicolons The compiler first checks the current directory then the paths in the Standard Include Path field The default standard includes are located in the following directories lt ZDS Installation Directory NincludeWstd lt ZDS Installation Directory NincludeWMilog where ZDS Installation Directory is the directory in which ZiLOG Developer Studio was installed By default this would be c Program Fi
208. ation marks on both sides of a pair of braces for the stdinc and usrinc commands for the C compiler For example Option Name stdince C ez8 include Table 9 Compiler Command Line Options Description asm Assembles compiler generated assembly file This switch results in the generation of an object module The assembly file is deleted if no assemble errors are detected and the keepasm switch is not given The default is asm asmsw sw Passes sw to the assembler when assembling the compiler generated assembly file chartype s u Selects whether plain char is implemented as signed or unsigned The default is unsigned cpu cpu Sets the CPU debug Generates debug information for the symbolic debugger define def Defines a symbol and sets it to a constant value For example define myvar 0 The alternate syntax define myvar is the same as define myvar 1 genprintf The format string is parsed at compile time and direct inline calls to the lower level helper functions are generated The default is genprintf help Displays the compiler help screen keepasm Keeps the compiler generated assembly file keeplst Keeps the assembly listing file 1st list Generates a lis source listing file listinc Displays included files in the compiler listing file Appendix A Running ZDS II from the Command Line UMO17103 0207 302 ZiLOG Developer Studio Il ZNE
209. ations of RAM ERAM data should be done in your code For example Segment NEAR BSS val DS 4 allocate 4 uninitialized bytes OK segment code ld r0 1512345678 ld val r0 initialize ram location val as part of code OK Segment NEAR BSS val dl 12345678 incorrect usage for production code as RAM does not retain value across power cycles NOT OK UMO17103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 261 zZiLOG If your application has a lot of such initializations this approach can be tedious In that case an alternative is to use the linker COPY directive and perform the physical copy for all the RAM data as a single loop in the startup An example can be found in the C startup provided in the installation under src boot common startups asm Copy ROM data into internal RAM EA RO low near romdata EA R1 low neardata LD R2 len neardata l JP lab10 lab9 LD B R3 RO LD B R1 R3 lab10 DINZ R2 1ab9 Along with the following linker directives COPY NEAR DATA EROM define low near romdata copy base of NEAR DATA define low neardata base of NEAR DATA define len neardata length of NEAR DATA Where NEAR DATA is the RAM segment containing initialized data segment NEAR DATA vall dl 512345678 val2 dl 23456789 val3 dl 3456789A The linker COPY directive only designates the load addresses and the run time
210. ative integer such that FLT_RADIX raised to that power approximates a positive floating point number in the range of represented numbers Minimum negative integer such that 10 raised to that power approximates a positive floating point number in the range of represented values int log10 FLT MIN and so on Radix of exponent representation Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 343 zZiLOG FLT_ROUND Rounding mode for floating point addition indeterminable 0 toward zero 1 to nearest 2 toward positive infinity 3 toward negative infinity LDBL DIG Number of decimal digits of precision LDBL MANT DIG Number of base FLT RADIX digits in the floating point mantissa LDBL MAX Maximum represented floating point numbers LDBL MAX EXP Maximum integer such that FLT RADIX raised to that power approximates a floating point number in the range of represented numbers LDBL MAX 10 EXP Maximum integer such that 10 raised to that power approximates a floating point number in the range of represented value int log10 LDBL MAX and so on LDBL MIN Minimum represented positive floating point numbers LDBL MIN EXP Minimum negative integer such that FLT RADIX raised to that power approximates a positive floating point number in the range of represented numbers LDBL MIN 10 EXP Minimum negative integer such that 10 raised to that power approximates a positive floating point number in the
211. ator ZiLOG Developer Studio Il ZNEO User Manual Zu ziLoc How do speed up the linker Use the following tips to lower linker execution times e Ifyou do not need a link map file deselect the Generate Map File check box in the Project Settings dialog box Output page See page 79 Make sure that all DOS windows are minimized How do generate debug information without generating code Use the COPY or CHANGE command in the linker to copy or change a segment to the predefined NULL space If you copy the segment to the NULL space the region is still allocated but no data is written for it If you change the segment to the NULL space the region is not allocated at all The following examples are of commands in the linker command file COPY myseg NULL CHANGE myseg NULL How much memory is my program using Unless the Generate Map File check box is unchecked in the Project Settings dialog box Output page the linker creates a link map file each time it is run The link map file name is the same as your executable file with the map extension and resides in the same direc tory as your project file The link map has a wealth of information about the memory requirements of your program Views of memory usage from the space segment and module perspective are given as are the names and locations of all public symbols See Generate Map File on page 79 and MAP on page 220 How do create a hex
212. ave 1 to 8 characters Positive numbers are indicated by the absence of a sign Nega tive numbers are indicated by a minus sign preceding the number Underscores _ can be inserted between hexadecimal digits to improve readability For example ABCDEFFFH hexadecimal SABCDEFFF hexadecimal OFFFFh negative hexadecimal ABCD EFFFH hexadecimal number with underscore ADCOD H NOT a hexadecimal number but a name hexadecimal digit must follow underscore Binary Numbers Binary numbers are signed 32 bit integers ending with the character b or B and consisting of the characters 0 and 1 A binary number can have 32 characters Positive numbers are indicated by the absence of a sign Negative numbers are indicated by a minus sign preceding the number Underscores can be inserted between binary digits to improve readability For example 0101b negative binary number 0010 1100 1010 1111B binary number with underscores Octal Numbers Octal numbers are signed 32 bit integers ending with the character o or O and consisting of the characters 0 7 An octal number can have 1 to 11 characters Positive numbers are indicated by the absence of a sign Negative numbers are indicated by a minus sign 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 178 zZiLOG preceding the number Underscores _ can be inserted between octal digits to improve readability For example
213. ax can take one of the following forms new project pathN name target exe lib lt cpu gt NOREPLACE new project pathN name target lt project type gt lt exe lib gt cpu NOREPLACE where lt name gt is the path and name of the new project If the path is not provided the current working directory is assumed Any file extension can be used but none is required If not provided the default extension of zdsproj is used target must match that of the IDE that is the ZNEO IDE can only create ZNEO based projects e lt exe lib gt must be either exe Executable or 1ib Static Library e lt cpu gt is the name of the CPU to configure for the new project e lt project type can be Standard or Assembly Only Standard is the default NOREPLACE is an optional parameter to use to prevent the overwriting of existing projects For example new project testl zdsproj ZNEO exe new project testl zdsproj ZNEO exe NOREPLACE open project The open project command opens the project designated by project name If the full path is not supplied the current working directory is used The command fails if the spec ified project does not exist The following is the syntax ofthe open project command open project lt project_name gt For example open project testl zdsproj open proje
214. be used to configure either UARTO or UARTI and select the UART passed as the current one for use All calls to putch getch and kbnit use the selected UART You can also change the selected UART using the select port function without having to reinitialize the UART Synopsis include lt sio h gt int select port int port 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 140 Returns A zero is returned on success a nonzero is returned on failure Example tinclude lt stdio h gt include lt sio h gt void main void init uart UARTO DEFFREQ DEFBAUD init uart UART1 DEFFREO DEFBAUD select port _UARTO printf Hello UARTO n Write to uart0 select port UART1 printf Hello UART1 n Write to uartl SET_VECTOR SET VECTOR is a ZiLOG intrinsic function provided by the compiler to specify the address of an interrupt handler for an interrupt vector Because the interrupt vectors of the ZNEO microcontroller are usually in ROM they cannot be modified at run time The SET VECTOR function works by switching to a special segment and placing the address of the interrupt handler in the vector table No executable code is generated for this state ment Calls to the SET VECTOR intrinsic function must be placed within a function body The reduceopt compiler option does not affect the SET VECTOR function handling
215. ber with E instead of e introducing the exponent The exponent always contains at least two digits However if the magnitude to be converted is greater than or equal to 1E 100 additional exponent digits are written as necessary g G The double argument is converted in style f or e or in style E in the case ofa G conversion character with the precision specifying the number of significant digits The style used depends on the value converted style e is used only if the exponent resulting from the conversion is less than 4 or greater than the precision Trailing zeros are removed from the result a decimal point appears only if it is followed by a digit c The int argument is converted to an unsigned char and the resulting character is written S The argument is taken to be a const char pointer to a string Characters from the string are written up to but not including the terminating null character or until the number of characters indicated by the precision are written If the precision is missing it is taken to be arbitrarily large so all characters before the first null character are written p The argument is taken to be a const void pointer to an object The value of the pointer is converted to a sequence of hex digits n The argument is taken to be an int pointer to an integer into which is written the number of characters written to the output stream so far by this call to printf No argument is converted A is w
216. bj C startup object file large model with external interface set up for devices with Port K lib zilog startupexl obj C startup object file large model with external interface set up for devices without Port K src boot common startupexl asm C startup source file large model with external interface set up lib zilog startupexks obj C startup object file small model with external interface set up for devices with Port K lib zilog startupexs obj C startup object file small model with external interface set up for devices without Port K src boot common startupexs asm SEGMENT NAMING C startup source file small model with external interface set up The compiler places code and data into separate segments in the object file The different segments used by the compiler are listed in Table 5 Table 5 Segments Segment Description NEAR DATA _Near initialized global and static data NEAR_BSS _Near un initialized global and static data NEAR_TEXT _Near constant strings FAR_DATA _Far initialized global and static data FAR_BSS _Far un initialized global and static data FAR TEXT Far constant strings 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 144 zZiLOG Table 5 Segments Segment Description ROM_DATA Rom global and static data ROM TEXT Rom constant strings EROM DATA Erom global and static
217. ble with multiple memory space specifier 202 Unrecognized invalid type specifier An attempt was made to declare a variable with unknown type specifier 204 Ignoring space specifiers e g near far rom on local parameter or struct member An attempt was made to declare a local parameter or struct member with a memory space specifier The space specifier for a local or parameter is decided based on the memory model chosen The space specifier for a struct member is decided based on the space specifier of the entire struct Any space specifier on local parameter or struct member is ignored 205 Ignoring const or volatile qualifier An attempt was made to assign a pointer to a type with const qualifier to a pointer to a type with no const qualifier or An attempt was made to assign a pointer to a type with volatile qualifier to a pointer to a type with no volatile qualifier 206 Cannot initialize typedef An attempt was made to initialize a typedef 207 Aggregate or union objects may be initialized with constant expressions only An attempt was made to initiaze an array or struct with non constant expression 208 Operands are not cast compatible An attempt was made to cast a variable to an uncompatible type for example casting a _ Far pointer to a Near pointer 209 Ignoring space specifier e g near far on function An attempt was made to designate a function as a_Near or a Far function 210 Invalid use of placement or alignment op
218. bler 2 Rl c Sil Code Generation 3 Listing Files Sil Preprocessor SBR Advanced fi Linker SS Commands h Objects and Libraries 3 Address Spaces SS Warnings 3 Output Eh Debugger Use page erase before flashing Target Target Name O 216F28001002C0G ZDS Default Z16F28114L ZDS Default Add Copy Delete Debug Tool Current EthemetSmartCable y Setup OK Cancel Help Figure 60 Debugger Page of the Project Settings Dialog Box The source level debugger is a program that allows you to find problems in your code at the C or assembly level The Windows interface is quick and easy to use You can also write batch files to automate debugger tasks Your understanding of the debugger design can improve your productivity because it affects your view of how things work The debugger requires target and debug tool set tings that correspond to the physical hardware being used during the debug session A tar get is a logical representation of a target board A debug tool represents debug communication hardware such as the USB Smart Cable or an emulator A simulator is a software debug tool that does not require the existence of physical hardware Currently the debugger supports debug tools for the ZNEO simulator and the USB Smart Cable 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 82 zZiLOG Use Page Erase Before Flashing Select the Use Page Era
219. bler recognizes only part of a source line The assembler might generate multiple errors for the directive 417 Unterminated quoted string You must terminate a string with a double quote 418 Illegal symbol name There are illegal characters in a symbol name 419 Unrecognized token The assembler has encountered illegal unknown character s 420 Constant expression overflow A constant expression exceeded the range of 22147483648 to 2147483648 421 Division by zero The divisor equals zero in an expression 422 Address space not defined The address space is not one of the defined spaces 423 File not found The file cannot be found in the specified path or if no path is specified the file cannot be located in the current directory 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 210 zZiLOG 424 XREF or XDEF label in const exp You cannot use an XREF or XDEF label in an EQU directive 425 EOF found in macro definition End of file encountered before ENDMAC RO reached 426 MACRO ENDMACRO name mismatch The declared MACRO name does not match the ENDMAC RO name 427 Invalid MACRO arguments The argument is not valid in this particular instance 428 Nesting same segment You cannot nest a segment within a segment of the same name 429 Macro call depth too deep You cannot exceed a macro call depth of 25 430 Illegal ENDMACRO found No macro definition for the ENDMAC RO encounte
220. both formats Fill Unused Hex File Bytes with 0xFF This check box is available only when the Intel Hex32 Records executable format is selected When the Fill Unused Hex File Bytes with OxFF check box is selected all unused bytes of the hex file are filled with the value 0xFF This option is sometimes required so that when interoperating with other tools that set otherwise uninitialized bytes to OxFF the hex file checksum calculated in ZDS II will match that in the other tools Use caution when selecting this option The resulting hex file begins at the first hex address 0x0000 and ends at the last page address that the program requires This significantly increases the programming time when using the resulting output hex file The hex file might try to fill nonexistent external memory locations with OxFF Maximum Bytes per Hex File Line This drop down list box sets the maximum length of a hex file record This option is pro vided for compatibility with third party or other tools that might have restrictions on the length of hex file records This option is available only when the Intel Hex32 Records exe cutable format is selected UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Project Settings Debugger Page In the Project Settings dialog box select the Debugger page Figure 60 L Project Settings Configuration Debug T Sak General Sie Assem
221. bp The bp command sets a breakpoint at a given label or line in a file The syntax can take one of the following forms bp line line number gt sets removes a breakpoint on the given line of the active file bp symbol sets a breakpoint at the given symbol This version of the bp command can only be used during a debug session For example bp main bp line 20 Starting in version 4 11 0 you can also use the bp when command to set access break points You can have up to three access breakpoints set at one time Access breakpoints can be set and cleared while the target is running The following is the syntax of the bp when command bp when READ WRITE address MASK lt mask gt If not specified MASK defaults to OxFFFFFE 1 bit masked The valid MASK range is 0xFF8000 15 bits masked to 0xFFFFFF 0 bits masked For example BP WHEN READ OxFFBFFO MASK OxFFFFFO break when read address in range OxFFBFFO OxFFBFFE BP WHEN WRITE 0x1234 break when write to address 0x1234 BP WHEN OxFFE030 break when read or write address OxFFE030 SFR IRQO BP WHEN READ amp my var break when read variable my var You can use the cancel bp or cancel all commands to clear access breakpoints See cancel all on page 314 and cancel bp on page 314 Appendix B Using the Command Processor UMO17103 0207 314 ZiLOG Developer Studio Il ZNEO User Manual
222. breakpoint description Remove To delete a particular breakpoint highlight the breakpoint in the Breakpoints dialog box and click Remove 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 50 zZiLOG Remove All To delete all of the listed breakpoints click Remove All NOTE For more information on breakpoints see Using Breakpoints on page 293 Toggle Bookmark Select Toggle Bookmark from the Edit menu to insert a bookmark in the active file for the line where your cursor is located or to remove the bookmark for the line where your cursor is located Next Bookmark Select Next Bookmark from the Edit menu to position the cursor at the line where the next bookmark in the active file is located NOTE The search for the next bookmark does not stop at the end of the file the next bookmark might be the first bookmark in the file Previous Bookmark Select Previous Bookmark from the Edit menu to position the cursor at the line where the previous bookmark in the active file is located NOTE The search for the previous bookmark does not stop at the beginning of the file the previous bookmark might be the last bookmark in the file Remove All Bookmarks Select Remove All Bookmarks from the Edit menu to delete all of the bookmarks in the currently loaded project View Menu The View menu allows you to select the windows you want to display in the ZNEO devel oper s environme
223. bug Tool Selection Step 5 Figure 5 New Project Wizard Dialog Box Target Memory Configuration Step 6 Figure 6 Add Files to Project Dialog Box 0 eee ees 7 Figure 7 Sample Project 0 2 eee cee n 8 Figure 8 General Page of the Project Settings Dialog Box 0 0000 9 Figure 9 Assembler Page of the Project Settings Dialog Box 10 Figure 10 Code Generation Page of the Project Settings Dialog Box 11 Figure 11 Advanced Page of the Project Settings Dialog Box o oo 12 Figure 12 Output Page of the Project Settings Dialog Box 00oooococoooooo 13 Figure 13 Build Output Window 0 cee cece eee ene 14 Figure 14 ZNEO Integrated Development Environment IDE Window 16 Figure I5 File Toolbar Ju oos Gd teat an paw ch x ex RT HR REY HEURE es 17 Figure 16 Build Toolbar 02 0 eee III 19 Fig re 17 Find Tolba s besseae Tean A CORRE NGS DASE aree dre b 20 Figure 18 Command Processor Toolbar 1 0 2 0 00 cece eee eens 21 Figure 19 Debug Toolbar 02 0 0 cece III 22 Figure 20 Debug Windows Toolbar 0 00 cece cece eee eens 25 Figure 21 Project Workspace Window for Standard Projects 0005 26 Figure 22 Project Workspace Window for Assembly Only Projects 27 Pigure 23 Edit Window seo pet Va tate A BO 28 Figure 24 Bookmark Example ssssseeeeeeee tne eens 30 Figur
224. byte word mark group mark or letter that signals the occurrence of some condition or event such as the end of a word block or message frequency For a periodic function the number of cycles or events per unit time Glossary UMO17103 0207 402 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG G graphical user interface GUI 1 A graphics based user interface that enables users to select files programs or commands by pointing to pictorial representations icons on the screen rather than by typing long complex commands from a command prompt 2 The windows and incorporated text displayed on a computer screen groups Collections of logical address spaces typically used for convenience of locating a set of address spaces GUI See graphical user interface H h See hexadecimal hardware The boards wires and devices that comprise the physical components of a system Hertz Abbreviated Hz A measurement of frequency in cycles per second A hertz is one cycle per second A kilohertz KHz is one thousand cycles per second A megahertz MHz is one million cycles per second A gigahertz GHz is a billion cycles per second hexadecimal A base 16 number system Hex values are often substituted for harder to read binary numbers I ICE In Circuit Emulator A ZiLOG product that supports the application design process icon A small screen image representing a specific element like a document embedded and
225. c VECTORS 5C _ VECTOR 60 T 0000 vect60 VECTORS 60 _ VECTOR 64 T 0000 vect64 __ VECTORS 64 VECTOR 68 T 0000 vect68 VECTORS 68 _ VECTOR 6C T 0000 vect6c _ VECTORS 6C _ VECTOR adc T 0000 vect2c VECTORS 2C _ VECTOR cO T 0000 vect6c VECTORS 6C VECTOR cl T 0000 vect68 VECTORS 68 UMO17103 0207 5 Using the Linker Locator lt ECTOR c2 ECTOR c3 ECTOR i2c ECTOR pOad ECTOR plad ECTOR p2ad ECTOR p3ad ECTOR p4ad ECTOR p5ad ECTOR poad ECTOR p7ad ECTOR pwm fault ECTOR pwm timer ECTOR reset ECTOR spi lt lt lt lt lt lt lt lt lt lt B lt lt lt _ VECTOR sysexc _ VECTOR timer0 _ VECTOR timerl _ VECTOR timer2 VECTOR uart0 rx VECTOR uart0 tx VECTOR uartl rx VECTOR uartl tx _c_ startup _ch El _errno exit far heapbot far heaptop far stack _getch _getchar _getState _gpio init init uart _kbhit len farbss len fardata len nearbss len neardata low far romdata low farbss low fardata low near romdata low nearbss low neardata main 5 Using the Linker Locator 00 00 00 00 00 00 00 00 ee T 0000 vect5c T 0000 vect50 0000 vect64 0000 vect60 0000 vect24 00 vect4c 00 vect48 00 vect44 00 vect40 00 vect3c 00 vect38 00 vect34 00 vect30 T 0000 startupexs T 0000 vect28 T 00 T 0000 Z16F2800100ZC0G VI 00 00 9499737 00 vect08 00 vect1
226. c hardware addresses and align objects at a given alignment String Placement on page 122 Because the ZNEO CPU has multiple address spaces the C Compiler provides language extensions to specify the storage for string constants Inline Assembly on page 123 The C Compiler provides directives for embedding assembly instructions and directives into the C program 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 115 zZiLOG e Char and Short Enumerations on page 124 The enumeration data type is defined as int as per ANSI C The C Compiler provides language extension to specify the enumeration data type to be other than int Setting Flash Option Bytes in C on page 125 The ZNEO CPU has four Flash option bytes The C Compiler provides language extension to define these Flash option bytes Supported New Features from the 1999 Standard on page 125 The ZNEO C Compiler is based on the 1989 ANSI C standard Some new features from the 1999 standard are supported in this compiler for ease of use Additional Keywords for Storage Specification The Near Far Rom and Erom keywords are storage class specifiers and are used to control the allocation of data objects by the compiler They can be used on individual data objects similar to const and volatile keywords in the ANSI C standard The storage specifiers can only be used to control the allocation of global and static data The all
227. cal frame a Setthe frame pointer to the current value of the stack pointer b Decrement the stack pointer by the size of locals and temporaries if required 2 Save the contents of any of the registers R8 R13 and possibly R14 see comment below that are going to be used inside this function 3 Execute the code for the function 4 Restore any of the registers R8 R14 that were saved in step 2 5 Ifthe function returns a scalar value place it in the rO register For functions returning an aggregate see Special Cases on page 130 6 Deallocate the local frame set the stack pointer to the current value of frame pointer and restore the frame pointer from stack 7 Return Registers R8 R13 are considered as callee save that is they are saved and restored if necessary by the called function If the called function does not set up a frame pointer it can also use R14 as a general purpose register but must still save it on entry and restore it on exit The flag register is not saved and restored by the called function The function call mechanism described in this section is a dynamic call mechanism In a dynamic call mechanism each function allocates memory on stack for its locals and tem poraries during the run time of the program When the function has returned the memory that it was using is freed from the stack Figure 84 shows a diagram of the ZNEO C Com piler dynamic call frame layout 3 Using the ANSI C
228. ch other select 2 in the Units list box Select the pages to erase before flashing in the Flash Configuration area Pages that are grayed out are not available 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 97 zZiLOG 11 Type the appropriate offset values in the File Offset field to offset the base address of the hex file NOTE The hex file address is shifted by the offset defined in the Start Address area You need to allow for the shift in any defined jump table index This offset value also shifts the erase range for the Flash 12 Select the Erase Before Flashing check box to erase all Flash memory before writing the hex file to Flash memory M Caution You can also delete the Flash memory by clicking ERASE Clicking ERASE deletes only the pages that are selected 13 Select the Close Dialog When Complete check box to close the dialog box after writing the hex file to Flash memory 14 Use the following procedure if you want to use the serialization feature a Select the Include Serial in Programming check box This option programs the serial number after the selected hex file has been written to Flash Select the Enable check box Type in the start value for the serial number in the Serial Value field and select the Dec button for a decimal serial number or the Hex button for a hexadecimal serial number Type the location you want the serial number located
229. cified by the C calling con vention as described in Calling Conventions on page 128 For example if you are using the following C prototype long myfunc short arga long argb short argc The assembly function returns the long value in register RO Preserving Registers The ZNEO C Compiler implements a scheme in which the registers R8 R 13 are treated as callee save The assembly function needs to preserve any of these registers that it uses The assembly function is not expected to save and restore the flag register CALLING C FUNCTIONS FROM ASSEMBLY The C functions that are provided with the compiler library can also be used to add func tionality to an assembly program You can also create your own C functions and call them from an assembly program Because the compiler makes the caller function responsible for saving registers RO R7 see Calling Conventions on page 128 if the assembly code is using any of these func tions and needs their contents to be preserved across the C function call it must save them before the call and restore them afterwards NOTE The C Compiler precedes the function names with an underscore in the generated assembly See Function Naming Convention on page 131 The following example shows an assembly source file referencing the function sinf The sinf function is defined in the C library Assembly File globals on xref sinf segment near data val dl 3F060A96 0 523599 re
230. clabO0 LD B R3 RO LD B R1 R3 clabl DJNZ R2 clab0 XREF low code copy EROM XREF len code ERAM XREF low code ERAM Finally add your modified startup module to your project To do this you must select the Included in Project button in the Objects and Libraries page of the Project Settings dialog box see C Startup Module on page 72 and also add the modified source code file to your project using the Add Files command from the Project menu Special Case Partial Copy to ERAM A special case of this configuration is when you want to copy program code from just one C source file into ERAM while retaining the rest of the code in EROM This allows you to gain the potential speed advantages of external RAM over external Flash for a specific module Do this by performing the following steps 1 UMO17103 0207 Select the Distinct Code Segment for Each Module check box in the Advanced page in the Project Settings dialog box see page 65 This directs the C Compiler to generate different code segment names for each file Add the linker commands to place the particular segment in ERAM at run time and EROM at load time 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 271 zZiLOG For example to copy the code for main c to ERAM add the following linker commands in the Additional Linker Directives dialog box see Additional Directives on page 68 change
231. creating 1 2 36 customized configuration 91 exporting as make file 88 saving 14 setting up 8 Project Directory button 86 Project file creating 3 Index Project menu 51 Add Files 52 Export Makefile 88 Remove Selected File s 52 Settings 52 shortcuts 111 Project Settings dialog box 52 Address Spaces page 74 75 Advanced page 12 62 63 Assembler page 10 56 Code Generation page 11 57 58 Commands page 66 67 Debugger page 81 General page 9 54 Librarian page 66 Listing Files page 59 60 Objects and Libraries page 70 71 Output page 78 79 Preprocessor page 61 Warnings page 77 Project Type field 3 37 Project Workspace window 26 27 Pseudorandom sequence generation 349 377 384 ptrdiff t 339 Public symbols creating 218 putch function 138 putchar function 348 375 puts function 348 376 pwd script file command 327 Q qsort function 349 376 quit script file command 328 Quotient computing 358 367 R RAM address space 76 168 255 RAM extended 76 255 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 426 zZiLOG rand function 349 377 RAND_MAX macro 348 RANGE command 222 Range error generating 76 Read Serial button 98 Reading input 378 readme txt location of xxv realloc function 349 377 Rebuild All button 19 rebuild script file command 328 Red octagon 279 294 Refresh button 87 Registers changing values 280 preserving 132 Registers window 279 280 Registers Window button
232. ct c projects testl zdsproj UMO017103 0207 Appendix B Using the Command Processor option ZiLOG Developer Studio ll ZNEO User Manual 323 zZiLOG The option command manipulates project settings for the active build configuration of the currently open project Each call to option applies to a single tool but can set multiple options for the given tool The following is the syntax for the option command option tool name exprl expr2 exprN where expr is lt option name gt option value For example option assembler debug TRUE option compiler debug TRUE keeplst TRUE option debugger readmem TRUE option linker igcase FALSE option linker code 0000 FFFF option general cpu z8f64 NOTE Many of these script file options are also available from the command line For more details see the Running ZDS II from the Command Line appendix on page 297 Table 13 lists some command line examples and the corresponding script file commands Table 13 Command Line Examples Script File Command Examples Corresponding Command Line Examples option compiler keepasm TRUE eZ8cc keepasm option compiler keepasm FALSE eZ8cc nokeepasm option compiler const RAM eZ8cc const RAM option assembler debug TRUE eZ8asm debug option linker igcase FALSE eZ8link NOigcase option librarian warn FALSE eZ8lib nowarn The following script file
233. curs before the first digit or recognized letter If the correct value would cause overflow LONG_MAX or LONG MIN is returned according to the sign of the value and the macro errno acquires the value ERANGE Example char ptr char s 12345 long res res strtol s ptr 10 UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 393 zZiLOG tan tanf The tangent of x measured in radians A large magnitude argument can yield a result with little or no significance Synopsis tinclude lt math h gt double tan double x float tanf float x Returns The tangent value Example double x 2 22 double y y tan x tanh tanhf Computes the hyperbolic tangent of x Synopsis finclude lt math h gt double tanh double x float tanhf float x Returns The hyperbolic tangent of x Example double x 2 22 double y y tanh x tolower Converts an uppercase letter to the corresponding lowercase letter Synopsis include lt ctype h gt int tolower int c Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 394 Returns If the argument is an uppercase letter the tolower function returns the corresponding lowercase letter if any otherwise the argument 1s returned unchanged Example char c A int x i tolower c toupper Converts a lowercase letter to the corresponding uppercase letter
234. d there are no tokens in s1 and the strtok function returns a null pointer If such a character is found it is the start of the first token The strtok function then searches from there for a character that is contained in the cur rent separator string If no such character is found the current token extends to the end of the string pointed to by s1 and subsequent searches for a token fail If such a character is found it is overwritten by a null character which terminates the current token The strtok function saves a pointer to the following character from which the next search for a token starts Each subsequent call with a null pointer as the value of the first argument starts searching from the saved pointer and behaves as described in the preceding paragraphs Synopsis finclude lt string h gt char strtok char sl const char s2 Returns A pointer to the first character of a token or a null pointer if there is no token Example finclude lt string h gt static char str a b y pte char t t strtok str t points to the token a t strtok NULL t points to the token b Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 392 7 zZiLOG t strtok NULL t points to the token c Strtok NULL t is a null pointer ll strtol Converts the string pointed to by nptr to long int representa
235. d Button The Stop Build button stops a build in progress Connect to Target Button The Connect to Target button starts a debug session and initializes the communication to the target hardware Clicking this button does not download the software or reset to main Use this button to access target registers memory and so on without loading new code or to avoid overwriting the target s code with the same code This button is not enabled when the target is the simulator Download Code Button The Download Code button downloads the executable file for the currently open project to the target for debugging The button also initializes the communication to the target hard ware if it has not been done yet Use this button anytime during a debug session NOTE The current code on the target is overwritten 2 Using the Integrated Development Environment UMO17103 0207 20 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Reset Button The Reset button resets the program counter to the beginning the program If not in Debug mode a debug session is started By default and if possible clicking the Reset button resets the program counter to symbol main If you deselect the Reset to Symbol main Where Applicable check box on the Debugger tab of the Options dialog box see page 107 the program counter resets to the first line of the program Go Button The Go button executes project code from the current program counter If not i
236. d include files This defines the location of include files using the tinclude file h syntax Multiple paths are separated by semicolons For example stdine c rtl c myinc In this example the compiler looks for the include file in 1 the current directory 2 the c rt1 directory 3 the c myinc directory If the file is not found after searching the entire path the compiler flags an error Omitting this switch tells the compiler to search only the current and default directory Appendix A Running ZDS II from the Command Line ZiLOG Developer Studio ll ZNEO User Manual 303 zZiLOG Table 9 Compiler Command Line Options Continued Option Name Description usrinc path Sets the search path for user include files This defines the location of include files using the tinclude file h syntax Multiple paths are separated by semicolons For example usrine c rtl c myinc In this example the compiler looks for the include file in 1 the current directory 2 the c Nr t1 directory 3 the c myinc directory If the file is not found after searching the entire path the compiler flags an error Omitting this switch tells the compiler to search only the current directory version Prints the version number of the compiler Appendix A Running ZDS II from the Command Line UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 304 zZiLOG LIBRARIAN COMMAND LINE OPTIONS Table 10 describes t
237. data EROM TEXT _Erom constant strings CODE _Erom code VECTORS Rom interrupt vectors STARTUP Rom C startup LINKER COMMAND FILES FOR C PROGRAMS This section describes how the ZNEO linker is used to link a C program For more detailed description of the linker and the various commands it supports see the Using the Linker Locator chapter on page 213 A C program consists of compiled and assembled object module files compiler libraries user created libraries and special object module files used for C run time initializations These files are linked based on the commands given in the linker command file The default linker command file is automatically generated by the ZDS II IDE whenever a build command is issued It has information about the ranges of various address spaces for the selected device the assignment of segments to spaces order of linking and so on The default linker command file can be overridden by the user The linker processes the object modules in the order in which they are specified in the linker command file resolves the external references between the modules and then locates the segments into the appropriate address spaces as per the linker command file The linker depicts the memory of the ZNEO CPU using a hierarchical memory model con taining spaces and segments Each memory region of the CPU is associated with a space Multiple segments can belong to a given space Each space has a range associated
238. ddress space or seg ment excluding any segment copies when lt name gt is a segment The value of BASE OF is treated as an expression value Syntax BASE OF lt name gt lt name gt can be a group address space or segment BASE OF Versus LOWADDR OF By default allocation for a given memory group address space or segment starts at the lowest defined address for that memory group address space or segment If you explicitly define an assignment within that memory space allocation for that space begins at that defined point and then occupies subsequent memory locations the explicit allocation becomes the default BASE OF value BASE OF lt name gt gives the lowest allocated address in the space LOWADDR OF lt name gt gives the lowest physical address in the space For example RANGE ROM 0 S7FFF RANGE RAM 8000 SBFFF 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 228 zZiLOG RAM allocation OCATE s uninit data at 8000 OCATE s nvrblock at 9000 DEFINE low data BASE OF s uninit data Using OCATE s uninit data at 8000 or OCATE s uninit data at LOWADDR OF RAM gives the same address the lowest possible address when RANGE RAM 8000 SBFFF If OCATE s uninit data at 8000 is changed to OCATE s uninit data at BASE OF RAM the lowest used address is 9000 because LOCATE s nvrblock at 9000
239. defined If a case value consists of an expression containing a sizeof its value is not known until code generation time Thus it is possible to have two cases with the same value not caught by the front end Review the switch statement closely 309 Interrupt function lt name gt cannot have arguments A function declared as an interrupt function cannot have function arguments 313 Bitfield Length exceeds x bits The compiler only accepts bit field lengths of 8 bits or less for char bit fields 16 bit or less for short bit fields and 32 bit or less for int and long bit fields UM017103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 167 zZiLOG 4 Using the Macro Assembler NOTE NOTE You use the Macro Assembler to translate ZNEO assembly language files with the asm extension into relocatable object modules with the ob3 extension After your relocatable object modules are complete you convert them into an executable program using the linker locator The Macro Assembler can be configured using the Assembler page of the Project Settings dialog box see page 56 The Command Processor allows you to use commands or script files to automate the execution of a significant portion of the IDE s functionality For more information about the Command Processor see the Using the Command Processor appendix on page 307 The following topics are covered in this section Address Spaces and Seg
240. dentifier lt name gt is not a member of name structure An attempt was made to reference a member of a structure that does not belong to the structure 141 Object cannot be subscripted An attempt was made to use an expression as the address of an array or a pointer that was not an array or pointer 142 Array subscript must be of integral type An attempt was made to subscript an array with a non integral expression 143 Cannot dereference a pointer to void An attempt was made to dereference a pointer to void 144 Cannot compare a pointer to a non pointer An attempt was made to compare a pointer to a non pointer UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 159 zZiLOG 145 Pointers to different types may not be compared An attempt was made to compare pointers to different types 146 Pointers may not be added It is not legal to add two pointers 147 A pointer and a non integral may not be subtracted It is not legal to subtract a non integral expression from a pointer 148 Pointers to different types may not be subtracted It is not legal to subtract two pointers of different types 149 Unexpected end of file encountered In the process of parsing the input file end of file was reached during the evaluation of an expression statement or declaration 150 Unrecoverable parse error detected The compiler became confused beyond the point of recovery 151 Operand mu
241. devices have internal nonvolatile memory starting at address 00 OOOOH For example a device equipped with 128K of Flash has internal nonvolatile memory starting at address 00 0000H and ending at address 01 FFFFH ZNEO CPU based devices have internal RAM ending at address FF BFFFH while the beginning address and hence the total extent of this area is device dependent For exam ple a device equipped with 4K of RAM has internal RAM starting at address FF B000H and ending at address FF BFFFH ZNEO CPU based devices reserve 8K of addresses for internal memory mapped I O located at addresses FF E000H FF FFFFH This memory contains CPU control registers and other SFRs on chip peripherals and memory mapped I O ports Finally ZNEO CPU based devices provide an external interface that allows seamless con nection to external memory and or peripherals External memory can be nonvolatile mem ory such as Flash volatile random access memory or both The external interface supports multiple chip select signals CSx which the target system designer can use as needed to enable different devices on the external interface One chip select is asserted whenever an external memory or I O address is accessed Each chip select is available for use in a particular address range with a particular priority but note that the actual external address ranges available on a target system depend on its design For details about chip select priorities and add
242. directive 190 Variable arguments 346 VECTOR directive 191 Verify button 98 Verify Download button 22 Verify File Downloads Read After Write check box 108 Verify File Downloads Upon Completion check box 108 View menu 50 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 430 ZiLOG Debug Windows 50 Output 51 Status Bar 51 Workspace 51 vprintf function 347 397 vsprintf function 347 397 W wait bp script file command 332 Wait States drop down list box 83 wait script file command 332 WARN command 225 Warn on Segment Overlap check box 78 WARNING IS FATAL command 225 Warning messages ANSI C Compiler 152 assembler 208 generating 225 linker locator 248 suppressing 222 WARNOVERLAP command 225 Watch window 287 adding new variables 288 changing values 288 removing expressions 288 viewing ASCII values 289 viewing ASCIZ values 289 viewing decimal values 289 viewing hexadecimal values 288 viewing NULL terminated ASCII 289 Watch Window button 25 wchar_t 339 348 White octagon 279 Windows menu 109 Arrange Icons 109 Cascade 109 Close 109 Close All 109 New Window 109 Tile 109 Index WITH directive 196 With Include Files check box 60 Workspace Window button 18 Wrap Around Search check box 48 Writing characters 375 Writing output 373 383 Writing strings 376 wsp file extension 41 X XDEF directive 192 XREF directive 192 204 Y Yellow arrow 279 Yellow arrow on red octagon 279 Z
243. ditional hyperbolic functions are provided float coshf float x Calculates hyperbolic cosine of x float sinhf float x Calculates hyperbolic sine of x float tanhf float x Calculates hyperbolic tangent of x Exponential double exp double x Calculates exponential function of x double frexp double value int exp Shows x as product of mantissa the value returned by frexp and 2 to the n double Idexp double x int exp Calculates x times 2 to the exp The following additional exponential functions are provided float expf float x Calculates exponential function of x float frexpf float value int exp Shows x as product of mantissa the value returned by frexp and 2 to the n float Idexpf float x int exp Calculates x times 2 to the exp Logarithmic double log double x Calculates natural logarithm of x double log10 double x Calculates base 10 logarithm of x double modf double value double iptr Breaks down x into integer the value returned by modf and fractional n parts The following additional logarithmic functions are provided float logf float x Calculates natural logarithm of x float log10f float x Calculates base 10 logarithm of x float modff float value float iptr Breaks down x into integer the value returned by modf and fractional n parts Appendix C C Standard Library UMO17103 0207 346 ZiLOG Developer Studio Il ZNEO User Manual ZitoG Power double pow double x double y Ca
244. dow 34 minus sign used as an operator 231 _ MODEL 127 modf function 345 372 modff function 345 372 Modules defining 216 definition 213 Moving characters 371 N Name button 80 Name for New Target field 86 NDEBUG macro 340 near 134 NEAR BSS segment 143 169 NEAR DATA segment 143 169 NEAR TEXT segment 143 169 Nearest integer functions 346 New button 17 New project adding files 6 52 building 13 configuring 8 creating 2 36 saving 14 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 424 zZiLOG setting up 8 New Project dialog box 2 3 36 New Project Wizard dialog box 4 5 6 38 39 40 new project script file command 322 New toolbar 101 New Toolbar dialog box 101 NODEBUG command 221 NOLIST directive 188 NOMAP command 220 221 NOWARN command 222 ntext 292 NULL macro 339 348 350 NULL using 216 218 NULL terminated ASCH viewing 289 Numbers binary 177 decimal 177 hexadecimal 177 octal 177 O obj file extension 170 171 Object code file 171 Object formats 80 for Linker 80 IEEE 695 80 OMF695 170 171 Object libraries 213 Octal numbers in assembly 177 offsetof macro 339 OMF695 format 170 171 Open button 17 Open dialog box 35 36 Open Project dialog box 41 open project script file command 322 Operator precedence in assembly 178 Operators subtract 231 amp and 227 Index multiply 230 add 227 divide 228 lt lt shift left 231 gt gt shif
245. dress Oxbef2 after ch2 The At directive can only be used after a pre vious At or Align directive Alignment of a Variable The following syntax can be used to declare a global or static variable aligned at a speci fied alignment char ch2 Align 2 ch2 is aligned at even boundary char ch4 Align 4 ch4 is aligned at a four byte boundary Only aligned variables with the rom or erom storage class specifiers can be initialized The aligned variables with the near and far storage class specifiers cannot be initialized The uninitialized aligned variables are not initialized to zero by the compiler startup routine String Placement When string constants literals like mystring are used in a C program they are stored by the C Compiler in RAM address space for the small memory model and in ERAM address space for the large memory model However sometimes this default placement of string constants does not allow you adequate control over your memory usage Therefore language extensions are provided to give you more control over string placement e N mystring This defines a near string constant The string is stored in RAM The address of the string isa Near pointer e F mystring This defines a far string constant The string is stored in ERAM The address of the string is a Far pointer e R mystring This defines a ROM string constant The string is stored in ROM The address of the string is a Rom pointer E mystring T
246. e No null character is added p Matches a hexadecimal number The corresponding argument is a pointer to a pointer to void n No input is consumed The corresponding argument is a pointer to integer into which is to be written the number of characters read from the input stream so far by this call to the scanf function Execution of a n directive does not increment the assignment count returned at the completion of execution of the scanf function Matches a single no conversion or assignment occurs If a conversion specification is invalid the behavior is undefined The conversion characters e g and x can be capitalized However the use of upper case is ignored If end of file is encountered during input conversion is terminated If end of file occurs before any characters matching the current directive have been read other than leading white space where permitted execution of the current directive terminates with an input failure otherwise unless execution of the current directive is terminated with a matching failure execution of the following directive 1f any is terminated with an input failure If conversion terminates on a conflicting input character the offending input character is left unread in the input stream Trailing white space including new line characters is left unread unless matched by a directive The success of literal matches and suppressed assignments is not directly determinable other than using t
247. e 25 Inserting a Bookmark 0 00 cece eee ee 31 Figure 26 Build Output Window 0 cee eee eee 33 Figure 27 Debug Output Window 0 cece e eens 33 Figure 28 Find in Files Output Window 2 0 c eect eens 33 Figure 29 Find in Files 2 Output Window 0 c cece eee eee eee 34 Figure 30 Messages Output Window 00 cece ccc teen eens 34 Figure 31 Command Output Window 0 e cece eect eee 34 Figure 32 Open Dialog Box 00 0 e eens 36 Figure 33 New Project Dialog Box 0 ccc ccc teeta 36 UMO17103 0207 xvii xviii ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Figure 34 Figure 35 Figure 36 Figure 37 Figure 38 Figure 39 Figure 40 Figure 41 Figure 42 Figure 43 Figure 44 Figure 45 Figure 46 Figure 47 Figure 48 Figure 49 Figure 50 Figure 51 Figure 52 Figure 53 Figure 54 Figure 55 Figure 56 Figure 57 Figure 58 Figure 59 Figure 60 Figure 61 Figure 62 Figure 63 Figure 64 Figure 65 Figure 66 Figure 67 Figure 68 Figure 69 UMO17103 0207 Select Project Name Dialog Box ooooooocoocooroorrror eese 37 New Project Wizard Dialog Box Build Options 38 New Project Wizard Dialog Box Target and Debug Tool Selection 39 New Project Wizard Dialog Box Target Memory Configuration 40 Open Project Dialog Box sssssseeeeeee eh 4
248. e ANSI C Standard They are described in detail in the C Standard Library appendix on page 337 The deviations from the ANSI Standard in these files are summarized in Library Files Not Required for Freestanding Implementation on page 151 The follow ing sections describe the use and format of the nonstandard ZiLOG specific run time libraries e ZiLOG Header Files on page 134 e ZiLOG Functions on page 136 The ZiLOG specific header files provided with the compiler are listed in Table 3 and described in ZiLOG Header Files on page 134 3 Using the ANSI C Compiler UMO17103 0207 134 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Table 3 Nonstandard Headers Header Description Page lt zneo h gt ZNEO defines and functions page 134 lt sio h gt Serial input output functions page 135 NOTE The ZiLOG specific header files are located in the following directory lt ZDS Installation Directory NincludeNzilog where ZDS Installation Directory gt is the directory in which ZiLOG Developer Studio was installed By default this would be C Program Files ZiLOG ZDSII_ ZNEO version where lt version gt might be 4 11 0 or 520607 NOTE All external identifiers declared in any of the headers are reserved whether or not the associated header is included All external identifiers and macro names that begin with an underscore are also reserved If the program redefines a reserved external identifi
249. e Memory space however PROGRAM CONFIGURATIONS With the information given so far in this chapter as background you are now ready to plan the memory configuration for your own application At this point you should have deter mined what external memory if any is present on your target system enabled and config ured its chip selects and added its address space to the linker address ranges For information about these settings see Project Settings Debugger Page on page 81 and Project Settings Address Spaces Page on page 74 Now it is necessary to implement your program s memory configuration using the devel opment environment and tools This section presents several examples of this process beginning with the default program configuration provided by the ZiLOG development tools For each configuration there is a discussion of reasons to choose the configuration and how to implement the configuration in both C and assembly language projects Two distinct features of a program configuration are how its code is downloaded and how its initial values are copied Downloading refers to what the development tools do when they copy your compiled or assembled code and data from your host computer to the ZNEO CPU s internal or external memory in preparation for a debugging or test session The memory space ZDS II address range or spaces into which your program is down loaded depend on the memory model that best fits your application Y
250. e Project Workspace window see Project Workspace Window on page 26 but you must also edit your linker command file to add the corresponding object modules to the list of linked modules at the end of the linker command file Project Settings Objects and Libraries Page Figure 56 shows the Objects and Libraries page UM017103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Wi Project Settings Configuration Debug x NOTE Eh General Objects Eh Assembler E Ic Additional Object Library Modules h Code Generation T 3 Listing Files C Startup Module Sil Preprocessor Standard 3 Advanced C Included In Project fi Linker E SS Commands Objects and Libraries Use Default Libraries 3 Address Spaces iw C Runtime Library A Warnings Floating Point Library Ra y 3 Output 3d Debugger Cancel Help Figure 56 Objects and Libraries Page of the Project Settings Dialog Box Additional Object Library Modules Use the Additional Object Library Modules field to list additional object files and modules that you want linked with your application You do not need to list modules that are other wise specified in your project such as the object modules of your source code files that appear in the Project Workspace window the C startup module and the ZiLOG default libraries listed in the Objects and Libraries page Separate multiple module names wit
251. e circumvented as follows e The GUI rejects an ERAM range lower boundary setting below 80 00008 If the target locates external volatile memory below this address an unrestricted ERAM range can be configured by adding an edited linker RANGE command to the Additional Linker Commands field of the ZDS II project settings For example if the target provides 8MB of extended RAM at address 70 0000H you would use this command RANGE ERAM 700000 SFEFFFF e The GUI rejects a RAM range upper boundary setting above FF_BFFFH If the target uses the space above this address for external volatile memory instead of external I O a higher RAM upper boundary up to FF DFFFH can be configured by adding an edited linker RANGE command to the Additional Linker Commands field of the ZDS Il project settings The debugger memory window always displays addresses above FF BFFFH as part of the I O Data space however For example if the target provides 24K B of combined internal and external RAM beginning at FF 8000H you would use this command RANGE RAM SFF8000 SFFDFFF 6 Configuring Memory for Your Program UMO17103 0207 258 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG The ZDS II GUI assumes external I O is located in the range FF_C000H to FF DFFFH Any external I O that is located elsewhere can be accessed using absolute addresses The debugger memory window displays all addresses below FF C000H as part of th
252. e encountered An obsolete feature was encountered 470 Missing token error A token needs to be added 475 User error General purpose error 476 User warning General purpose warning 480 Relist map file error A map file will not be generated 481 Relist file not found error The map file cannot be found in the specified path or if no path is specified the map file cannot be located in the current directory 482 Relist symbol not found Any symbol used in a conditional directive must be previously defined by an EQU or VAR directive 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 212 zZiLOG 483 Relist aborted A map file will not be generated 490 Stall or hazard conflict found A stall or hazard conflict was encountered 499 General purpose switch error There was an illegal or improperly formed command line option UM017103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 213 zZiLOG 5 Using the Linker Locator The ZNEO developer s environment linker locator creates a single executable file from a set of object modules and object libraries It acts as a linker by linking together object modules and resolving external references to public symbols It also acts as a locator because it allows you to specify where code and data is stored in the target processor at run time The executable file generated by the linker can be
253. e end of the characters written it is not counted as part of the returned sum Synopsis include lt stdio h gt int sprintf char s const char format Returns The number of characters written in the array not counting the terminating null character Example int d 51 char buf 40 sprintf buf COMPASS d 4d sqrt sqrtf Computes the non negative square root of x A domain error occurs if the argument is negative Synopsis include lt math h gt double sqrt double x float sqrtf float x Returns The value of the square root Example double x 25 0 double y y sqrt x Appendix C C Standard Library UMO17103 0207 384 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG srand Uses the argument as a seed for a new sequence of pseudorandom numbers to be returned by subsequent calls to rand If srand is then called with the same seed value the sequence of pseudorandom numbers is repeated If rand is called before any calls to srand have been made the same sequence is generated as when srand is first called with a seed value of 1 Synopsis include lt stdlib h gt void srand unsigned int seed Example int i srand 1001 i rand sscanf Reads formatted data from a string Synopsis include lt stdio h gt int sscanf const char s const char format Returns The value of the macro EOF if an input failure occurs before any conversion Otherwise the
254. e executable program code nonstartup code under the CODE segment This segment belongs to EROM address space To set up this configuration you need to copy the CODE segment from EROM to the ERAM address space Do this by performing steps 2 and 3 from the C Program Setup for this configuration as described in C Program 6 Configuring Memory for Your Program UMO17103 0207 272 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Setup on page 269 In step 3 add the code to your assembly startup code instead of the standard C startup Special Case Partial Copy to ERAM A special case of this configuration is when you want to copy program code from just one assembly segment into ERAM while retaining the rest of the code in EROM This allows you to gain the potential speed advantages of external RAM over external Flash for a spe cific module Do this by performing the following steps 1 Use a distinct segment name for the particular segment For example Define main TEXT space EROM segment main TEXT code goes here 2 Tocopythe main TEXT segment from EROM to the ERAM address space perform steps 2 and 3 from the C Program Setup Special Case for this configuration as described in C Program Setup on page 269 In step 3 add the code to your assembly startup code instead of the standard C startup Copy to RAM Program Configuration The Copy to RAM Program Configuration Figure 93 can be used for production a
255. e following which vector is being selected For ZNEO vector name must ADC P7AD C0 PWM FAULT Cl PWM_TIMER C2 RESET C3 SPI Dc SYSEXC POAD TIMERO PIAD TIMERI P2AD TIMER2 P3AD UARTO RX P4AD UARTO_TX PSAD UARTI_RX P6AD UARTI_TX 4 Using the Macro Assembler UMO17103 0207 192 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Examples VECTOR SPI spi handler VECTOR P2AD p2ad handler Defines a list of labels in the current module as an external symbol that are to be made publicly visible to other modules at link time The operands must be labels that are defined somewhere in the assembly file Synonyms Global GLOBAL GLOBAL public def public Syntax xdef directive gt XDEF ident list Examples XDEF label XDEF labell label2 1abel3 Specifies that a list of labels in the operand field are defined in another module The reference is resolved by the linker The labels must not be defined in the current module This directive optionally specifies the address space in which the label resides Synonyms extern EXTERN EXTERNAL ref Syntax xref directive gt XREF ident space list ident space list gt ident space gt ident space list ident space ident space gt ident lt space gt Examples XREF label XREF labell label2 1abel3 XREF label ROM Structures and Unions in Assembly Code
256. e given data item for the active target The following is the syntax of the target get command target get data item Use the target setup command to view available data items and current values For example target get cpu target help The target help command displays all target commands The following is the syntax ofthe target help command target help target list The target list command lists all available targets The syntax can take one of three forms target list UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual 331 zZiLOG displays the names of all available targets restricted to the currently configured CPU family target list CPU cpu name gt displays the names of all available targets associated with the given CPU name target list FAMILY family name displays the names of all available targets associated with the given CPU family name For example target list FAMILY ZNEO target options NOTE See a target in the following directory for a list of categories and options lt ZDS Installation Directory Ntargets where ZDS Installation Directory is the directory in which ZiLOG Developer Studio was installed By default this would be C Program FilesVZiLOGNZDSII ZNEO version where lt version gt might be 4 11 0 or 90 30 To set a target value use one of the following syntaxes target options CATE
257. eatedly The STRUCT and ENDSTRUCT directives have the following form stag STRUCT offset parent name_1 DS countl name _2 DS count2 name TAG stagx count name_n DS count3 ssize ENDSTRUCT stag The label stag defines a symbol to use to reference the structure the expression offset 1f used indicates a starting offset value to use for the first element encountered otherwise the starting offset defaults to zero If parent 1s specified rather than offset the parent must be the name of a previously defined structure and the offset is the size of the parent structure In addition each name in the parent structure is inserted in the new structure Each element can have an optional label such as name 1 which is assigned the value of the element s offset into the structure and which can be used as the symbolic offset If stag is missing these element names become global symbols otherwise they are referenced 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 194 zZiLOG NOTE using the syntax stag name The directives following the optional label can be any space reserving directive such as DS or the TAG directive defined below and the structure offset is adjusted accordingly The label ssize if provided is a label in the global name space and is assigned the size of the structure If a label stag is specified with the ENDSTRU
258. eck box 104 SHRT MAX 341 SHRT MIN 341 Simulated UART Output window 292 Simulated UART Output Window button 26 sin function 344 382 Sine computing 382 sinf function 344 382 sinh function 345 382 sinhf function 345 382 lt sio h gt header 135 size t 339 348 350 Small memory model 119 Smallest integer computing 357 Smart Cables Available area 87 Software installation 1 SORT command 223 Sort Symbols By area 80 Sorting arrays 376 Sorting functions 349 Source area 83 Source line contents 172 definition 172 labels 203 SPACE clause 186 Special function registers changing values 281 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 428 zZiLOG location 280 Special Function Registers window 280 281 Special Function Registers Window button 25 SPECIAL_CASE 281 SPLITTABLE command 224 SPOV register 142 sprintf function 347 383 sqrt function 346 383 sqrtf function 346 383 Square root calculating 383 srand function 349 384 sscanf function 347 384 Stack pointer overflow 142 Standard button 72 Standard Include Path field 62 Starting a project 2 Startup files 142 STARTUP segment 144 Status bar 278 lt stdarg h gt header 346 STDC 127 lt stddef h gt header 339 lt stdio h gt header 347 lt stdlib h gt header 348 Step Into button 23 Step Out button 23 Step Over button 23 step script file command 329 stepin script file command 329 stepout script file command 329 Stop Build button 19 Stop Com
259. ed ZiLOG Developer Studio Il ZNEO User Manual zZiLOG 6 Select the Limit Optimizations for Easier Debugging check box See Figure 10 Wi Project Settings Configuration Debug h General ile Assembler 8 c la h Code Generation h Listing Files 3 Preprocessor SB Advanced fi Linker Commands 3 Objects and Libraries Y Limit Optimizations for Easier Debugging 3 Address Spaces TS SS Warnings Memory Model Small 3 Output h Debugger Cancel Help Figure 10 Code Generation Page of the Project Settings Dialog Box 7 Click on the Advanced page 1 Getting Started UM017103 0207 ZiLOG Developer Studio Il ZNEO User Manual 12 zZiLOG 8 Make certain the Generate Printfs Inline check box is selected See Figure 11 Wi Project Settings Configuration Debug 5e General Eh Assembler El c 3 Code Generation MV Generate Printfs Inline 3 Listing Files Distinct Code Segment for Each Module 3 Preprocessor 3 Default Type of Char Unsigned y El Linker 5s Commands 2 Objects and Libraries 3 Address Spaces Sls Warnings 3 Output Eh Debugger Note Some items on this page are disabled due to the use of the Limit Optimizations for Easier Debugging option on the C gt Code Generation page EUH Help j Figure 11 Advanced Page of the Project Settings Dialog Box 9 Click on the Output page UMO17103 0207 1 Getting Started ZiLOG Develope
260. ed even in a later ZDS II session the Generate Debug Information check box returns to the setting it had before the Limit Optimizations for Easier Debugging check box was selected Ignore Case of Symbols When the Ignore Case of Symbols check box is enabled the assembler and linker ignore the case of symbols when generating and linking code This check box is occasionally needed when a project contains source files with case insensitive labels This check box is only available for Assembly Only projects with no C code 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 56 zZiLOG Intermediate Files Directory This directory specifies the location where all intermediate files produced during the build will be located These files include make files object files and generated assembly source files and listings that are generated from C source code This field is provided primarily for the convenience of users who might want to delete these files after building a project while retaining the built executable and other more permanent files Those files are placed into a separate directory specified in the Output page see Project Settings Output Page on page 78 Project Settings Assembler Page In the Project Settings dialog box select the Assembler page The assembler uses the con tents of the Assembler page to determine which options are to be applied to the files
261. ed space Or sign xtend the address The following example illustrates these features in near data space is RAM in far data space is ERAM nwl RO nwl is in RAM uses 16 bit encoding fw1 R1 fwl is in ERAM uses 32 bit encoding RO nw2 nw2 will be in RAM uses 16 bit encoding R1 fw2 fw2 will be in ERAM uses 32 bit encoding RO rwl rwl declared to be in ROM uses 16 bit encoding R1 erwl erwl declared to be in EROM uses 32 bit encoding xxx RO xxx undeclared 16 bit encoding assumed yyy EROM R1 yyy undeclared 32 bit encoding forced ENT NEAR BSS EF E m E EF nw2 is in near bss SEGMENT FAR BSS fw2 is far bss Space Space is RAM is ERAM rwl ROM rwl declared to be in ROM erwl EROM erwl declared to be in EROM 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 180 zZiLOG Register Lists for PUSHM and POPM Instructions The ZNEO processor provides the PUSHM and POPM instructions to push or pop multiple registers Actually the ZNEO processor provides the PUSHMHI PUSHMLO POPMHI and POPMLO instructions which each push or pop half the register set The ZNEO assembler accepts PUSHM and POPM and generates the lower level instructions The list of registers to be pushed or popped can be expressed either as a register list or as an immediate value If an immediate value i
262. ed with a corresponding endif directive 028 else not within if and endif directives else directive was encountered before a corresponding if directive 029 Illegal constant expression The constant expression in preprocessing directive has invalid type or syntax 030 Illegal macro name lt name gt The macro name does not have a valid identifier syntax 031 Extra endif found endif directive without a corresponding i directive was found 032 Division by zero encountered Divide by zero in constant expression found UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 155 zZiLOG 033 Floating point constant over underflow In the process of evaluating a floating point expression the value became too large to be stored 034 Concatenated string too long Shorten the concatenated string 035 Identifier longer than 32 characters Identifiers must be 32 characters or shorter 036 Unsupported CPU name in pragma An unknown CPU encountered 037 Unsupported or poorly formed pragma An unknown pragma directive encountered 038 User supplied text A user created error directive has been encountered The user supplied text from the directive is printed with the error message Front End Warning and Error Messages 100 Syntax error A syntactically incorrect statement declaration or expression was encountered 101 Function lt name gt already declared An attempt was made
263. ee Using Breakpoints on page 293 Reset the debugger Stop debugging Start or continue running the program Go Run to the cursor Pause the debugging Break Step into over or out of program instructions Set the next instruction at the current line Enable and disable source annotation and source line numbers Simulated UART Output Window Click the Simulated UART Output Window button to show or hide the Simulated UART Output window Figure 110 Simulated UART Output UARTO M Hello World Figure 110 Simulated UART Output Window The Simulated UART Output window displays the simulated output ofthe selected UART Use the drop down list to view the output for a particular UART Right clicking in the Simulated UART Output window displays a context menu that pro vides access to the following features UMO17103 0207 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual L a ZiLOG Clear the buffered output for the selected UART Copy selected text to the Windows clipboard NOTE The Simulated UART Output window is available only when the Simulator is the active debug tool USING BREAKPOINTS This section to describes how to work with breakpoints while you are debugging The fol lowing topics are covered Inserting Breakpoints on page 293 Viewing Breakpoints on page 294 Moving to a Breakpoint on page 295 Enabling Breakpoints on page 295 Disabling Break
264. either 16 or 32 bits the ZNEO CPU sign extends 16 bit addresses The C Compiler does not support gaps holes within the RAM range ZDS ll uses the RAM address range for nonpermanent storage of data during program execution ZDS II can be configured to place code in the RAM address range if desired For more information see Program Configurations on page 258 Special Function Registers and IO IODATA Typically FF COO0H FF FFFFH The microcontroller reserves addresses FF E000H and above for its special function registers on chip peripherals and I O ports The ZDS II GUI expects addresses FF CO00Hto FF DFFFH to be used for external I O if any on the target system The IODATA address range is addressable using 16 or 32 bits the ZNEO CPU sign extends 16 bit addresses ZDS II does not support placing executable code in the IODATA space Figure 88 on page 256 illustrates typical contents of the five ZDS II address ranges and an example of how they might map to a target s physical memory 6 Configuring Memory for Your Program UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 256 zZiLOG Address Range Space FF FFFFH IODATA FF COOO0H FF BFFFH Address FF 8000H 08 FFFFH 08 0000H 00 FFFFH 00 4000H 00 3FFFH 00 0000H Physical Contents Example Internal I O External I O Optional Internal RAM External RAM Optional I O Access Small Model Stack RAM D
265. elete all text in the Output window Build Output Window The Build Output window Figure 26 holds all text messages generated by the compiler assembler librarian and linker including error and warning messages UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 33 zZiLOG I Simulator Configuration Debug i C PROGRA 1 ZiL0G ZDSII_ 3 0 samples QUICKS 1 Source main c C PROGRA 1 ZiL0G ZD3II_ 3 0 samples QUICKS 1 S5ource simulator c Linking uild completed Build A Debug A Find in Files A Find in Files 2 A Messages A Command 4 2 Figure 26 Build Output Window Debug Output Window The Debug Output window Figure 27 holds all text messages generated by the debugger while you are in Debug mode Connected to target Simulator Starting debug session project Simulator configuration Debug Cpu Z16F2811AL L be i gt 14 4 gt PL Build A Debug Find in Files A Find in Files 2 J Messages A Command 4 gt Figure 27 Debug Output Window Find in Files Output Windows The two Find in Files Output windows Figure 28 and Figure 29 display the results of the Find in Files command available from the Edit menu and the Find toolbar The File in Files 2 window is used when the Output to Pane 2 check box is selected in the Find in File dialog box see Find in Files on page 46 x Searching for getcha
266. embly Using the asm Statement The second method of inserting assembly language uses the asm statement asm lt assembly line The asm statement cannot be within an expression and can be used only within the body of a function The lt assembly line gt can be any string The compiler does not check the legality of the string As with the pragma asm form the compiler does not process the assembly line gt except for translating the standard C escape sequences The compiler prefixes the name of every global variable name with _ Global variables can therefore be accessed in inline assembly by prefixing their name with _ The local variables and parameters cannot be accessed in inline assembly Char and Short Enumerations The enumeration data type is defined as int as per ANSI C The C Compiler provides language extensions to specify the enumeration data type to be other than int to save space The following syntax is provided by the C Compiler to declare them as char or short enum R YELLOW B INVALID char color enum EW 0 N OF FIXED VERIFIED CLOSED short status void main void if color RED status FIXED else status OPEN UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 125 zZiLOG Setting Flash Option Bytes in C The ZNEO CPU provides up to four Flash option bytes to
267. empt was made to take the address of a variable with register class 162 Conditional expression operands are not compatible One operand of a conditional expression cannot be promoted to the type of the other operand 163 Casting a non pointer to a pointer An attempt was made to promote a non pointer to a pointer 164 Type name of cast must be scalar type An attempt was made to cast an expression to a non scalar type 165 Operand to cast must be scalar type An attempt was made to cast an expression whose type was not scalar 166 Expression is not a structure or union An expression was encountered whose type was not structure or union where only a structure or union is allowed 167 Expression is not a pointer to a structure or union An attempt was made to dereference a pointer with the arrow operator and the expression s type was not pointer to a structure or union 168 Cannot take size of void function or bit field types An attempt was made to take the size of an expression whose type is void function or bit field 169 Actual parameter has no corresponding formal parameter An attempt was made to call a function whose formal parameter list has fewer elements than the number of arguments in the call 170 Formal parameter has no corresponding actual parameter An attempt was made to call a function whose formal parameter list has more elements than the number of arguments in the call UMO17103 0207 3 Using the ANSI C
268. er even with a semantically equivalent form the behavior is indeterminate ZiLOG Header Files Architecture Specific Functions lt zneo h gt A ZNEO specific header file lt zneo h gt is provided that has prototypes for ZiLOG specific C library functions and macro definitions Macros lt zneo h gt has macro definitions giving the more conventional names for storage specifi ers erom Expands to space specifier Erom near Expands to space specifier Near far Expands to space specifier Far rom Expands to space specifier Rom lt zneo h gt has the macro definitions for all ZNEO microcontroller peripheral registers For example TOH Expands to unsigned char volatile near 0xE300 Refer to the ZNEO product specifications for the list of peripheral registers supported UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 135 zZiLOG lt zneo h gt also has the macro definition for the ZNEO Flash option bytes FLASH OPTIONO FLASH OPTIONI FLASH OPTION2 FLASH OPTION3 Expands to a Rom char at address 0x0 Expands to a Rom char at address 0x1 Expands to a Rom char at address 0x2 Expands to a Rom char at address 0x3 lt zneo h gt also has the macro definition for interrupt vector addresses RESET Expands to address of Reset vector Refer to the ZNEO product specifications for the list of interrupt vectors supported Functions intrinsic void El void intri
269. er Command File dialog box Figure 55 is displayed Select Linker Command File Look in samples e amp er E3 E QuickStart ce Tutorial E test123 Debug linkcmd File name Files of type Linker Command Files linkemd Ink X Cancel Figure 55 Select Linker Command File Dialog Box 3 Use the Look In drop down list box to navigate to the linker command file that you want to use 2 Using the Integrated Development Environment UMO17103 0207 70 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG NOTE 4 Click Select The Use Existing button is the alternative to the Always Generate from Settings button see Always Generate from Settings on page 67 When this button is selected a new linker command file is not generated when you build your project Instead the linker com mand file that you specify in this field 1s applied every time When the Use Existing button is selected many project settings are grayed out including all the settings on the Objects and Libraries page Warnings page and Output page These settings are disabled because when you have specified that an existing linker command file is to be used those settings have no effect When the Use Existing button is selected some other changes that you make in your project such as adding new files to the project also do not automatically take effect To add new files to the project you must not only add them to th
270. er Directives dialog box Download to RAM Program Configuration The Download to RAM Program Configuration Figure 91 can be used only during development and not for production code It is similar to the Default Program Configura tion the only difference is that the rest of the executable program code is downloaded in RAM and executed from RAM 6 Configuring Memory for Your Program UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 266 Address Range Space Contents IODATA I O Access 16 Bit Addressable Small Model Stack Data RAM Data Code Large Model Stack ERAM Data EROM Data Copy of ERAM Initializers Copy of RAM Initializers Startup Code Addressable Vector Table Data Option Bytes Figure 91 Programmer s Model Download to RAM Program Configuration Because RAM cannot retain values across power cycles this configuration is meant for development only By using this configuration you can avoid erasing and burning the exe cutable code in Flash multiple times as part of development cycle In this respect this con figuration obviously is very similar to the Download to ERAM Program Configuration discussed in Download to ERAM Program Configuration on page 262 The main difference is that RAM is typically internal memory while ERAM is external Therefore in order to use the Download to ERAM Program Configuration you must provide external memory and configure its interface By using the Download to RAM
271. er and contiguity of storage allocated by successive calls to the calloc malloc and realloc functions are unspecified The pointer returned if the allocation succeeds is suitably aligned so that it can be assigned to a pointer to any type of object and then used to access such an object in the space allocated until the space is explicitly freed or reallo cated void calloc size t nmemb size t size Allocates storage for array void free void ptr Frees a block allocated with calloc malloc or realloc void malloc size t size Allocates a block void realloc void ptr size t size Reallocates a block Searching and Sorting Utilities void bsearch void key void base size t nmemb Performs binary search size_t size int compar void void void qsort void base size t nmemb size t size int compar void Performs a quick sort void Appendix C C Standard Library UMO17103 0207 350 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Integer Arithmetic int abs int j Finds absolute value of integer value div_t div int numer int denom Computes integer quotient and remainder long int labs long int j Finds absolute value of long integer value ldiv t ldiv long int numer long int denom Computes long quotient and remainder String Handling lt string h gt The lt string h gt header declares several functions useful for manipulating character arrays and other objects treated as cha
272. er the INCLUDE directive The file to include is named in the string constant after the INCLUDE directive The file name can contain a path If the file does not exist an error results and the assembly is aborted A recursive INCLUDE also results in an error INCLUDE files are contained in the listing 1st file unless a NOLIST directive is active Synonyms include copy COPY 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 188 zZiLOG LIST Syntax include directive gt INCLUDE lt string_const gt Examples INCLUDE calc h include calc header file INCLUDE test calc h contains a path name INCLUDE calc h ERROR use string constant Instructs the assembler to send output to the listing file This mode stays in effect until a NOLIST directive is encountered No operand field is allowed This mode is the default mode Synonyms list LIST Syntax list directive LIST Example LIST NOLIST NOLIST ORG Turns off the generation of the listing file This mode remains in effect until a LIST directive is encountered No operand is allowed Synonym NOLIST Syntax nolist directive NOLIST Example LIST NOLIST The ORG assembler directive sets the assembler location counter to a specified value in the address space of the current segment The ORG directive must be followed by an integer constant
273. error occurs for arguments not in the range 1 1 Synopsis finclude math h double asin double x float asinf float x Returns The arc sine in the range pi 2 pi 2 Example double y 1234 double x x asin y assert Puts diagnostics into programs When it is executed if expression is false that is eval uates to zero the assert macro writes information about the particular call that failed including the text of the argument the name of the source file and the source line num ber the latter are respectively the values of the preprocessing macros FILE and LINE onthe serial port using the print function It then loops forever Synopsis dinclude lt assert h gt void assert int expression Returns If expression 1s true that 1s evaluates to nonzero the assert macro returns no value Example dinclude lt assert h gt Appendix C C Standard Library UMO17103 0207 354 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG char str COMPASS void main void assert str 0 B atan atanf Computes the principal value of the arc tangent of x Synopsis tinclude lt math h gt double atan double x float atanf float x Returns The arc tangent in the range pi 2 pi 2 Example double y 1234 double x x atan y atan2 atan2f Computes the principal value of the arc tangent of y x using the signs of both arguments to determ
274. ese ORDER commands specify the link order of these segments The FAR_BSS seg ment is placed at lower addresses with the FAR DATA segment immediately following it in the ERAM space Similarly NEAR DATA follows after NEAR BSS in RAM space COPY NEAR DATA EROM COPY FAR DATA EROM This COPY command is a linker directive to make the linker place a copy of the initialized data segments NEAR DATA and FAR DATA into the EROM address space At run time the C startup module then copies the initialized data back from the EROM address space to the RAM NEAR DATA segment and ERAM FAR DATA segment address spaces UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual ziLoc This is the standard method to ensure that variables get their required initialization from a nonvolatile stored copy in a typical embedded application where there is no offline mem ory such as disk storage from which initialized variables can be loaded define low near romdata copy base of NEAR DATA define low neardata base of NEAR DATA define len neardata length of NEAR DATA define low far romdata copy base of FAR DATA define low fardata base of FAR DATA define len fardata length of FAR DATA define low nearbss base of NEAR BSS define len nearbss length of NEAR BSS define low farbss base of FAR BSS define len farbss length of FAR BSS define far heapbot top of ERAM
275. esponding Option in Project Settings Dialog Box Acceptable Values cpu General page CPU drop down field string valid CPU name debug General page Generate Debug Information check box TRUE FALSE igcase General page Ignore Case of Symbols check box TRUE FALSE outputdir General page Intermediate Files Directory field string path warn General page Show Warnings check box TRUE FALSE Librarian Options Table 17 Librarian Options Option Name Corresponding Option in Project Settings Dialog Box Acceptable Values outfile Librarian page Output File Name field Appendix B Using the Command Processor string library file name with option path UMO17103 0207 326 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Linker Options Table 18 Linker Options Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values createnew Commands page Always Generate from Settings button TRUE FALSE directives Commands page Edit button Additional Linker Directives string dialog box Contains the text for additional directives eram Address Spaces page Extended RAM ERAM field string address range in the format lt low gt lt high gt erom Address Spaces page Program Space EROM string address range in the format lt ow gt lt high gt exeform Output page Executable Formats area string one or more of IEEE 695 or Inte
276. ested signal handler that is from a function invoked as a result of a signal raised during the handling of another signal the behavior is undefined Synopsis include lt setjmp h gt void longjmp jmp buf env int val Returns After 1ongjmp is completed program execution continues as if the corresponding call to set jmp had just returned the value specified by val The 1ongjmp function cannot cause setjmp to return the value 0 if val is 0 set jmp returns the value 1 Example int i jmp buf env i setjmp env longjmp env i malloc Allocates space for an object whose size is specified by size NOTE The existing implementation of malloc depends on the heap area being located from the bottom of the heap referred to by the symbol heapbot to the top of the stack SP Care must be taken to avoid holes in this memory range Otherwise the malloc function might not be able to allocate a valid memory object Synopsis finclude lt stdlib h gt void malloc size t size Returns A pointer to the start lowest byte address of the allocated space If the space cannot be allocated or if size is zero the malloc function returns a null pointer Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 370 Example char buf buf char malloc 40 sizeof char if buf NULL success else fail memchr Locates the first occurrence of c converted to
277. et the base address and top address of the contents in ROM You can use the BASE OF and TOP OF linker expressions to get the base address and top address of codeseg To copy multiple segments to ROM use the following procedure 1 Inthe assembly code define the segments for example strseg text and codeseg to be segments located in RAM This is the run time location of the segments 2 Use the following linker commands CHANGE strseg codeseg CHANGE text codeseg COPY codeseg ROM 5 Using the Linker Locator UMO17103 0207 218 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG The linker renames strseg and text as codeseg and performs linking as described in the previous example You need to write only one loop to perform the copy from ROM to RAM at run time instead of three one loop each for strseg text and codeseg To allocate a string segment in ROM but not generate the initialization 1 Inthe assembly code define the string segment for example strsect to bea segment located in ROM 2 Use the following linker command COPY strsect NULL The linker associates all the labels in strsect with an address in ROM and does not generate any loadable data for strsect This is useful when ROM is already programmed separately and the address information 1s needed for linking and debugging NOTE The linker recognizes the special space NULL NULL is not one ofthe spaces that an object file or library cont
278. example if you are consider ing the Partial Copy to RAM Program Configuration discussed in Special Case Partial Copy to RAM on page 275 Do this by performing the following steps 1 Select the Distinct Code Segment for Each Module check box in the Advanced page in the Project Settings dialog box see page 65 This option directs the C Compiler to generate different code segment names for each file 2 Usethe linker CHANGE directive to move the particular segment to RAM For example To download the code for main c to RAM add the following linker command in the Additional Linker Directives dialog box see Additional Directives on page 68 change main TEXT RAM To go back to the Default Program Configuration for production code remove this directive from the Additional Linker Directives dialog box Assembly Program Setup The Assembly program setup for the Download to RAM Program Configuration is similar to the Default Program Configuration with some additional guidelines as described in this section Write all the executable program code nonstartup code under the CODE segment This segment belongs to EROM address space To set up this configuration you need to move 6 Configuring Memory for Your Program UMO17103 0207 268 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG the CODE segment from EROM to the RAM address space Do this by adding the follow ing linker command in the Additional Linker Di
279. f neither an exponent part or a decimal point appears a decimal point is assumed to follow the last digit in the string If a minus sign appears immediately before the first digit the value resulting from the conver sion is negated Synopsis finclude lt stdlib h gt double strtod const char nptr char endptr float strtof const char nptr char endptr Returns The converted value or zero if an inappropriate character occurs before any digit If the correct value would cause overflow plus or minus HUGE VAL is returned according to the sign of the value and the macro errno acquires the value ERANGE If the correct UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual zZiLOG 391 value causes underflow zero is returned and the macro errno acquires the value ERANGE Example char ptr char s 0 1456 double res res strtod s amp ptr strtok A sequence of calls to the st rtok function breaks the string pointed to by s1 into a sequence of tokens each of which is delimited by a character from the string pointed to by s2 The first call in the sequence has s1 as its first argument and is followed by calls with a null pointer as their first argument The separator string pointed to by s2 can be different from call to call The first call in the sequence searches s1 for the first character that 1s not contained in the current separator string s2 If no such character is foun
280. figuring Memory for Your Program ccc cece eee e cece nnn 251 ZNEO Memory Layout 0 een mee 251 Programmer s Model of ZNEO Memory 0c e eee eee eee ences 253 Unconventional Memory Layouts 2 0 c eee eee nes 257 Program Configurations 0 e cece cette teen ene ees 258 Default Program Configuration 0 cece eee eae 258 Download to ERAM Program Configuration 00 0 e cece eee eee 262 Download to RAM Program Configuration 0 2 00 c eee eee ee eee 265 Copy to ERAM Program Configuration 00 e eee eee eens 268 Copy to RAM Program Configuration 0 0 0 c eee eee eee 272 7 Using the Debugger 42 rr re e re See ERE RR e 277 Status Baf ere eirean a hee Rede ne eae eal pate hdl eed eae he de 278 Code Line Indicators 2 0 cence e 279 Debug WindOWSs ciere edd A SNORE aa as 279 Registers Window 2 0 cece eee s 279 Special Function Registers Window 0 0 cece cee eee ene es 280 Clock Window siria a a ates 281 Memory Window 0c cece tnt hs 282 Watch WindOW cita a id BO d etc e d s 287 Locals Window ssssseeseeeeee e teen nen ne eae 290 Call Stack WindOW stilin ebbe qul Eee RACER UA dee b UR at RR 290 Symbols Window oooococccccccoc eh e 291 Disassembly Window 00 cece cece ehe 291 Simulated UART Output Window 0 cece 292 Using Breakpoints 0 ccc e a 293
281. file Select Intel Hex32 Records from the Executable Formats area in the Project Settings dia log box Project Settings Output Page on page 78 How do determine the size of my actual hex code Refer to the map file Unless the Generate Map File check box is unchecked in the Project Settings dialog box Generate Map File on page 79 the linker creates a link map file each time it is run The link map file name is the same as your executable file with the map extension and resides in the same directory as your project file 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 248 zZiLOG WARNING AND ERROR MESSAGES NOTE Ifyou see an internal error message please report it to Technical Support at http support zilog com ZILOG staff will use the information to diagnose or log the problem This section covers warning and error messages for the linker locator 700 Absolute segment lt name gt is not on a MAU boundary The named segment is not aligned on a Minimum Addressable Unit boundary Padding or a correctly aligned absolute location must be supplied 701 address range error message A group section or address space is larger than is specified maximum length 704 Locate of a type is invalid Type lt typename gt It is not permitted to specify an absolute location for a type 708 lt name gt is not a valid group space or segment An invalid record type wa
282. files A project configuration is activated by being selected using the Select Configuration dialog box or the Select Build Configuration drop down list box or created using the Manage Configurations dialog box This option is not selected by default 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 104 zZiLOG e Select the Automatically Reload Externally Modified Files check box to automatically reload externally modified files This option is not selected by default e Select the Load Last Project on Startup check box to load the most recently active project when you start ZDS II This option is not selected by default e Select the Show the Full Path in the Document Window s Title Bar check box to add the complete path to the name of each file open in the Edit window This option is not selected by default Select the Save Restore Project Workspace check box to save the project workspace settings each time you exit from ZDS II This option is selected by default Select a number of commands to save in the Commands to Keep field or click Clear to delete the saved commands Options General Editor Debugger Iv Save files before build Always rebuild after configuration activated Automatically reload externally modified files Load last project on startup Show the full path in the document window s title bar v Save restore project workspace Command
283. fits your target system or create your own Click Setup to configure the target as needed Refer to the User Manual for details on Setup Add Copy Delete Debug Tool Current Simulator y lt lt Back Nec Finish Cancel Figure 36 New Project Wizard Dialog Box Target and Debug Tool Selection 11 Select the Use Page Erase Before Flashing check box to configure the internal Flash memory of the target hardware to be page erased If this check box is not selected the internal Flash is configured to be mass erased 12 Select the appropriate target from the Target list box 13 Click Setup in the Target area Refer to Setup on page 82 for details on configuring a target NOTE Click Add to create a new target see Add on page 84 or click Copy to copy an existing target see Copy on page 85 14 Select the appropriate debug tool and 1f you have not selected the Simulator click Setup in the Debug Tool area Refer to Debug Tool on page 87 for details about the available debug tools and how to configure them 15 Click Next The Target Memory Configuration step Figure 37 of the New Project Wizard dialog box 1s displayed 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG New Project Wizard 3 Target Memory Configuration Linker Address Spaces Use oe fields to dafine the Linker Address Spaces pl Pond memo
284. for the ZNEO proces sors 1 Ensure that the target board is powered up and the emulator is connected and operating properly 2 Inthe Configure Target dialog box see page 82 do the following a If external memory is used on the target ensure that the appropriate external bus interface is selected and that each chip select register used on the target is enabled and configured properly UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 95 zZiLOG b Configure the Clock Source and Frequency settings to match the clock source and frequency used on the target 3 Inthe Address Spaces page see page 74 configure the address range for each type of memory that is present on the target 4 Select Flash Loader from the Tools menu The Flash Loader connects to the target and sets up communication The Flash Loader Processor dialog box see Figure 71 1s displayed with the appropriate Flash target options for the selected CPU Flash Loader Processor 216F2811AL Flash File Start Address File E15f28001002cog hex Internal Start Address E Path c program filesszilog zdsii zneo 4 10 1 samples quickstartrelease Flash Options Flash Configuration File Offset Internal Flash E 000000 O1FFFF INT Serialization Controls Y Internal Flash Enable External Flash 4 Micron E AMD E STMicro TE Flash File Controls Status Erase Program Program a
285. g on page 58 When the Limit Optimizations for Easier Debugging check box is selected register variables are not used because they can cause confusion when debugging The Use Register Variables check box is disabled grayed out when the Limit Optimizations for Easier Debugging check box is selected If the Limit Optimizations for Easier Debugging check box is later deselected even in a later ZDS II session the Use Register Variables check box returns to the setting it had before the Limit Optimizations for Easier Debugging check box was selected Using register variables can complicate debugging in at least two ways One way is that register variables are more likely to be optimized away by the compiler If variables you want to observe while debugging are being optimized away you can usually prevent this by any of the following actions e Select the Limit Optimizations for Easier Debugging check box see Limit Optimizations for Easier Debugging on page 58 e Deselect the Use Register Variables check box Rewrite your code so that the variables in question become global rather than local The other way that register variables can lead to confusing behavior when debugging is that the same register can be used for different variables or temporary results at different times in the execution of your code Because the debugger is not always aware of these multiple uses sometimes a value for a register variable might be shown in the Watch win
286. g the Debug mode This option is selected by default Select the Reset to Symbol main Where Applicable check box to skip the startup boot code and start debugging at the main function for a project that includes a C language main function When this check box is selected a user reset clicking the Reset button on the Build and Debug toolbars selecting Reset from the Debug menu or using the reset script command results in the program counter PC pointing to the beginning of the main function When this check box is not selected a user reset results in the PC pointing to the first line of the program the first line of the startup code e When the Show DataTips Pop Up Information check box is selected holding the cursor over a variable in a C file in the Edit window in Debug mode displays the value 2 Using the Integrated Development Environment UMO17103 0207 108 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG UMO17103 0207 Select the Hexadecimal Display check box to change the values in the Watch and Locals windows to hexadecimal format Deselect the check box to change the values in the Watch and Locals windows to decimal format Select the Verify File Downloads Read After Write check box to perform a read after write verify of the Code Download function Selecting this check box increases the time taken for the code download to complete Select the Verify File Downloads Upon Completion check box to verify t
287. general debug Ignore Case of Symbols option general igcase Intermediate Files Directory option general outputdir Settings Assembler page Includes option assembler include Table 14 Defines option assembler define on Generate Assembly Listing Files option assembler list page 324 Ist Expand Macros option assembler listmac Page Width option assembler pagewidth Page Length option assembler pagelen Settings Code Generation Limit Optimizations for Easier option compiler reduceopt Table 15 page Debugging on Memory Model option compiler model page 324 Settings Listing Files page Generate C Listing Files lis option compiler list Table 15 With Include Files option compiler listinc on Generate Assembly Source Code option compiler keepasm page 324 Generate Assembly Listing Files option compiler keeplst Ist Settings Preprocessor page Preprocessor Definitions option compiler define Table 15 Standard Include Path option compiler stdinc on User Include Path option compiler usrinc page 324 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual Table 12 Script File Commands Continued zZiLOG ZDS II Menus ZDS II Commands Dialog Box Options Script File Commands Page Settings Advanced page Use Register Variables option compiler regvar Table 15 Generate Printfs Inline option compiler genprintf on Distinct Code Segment for Each option compiler modsect page 324 Module
288. ght C 1999 2004 ZiLOG Inc All Rights Reserved LINK MAP DATE Wed Dec 07 13 51 43 2005 PROCESSOR assembler FILES C PROGRA 1 ZiLOG ZDSII_ 1 0 lib zilog startupexkS obj main obj Z16F2800100ZC0G obj C PROGRA 1 ZiLOG ZDSII_ 1 0 lib std chelpSD lib C PROGRA 1 ZiLOG ZDSIT_ 1 0 lib std crtSD lib C PROGRA 1 ZiLOG ZDSII_ 1 0 lib std fpSD lib COMMAND LIST UMO17103 0207 5 Using the Linker Locator Linker Comma Generated by ZDS II ZN IDE compone compiler opt chartype U define Z16 NOlistinc zs stdinc C PROG include zilog NOregvar r asmsw cp ZiLOG Developer Studio ll ZNEO User Manual Zim zZiLOG nd File Z216F2800100ZC0G Debug RT ions EO 4 11 0 Build 05120701 nt b 4 10 05120701 ny define Z16F2811AL define Z16K SERIES F SERIES genprintf keepasm NOkeeplst NOlist model S educeopt debug cpu Z16F2811AL u 216F2811AL define Z16F2811AL 1 define Z16K SERIES 1 RA 1 ZiLOG ZDSII_ 1 0 include std C PROGRA 1 ZiLOG ZDSII_ 1 0 define Z16F SE RIES 1 include C PROG include zilog assembler op define 216 define Z16 e tions F2811AL 1 define Z16K S F SERIES 1 RA 1 ZiLOG ZDSII_ 1 0 include std C PROGRA 1 ZiLOG ZDSII_ 1 0 ERI
289. gister at the Technical Support web page UMO17103 0207 Preface ZiLOG Developer Studio ll ZNEO User Manual XXV zZiLOG Before Contacting Technical Support Before you use technical support consult the following documentation readme txt file Refer to the readme txt file in the following directory for last minute tips and information about problems that might occur while installing or running ZDS II lt ZILOGINSTALL gt ZDSI11_product_version where ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files ZiLoG product is the specific ZiLOG product For example product can be ZNEO Z8Encore eZ80Acclaim Crimzon or Z8GP version is the ZDS II version number For example version might be 4 11 0 or 5 0 0 e rAQ html file The FAQ html file contains answers to frequently asked questions and other information about good practices for getting the best results from ZDS II The information in this file does not generally go out of date from release to release as quickly as the information in the readme txt file You can find the FAQ htm1 file in the following directory ZILOGINSTALL NZDSII product version where ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files ZiLoG product is the specific ZiLOG product For example product can be ZNEO
290. gment If SPLITTABLE is not specified for a given segment the linker allocates the entire seg ment contiguously The SPLITTABLE command takes precedence over the ORDER and SEQUENCE com mands By default ZDS II segments are nonsplittable When multiple segments are made splitta ble the linker might re order segments regardless of what is specified in the ORDER or SEQUENCE command In this case you need to do one of following actions Modify the memory map ofthe system so there 1s only one discontinuity and only one splittable segment in which case the ORDER command is followed e Modify the project so a specific ordering of segments is not needed in which case multiple segments can be marked splittable Syntax SPLITTABLE segment list Example SPLITTABLE CODE ROM TEXT UNRESOLVED IS FATAL The UNRESOLVED IS FATAL command causes the linker to treat undefined external symbol warnings as fatal errors The linker quits generating output files immediately if UMO017103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual 225 zZiLOG the linker cannot resolve any undefined symbol By default the linker proceeds with gen erating output files if there are any undefined symbols Syntax lt UNRESOLVED gt IS gt FATAL Examples unresolved fatal or UNRESOLVED IS FATAL WARN The WARN command specifies
291. gs Configuration Debug m 5e General Eh Assembler 2 Rl c Sk Code Generation Sis Listing Files E Preprocessor kh Advanced f amp Linker 5s Commands 3 Objects and Libraries v Limit Optimizations for Easier Debugging ENS Address Spaces Mte Mode I B A Warnings Sk Output Debugger Cancel Help Figure 49 Code Generation Page of the Project Settings Dialog Box Limit Optimizations for Easier Debugging Selecting this check box causes the compiler to generate code in which certain optimiza tions are turned off These optimizations can cause confusion when debugging For exam ple they might rearrange the order of instructions so that they are no longer exactly correlated with the order of source code statements or remove code or variables that are not used You can still use the debugger to debug your code without selecting this check box but it might difficult because of the changes that these optimizations make in the assembly code generated by the compiler Selecting this check box makes it more straightforward to debug your code and interpret what you see in the various Debug windows However selecting this check box also causes a moderate increase in code size Many users select this check box until they are ready to go to production code and then deselect it UMO17103 0207 2 Using the Integrated Development Environment NOTE NOTE ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Selec
292. gt OFFSET lt expression gt gt gt lt lt digit digit hexdigit hexdigit _ H bindigit bindigit _ B lt char_const gt any lt ident gt lany g letter _ letter _ digit lt ident gt lt ident gt lt ident gt MACRO lt arg gt lt arg gt lt code_body gt ENDMAC RO lt macname gt lt macname gt lt arg gt lt arg gt UMO17103 0207 207 ZiLOG Developer Studio Il ZNEO User Manual 208 zZiLOG lt arg gt macro argument public definition gt PUBLIC lt ident list EXTERN lt ident list scalar definition gt type value segment definition gt DEFINE lt ident gt lt space_clause gt gt lt align_clause gt lt org_clause gt lt space_clause gt gt SPACE lt space gt lt align_clause gt gt ALIGN cint const org clause gt ORG cint const space gt RAM ROM ERAM EROMIIODATA WARNING AND ERROR MESSAGES This section covers warning and error messages for the assembler 400 Symbol already defined The symbol has been previously defined 401 Syntax error General purpose error when the assembler recognizes only part of a source line The assembler might generate multiple syntax errors per source line 402 Symbol XREF d and XDEF d Label previously marked as externally defined or referenced This error occurs when an attempt is made to both XREF and XDEF
293. gure 81 Font Dialog Box 0 2 eee ect e 107 Figure 82 Options Dialog Box Debugger Tab 0 0 00 cece eee ee 108 Figure 83 ZNEO C Compiler Memory Layout 00 00 00 cee eee eee ee 116 Figure 84 Call Frame Layout 00 cece cece e eee anes 130 Figure 85 ZNEO Hierarchical Memory Model 0 0 cee eee eens 145 Figure 86 Multiple File Linking ssleeeeeeeee II 145 Figure 87 Typical ZNEO Physical Memory Layout useless 252 Figure 88 Typical ZNEO Programmer s Model General 2 4 256 Figure 89 Programmer s Model Default Program Configuration 259 Figure 90 Programmer s Model Download to ERAM Program Configuration 263 Figure 91 Programmer s Model Download to RAM Program Configuration 266 Figure 92 Programmer s Model Copy to ERAM Program Configuration 269 Figure 93 Programmer s Model Copy to RAM Program Configuration 273 Figure 94 Debug and Debug Window ToolbarsS o oooooocococcoccccon 278 Figure 95 Registers Window 0oooococcccoccoccrc e 280 Figure 96 Special Function Registers Window o coococcccoccoconcoccn o 280 Figure 97 Clock Window 00 0 cece cece cece ee 281 Figure 98 Memory Window ssseseeeee ehe 282 Figure 99 Memory Window Starting Address 2 0 0 eee esses 283 Figure 100 Memory Window Requested Address 00 0 cee ee eeee 284 Figure 1
294. h ch getch NOTE Before using this function the init_uart function needs to be called to initialize and select the UART The default UARTis UARTO init_uart The init uart function is a ZiLOG function that selects the specified UART and initial izes it for specified settings and returns the error status 3 Using the ANSI C Compiler UMO17103 0207 138 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Synopsis include lt sio h gt int init uart int port unsigned long freq unsigned long baud Returns Returns 0 if initialization is successful and 1 otherwise Example tinclude lt stdio h gt include lt sio h gt void main init uart UARTO DEFFREQ DEFBAUD printf Hello UARTO An Write to UARTO _DEFFREQ is automatically set from the IDE using the setting in the Configure Target dialog box See Setup on page 82 kbhit kbhit is a ZiLOG function that determines whether there is receive data available on the selected UART Synopsis include lt sio h gt int kbhit void Returns Returns if there is receive data available on the selected UART otherwise it returns 0 Example int i i kbhit NOTE Before using this function the init uart function needs to be called to initialize and select the UART The default UART is UARTO putch putch is a ZiLOG function that sends a character to the selected UART and returns the error status
295. h commas Modules listed in this field are linked before the ZiLOG default libraries Therefore if there is a name conflict between symbols in one of these user specified additional modules and in a ZiLOG default library the user specified module takes precedence and its version of the symbol is the one used in linking You can take advantage of this to provide your own replacement for one or more functions for example C run time library functions by compiling the function and then including the object module name in this field This is an alternative to 2 Using the Integrated Development Environment UMO17103 0207 72 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG including the source code for the revised function explicitly in your project which would also override the function in the default run time library C Startup Module The buttons and check box in this area which are not available for Assembly Only projects control which startup module is linked to your application All C programs require some initialization before the main function is called which is typically done in a startup module Standard If the Standard button is selected the precompiled startup module shipped with ZDS II is used This standard startup module performs a minimum amount of initialization to pre pare the run time environment as required by the ANSI C Standard and also does some ZNEO specific configuration such as interrupt vector t
296. h functions 349 351 356 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z az ZiLOG SEARCHPATH command 223 SEGMENT directive 169 189 Segments 143 168 214 absolute 168 170 186 214 address space 186 alignment 170 185 allocation order 223 attaching code 169 attaching data 169 copying 217 creating 169 defining 185 definition 167 linking sequence 222 locating 186 220 moving 216 origin 170 predefined 168 relocatable 168 170 214 renaming 216 setting maximum size 221 setting ranges 222 splitting 224 types 168 user defined 169 Select Build Configuration list box 19 Select Configuration dialog box 90 Select Linker Command File dialog box 69 Select Project Name dialog box 2 37 select_port function 139 SEQUENCE command 223 226 Serial Number list box 88 Serial number choosing 88 Serial Value field 97 set config script file command 329 Set Next Instruction button 24 SET_VECTOR 140 setjmp function 346 381 lt setjmp h gt header 346 Setting breakpoints 293 Setup button Target area 82 Index Setup Ethernet Smart Cable Communication dialog box 87 Setup USB Communication dialog box 88 SFR definition 280 short enumerations 124 SSHORT STACK FRAME directive 189 Shortcut keys 110 Show Absolute Addresses in Assembly List ings check box 80 Show CRC dialog box 98 99 287 Show DataTips Pop Up Information check box 107 Show the Full Path in the Document Window s Title Bar ch
297. h gt void memmove void s1 const void s2 size t n Returns The value of s1 Example Glar s1 1015 char s2 COMPASS memmove s1 s2 8 sizeof char memset Copies the value of c converted to an unsigned char into each of the first n characters of the object pointed to by s Synopsis finclude lt string h gt void memset void s int c size t n Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 372 Returns The value of s Example char str 20 char c a memset str c 10 sizeof char modf modff Breaks the argument value into integral and fractional parts each of which has the same sign as the argument It stores the integral part as a double modf or float modff in the object pointed to by iptr Synopsis dinclude lt math h gt double modf double value double iptr float modff float value float iptr Returns The signed fractional part of value Example double x 1 235 double f double i i modf x amp f pow powf Computes the x raised to the power of y A domain error occurs if x is zero and y is less than or equal to zero or if x 1s negative and y is not an integer A range error can occur Synopsis include lt math h gt double pow double x double y float powf float x float y Returns The value of x raised to the power y Example double x 2 0 double y 3 0 UMO17103 0207 Appendix C C S
298. h to command file runall cmd zds2ide commands txt Processed commands are echoed and associated results are displayed in the Command Output window in the IDE and if logging is enabled see log on page 321 in the log file as well Commands are not case sensitive In directory or path based parameters you can use 1 11 or as separators as long as you use the same separator throughout a single parameter For example the following exam ples are legal cd path to change to cd path to change to cd path to change to The following examples are illegal cd path to change to cd path to change to Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 308 zZiLOG Table 12 lists ZDS II menu commands and dialog box options that have corresponding script file commands Table 12 Script File Commands UMO17103 0207 ZDS II Menus ZDS II Commands Dialog Box Options Script File Commands Page File New Project new project page 322 Open Project open project page 322 Exit exit page 320 Edit Manage Breakpoints list bp page 320 Go to Code Enable All Disable All Remove cancel bp page 314 Remove All cancel all page 314 Project Add Files add file page 312 Settings General page CPU Family Table 16 CPU option general cpu on Show Warnings option general warn page 325 Generate Debug Information option
299. han one ASCII character 121 Illegal declaration specifier An attempt was made to declare an object with an illegal declaration specifier 122 Only const and volatile may be specified with a struct union enum or typedef An attempt was made to declare a struct union enum or typedef with a declaration specifier other than const and volatile 123 Cannot specify both long and short in declaration specifier An attempt was made to specify both long and short in the declaration of an object 124 Only type qualifiers may be specified within pointer declarations An attempt was made to declare a pointer with a declaration specifier other than const and volatile 125 Identifier lt name gt already declared within current scope An attempt was made to declare two objects of the same name in the same scope 126 Identifier lt name gt not in function argument list ignored An attempt was made to declare an argument that is not in the list of arguments when using the old style argument declaration syntax 127 Name of formal parameter not given The type of a formal parameter was given in the new style of argument declarations without giving an identifier name 128 Identifier lt name gt not defined within current scope An identifier was encountered that is not defined within the current scope 129 Cannot have more than one default per switch statement More than one default statements were found in a single switch statement 13
300. he n directive setjmp Saves its calling environment in its jmp buf argument for later use by the Longjmp function Synopsis include lt setjmp h gt int setjmp jmp buf env Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 382 Returns If the return is from a direct invocation the set jmp function returns the value zero If the return is from a call to the Long jmp function the set jmp function returns a nonzero value Example int i jmp buf env i setjmp env longjmp env i sin sinf Computes the sine of x measured in radians A large magnitude argument can yield a result with little or no significance Synopsis tinclude lt math h gt double sin double x float sinf float x Returns The sine value Example double x 1 24 double y y sin x sinh sinhf Computes the hyperbolic sine of x A range error occurs if the magnitude of x is too large Synopsis tinclude lt math h gt double sinh double x float sinhf float x Returns The hyperbolic sine value UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual A zZiLOG Example double x 1 24 double y y sinh x sprintf The sprintf function is equivalent to printf except that the argument s specifies an array into which the generated output is to be written rather than to a stream A null char acter is written at th
301. he Use C Runtime Library check box only functions you call in your application are linked into your application Floating Point Library The Floating Point Library drop down list box allows you to choose which version of the subset of the C run time library that deals with the floating point operations will be linked to your application e Real 2 Using the Integrated Development Environment UMO17103 0207 73 74 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG If you select Real the true floating point functions are linked in and you can perform any floating point operations you want in your code Dummy If you select Dummy your application is linked with alternate versions that are stubbed out and do not actually carry out any floating point operations This dummy floating point library has been developed to reduce code bloat caused by including calls to printf and related functions such as sprintf Those functions in turn make calls to floating point functions for help with formatting floating point expressions but those calls are unnecessary unless you actually need to format floating point values For most users this problem has now been resolved by the Generate Printfs Inline check box see Generate Printfs Inline on page 64 for a full discussion You only need to select the dummy floating point library if you have to disable the Generate Printfs Inline check box and your application uses no floating
302. he code that you downloaded after it has downloaded Select the Load Debug Information Current Project check box to load the debug information for the currently open project when the Connect to Target command is executed from the Debug menu or from the Connect to Target button This option is selected by default Select the Activate Breakpoints check box for the breakpoints in the current project to be active when the Connect to Target command is executed from the Debug menu or from the Connect to Target button This option is selected by default Select the Disable Warning on Flash Optionbits Programming check box to prevent messages from being displayed before programming Flash option bits Options General Editor Debugger v Save project before start of debug session v Reset to symbol main where applicable iw Show DataTips pop up information v Hexadecimal Display Verify File Downloads Read after Write Verify File Downloads Upon Completion On Connect To Target V Load debug information current project v Activate breakpoints Disable warning on Flash Optionbits programming Cancel Help Figure 82 Options Dialog Box Debugger Tab Window Menu The Window menu allows you to select the way you want to arrange your files in the Edit window and allows you to activate the Project Workspace window or the Output window 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNE
303. he librarian command line options NOTE If you use DOS use double quotation marks for the stdinc and usrinc commands for the C compiler For example stdinc C Nez8Ninclude If you use cygwin use single quotation marks on both sides of a pair of braces for the stdinc and usrinc commands for the C compiler For example stdine C ez8 include Table 10 Librarian Command Line Options Option Name Description help Displays the librarian help screen list Generates an output listing with the 1st extension This is the default setting noquiet Displays the title information nowarn Suppresses warning messages quiet Suppresses title information that is normally displayed to the screen Errors and warnings are still displayed The default setting is to display title information version Displays the version number of the librarian warn Displays warnings LINKER COMMAND LINE OPTIONS Table 11 describes the linker command line options NOTE If you use DOS use double quotation marks for the stdinc and usrinc commands for the C compiler For example stdinc C lez8linclude If you use cygwin use single quotation marks on both sides of a pair of braces for the stdinc and usrinc commands for the C compiler For example stdinc C ez8 include Table 11 Linker Command Line Options Option Name Description copy segment space Makes a copy of a segment into a specified address sp
304. he particular segment in RAM at run time and EROM at load time For example to copy the code for main c to RAM add the following linker commands in the Additional Linker Directives dialog box see Additional Directives on page 68 change main TEXT RAM Run time main TEXT is in RAM space copy main TEXT EROM Load time main TEXT is in EROM space define low main copy copy base of main TEXT define low main base of main TEXT define len main length of main TEXT 3 Thelinker COPY directive only designates the load addresses and the run time addresses for the segment The actual copying of the segment needs to be performed by the startup code For example if you are using the small model copy and modify the C startup provided in the installation under src boot common startupexs asm rewriting the relevant section as follows Copy main TEXT into ERAM EA RO low main copy EA R1 low main LD R2 len main 1 JP mlabl mlabO0 LD B R3 RO LD B R1 R3 mlabl DJNZ R2 mlab0 XREF low main copy EROM XREF len main XREF low main RAM 6 Configuring Memory for Your Program UMO17103 0207 276 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG 4 Finally add your modified startup module to your project To do this you must select the Included in Project button in the Objects and Libraries page of the Project Settings dialog box see
305. hese directives are instructions to the assembler itself and are not part of the microprocessor instruction set Each of the supported assembler directives is described in the following sections ALIGN on page 181 e COMMENT on page 182 e CPU on page 182 e Data Directives on page 182 e DEFINE on page 185 e DS on page 186 END on page 186 e EQU on page 187 e INCLUDE on page 187 e LIST on page 188 e NOLIST on page 188 e ORG on page 188 e SEGMENT on page 189 e SHORT STACK FRAME on page 189 TITLE on page 190 VAR on page 190 e VECTOR on page 191 e XDEF on page 192 e XREF on page 192 Structures and Unions in Assembly Code on page 192 ALIGN Forces the object following to be aligned on a byte boundary that is a multiple of value Synonym align Syntax align directive gt ALIGN value 4 Using the Macro Assembler UMO17103 0207 181 182 ZiLOG Developer Studio Il ZNEO User Manual Example ALIGN 2 DW EVEN LABEL COMMENT CPU The COMMENT assembler directive classifies a stream of characters as a comment The COMMENT assembler directive causes the assembler to treat an arbitrary stream of characters as a comment The delimiter can be any printable ASCII character The assembler treats as comments all text between the initial and final delimiter as well
306. his defines an EROM string constant The string is stored in EROM The address of the string is a_Erom pointer The following is an example of string placement include lt sio h gt void funcn Near char str while str putch str putch n UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 123 zZiLOG void funcf Far char str while str putch str putch n void funcr Rom char str while str putch str putch in void funcer Erom char str while str putch str putch n void main void funcn N nstr funcf F fstr funcr R rstr funcer E erstr Inline Assembly There are two methods of inserting assembly language within C code Inline Assembly Using the Pragma Directive The first method uses the pragma feature of ANSI C with the following syntax pragma asm lt assembly line gt pragma can be inserted anywhere within the C source file The contents of lt assembly line gt must be legal assembly language syntax The usual C escape sequences such as n t and r are properly translated Currently the compiler does not process the lt assembly line gt Except for escape sequences it is passed through the compiler verba tim 3 Using the ANSI C Compiler UMO17103 0207 124 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Inline Ass
307. hus the bus can have multiple bus cycles pending at a time POP Retrieve a value from the stack port The point at which a communications circuit terminates at a network serial or parallel interface card power The rate of transfer or absorption of energy per unit time in a system push To store a value in the stack R RAM Random access memory A memory that can be written to or read at random The device is usually volatile which means the data is lost without power random access memory RAM A read write nonsequential access memory used for the storage of instructions and data read only memory ROM A type of memory in which data under normal conditions can only be read Nonvolatile computer memory that contains instructions that do not require change such as permanent parts of an operating system A computer can read instructions from ROM but cannot store new data in ROM Also called nonerasable storage register A device accessible to one or more input circuits that accepts and stores data A register is most often used only as a device for temporary storage of data ROM See read only memory RR Rotate Right UMO17103 0207 Glossary ZiLOG Developer Studio ll ZNEO User Manual Zu zZiLOG S SCF Set C Flag SL Shift Left SLL Shift Left Logical SP Stack Pointer SR Shift Right SRA Shift Right Arithmetic Static Characteristic of random access memory that enables it to operate witho
308. icating the characteristics of one product or part using another medium For example an In Circuit Emulator ICE module duplicates the behavior of the chip it emulates in the circuit being tested emulator An emulation device EOF End of file when all records in a file are processed the computer encounters an end of file condition EPROM Erasable Programmable Read Only Memory An EPROM can be erased by exposure to ultraviolet light EQ A Boolean operator meaning Equal to escape sequence A special escape command is entered as three plus symbols placing the modem in command mode and interrupting user data transmission However the escape sequence does not terminate the data connection Command mode allows the entering of commands while the connection is maintained F F Falling Edge Fast Fourier Transform An algorithm for computing the Fourier transform of a set of discrete data values Given a finite set of data points for example a periodic sampling taken from a real world signal the FFT expresses the data in terms of its component frequencies It also solves the essentially identical inverse problem of reconstructing a signal from the frequency data FFT See Fast Fourier Transform filter A process for removing information content such as high or low frequencies flag In data transmission or processing an indicator such as a signal symbol character or digit used for identification A flag may be a
309. imulator c C F Extemal Dependen El FORMAT H C QuickStart h C tinclude QuickStart h SIO H C XProar El STDARG H C El STDIO H CAP int ch B Zconsth C Pre void main El nen h PAPI mei include lt sio h gt A initi Connected to target Simulator Starting debug session project Simulator configuration Debug Cpu Z16F2811AL Loading file C Program Files ZiLOGNZDSII_ZNEO_4 11 0 samples QuickStart Debug Simulator lod Loading file C Program Files ZiLOGNZDSII_ZNEO_4 11 0 samples QuickStart Debug Simulator lod successful gt JS Build A Debug Find in Files A Find in Fil 4 For Help press F1 Ln 7 Col 24 Figure 94 Debug and Debug Window Toolbars NOTE Project code cannot be rebuilt while in Debug mode The Development Environment will prompt you if you request a build during a debug session If you edit code during a debug session and the attempt to execute the code the Development Environment will stop the current debug session rebuild the project and then attempt to start a new debug session if you elect to do so when prompted STATUS BAR The status bar displays the current status of your program s execution The status can be STOP STEP or RUN In STOP mode your program is not executing In STEP mode a Step Into Step Over or Step Out command is in progress In RUN mode a Go command has been issued with no animate active UM017103 0207 7 Us
310. include lt math h gt double fabs double x float fabsf float x Returns The absolute value of x Example double y 6 23 double x x fabs y floorf Computes the largest integer not greater than x Synopsis tinclude lt math h gt double floor double x float floorf float x Returns The largest integer not greater than x expressed as a double for 1oor and expressed as a float for floorf Example double y 6 23 double x x floor y fmodf Computes the floating point remainder of x y If the quotient of x y cannot be represented the behavior is undefined Synopsis tinclude lt math h gt double fmod double x double y float fmodf float x float y UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 361 zZiLOG Returns The value of x if y is zero Otherwise it returns the value f which has the same sign as x such that x 1 y f for some integer 1 where the magnitude of fis less than the magni tude of y Example double y 7 23 double x 2 31 double z z fmod y x free Causes the space pointed to by ptr to be deallocated that is made available for further allocation If ptr is a null pointer no action occurs Otherwise if the argument does not match a pointer earlier returned by the calloc malloc or realloc function or if the space has been deallocated by a call to free or realloc the behavior is undefined
311. ine the quadrant of the return value A domain error occurs if both arguments are Zero Synopsis tinclude lt math h gt double atan2 double y double x float atan2f float y float x Returns The arc tangent of y x in the range pi pi Example double y 1234 double x 4321 double z z atan2 y x UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 355 zZiLOG atof atoff Converts the string pointed to by nptr to double representation Except for the behavior on error atof is equivalentto strtod nptr char NULL and atoff is equiva lentto strtof nptr char NULL Synopsis include lt stdlib h gt double atof const char nptr float atoff const char nptr Returns The converted value Example char str 1 234 double x x atof str atoi Converts the string pointed to by nptr to int representation Except for the behavior on error it is equivalent to int strtol nptr char NULL 10 Synopsis include lt stdlib h gt int atoi const char nptr Returns The converted value Example char str 50 int x x atoi str atol Converts the string pointed to by nptr to long int representation Except for the behavior on error it is equivalent to strtol nptr char NULL 10 Synopsis tinclude lt stdlib h gt long int atol const char nptr Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio
312. ing the Debugger ZiLOG Developer Studio ll ZNEO User Manual 279 zZiLOG CODE LINE INDICATORS The Edit window displays your source code with line numbers and code line indicators The debugger indicates the status of each line visually with the following code line indica tors A red octagon indicates an active breakpoint at the code line a white octagon indicates a disabled breakpoint Blue dots are displayed to the left of all valid code lines these are lines where breakpoints can be set the program can be run to and so on NOTE Some source lines do not have blue dots because the code has been optimized out of the executable and the corresponding debug information A program counter code line indicator yellow arrow indicates the code line at which the program counter is located A program counter code line indicator on a breakpoint yellow arrow on a red octagon indicates a code line indicator has stopped on a breakpoint If the program counter steps into another file in your program the Edit window switches to the new file automatically DEBUG WINDOWS The Debug Windows toolbar described in Debug Windows Toolbar on page 24 allows you to display the following Debug windows Registers Window on page 279 Special Function Registers Window on page 280 Clock Window on page 281 Memory Window on page 282 Watch Window on page 287 Locals Window on page 290 Call Stack Windo
313. inker Locator UMO17103 0207 240 ZiLOG Developer Studio Il Library chelpSD lib Version 1 0 12 06 2005 Library chelpSD lib Library chelpSD lib Version Library chelpSD lib Version Library chelpSD lib Library chelpSD lib Version ZNEO User Manual zZiLOG Module common vectic asm 16 59 45 Name Segment _ VECTORS 1C Module common vect20 asm 16 59 45 Name Segment VECTORS 20 Module common vect24 asm 16 59 45 Name Segment VECTORS 24 Module common vect28 asm 16 59 45 Name Segment VECTORS 28 Module common vect2c asm 16 59 45 Name Segment _ VECTORS 2C Module common vect30 asm 16 59 45 Name Segment VECTORS 30 UMO17103 0207 5 Using the Linker Locator Module 16 59 45 common vect34 asm Library chelpSD ZiLOG Developer Studio ll ZNEO User Manual Z 241 Segment Module 16 59 45 VECTORS 34 common vect38 asm Library chelpSD Segment Module 16 59 45 VECTORS 38 common vect3c asm Library chelpSD Segment Module 16 59 45 VECTORS 3C common vect40 asm Library chelpSD Segment Module 16 59 45 VECTORS 40 common vect44 asm Library chelpSD Segment Module 16 59 45 VECTORS 44 common vect48 asm Library chelpSD Segment VECTORS 48 5 Using the
314. ions to the ANSI standard and deviations from the behavior described by the standard The extensions to the ANSI standard are explained in Language Extensions on page 114 There are a small number of areas in which the ZNEO C Compiler does not behave as specified by the Standard These areas are described in the following sections UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 151 zZiLOG Prototype of Main As per ANSI C in a freestanding environment the name and type of the function called at program startup are implementation defined Also the effect of program termination is implementation defined For compatibility with hosted applications the ZNEO C Compiler uses main as the function called at program startup Because the ZNEO compiler provides a freestanding execution environment there are a few differences in the syntax for main The most important of these is that in a typical small embedded application main never executes a return as there is no operating system for a value to be returned to and is also not intended to terminate If main does terminate and the standard ZiLOG ZNEO C startup module is in use control simply goes to the statement exit B JP exit For this reason in the ZNEO C Compiler main needs to be of type void any returned value is ignored Also main is not passed any arguments In short the following is the prototype for main
315. is a 32 bit address The global variables can be manually placed into the RAM ROM or EROM address space by using the Near Rom and Erom address specifiers respectively The local variables nonstatic and parameters are always allocated in the ERAM address space and any address specifiers if used on them are ignored In the large memory model the local and global data and parameters can span the entire ERAM space which can be configured at the user s discretion to be much larger than the space available in the RAM address space Besides the requirement to implement an external memory interface the costs of using the large model are that 32 bit addressing is required to access the variables in ERAM causing an increase in code size Also pointers to these data are 32 bits which might increase the data space requirements if the application uses lots of pointers It is possible that the application might run more slowly if accesses to external memory require wait states To reduce the impact of some of these issues you can selectively place your more frequently accessed global and static data in RAM using the Near keyword 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 120 zZiLOG Interrupt Support To support interrupts the ZNEO C Compiler provides two features e interrupt Keyword on page 120 e Interrupt Vector Setup on page 120 interrupt Keyword Functions that a
316. is changed to OCATE s uninit data at BASE OF RAM the lowest used address is 9000 because LOCATE s nvrblock at 9000 and s nvrblock is in RAM Multiply The Multiply operator is used to multiply two expressions Syntax lt expression gt lt expression gt Decimal Numeric Values Decimal numeric constant values can be used as an expression or part of an expression Digits are collections of numeric digits from 0 to 9 Syntax lt digits gt UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual Z 231 ZiLOG Hexadecimal Numeric Values Hexadecimal numeric constant values can be used as an expression or part of an expres sion Hex digits are collections of numeric digits from 0 to 9 or A to F Syntax lt hexdigits gt Or The Or operator is used to perform a bitwise inclusive Or of two expressions Syntax lt expression gt lt expression gt lt lt Shift Left The lt lt Shift Left operator is used to perform a left shift The first expression to the left of lt lt is the value to be shifted The second expression is the number of bits to the left the value is to be shifted Syntax lt expression gt lt lt lt expression gt gt gt Shift Right The gt gt Shift Right operator is used to perform a right shift The first expression to the left of gt gt is the value to be shifted The second expression is the number of
317. ist 2 Right click in the Memory window list box to display the context menu 3 Select Fill Memory The Fill Memory dialog box is displayed as shown in Figure 101 Fill Memory Fill Value Address Range FF Start Address Hex 00000000 EE C 00 End Address Hex OOFFBFFF C Other o Cancel Figure 101 Fill Memory Dialog Box 4 Inthe Fill Value area select the characters to fill memory with or select the Other button If you select the Other button type the fill characters in the Other field UMO17103 0207 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual 285 zZiLOG 5 Type the start address in hexadecimal format in the Start Address Hex field and type the end address in hexadecimal format in the End Address Hex field This address range is used to fill memory with the specified value 6 Click OK to fill the selected memory Save Memory to a File Use this procedure to save memory specified by an address range to a binary hexadeci mal or text file Perform the following steps to save memory to a file 1 Select the memory space in the Space drop down list 2 Right click in the Memory window list box to display the context menu 3 Select Save to File The Save to File dialog box is displayed as shown in Figure 102 Save To File File Name Ed File Format Address Range C Text Start Address Hex 00000000 f Hex End Address Hex DOFFBFFF C Bin
318. it addressed range above the highest EROM address and below FF 8000 For exam ple Far int fi fi is placed in ERAM address space Storage Specification for Pointers To properly access Near Far Rom and Erom objects using a pointer the compiler provides the ability to associate the storage specifier with the pointer type Near pointer The Near pointer points to Near data e Far pointer The Far pointer points to Far data e Rom pointer The Rom pointer points to Rom data e Erom pointer The Erom pointer points to Erom data For example char Near Far npf npf is a pointer to a Near char npf itself is stored in Far memory Default Storage Specifiers Default storage specifiers are applied if none is specified The default storage specifiers depend on the memory model chosen See Table 1 for the default storage specifiers for each model type Table 1 Default Storage Specifiers Function Globals Locals String Const Parameters Pointer Small S _Erom _ Near _Near _ Near _Near _Near _ Near Large L _Erom _Far _Far _Far _Far _Far _Far 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 118 zZiLOG Space Specifier on Structure and Union Members The space specifier for a structure or union takes precedence over the space specifier of an individual member When the space specifier of a member does not match the space spec ifier of its structure
319. itional assembly is used to control the assembly of blocks of code Entire blocks of code can be enabled or disabled using conditional assembly directives The following conditional assembly directives are allowed e JF e IFDEF IFSAME e IFMA Any symbol used in a conditional directive must be previously defined by an EQU or VAR directive Relational operators can be used in the expression Relational expressions eval uate to 1 if true and 0 if false 4 Using the Macro Assembler UMO17103 0207 198 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG If a condition is true the code body is processed Otherwise the code body after an ELSE is processed if included The ELIF directive allows a case like structure to be implemented NOTE Conditional assembly can be nested Conditional Assembly Directives e IF on page 198 e IFDEF on page 199 e IFSAME on page 199 e IFMA on page 200 IF Evaluates a Boolean expression If the expression evaluates to 0 the result is false otherwise the result is true Synonyms if IF IFN IFNZ COND IFTRUE IFNFALSE IFTRUE Syntax IF cond expression code body gt ELIF cond expression code body ELSE code body ENDIF Example IF XYZ process code body if XYZ is not O0 Code Body ENDIF IF XYZ 3 code body 1 if XYZ is not 3 Code Body 1 UMO17103
320. k Re Wadd aoe Eee 191 DIEU traia Rae ee 192 XREF piropo qii t 192 Structures and Unions in Assembly Code lsseleslelesess 192 Conditional Assembly o o ooooooooorrrrr ene 197 Conditional Assembly Directives ooo oooooooooooorrrrrrr eee 198 Macros pet C MTM 200 Macro Definition coded eoe ee deo RA I d ee eris 200 Concatenatlon Jo sueco See eme e ed aec eg E do a Ra aue 201 Macro Invoc tlon i ossleilesele4ree3he bre EREEREER PESE AV PEE 201 Local Macro Labels curia Bib 202 Optional Macro Arguments 0 ccc ehh 202 Exiting a Mato iR bee ee dbo dan dad abs 203 IJ Jer 203 Anonymous Labels 20 hh 204 Local Labels MP 204 Importing and Exporting Labels 2 0 00 cece eee eens 204 Label SPACES eee ete e dia 204 Source Language Syntax oooooooooor er 205 Warning and Error Messages ooooocococooor eee 208 Using the Linker Locator eeeeeeeeeeeeee rH Ih ntn 213 Linker Functions k Ren endian ecw be DEPETREBEPRCOIRI SE PESE E RE TEES 213 Invoking the Linket oi ee heim Se Y eate aue eR A aa 214 Linker Commands n nannu 00 eee hh 215 lt outputfile gt lt module liSt gt csse 216 CHANGE 44235 0905 o A 216 COPY csc chs ee GE RENE UPPER RP RO e OPER p MN qu eid ees 217 SA d ODE RHENO A TO 218 DEBINE 1 p RRRPOEY REPE rr peer bebes beau eed 218 FORMAT oo eR Jb padded Oe e da 219 GROUP sad Ei Ea 219 HEADING acid adas 219 UMO17103 0207 Table of C
321. k if you plan to make any calls to standard library functions and you do not plan to provide your own code for all library functions that plan to use Floating Point Library Check Step 1 Build options Would you like your project to be linked with any of the following v Standard C Startup Module iv C Runtime Library Iv Floating Point Library requires the C Runtime Library Select the appropriate memory model from the following list Small m Figure 35 New Project Wizard Dialog Box Build Options 10 Select whether your project is linked to the standard C startup module C run time library and floating point library select a small or large memory model see Memory Models on page 119 and click Next For executable projects the Target and Debug Tool Selection step Figure 36 of the New Project Wizard dialog box is displayed UM017103 0207 2 Using the Integrated Development Environment New Project Wizard Use Page Erase Before Flashing Select this option to configure the internal Flash of the target hardware to be page erased Deselect it to configure the internal Flash to ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Step 2 Target and Debug Tool Selection Use page erase before flashing Target 1z16F28001002C06 ZDS Default Z16F2811AL ZDS Default be mass erased Target A target is a logical representation of a target system Select the available target that best
322. k in Subfolders check box 47 LOW operator 176 LOW16 operator 176 LOWADDR operator 229 Ast file extension 170 M MACEXIT directive 203 Macro Assembler 167 adding null characters 175 arithmetic operators 176 binary numbers 177 Boolean operators 176 case sensitivity 55 173 character constants 178 character strings 175 command line options 299 decimal numbers 177 directives 181 error messages 208 expressions 175 generating listing file 1st 170 generating object file 170 hexadecimal numbers 177 numeric representation 175 octal numbers 177 operator precedence 178 relational operators 176 reserved words 173 running from the command line 298 setup 56 syntax 205 warning messages 208 MACRO directive 200 Macros 200 CONST IN ROM _ 127 _ DATE 127 _ FILE 127 LINE 127 _ MODEL _ 127 Index _STDC_ 127 TIME _ 127 _ UNSIGNED CHARS 127 _ ZDATE 127 ZILOG 127 ZNEO 127 character handling 340 concatenation character 201 diagnostics 340 empty arguments 126 error reporting 339 exiting 203 expanding 57 floating point 342 general utility 348 input output 347 invocation 201 labels 202 limits 341 mathematical 343 optional arguments 202 predefined 127 standard definitions 339 string handling 350 Make file exporting 88 makefile script file command 321 makfile script file command 321 malloc function 349 369 Manage Configurations dialog box 91 MAP command 220 map file extension 220 247 Mark A
323. kmark from the Edit menu Type Ctrl M UM017103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG int ch unid maini Paste World n Insert Breakpoint Edit Breakpoints 09 Reset Go getchar Run To Cursor er ch Insert Bookmark Next Boats ark Previous Bookmark Remove Bookmarks message to show any interrupts received Figure 25 Inserting a Bookmark To remove a bookmark position the cursor on the line of the active file containing the bookmark to be removed and perform one of the following actions Right click in the Edit window and select Remove Bookmark from the resulting context menu Select Toggle Bookmark from the Edit menu e Type Ctrl M To remove all bookmarks in the active file right click in the Edit window and select Remove Bookmarks from the resulting context menu To remove all bookmarks in the current project select Remove All Bookmarks from the Edit menu To position the cursor at the next bookmark in the active file perform one of the following actions Right click in the Edit window and select Next Bookmark from the resulting context menu e Select Next Bookmark from the Edit menu Press the F2 key 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG The cursor moves forward through the file starting at its current positio
324. kpoints dialog box to view go to enable disable or remove break points in an active project when in or out of Debug mode Breakpoints 001 C Program FilesvZiLOGXZDSIl ZNEO 4 10 1samplesxt Go to Code 002 C Program FilesxZziLOG zD5SlIl ZNEO 4 10 1 samples C 003 C Program Files ZiLOG ZDSII_ZNEO_4 10 1 samples Enable All Disable All Remove Remove All Figure 112 Viewing Breakpoints UMO17103 0207 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual 295 zZiLOG Moving to a Breakpoint To quickly move the cursor to a breakpoint you have previously set in your project do the following 1 Select Manage Breakpoints from the Edit menu The Breakpoints dialog box is displayed 2 Highlight the breakpoint you want 3 Click Go to Code Your cursor moves to the line where the breakpoint is set Enabling Breakpoints To make all breakpoints in a project active do the following 1 Select Manage Breakpoints from the Edit menu The Breakpoints dialog box is displayed 2 Click Enable All Check marks are displayed to the left of all enabled breakpoints 3 Click OK There are three ways to enable one breakpoint Double click on the white octagon to remove the breakpoint and then double click where the octagon was to enable the breakpoint Place your cursor in the line in the file where you want to activate a disabled breakpoint and click the Enable Disable Breakpoint button on the Bui
325. l Hex32 fplib Objects and Libraries page Floating Point Library drop down string real dummy list box or none iodata Address Spaces page SFRs and IO IOData field string address range in the format lt ow gt lt high gt linkconfig Commands page Use Existing button Select Linker string All Internal or Command File dialog box External Included linkctlfile Sets the linker command file path and name The value is string only used when createnew is set to 1 map Output page Generate Map File check box TRUE FALSE maxhexlen Output page Maximum Bytes per Hex File Line drop down integer 16 32 64 or list box 128 objlibmods Objects and Libraries page Additional Object Library string separate multiple Modules field modules names with commas of Output page Output File Name field string path and file name excluding file extension padhex Output page Fill Unused Hex File Bytes with OxFF check TRUE FALSE UMO17103 0207 box Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual 327 zZiLOG Table 18 Linker Options Continued Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values ram Address Spaces page Internal RAM RAM field string address range in the format lt low gt lt high gt relist Output page Show Absolute Addresses in Assembly check TRUE FAL
326. lculates x to the y double sqrt double x Finds square root of x The following additional power functions are provided float powf float x float y Calculates x to the y float sqrtf float x Finds square root of x Nearest Integer double ceil double x Finds integer ceiling of x double fabs double x Finds absolute value of x double floor double x Finds largest integer less than or equal to x double fmod double x double y Finds floating point remainder of x y The following additional nearest integer functions are provided float ceilf float x Finds integer ceiling of x float fabsf float x Finds absolute value of x float floorf float x Finds largest integer less than or equal to x float fmodf float x float y Finds floating point remainder of x y Nonlocal Jumps lt setjmp h gt The lt setjmp h gt header declares two functions and one type for bypassing the normal function call and return discipline Type jmp buf An array type suitable for holding the information needed to restore a calling environment Functions int setimp jmp buf env Saves a stack environment void longjmp jmp_ buf env int val Restores a saved stack environment Variable Arguments lt stdarg h gt The lt stdarg h gt header declares a type and a function and defines two macros for advancing through a list of arguments whose number and types are not known to the called function when it is translated UMO17103 0207 A
327. ld Type Executable Continue Finish Cancel Figure 2 New Project Dialog Box 11 Click Continue The New Project Wizard dialog box Figure 3 is displayed It allows you to modify the initial values for some of the project settings during the project creation process 1 Getting Started UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG New Project Wizard Step 1 Build options Standard C Startup Module Check to link the object file for Would you like your project to be linked with any of the the standard C startup module following into your application If you 3 MV Standard C Startup Module plan to provide your own da startup code uncheck the M C Runtime Library option Floating Point Library requires the C Runtime Library T R Select the appropriate memory model from the following list C Runtime Library Check if you plan to make any calls to Small standard library functions and you do not plan to provide your own code for all library functions that plan to use Floating Point Library Check aC Finish Cancel Figure 3 New Project Wizard Dialog Box Build Options Step 12 Accept the defaults by clicking Next The Target and Debug Tool Selection step Figure 4 of the New Project Wizard dialog box is displayed UMO17103 0207 1 Getting Started ZiLOG Developer Studio ll ZNEO User Manual zZiLOG New Project Wizard Step 2 Target and Debug T
328. ld or Debug toolbar Place your cursor in the line in the file where you want to activate a disabled breakpoint and select Enable Breakpoint from the context menu The white octagon becomes a red octagon to indicate that the breakpoint 1s enabled Disabling Breakpoints There are two ways to make all breakpoints in a project inactive Select Manage Breakpoints from the Edit menu to display the Breakpoints dialog box Click Disable All Disabled breakpoints are still listed in the Breakpoints dialog box Click OK e Click the Disable All Breakpoints button on the Debug toolbar 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 296 zZiLOG There are two ways to disable one breakpoint Place your cursor in the line in the file where you want to deactivate an active breakpoint and click the Enable Disable Breakpoint button on the Build or Debug toolbar Place your cursor in the line in the file where you want to deactivate an active breakpoint and select Disable Breakpoint from the context menu The red octagon becomes a white octagon to indicate that the breakpoint is disabled Removing Breakpoints There are two ways to delete all breakpoints in a project Select Manage Breakpoints from the Edit menu to display the Breakpoints dialog box Click Remove All and then click OK All breakpoints are removed from the Breakpoints dialog box and all project files Click the Remove All Break
329. le a corresponding file of assembler source code In this file which is a legal assembly file that the assembler will accept the C source code commented out is interleaved with the UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG generated assembly code and the compiler generated assembly directives This file is placed in the directory specified by the Intermediate Files Directory check box in the Gen eral page See Intermediate Files Directory on page 56 Generate Assembly Listing Files Ist When this check box is selected the compiler generates for each C source code file a cor responding assembly listing file In this file the C source code is displayed interleaved with the generated assembly code and the compiler generated assembly directives This file also displays the hexadecimal addresses and op codes of the generated machine code This file is placed in the directory specified by the Intermediate Files Directory field in the General page See Intermediate Files Directory on page 56 Project Settings Preprocessor Page NOTE For Assembly Only projects the Preprocessor page is not available Figure 51 shows the Preprocessor page Wi Project Settings Configuration Debug v Eh General Preproc ae Assembler Preprocessor Definitions ailc Sis Code Generation 21 BF2811AL Z1BF SERIES h Listing Files Standard Include P
330. lesNVZiLOGNZDSII ZNEO version where lt version gt might be 4 11 0 or 5 020 User Include Path The User Include Path field allows you to specify the series of paths for the compiler to use when searching for user include files User include files are those included with the tinclude file h in the compiler If more than one path is used the paths are sepa rated by semicolons The compiler first checks the current directory then the paths in the User Include Path field Project Settings Advanced Page NOTE For Assembly Only projects the Advanced page is not available Figure 52 shows the Advanced page UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Wi Project Settings Configuration Debug m 5e General Eh Assembler El c 3 Code Generation M Generate Printfs Inline 3 Listing Files Distinct Code Segment for Each Module E Preprocessor 3 Default Type of Char Unsigned y El Linker 5s Commands 2 Objects and Libraries h Address Spaces 3 Warnings 3 Output 3 Debugger Note Some items on this page are disabled due to the use of the Limit Optimizations for E asier Debugging option on the C gt Code Generation page Cancel Help Figure 52 Advanced Page of the Project Settings Dialog Box Use Register Variables Selecting this check box allows the compiler to allocate local variables in registers rather th
331. linked objects or a collection of programs gathered together in a group ID Identifier IE Interrupt Enable initialize To establish start up parameters typically involving clearing all of some part of the device s memory space instruction Command interface I F 1 In a system a shared boundary i e the boundary between two subsystems or two devices 2 A shared boundary between two functional units defined by specific attributes such as functional characteristics common physical interconnection characteristics and signal characteristics 3 A point of communication between two or more processes persons or other physical entities interleaving The transmission of pulses from two or more digital sources in time division sequence over a single path interrupt A suspension of a process such as the execution of a computer program caused by an event external to that process and performed in such a way that the process can be resumed The three types of interrupts include internal hardware external hardware and software 1 O Input Output In computers the part of the system that deals with interfacing to external devices for input or output such as keyboards or printers UMO017103 0207 Glossary ZiLOG Developer Studio ll ZNEO User Manual Z 403 IPR Interrupt Priority Register J JP Jump K K Thousands May indicate 1000 or 1024 to differentiate between decimal and binary values Abbreviation for the
332. ll button 46 Match Case check box 46 47 48 Match Whole Word Only check box 46 47 math h header 343 Mathematical functions 344 Mathematical macro 343 MAXBRANCH directive 300 MAXHEXLEN command 220 Maximum Bytes per Hex File Line drop down list box 80 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 423 ZiLOG MAXLENGTH command 221 MB_LEN_MAX 341 memchr function 351 370 mememp function 351 370 memcpy function 350 371 memmove function 350 371 Memory amount used by program 247 configuring 251 copy to ERAM program configuration 268 copy to RAM program configuration 272 default program configuration 258 defining holes 76 defining locations 168 download to ERAM program configuration 262 download to RAM program configuration 265 filling 284 layout 251 loading to file 286 physical memory layout 252 programmer s model 253 requirements xxiii saving to file 285 Memory management functions 349 Memory Model drop down list box 59 Memory models defining 59 large 119 small 119 Memory range syntax 76 Memory window 282 changing memory spaces 283 changing values 282 cyclic redundancy check 286 filling memory 284 finding addresses 283 loading to file 286 saving to file 285 viewing addresses 283 Index Memory Window button 25 memset function 351 371 Menu bar 34 Menus Build 89 Debug 92 Edit 44 File 35 Help 109 Project 51 shortcuts 110 Tools 94 View 50 Windows 109 Messages Output win
333. lled function 2 Place the first seven scalar parameters not structures or unions of the called function in registers RI R7 Push parameters beyond the seventh parameter and nonscalar parameters on the stack in reverse order the rightmost declared argument is pushed first and the leftmost is pushed last This places the leftmost argument on top of the stack when the function is called For a varargs function all parameters are pushed on the stack in reverse order 3 Then call the function The call instruction pushes the return address on the top of the stack 4 Onreturn from the called function caller pops the arguments off the stack or increment the stack pointer 5 Restore any of the registers RO R7 that were saved in step 1 When a byte or structure of an odd size is pushed on the stack only the byte or structure is pushed Future enhancements might introduce padding so that 16 or 32 bit objects are UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 129 zZiLOG located at an even offset from the frame pointer so avoid writing code that depends on the alignment of data If you are writing an assembly routine called out of C it 15 recom mended that you declare parameters as short rather than char so that offsets to parame ters are not changed by such an enhancement The called function performs the following tasks 1 Push the frame pointer onto the stack and allocate the lo
334. llowing are the existing menu shortcuts e File Menu Shortcuts on page 110 e Edit Menu Shortcuts on page 110 Project Menu Shortcuts on page 111 Build Menu Shortcuts on page 111 e Debug Menu Shortcuts on page 112 File Menu Shortcuts These are the shortcuts for the options on the File menu Option Shortcut Description New File Ctrl N To create a new file in the Edit window Open File Ctrl O To display the Open dialog box for you to find the appropriate file Save Ctrl S To save the file Save All Ctrl L To save all files in the project Print Ctrl P To print a file Edit Menu Shortcuts These are the shortcuts for the options on the Edit menu Option Shortcut Description Undo Ctrl Z To undo the last edit made to the active file Redo Ctrl Y To redo the last edit made to the active file Cut Ctrl X To delete selected text from a file and put it on the clipboard Copy Ctrl C To copy selected text from a file and put it on the clipboard Paste Ctrl V To paste the current contents of the clipboard into a file UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 111 zZiLOG Option Shortcut Description Delete Ctrl D To remove a file from the current project Select All Ctrl A To highlight all text in the active file Show Whitespaces Ctrl Shift 8 To display all whitespace characters
335. llows you to open the files for viewing and editing 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 36 zZiLOG Look in QuickStart Debug co Source Files of type Source Files c asm s src y Cancel Figure 32 Open Dialog Box Close File Select Close File from the File menu to close the selected file New Project To create a new project do the following 1 Select New Project from the File menu The New Project dialog box is displayed as shown in Figure 33 New Project Project Name C Program Files ZiLOG ZDSII_ZNEO_4 11 0 samples T utorial m Project Type Standard CPU Family Z16F_Series CPU Z16F2811AL M Build Type Executable Continue Finish Cancel Figure 33 New Project Dialog Box 2 Fromthe New Project dialog box click on the Browse button mI to navigate to the directory where you want to save your project UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG The Select Project Name dialog box is displayed as shown in Figure 34 Select Project Name Look in gt samples 3 er E3 E Assembly 3 QuickStart Tutorial File name Files of type Project Files zdsproi Cancel Figure 34 Select Project Name Dialog Box 3 Inthe File Name field type the name of your project
336. ly built code Each defined symbol must have a corresponding value lt name gt lt value gt Multiple symbols can be defined and must be separated by commas Generate Assembly Listing Files Ist When selected the Generate Assembly Listing Files 1st check box tells the assembler to create an assembly listing file for each assembly source code module This file displays the assembly code and directives as well as the hexadecimal addresses and op codes of the generated machine code The assembly listing files are saved in the directory specified by the Intermediate Files Directory field on the General page see Intermediate Files Directory on page 56 By default this check box is selected Expand Macros When selected the Expand Macros check box tells the assembler to expand macros in the assembly listing files Page Length When the assembler generates the listing files the Page Length field sets the maximum number of lines between page breaks The default is 56 Page Width When the assembler generates the listing files the Page Width field sets the maximum number of characters on a line The default is 80 the maximum width is 132 Project Settings Code Generation Page NOTE For Assembly Only projects the Code Generation page is not available 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual Y zZiLOG Figure 49 shows the Code Generation page Wi Project Settin
337. m cpu z8f64 test asm RUNNING THE LINKER FROM THE COMMAND LINE To run the linker from the command line 1 Open the make file in a text editor UMO17103 0207 Appendix A Running ZDS II from the Command Line ZiLOG Developer Studio ll ZNEO User Manual 299 zZiLOG 2 Ina Command Prompt window type the path to the linker and your linker file For example C NPROGRA 1NZiLOGNZDSII ZNEO 4 11 0 bin eZ81nk e ez8 rtl testfiles test test linkcmd ASSEMBLER COMMAND LINE OPTIONS Table 8 describes the assembler command line options NOTE If you use DOS use double quotation marks for the stdinc and usrinc commands for the C compiler For example stdinc C lez8linclude If you use cygwin use single quotation marks on both sides of a pair of braces for the stdinc and usrinc commands for the C compiler For example stdinc C Nez8Ninclude Table 8 Assembler Command Line Options Option Name Description cpu name Sets the CPU debug Generates debug information for the symbolic debugger The default setting is nodebug define name value Defines a symbol and sets it to the constant value For example define DEBUG 0 This option is equivalent to the C Zdefine statement The alternate syntax define myvar is the same as define myvar 1 FP Qn The ZNEO architecture allows you to specify which quad register is to be used as the frame pointer which is implicitly used in the LINK a
338. m counter resides at the next program statement or instruction unless a function was 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG entered in which case the program counter resides at the first statement or instruction in the function Step Over Select Step Over from the Debug menu to execute one statement or instruction from the current program counter without following execution into function calls When complete the program counter resides at the next program statement or instruction Step Out Select Step Out from the Debug menu to execute the remaining statements or instructions in the current function and returns to the statement or instruction following the call to the current function Set Next Instruction Select Set Next Instruction from the Debug menu to set the program counter to the line containing the cursor in the active file or the Disassembly window Tools Menu The Tools menu lets you set up the Flash Loader customize the appearance of the ZNEO developer s environment update your firmware and perform a cyclic redundancy check The Tools menu has the following options e Flash Loader on page 94 Firmware Upgrade on page 98 e Show CRC on page 98 Calculate File Checksum on page 99 Customize on page 100 e Options on page 103 Flash Loader Use the following procedure to program internal and external Flash
339. main TEXT ERAM Run time main TEXT is in ERAM space copy main TEXT EROM Load time main TEXT is in EROM space define low main copy copy base of main TEXT define low main base of main TEXT define len main length of main TEXT 3 The linker COPY directive only designates the load addresses and the run time addresses for the segment The actual copying of the segment needs to be performed by the startup code For example if you are using the small model copy and modify the C startup provided in the installation under src boot common startupexs asm rewriting the relevant section as follows Copy main TEXT into ERAM EA RO low main copy EA R1 low main LD R2 len main 1 JP mlabl mlab0 LD B R3 RO LD B R1 R3 mlabl DJNZ R2 mlab0 XREF low main copy EROM XREF len main ERAM XREF low main ERAM 4 Finally add your modified startup module to your project To do this you must select the Included in Project button in the Objects and Libraries page of the Project Settings dialog box see C Startup Module on page 72 and also add the modified source code file to your project using the Add Files command from the Project menu Assembly Program Setup The Assembly program setup for the Copy to ERAM Program Configuration is similar to the Default Program Configuration with some additional guidelines as described in this section Write all th
340. mand button 21 Stop Debugging button 23 stop script file command 329 strcat function 350 384 strchr function 351 385 strcmp function 351 385 strcpy function 350 386 strcspn function 351 386 String comparison 385 386 String conversion functions 348 355 390 392 Index String placement 122 lt string h gt header 350 String handling functions 350 strlen function 351 387 strncat function 350 387 strncmp function 351 387 strncpy function 350 388 strpbrk function 351 388 strrchr function 351 389 strspn function 351 389 strstr function 351 390 strtod function 349 390 strtof function 349 strtok function 351 391 strtol function 349 392 STRUCT directive 193 Structures in assembly 192 Symbols window 291 Symbols Window button 25 Symbols public 218 Syntax Coloring dialog box 106 System requirements xxiii T Tab Size field 105 TAG directive 194 tan function 344 393 tanf function 344 393 Tangent calculating 393 tanh function 345 393 tanhf function 345 393 Target area 82 Target Copy or Move dialog box 86 target copy script file command 330 target create script file command 330 Target File button 86 Target Flash Settings dialog box 84 target get script file command 330 target help script file command 330 Target list box 39 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 429 zZiLOG target list script file command 330 target options script file command 331 target sa
341. mands are used to specify where relocatable segments are to be located within their space Relocatable segments can be assigned to different physical memory locations without re assembling Address Spaces The assembler provides the address spaces listed in Table 8 which represent the memory regions of the ZNEO microcontroller Table 8 ZNEO Address Spaces Space ID Description ROM 16 bit addressable read only memory RAM 16 bit addressable read write memory EROM 32 bit addressable code memory ERAM 32 bit addressable extended memory IODATA 16 bit addressable IO data memory Code and data are allocated to these spaces by using segments attached to the space Segments Segments are used to represent regions of memory Only one segment is considered active at any time during the assembly process A segment must be defined before setting it as the current segment Every segment is associated with one and only one address space Predefined Segments For convenience the segments listed in Table 9 are predefined by the assembler UMO17103 0207 4 Using the Macro Assembler Table 9 Predefined Segments ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Segment ID Space Alignment Type Contents CODE EROM 2 bytes Relocatable Code EROM DATA EROM 1 byte Relocatable Constant data tables and strings EROM TEXT EROM 1 byte Relocatable Constant strings ROM DATA ROM 1 byte
342. match a pointer earlier returned by the calloc malloc or realloc func tion or if the space has been deallocated by a call to the free or realloc function the behavior is undefined If the space cannot be allocated the realloc function returns a null pointer and the object pointed to by ptr is unchanged If size is zero the realloc function returns a null pointer and if ptr is not a null pointer the object it points to is freed Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 378 Synopsis tinclude lt stdlib h gt void realloc void ptr size t size Returns Returns a pointer to the start lowest byte address of the possibly moved object Example char buf buf char malloc 40 sizeof char buf char realloc buf 80 sizeof char if buf NULL success else fail scanf Reads input from the stream pointed to by stdin under control of the string pointed to by format that specifies the admissible input sequences and how they are to be converted for assignment using subsequent arguments as pointers to the object to receive the converted input If there are insufficient arguments for the format the behavior is undefined If the format is exhausted while arguments remain the excess arguments are evaluated but otherwise ignored The format is composed of zero or more directives from the following list one or more white space characters e an ordi
343. me library 133 337 warning messages 152 writing C programs 113 arc cosine computing 352 arc sine computing 353 arc tangent computing 354 Argument location 131 variable 346 Arithmetic operators in assembly 176 Index Array function 357 ASCII values viewing 289 ASCIZ values viewing 289 asctime function 127 asin function 344 353 asinf function 344 353 asm statement 124 Assembler 167 adding null characters 175 arithmetic operators 176 binary numbers 177 Boolean operators 176 case sensitivity 55 173 character constants 178 character strings 175 command line options 299 decimal numbers 177 directives 181 error messages 208 expressions 175 generating listing file 1st 170 generating object file 170 hexadecimal numbers 177 numeric representation 175 octal numbers 177 operator precedence 178 options 324 relational operators 176 reserved words 173 running from the command line 298 setup 56 syntax 205 warning messages 208 Assembler page 10 56 Assembly language adding null characters 175 argument location 131 arithmetic operators 176 backslash 172 binary numbers 177 blank lines 172 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 409 ZiLOG Boolean operators 176 calling C functions from 132 calling from C 131 case sensitivity 173 character constants 178 character strings 175 comments 172 conditional 197 decimal numbers 177 directives 173 181 expressions 175 function names 131 hex
344. me of a segment for example strseg to another segment name for example codeseg use the following command CHANGE strseg codeseg UMO017103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual 217 ziLoc To move a segment for example codeseg to a different address space for example RAM use the following command CHANGE codeseg RAM To not allocate a segment for example dataseg use the following command CHANGE dataseg NULL COPY The COPY command is used to make a copy of a segment into a specified address space This is most often used to make a copy of initialized RAM in ROM so that it can be initial ized at run time Syntax COPY lt segment gt lt name gt at lt expression gt segment can only be a segment lt name gt can only be an address space Examples To make a copy of a code segment in ROM use the following procedure 1 Inthe assembly code define a code segment for example codeseg to be a segment located in RAM This is the run time location of codeseg 2 Use the following linker command COPY codeseg ROM The linker places the actual contents associated with codeseg in ROM the load time location and associates RAM the run time location addresses with labels in codeseg NOTE You need to copy the codeseg contents from ROM to RAM at run time as part of the startup routine You can use the COPY BASE OF and COPY TOP OF linker expressions to g
345. ment is a pointer to the initial character of an array large enough to accept the sequence and a terminating null character which is added automatically UM017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 381 zZiLOG Matches a sequence of expected characters the scanset The corresponding argument is a pointer to the initial character of an array large enough to accept the sequence and a terminating null character which is added automatically The conversion character includes all subsequent characters is the format string up to and including the matching right bracket The characters between the brackets the scanlist comprise the scanset unless the character after the left bracket is a circumflex in which case the scanset contains all characters that do not appear in the scanlist between the circumflex and the right bracket As a special case if the conversion character begins with or the right bracket character is in the scanlist and next right bracket character is the matching right bracket that ends the specification If a character is in the scanlist and is neither the first nor the last character the behavior is indeterminate c Matches a sequence of characters of the number specified by the field width 1 if no field width is present in the directive The corresponding argument is a pointer to the initial character of an array large enough to accept the sequenc
346. ments on page 167 e Output Files on page 170 e Source Language Structure on page 172 e Expressions on page 175 Directives on page 181 Conditional Assembly on page 197 Macros on page 200 e Labels on page 203 Source Language Syntax on page 205 e Warning and Error Messages on page 208 For more information about ZNEO CPU instructions see the Instruction Set Description section in the ZNEO CPU User Manual UMO188 ADDRESS SPACES AND SEGMENTS The ZNEO architecture divides the entire memory into various memory regions These memory regions are depicted by address spaces in the assembler Each address space can have various segments associated with it A segment is a contiguous set of memory loca tions within an address space The segments can be predefined by the assembler or user defined 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 168 zZiLOG Allocating Processor Memory All memory locations whether data or code must be defined within a segment There are two types of segments Absolute segments An absolute segment is any segment with a fixed origin The origin of a segment can be defined with the ORG directive All data and code in an absolute segment is located at the specified physical memory address e Relocatable segments A relocatable segment is a segment without a specified origin At link time linker com
347. merWarningMessage sprintf timerWarningMessage reset time e The functions vprintf and vsprintf cannot be used even if the format string is a string literal If the Generate Printfs Inline check box is selected and these conditions are not met the compiler warns you that the code size cannot be reduced In this case the compiler gener ates correct code and the execution is significantly faster than with normal printf calls However there is a net increase in code size because the generated inline calls to lower level functions require more space with no compensating savings from removing the top level functions In addition an application that makes over 100 separate calls of printf or sprintf might result in larger code size with the Generate Printfs Inline check box selected because of the cumulative effect of all the inline calls The compiler cannot warn about this situation If in doubt simply compile the application both ways and compare the resulting code sizes The Generate Printfs Inline check box is selected by default Distinct Code Segment for Each Module For most applications the code segment for each module compiled by the ZNEO compiler is named CODE Later in the linker step of the build process the linker gathers all these small CODE segments into a single large CODE segment and then places that segment in the appropriate address space thus ensuring that all the executable code is kept in a single con
348. n or in a few cases a few closely related functions in each module Although the C run time library contains a very large number of functions from the C standard library if your application only calls two of those functions then only those two are linked into your application plus any functions that are called by those two functions in turn This means it is safe for you to simply link in a large library like chelpLD lib crtLD lib and fpLD 1ib in this example You do not have to worry about any 3 Using the ANSI C Compiler UMO17103 0207 149 150 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG unnecessary code being linked in and do not have to do the extra work of painstakingly finding the unresolved symbols for yourself and linking only to those specific functions See Use Default Libraries on page 73 for a further discussion of this area ANSI STANDARD COMPLIANCE The ZiLOG ZNEO C Compiler is a freestanding ANSI C compiler complying with the 1989 ISO standard which is also known as ANSI Standard X3 159 1989 with some devi ations which are described in Deviations from ANSI C on page 150 Freestanding Implementation A freestanding implementation of the C language is a concept defined in the ANSI stan dard itself to accommodate the needs of embedded applications that cannot be expected to provide all the services of the typical desktop execution environment which is called a hosted environment in the
349. n Debug mode when the button is clicked a debug session is started Insert Remove Breakpoint Button The Insert Remove Breakpoint button sets a new breakpoint or removes an existing break point in the active file at the line where the cursor is You can set a breakpoint in any line with a blue dot displayed to the left of the line shown in Debug mode only Enable Disable Breakpoint Button The Enable Disable Breakpoint button activates or deactivates an existing breakpoint at the line where the cursor is A red octagon indicates an enabled breakpoint a white octa gon indicates a disabled breakpoint Remove All Breakpoints Button The Remove All Breakpoints button deletes all breakpoints in the currently loaded project Find Toolbar The Find toolbar Figure 17 provides access to text search functions with the following controls e Find in Files Button on page 20 e Find Field on page 21 a Figure 17 Find Toolbar Find in Files Button This button opens the Find in Files dialog box allowing you to search for text in multiple files UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 21 zZiLOG Find Field To locate text in the active file type the text in the Find field and press the Enter key The search term is highlighted in the file To search again press the Enter key again Command Processor Toolbar The Command Processor toolbar Figure 18
350. n and beginning again when the end of file is reached until a bookmark is encountered If no bookmarks are set in the active file this function has no effect To position the cursor at the previous bookmark in the active file perform one of the fol lowing actions Right click in the Edit window and select Previous Bookmark from the resulting context menu Select Previous Bookmark from the Edit menu e Type Shift F2 The cursor moves backwards through the file starting at its current position and starting again at the end of the file when the file beginning is reached until a bookmark is encountered If no bookmarks are set in the active file this function has no effect Output Windows The Output windows display output errors and other feedback from various components of the Integrated Development Environment Select one of the tabs at the bottom of the Output window to select one of the Output win dows e Build Output Window on page 32 e Debug Output Window on page 33 e Find in Files Output Windows on page 33 e Messages Output Window on page 34 Command Output Window on page 34 To dock the Output window with another window click and hold the window s grip bar and then move the window Double click on the window s grip bar to cause it to become a floating window Double click on the floating window s title bar to change it to a dockable window Use the context menu to copy text from or to d
351. n only be defined once The maximum label length is 129 characters See Labels on page 203 for more information Labels that can be interpreted as hexadecimal numbers are not allowed For example ADH ABEFH cannot be used as labels See Labels on page 203 and Hexadecimal Numbers on page 177 for more informa tion UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 173 zZiLOG Instruction An instruction contains one valid assembler instruction that consists of a mnemonic and its arguments When an instruction is in the first column it is treated as a instruction and not a label Use commas to separate the operands Use a semicolon or carriage return to termi nate the instruction For more information about ZNEO CPU instructions see the Instruction Set Description section in the ZVEO CPU User Manual UMO188 Directive A directive tells the assembler to perform a specified task Use a semicolon or carriage return to terminate the directive Use spaces or tabs to separate the directive from its oper ands See Directives on page 181 for more information Case Sensitivity In the default mode the assembler treats all symbols as case sensitive Select the Ignore Case of Symbols check box of the General page in the Project Settings dialog box to have the assembler ignore the case of user defined identifiers see Ignore Case of Symbols on page 55 Assembler
352. nalog to Digital the conversion of an analog signal such as a waveform to a digital signal represented by binary data See ADC ADC Analog to Digital Converter a circuit that converts an analog signal to a digital bit stream See A D address space The physical or logical area of the target system s memory map The memory map could be physically partitioned into ROM to store code and RAM for data The memory can also be divided logically to form separate areas for code and data storage ALU See Arithmetic Logical Unit American National Standards Institute ANSI The U S standards organization that establishes procedures for the development and coordination of voluntary American National Standards analog From the word analogous meaning similar to The signal being transmitted can be represented in a way similar to the original signal For example a telephone signal can be seen on an oscilloscope as a sine wave similar to the voice signal being carried through the phone line analog signal A signal that exhibits a continuous nature rather than a pulsed or discrete nature AND A bitwise AND instruction ANSI American National Standards Institute application program interface API A formalized set of software calls and routines that can be referenced by an application program to access supporting network services architecture Of a computer the physical configuration logical structure formats protocols and operational
353. nary character not 96 e a conversion specification Each conversion specification is introduced by the character After the the following appear in sequence e An optional assignment suppressing character An optional decimal integer that specifies the maximum field width An optional h or L indicating the size of the receiving object The conversion characters d 1 n o and x can be preceded by h to indicate that the corresponding argument is a pointer to short_int rather than a pointer to int or by 1 to indicate that it is a pointer to long int Similarly the conversion character u can be preceded by h to indicate that the corresponding argument is a pointer to unsigned short int rather than a pointer to unsigned int or by to indicate that it is a pointer to unsigned long int Finally the conversion character e f and g can be preceded by 1 to indicate that the corresponding argument is a pointer to double rather than a pointer to float or by L to UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual L so zZiLOG indicate a pointer to long double If an h 1 or L appears with any other conversion character it is ignored e A character that specifies the type of conversion to be applied The valid conversion characters are described in the following paragraphs The scanf function executes each directive of the format in turn If a directive fails as detailed belo
354. ncat Appends no more than n characters of the string pointed to by s2 not including the termi nating null character to the end of the string pointed to by s1 The initial character of s2 overwrites the null character at the end of s1 A terminating null character is always appended to the result Synopsis finclude lt string h gt char strncat char sl const char s2 size t n Returns The value of s1 Example char ptr char strl 80 2 Production char str2 Languages ptr strncat strl str2 4 strncmp Compares no more than n characters from the string pointed to by s1 to the string pointed to by s2 Synopsis finclude string h int strncmp const char sl const char s2 size t n Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 388 Returns An integer greater than equal to or less than zero according as the string pointed to by s1 is greater than equal to or less than the string pointed to by s2 Example char s1 Production char s2 Programming int res res strncmp s1 s2 3 strncpy Copies not more than n characters from the string pointed to by s2 to the array pointed to by s1 If copying takes place between objects that overlap the behavior is undefined If the string pointed to by s2 is shorter than n characters null characters are appended to the copy in the array pointed to by s1 until n characters in all have been written
355. nd UNLNK instructions The assembler accepts FP as a quad register and the FP command line option and directive tell the assembler which quad register to use as the frame pointer genobj Generates an object file with the ob3 extension This is the default setting help Displays the assembler help screen igcase Suppresses case sensitivity of user defined symbols When this option is used the assembler converts all symbols to uppercase This is the default setting include path Allows the insertion of source code from another file into the current source file during assembly list Generates an output listing with the 1st extension This is the default setting listmac Expands macros in the output listing This is the default setting listoff Does not generate any output in list file until a directive in assembly file sets the listing as on Appendix A Running ZDS II from the Command Line UMO17103 0207 300 ZiLOG Developer Studio Il ZNEO User Manual Z ZiLOG Table 8 Assembler Command Line Options Continued Option Name Description MAXBRANCH lt expression gt The MAXBRANCH directive allows control over how large a branch the assembler generates in the jump translation phase especially when the label branched to is in a separate assembly unit so the assembler must assume the largest possible branch A possible use of the command line option is in an application expected to fit
356. nd Verify Verify Close V Erase Before Flashing Close Dialog when Complete ju Figure 71 Flash Loader Processor Dialog Box 000000 000000 5 Click on the Browse button L to navigate to the hex file to be flashed 6 Select the Flash targets in the Flash Options area NOTE The Flash Options displayed in the Flash Loader Processor dialog box depend on the CPU you selected in the General page of the Project Settings dialog box see Project Settings General Page on page 54 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 96 zZiLOG You must select at least one of the following check boxes in the Flash Options area before erasing or flashing a target Internal Flash The internal Flash memory configuration is defined in the CpuFlashDevice xml file The device is the currently selected microcontroller or microprocessor When the internal Flash is selected the address range is displayed in the Flash Configuration area with an INT extension External Flash If you select the External Flash check box select which Flash devices you want to program The Flash devices are defined in the FlashDevice xml file The device is the current external Flash device s memory arrangement When an external Flash device is selected the Flash Loader uses the address specified in the Flash Base field to begin searching for the selected Flash device The Flash L
357. nd special function registers SFRs External memory and memory mapped peripherals The internal memory and I O are always present in ZNEO devices and are located at spe cific address ranges in the unified address space External memory or I O is optional and its location in the address space is determined by the target hardware design To promote code efficiency the ZNEO CPU supports shorter 16 bit data addressing for the address ranges 00 0000H 00 7FFFHand FF 8000H FF FFFFH 32 bit addressing can also be used in these ranges The range 00 8000H FF 7FFFH requires 32 bit addresses Figure 87 on page 252 shows the typical address layout of memory types avail able in the ZNEO architecture 6 Configuring Memory for Your Program UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 252 Address Memory Type FF FFFFH Internal I O and SFRs FF E000H E External Memory or I O FF_C000H optional 16 Bit FF BFFFH Addressable Internal Random Access Memory Data FF BOOOR 4K RAM Part FF AFFFH FF 8000H J A FF 7FFFH External Memory or I O Not to Scale optional 01 0000H 00 FFFFH 00 8000H Internal Flash 00 7FFFH 64K Flash Part 16 Bit Addressable Data 00 0000H Internal Memory and I O Figure 87 Typical ZNEO Physical Memory Layout UMO17103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 253 zZiLOG ZNEO CPU based
358. ndition codes on the JP instruction Thus they cannot be used as macro arguments To avoid this and similar errors it is recommended that you avoid single character names Concatenation To facilitate unambiguous symbol substitution during macro expansion the concatenation character amp can be suffixed to symbol names The concatenation character is a syntactic device for delimiting symbol names that are points of substitution and is devoid of seman tic content The concatenation character therefore is discarded by the assembler when the character has delimited a symbol name For example val partl equ 55h val part2 equ 33h The assembly is value macro parl par2 DB parl amp amp par2 macend value val partl value val part2 The generated list file is A 9 value val partl 000000 55 A 9 DB val partl A 9 macend A 10 value val part2 000001 33 A T0 DB val part2 A 10 macend Macro Invocation A macro is invoked by specifying the macro name and following the name with the desired arguments Use commas to separate the arguments 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 202 zZiLOG Syntax lt macroname gt lt arg gt lt arg gt Example store R1 R2 R3 This macro invocation causes registers R1 and R2 to be added and the result stored in reg ister R3 Local Macro Labels Local macro labels allow labels to be used within multiple macro ex
359. ne directive is incorrect 016 Unterminated comment in preprocessor directive Within a comment an end of line was encountered 017 Unterminated quoted string Within a quoted string an end of line was encountered 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 154 zZiLOG 018 Escape sequence ASCII code too large to fit in char The binary value of an escape sequence requires more than 8 bits of storage 019 Character not within radix An integer constant was encountered with a character greater than the radix of the constant 020 More than four characters in string constant A string constant was encountered having more than four ASCII characters 021 End of file encountered before end of macro call The end of file is reached before right parenthesis of macro call 022 Macro expansion caused line to be too long The line needs to be shortened 023 E cannot be first or last token in replacement string The macro definition cannot have operator in the beginning or end 024 must be followed by an argument name In a macro definition operator must be followed by an argument 025 Illegal line directive syntax In line lt linenum gt directive lt inenum gt must be an integer after macro expansion 026 Cannot undefine macro name The syntax of the macro is incorrect 027 End of file found before endif directive tif directive was not terminat
360. ned _ flash_option0 T 0000 FLASHO flash option0 segment _ flash optionl T 0001 FLASH1 flash optionl segment _ flash option2 T 0002 FLASH2 flash option2 segment _ flash option3 T 0003 FLASH3 flash option3 segment _ PAAF INIT PARAM 00000000 User Defined _ PCAF INIT PARAM 00000000 User Defined PDAF INIT PARAM 0000FF00 User Defined _ PFAF INIT PARAM 000000FF User Defined _ PGAF INIT PARAM 000000FF User Defined PHAF INIT PARAM 00000300 User Defined _ PKAF INIT PARAM 0000000F User Defined _ ucase C 008000 ucase CODE _ VECTOR 04 T 0000 startupexs VECTORS 04 __ VECTOR 08 T 0000 vect08 VECTORS 08 _ VECTOR 0C T 000C vectOc VECTORS OC _ VECTOR 10 T 0000 vect10 VECTORS 10 _ VECTOR 14 T 0000 vect14 VECTORS 14 _ VECTOR 18 T 0000 Z16F2800100ZC0G VECTORS 18 VECTOR 1C T 0000 vectic VECTORS 1C _ VECTOR 20 T 0000 vect20 VECTORS 20 _ VECTOR 24 T 0000 vect24 VECTORS 24 VECTOR 28 T 0000 vect28 VECTORS 28 _ VECTOR 2C T 0000 vect2c VECTORS 2C VECTOR 30 T 0000 vect30 VECTORS 30 _ VECTOR 34 T 0000 vect34 __ VECTORS 34 VECTOR 38 T 0000 vect38 VECTORS 38 _ VECTOR 3C T 0000 vect3c VECTORS 3C __ VECTOR 40 T 0000 vect40 __ VECTORS 40 _ VECTOR 44 T 0000 vect44 VECTORS 44 __ VECTOR 48 T 0000 vect48 __ VECTORS 48 VECTOR 4C T 0000 vect4c VECTORS 4C _ VECTOR 50 T 0000 vect50 VECTORS 50 VECTOR 54 T 0000 vect54 VECTORS 54 _ VECTOR 58 T 0000 vect58 VECTORS 58 VECTOR 5C T 0000 vect5
361. new debug tool name gt E lt new debug tool name gt SOURCE lt existing E Z16F2811AL UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 316 7 zZiLOG debugtool create The debugtool create command creates a new debug tool with the given name and using the given communication type usb tcpip ethernet or simulator The fol lowing is the syntax ofthe debugtool create command debugtool create NAME lt debug tool name gt COMMTYPE lt comm type gt For example debugtool create NAME emulator2 COMMTYPE ethernet debugtool get The debugtool get command displays the current value for the given data item for the active debug tool Use the debugtool setup command to view available data items and current values The following is the syntax of the debugtool get command debugtool get data item For example debugtool get ipAddress debugtool help The debugtool help command displays all debugtool commands The following is the syntax of the debugtool help command debugtool help debugtool list The debugtool list command lists all available debug tools The syntax can take one of two forms debugtool list displays the names of all available debug tools debugtool list COMMTYPE lt type gt displays the names of all available debug tools using the given communications type usb tcpip ethernet or simulator For example debugtool list COM
362. ng Conventions on page 128 This section covers the following topics e Function Naming Convention on page 131 Argument Locations on page 131 Return Values on page 132 Preserving Registers on page 132 Function Naming Convention Assembly function names must be preceded by an _ underscore The compiler prefixes the function names with an underscore in the generated assembly For example a call to myfunc in Cis translated to a call to my unc in assembly generated by the compiler Argument Locations The assembly function assigns the location of the arguments following the C calling con ventions as described in Calling Conventions on page 128 For example if you are using the following C prototype void myfunc short arga long argb short argc char argd int arge int argf char argg long argh int argi The location of the arguments are as follows arga Rl argb R2 argc R3 argd R4 arge R5 argf R6 argg R7 The remaining arguments are on stack and their offsets from Stack Pointer SP R15 at the entry point of assembly function are as follows argh 4 SP argi 8 SP 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 132 zZiLOG The corresponding offsets from Frame Pointer FP R14 after a Link 0 instruction are as follows argh 8 FP argi 12 FP Return Values The assembly function returns the value in the location as spe
363. ng calls for and the inline generation of printf calls is requested For example printf x 4dMn 254 Too many parameters for s printf format This warning is generated when there are more parameters to a call to printf or sprintf than the format string calls for and the inline generation of printf calls is requested For example printf x 34d n x y The format string is parsed and the extra arguments are ignored 255 Missing declaration of s printf helper function variable or field This warning is generated when the compiler has not seen the prototypes for the printf or sprintf helper functions it generates calls to This occurs if the standard include file stdio h has not been included or if stdio h from a different release of ZDS II has been included 256 Can t preprocess calls to vprintf or vsprintf This message is generated when the code contains calls to vprintf or vsprintf and the inline generation of printf calls is requested The reason for this warning and the solutions are similar to the ones for message 201 Can t preprocess format to s printf 257 Not all paths through lt name gt return a value The function declared with a return type is not returning any value at least on one path in the function 3 Using the ANSI C Compiler UMO17103 0207 165 ZiLOG Developer Studio Il ZNEO User Manual 166 zZiLOG Code Generator Warning and Error Messages 303 Case value lt number gt already
364. ng constant Synonym title Syntax title directive gt TITLE lt string_const gt Example TITLE My Title VAR The VAR directive works just like an EQU directive except you are allowed to change the value of the label In the following example STRVAR is assigned three different values This would cause an error if EQU was used instead of VAR Synonym VAR SET SET Syntax lt label gt VAR lt expression gt Example A 6 SEGMENT NEAR DATA UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 191 zZiLOG A 7 ALIGN 2 000000FF A 8 STRVAR VAR FFH 000000 FF A 9 DB STRVAR A 10 SEGMENT ROM TEXT 000000 A 11 L 0 000000 4641494C 4544 A 12 DB FAILED 000006 00 A 13 DB 0 A 14 SEGMENT NEAR DATA A 15 ALIGN 2 00000000 A 16 STRVAR VAR L 0 A 17 000002 A 18 _ fail str 000002 00 A 19 DB STRVAR A 20 SEGMENT ROM TEXT 000007 A 21 E 1 000007 50415353 4544 A 22 DB PASSED 00000D 00 A 23 DB 0 00000007 A 24 STRVAR VAR L 1 A 25 SEGMENT NEAR DATA A 26 ALIGN 2 000004 A 21 pass str 000004 07 A 28 DB STRVAR VECTOR Initializes an interrupt or reset vector to a program address The CPU directive is used to determine the physical location of the interrupt vectors Syntax yector directive gt VECTOR lt vector name gt expression vector name gt specifies be one of th
365. ns the location of address spaces segments and symbols The default is to create a link map file NOMAP suppresses the generation of a link map file For the ZNEO link map file the C prefix indicates EROM the T prefix indicates ROM the E prefix indicates ERAM and the R prefix indicates RAM Syntax MAP lt mapfile gt mapfile has the same name as the executable file with the map extension unless an optional lt mapfile gt is specified Example MAP myfile map Link Map File A sample map file is shown in the Sample Linker Map File on page 232 MAXHEXLEN The MAXHEXLEN command causes the linker to fix the maximum data record size for the Intel hex output The default is 64 bytes UMO17103 0207 5 Using the Linker Locator Zi Syntax MAXH EXL EN lt IS gt lt 16 32 64 128 Examples maxhexlen 16 or MAXH EXL EN IS 16 MAXLENGTH The MAXI space or segment is longer than the specified size The RANGI boundaries The MAXLI Syntax MAXLI ENGTH lt name gt lt expression gt lt name gt can be a group address space or segment lt expression gt is the maximum size Example MAXLENGTH CODI E SFF LOG Developer Studio ll ZNEO User Manual Z 221 ZiLOG 255 gt ENGTH command causes a warning message to be issued if a group address E command sets address ENGTH command allows further control of
366. nsic void DI void intrinsic void RI unsigned short istat Enable interrupts Disable interrupts Restores interrupts intrinsic void SET VECTOR int vectnum void hndlr void Specifies the address of an interrupt handler for an interrupt intrinsic unsigned short TDI void vector Nonstandard I O Functions lt sio h gt Tests and disables interrupts This header contains nonstandard ZNEO specific input output functions _DEFFREQ Expands to unsigned long default frequency _DEFBAUD Expands to unsigned long default baud rate _UARTO Expands to an integer indicating UARTO _UARTI Expands to an integer indicating UARTI 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 136 zZiLOG Functions char getch void Returns the data byte available in the selected UART int init_uart int port unsigned long freq unsigned long baud Initializes the selected UART for specified settings and returns the error status int kbhit void Checks for receive data available on selected UART int putch char Sends a character to the selected UART and returns the error status int select port int port Selects the UART Default is UARTO ZiLOG Functions The following functions are ZiLOG specific e DI on page 136 e EP on page 137 e getch on page 137 e init uart on page 137 e kbhit on page 138 e putch on page 138 e RI on page 139
367. nt The View menu contains these options e Debug Windows on page 50 e Workspace on page 51 e Output on page 51 e Status Bar on page 51 Debug Windows When you are in Debug mode running the debugger you can select any of the Debug windows From the View menu select Debug Windows and then the appropriate Debug window UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG For more information on the Debug windows see Debug Windows on page 279 The Debug Windows submenu contains the following Registers Window on page 279 e Special Function Registers Window on page 280 e Clock Window on page 281 e Memory Window on page 282 e Watch Window on page 287 e Locals Window on page 290 e Call Stack Window on page 290 Symbols Window on page 291 Disassembly Window on page 291 Simulated UART Output Window on page 292 Workspace Select Workspace from the View menu to display or hide the Project Workspace window Output Select Output from the View menu to display or hide the Output windows Status Bar Select Status Bar from the View menu to display or hide the status bar which resides beneath the Build Output window Project Menu The Project menu allows you to add files to your project set configurations for your project and export a make file The Project menu contains
368. nt UMO17103 0207 78 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG NOTE UMO17103 0207 files and terminates with an error message immediately if the linker cannot resolve any undefined symbol By default this check box is selected because a completely valid exe cutable cannot be built when the program contains references to undefined external sym bols If this check box is deselected the linker proceeds with generating output files even if there are undefined symbols Selecting this check box displays any undefined external symbol warning as an error regardless of the state of the Show Warnings check box in the General page see Show Warnings on page 55 Warn on Segment Overlap This check box enables or disables warnings when overlap occurs while binding seg ments By default the check box is selected which is the recommended setting for ZNEO For some ZiLOG processors benign segment overlaps can occur but for the ZNEO an overlap condition usually indicates an error in project configuration that must be cor rected These errors in ZNEO can be caused either by user assembly code that erroneously assigns two or more segments to overlapping address ranges or by user code defining the same interrupt vector segment in two or more places Project Settings Output Page Figure 59 shows the Output page 2 Using the Integrated Development Environment Wi Project Settings ZiLOG Developer Studio ll ZNE
369. nu section 2 Using the Integrated Development Environment UMO17103 0207 16 ZiLOG Developer Studio ll ZNEO User Manual zZiLOG ZDS II ZNEO File Edit Yiew Project Build Debug Tools Window Help D ea s me x S aie Je mes LADA EE BG For Help press F1 OR READ Z Figure 14 ZNEO Integrated Development Environment IDE Window For a table of all the shortcuts used in the ZNEO developer s environment see Shortcut Keys on page 110 TOOLBARS The toolbars give you quick access to most features of the ZNEO developer s environ ment You can use these buttons to perform any task NOTE There are cue cards for the toolbars As you move the mouse pointer across the toolbars the main function of each button is displayed Also you can drag and move the toolbars to different areas on the screen These are the available toolbars e File Toolbar on page 17 e Build Toolbar on page 18 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Find Toolbar on page 20 e Command Processor Toolbar on page 21 Debug Toolbar on page 22 e Debug Windows Toolbar on page 24 NOTE For more information on debugging see the Using the Debugger chapter on page 251 File Toolbar The File toolbar Figure 15 allows you to perform basic functions with your files using the following buttons e
370. nual zZiLOG Trailing Comma in Enum A trailing comma in enum declarations is allowed This essentially allows a common syn tactic error that does no harm Thus a declaration such as enum color red green blue col is allowed note the extra comma after blue Empty Macro Arguments Preprocessor macros that take arguments are allowed to be invoked with one or more arguments empty as in this example define cat3 a b c ab c printf sin cat3 Hello World Empty arg Long Long Int Type The long long int type is allowed In the ZNEO C Compiler this type is treated as the same as 1ong which is allowed by the standard TYPE SIZES The type sizes for basic data types on the ZNEO C Compiler is as follows int 32 bits short int 16 bits char 8 bits long 32 bits float 32 bits double 32 bits The type sizes for the pointer data types on the ZNEO C Compiler is as follows _ Near pointer 16 bits Far pointer 32 bits Rom pointer 16 bits Erom pointer 32 bits AII data are aligned on a byte boundary Alignment of 16 or 32 bit objects on even boundaries is a possible future enhancement Avoid writing code that depends on how data are aligned UMO17103 0207 3 Using the ANSI C Compiler PREDEFINED MACROS ZiLOG Developer Studio ll ZNEO User Manual 127 zZiLOG The ZNEO C Compiler comes with the following standard predefined macro names _ DATE This macro expands to the current date
371. nverted A negative field width argument is taken as a flag followed by a positive field width A negative precision argument is taken as if it were missing NOTE For more specific information on the flag characters and conversion characters for the printf function see printf Flag Characters on page 374 Synopsis finclude lt stdio h gt int printf const char format Returns The number of characters transmitted or a negative value if an output error occurred Example int i 10 printf This is d i NOTE The UART needs to be initialized using the ZILOG init uart function See jnit uart on page 137 printf Flag Characters The result of the conversion is left justified within the field The result of a signed conversion always begins with a plus or a minus sign space Ifthe first character of a signed conversion is not a sign a space is added before the result If the space and flags both appear the space flag is ignored The result is to be converted to an alternate form For c d i s and u conversions the flag has no effect For o conversion it increases the precision to force the first digit of the result to be a zero For x or X conversion a nonzero result always contains a decimal point even if no digits follow the point normally a decimal point appears in the result of these conversions only if a digit follows it For g and G conversions trailing zeros are not removed from the result
372. nvironment Specifically ZILOG defines the ANSI required functions that do not depend on a file system For example printf and sprintf are supplied but not fprintf e lt stdlib h gt This header is ANSI compliant in the ZiLOG library except that the following functions of limited or no use in an embedded environment are not supplied strtoul _Exit atexit WARNING AND ERROR MESSAGES NOTE If you see an internal error message please report it to Technical Support at http support zilog com ZiLOG staff will use the information to diagnose or log the problem This section covers the following e Preprocessor Warning and Error Messages on page 152 e Front End Warning and Error Messages on page 155 Optimizer Warning and Error Messages on page 164 e Code Generator Warning and Error Messages on page 166 Preprocessor Warning and Error Messages 000 Illegal constant expression in directive A constant expression made up of constants and macros that evaluate to constants can be the only operands of an expression used in a preprocessor directive 001 Concatenation at end of file Ignored An attempt was made to concatenate lines with a backslash when the line is the last line of the file 002 Illegal token An unrecognizable token or non ASCII character was encountered 003 Illegal redefinition of macro lt name gt An attempt was made to redefine a macro and the tokens in the macro definition do
373. o ll ZNEO User Manual 291 zZiLOG Symbols Window Click the Symbols Window button to show or hide the Symbols window Figure 108 SPACE ROM VARIABLE flash option Z16F2800100ZC0G C IRQ2EN PWMTEN DisAbl startups asm IRQ2EN DMA EN Dis Abl startups asm PAFL AF2 NoAltFunc startups asm ZNEO PORTK startups asm 00000000 _ ZNEO PORTJ startups a m lt Figure 108 Symbols Window NOTE Close the Symbols window before running a command script The Symbols window displays the address for each symbol in the program Disassembly Window Click the Disassembly Window button to show or hide the Disassembly window Figure 110 Disassembly 9000 CP RO 30 00008028 E606 JP z 50034 ch getchar 00008024 F1000304 CALL 58636 0000802E 0370B004 LD B004 R0 putchar ich 00008032 03415004 LD R1 45004 00008036 F10002EE CALL 8616 Figure 109 Disassembly Window The Disassembly window displays the assembly code associated with the code shown in the Code window For each line in this window the address location the machine code the assembly instruction and its operands are displayed 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 292 zZiLOG When you right click in the Disassembly window the context menu allows you to do the following Copy text Go to the source code Insert edit enable disable or remove breakpoints For more information on breakpoints s
374. oader reads each page of memory from the FlashDevice xml file checking if the page is enabled by the chip select register settings It then queries the actual address to verify that the correct Flash device is found If the correct Flash device is found the page s range with an EXT extension and chip select register are displayed in the Flash Configuration area The external Flash device options are predefined Flash memory arrangements for specific Flash devices such as the Micron MT28F008B3 The Flash Loader uses the external Flash device option arrangements as a guide for erasing and loading the Intel hexadecimal file in the appropriate blocks of memory NOTE The Flash Loader is unable to identify erase or write to a page of Flash that is protected through hardware For example a target might have a write enable jumper to protect the boot block In this case the write enable jumper must be set before flashing the area of Flash The Flash Loader displays this page as disabled 7 To perform a cyclic redundancy check on the whole internal Flash memory click CRC 10 UMO17103 0207 The checksum is displayed in the Status area of the Flash Loader Processor dialog box In the Flash Base field type where you want the Flash programming to start The Flash base defines the start of external Flash In the Units drop down list box select the number of Flash devices to program For example if you have two devices stacked on top of ea
375. oca tion of local data nonstatic local and function parameters is decided by the compiler and is described in later sections Any storage specifier used on local and parameter data is ignored by the compiler The ZiLOG header file lt zneo h gt defines macros to permit the use of more familiar key words near far rom and erom The reason for not using these keywords directly is to avold conflict with C identifiers in a preexisting C program To avoid conflicts current ANSI recommendations are that keywords for vendor extensions to the C language begin with an underscore and capitol letter The data allocation for various storage class specifiers is shown in Figure 83 and described in the following sections e Near on page 116 e Rom on page 116 e Erom on page 116 e Far on page 117 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 116 zZiLOG Figure 83 ZNEO C Compiler Memory Layout _Near The variable with the Near storage specifier is allocated in the 16 bit addressable near RAM address space This space corresponds to the RAM assembler address space defined in the linker address space project settings These variables lie within the 16 bit address range 8000 BFFF which is the 32 bit range FF_8000 FF_BFFF For example Near int ni ni is placed in RAM address space NOTE Inthe ZNEO compiler the peripheral registers 16 bit address C
376. ode dedu p dre nds 329 SLED 1 rm 329 O LUUTTT 329 POUM o a ii GE E e A ED e Ai eo 329 jn Mv CTETUR 329 target CODY or eoet detur qb e e cie dia tbe bna Qr Cet dob ee odis 330 target Credito GRE AER ME A RR ARi ER E eS d rd 330 target get nio id ME RERHMRRRERUBRRRPERECM SERM 330 target help 2 ds roten pg HERE EORR apice tee ele p tactus 330 target list o oases A A E NE eed des 330 target Option nc idees o erede eae a deb sedem doi bbe e e dds 331 A O AEE RURSUS aoe RR RARE d d 331 larpet Seb i595 deg AA A aks 331 target setup iosccRe Em EET Xu A e RE RR E es EAE RR AUR 332 MA INR REOS 332 Walt DD sce TA eR RARE ERU SR Ep P EAE e 332 Running the Flash Loader from the Command Processor oooccococcocooo o 333 Displaying Flash Help lsslesseeeeeeeeee I 333 Setting Up Flash Options 0 cece I Ie 333 Executing Flash Commands 000 ccc cece teens 334 EXAMPLES a IE elas Riad wow wae SU patilla 334 Appendix CC Standard Library 0 ccc cece cee reece eee e cence ees 337 Standard Header Files 0 2 0 cece cece enn eens 338 Errors lt ermo h gt 2 0 0 0 eect teen nee eens 339 Standard Definitions lt stddef h gt 2 0 00 ketene nes 339 Diagnostics lt assert h gt 2 0 eect hes 340 Character Handling lt ctype h gt 0 0 cette tenes 340 Limits limits ir eere pe CROP share epee E ead 341 Floating Point lt floath gt 2 0 0 ccc eee een eens 342 Ma
377. odel Startupl obj C startup for large model Startupexks obj C startup small model with external interface setup for devices with Port K Startupexs obj C startup small model with external interface setup for devices without Port K Startupexkl obj C startup large model with external interface setup for devices with Port K Startupexl obj C startup large model with external interface setup for devices without Port K Fpdumy obj Floating point do nothing stubs Crtl lib C run time library for large model no debug information Crtld lib C run time library for large model with debug information Fpl lib Floating point library for large model no debug information Fpld lib Floating point library for large model with debug information Crts lib C run time library for small model no debug information Crtsd lib C run time library for small model with debug information Fps lib Floating point library for small model no debug information Fpsd lib Floating point library for small model with debug information Chelps lib C helper routines for small model no debug information Chelpsd lib C helper routines for small model with debug information Chelp1 lib C helper routines for large model no debug information Chelpld lib C helper routines for large model with debug information UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer S
378. og box Figure 65 is displayed NOTE Ifa Windows Security Alert is displayed with the following message Do you want to keep blocking this program click Unblock Setup Ethernet Smart Cable Communication Smart Cables Available IP Address Port No MAC Address Description 10 1 7 83 4040 00 90 23 00 06 32 Ethernet Smart Cable lt gt Broadcast Address 255 255 255 255 Refresh Smart Cable Selected IP Address 10 1 7 83 TCP Port 14040 DK Cancel ok Figure 65 Setup Ethernet Smart Cable Communication Dialog Box Click Refresh to search the network and update the list of available Ethernet Smart Cables The number in the Broadcast Address field is the destination address to which ZDS sends the scan message to determine which Ethernet Smart Cables are accessible The default value of 255 255 255 255 can be used if the Ethernet Smart Cable is connected to your local network Other values such as 192 168 1 255 or 192 168 1 50 can be used to direct or focus the search ZDS uses the default broadcast address if the Broadcast Address field is empty Select an Ethernet Smart Cable from the list of available Ethernet Smart Cables by checking the box next to the Smart Cable you want to use Alternately select the Ethernet Smart Cable by entering a known Ethernet Smart Cable IP address in the IP Address field Type the port number in the TCP Port field Click OK Ifyou select USBSmartCable and click
379. oject 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 28 zZiLOG system init printf Hello World n while 1 if kbhit System initializations Figure 23 Edit Window The Edit window supports the following shortcuts Function Shortcuts Undo Ctrl Z Redo Ctrl Y Cut Ctrl X Copy Ctrl C Paste Ctrl V Find Ctrl F Repeat the previous search F3 Go to Ctrl G Go to matching or Ctrl E Place your cursor at the right or left of an opening or closing brace and press Ctrl Ctrl E or Ctrl to move the cursor to the matching opening or closing brace This section covers the following topics Using the Context Menus on page 29 e Using Bookmarks on page 29 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Using the Context Menus There are two context menus in the Edit window depending on where you click When you right click in a file the context menu allows you to do the following depend ing on whether any text is selected or you are running in Debug mode Cut copy and paste text Go to the Disassembly window Show the program counter Insert edit enable disable or remove breakpoints Reset the debugger Stop debugging Start or continue running the program Go Run to the cursor Pause
380. ompliant with the ANSI C Standard The deviations from the ANSI Standard in these files are summa rized in Library Files Not Required for Freestanding Implementation on page 151 The standard header files provided with the compiler are listed in Table 19 and described in detail in Standard Header Files on page 338 The following sections describe the use and format of the standard portions of the run time libraries e Standard Header Files on page 338 e Standard Functions on page 351 Table 19 Standard Headers Header Description Page lt assert h gt Diagnostics page 340 lt ctype h gt Character handling functions page 340 lt errno h gt Error numbers page 339 lt float h gt Floating point limits page 342 lt limits h gt Integer limits page 341 math h Math functions page 343 lt setjmp h gt Nonlocal jump functions page 346 lt stdarg h gt Variable arguments functions page 346 stddef h Standard defines page 339 stdio h Standard input output functions page 347 stdlib h General utilities functions page 348 lt string h gt String handling functions page 350 Appendix C C Standard Library UMO17103 0207 338 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG NOTE The standard include header files are located in the following directory lt ZDS Installation Directory gt include std where ZDS Installation Directory is the directory
381. on scanf 2d 5f amp varl var2 scanf Conversion Characters d Matches an optionally signed decimal integer whose format is the same as expected for the subject sequence of the strtol function with the value 10 for the base argument The corresponding argument is a pointer to integer 1 Matches an optionally signed integer whose format is the same as expected for the subject sequence of the strtol function with the value 0 for the base argument The corresponding argument is a pointer to integer o Matches an optionally signed octal integer whose format is the same as expected for the subject sequence of the strtol function with the value 8 for the base argument The corresponding argument is a pointer to integer u Matches an unsigned decimal integer whose format is the same as expected for the subject sequence of the strtol function with the value 10 for the base argument The corresponding argument is a pointer to unsigned integer x Matches an optionally signed hexadecimal integer whose format is the same as expected for the subject sequence of the strtol function with the value of 16 for the base argument The corresponding argument is a pointer to integer efg Matches an optionally signed floating point number whose format is the same as expected for the subject string of the strtod function The corresponding argument is a pointer to floating s Matches a sequence of non white space characters The corresponding argu
382. onment UMO17103 0207 80 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG NOTE Sort Symbols By You can choose whether to have symbols in the link map file sorted by name or address Show Absolute Addresses in Assembly Listings When this check box is selected all assembly listing files that are generated in your build are adjusted to show the absolute addresses of the assembly code statements If this check box is deselected assembly listing files use relative addresses beginning at zero For this option to be applied to listing files generated from assembly source files the Gen erate Assembly Listing Files Ist check box in the Assembler page of the Project Settings dialog box must be selected For this option to be applied to listing files generated from C source files both the Gener ate Assembly Source Code and Generate Assembly Listing Files lst check boxes in the Listing Files page of the Project Settings dialog box must be selected Executable Formats These check boxes determine which object format is used when the linker generates an executable file The linker supports the following formats IEEE 695 10d and Intel Hex32 Records hex IEEE 695 is the default format for debugging Selecting Intel Hex32 Records generates a hex file in the Intel Hex32 format which is a backward com patible superset of the Intel Hex16 format You can also select both check boxes which produces executable files in
383. ons See Memory Models on page 119 for full details of the memory models Project Settings Listing Files Page For Assembly Only projects the Listing Files page is not available Figure 50 shows the Listing Files page 2 Using the Integrated Development Environment UMO17103 0207 59 ZiLOG Developer Studio Il ZNEO User Manual 60 zZiLOG Wi Project Settings Configuration Debug m Sii General Listing Hd Assembler E gt as Code saben Generate C Listing Files lis s TEM Sls Preprocessor Generate Assembly Source Code Se Advanced PUE E Linker Y Generate Assembly Listing Files Ist 5s Commands 2 Objects and Libraries Sil Address Spaces SS Warnings 3 Output de Debugger Cancel Help Figure 50 Listing Files Page of the Project Settings Dialog Box Generate C Listing Files lis When selected the Generate C Listing Files lis check box tells the compiler to create a listing file for each C source code file in your project All source lines are duplicated in this file as are any errors encountered by the compiler With Include Files When this check box is selected the compiler duplicates the contents of all files included using the include preprocessor directive in the compiler listing file This can be helpful if there are errors in included files Generate Assembly Source Code When this check box is selected the compiler generates for each C source code fi
384. ontents SORT univer SBP SRM SIE WARN obese kde or eee oe Rees Linker Expressions o ooooocoococoo o Examples ooooccccoccccnccoocoo T AG ise tema antes amp And A rure nde bb Ros BASE OF 2 2254 be HE HER COPY BASE 5 2 4x32 taa craris COPY TOP occu cere UR ERE ER RR DIVAS cur e e na FREEMEM 0 000 eae HIGHADDR 04 LENGTH cuarta bee a nae EN LOWADDE 2424454 xb EE ERO ote Multiply 0 20 2 0 ee eee Decimal Numeric Values Hexadecimal Numeric Values Oda caia lt lt Shift Left eec eode gt gt Shift Right ooo o o o ooo Subtract o ooooooooomooo o TOP OF unir aa Bitwise Exclusive Or NOD TET ddaues Sample Linker Map File Troubleshooting the Linker Table of Contents MAXLENGTH 00 NODEBUG eect Ree NOMAR sortir peta ZiLOG Developer Studio ll ZNEO User Manual zZiLOG UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual How do I speed up the linker 2 0 0 0 keene 247 How do I generate debug information without generating code 247 How much memory is my program using 0 eee eee eee 247 How do I create a hex file l una ccc ence ees 247 How do I determine the size of my actual hex code 0 000 00 ee 247 Warning and Error Messages 00 cece cette eens 248 6 Con
385. ool Selectio Use Page Erase Before 7 Flashing Select this option to Use page erase aa configure the internal Flash of Target the target hardware to be page erased Deselect it to 1z15F280010072C0G ZDS Default configure the internal Flash to Z1 z16F2811AL ZDS Default be mass erased Target A target is a logical representation of a target system Select the available target that best fits your target _Setup Bed _Copy Dee system or create your own r Debug Tool Click Setup to configure the Current Simulator y target as needed Refer to the User Manual for details on lt lt Back Net Finish Cancel Figure 4 New Project Wizard Dialog Box Target and Debug Tool Selection Step 13 Click Next to accept the defaults The Target Memory Configuration step Figure 5 of the New Project Wizard dialog box is displayed 1 Getting Started UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG New Project Wizard 3 Target Memory Configuration Linker Address Spaces Use the provided fields to define the Linker Address Spaces ranges of available memory on Ensure that the ranges below are valid for your target The t t t Thi ranges below were initialized based on the selected CPU insi dais pi ES E Constant Data ROM Intemal Ram RAM developer s environment to 000000 007FFF FFBODO FFBFFF inform you when your code or SFRs and IO IDData Program Space EROM
386. options are available Assembler Options on page 324 Compiler Options on page 324 Debugger Options on page 325 General Options on page 325 Librarian Options on page 325 e Linker Options on page 326 Appendix B Using the Command Processor UMO17103 0207 324 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Assembler Options Table 14 Assembler Options Description or Corresponding Option in Project Option Name Settings Dialog Box Acceptable Values define Assembler page Defines field string separate multiple defines with semicolons include Assembler page Includes field string separate multiple paths with semicolons list Assembler page Generate Assembler Listing Files TRUE FALSE Ist check box listmac Assembler page Expand Macros check box TRUE FALSE pagelen Assembler page Page Length field integer pagewidth Assembler page Page Width field integer quiet Toggles quiet assemble TRUE FALSE sdiopt Toggles Jump Optimization TRUE FALSE Compiler Options Table 15 Compiler Options Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values chartype Advanced page Default Type of Char drop down list box string unsigned or signed define Preprocessor page Preprocessor Definitions field string separate multiple defines with semicolons genprintf Advanced page Generate Assembl
387. or union the space specifier of the member is ignored For example struct _Near char num Warning Near space specifier is ignored _Near char ptr Correct ptr points to a char in Near memory ptr itself is stored in the memory space of structure Far Far mystruct All of mystruct is allocated in Far memory Pointer Conversions A pointer to a qualified space type can be converted to a different qualified space type as given in Table 2 Table 2 Pointer Conversion Source Destination unqualified const volatile Near Far Rom _Erom unqualified y W W y L v L const V V W V L V L volatile v W v v L v L Near S WS WS V X V X _Far V W W V V V L Rom S WS WS V X V X Erom v W W v v v v where vrepresents Valid e W represents Warning e Srepresents Valid in Small Model Error in Large Model e L represents Valid in Large Model Error in Small Model WS represents Warning in Small Model Error in Large Model e WL represents Warning in Large Model Error in Small Model e X represents Error UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 119 zZiLOG Memory Models The ZNEO C Compiler provides two memory models Small memory model In the small memory model global variables are allocated in RAM address space The address of these variables is 16 bits The locals and parameters are allocated on the stack which is located
388. orage This function is an intrinsic function and is inline expanded by default If the reduceopt compiler option is selected then this function is not inline expanded and is implemented as a regular function instead Synopsis include lt zneo h gt intrinsic unsigned short TDI void Example include lt zneo h gt 3 Using the ANSI C Compiler UMO17103 0207 142 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG void main void unsigned short istat istat TDI Test and Disable Interrupts Do Something RI istat Restore Interrupts STACK POINTER OVERFLOW The run time library for the ZNEO C Compiler manipulates the SPOV register to protect program and allocated data The default action is The SPOV register is initialized to the end of the initialized data segment So if the Stack Pointer is decremented below SPOV it results in the Stack overflow exception When malloc is called the SPOV register is increased to the highest address of allocated data malloc returns NULL if changing the SPOV results in an immediate stack overflow Calling free returns memory for possible use by malloc but does not return memory for possible use as stack that is the SPOV register is not updated However if you modify the SPOV register directly malloc leaves SPOV where you have put it and does not allocate data on the stack side of SPOV The run time library does not sup
389. ot otherwise qualified as either signed or unsigned at the compiler s discretion the compiler is only required to consistently apply the choice to all such variables So in the following declara tions signed char sc unsigned char uc char cc the signedness of cc is left to the compiler The Default Type of Char drop down list box allows you to make this decision The selection Signed or Unsigned is applied to all char variables whose signedness is not explicitly declared The default value for ZNEO is Unsigned Project Settings Librarian Page NOTE This page is available for Static Library projects only To configure the librarian use the following procedure 1 Select Settings from the Project menu The Project Settings dialog box is displayed 2 Click the Librarian page 3 Use the Output File Name field to specify where your static library file is saved Project Settings Commands Page Figure 56 shows the Commands page UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Wi Project Settings Configuration Debug 5i General Comme Eh Assembler fig c Sil Code Generation 3 Listing Files 3 Preprocessor Sis Advanced Additional Directives Fl Linker C Use Existing 2 Objects and Libraries Sil Address Spaces A Warnings Sak Output Debugger Always Generate From Settings Note Selecting the Use E
390. ototype is as shown in the preceding example int compare const void x const void y calloc Allocates space for an array of nmemb objects each of whose size is size The space is initialized to all bits zero Synopsis include lt stdlib h gt void calloc size t nmemb size t size Returns A pointer to the start lowest byte address of the allocated space If the space cannot be allocated or if nmemb or size is zero the calloc function returns a null pointer Example char buf buf char calloc 40 sizeof char if buf NULL success else fail ceil ceilf Computes the smallest integer not less than x Synopsis tinclude lt math h gt double ceil double x float ceilf float x Returns The smallest integer not less than x expressed as a double for ceil and expressed as a float for ceilf Example double y 1 45 double x x cell y Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 358 zZiLOG cos cosf Computes the cosine of x measured in radians A large magnitude argument can yield a result with little or no significance Synopsis tinclude lt math h gt double cos double x float cosf float x Returns The cosine value Example double y 1234 double x x COS y cosh coshf Computes the hyperbolic cosine of x A range error occurs if the magnitude of x is too large Synopsis
391. ou might also choose to change those spaces as your application evolves from the early stages of development closer to production The copying of initial values on the other hand is carried out by the startup code in your application Usually the startup code copies values from nonvolatile memory to a location in volatile memory where they are accessed in the main body of your program In addition to copying data that must have a specific value on program startup the startup code can also set otherwise uninitialized values to zero to conform with the C standard Unlike the downloading step the copying step continues to occur in your production code typically when the end user device is powered up or reset Default Program Configuration The default program configuration Figure 89 provided by ZNEO development tools can be used for production code as well as development It is designed to provide a general case that meets the needs of many users In this configuration your compiled or assembled program is all downloaded to the ROM or EROM functional address spaces The startup code which is provided in the form of both source code and the standard pre compiled C startup module is downloaded to ROM and the rest of the executable pro gram code is downloaded to EROM The ROM EROM data declared using the Rom or UMO17103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 259 zZiLOG _ E
392. our file and or project 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 112 zZiLOG Debug Menu Shortcuts These are the shortcuts for the options on the Debug menu Option Shortcut Description Stop Debugging Shift F5 To stop debugging of your program Reset Ctrl Shift F5 To reset the debugger Go FS To invoke the debugger go into Debug mode Run to Cursor Ctrl F10 To make the debugger run to the line containing the cursor Break Ctrl F5 To break the program execution Step Into F11 To execute the code one statement at a time Step Over F10 To step to the next statement regardless of whether the current statement is a call to another function Step Out Shift F11 To execute the remaining lines in the current function and return to execute the next statement in the caller function Set Next Instruction Shift F10 To set the next instruction at the current line UM017103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 113 zZiLOG 3 Using the ANSI C Compiler The ZNEO C Compiler is a conforming freestanding 1989 ANSI C implementation with some exceptions These exceptions are described in the ANSI Standard Compliance sec tion In accordance with the definition of a freestanding implementation the compiler accepts programs that confine the use of the features of the ANSI
393. our linker command file even though you have chosen to include your own nonstandard startup module in the project This option is usually helpful in getting your project properly configured and initialized because all C startup modules have to do most of the same tasks Formerly these linker commands had to be inserted manually when you were not using the standard startup UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG The standard startup commands define a number of linker symbols that are used in the standard startup module for initializing the C run time environment You do not have to refer to those symbols in your own startup module but many users will find it useful to do so especially since user customized startup modules are often derived from modifying the standard startup module There are also a few linker commands such as CHANGE COPY ORDER and GROUP that are used to configure your memory map See Linker Com mands on page 215 for a description of these commands This option is only available when the Included in Project button has been selected The default for newly created projects 1s that this check box if available 1s selected Use Default Libraries These controls determine whether the available default libraries that are shipped with ZiLOG Developer Studio II are to be linked with your application For ZNEO there is essentially one av
394. ow UMO017103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual D zs zZiLOG FLASH HELP The current Flash Loader command options are displayed in the Command Output window Flash Options NAUTO The Flash Loader does not automatically select the external Flash device Flash Options PBF Page erase is enabled instead of mass erase for internal and external Flash programming Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 336 zZiLOG UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual 337 zZiLOG Appendix C C Standard Library As described in Run Time Library on page 133 the ZNEO C Compiler provides a col lection of run time libraries The largest section of these libraries consists of an implemen tation of much of the C Standard Library The ZNEO C Compiler is a conforming freestanding 1989 ANSI C implementation with some exceptions In accordance with the definition of a freestanding implementation the compiler supports the required standard header files 10at h lt limits h gt lt stdarg h gt and lt stddef h gt It also supports additional standard header files and ZiLOG specific nonstandard header files The latter are described in Run Time Library on page 133 The standard header files and functions are with minor exceptions fully c
395. own list box 105 Fill Memory dialog box 284 Fill Unused Hex File Bytes with OxFF check box 80 FILLMEM script file command 320 Find button 47 Find dialog box 45 46 Find field 21 47 Find in Files 2 Output window 33 34 Find in Files button 20 Find in Files dialog box 46 47 Find in Files Output window 33 Find list box 47 Find Next button 46 48 Find toolbar 20 Find What field 46 48 Find What list box 46 48 Finding characters 385 388 389 Finding strings 390 Flash Base field 96 Flash Configuration area 96 Flash Loader running from the Command Processor 333 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 416 zZiLOG using the GUI 94 Flash Loader Processor dialog box 95 Flash memory setting Flash option bytes in C 125 Flash option bytes 125 135 Flash Options area 95 FLASH OPTIONI 125 FLASH OPTION2 125 FLASH OPTIONBITS 281 FlashDevice xml file 84 96 lt float h gt header 342 Floating Point Library drop down list box 73 floor function 346 360 floorf function 346 360 FLT_DIG 342 FLT MANT DIG 342 FLT MAX 342 FLT MAX 10 EXP 342 FLT MAX EXP 342 FLT MIN 342 FLT MIN 10 EXP 342 FLT MIN EXP 342 FLT RADIX 342 FLT ROUND 343 fmod function 346 360 fmodf function 346 360 Font dialog box 107 FORMAT command 219 free function 349 361 FREEMEM operator 229 frexp function 345 361 frexpf function 345 361 Function names in assembly 131 Functions abs 352 acos 352 acosf 352 asctime 127 asin 353 a
396. pansions without duplication When used within the body of a macro symbols preceded by two dollar signs are considered local to the scope of the macro and therefore are guaranteed to be unique The two dollars signs are replaced by an underscore followed by a macro invoca tion number Syntax lt label gt Example LJMP MACRO cc label JP cc lab JP label SSlab ENDMAC Optional Macro Arguments A macro can be defined to handle omitted arguments using the IFMA if macro argument conditional directive within the macro The conditional directive can be used to detect if an argument was supplied with the invocation Example MISSING ARG MACRO ARGO ARG1 ARG2 IFMA 2 LD ARGO ARG1 ELSE LD ARGO ARG2 ENDIF ENDMACRO MISSING ARG Invocation MISSING ARG R1 R2 missing second arg Result LD R1 R2 UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 203 zZiLOG NOTE IFMA refers to argument numbers that are one based that is the first argument is numbered one Exiting a Macro The MACEXIT directive 1s used to immediately exit a macro No further processing is per formed However the assembler checks for proper i then conditional directives A MACEXIT directive is normally used to terminate a recursive macro The following example is nate the macro Example RECURS MAC MACRO A ELSE RECUR DB AR ENDIF
397. per Studio Il ZNEO User Manual 390 zZiLOG strstr Locates the first occurrence of the string pointed to by s2 in the string pointed to by s1 Synopsis finclude lt string h gt char strstr const char sl const char s2 Returns A pointer to the located string or a null pointer if the string is not found Example char ptr char s1 Production Languages char s2 Lang ptr strstr s1 s2 strtod strtof Converts the string pointed to by nptr to double strtod or float strtof represen tation The function recognizes an optional leading sequence of white space characters as specified by the isspace function then an optional plus or minus sign then a sequence of digits optionally containing a decimal point then an optional letter e or E followed by an optionally signed integer then an optional floating suffix If an inappropriate character occurs before the first digit following the e or E the exponent is taken to be zero The first inappropriate character ends the conversion If endptr is not a null pointer a pointer to that character is stored in the object endptr points to if an inappropriate charac ter occurs before any digit the value of nptr is stored The sequence of characters from the first digit or the decimal point whichever occurs first to the character before the first inappropriate character is interpreted as a floating constant according to the rules of this section except that i
398. ply a handler for the stack overflow exception or any other exception If there is any possibility of your released application overflowing its stack you need to decide how to recover from the situation and write your own handler STARTUP FILES The startup or C run time initialization file is an assembly program that performs required start up functions and then calls main which is the C entry point The startup program performs the following C run time initializations Initialize the stack pointer and stack overflow register Initialize the external interface if enabled See the description of the Configure Target dialog box on page 82 Clear the Near and Far uninitialized variables to zero Set the initialized Near and Far variables to their initial value from Erom Allocate space for interrupt vectors Allocate space for the errno variable used by the C run time libraries Table 4 lists the startup files provided with the ZNEO C Compiler UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 143 zZiLOG Table 4 ZNEO Startup Files Name libNzilogNstartups obj Description C startup object file for small model src boot common startups asm C startup source file for small model lib zilog startupl obj C startup object file for large model src boot common startupl asm C startup source file for large model lib zilog startupexkl o
399. pment code It is somewhat similar to the Default Program Configuration the only difference being that aside from the startup code the rest of the executable pro gram is downloaded into EROM copied from EROM to ERAM by the startup code and then executed from ERAM The reason for choosing this configuration is that while inter nal Flash on ZNEO CPU based devices can be accessed quickly enough to keep up with the CPU that might not be true of external Flash If you have both external Flash as part of the EROM address range and external RAM as part of ERAM in your application and if the external RAM is faster than the external Flash the user program might execute faster on ERAM Therefore this configuration might be advantageous if you want to exe cute your program from external memory for example because your program is too large to fit into internal Flash but you do not want your execution speed to be limited by the access speed of external Flash memory UMO17103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual L ns ziLoc Address Range Space IODATA I O Access 16 Bit Addressable Data Contents Small Model Stack RAM Data Large Model Stack ERAM Data Code EROM Data Copy of Code Copy of ERAM Initializers Copy of RAM Initializers ROM Data 16 Bit Startup Code Addressable Vector Table Data Option Bytes Figure 92 Programmer s Model Copy to ERAM Program
400. point operations In that case selecting Dummy keeps your code size from bloating unnecessarily None If you can select None no floating point functions are linked to your application at all This can be a way of ensuring that your code does not inadvertently make any floating point calls because if it does and this option is selected you receive a warning message about an undefined symbol NOTE None of the libraries mentioned here are available for Assembly Only projects Project Settings Address Spaces Page Figure 57 shows the Address Spaces page UMO17103 0207 2 Using the Integrated Development Environment Wi Project Settings ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Configuration Debug hM h General ils Assembler 2 flc h Code Generation h Listing Files 3 Preprocessor SB Advanced Fig Linker Commands 2 Objects and Libraries SS Warnings 3 Output de Debugger art Constant Data ROM Internal Ram RAM 000000 007FFF FFBODO FFBFFF SFRs and IO IDData Program Space EROM FFCODO FFFFFF 008000 01 FFFF Extended RAM ERAM 800000 87FFFF Figure 57 Address Spaces Page of the Project Settings Dialog Box The memory range fields in the Address Spaces page allow you to inform ZDS II about the amount and location of memory and I O on your target system The appropriate set tings for these fields depend on the CPU selection and target system design ZDS II uses
401. points on page 295 Removing Breakpoints on page 296 Inserting Breakpoints There are three ways to place a breakpoint in your file Click on the line of code where you want to insert the breakpoint You can set a breakpoint in any line with a blue dot displayed to the left of the line shown in Debug mode only Click the Insert Remove Breakpoint button sth on the Build or Debug toolbar Click on the line where you want to add a breakpoint and select Insert Breakpoint from the context menu You can set a breakpoint in any line with a blue dot displayed to the left of the line shown in Debug mode only Double click in the gutter to the left of the line where you want to add a breakpoint You can set a breakpoint in any line with a blue dot displayed to the left of the line shown in Debug mode only A red octagon shows that you have set a breakpoint at that location see Figure 111 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 294 zZiLOG system init printf Hello World n while 1 if kbhit ch getchar putchar ch Figure 111 Setting a Breakpoint Viewing Breakpoints There are two ways to view breakpoints in your project Select Manage Breakpoints from the Edit menu to display the Breakpoints dialog box Figure 112 Select Edit Breakpoints from the context menu to display the Breakpoints dialog box You can use the Brea
402. points button on the Build or Debug toolbar There are four ways to delete a single breakpoint UMO17103 0207 Double click on the red octagon to remove the breakpoint Select Manage Breakpoints from the Edit menu to display the Breakpoints dialog box Click Remove and then click OK The breakpoint is removed from the Breakpoints dialog box and the file Place your cursor in the line in the file where there is a breakpoint and click the Insert Remove Breakpoint button on the Build or Debug toolbar Place your cursor in the line in the file where there is a breakpoint and select Remove Breakpoint from the context menu 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual 297 zZiLOG Appendix A Running ZDS II from the Com mand Line You can run ZDS II from the command line ZDS II generates a make file project Debug mak or project Release mak depending on the project configuration every time you build or rebuild a project For a project named test zdspro j set up in the Debug configuration ZDS II generates a make file named test Debug mak in the project directory You can use this make file to run your project from the command line This section covers the following topics Building a Project from the Command Line on page 297 Running the Compiler from the Command Line on page 298 Running the Assembler from the Command Line on page 298 Running the Linker from the Command Line on page 298
403. ppendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 347 zZiLOG A function can be called with a variable number of arguments of varying types Function Definitions parameter list contains one or more parameters The rightmost parameter plays a special role in the access mechanism and is designated parmN in this description Type va_list An array type suitable for holding information needed by the macro va_arg and the function va_end The called function declares a variable referred to as ap in this section having type va_list The variable ap can be passed as an argument to another function Variable Argument List Access Macros and Function The va_start and va_arg macros described in this section are implemented as macros not as real functions If undef is used to remove a macro definition and obtain access to a real function the behavior is undefined Functions void va_start va_list ap parmN Sets pointer to beginning of argument list type va arg va list ap type Retrieves argument from list void va end va list ap Resets pointer Input Output lt stdio h gt The lt stdio h gt header declares input and output functions Macro EOF Expands to a negative integral constant Returned by functions to indicate end of file Functions Formatted Input Output int printf const char format Writes formatted data to stdout int scanf const char format Reads formatted d
404. previously defined STRUCT or UNION or an ordinary label to which a structure has been attached using a TAG directive It can also be the name of an equate or label with no structure attached Within the WITH section the assembler attempts to prepend name to each identifier encountered and selects the UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual 197 zZiLOG modified name if the result matches a name created by the STRUCT UNION or TAG directives The WITH directives can be nested in which case the search is from the deepest level of nesting outward In the event that multiple names are found a warning is generated and the first such name is used If name is specified with the ENDWITH directive the name must match that used for the WITH directive The intent is to allow for code readability with some checking by the assembler For example the COMPUTE PAY routine below COMPUTE PAY Enter with pointer to an EMPLOYEE in R2 days in R1 Return with pay in RO R1 LD RO EMPLOYEE SALARY R2 MULT RRO RET could be written using the WITH directive as follows COMPUTE PAY Enter with pointer to an EMPLOYEE in R2 days in R1 Return with pay in RO R1 WITH EMPLOYEE LD RO SALARY R2 MULT RRO RET ENDWITH EMPLOYEE CONDITIONAL ASSEMBLY Cond
405. qsort 376 rand 377 realloc 377 RI 139 scanf 378 search 349 351 select port 139 SET VECTOR 140 setjmp 381 sin 382 sinf 382 sinh 382 sinhf 382 sorting 349 sprintf 383 sqrt 383 sqrtf 383 srand 384 sscanf 384 strcat 384 strchr 385 stremp 385 strcpy 386 strcspn 386 string conversion 348 strlen 387 strncat 387 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 418 zZiLOG strncmp 387 strncpy 388 strpbrk 388 strrchr 389 strspn 389 strstr 390 strtod 390 strtok 391 strtol 392 tan 393 tanf 393 tanh 393 tanhf 393 TDI 141 testing characters 363 364 365 366 tolower 393 toupper 394 trigonometric 344 va arg 394 va end 395 va start 396 vprintf 397 vsprintf 397 G General page 9 54 General tab Options dialog box 103 Generate Assembly Listing Files 1st check box 57 61 Generate Assembly Source Code check box 60 Generate C Listing Files lis check box 60 Generate Map File check box 79 Generate Printfs Inline check box 64 getch function 137 getchar function 348 362 gets function 348 362 Go button 20 23 Go To button 48 Go to Code button 49 295 Go to Line Number dialog box 48 Index go script file command 320 GPIO Port drop down list box 83 GROUP command 219 Groups 214 allocation order 223 linking sequence 222 locating 220 renaming 216 setting maximum size 221 setting ranges 222 H Headers 338 architecture specific functions 134 character
406. r M Search complete 0 occurrences found Build A Debug A Find in Files Find in Files 2 Messages Command 4 gt Figure 28 Find in Files Output Window 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual x Searching for getchar n Search complete 0 occurrences found Build A Debug A Find in Files A Find in Files 2 Messages Command 4 Figure 29 Find in Files 2 Output Window Messages Output Window The Messages Output window Figure 30 holds informational messages intended for the user The Messages Output window also displays the chip revision identifier always 0x0800 for ZNEO and the Smart Cable firmware version x Project loaded ei uilding project Simulator Debug configuration A uild completed Starting debug session project Simulator configuration Debug J Starting debug session project Simulator configuration Debug Find in Files 2 A Messages Command 4 Build A Debug A Find in Files Figure 30 Messages Output Window Command Output Window The Command Output window Figure 31 holds output from the execution of commands pisplays Debug Tool Commands Setting and Getting Debug Tool Values ebugTool Set lt value id lt value to set gt Find in Files 2 A Messages Set a Value Command 4 v lt
407. r example C NPROGRA 1NZiLOGNZDSII ZNEO 4 11 0 bin eZ8cc alias asm const RAM debug define z8f64 NOexpmac NOfplib intsrc intrinsic NOkeepasm NOkeeplst NOlist NOlistinc maxerrs 50 NOmodsect promote quiet NOstrict NOwatch optsize localopt localcse localfold localcopy peephole globalopt NOglobalcse NOglobalfold NOglobalcopy NOloopopt NOsdiopt NOjmpopt stdinc include C PROGRA 1 ZiLOG ZDSII_ZNEO 4 11 0 include usrinc include cpu z8f64 bitfieldsize 24 charsize 8 doublesize 32 floatsize 32 intsize 24 longsize 32 shortsize 16 asmsw cpu z8f64 test c NOTE If you use DOS use double quotation marks for the stdinc and usrinc commands for the C Compiler For example stdinc C ez8 include If you use cygwin use single quotation marks on both sides of a pair of braces for the stdinc and usrinc commands for the C Compiler For example stdine C ez8 include RUNNING THE ASSEMBLER FROM THE COMMAND LINE To run the assembler from the command line 1 Open the make file in a text editor 2 Copy the options in the AFLAGS section 3 Ina Command Prompt window type the path to the assembler the options from the AFLAGS section on a single line and without backslashes and your assembly file For example C NPROGRA 1NZiLOGNZDSII ZNEO 4 11 0 bin eZ8asm debug genobj NOigcase include include list NOlistmac name pagelen 56 pagewidth 80 quiet warn NOzmas
408. r Options Table 15 Compiler Options Table 16 General Options Table 17 Librarian Options Table 18 Linker Options Table 19 Standard Headers List of Tables ZiLOG Developer Studio ll ZNEO User Manual zZiLOG UMO17103 0207 xxi ZiLOG Developer Studio ll ZNEO User Manual zZiLOG UMO17103 0207 List of Tables ZiLOG Developer Studio ll ZNEO User Manual Z xxiii ZiLOG Preface This section covers the following topics e ZDS II System Requirements on page xxiii e ZiLOG Technical Support on page xxiv ZDS Il SYSTEM REQUIREMENTS To effectively use ZILOG Developer Studio II you need a basic understanding of the C and assembly languages the device architecture and Microsoft Windows NOTE The memory requirements might vary from system to system depending on the size of the assembly or C source files the amount of variable data and stack usage Very large or data intensive applications might cause an out of memory message on your system Supported Operating Systems Windows Vista NOTE The USB Smart Cable is not supported on 64 bit Windows Vista The Ethernet Smart Cable available separately in the Ethernet Smart Cable Accessory Kit is supported e Windows XP Professional e Windows 2000 SP4 Windows 98 SE Recommended Host System Configuration e Windows XP Professional Pentium III 500 MHz processor or higher e 128 MB RAM or more e 100 MB hard disk space includes application
409. r Studio ll ZNEO User Manual 13 zZiLOG 10 Make sure that the IEEE 695 and Intel Hex32 Records check boxes are both selected See Figure 12 Wi Project Settings Configuration Debug h General Eh Assembler Bl C ta h Code Generation h Listing Files 3 Preprocessor Sil Advanced fi Linker SS Commands 2 Objects and Libraries 3 Address Spaces h Warnings gt h Debugger Wc 1 155 s Dutput File Name c Program Files ZiLOG ZDSII_ZNEO_4 11 0 samples T utorial V Generate Map File Sort Symbols By Name Address Show Absolute Addresses in Assembly Listings Executable Formats IEEE 695 Intel Hex32 Records Fil Unused Hex File Bytes with OxFF Maximum Bytes per Hex File Line 64 Cael Figure 12 Output Page of the Project Settings Dialog Box 11 12 1 Getting Started Click OK to save all the settings on the Project Settings dialog box The Development Environment will prompt you to build the project when changes are made to the project settings that would effect the resulting build program The message is as follows The project settings have changed since the last build Would you like to rebuild the affected files Click Yes to build the project The developer s environment builds the sample project UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 14 zZiLOG 13 Watch the compilation process in the Build
410. r each chip select that is used by the target system for external memory or I O The settings appropriate for each chip select depend on the target system design Choose the chip select register CSO CS5 from the Chip Select Registers drop down list box UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 83 zZiLOG Select the Enabled check box to enable the chip select Do not enable chip selects that the target does not use To use ISA compatible mode select the ISA Mode Enabled check box To use Active High polarity select the Polarity Active High check box To use 16 bit data width select the 16 Bit Data Width check box Select the number of wait states from the Wait States drop down list box Select the number of post read wait states from the Post Read Wait States drop down list box Select the appropriate GPIO port from the GPIO Port drop down list box This list box is only available 1f the chip select is an alternate function on more than one GPIO port 3 Select the internal watchdog or external clock source in the Source area 4 Select the appropriate clock frequency in the Clock Frequency MHz area or enter the clock frequency in the Other field For the emulator this frequency must match the clock oscillator on Y4 For the development kit this frequency must match the clock oscillator on Y1 The emulator clock cannot
411. r hides the Output window Build Toolbar The Build toolbar Figure 16 allows you to build your project set breakpoints and select a project configuration with the following controls and buttons Select Build Configuration List Box on page 19 e Compile Assemble File Button on page 19 Build Button on page 19 Rebuild All Button on page 19 Stop Build Button on page 19 e Connect to Target Button on page 19 Download Code Button on page 19 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG e Reset Button on page 20 e Go Button on page 20 Insert Remove Breakpoint Button on page 20 Enable Disable Breakpoint Button on page 20 Remove AII Breakpoints Button on page 20 Debug 885 IL Figure 16 Build Toolbar Select Build Configuration List Box The Select Build Configuration drop down list box lets you activate the build configura tion for your project See Set Active Configuration on page 90 for more information Compile Assemble File Button The Compile Assemble File button compiles or assembles the active source file Build Button The Build button builds your project by compiling and or assembling any files that have changed since the last build and then links the project Rebuild All Button The Rebuild All button rebuilds all files and links the project Stop Buil
412. r toolbar type in one of the following command sequence to use the Flash Loader Displaying Flash Help Flash Setup Flash Help Setting Up Flash Options Flash Options lt File Name gt Flash Options OFFSET lt address gt Flash Options NAUTO Flash Options AUTO Flash Options INTMEM Flash Options EXTMEM Flash Options BOTHMEM Flash Options NEBF Flash Options EBF Flash Options NISN Flash Options ISN Flash Options NPBF Flash Options PBF Flash Options SERIALADDRESS lt address gt Flash Options SERIALNUMBER lt Number in Hex Flash Options SERIALSIZE 1 87 Flash Options INCREMENT lt Decimal value Appendix B Using the Command Processor Displays the Flash setup in the Command Output window Displays the Flash command format in the Command Output window File to be flashed Offset address in hex file Do not automatically select external Flash device Automatically select external Flash device Set to internal memory Set to external memory Set to both internal and external memory Do not erase before flash Erase before flash Do not include serial number Include a serial number Do not page erase Flash memory use mass erase Page erase Flash memory Serial number address Initial serial number value Number of bytes in serial number Increment value for serial number UMO17103 0207 334 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Executing Flash Commands Flash READ
413. racter arrays Various methods are used for deter mining the lengths of arrays but in all cases a char or void argument points to the initial lowest addressed character of the array If an array is written beyond the end of an object the behavior is undefined Type size t Unsigned integral type of the result of the sizeof operator Macro NULL Expands to a null pointer constant Functions Copying void memoepy void s1 const void s2 size tn Copies a specified number of characters from one buffer to another void memmove void sl const void s2 size tn Moves a specified number of characters gt from one buffer to another char strcpy char s1 const char s2 Copies one string to another char strncpy char s1 const char s2 size t n Copies n characters of one string to another Concatenation char strcat char s1 const char s2 Appends a string char strncat char s1 const char s2 size t n Appends n characters of string UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual L ss zZiLOG Comparison The sign of the value returned by the comparison functions is determined by the sign of the difference between the values of the first pair of characters that differ in the objects being compared int memcmp const void s1 const void s2 size t n Compares the first n characters int stremp const char s1 const char s2 Compares two strings int
414. range of represented values int log10 LDBL MIN and so on NOTE The limits for the double and long double data types are the same as that for the float data type for the ZNEO C Compiler Mathematics lt math h gt The math h header declares several mathematical functions and defines one macro The functions take double precision arguments and return double precision values Integer arithmetic functions and conversion functions are discussed later NOTE The double data type is implemented as float in the ZNEO C Compiler Macro HUGE VAL Expands to a positive double expression not necessarily represented as a float Treatment of Error Conditions The behavior of each of these functions is defined for all values of its arguments Each function must return as if it were a single operation without generating any externally vis Ible exceptions Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 344 zZiLOG For all functions a domain error occurs if an input argument to the function is outside the domain over which the function is defined On a domain error the function returns a spec ified value the integer expression errno acquires the value of the EDOM macro Similarly a range error occurs if the result of the function cannot be represented as a dou ble value If the result overflows the magnitude of the result is so large that it cannot be represented in an object of
415. re preceded by pragma interrupt or are associated with interrupt storage class are designated as interrupt handlers These functions should neither take parameters nor return a value The compiler stores the machine state at the beginning of these functions and restores the machine state at the end of these functions Also the com piler uses the iret instruction to return from these functions For example void interrupt isr timer0 void or pragma interrupt void isr timer0 void Interrupt Vector Setup The compiler provides an intrinsic function SET VECTOR for interrupt vector setup SET VECTOR can be used to specify the address of an interrupt handler for an interrupt vector Because the interrupt vectors of the ZNEO microcontroller are usually in ROM they cannot be modified at run time The SET VECTOR function works by switching to a special segment and placing the address of the interrupt handler in the vector table No executable code is generated for this statement The following is the SET VECTOR intrinsic function prototype intrinsic void SET VECTOR int vectnum void hndlr void An example of the use of SET VECTOR is as follows include lt zneo h gt extern void interrupt isr timer0 void void main void SET VECTOR TIMERO isr timer0 UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNE
416. ream in which case it is an input failure e Except in the case of a character the input item or in the case of a n directive the count of input characters is converted to a type appropriate to the conversion character If the input item is not a matching sequence the execution of the directive fails this condition is a matching failure Unless assignment suppression was indicated by a the result of the conversion is placed in the object pointed to by the first argument following the format argument that has not already received a conversion result If this object does not have an appropriate type or if the result of the conversion cannot be represented in the space provided the behavior is undefined NOTE See scanf Conversion Characters for valid input information Synopsis tinclude lt stdio h gt int scanf const char format Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 380 zZiLOG Returns The value of the macro EOF if an input failure occurs before any conversion Otherwise the scan function returns the number of input items assigned which can be fewer than provided for or even zero in the event of an early conflict between an input character and the format Examples int i scanf Sd amp i The following example reads in two values var1 is an unsigned char with two decimal digits and var2 is a float with three decimal place precisi
417. rectives dialog box see Additional Directives on page 68 change code RAM The linker will then allocate code segment in RAM To go back to the Default Program Configuration for production code remove this direc tive from the Additional Linker Directives dialog box Special Case Partial Download to RAM A special case of this configuration is when you want to download program code from just one assembly segment into RAM while retaining the rest of the code in EROM This allows you to experiment with different partitions of your code for instance if you are considering the Partial Copy to RAM Program Configuration discussed in Special Case Partial Copy to RAM on page 275 Do this by performing the following steps 1 Use a distinct segment name for the particular segment For example Define main TEXT space EROM segment main TEXT code goes here 2 Usethe linker CHANGE directive to move the particular segment to RAM For example to download the code for the main TEXT segment to RAM add the following linker command in the Additional Linker Directives dialog box see Additional Directives on page 68 change main TEXT RAM To go back to the Default Program Configuration for production code remove this directive from the Additional Linker Directives dialog box Copy to ERAM Program Configuration The Copy to ERAM Program Configuration Figure 92 can be used for production as well as develo
418. red 43 Recursive macro call Macro calls cannot be recursive 432 Recursive include file Include directives cannot be recursive 433 ORG to bad address The ORG clause specifies an invalid address for the segment 434 Symbol name too long The maximum symbol length 33 characters has been exceeded 435 Operand out of range error The assembler detects an expression operand that is out of range for the intended field and generates appropriate error messages 436 Relative branch to XREF label Do not use the JP instruction with XREF 437 Invalid array index A negative number or zero has been used for an array instance index You must use positive numbers UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual Z 211 zZiLOG 438 Label in improper space Instruction requires label argument to be located in certain address space The most common error is to have a code label when a data label is needed or vice versa 439 Vector not recognized The vector name is illegal 444 Too many initializers Initializers for array data allocation exceeds array element size 445 Missing endif at EOF There is no matching endif for the if directive 448 Segment stack overflow Do not allocate returned structures on the stack 461 Unexpected end of file in comment End of file encountered in a multi line comment 462 Macro redefinition The macro has been redefined 464 Obsolete featur
419. red The compar function returns an integer less than equal to or greater than zero if the first argu ment is considered to be respectively less than equal to or greater than the second If two members in the array compare as equal their order in the sorted array is unspeci fied Synopsis include lt stdlib h gt UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 377 zZiLOG void qsort void base size t nmemb size t size int compar const void const void rand Example int lst 5 8 2 9 int compare const void x qsort lst sizeof int 4 const void y compare int compare const void x const void y int a int x int b int y if a lt b return 1 if a b return 0 return 1 The compare function prototype is as shown in the preceding example int compare const void x const void y Computes a sequence of pseudorandom integers in the range 0 to RAND MAX Synopsis include lt stdlib h gt int rand void Returns A pseudorandom integer Example int a srand 1001 i rand realloc Changes the size of the object pointed to by ptr to the size specified by size The contents of the object are unchanged up to the lesser of the new and old sizes If ptr is a null pointer the realloc function behaves like the malloc function for the specified size Otherwise if ptr does not
420. ress Select whether to load the file as text hex hexadecimal or binary Click OK to load the file s contents into the selected memory Perform a Cyclic Redundancy Check Use the following procedure to perform a cyclic redundancy check CRC l 2 3 UMO17103 0207 Select the Memory space in the Space drop down list Right click in the Memory window list box to display the context menu Select Show CRC The Show CRC dialog box Figure 104 is displayed 7 Using the Debugger ZiLOG Developer Studio ll ZNEO User Manual 287 zZiLOG Start Address 1000 End Address 1FFFF CRC AEBA Close Figure 104 Show CRC Dialog Box 4 Enter the start address in the Start Address field The start address must be on a 4K boundary If the address is not on a 4K boundary ZDS II produces an error message 5 Enter the end address in the End Address field If the end address is not a 4K increment it is rounded up to a 4K increment 6 Click Read The checksum is displayed in the CRC field Watch Window Click the Watch Window button to show or hide the Watch window Figure 105 Expression Value Ticks 0x00000000 system_init 0x00008526 check_isr ox00008560 Figure 105 Watch Window The Watch window displays all the variables and their values defined using the WATCH command If the variable is not in scope the variable is not displayed The values in the Watch window change as the program executes
421. ress spaces refer to the individual product specification for your ZNEO CPU based device To use ZDS II a detailed understanding of chip selects is not needed It is only necessary to enable and configure the chip selects used by the target system and to add the actual external address ranges as implemented on the target to the Address Spaces page of the Project Settings dialog box see page 74 PROGRAMMER S MODEL OF ZNEO MEMORY Different address ranges in the 24 bit ZNEO CPU memory space are suited for different functions depending on whether the corresponding memory is volatile or nonvolatile whether it can be addressed using 16 or 32 bits and whether it is reserved or otherwise convenient for I O The following considerations affect the suitability of an address range for various memory functions e Volatile random access memory contents can be changed easily so it is used for storing variable data and can also contain program code downloaded temporarily or copied from nonvolatile memory e Nonvolatile memory is not easily changed but is also unaffected by power loss so it is used for storing constants variable initializers program code option bits and vectors Data in 16 bit addressable memory can be addressed with short pointers and instructions so using these spaces for data results in more compact code However 16 6 Configuring Memory for Your Program UMO17103 0207 254 ZiLOG Developer Studio Il ZNEO
422. ression Cancel Down v Wrap around search Figure 43 Replace Dialog Box 2 Enterthe text to search for in the Find What field or select a recent entry from the Find What drop down list box By default the currently selected text in a source file or the text where your cursor is located in a source file is displayed in the Find What field 3 Enter the replacement text in the Replace With field or select a recent entry from the Replace With drop down list box 4 Select the Match Case check box if you want the search to be case sensitive 5 Select the Regular Expression check box if you want to use regular expressions 6 Select the Wrap Around Search check box to continue the search past the end or beginning of the file until the current cursor position is reached 7 Select the direction of the search with the Up or Down button 8 Click Find Next to jump to the next occurrence of the search text click Replace to replace the highlighted text or click Replace All to automatically replace all instances of the search text Go to Line To position the cursor at a specific line in the active file select Go to Line from the Edit menu to display the Go to Line Number dialog box as shown in Figure 44 Go to Line Number E Figure 44 Go to Line Number Dialog Box Enter the desired line number in the edit field and click Go To UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio
423. ritten No argument is converted In no case does a nonexistent or small field width cause truncation of a field If the result of a conversion is wider than the field width the field is expanded to contain the conver sion result putchar Writes a character to the serial port Synopsis tinclude lt stdio h gt int putchar int c Appendix C C Standard Library UMO17103 0207 376 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG NOTE puts NOTE Returns The character written If a write error occurs putchar returns EOF Example int bz charc a i putchar c The UART needs to be initialized using the ZILOG init uart function See init uart on page 137 Writes the string pointed to by s to the serial port and appends a new line character to the output The terminating null character is not written Synopsis include lt stdio h gt int puts char s Returns EOF if an error occurs otherwise it is a non negative value Example int i char strp COMPASS i puts str The UART needs to be initialized using the ZILOG init uart function See jnit uart on page 137 qsort Sorts an array of nmemb objects the initial member of which is pointed to by any base The size of each object is specified by size The array is sorted in ascending order according to a comparison function pointed to by compar which is called with two arguments that point to the objects being compa
424. rocessor ZDS II System Requirements on page xxiii Create a New Project on page 2 New Project on page 36 Save Project on page 41 Find on page 45 Manage Breakpoints on page 49 Show Absolute Addresses in Assembly Listings on page 80 Fill Unused Hex File Bytes with OxFF on page 80 Manage Configurations on page 91 Firmware Upgrade on page 98 Options General Tab on page 103 Options Editor Tab on page 104 Edit Menu Shortcuts on page 110 Preprocessor Warning and Error Messages on page 152 Label Field on page 172 Instruction on page 173 ORG on page 188 Using Breakpoints on page 293 Building a Project from the Command Line on page 297 Sample Command Script File on page 311 bp on page 313 cancel all on page 314 cancel bp on page 314 and Running the Flash Loader from the Command Processor on page 333 Select All on page 45 Show Whitespaces on page 45 Find Again on page 46 Clean on page 89 Structures and Unions in Assembly Code on page 192 and Anonymous Labels on page 204 Warning and Error Messages on page 152 and Warning and Error Messages on page 248 Edit Window on page 27 UMO17103 0207 Settings dialog box Changed Select Active Configuration to Select Build Configuration Changed File Verify button to
425. rojects only Project Settings Debugger Page on page 81 available for Executable projects only The Project Settings dialog box provides various project configuration pages that can be accessed by selecting the page name in the pane on the left side of the dialog box There are several pages grouped together for the C Compiler and Linker that allow you to set up subsettings for that tool The pages for the C Compiler are Code Generation Listing Files Preprocessor and Advanced The pages for the Linker are Commands Objects and Libraries Address Spaces Warnings and Output NOTE If you change project settings that affect the build the following message is displayed when you click OK to exit the Project Settings dialog box The project settings have changed since the last build Would you like to rebuild the affected files Click Yes to save and then rebuild the project 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 54 zZiLOG Project Settings General Page From the Project Settings dialog box select the General page The options on the General page Figure 47 are described in this section E Project Settings Configuration Debug Hd Assembler 2 fl c Sls Code Generation 3 Listing Files h Preprocessor Eh Advanced fig Linker SS Commands h Objects and Libraries 3 Address Spaces 3 Warnings Eh Output Debugger CPU F
426. rom keywords in a C application or appropriate SEGMENT directives in an assembly application are downloaded into their respective address spaces The initialized values of all initialized RAM ERAM data are also downloaded into EROM The Flash option bytes and the vector table are downloaded into ROM at addresses appropriate for the specified device The startup module code is executed from ROM while the rest of the executable program code is executed from EROM The startup code sets up the external interface if required based on the target setup parameters see Setup on page 82 and copies the initial values of RAM ERAM data from EROM to their respective run time addresses in RAM ERAM Address Range Space Contents IODATA I O Access 16 Bit Addressable Data Small Model Stack RAM Data Large Model Stack ERAM Data Code EROM Data Copy of ERAM Initializers Copy of RAM Initializers ROM Data 16 Bit Startup Code Addressable Vector Table Data Option Bytes Figure 89 Programmer s Model Default Program Configuration 6 Configuring Memory for Your Program UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 260 zZiLOG NOTE Figure 89 and the other program configuration figures omit physical address and interface information to emphasize that once the address ranges have been defined in the project setup most memory locations can be expressed symbolically in terms of the functional space address range
427. rrectness by comparing executable file contents to target memory Stop Debugging Select Stop Debugging from the Debug menu to end the current debug session To stop program execution select the Break command Reset Select Reset from the Debug menu to reset the program counter to the beginning of the program If not in Debug mode a debug session is started By default and if possible the Reset command resets the program counter to symbol main If you deselect the Reset to Symbol main Where Applicable check box on the Debugger tab of the Options dialog box see page 107 the program counter resets to the first line of the program Go Select Go from the Debug menu to execute project code from the current program counter If not in Debug mode when the command is selected a debug session is started Run to Cursor Select Run to Cursor from the Debug menu to execute the program code from the current program counter to the line containing the cursor in the active file or the Disassembly window The cursor must be placed on a valid code line a C source line with a blue dot displayed in the gutter or any instruction line in the Disassembly window Break Select Break from the Debug menu to stop program execution at the current program counter Step Into Select Step Into from the Debug menu to execute one statement or instruction from the current program counter following execution into function calls When complete the pro gra
428. ry on Ensure that the ranges below are valid for your target The t t Thi ranges below were initialized based on the selected CPU npe seu uu Constant Data ROM Internal Ram RAM information allows the developer s environment to 000000 007FFF FFB000 FFBFFF inform you when your code or SFRs and IO IDData Program Space EROM data has grown beyond your FFCOOO FFFFFF 008000 01 FFFF system s capability and to Extended RAM ERAM automatically locate your code 800000 87FFFF or data All options can be modified later Project Settings Finish Cancel Figure 37 New Project Wizard Dialog Box Target Memory Configuration 16 Enter the memory ranges appropriate for the target CPU 17 Click Finish Open Project To open an existing project use the following procedure 1 Select Open Project from the File menu The Open Project dialog box is displayed as shown in Figure 38 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG Open Project Look in 3 Tutorial File name Files of type zos Il Project Files zdsproj Cancel Figure 38 Open Project Dialog Box 2 Use the Look In drop down list box to navigate to the directory where your project is located 3 Select the project to be opened 4 Click Open to open to open your project NOTE To quickly open a project you were working in recently
429. s Tab The Commands tab lets you modify the following by selecting the appropriate categories File Toolbar on page 17 Find Toolbar on page 20 Build Toolbar on page 18 Debug Toolbar on page 22 Debug Windows Toolbar on page 24 Command Processor Toolbar on page 21 Menu Bar on page 34 To see a description of each toolbar button highlight the icon as shown in Figure 77 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual 103 zZiLOG Customize Toolbars Commands Categories Buttons Deug rx Ge Debug Windows Command Proces Menu Select a category then click a button to see its description Drag the button to any toolbar Description Create a new document Cancel Help Figure 77 Customize Dialog Box Commands Tab Options The Options dialog box contains three tabs e Options General Tab on page 103 e Options Editor Tab on page 104 e Options Debugger Tab on page 107 Options General Tab The General tab Figure 78 contains the following check boxes e Select the Save Files Before Build check box to save files before you build This option is selected by default e Select the Always Rebuild After Configuration Activated check box to ensure that the first build after a project configuration such as Debug or Release is activated results in the reprocessing of all of the active project s source
430. s dl 0 UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual 133 zZiLOG segment code main pushm R1 Save the registers other than return register if any in use ld R1 val load the argument call sinf call the c functions ld res r0 the result is in r0 popm R1 restore the registers if any were saved ret Referenced C Function Prototype float sinf float arg COMMAND LINE OPTIONS The compiler like the other tools in ZDS II can be run from the command line for pro cessing inside a script and so on Please see Compiler Command Line Options on page 301 for the list of compiler commands that are available from the command line RUN TIME LIBRARY The C Compiler provides a collection of run time libraries The largest section of these libraries consists of an implementation of much of the C Standard Library A small library of functions specific to ZiLOG or to the ZNEO is also provided The ZNEO C Compiler is a conforming freestanding 1989 ANSI C implementation with some exceptions In accordance with the definition of a freestanding implementation the compiler supports the required standard header files lt float h gt lt limits h gt lt stdarg h gt and lt stddef h gt It also supports additional standard header files and ZiLOG specific nonstandard header files The standard header files and functions are with minor exceptions fully compliant with th
431. s encountered Most likely the object or library file is corrupted 710 Merging two located spaces lt spacel gt lt space2 gt is not allowed When merging two or more address spaces at most one of them can be located absolutely 711 Merging two located groups lt group1 gt lt group2 gt When merging two or more groups at most one can be located absolutely 712 Space lt space gt 1s not located on a segment base The address space is not aligned with a segment boundary 713 Space lt space gt 1s not defined The named address space is not defined 714 Multiple locates for lt name gt have been specified Multiple absolute locations have been specified for the named group section or address space 715 Module lt name gt contains errors or warnings Compilation of the named module produced a nonzero exit code 717 Invalid expression An expression specifying a symbol value could not be parsed UMO17103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual L z ZiLOG 718 lt segment gt is not in the specified range The named segment is not within the allowed address range 719 lt segment gt is an absolute or located segment Relocation was ignored An attempt was made to relocate an absolutely located segment 720 lt name gt calls lt name gt graph node which is not defined This message provides detailed information on how an undefined function name is called
432. s than the option com mand which requires that the entire defines string be set with each use Each defines parameter is a string containing a single define symbol such as TRAC E or SIMULATE 1 The defines command can take one of three forms e defines lt compiler assembler gt add lt new define gt adds the given define to the compiler or assembler defines as indicated by the first parameter defines compiler assembler replace new defin define gt Cold replaces old define with new define for the compiler or assembler defines as indicated by the first parameter If old define is not found no change is made Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 318 7 zZiLOG e defines lt compiler assembler gt remove lt define to be removed gt removes the given define from the compiler or assembler defines as indicated by the first parameter For example defines compiler add TRACE defines assembler add TRACE 1 defines assembler replace TRACE NOTRACE defines assembler replace TRACE 1 TRACE 0 defines compiler remove NOTRACE delete config The delete config command deletes the given existing project build configuration The following is the syntax ofthe delete config command delete config config name gt If config name is active the first remaining b
433. s the new page width for the list file The page width must immediately follow the with no space between The default and minimum page width is 80 The maximum page width is 132 For example pagewidth 132 quiet Suppresses title information that is normally displayed to the screen Errors and warnings are still displayed The default setting 1s to display title information relist mapfile Generates an absolute listing by making use of information contained in a linker map file This results in a listing that matches linker generated output mapfile is the name of the map file created by the linker For example relist product map sdiopt UMO17103 0207 Performs span dependent optimizations The smallest instruction size allowed is selected for all size optimizable instructions This is the default setting Appendix A Running ZDS II from the Command Line ZiLOG Developer Studio ll ZNEO User Manual 301 zZiLOG Table 8 Assembler Command Line Options Continued Option Name Description trace Debug information for internal use version Prints the version number of the assembler warns Toggles display warnings COMPILER COMMAND LINE OPTIONS Table 9 describes the compiler command line options NOTE If you use DOS use double quotation marks for the stdinc and usrinc commands for the C compiler For example stdine C ez8 include If you use cygwin use single quot
434. s used the least significant bit represents RO and the most signifi cant bit represents R15 The following examples illustrate the syntax for register lists myFunction PUSHM lt RO R2 R8 R12 gt Save registers RO R1 R2 R8 and R12 Code for myFunction POPM lt RO R2 R8 R12 gt Restore Registers RET and return The sam xample using immediate values hisFunction PUSHM 1107H Save registers RO R1 R2 R8 and R12 Code for hisFunction POPM 1107H Restore Registers RET and return The sam xample using equates RegList EQU lt RO R2 R8 R12 gt herFunction PUSHM RegList Save registers Code for herFunction POPM RegList Restore Registers RET and return Instruction Alignment Because all ZNEO instructions must be aligned to an even address the ZNEO assembler implicitly inserts an ALIGN directive in front of each instruction Thus the following example assembles correctly Some code RET L1 DW 1234 Some data perhaps used by previous routine DB 3 Warning next address is odd myFunction OK implicitly aligned to next even address LINK 20 Of course it does no harm to insert an ALIGN 2 or a EVEN directive ahead of a function just to be safe UMO17103 0207 4 Using the Macro Assembler ZiLOG Developer Studio ll ZNEO User Manual zZiLOG DIRECTIVES Directives control the assembly process by providing the assembler with commands and information T
435. s well as development code It is somewhat similar to the Default Program Configuration the only difference being that the executable program code is downloaded in EROM copied from EROM to RAM by the startup code and then executed from RAM The reason for choosing this configuration is that while internal Flash on ZNEO CPU based devices can be accessed quickly enough to keep up with the CPU that might not be true of external Flash If you have external Flash as part of the EROM address space and if the internal RAM is faster than the external Flash the user program might execute faster from RAM UM017103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual APT Address Range Space Contents IODATA I O Access 16 Bit Addressable Small Model Stack Data RAM Data Code Large Model Stack ERAM Data EROM Data Copy of Code Copy of ERAM Initializers Copy of RAM Initializers Startup Code Addressable Vector Table Data Option Bytes Figure 93 Programmer s Model Copy to RAM Program Configuration In this respect this configuration obviously is very similar to the Copy to ERAM Program Configuration discussed in Copy to ERAM Program Configuration on page 268 The main difference is that RAM is typically internal memory while ERAM is external Therefore in order to use the Copy to ERAM Program Configuration you must provide external memory and configure its interface By using the Copy
436. sassembly Window button 26 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 414 zZiLOG Distinct Code Segment for Each Module check box 65 div function 350 358 div t 348 DL directive 184 Down button 46 48 Download Code button 19 22 DS directive 186 DW directive 184 185 E Edit Breakpoints command 294 Edit button 68 Edit menu 44 Copy 45 Cut 45 Delete 45 Find 45 Find Again 46 Find in Files 46 Go to Line 48 Manage Breakpoints 49 Paste 45 Redo 45 Replace 47 Select All 45 shortcuts 110 Show Whitespaces 45 Undo 45 Edit window 27 28 code line indicators 279 Editor tab Options dialog box 104 EDOM 339 348 El 137 Enable All button 49 295 Enable Breakpoint command 295 Enable check box 97 Enable Disable Breakpoint button 20 24 END directive 186 ENDMACRO directive 200 Index ENDSTRUCT directive 193 ENDWITH directive 196 enum declarations with trailing commas 126 enumeration data type 124 EOF macro 347 EQU directive 187 ERAM address space 76 168 255 ERANGE 339 348 Erase Before Flashing check box 97 ERASE button 97 erom 134 EROM address space 76 168 254 EROM DATA segment 144 169 EROM TEXT segment 144 169 errno macro 339 lt ermo h gt header 339 Error conditions 339 343 Error messages ANSI C Compiler 152 assembler 208 linker locator 248 Executable Formats area 80 Executable formats for Linker 80 exit script file command 320 EXIT_FAILURE macro 348 EXIT
437. se Before Flashing check box to configure the internal Flash mem ory of the target hardware to be page erased If this check box is not selected the internal Flash is configured to be mass erased Target Select the appropriate target from the Target list box Setup Click Setup in the Target area to display the Configure Target dialog box Figure 61 Configure Target 7216F28001007C0G Chip Select Settings Clock Chip Select Register C50 x Source C Internal Watchdog Lower Upper G Bound hex 000000 FFFFFF pema Frequency MHz MV Enabled e ISA Mode Enabled 20 00000 16 00000 Polarity Active High C 1843200 C 8 00000 Iv 16 Bit Data Width C Other Wait States 2 z External Bus Interface Post Read Wait States 1 y C 8Bit 16Bit GPIO Port K v C None Configure Flash Figure 61 Configure Target Dialog Box NOTE The options displayed in the Configure Target dialog box depend on the CPU you selected in the New Project dialog box see New Project on page 36 or General page of the Project Settings dialog box see Project Settings General Page on page 54 Chip select and external bus interface settings are only available for CPUs that support an external bus 1 Select an 8 bit 16 bit or no external bus interface Selecting an external bus interface is appropriate only for target designs that use an external bus 2 Ifan external bus interface is selected do the following steps fo
438. see Recent Projects on page 44 Save Project Select Save Project from the File menu to save the currently active project By default project files and configuration information are saved in a file named project name gt zdspro3 An alternate file extension is used if provided when the project is cre ated NOTE The lt project name z sproj file contains all project data If deleted the project is no longer available If the Save Restore Project Workspace check box is selected see Options General Tab on page 103 a file named project name gt wsp is also created or updated with work space information such as window locations and bookmark details The wsp file supple ments the project information If it is deleted the last known workspace data is lost but this does not affect or harm the project Close Project Select Close Project from the File menu to close the currently active project 2 Using the Integrated Development Environment UMO17103 0207 42 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Save Select Save from the File menu to save the active file Save As To save the active file with a new name perform the following steps 1 Select Save As from the File menu The Save As dialog box is displayed as shown in Figure 39 Save in 6 Source gt e E3 E main c E Simulator c E 216F28001002C0G c File name main c Save as type an Files Cancel
439. sinf 353 assert 353 Index atan 354 atan2 354 atan2f 354 atanf 354 atof 355 atoff 355 atoi 355 atol 355 bsearch 356 calloc 357 ceil 357 ceilf 357 character case mapping 341 character handling 340 character input 348 character output 348 character testing 340 comparison 351 concatenation 350 copying 350 cos 358 cosf 358 cosh 358 coshf 358 detailed descriptions of 351 DI 136 div 358 EI 137 error conditions 343 exp 359 expf 359 exponential 345 fabs 360 fabsf 360 floor 360 floorf 360 fmod 360 fmodf 360 formatted input 347 formatted output 347 free 361 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z a ZiLOG frexp 361 frexpf 361 getch 137 getchar 362 gets 362 hyperbolic 345 init_uart 137 integer arithmetic 350 isalnum 363 isalpha 363 iscntrl 363 isdigit 364 isgraph 364 islower 364 isprint 365 ispunct 365 isspace 365 isupper 366 isxdigit 366 kbhit 138 labs 366 ldexp 367 Idexpf 367 Idiv 367 library 338 linker 213 log 368 log10 368 log10f 368 logarithmic 345 logf 368 longjmp 368 malloc 369 mathematical 344 memchr 370 memcmp 370 memcpy 371 memmove 371 memory management 349 memset 371 modf 372 Index modff 372 multiplication 367 nearest integer 346 nonlocal jumps 346 nonstandard input 136 nonstandard output 136 pow 372 power 346 powf 372 printf 373 pseudorandom sequence generation 349 putch 138 putchar 375 puts 376
440. size of an array with an omitted dimension 190 Identifier lt name gt already declared with different type or linkage An attempt was made to declare a tentative declaration with a different type than a declaration of the same name or an attempt was made to declare an object with a different type from a previous tentative declaration 191 Cannot perform pointer arithmetic on pointer to void An attempt was made to perform pointer arithmetic on pointer to void 192 Cannot initialize object with extern storage class An attempt was made to initialize variable with extern storage class 193 Missing lt name gt detected An attempt was made to use a variable without any previous definition or declaration 194 Recursive structure declaration A structure member can not be of same type as the structure itself 195 Initializer is not assignment compatible The initializer type does not match with the variable being initialized 196 Empty parameter list is an obsolescent feature Empty parameter lists are not allowed UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual AR zZiLOG 197 No function prototype lt name gt in scope The function lt name gt is called without any previous definition or declaration 198 old style formal parameter declarations are obsolescent Change the parameter declarations 201 Only one memory space can be specified An attempt was made to declare a varia
441. small model copy and modify the C startup provided in the installation under src boot common startupexs asm rewriting the relevant section as follows Copy CODE into RAM EA RO low code copy EA Rl low code LD R2 len code 1 JP clabl clab0 LD B R3 RO LD B R1 R3 clabl DJNZ R2 clab0 XREF low code copy EROM XREF len code XREF low code RAM Finally add your modified startup module to your project To do this you must select the Included in Project button in the Objects and Libraries page of the Project Settings dialog box see C Startup Module on page 72 and also add the modified source code file to your project using the Add Files command from the Project menu 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 275 zZiLOG Special Case Partial Copy to RAM A special case of this configuration is when you want to copy program code from just one C source file into RAM while retaining the rest of the code in EROM This allows you to investigate whether there might be power or speed savings to be realized by partitioning your application in this way Do this by performing the following steps 1 Select the Distinct Code Segment for Each Module check box in the Advanced page in the Project Settings dialog box see page 65 This directs the C Compiler to generate different code segment names for each file 2 Add the linker commands to place t
442. splays or hides the Clock window This window is described in Clock Window on page 281 Memory Window Button The Memory Window button opens one of ten Memory windows This window is described in Memory Window on page 282 Watch Window Button The Watch Window button displays or hides the Watch window This window is described in Watch Window on page 287 Locals Window Button The Locals Window button displays or hides the Locals window This window is described in Locals Window on page 290 Call Stack Window Button The Call Stack Window button displays or hides the Call Stack window This window is described in Call Stack Window on page 290 Symbols Window Button The Symbols Window button displays or hides the Symbols window This window is described in Symbols Window on page 291 2 Using the Integrated Development Environment UMO17103 0207 26 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Disassembly Window Button The Disassembly Window button displays or hides the Disassembly window This win dow is described in Disassembly Window on page 291 Simulated UART Output Window Button The Simulated UART Output Window button displays or hides the Simulated UART Out put window This window is described in Simulated UART Output Window on page 292 WINDOWS The following ZDS II windows allow you to see various aspects of the tools while work ing with your project
443. splays the values of variables This command works for values of any type including arrays and structures The following is the syntax expression The following are examples To see the value of z enter Z To see the nth value of array x enter x n To see all values of array x enter X To see the nth through the n 5th values of array x enter 3e 12 2 5 If x is an array of pointers to strings enter asciz x n NOTE When displaying a structure s value the examine command also displays the names of each of the structure s elements Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 320 7 zZiLOG exit The exit command exits the IDE The following is the syntax of the exit command exit fillmem The illmem command fills a block of a specified memory space with the specified value The functionality is similar to the Fill Memory command available from the context menu in the Memory window see Fill Memory on page 286 The following is the syn tax of the illmem command fillmem SPACE lt displayed spacename FILLVALUE lt hexcadecimal value gt STARTADDRESS lt hexadecimal address gt ENDADDRESS lt hexadecimal address gt If STARTADDRESS and ENDADDRESS are not specified all the memory contents of a spec ified space are filled For example fillmem SPACE ROM VALUE AA fillmem SPACE ROM
444. sscanf function returns the number of input items assigned which can be fewer than provided for or even zero in the event of an early conflict between an input character and the format Example char buf 80 int i sscanf buf d amp i Appends a copy of the string pointed to by s2 including the terminating null character to the end of the string pointed to by s1 The initial character of s2 overwrites the null charac ter at the end of sl UMO17103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual L as ZiLOG Synopsis include lt string h gt char strcat char s1 const char s2 Returns The value of s1 Example char ptr char s1 80 Production char s2 Languages ptr strcat s1 s2 strchr Locates the first occurrence of c converted to a char in the string pointed to by s The terminating null character is considered to be part of the string Synopsis finclude lt string h gt char strchr const char s int c Returns A pointer to the located character or a null pointer if the character does not occur in the string Example char ptr char str COMPASS ptr strchr str p strcmp Compares the string pointed to by s1 to the string pointed to by s2 Synopsis include lt string h gt int strcmp const char sl const char s2 Returns An integer greater than equal to or less than zero according as the string pointed to by s1 is
445. st be a modifiable lvalue An attempt was made to assign a value to an expression that was not modifiable 152 Operands are not assignment compatible An attempt was made to assign a value whose type cannot be promoted to the type of the destination 153 lt name gt must be arithmetic type An expression was encountered whose type was not arithmetic where only arithmetic types are allowed 154 lt name gt must be integral type An expression was encountered whose type was not integral where only integral types are allowed 155 lt name gt must be arithmetic or pointer type An expression was encountered whose type was not pointer or arithmetic where only pointer and arithmetic types are allowed 156 Expression must be an lvalue An expression was encountered that is not an lvalue where only an lvalue is allowed 157 Cannot assign to an object of constant type An attempt was made to assign a value to an object defined as having constant type 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 160 zZiLOG 158 Cannot subtract a pointer from an arithmetic expression An attempt was made to subtract a pointer from an arithmetic expression 159 An array is not a legal lvalue Cannot assign an array to an array 160 Cannot take address of a bit field An attempt was made to take the address of a bit field 161 Cannot take address of variable with register class An att
446. strncmp const char s1 const char s2 size t n Compares n characters of two strings Search void memchr const void s int c size t n Returns a pointer to the first occurrence within a specified number of characters of a given character in the buffer char strchr const char s int c Finds first occurrence of a given character in string size t strcspn const char s1 const char s2 Finds first occurrence of a character from a given character in string char strpbrk const char s1 const char s2 Finds first occurrence of a character from one string to another char strrchr const char s int c Finds last occurrence of a given character in string size_t strspn const char s1 const char s2 Finds first substring from a given character set in string char strstr const char s1 const char s2 Finds first occurrence of a given string in another string char strtok char s1 const char s2 Finds next token in string Miscellaneous void memset void s int c size t n Uses a given character to initialize a specified number of bytes in the buffer size t strlen const char s Finds length of string STANDARD FUNCTIONS The following functions are standard functions abs acos acosf asin asinf assert atan atanf atan2 atan2f atof atoff atoi atol bsearch calloc cell ceilf COS cosf cosh coshf div exp expf fabs fabsf floor floorf fmod fmodf free Appendix C C Standard Library UMO17103
447. sum loadmem target create cre log target get debugtool copy makfile or makefile target help debugtool create new project target list debugtool get open project target options debugtool help option target save debugtool list print target set debugtool save pwd target setup debugtool set quit wait debugtool setup rebuild wait bp defines reset In the following syntax descriptions items enclosed in angle brackets lt gt need to be replaced with actual values items enclosed in square brackets are optional double quotes indicate where double quotes must exist and all other text needs to be included as is add file The add file command adds the given file to the currently open project If the full path is not supplied the current working directory is used The following is the syntax of the add file command add file lt path lt filename gt For example add file c projectl main c The batch command runs a script file through the Command Processor If the full path is not supplied the current working directory is used The following is the syntax of the batch command batch wait lt path lt filename gt wait blocks processing of the current script until the invoked batch file completes useful when nesting script files Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual L a ZiLOG For example BATCH commands txt batch wait d batch do_it cmd
448. t is defined The named address space is not valid It must be either a group or an address space 740 Space lt space gt 1s not defined The referenced space name is not defined 742 lt error message gt A general purpose error message 743 Vector lt vector gt not defined The named interrupt vector could not be found in the symbol table 745 Configuration bits mismatch in file lt file gt The mode bit in the current input file differs from previous input files 746 Symbol lt name gt not attached to a valid segment The named symbol is not assigned to a valid segment 747 message General purpose error message for reporting out of range errors An address does not fit within the valid range 748 message General purpose error message for OMF695 to OMF251 conversion The requested translation could not proceed 749 Could not allocate global register A global register was requested but no register of the desired size remains available 75 Error opening output file lt outfile gt The named load module file could not be opened 753 Segment lt segment gt being copied is splittable A segment which is to be copied is being marked as splittable but startup code might assume that it is contiguous UMO017103 0207 5 Using the Linker Locator ZiLOG Developer Studio Il ZNEO User Manual 251 zZiLOG 6 Configuring Memory for Your Program The ZNEO CPU architecture provides a single unified address
449. t To remove breakpoints from your program use the Remove All Breakpoints but ton Remove All Breakpoints Button The Remove All Breakpoints button deletes all breakpoints in the currently loaded project To deactivate breakpoints in your project use the Disable All Breakpoints button Debug Windows Toolbar The Debug Windows toolbar Figure 20 allows you to display the Debug windows with the following buttons Registers Window Button on page 25 Special Function Registers Window Button on page 25 e Clock Window Button on page 25 e Memory Window Button on page 25 e Watch Window Button on page 25 e Locals Window Button on page 25 e Call Stack Window Button on page 25 e Symbols Window Button on page 25 e Disassembly Window Button on page 26 UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual zZiLOG e Simulated UART Output Window Button on page 26 BARA Figure 20 Debug Windows Toolbar Registers Window Button The Registers Window button displays or hides the Registers window This window is described in Registers Window on page 279 Special Function Registers Window Button The Special Function Registers Window button opens one of ten Special Function Regis ters windows This window is described in Special Function Registers Window on page 280 Clock Window Button The Clock Window button di
450. t and RAM ranges Normally the EROM range begins immediately above the ROM range but this is not required The EROM range can include both internal Flash and external nonvolatile memory if present The EROM range is the primary location for storing executable code in most applications e Extended RAM ERAM The ERAM address range identifies any 32 bit addressed random access memory on the target In current ZNEO CPU based devices ERAM is always external memory The ERAM range must begin above the highest EROM address Also the ZDS II GUI does not allow an ERAM starting address below 80 00008 An address gap is allowed between the EROM and ERAM ranges The C Compiler does not support gaps holes within the ERAM range The highest ERAM address must fall below the specified RAM address range Any external volatile memory that is present at or above FF 8000H is 16 bit addressable so it should be assigned to the RAM range The ERAM address range can be used for data stack or executable code For details see Program Configurations on page 258 Internal RAM RAM Typically FF B700H FF BFFFH for 2KB internal RAM or FF B000H FF BFFFH for 4KB internal RAM Despite its name this range can be expanded up to FF 8000H FF BFFFH if the target system provides external random access memory to fill out this address range This GUI field does not allow a high RAM address boundary above FF BFFFH The RAM address range is addressable using
451. t boundary for a segment The linker places modules in this segment on the defined boundary The multiple given in bytes must be a power of two 1 2 4 8 and so on Syntax align clause gt ALIGN int const Example DEFINE fdata SPACE ERAM ALIGN 2 Aligns on 2 byte boundary relocatable 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 186 ORG Clause Allows you to specify where the segment is to be located making the segment an absolute segment The linker places the segment at the memory location specified by the oRG The default is no ORG and thus the segment is relocatable Syntax org clause gt ORG int const Synonym ORIGIN Example DEFINE near code ORG FFF8 Uses current space byte alignment and absolute starting address at memory location FFF8 SPACE Clause A SPACE clause defines the address space in which the segment resides The linker groups together segments with the same space identification See Table 8 ZNEO Address Spaces on page 168 for available spaces Syntax space clause gt SPACE lt indent gt Example DEFINE fdata SPACE ERAM ALIGN 2 Aligns on a 2 byte boundary relocatable DS Defines storage locations that do not need to be initialized Synonym block Syntax define storage gt DS value Example NAME DS
452. t of the listing file can be controlled with directives included in the source file TITLE e NOLIST LIST e MACLIST ON OFF e CONDLIST ON OFF NOTE Error and warning messages follow the source line containing the error s A count of the errors and warnings detected is included at the end of the listing output file The addresses in the assembly listing are relative To convert the relative addresses into absolute addresses select the Show Absolute Addresses in Assembly Listings check box on the Output page of the Project Settings dialog box This option uses the information in the src file generated by the compiler when the Generate Assembly Source Code check box is selected see Project Settings Listing Files Page on page 59 and the map file to change all of the relative addresses in the assembly listing into absolute addresses Object Code obj File The object code output file name is the same as the source file name with an ob3 exten sion This file contains the relocatable object code in OMF695 format and is ready to be processed by the linker and librarian 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 172 zZiLOG SOURCE LANGUAGE STRUCTURE This section describes the form of an assembly source file General Structure A line in an assembly source file is either a source line or a comment line The assembler ignores blank lines Each line of input consis
453. t or double 180 Illegal bit field length The length of a bit field was outside of the range 0 32 181 Too many initializers for object An attempt was made to initialize an object with more elements than the object contains 182 Static objects can be initialized with constant expressions only An attempt was made to initialize a static object with a non constant expression 183 Array lt name gt has too many initializers An attempt was made to initialize an array with more elements than the array contains 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 162 zZiLOG 184 Structure lt name gt has too many initializers An attempt was made to initialize a structure with more elements than the structure has members 185 Dimension size may not be omitted An attempt was made to omit the dimension of an array which is not the rightmost dimension 186 First dimension of lt name gt may not be omitted An attempt was made to omit the first dimension of an array which is not external and is not initialized 187 Dimension size must be greater than zero An attempt was made to declare an array with a dimension size of zero 188 Only register storage class is allowed for formal parameter An attempt was made to declare a formal parameter with storage class other than register 189 Cannot take size of array with missing dimension size An attempt was made to take the
454. t right 231 A bitwise exclusive or 232 or 231 not 232 arithmetic 176 BASE OF 227 Boolean 176 COPY BASE 228 COPY TOP 228 FREEMEM 229 HIGHADDR 229 LENGTH 229 LOW 176 LOWI6 176 LOWADDR 229 precedence 178 relational 176 TOP OF 231 option script file command 323 Options 323 assembler 324 compiler 324 general 325 librarian 325 linker 326 Options dialog box 103 Debugger tab 107 108 Editor tab 104 105 General tab 103 104 ORDER command 222 226 ORG clause 186 ORG directive 188 Output File Name field 79 Output to Pane 2 check box 47 Output Window button 18 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Za zZiLOG P Page Length field 57 Page Width field 57 Paste button 18 PC definition 279 Place Target File In area 86 Place Target File in Project Directory check box 85 Placing breakpoints 293 Polarity Active High check box 83 Post Read Wait States drop down list box 83 pow function 346 372 Power functions 346 powf function 346 372 pragma asm 123 Predefined macros 127 Predefined segments 168 Preprocessing predefined macros 127 Preprocessor Definitions field 62 Print button 18 Print Preview window 43 Print Setup dialog box 43 print script file command 327 printf function 347 373 conversion characters 374 flag characters 374 Program and Verify button 97 98 Program button 97 98 Program space 76 254 Project adding files 6 52 building 13 89 compiling 89 configuring 8 90
455. t the specified milliseconds before executing the next command The following is the syntax of the wait command wait milliseconds For example wait 5000 wait bp The wait bp command instructs the Command Processor to wait until the debugger stops executing The optional max milliseconds parameter provides a method to limit the amount of time a wait takes that is wait until the debugger stops or max milliseconds passes The following is the syntax of the wait bp command wait bp max milliseconds For example wait bp wait bp 2000 UMO017103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual 333 zZiLOG RUNNING THE FLASH LOADER FROM THE COMMAND PROCESSOR You can run the Flash Loader from the Command field Command Processor keywords have been added to allow for easy scripting of the Flash loading process Each of the parameters is persistent which allows for the repetition of the Flash and verification pro cesses with a minimum amount of repeated key strokes Use the following procedure to run the Flash Loader 1 Create a project or open a project with a ZNEO microcontroller selected in the CPU Family and CPU fields of the General page of the Project Settings dialog box see Project Settings General Page on page 54 2 Setup the USB communication in the Configure Target dialog box see Figure 61 on page 82 3 In the Command field in the Command Processo
456. tandard Library ZiLOG Developer Studio ll ZNEO User Manual zZiLOG double res res pow x y printf Writes output to the stream pointed to by stdout under control of the string pointed to by format that specifies how subsequent arguments are converted for output A format string contains two types of objects plain characters which are copied unchanged to stdout and conversion specifications each of which fetch zero or more sub sequent arguments The results are undefined if there are insufficient arguments for the format If the format is exhausted while arguments remain the excess arguments are eval uated but otherwise ignored The printf function returns when the end of the format string is encountered Each conversion specification is introduced by the character After the the following appear in sequence Zero or more flags that modify the meaning of the conversion specification An optional decimal integer specifying a minimum field width If the converted value has fewer characters than the field width it is padded on the left or right if the left adjustment flag described later has been given to the field width The padding is with spaces unless the field width integer starts with a zero in which case the padding is with zeros An optional precision that gives the minimum number of digits to appear for the d i o u x and X conversions the number of digits to appear after the decimal point for e
457. tatement or instruction Step Out Button The Step Out button executes the remaining statements or instructions in the current func tion and returns to the statement or instruction following the call to the current function 2 Using the Integrated Development Environment UMO17103 0207 24 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Set Next Instruction Button The Set Next Instruction button sets the program counter to the line containing the cursor in the active file or the Disassembly window Insert Remove Breakpoint Button The Insert Remove Breakpoint button sets a new breakpoint or removes an existing break point at the line containing the cursor in the active file or the Disassembly window A breakpoint must be placed on a valid code line a C source line with a blue dot displayed in the gutter or any instruction line in the Disassembly window For more information on breakpoints see Using Breakpoints on page 293 Enable Disable Breakpoint Button The Enable Disable Breakpoint button activates or deactivates the existing breakpoint at the line containing the cursor in the active file or the Disassembly window A red octagon indicates an enabled breakpoint a white octagon indicates a disabled breakpoint For more information on breakpoints see Using Breakpoints on page 293 Disable All Breakpoints Button The Disable All Breakpoints button deactivates all breakpoints in the currently loaded projec
458. ted as a character constant The assembler does not insert null character 0 s at the end of a text string automatically unless a 0 is inserted and a character string cannot be used as an operand For example DB STRING a string DB STRING 0 C printable string DB STRING S embedded quote DB a b c character constants EXPRESSIONS In most cases where a single integer value can be used as an operand an expression can also be used The assembler evaluates expressions in 32 bit signed arithmetic Logical expressions are bitwise operators The assembler detects division by zero errors and reports an error message The following sections describe the syntax of writing an expression 4 Using the Macro Assembler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 176 zZiLOG Arithmetic Operators lt lt Left Shift gt gt Arithmetic Right Shift AU Exponentiation Multiplication Division Modulus Addition Subtraction NOTE You must put spaces before and after the modulus operator to separate it from the rest of the expression Relational Operators For use only in conditional assembly expressions Equal Synonyms eq EQ l Not Equal Synonyms ne NE gt Greater Than Synonyms gt GT lt Less Than Synonyms lt LT gt Greater Than or Equal Synonyms ge GE lt Less Than or Equal Synonyms le E Boolean Operators amp Bitwise A
459. terms of the standard In particular it is presumed that there are no file system and no operating system The use of the standard term freestanding imple mentation means that the compiler must contain at least a specific subset of the full ANSI C features This subset consists of those basic language features appropriate to embedded applications Specifically the list of required header files and associated library functions is minimal namely lt f1oat h gt lt limits h gt lt stdarg h gt and lt stddef h gt A freestanding implementation is allowed to additionally support all or parts of other standard header files but is not required to The ZNEO C Compiler for example supports a number of additional headers from the standard library as specified in Library Files Not Required for Freestanding Implementation on page 151 A conforming implementation that is compiler is allowed to provide extensions as long as they do not alter the behavior of any program that uses only the standard features of the language The ZiLOG ZNEO C Compiler uses this concept to provide language extensions that are useful for developing embedded applications and for making efficient use of the resources of the ZNEO CPU These extensions are described in Language Extensions on page 114 Deviations from ANSI C The differences between the ZiLOG ZNEO C Compiler and the freestanding implementa tion of ANSI C Standard consist of both extens
460. that warning messages are to be generated An optional warning file can be specified to redirect messages The default setting is to generate warn ing messages on the screen and in the map file Syntax JWARN lt warn filename Example WARN warnfile txt WARNING IS FATAL The WARNING IS FATAL command causes the linker to treat all warning messages as fatal errors The linker does not generate output file s if there are any warnings while linking By default the linker proceeds with generating output files even if there are warn ings Syntax lt WARNING WARN IS gt lt FATAL gt Examples warn fatal or WARNING IS FATAL WARNOVERLAP The WARNOVERLAP command enables or disables the warnings when overlap occurs while binding segments The default is to display the warnings whenever a segment gets over lapped 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 226 zZiLOG Syntax NO warnoverlap LINKER EXPRESSIONS This section describes the operators and their operands that form legal linker expressions e Add on page 227 e amp And on page 227 e BASE OF on page 227 e COPY BASE on page 228 e COPY TOP on page 228 e Divide on page 228 e FREEMEM on page 229 e HIGHADDR on page 229 e LENGTH on page 229 e LOWADDR on page 229 e Multiply on page 230 e Decimal Numeric
461. the debugging Break Step into over or out of program instructions Set the next instruction at the current line Insert or remove bookmarks see Using Bookmarks on page 29 When you right click outside of all files the context menu allows you to do the following Show or hide the Output windows Project Workspace window status bar File toolbar Build toolbar Find toolbar Command Processor toolbar Debug toolbar Debug Windows toolbar Toggle Workbook Mode When in Workbook Mode each open file has an associated tab along the bottom of the Edit Windows area Customize the buttons and toolbars Using Bookmarks A bookmark is a marker that identifies a position within a file Bookmarks appear as cyan boxes in the gutter portion left of the file window as shown in Figure 24 The cursor can be quickly positioned on a lines containing bookmarks 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 30 zZiLOG system_init printf Hello World n while 1 if kbhit 1 ch getchar putchar ch print message to show any interrupts received check isr Figure 24 Bookmark Example To insert a bookmark position the cursor on the desired line of the active file and perform one of the following actions e Right click in the Edit window and select Insert Bookmark from the resulting context menu see Figure 25 Select Toggle Boo
462. the specified type the function returns the value of the HUGE VAL macro with the same sign as the correct value of the function the integer expression errno acquires the value of the ERANGE macro If the result underflows the magnitude of the result is so small that it cannot be represented in an object of the speci fied type the function returns zero Functions Trigonometric double acos double x Calculates arc cosine of x double asin double x Calculates arc sine of x double atan double x Calculates arc tangent of x double atan2 double y double x Calculates arc tangent of y x double cos double x Calculates cosine of x double sin double x Calculates sine of x double tan double x Calculates tangent of x The following additional trigonometric functions are provided float acosf float x Calculates arc cosine of x float asinf float x Calculates arc sine of x float atanf float x Calculates arc tangent of x float atan2f float y float x Calculates arc tangent of y x float cosf float x Calculates cosine of x float sinf float x Calculates sine of x float tanf float x Calculates tangent of x UMO017103 0207 Appendix C C Standard Library ZiLOG Developer Studio ll ZNEO User Manual 345 zZiLOG Hyperbolic double cosh double x Calculates hyperbolic cosine of x double sinh double x Calculates hyperbolic sine of x double tanh double x Calculates hyperbolic tangent of x The following ad
463. thematics lt math h gt 1 0 0 eee nee e eens 343 Nonlocal Jumps lt setjmp h gt 2 0 00 e 346 Variable Arguments lt stdarg h gt 2 2 0 keene eens 346 Input Output lt stdio h gt 2 6 kc EATA EE EEEE E 347 General Utilities lt stdlib h gt lisse 348 String Handling lt string h gt 22 aaran nera 350 Standard Functions oooocoococor e teen e nee eae 351 ADS triada adria tbe 352 UMO17103 0207 Table of Contents ZiLOG Developer Studio ll ZNEO User Manual xiii COS AC OST iii ere ere rere ene Ot eerie S fee Ii t ee n e eer E e o RR 352 ASIN AM A RD ease Gave ev RE DeC RUPES 353 A A eh Be ea aa alee eas 353 atan atanh oee a a O ee eU 354 atan2 atan2f AA 354 LOL ALO E PRETI 355 A e MEL 355 A E NA 355 bseareli cisnes into ida abes 356 callOQ di iii 357 AA O Ne EE 357 COS COS id dd a 358 OSH NCOS Mio acacia 358 A PEUT 358 OONOQ EET debi e 359 PADS TADS A E ma dre Die nein natin abate 360 MOO FOOTE 1 oa c n ede a 360 mod fmodf sorore Rete me Wiis fw e eR le E RH FOE RA 360 TOS ccu tuere el Ml e uM au LM eee 361 MS MP 361 getchar iic 4e dea doa gy de Grea RR nid e dS Ser ab eee a ee ARA 362 BelS aora 362 EC diia sed 363 Isalph a id RE TE E RED edes 363 iud 363 o n IE RWenTPERwestieberebee b ELE 364 IS OT ADM ies e bep deese Me sat via 24 de og Hob esed die A eue d sans 364 ISIOWSE S 4 530 5 id d osea de aL RR a E e a da aq NU d ER E EA 364 IST ds 365 ISPUA i aire te ai
464. this command is equivalent to step This command starts a debug session if one has not been started The following is the syntax of the stepin command stepin stepout The stepout command steps out of the function This command starts a debug session if one has not been started The following is the syntax of the stepout command stepout stop The stop command stops the execution of program code The following is the syntax of the stop command stop Appendix B Using the Command Processor UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 330 zZiLOG target copy The target copy command creates a copy of the existing target with a given name with the given new name The syntax can take one of two forms target copy NAME new target name gt creates a copy of the active target named the value given for NAME target copy NAME lt new target name gt SOURCE lt existing target name gt creates a copy of the SOURCE target named the value given for NAME For example target copy NAME mytarget SOURCE Sim3 target create The target create command creates a new target with the given name and using the given CPU The following is the syntax ofthe target create command target create NAME lt target name CPU lt cpu name gt For example target create NAME mytarget CPU Z16F2811AL target get The target get command displays the current value for th
465. tiguous block within a single address space However some users might need a more complex configuration in which particular code modules are put in different address spaces Such users can select the Distinct Code Segment for Each Module check box to accom plish this purpose When this check box is selected the code segment for every module receives a distinct name for example the code segment generated for the myModule c module is given the name myModule TEXT You can then add linker directives to the linker command file to place selected modules in the appropriate address spaces This check box is deselected by default 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG An example of the use of this feature is to place most of the application s code in the usual EROM address space see Project Settings Address Spaces Page on page 74 for a dis cussion of the ZNEO address spaces except for a particular module that is to be run from the RAM 16 bit addressable RAM space See Special Case Partial Download to RAM on page 267 for an example of how to configure the linker command file for this type of application NOTE It is the user s responsibility to configure the linker command file properly when the Distinct Code Segment for Each Module check box is selected Default Type of Char The ANSI C Standard permits the compiler to regard char variables that are n
466. ting this check box can also increase the data size required by your application This happens because this option turns off the use of register variables see Use Register Vari ables on page 63 The variables that are no longer stored in registers must instead be stored in memory and on the stack if dynamic frames are in use thereby increasing the overall data storage requirements of your application Usually this increase is fairly small You can debug your application when this check box is deselected The debugger contin ues to function normally but debugging might be more confusing due to the factors described earlier This check box interacts with the Generate Debug Information check box see Generate Debug Information on page 55 Memory Model The Memory Model drop down list allows you to choose between the two memory mod els supported by the ZNEO C Compiler Small or Large One fundamental difference between these models is that the small model can be implemented using only ZNEO CPU s internal Flash and RAM memory but the large model requires the presence of external RAM Using the small model also results in more compact code and often reduces the RAM requirements as well However the small model places constraints on the data space size not on the code space size of your application Some applications might not be able to fit into the small model s data space size the large model is provided to support such applicati
467. tion An attempt was made to use a placement or alignment option on a local or parameter 212 No previous use of placement or alignment options 3 Using the ANSI C Compiler UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 164 zZiLOG An attempt was made to use the At directive without any previous use of the At address directive 213 Function lt name gt must return a value An attempt was made to return from a non void function without providing a return value 214 Function return type defaults to int The return type of the function was not specified so the default return type was assumed A function that does not return anything should be declared as void 215 Signed unsigned mismatch An attempt was made to assign a pointer to a signed type with a pointer to an unsigned type and vice versa Optimizer Warning and Error Messages 250 Missing format parameter to s printf This message is generated when a call to printf or sprintf is missing the format parameter and the inline generation of printf calls is requested For example a call of the form printf 251 Can t preprocess format to s printf This message is generated when the format parameter to printf or sprintf is not a string literal and the inline generation of printf calls is requested For example the following code causes this warning static char msgl x 4d char buff sizeof msgl 4 sprintf buff msgl x WARNING HERE
468. tion The function recognizes an optional leading sequence of white space characters as specified by the isspace func tion then an optional plus or minus sign then a sequence of digits and letters then an optional integer suffix The first inappropriate character ends the conversion If endptr is not a null pointer a pointer to that character is stored in the object endptr points to if an inappropriate charac ter occurs before the first digit or recognized letter the value of nptr is stored If the value of base is 0 the sequence of characters from the first digit to the character before the first inappropriate character is interpreted as an integer constant according to the rules of this section If a minus sign appears immediately before the first digit the value resulting from the conversion is negated If the value of base is between 2 and 36 it is used as the base for conversion Letters from a or A through z or Z are ascribed the values 10 to 35 a letter whose value is greater than or equal to the value of base ends the conversion Leading zeros after the optional sign are ignored and leading 0x or 0X is ignored if the value of base is 16 If a minus sign appears immediately before the first digit or letter the value resulting from the conversion is negated Synopsis include lt stdlib h gt long strtol const char nptr char endptr int base Returns The converted value or zero if an inappropriate character oc
469. tion as described in C Program Setup on page 274 In step 3 add the code to your assembly startup code instead of the standard C startup UMO17103 0207 6 Configuring Memory for Your Program ZiLOG Developer Studio ll ZNEO User Manual 277 zZiLOG 7 Using the Debugger The source level debugger is a program that allows you to find problems in your code at the C or assembly level You can also write batch files to automate debugger tasks see the Using the Command Processor appendix on page 307 The following topics are cov ered in this section Status Bar on page 278 e Code Line Indicators on page 279 e Debug Windows on page 279 Using Breakpoints on page 293 From the Build menu go to the Debug submenu and select Reset This moves you into Debug mode You are now in Debug mode as shown in the Debug Output window For a description of this window see Debug Output Window on page 33 The Debug toolbar and Debug Windows toolbar are displayed as shown in Figure 94 The Debug toolbar is described in Debug Toolbar on page 22 the Debug Windows tool bar is described in Debug Windows Toolbar on page 24 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 278 zZiLOG Simulator ZDS II ZNEO MAIN C File Edit View Project Build Debug Tools Window Help DG o Bas amp mm Pebug y 8B Es E E main c C Proar El S
470. to RAM Program Config uration you avoid that work On the other hand the amount of internal memory is rather limited on many ZNEO devices so the Copy to RAM Program Configuration might tend to be limited to small applications or portions of applications during development 6 Configuring Memory for Your Program UMO17103 0207 274 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG C Program Setup The C program setup for Copy to RAM Program Configuration is similar to the Default Program Configuration with some additional steps as described in this section The C Compiler by default generates the executable program code under one unified seg ment named CODE The CODE segment belongs to the EROM address space l UMO17103 0207 To set up this configuration you need to place the CODE segment in RAM at run time and EROM at load time Do this by adding the following linker commands in the Additional Linker Directives dialog box see Additional Directives on page 68 change code RAM Run time CODE is in RAM space copy code EROM Load time CODE is in EROM space define low code copy copy base of CODE define low code base of CODE define len code length of CODE The linker COPY directive only designates the load addresses and the run time addresses for the segment The actual copying of the segment needs to be performed by the startup code For example if you are using the
471. to be reused A local label cannot be imported or exported Example SLOOP JP SLOOP Infinite branch to SLOOP LAB JP LAB Infinite branch to LAB SCOPE New local label scope SLOOP JP SLOOP Reuse LOOP LAB JP LAB Reuse LAB Importing and Exporting Labels Labels can be imported from other modules using the EXTERN or XREF directive A space can be provided in the directive to indicate the label s location Otherwise the space of the current segment is used as the location of the label Labels can be exported to other modules by use of the PUBLIC or XDEF directive Label Spaces The assembler makes use of a label s space when checking the validity of instruction oper ands Certain instruction operands require that a label be located in a specific space because that instruction can only operate on data located in that space A label is assigned to a space by one of the following methods The space of the segment in which the label is defined e The space provided in the EXTERN or XREF directive UMO17103 0207 4 Using the Macro Assembler e Tfno space is provided with the ZiLOG Developer Studio ll ZNEO User Manual L 0s zZiLOG EXTERN or XREF directive the space check is not performed on the label SOURCE LANGUAGE SYNTAX The syntax description that follows is given to outline the general assembler syntax It does not define assembl
472. to function f2 The number of pointers is specified by the first argument to fl include lt stdarg h gt extern void f2 int n char arrayl define MAXARGS 31 void fl int n ptrs va_list ap char array MAXARGS int ptr no 0 if n ptrs MAXARGS n ptrs MAXARGS va start ap n ptrs while ptr no lt n ptrs array ptr no va arg ap char va end ap f2 n ptrs array Each call to f1 has in scope the definition of the function of a declaration such as void fl int ses va_end Facilitates a normal return from the function whose variable argument list was referenced by the expansion of va start that initialized the va_list ap The va end function can modify ap so that it is no longer usable without an intervening invocation of va start Ifthe va end function is not invoked before the return the behavior is unde fined Synopsis include lt stdarg h gt void va_end va_list ap Example The function f1 gathers into an array a list of arguments that are pointers to strings but not more than MAXARGS arguments then passes the array as a single argument to function f2 The number of pointers is specified by the first argument to fl Appendix C C Standard Library UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 396 7 zZiLOG include lt stdarg h gt extern void f2 int n char arrayl define MAXARGS 31 void fl znt n ptfs 4 va list ap char array MAXARGS
473. to select or add configurations for your project The Build menu has the following options e Compile on page 89 e Build on page 89 e Rebuild All on page 89 Stop Build on page 89 e Clean on page 89 Update All Dependencies on page 90 Set Active Configuration on page 90 e Manage Configurations on page 91 Compile Select Compile from the Build menu to compile or assemble the active file in the Edit window Build Select Build from the Build menu to build your project The build compiles and or assem bles any files that have changed since the last build and then links the project Rebuild All Select Rebuild All from the Build menu to rebuild all of the files in your project This option also links the project Stop Build Select Stop Build from the Build menu to stop a build in progress Clean Select Clean from the Build menu to remove intermediate build files 2 Using the Integrated Development Environment UMO17103 0207 90 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Update All Dependencies Select Update All Dependencies from the Build menu to update your source file depen dencies Set Active Configuration You can use the Select Configuration dialog box to select the active build configuration you want 1 From the Build menu select Set Active Configuration to display the Select Configuration dialog box Figure 68 Select Configuration Rele
474. tomized configuration do the following 1 From the Build menu select Manage Configurations The Manage Configurations dialog box Figure 69 is displayed Manage Configurations Figure 69 Manage Configurations Dialog Box 2 From the Manage Configurations dialog box click Add The Add Project Configuration dialog box Figure 70 is displayed Add Project Configuration Configuration Name l Copy settings from Debug ced Figure 70 Add Project Configuration Dialog Box 3 Type the name ofthe new configuration in the Configuration Name field 4 Selecta similar configuration from the Copy Settings From drop down list box 5 Click OK Your new configuration is displayed in the configurations list in the Manage Configurations dialog box 6 Click Close 2 Using the Integrated Development Environment UMO17103 0207 92 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG The new configuration is the current configuration as shown in the Select Build Configuration drop down list box on the Build toolbar Now that you have created a blank template you are ready to select the settings for this new configuration 7 From the Project menu select Settings The Project Settings dialog box is displayed 8 Select the settings for the new configuration and click OK 9 From the File menu select Save All Debug Menu Use the Debug menu to access the following functions for the debugger Connect
475. ts of ASCH characters terminated by a car riage return An input line cannot exceed 512 characters A backslash 1 at the end of a line is a line continuation The following line is concate nated onto the end of the line with the backslash as exemplified in the C programming language If you place a space or any other character after the backslash the following line is not treated as a continuation Source Line A source line is composed of an optional label followed by an instruction or a directive It is possible for a source line to contain only a label field Comment Line A semicolon terminates the scanning action of the assembler Any text following the semicolon is treated as a comment A semicolon that appears as the first character causes the entire line to be treated as comment Label Field A label must meet at least one of the following conditions e It must be followed by a colon Jt must start at the beginning of the line with no preceding white space start in column 1 When an instruction is in the first column it is treated as a instruction and not a label The first character of a label can be a letter an underscore a dollar sign a question mark a period or pound sign 7 Following characters can include letters digits underscores dollar signs question marks periods or pound signs 7 The label can be followed by a colon that completes the label definition A label ca
476. tudio ll ZNEO User Manual 147 zZiLOG Linker Symbols The default linker command file defines some system symbols which are used by the C startup file to initialize the stack pointer clear the uninitialized variables to zero set the initialized variables to their initial value set the heap base and so on Table 7 shows the list of symbols that might be defined in the linker command file depending on the compi lation memory model selected by the user Table 7 Linker Symbols Symbol Description low neardata Base of near data segment after linking len neardata Length of near data segment after linking low near romdata Base of the rom copy of near data segment after linking low fardata Base of far data segment after linking len fardata Length of far data segment after linking low far romdata Base of the rom copy of far data segment after linking low nearbss Base of near bss segment after linking len nearbss Length of near bss segment after linking low farbss Base of far bss segment after linking len farbss Length of far bss segment after linking far stack Top of stack for large model is set as highest address of ERAM near stack Top of stack for small model is set as highest address of RAM far heapbot Base of heap for large model is set as highest allocated ERAM address near heapbot Base of heap for small model is set
477. uild configuration if any is made active If config name gt does not exist no action is taken For example delete config MyDebug examine for Expressions The examine command evaluates the given expression and displays the result It accepts any legal expression made up of constants program variables and C operators The syn tax takes the following form data type lt radix gt lt expr gt lt count gt data type can consist of one of the following types short int eger long ascii asciz radix can consist of one of the following types dec mal hex adecimal oct al bin ary Omitting a data type or radix results in using the data type or radix pseudo variable respectively count represents the number of items to display UMO17103 0207 Appendix B Using the Command Processor ZiLOG Developer Studio ll ZNEO User Manual Zu zZiLOG The following are examples X shows the value of x using data type and radix ascii STR shows the ASCII string representation of STR 0x1000 shows the value of 0x1000 in the data type and radix 0x1000 shows the byte at address 0x1000 0x1000 25 shows 25 bytes at address 0x1000 LO shows the value of register D0 0 using data type and radix asciz D0 0 shows the null terminated string pointed to by the contents of register DO 0 examine for Variables The examine command di
478. up address space or seg ment If an address falls outside of the specified RANGE the system displays a message NOTE You must use white space to separate the colon from the RANGE command operands Syntax RANGE name expression expression expression lt expression gt lt name gt can be a group address space or segment The first expression marks the lower boundary for a specified address RANGE The second lt expression gt marks the upper boundary for a specified address RANGE Example RANGE EROM 008000 SO1FFFF 040000 04FFFF UMO017103 0207 5 Using the Linker Locator ZiLOG Developer Studio ll ZNEO User Manual 223 zZiLOG Ifa RANGE is specified for a segment this range must be within any RANGE specified by that segment s address space NOTE Refer to Linker Expressions on page 226 for the format to write an expression SEARCHPATH The SEARCHPATH command establishes an additional search path to be specified in locat ing files The search order is as follows 1 Current directory 2 Environment path 3 Search path Syntax SEARCHPATH lt path gt Example SEARCHPATH C ZDSII_ZNEO 4 11 0 MlibNstandard SEQUENCE The SEQUENCE command forces the linker to allocate a group address space or segment in the order specified Syntax SEQUENCE lt name gt lt name_list gt lt
479. ut clocking signals SUB Subtract T tristate A form of transistor to transistor logic in which output stages or input and output stages can assume three states Two are normal low impedance and 0 states the third is a high impedance state that allows many tristate devices to time share bus lines This industry term is not trademarked and is available for ZiLOG use Do not use 3 state or three state U ULT Unsigned Less Than W wait state A clock cycle during which no instructions are executed because the processor is waiting for data from memory word Amount of data a processor can hold in its registers and process at one time write To make a permanent or transient recording of data in a storage device or on a data medium X X 1 Indexed Address 2 An undefined or indeterminate variable XOR Bitwise exclusive OR Z Z 1 Zero 2 Zero Flag ZDS ZiLOG Developer Studio ZiLOG s program development environment for Microsoft Windows Glossary UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 406 zZiLOG UMO17103 0207 Glossary Index Symbols Bytes drop down list box 97 98 include 60 62 338 pragma asm 123 pragma interrupt 120 202 amp and 227 multiply 230 add 227 COMMENT directive 182 ENDSTRUCT directive 193 ENDWITH directive 196 hex file extension 80 map file extension 220 247 SSHORT STACK FRAME directive 189 STRUCT directive 193 TAG directi
480. value Syntax LENGTH OF lt name gt lt name gt can be a group address space or segment LOWADDR The LOWADDR operator provides the lowest possible address of a group address space or segment The value of LOWADDR is treated as an expression value Syntax LOWADDR OF lt name gt lt name gt can be a group address space or segment BASE OF Versus LOWADDR OF By default allocation for a given memory group address space or segment starts at the lowest defined address for that memory group address space or segment If you explicitly 5 Using the Linker Locator UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 230 zZiLOG define an assignment within that memory space allocation for that space begins at that defined point and then occupies subsequent memory locations the explicit allocation becomes the default BASE OF value BASE OF lt name gt gives the lowest allocated address in the space LOWADDR OF lt name gt gives the lowest physical address in the space For example RANGE ROM 0 S7FFF RANGE RAM 8000 SBFFF RAM allocation OCATE s uninit data at 8000 OCATE s nvrblock at 9000 DEFINE low data BASE OF s uninit data Using OCATE s uninit data at 8000 or OCATE s uninit data at LOWADDR OF RAM gives the same address the lowest possible address when RANGE RAM 8000 BFFF If OCATE s uninit data at 8000
481. ve script file command 331 332 target set script file command 331 Target selecting 81 TCP Port field 87 TDI function 141 Technical service xxiv Technical support xxiv Tile the files 109 J TIME 127 TITLE directive 190 tof 349 tolower function 341 393 Toolbars 16 Build 18 Command Processor 21 creating 101 Debug 22 Debug Windows 24 279 File 17 Find 20 Toolbars tab 100 Tools menu 94 Calculate File Checksum 99 Customize 100 Firmware Upgrade 98 Flash Loader 94 Options 103 Show CRC 98 TOP OF 217 231 toupper function 341 394 Treat All Warnings as Fatal check box 77 Treat Undefined Symbols as Fatal check box 77 Trigonometric functions 344 Troubleshooting the linker 246 True macro 340 Tutorials developer s environment 1 Type sizes 126 Index U UCHAR_MAX 341 UINT_MAX 341 ULONG_MAX 341 Underscore 134 UNION directive 196 Unions in assembly 192 Units drop down list box 84 96 UNRESOLVED IS FATAL command 224 UNSIGNED CHARS 127 Up button 46 48 Use C Runtime Library check box 73 Use Default Libraries area 73 Use Existing button 69 Use Page Erase Before Flashing check box 39 82 Use Register Variables check box 63 Use Selected Target button 86 Use Standard Startup Linker Commands check box 72 User Include Path field 62 User defined segments 169 USHRT MAX 341 V va arg function 347 394 va end function 347 395 va list 347 va start function 347 396 Values return 132 VAR
482. ve 194 UNION directive 196 WITH directive 196 divide 228 shift left 231 lt assert h gt header 340 lt ctype h gt header 340 lt errno h gt header 339 lt float h gt header 342 lt limits h gt header 341 lt math h gt header 343 lt outputfile gt lt module list gt command 216 lt setjmp h gt header 346 lt sio h gt header 135 lt stdarg h gt header 346 lt stddef h gt header 339 lt stdio h gt header 347 lt stdlib h gt header 348 lt string h gt header 350 lt zneo h gt header 134 gt gt shift right 231 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z w ZiLOG script file command for expressions 318 for variables 319 bitwise exclusive or 232 _ underscore for assembly routine names 131 for external identifiers 134 for macro names 134 CONST IN ROM _ 127 DATE 197 FILE 127 LINE 127 J MODEL 127 _ STDC 127 TIME 127 _ UNSIGNED CHARS _ 127 VECTORS segment 169 _ ZDATE 127 ZILOG 127 ZNEO 127 Align keyword 122 At keyword placement of a variable 121 placement of consecutive variables 121 _Erom 116 Far 117 far heapbot 147 far heaptop 147 far stack 147 len farbss 147 len fardata 147 len nearbss 147 len neardata 147 low far romdata 147 low farbss 147 low fardata 147 low near romdata 147 Index _low_nearbss 147 _low_neardata 147 _Near 116 _near_heapbot 147 _near_heaptop 147 _near_stack 147 Rom 116 SYS CLK FR
483. ve file and put it on the Windows clipboard Copy Select Copy from the Edit menu to copy selected text from the active file and put it on the Windows clipboard Paste Select Paste from the Edit menu to paste the current contents of the clipboard into the active file at the current cursor position Delete Select Delete from the Edit menu to delete selected text from the active file Select All Select Select All from the Edit menu to highlight all text in the active file Show Whitespaces Select Show Whitespaces from the Edit menu to display all whitespace characters like spaces and tabs in the active file Find To find text in the active file use the following procedure 1 Select Find from the Edit menu The Find dialog box is displayed as shown in Figure 41 2 Using the Integrated Development Environment UMO17103 0207 46 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Find what y Match whole word only Direction Match case C Up Cancel Regular expression Down Canol Figure 41 Find Dialog Box 2 Enter the text to search for in the Find What field or select a recent entry from the Find What drop down list box By default the currently selected text in a source file or the text where your cursor is located in a source file is displayed in the Find What field 3 Select the Match Whole Word Only check box if you want to ignore the search text when it occurs as part of longer words
484. w on page 290 Symbols Window on page 291 Simulated UART Output Window on page 292 Registers Window Click the Registers Window button to show or hide the Registers window The Registers window Figure 95 displays all the registers in the standard ZNEO architecture 7 Using the Debugger UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 280 zZiLOG Registers 00000000 Ri 00000000 00000000 00000034 R4 00000000 00000000 00000000 R 00000000 00000000 00000000 R10 00000000 00000000 00000000 R13 00000000 00000000 FFFFBFFC SP FFFFBFFC 00008000 C 0 1 40 0 V 0 0 F 0 F2 0 0 PCOV FFFFFFFF SPOV FFFFB02 00 Figure 95 Registers Window To change register values do the following 1 Inthe Registers window highlight the value you want to change 2 Type the new value and press the Enter key The changed value is displayed in red Special Function Registers Window Click the Special Function Registers Window button to open up to ten Special Function Registers windows Each Special Function Registers window Figure 96 displays the spe cial function registers in the standard ZNEO architecture that belong to the selected group Addresses F00 through FFF are reserved for special function registers SFRs Use the Group drop down list to view a particular group of SFRs Special Function Registers x Group FLASH Figure 96 Special Function Registers Window UMO017103
485. w the scanf function returns Failures are described as input failures due to the unavailability of input characters or matching failures due to inappropriate input A directive composed of white space is executed by reading input up to the first non white space character which remains unread or until no more characters can be read A white space directive fails 1f no white space character can be found A directive that is an ordinary character is executed by reading the next character of the stream If the character differs from the one comprising the directive the directive fails and the character remains unread A directive that is a conversion specification defines a set of matching input sequences as described below for each character A conversion specification is executed in the follow ing steps e Input white space characters as specified by the isspace function are skipped unless the specification includes a c or n character e An input item is read from the stream unless the specification includes an n character An input item is defined as the longest sequence of input characters up to any specified maximum field width which is an initial subsequence of a matching sequence The first character if any after the input item remains unread If the length of the input item is zero the execution of the directive fails this condition is a matching failure unless an error prevented input from the st
486. which is the value of the new origin UMO17103 0207 4 Using the Macro Assembler ORG 1000 ORG LOOP ZiLOG Developer Studio ll ZNEO User Manual y ARA zZiLOG Synonyms ORIGIN ORG Syntax org directive gt ORG int const Examples Sets the location counter at 1000 in the address space of current segment ERROR use an absolute constant On encountering the ORG assembler directive the assembler creates a new absolute seg ment with a name starting with 0rg This new segment is placed in the address space of the current segment with origin at the specified value and alignment as 1 NOTE ZiLOG recommends that segments requiring the use of ORG be declared as absolute segments from the outset by including an oRG clause in the DEFINE directive for the segment SEGMENT Specifies entry into a previously defined segment The SEGMENT directive must be followed by the segment identifier The default segment is used until the assembler encounters a SEGMENT directive The internal assembler program counter is reset to the previous program counter of the segment when a SEGMENT directive is encountered See Table 9 Predefined Segments on page 169 for the names of pre defined segments Synonyms SECTION Syntax segment directive gt SEGMENT ident Example SEGMENT code predefined segment DEFINE data
487. with it that identifies valid addresses for that space The hierarchical memory model for the ZNEO CPU is shown in Figure 85 Figure 86 depicts how the linker links and locates seg ments in different object modules UMO17103 0207 3 Using the ANSI C Compiler ZiLOG Developer Studio ll ZNEO User Manual Z 145 zZiLOG ZNeo Memory Spaces EROM Space ROM Space RAM Space ERAM Space EROM_DATA EROM_TEXT ROM_DATA ROM_TEXT NEAR_BSS NEAR_DATA FAR_BSS FAR_DATA Segment Segment Segment Segment Segment Segment Segment Segment CODE NEAR_TEXT FAR_TEXT Segment Segment Figure 85 ZNEO Hierarchical Memory Model Module one obj Module two obj Module three obj Space EROM Space ROM Space ERAM Space RAM Figure 86 Multiple File Linking 3 Using the ANSI C Compiler UMO17103 0207 146 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Linker Referenced Files The default linker command file generated by the ZDS II IDE references system object files and libraries based on the compilation memory model selected by the user A list of the system object files and libraries is given in the Table 6 The linker command file auto matically selects and links to the appropriate version of the C run time and if necessary floating point libraries from the list shown in Table 6 based on the your project settings Table 6 Linker Referenced Files File Description Startups obj C startup for small m
488. x file to Flash memory by writing a segment of data and then reading back the segment and verifying that it has been written correctly 17 Verify the Flash memory by clicking Verify When you click Verify the Flash Loader reads and compares the hex file contents with the current contents of Flash memory This function does not change target Flash memory Firmware Upgrade NOTE This command is available only when a supporting debug tool is selected Debug Tool on page 87 USB Smart Cable lt ZDS Installation Directory NbinNf irmwareNUSBSmartCableNUSBSmartCable upgrade information txt Serial Smart Cable This is not available for this release Ethernet Smart Cable lt ZDS Installation Directory gt bin firmware EthernetSmartCable EthernetSmartCable upgrade information txt Show CRC NOTE This command is only available when the target is not a simulator Use the following procedure to perform a cyclic redundancy check CRC 1 Select Show CRC from the Tools menu The Show CRC dialog box Figure 72 is displayed UMO17103 0207 2 Using the Integrated Development Environment ZiLOG Developer Studio ll ZNEO User Manual ziLoc Start Address 1000 End Address 1FFFF CRC AEBA Close Figure 72 Show CRC Dialog Box 2 Enter the start address in the Start Address field The start address must be on a 4K boundary If the address is not on a 4K boundary ZDS II produces an error message 3
489. xisting option disables all configurable linker options Cancel Help Figure 53 Commands Page of the Project Settings Dialog Box Always Generate from Settings When this button is selected the linker command file is generated afresh each time you build your project the linker command file uses the project settings that are in effect at the time This button is selected by default which is the preferred setting for most users Selecting this button means that all changes you make in your project such as adding more files to the project or changing project settings are automatically reflected in the linker command file that controls the final linking stage of the build If you do not want the linker command file generated each time your project builds select the Use Existing button see Use Existing on page 69 NOTE Even though selecting Always Generate from Settings causes a new linker command file to be generated when you build your project any directives that you have specified in the Additional Linker Directives dialog box are not erased or overridden 2 Using the Integrated Development Environment UMO17103 0207 68 ZiLOG Developer Studio Il ZNEO User Manual zZiLOG Additional Directives To specify additional linker directives that are to be added to those that the linker gener ates from your settings when the Always Generate from Settings button is selected do the following 1 Select the Additional
490. xt to search for in the Find field or select a recent entry from the Find drop down list box If you select text in a source file before displaying the Find dialog box the text is displayed in the Find field 3 Select or enter the file type s to search for in the In File Types drop down list box Separate multiple file types with semicolons 4 Usethe Browse button ET or the In Folder drop down list box to select where the files are located that you want to search 5 Select the Match Whole Word Only check box if you want to ignore the search text when it occurs as part of longer words 6 Select the Match Case check box if you want the search to be case sensitive 7 Select the Look in Subfolders check box if you want to search within subfolders 8 Select the Output to Pane 2 check box if you want the search results displayed in the Find in Files 2 Output window If this button is not selected the search results are displayed in the Find in Files Output window 9 Click Find to perform the search Replace To find and replace text in the active file use the following procedure 1 Select Replace from the Edit menu The Replace dialog box is displayed as shown in Figure 43 2 Using the Integrated Development Environment UMO17103 0207 ZiLOG Developer Studio Il ZNEO User Manual 48 zZiLOG Find what oh e Find Next Replace With e Replace irecti Replace Match Case Pani eplace All Up Regular exp
491. y Source Code check box TRUE FALSE keepasm Listing Files page Preprocessor Definitions field keeplst Listing Files page Generate Assembly Listing Files lst check TRUE FALSE box list Listing Files page Generate C Listing Files lis check box TRUE FALSE listinc Listing Files page With Include Files check box TRUE FALSE Only applies if 1ist option is currently true model Code Generation page Memory Model drop down list box string large or small UMO17103 0207 Appendix B Using the Command Processor Table 15 Compiler Options Continued ZiLOG Developer Studio ll ZNEO User Manual 325 zZiLOG Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values modsect Advanced page Distinct Code Segment for Each Module check TRUE FALSE box optspeed Toggles optimizing for speed TRUE optimize for speed FALSE optimize for size reduceopt Code Generation page Limit Optimizations for Easier TRUE FALSE Debugging check box regvar Advanced page Use Register Variables check box TRUE FALSE stdinc Preprocessor page Standard Include Path field string separate multiple paths with semicolons usrinc Preprocessor page User Include Path field string separate multiple paths with semicolons Debugger Options For debugger options use the target help and debugtool help commands General Options Table 16 General Options Option Name Corr
492. y at speeds above 2400 bps baud rate A unit of measure of the number of state changes from 0 to 1 or 1 to 0 per second on an asynchronous communications channel binary b A number system based on 2 A binary digit is a bit bit binary digit a digit of a binary system It contains only two possible values 0 or 1 block diagram A diagram of a system a computer or a device in which the principal parts are represented by suitably annotated geometrical figures to show both the basic functions of the parts and their functional relationships buffer 1 In hardware a device that restores logic drive signal levels to drive a bus or a large number of inputs In software any memory structure allocated to the temporary storage of data 2 A routine or storage medium used to compensate for a difference in rate of flow of data or time of occurrence of events when transferring data from one device to another bus In electronics a parallel interconnection of the internal units of a system that enables data transfer and control information One or more conductors or optical fibers that serve as a common connection for a group of related devices byte B A sequence of adjacent bits usually 8 considered as a unit A collection of four sequential bits of memory Two sequential bytes 8 bits comprise one word C CALL This command invokes a subroutine CCF Clear Carry Flag character set A finite set of different characters that is
493. y functions 338 351 Limit Optimizations for Easier Debugging check box 58 lt limits h gt header 341 LINE 127 Line continuation in assembly 172 Link map file contents 220 creating 220 221 Linker case sensitivity 55 Index command line options 304 commands 215 creating link map file 220 221 creating linking sequence 222 defining holes in memory 76 detailed description 213 error messages 248 expressions 226 file format 219 functions 213 generating debug information 218 221 247 generating warnings 225 invoking 214 map file 232 memory used 247 objects manipulated during linking 213 opening 214 options 326 reducing execution times 247 running 214 running from the command line 298 search order 223 speeding up 247 starting 214 suppressing warnings 222 symbols 147 troubleshooting 246 warning messages 248 Linker command file 214 commands 215 for C programs 144 linker symbols 147 referenced files 146 sample 147 Linker commands lt outputfile gt lt module list gt 216 BASE OF 217 CHANGE 216 COPY 217 COPY BASE OF 217 UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual Z 421 zZiLOG COPY TOP OF 217 DEBUG 218 DEFINE 218 FORMAT 219 GROUP 219 HEADING 219 LOCATE 220 MAP 220 MAXHEXLEN 220 MAXLENGTH 221 NODEBUG 221 NOMAP 220 221 NOWARN 222 ORDER 222 RANGE 222 SEARCHPATH 223 SEQUENCE 223 SORT 223 SPLITTABLE 224 TOP OF 217 UNRESOLVED IS FATAL 224 WARN 225 WARNING IS FATA
494. y language instructions lt source_line gt lt if_statement gt if section if conditional else statement cond expression lt relop gt lt code_body gt lt label_field gt lt instruction_field gt lt directive_field gt lt mnemonic gt lt operand gt lt addressing_mode gt 4 Using the Macro Assembler lt if_statement gt lt Label_field gt lt instruction_field gt lt EOL gt lt Label_field gt lt directive_field gt lt EOL gt lt Label_field gt lt EOL gt lt EOL gt lt if_section gt lt else_statement gt ENDIF if conditional lt code body gt IF lt cond_expression gt IFDEF lt ident gt IFSAME lt string_const gt lt string_const gt IFMA lt int_const gt ELSE lt code_body gt ELIF lt cond_expression gt lt code_body gt lt else_statement gt lt expression gt lt expression gt lt relop gt lt expression gt lt gt lt gt source line ident lt mnemonic gt lt operand gt lt directive gt valid instruction mnemonic lt addressing_mode gt lt expression gt valid instruction addressing mode UMO17103 0207 ZiLOG Developer Studio ll ZNEO User Manual 206 2 ZiLOG lt directive gt lt array_definition gt lt type gt lt elements gt lt initvalue gt lt instances gt lt value gt UMO17103 0207 ALIGN lt int_const gt lt array_definition gt CON
Download Pdf Manuals
Related Search
Related Contents
Verbatim VB-DPR47S2PA 509 & 511 power backhoes operator`s manual Jabra Motion Office American Power Conversion PD150G6F User's Manual 1500 Installation Manual Husqvarna U03380 User's Manual 株式会社ミツバサンコーワ 技術サービス Targus 3D Copyright © All rights reserved.
Failed to retrieve file