Home
Zilog Developer Studio II--Z8 Encore! User Manual
Contents
1. Z8 Encore Assembler Compatible With NIF IFZ IFE IFFALSE IFNTRUE IFNTRUE NOLIST NOLIST NOSAME IFDIFF IFNSAME ORG org ORIGIN PE V PO NV POPSEG none PRINT none PT none PUSHSEG none REPEAT SREPEAT Srepeat SAME IFNDIFF IFSAME SBLOCK SBLOCK SCOPE none SEGMENT Section SECTION STRUCT STRUCT TAG TAG TEXT text ITLE title UNTIL SUNTIL until VAR VAR SET SE VECTOR lt none gt WARNING wmsg MESSAGE WEND SWEND wend WHILE SWHILE while XDEF Global GLOBAL GLOBAL public def public XREF EXTERN EXTERNAL extern ref ZIGNORE lt none gt UMO13033 0508 Compatibility Issues 439 Zilog Developer Studio ll Z8 Encore User Manual Table 19 Z8 Encore Directive Compatibility Continued Z8 Encore Assembler Compatible With ZSECT Sect ZUSECT USECT COMPILER COMPATIBILITY ISSUES NOTE Use of the pragmas documented in this section should not be necessary in ZDS II release 4 10 and later Zilog does not recommend their use especially in new projects because it is extremely difficult to validate that they continue to work correctly as the compiler is updated and in all circumstances They continue to be supported as they have been in older releases and will be accepted by the compiler Compiler options can be set in t
2. define Z8ENCOR E F642X define SIMULATE genprintf NOkeepasm NOkeeplst NOlist NOlistinc model L NOoptlink promote regvar 8 reduceopt stdinc C PROGRA 1 ZiLOG ZDSII_ 3 0 include std C PROGRA 1 ZiLOG ZDSII_ 3 0 include zilog C PROGRA 1 ZiLOG ZDSII_ 3 0 include zilog Z8ENCO 2 debug NOrevaa cpu Z8F6423 asmsw cpu 28F6423 define Z8F6423 1 define Z8ENCORE 64K SERIES 1 define Z8ENCORE F642X 1 define SIMULATE 1 include C PROGRA 1 ZiLOG ZDSII_ 3 0 include std C PROGRA 1 ZiLOG ZDSII_ 3 0 include zilog C PROGRA 1 ZiLOG ZDSII_ 3 0 include zilog Z8Encore F642X NOrevaa assembler option define Z8F6423 1 define Z8ENCORE 64K S s RIES 1 H I define Z8ENCOR E F642X 1 define SIMULATE 1 zy include C NVPROGRA include zilog C P list NOlistmac warn debug NO 1 ZiLOG ZDSII_ 3 0 include std C PROGRA 1 ZiLOG ZDSII_ 3 0 ROGRA 1 ZiLOG ZDSII_ 3 0 include zilog Z8ENCO 2 name pagelen 56 pagewidth 80 quiet sdiopt igcase NOrevaa cpu Z8F6423 FORMAT OMF695 INTEL32 map maxhexlen 64 NOquiet sort name ascending unresolved fatal NOwarnoverlap NOxref warn debug NOigcase RANGE ROM 000000 RANGE RDATA 000020 RANGE EDATA 00
3. Synopsis include lt eZ8 h gt intrinsic void SET VECTOR int vectnum void hndlr void where vectnum is the interrupt vector number for which the interrupt handler hndir is to be set hndlr is the interrupt handler function pointer The hnd1r function must be declared to be of type interrupt with no parameters and return void no parameters and no return UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zzilog as The following values for vectnum are supported for most Z8 Encore parts all those that do not fall into the more specific categories covered in the next two tables RESET P4AD WDT P3AD TRAP P2AD TIMER2 PIAD TIMERI POAD TIMERO TIMER3 UARTO RX UARTI RX UARTO TX UARTI TX Dc DMA SPI C3 ADC C2 P7AD Cl P6AD CO P5AD The following values for vectnum are supported for Z8 Encore Motor Control CPUs RESET CO WDT PB TRAP PTA PWMTIMER P3A PWMFAULT P6A ADC P2A CMP PSA TIMERO PIA UARTO RX P4A UARTO_TX POA SPI POTRAP Dc WOTRAP UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog 174 The following values for vectnum are supported for the Z8 Encore XP 16K Series RESET P4AD WDT P3AD TRAP P2AD TIMER2 PIAD TIMERI POAD TIMERO MCT UARTO RX UARTI RX UARTO TX UARTI TX Dc C3 SPI C2 ADC CI P7AD CO P6AD POTRAP P5AD WOTRAP Returns None Example finclu
4. ooooooo 334 What is the difference between the Interrupt mode and the Poll mode mthe VARTS coude II Rs en and SAE ne UN 335 What are the default settings for the UART device 0 002 eee eee 335 How can I change the default UART settings for my application 335 I am using the UART in the interrupt mode Why do I seem to lose some of the data when I try to print or try to receive a large amount of data 335 When I call open UARTXx function by configuring it in INTERRUPT mode the control never comes back to my program and my program behaves indifferently Why is this 0 2 eect eens 335 Where can I find sample applications that demonstrate the use of ZSL 335 I have used init_uart and other functions provided in the RTL Do I need to change my source code because of ZSL nonn eee 336 C Standard Library 2 2 e rre E temp IPRC IEEE T QA edv 337 Standard Header Piles eos eee RR Rte i RP REOR RR e IR eats 338 Diagnostics lt assert h gt eeseseeeel e 338 Character Handling lt ctype b gt 2 0 0 0 cette ees 339 Errors SHO cias ORG eee teed Reade A BERGE dU nea ed Beek ead 340 Floating Point lt float h gt 2 2 0 0 ect neeeeenen eee 340 Limits lt limits b gt 2 eect eee teen nes 342 Mathematics math h 2 0 2 eannan nare 343 Nonlocal Jumps setjmp h 2 0 0 0 cece enna 345 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8
5. Examples unresolved fatal or UNRESOLVED IS FATAL WARN The WARN command specifies 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 WARN lt warn filename UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual 288 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 gt lt 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 Syntax NO warnoverlap LINKER EXPRESSIONS This section describes the operators and their operands that form legal linker expressions e Add on page 289 e amp And on page 289 BASE OF on page 290 e COPY BASE on page 291 e COPY TOP on page 291 e Divide on page 291 e FREEMEM on page 291 e HIGHADDR on page 291 e L
6. Figure 37 New Project Dialog Box Build Options 11 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 137 select static or dynamic frames see Call Frames on page 138 and click Next For executable projects the Target and Debug Tool Selection step of the New Project Wizard dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi New Project Wizard Step 2 Target and Debug Tool Selection Target A target is a logical representation of a target V Use page erase before flashing system Select the available Target target that best fits your target system or create your own v ZaF158001282COG ZDS Default Click Setup to configure the O 29F 169001 44Zc0G ZDS Default target as needed Refer to the User Manual for details on managing and configuring targets Debug Tool A debug tool Setup Add Copy Delete represents debug Debug Tool communication hardware such n as the USB Smart Cable or a Current Simulator E simulator Select the debug lt lt Back Nest Finish Cancel Figure 38 New Project Wizard Dialog Box Target and Debug Tool Selection 12 Select the Use Page Erase Before Flashing check box if you want the internal Flash to be page erased
7. csiof8pinlsd lib UMO13033 0508 C serial IO library for 8 pin large static model with debug information Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual o f fi li I Table 5 Linker Referenced Files Continued File Description csiof8pinsd lib C serial IO library for 8 pin small dynamic model no debug information csiof8pinsdd lib C serial IO library for 8 pin small dynamic model with debug information csiof8pinss lib C serial IO library for 8 pin small static model no debug information csiof8pinssd lib C serial IO library for 8 pin small static model with debug information 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 The following table shows the list of symbols that might be defined in the linker command file depending on the compilation memory model that you selected Table 6 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 linki
8. ncy 18432000 C PROGRA 1 ZiLOG ZDSII_ 3 0 lib zilog startupL obj Amain obj C PROGRA 1 ZiLOG ZDSII_ 3 0 lib std chelpD 1lib C C C Cc Ij SPACE ALLOCATION PROGRA 1 ZiLOG ZDSII_ 3 0 lib std crtLDD 1ib PROGRA 1 ZiLOG ZDSII_ 3 0 lib std fpLDD 1lib PROGRA 1 ZiLOG ZDSII_ 3 0 lib zilog csioLDD 1lib PROGRA 1 ZiLOG ZDSII_ 3 0 lib zilog zsldevinitdummy obj Space Base Top Size EDATA E 0100 E 0102 3h RDATA R EO R EF 10h ROM C 0000 C 00E7 e8h SEGMENTS WITHIN SPACE UM013033 0508 Gl Using the Linker Locator 296 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ EDATA Type Base Top Size FAR BSS normal data E 0100 E 0102 3h RDATA Type Base Top Size workingreg absolute data R EO R EF 10h ROM Type Base Top Size __ flash optionl s absolute data C 0000 C 0000 1h flash option2 s absolute data C 0001 C 0001 1h __ VECTORS 002 absolute data C 0002 C 0003 2h VECTORS 004 absolute data C 0004 C 0005 2h VECTORS 006 absolute data C 0006 C 0007 2h __ VECTORS 008 absolute data C 0008 C 0009 2h __ VECTORS 00A absolute data C 000A C 000B 2h VECTORS 00C absolute data C 000C C 000D 2h __ VECTORS OOE absolute data C 000E C 000F 2h VECTORS 010 absolute data C 0010 C 0011 2h VECTORS 012 absolute data C 0012 C 0013 2h VECTORS 014 absolute data C 0014 C 0015 2h VECTORS 0
9. A SPACE clause defines the address space in which the segment resides The linker groups together segments with the same space identification See Address Spaces on page 211 for available spaces Syntax lt space_clause gt gt SPACE lt ident gt Examples DEFINE fdata SPACE EData ALIGN 2 Aligns on 2 byte boundary relocatable DS Defines storage locations that do not need to be initialized Synonym block Syntax define storage gt DS value Examples NAME DS 10 Reserve 10 bytes of storage DS 22 Reserve 22 bytes of storage END Informs the assembler of the end of the source input file If the operand field 1s present it defines the start address of the program During the linking process only one module can have a start address otherwise an error results The END directive 1s optional for those modules that do not need a start address NOTE Any text found after an END directive is ignored Synonym end Syntax end directive gt END lt expression gt UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual A 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
10. C startup for small model startupl obj C startup for large model startupf0las obj C startup object file for 1K XP small model startupf0lal obj C startup object file for 1K XP large model startupf04as obj C startup object file for 4K XP small model startup f04al obj C startup object file for 4K XP large model Startupf1680s obj C startup object file for 16K XP small model Startupf16801 0bj C startup object file for 16K XP large model UMO13033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Table 5 Linker Referenced Files Continued File Description fpdumyl lib Floating point do nothing stubs for large model no debug information fpdumyld lib Floating point do nothing stubs for large model with debug information fpdumys lib Floating point do nothing stubs for small model no debug information fpdumysd lib Floating point do nothing stubs for small model with debug information chelp lib Code generator helper routines no debug information chelpd lib Code generator helper routines with debug information pchelp lib Code generator helper routines in pram no debug information pchelpd lib Code generator helper routines in pram with debug information ertld lib C run time library for large dynamic model no debug information ertldd lib C run time library for large dynamic m
11. Figure 111 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 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOO Symbols Window Click the Symbols Window button to show or hide the Symbols window PROCEDURES LOCATION VARIABLE Z8F0823_8PIN Z8F1680 Z8FMCO4100 ZS8F 8 ZS8F 4 Z8F2480XN Z8F2480XM Z8F2480XJ Z8F2480XH ZS8F 830A Z8FMC16100 Z8F1680XN Z8F1680XM Z8F0480XN Z8FMC16 Z8F1680XJ Z8F0480XM 78F1 da Figure 112 Symbols Window NOTE Close the Symbols window before running a command script The Symbols window displays the address for each symbol in the program UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOQ Disassembly Window Click the Disassembly Window button to show or hide the Disassembly window Disassembly Address 0205 FFBZEED602 Illegal Instruction gt 0204 10D6 RLC D6 020C 00 BRK 020D 3E INC R3 gt 020E 8BFE JR 20E Last modii Figure 113 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 After performing a reset the Disassembly
12. NOTE To add your own configuration s see Manage Configurations on page 104 Use one of the following methods to activate a build configuration Using the Select Configuration dialog box See Set Active Configuration on page 103 Using the Build toolbar See Select Build Configuration List Box on page 18 Use the Project Settings dialog box to modify build configuration settings See Settings on page 55 Manage Configurations For your specific needs you can add or copy different configurations for your projects To add a customized configuration do the following 1 From the Build menu select Manage Configurations The Manage Configurations dialog box is displayed Manage Configurations Debug Release Remove Copy Close Figure 74 Manage Configurations Dialog Box UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZILOQ us 2 From the Manage Configurations dialog box click Add The Add Project Configuration dialog box is displayed Add Project Configuration Configuration Name l Copy settings from Debug Figure 75 Add Project Configuration Dialog Box 3 Type the name of the 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 b
13. Run Command Button on page 22 e Stop Command Button on page 22 Command Field on page 22 E Figure 19 Command Processor Toolbar See Supported Script File Commands on page 413 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 Bookmarks Toolbar The Bookmarks toolbar allows you to set remove and find bookmarks with the following buttons Set Bookmark Button on page 23 Next Bookmark Button on page 23 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Previous Bookmark Button on page 23 Delete Bookmarks Button on page 23
14. Save as type Make Files mak Y Cancel Figure 72 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 3 Type the make file name in the File Name field You do not have to type the extension mak The extension is added automatically 4 Click Save 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 to select or add configurations for your project The Build menu has the following commands e Compile on page 103 e Build on page 103 e Rebuild All on page 103 Stop Build on page 103 e Clean on page 103 Update All Dependencies on page 103 e Set Active Configuration on page 103 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZILOQ us Manage Configurations on page 104 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 a of the files in your project This option also l
15. Zilog Developer Studio ll Z8 Encore User Manual Zilog Use Page Erase Before Flashing Select the Use Page Erase Before Flashing check box if you want the internal Flash to be page erased Deselect this check box if you want the internal Flash to be mass erased Target Select the appropriate target from the Target list box The selected target name is displayed in the Debug output window after you click the Reset button available from the Build toolbar or Debug toolbar Setup Click Setup in the Target area to display the Configure Target dialog box Configure Target Z8F 1680 Clock Source Internal External Clock Frequency MHz 0 04320 1 38420 0 08640 C 2 76480 C 0 34550 5 52960 C 0 69120 C 11 05920 C Other Cancel Figure 66 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 39 or the General page of the Project Settings dialog box see General Page on page 56 1 Select the internal or external clock source 2 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 be supplied from the target application board
16. BLKB 16 Allocate 16 uninitialized bytes BLKB 16 1 Allocate 16 bytes and initialize them to 1 BLKL Declaration Type Syntax BLKL number of longs 32 bits each init value Examples BLKL 16 Allocate 16 uninitialized longs BLKL 16 1 Allocate 16 longs and initialize them to 1 BLKW Declaration Type Syntax BLKW number of words 16 bits each init value UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual d Examples BLKW 16 Allocate 16 uninitialized words BLKW 16 1 Allocate 16 words and initialize them to 1 DB Declaration Type Synonyms byte ascii asciz DEFB FCB STRING STRING byte 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 except that a trailing null is added for the otherwise identical asciz declaration type DD Declaration Type Synonym double Syntax DD double signed floating point value 32 bits Example DD 0 1 16 42 Reserve space for 2 64 bit double precision Signed floating point numbers Initialize the first with 0 1 and the last with 16 42 DF Declaration Type Synonym float Syntax DF word signed floating poin
17. Computes the principal value of the arc cosine of x A domain error occurs for arguments not in the range 1 1 Synopsis dinclude lt math h gt double acos double x Returns The arc cosine in the range 0 pi Example double y 0 5635 double x x acos y Computes the principal value of the arc sine of x A domain error occurs for arguments not in the range 1 1 Synopsis include lt math h gt double asin double x Returns The arc sine in the range pi 2 pi 2 Example double y 1234 double x x asin y Computes the principal value of the arc tangent of x Synopsis dinclude lt math h gt double atan double x UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f Z f I V MV M 354 amu Returns The arc tangent in the range pi 2 pi 2 Example double y 1234 double x x atan y atan2 Computes the principal value of the arc tangent of y x using the signs of both arguments to determine the quadrant of the return value A domain error occurs if both arguments are Zero Synopsis include lt math h gt double atan2 double y double 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 atof Converts the string pointed to by nptr to double representation Except for the behavior on error atof is equivalentto strtod nptr
18. Disables global dead variable removal pragma globalfold Enables global constant folding pragma noglobalfold Disables global constant folding pragma intrinsics lt state gt Defines whether the compiler defined intrinsic functions are to be expanded to inline code NOTE The intrinsic property is only available for compiler defined intrinsic functions user defined intrinsics are not supported lt state gt can be ON or OFF This pragma with lt state gt ON is the default pragma nointrinsics Disables the INTRINSICS switch UM013033 0508 Compatibility Issues Zilog Developer Studio ll Z8 Encore User Manual pragma nobss Does not put uninitialized static data in bss segment instead it puts it in data segment and initializes it at link time pragma jumpopt Enables jump optimizations pragma nojumpopt Disables jump optimizations pragma localcopy Enables local copy propagation pragma nolocalcopy Disables local copy propagation pragma localcse Enables local common subexpression elimination pragma nolocalcse Disables local and global common subexpression elimination pragma localfold Enables local constant folding pragma nolocalfold Disables local constant folding pragma localopt Enables all local optimizations pragma nolocalopt Disables all local optimizations pragma noopt Disables all optimizations pragma optlink Enables optimi
19. One of the reasons could be that the software FIFO buffer size is small Try increasing the size to a bigger value The default size of the software FIFO is 64 The software FIFO size is defined in the zsldevinit asm file as the BUFF SIZE macro WHEN I CALL OPEN UARTX FUNCTION BY CONFIGURING IT IN INTER RUPT MODE THE CONTROL NEVER COMES BACK TO MY PROGRAM AND MY PROGRAM BEHAVES INDIFFERENTLY WHY IS THIS The open UARTx function calls the control UARTx function which enables the UART interrupt As a result of this the UARTx transmit empty interrupt is generated immediately If the ISR for UART is not installed the control on the program might be lost So install the ISR before calling open UARTx in the INTERRUPT mode This is not a problem when the standard boot module is used WHERE CAN I FIND SAMPLE APPLICATIONS THAT DEMONSTRATE THE USE OF ZSL The ZDS II installation includes two different directories called Applications and Sam ples In both of these directories all projects using devices supported by ZSL are config ured to use it The main difference between the directories is that the applications UM013033 0508 Zilog Standard Library Notes and Tips Zilog Developer Studio ll Z8 Encore User Manual Z ILOU ace demonstrate the use of direct ZSL APIs and the samples demonstrate the indirect use of ZSL using RTL calls I HAVE USED INIT UART AND OTHER FUNCTIONS PROVIDED IN THE RTL DOIN UM013033 0508 E
20. Recode to pass a string literal For example the code in the example can be revised as follows define MSG1 x 34d char buff sizeof MSG1 4 sprintf buff MSG1 x OK 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 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Nod ILU LUJ V MV M 208 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 string calls for and the inline generation of printf calls is requested For example printf x 4d n 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 4d n x y The format string is parsed and the extra arguments are ignored 255 Missing declaration of s printf he
21. SZDSII_Z8Encorel_4 11 0 samples Tut Project Type Standard y CPU Family Z8Encore XP F1 B80 Series 16K y CPU Z8F1680 J Build Type Executable Continue Finish Cancel Figure 35 New Project Dialog Box UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog 2 From the New Project dialog box click on the Browse button b to navigate to the directory where you want to save your project The Select Project Name dialog box is displayed Select Project Name Look in G Tutorial 0 e Eg File name Files of type Project Files zdsproj y Cancel Figure 36 Select Project Name Dialog Box 3 Use the Look In drop down list box to navigate to the directory where you want to save your project 4 Inthe File Name field type the name of your project 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 5 Click Select to return to the New Project dialog box 6 Inthe Project Type field select Standard for a project that will include C language source code Select Assembly Only for a project that will include only assembly source code 7 Inthe CPU Family drop down list box select a product family 8 Inthe CPU drop down list box select a CPU 9 Inthe Build Type drop down list box s
22. The RData memory is located in 00H FFH and is used for a small memory model The low boundary is set to 10H by default The low boundary needs to be set by 10H higher for one level of interrupts For example for a non nesting interrupt set the low boundary to 20H for two levels of interrupts set the low boundary to 30H and so on For more information about interrupts see SET VECTOR on page 172 e EData extended data EData is used for default data storage in the large memory model The EData memory begins at data address 100H and extends to a maximum of EFFH Some CPUS provide less data memory so the upper bound of this range will be less than EFFH This reduced upper bound is displayed by default in the GUI when one of those parts is selected as the CPU in your project See the product specification for your particular CPU to find out how much on chip RAM is provided NOTE If your CPU is one ofthe Z8 Encore XP F1680 Series devices that has PRAM and you choose not to use the PRAM memory by deselecting the Use PRAM check box then the 512 or 1024 bytes that could have been used for PRAM will instead be available as additional EData memory and will be mapped onto the end of EData If you want to use this additional data storage you must modify the upper bound of your EData range to add the extra memory For example if your upper EData bound previously was 3FF and you choose not to use the available 512 bytes 200H of PRAM you can
23. UM013033 0508 Using the Integrated Development Environment 35 Zilog Developer Studio ll Z8 Encore User Manual Zilog Build Output Window The Build Output window holds all text messages generated by the compiler assembler librarian and linker including error and warning messages Y C PROGRA 1 ZiL0G ZDSII_ 2 0 samples STARTE 1 source main c Linking FATAL ERROR 724 gt Symbol _ case C XPROGRA 1VZiLOGVZDSII 2 0XlibistdicrtD lib is not defined uild completed Build Debug Find in Files Find in Files 2 Messages Command 4 Figure 28 Build Output Window Debug Output Window The Debug Output window holds all text messages generated by the debugger while you are in Debug mode The Debug Output window also displays the chip revision identifier and the Smart Cable firmware version XllConnected to target Simulator E Starting debug session project starter configuration Debug q gt K Build Debug Find in Files A Find in Files 2 A Messages A Command 7 4 gt Figure 29 Debug Output Window Find in Files Output Windows The two Find in Files Output windows 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 49 zi ledblink asm 53 SCKSEL EQU SCK_CLKIN
24. UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog ase setting maximum size 283 setting ranges 285 H Headers architecture specific functions 162 character handling 339 diagnostics 338 error reporting 340 floating point 340 general utilities 347 input 346 limits 342 location 161 338 mathematics 343 nonlocal jumps 345 nonstandard 161 nonstandard input functions 163 nonstandard output functions 163 output 346 reserved words 161 standard 337 standard definitions 346 string handling 349 variable arguments 345 ZSL 332 HEADING command 282 Help menu 128 About 129 Help Topics 128 Technical Support 129 Hex button 113 hex file extension 95 Hexadecimal Display check box 127 Hexadecimal numbers in linker expressions 293 viewing 322 Hexadecimal numbers in assembly 223 HIGH operator 222 HIGH 16 operator 222 Index HIGHADDR operator 291 HUGE VAL macro 343 348 Hyperbolic cosine computing 358 Hyperbolic functions 344 Hyperbolic sine computing 382 Hyperbolic tangent calculating 393 I IDE definition 15 IEEE 695 format 95 281 IF directive 257 IFDEF directive 258 IFMA directive 259 261 IFSAME directive 258 Ignore Case of Symbols check box 58 In File Types list box 50 In Folder list box 50 INCLUDE directive 236 include directive 66 Include Serial in Burn check box 113 Include Zilog Standard Library Peripheral Support check box 79 Included in Project button 86 Includes fi
25. User Manual 13 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 hex file to Flash memory by writing a segment of data and then reading back the segment and verifying that it has been written correctly 14 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 NOTE Ifyou want to run the program that you just flashed use the following procedure 15 After you see Flashing complete in the Status area of the Flash Loader Processor dialog box click Close to close the dialog box 16 Remove the power supply followed by the USB Smart Cable 17 Reconnect the power supply Serialization The general procedure to write a serial number to a Flash device involves the following steps 1 Choose a location for the serial number inside or outside of the address range defined in the hex file NOTE The serial number must be written to a location that is not being written to by the hex file 2 Erase the Flash device 3 Write the hex file to the Flash device and then write the serial number or write the serial number to the Flash device and then write the hex file Use the following procedure if you want to use the ser
26. User Manual Nod ILUO LUI EN M 56 C Preprocessor Page on page 67 not available for Assembly Only projects C Advanced Page on page 69 not available for Assembly Only projects C Deprecated Page on page 72 not available for Assembly Only projects Librarian Page on page 77 available for Static Library projects only ZSL Page on page 78 not available for Assembly Only projects Linker Commands Page on page 80 available for Executable projects only Linker Objects and Libraries Page on page 84 available for Executable projects only Linker Address Spaces Page on page 89 available for Executable projects only Linker Warnings Page on page 91 available for Executable projects only Linker Output Page on page 93 available for Executable projects only Debugger Page on page 96 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 those tools 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 fil
27. lil Project Settings Configuration Debug x 5e General h Assembler Fill c Use Register Variables 3 Code Generation Iv Generate Prints Inline h Listing Files 3 Preprocessor x Se Deprecated Bitfield Packing MostCompact v 5 ZSL fi Linker SS Commands Sil Objects and Libraries 3 Address Spaces SS Warnings SS 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 Cancel Help Figure 12 Advanced Page of the Project Settings Dialog Box 9 Select the Output page 10 Make certain that both the IEEE 695 and Intel Hex32 Records check boxes are selected UMO13033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual zilogi li Project Settings Configuration Debug y 5e General OU to Sis Assembler Output File Name T s CERE C Program FilesziLOG ZDSIl Z8Encore 4 11 0 samples Tut 3 Listing Files V Generate Map File E cl Sort Symbols By Name Address vance Deprecated Show Absolute Addresses in Assembly Listings 5s ZSL Executable Formats IEEE 695 FE Linker Intel Hex32 Records SS Commands SS Objects and Libraries Fil Unused Hex File Bytes with OxFF Si Address Spaces Maximum Bytes per Hex File Line 64 y 3 Warnings Debugger Note Figure 13 Output Page of the Project Settings Dialog Box The e
28. r isalpha c iscntrl Tests for any control character Synopsis include lt ctype h gt int iscntrl int c Example int r char c NULL r iscntrl c isdigit Tests for any decimal digit Synopsis include lt ctype h gt int isdigit int c Example int tf char c 4 r isdigit c UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual T IION ILU LI V MV M 363 dd C Standard Library Zilog Developer Studio ll Z8 Encore User Manual IION NULL V MV M 364 au isgraph Tests for any printing character except space Synopsis include lt ctype h gt int isgraph int c Example int 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 isprint Tests for any printing character including space Synopsis include lt ctype h gt int isprint int c Example int r char c 1 r isprint c UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i 1l rfl 1 LJl V MV M 365 amu 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 f char c a r ispunct c isspace Tests for the following white space characters space
29. s src Cancel Figure 48 Add Files to Project Dialog Box 2 Usethe Look In drop down list box to navigate to the appropriate directory where the files you want to add are saved 3 Click on the file you want to add or highlight multiple files by clicking on each file while holding down the Shift or Ctrl 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 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 103 The Project Settings dialog box has different pages you must use to set up the project General Page on page 56 Assembler Page on page 59 e C Code Generation Page on page 61 not available for Assembly Only projects C Listing Files Page on page 65 not available for Assembly Only projects UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore
30. ss is assigned an address Oxeff rom char init char At Oxffff 33 init char is in rom and initialized to 33 NOTE Only placed variables with rom storage class specifier 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 Oxef0 char ch2 At char ch3 At This places ch1 at address 0xef0 ch2 at the next address 0xef1 after ch1 and ch3 at the next address 0xe 2 after ch2 The At directive can only be used after a previous Ator 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 NOTE Only aligned variables with the rom storage class specifier 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 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 t
31. 255 levels Nested SELSEIF and SELSE directives are associated with the most recent SIF directive There is no preset limit on the number of statements that can appear in the statements sections there can be any number of assembler statements in each statements section including zero The operating system file system might impose limitations on file sizes and the user needs to consult the appropriate operating system users guide for such limitations Each expression must be a conditional expression See Expressions on page 220 e The IF and SENDIF directives must be coded in matching pairs That is it is not legal to code an SIF directive without a matching SENDIF directive appearing later in the source module nor is it legal to code an ENDIF directive without a matching SIF directive appearing earlier in the source module The SELSEIF and SELSE assembler directives can only appear between enclosing SIF and SENDIF directives It is not valid for the SELSEIF and SELSE directives to appear in any other context The SELSE directive does not have any parameters The SENDIF directive does not have any parameters UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual e H I PES PN Z I1 Of V MV M 252 I None of the SIF SELSEIF SELSE and EN
32. 255 levels Nested SBREAK nested The structured assembly test directives can be nested up to and SCONTINUE directives are associated with the most recent SREPEAT directive There is no prese t limit on the number of statements that can appear in the statements sections there can be any number of assembler statements in each statements section including zero T he operating system file system might impose limitations on file sizes and the user needs to consult the appropriate operating system users guide for such limitations The SREPEAT and UNTIL directives must be coded in matching pairs That is it is not legal to code a SREPEAT directive without a matching SUNTIL directive appearing later in the source module nor is it legal to code an SUNTIL directive without a matching SREPEAT directive appearing earlier in the source module Using the Macro Assembler The SBREAK and CONTINUI enclosing directives It is not valid for the SBREAK and any other context Zilog Developer Studio ll Z8 Encore User Manual A a Z ii 0 0 V MV M I E assembler directives can only appear between REPEAT and SUNTIL directives or between SWHILE and SWEND SCONTINUE directives to appear in The BREAK directive has an optional 1F conditional parameter The SCONTINUI
33. 9 9 2 TE 3 9 9 TE 3 9 9 2 3 include lt stdio h gt define ZDS NAME ZiLOG Developer Studio void main Bears the R Paste Show Whitespace relcome Welcome to ZDS NAME 3 Hello world Insert Breakpoint Edit Breakpoints Reset Go Run To Cursor Insert Bookmark Next Bookmark Previous Bookmark Remove Bookmarks Figure 27 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 e 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 F2 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 Select Next Bookmark from the Edit menu Press the F2 key The cursor moves forward through the file starting at its current position and beginning again when the end of file 1
34. Deselect this check box if you want the internal Flash to be mass erased 13 Select the appropriate target from the Target list box 14 Click Setup in the Target area Refer to Setup on page 97 for details on configuring a target NOTE Click Add to create a new target see Add on page 98 or click Copy to copy an existing target see Copy on page 99 15 Select the appropriate debug tool and if you have not selected the Simulator click Setup in the Debug Tool area Refer to Debug Tool on page 100 for details about the available debug tools and how to configure them 16 Click Next The Target Memory Configuration step of the New Project Wizard dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi New Project Wizard 3 Target Memory Configuration Linker Address Spaces Use the provided fields to define the p Ensure that the ranges below are valid for your target The ranges of available memory on ranges below were initialized based on the selected CPU your target system This ROM RData information allows the developer s environment to 000000 003FFF 000020 0000FF inform you when your code or EData NVDS data has grown beyond your a001 00 0007FF 000000 0000FF system s capability and to V PRAM automatically locate your code 00 000 00 3FF or data m Linker Address Spaces
35. E directive has an optional 1F conditional parameter None of the SREPEAT SBREAK SCONTINUE and SUNTIL assembler directives can be labeled If a label is specified a warning message is issued and the label is discarded WHILE Structured Assembly Block Inputs The Syn W SBRI SWI SWHILE SBREAK tax SCONTINUE and SWEND assembler directives are used to test execution time conditions and conditionally execute object code based on the results of the test HILE condition comment statemen ts statements EAK SIF condition2 comment CONTINUE IF condition3 comment statements END comment The following qualifications elaborate the syntax and semantics of the structured assembly test directives Unless otherwise specified violations of these qualifications cause the assembly to fail UM013033 0508 The SWHILI The SBREA E and Swi END assembler directives must be specified in that order K assembler directive is optional It can be specified an arbitrary number of times between the SWHILE and SWEND assembler directives The SCONTINUI number of times between the SWHILE and SWI E assembler directive is optional It can be specified an arbitrary END directives Any valid assembler statement can appear in the statements sections of the
36. Figure 20 Bookmarks Toolbar NOTE This toolbar is not displayed in the default IDE window Set Bookmark Button Click the Set Bookmark button to insert a bookmark in the active file for the line where your cursor is located Next Bookmark Button Click the Next Bookmark button to position the cursor at the line where the next book mark in the active file is located Previous Bookmark Button Click the Previous Bookmark button to position the cursor at the line where the next book mark in the active file is located Delete Bookmarks Button Click the Delete Bookmarks button to remove all of the bookmarks in the currently loaded project Debug Toolbar The Debug toolbar allows you to perform debugger functions with the following buttons e Download Code Button on page 24 Verify Download Button on page 25 Reset Button on page 25 e Stop Debugging Button on page 25 Go Button on page 25 Run to Cursor Button on page 26 Break Button on page 26 Step Into Button on page 26 Step Over Button on page 26 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual IION ILU LUI EN M 24 Step Out Button on page 26 Set Next Instruction Button on page 26 Insert Remove Breakpoint Button on page 21 Enable Disable Breakpoint Button on page 21 Disable All Breakpoints Button on page 27 Remove All Breakpoints Button on page
37. 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 crtldd lib and fpldd lib in this example No unnecessary code is linked in and you avoid the extra work of painstakingly finding the unresolved symbols and linking only to those specific func tions ANSI STANDARD COMPLIANCE The Zilog Z8 Encore C Compiler is a freestanding ANSI C compiler see Freestanding Implementation on page 189 complying with the 1989 ISO standard which is also known as ANSI Standard X3 159 1989 with some deviations which are described in Deviations from ANSI C on page 190 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 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual J fl mm PY
38. 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 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 lt expression gt lt expression gt 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 UM013033 0508 Using the Linker Locator Syntax TOP OF lt name gt Zilog Developer Studio ll Z8 Encore User Manual Zn E ZIt Og 294 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 start
39. The Debugger tab contains the following check boxes Select the Save Project Before Start of Debug Session check box to save the current project before entering 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zzilogi 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
40. Z rio tT n i tJ LI l 46 V U 190 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 float 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 Z8 Encore 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 193 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 Z8 Encore 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 Z8 Encore CPU These extensions are described in Language Extensions on page 132 Deviations from ANSI C The differences between the Zilog Z8 Encore C Compiler and the freestanding imple mentation of ANSI C Standard consist of both extensions to the ANSI standard and devia tions from the behavior described by the standard The extensions to the ANSI standard are explained in Language Extensions on page 132 The
41. a binary file or a text file to a specified memory space at a specified address The functionality 1s similar to the Load from File command available from the context menu in the Memory window see Load ing from a File on page 319 The following is the syntax of the 10admem command loadmem SPACE displayed spacename FORMAT HEX BIN TEXT lt PATH name gt STARTADDRESS lt hexadecimal address gt If STARTADDRESS is not specified the data is loaded at the memory lower address For 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 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual sets the file name for the script 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 makfile and makefile commands export a make file for the current project The syntax can take one of two forms makfile lt path file name gt
42. chelpD lib Version 1 0 05 03 2006 09 17 42 Segment flash optionl segment C 0000 C 0000 lh Module COMMON FLASH2 C Library chelpD lib Version 1 0 05 03 2006 09 17 42 Segment flash option2 segment C 0001 C 0001 1h Module common frame asm Library chelpD lib Version 1 0 05 03 2006 09 17 42 Segment CODE C 0039 Cc 005 24h Module common framer asm Library chelpD lib Version 1 0 05 03 2006 09 17 42 UM013033 0508 Using the Linker Locator chelpD lib C 005D Version Zilog Developer Studio ll Z8 Encore User Manual Zilog chelpD lib Version chelpD lib Version chelpD lib Version chelpD lib Version Segment CODE Module common vect04 asm Library 09 17 43 Name Segment _ VECTORS 004 Module common vect06 asm Library 09 17 43 Name Segment _ VECTORS 006 Module common vect08 asm Library 09 17 43 Name Segment _ VECTORS 008 Module commonivect0a asm Library 09 17 43 Name Segment VECTORS 00A Module commonivect0c asm Library 09 17 43 Name Segment VECTORS 00C Module commonivect0e asm Library 09 17 43 Name chelpD lib Version C 006B fh 1 0 05 03 2006 Top Size C 0005 2h 1 0 05 03 2006 Top Size C 0007 2h 1 0 05 03 2006 Top Size C 0009 2h 1 0 05 03 2006 Top Size C 000B 2h 1 0 05 03 2006 Top Size C 000D 2h UMO13033 0508 Using the Linker Locator 299 che
43. gle address space is used for all memory will be considered Harvard architectures are of course quite common in embedded system processors to give better performance within the constraints of the limited resources available to these processors In the Harvard architecture pointers to the normal data space and pointers into ROM space are generally required to be distinct types In Z8 Encore this difference can also be seen at the machine instruction level where a separate instruction LDC must be generated UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual iH PES NT 7 IIO 0 EN M 74 by the compiler to load data from the ROM space That means that if constants are placed in ROM a different function must be called ifa const pointer is used as a function parameter than the function that is called for a non const pointer type For example con sider the following code char const quote Ask not char buffer 80 rom src strcpy buffer quote OK if CONST ROM parameter type mismatch if not strcpy buffer quote Parameter type mismatch if const ROM OK otherwise The top form shown here calls a function whose signature is char rom src strcpy void dest rom void source whereas the standard function strcpy has the more usual signature char strcpy void dest const void source The top form succeeds in this code
44. 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 assem bler Each page of the listing file 1st contains the following UM013033 0508 Heading with the assembler version number Source input file name Date and time of assembly Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 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 content of the listing file can be controlled with directives included in the source file e NEWPAGE 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 see Show Absolute Addresses in Assembly Listings on page 95 This option uses the information in the src file generated by the com
45. lt project name gt z spro j You do not have to type the extension zdspro j It is added automatically Click Select to return to the New Project dialog box In the Project Type field select Standard because the sample project uses c files In the CPU Family drop down list box select Z8Encore XP F1680 Series 16K In the CPU drop down list box select Z8F1680XJ In the Build Type drop down list box select Executable to build an application Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog New Project Project Name C Program Files ZiLOG ZDSII_Z8Encore _4 11 0 samples Tut Project Type Standard y CPU Family Z8Encore XP F1 B80 Series 16K y CPU Z8F15800 J Build Type Executable Continue Finish Cancel Figure 3 New Project Dialog Box 10 Click Continue The New Project Wizard dialog box is displayed It allows you to modify the initial values for some of the project settings during the project creation process 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 is your application If you Iv Standard C Startup Module plan to provide your own F7 C Runtime Library startup code uncheck the option Iv Floating Point Library requires the C Runtime Library E p Select the appropriate memory model from the
46. 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 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 cannot be of same type as the structure itself UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual T I JR sm f ZILOQ ICY Uy 205 I 195
47. place the scalar parameters not structures or unions of the called function in registers R8 R13 starting from left to right Push the remaining parameters including the non scalar parameters on the stack for dynamic frame functions or load into the static locations for static frame functions For a varargs function a dynamic frame is always used no parameter is passed in register and all parameters are pushed on the stack in reverse order 2 Then call the function The call instruction pushes the return address on the top of the stack 3 Onreturn from the function the return address is automatically popped from the stack by the ret instruction 4 Onreturn from the called function if there were any stack parameters caller pops them off the stack or increments the stack pointer UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual The called function performs the following tasks 1 7 If the called function is a monitor function only push the existing value of the interrupt control register IRQCTL on the stack and disable interrupts Push the frame pointer onto the stack and allocate the local frame a Set the frame pointer to the current value of the stack pointer b Decrement the stack pointer by the size of locals and temporaries on stack if required Execute the code for the function If the function returns a scalar value place it in the return value registers
48. 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 oth erwise ignored The format is composed of zero or more directives from the following list one or more white space characters e an ordinary character not a conversion specification Each conversion specification is introduced by the character 9o After the the following appear in sequence e An optional assignment suppressing character e An optional decimal integer that specifies the maximum field width e 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 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 prece
49. 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 to be reused A local label cannot be imported or exported Example SLOOP JP SLOOP LAB JP LAB SCOPE SLOOP JP SLOOP LAB JP LAB UM013033 0508 Infinite branch to LOOP Infinite branch to LAB New local label scope Reuse SLOOP Reuse LAB Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 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 e The space of the segment in which the label is defined e The space provided in the EXTERN or XREF directive e Ifno s
50. 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 Assembler Page on page 59 NOTE 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 408 The following topics are covered in this section Address Spaces and Segments on page 211 Output Files on page 214 Source Language Structure on page 215 Expressions on page 220 Directives on page 226 Structured Assembly on page 248 Conditional Assembly on page 256 Macros on page 259 Labels on page 263 Source Language Syntax on page 264 Compatibility Issues on page 268 Warning and Error Messages on page 269 NOTE For more information about Z8 Encore CPU instructions see the eZ8 CPU Instruction Set Description section in the eZ8 CPU User Manual UM0128 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual ADDRESS SPACES AND SEGMENTS You access the memory regions of the Z8 Encore microcontroller by using segment direc tives A segment is a contiguous set of memory locations All segments are attached to exactly one memory space The Z8 Encore Assemble
51. 0508 Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual i IIAN 1 LJ MV M 405 I Table 9 Compiler Command Line Options Continued Option Name Description list Generates a 1is source listing file listinc Displays included files in the compiler listing file model model Selects the memory model Select S for the small memory model or L for the large memory model The default is L noasm Does not assemble the compiler generated assembly file nodebug Does not generate symbol debug information nofastcall Pass parameters in memory nofplib Does not link with floating point emulation library nogenprint A call to printf or sprintf parses the format string at run time to generate the required output nojmpopt Turns off application of branch optimizations 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 nooptlink Sets the call frame as dynamic This is the default nopromote Turns off ANSI promotion The nopromote option is deprecated noquiet Displays the title information This is the
52. 27 RY SH Ho COP O OM B Figure 21 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 Starting in version 4 10 0 the Download Code button can also program Flash memory A page erase is done instead of a mass erase for both internal and external Flash memory Use this button anytime during a debug session This button is not enabled when the target is the simulator NOTE The current code on the target is overwritten If ZDS II is not in Debug mode when the Download Code button is clicked the following process is executed 1 2 3 4 2 6 Initializes the communication to the target hardware Resets the device with a hardware reset by driving pin 2 of the debug header low Configures the device using the settings in the Configure Target dialog box Downloads the program Issues a software reset through the debug header serial interface Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If itis a C project ZDS II resets to the main function if it is found If ZDS II is already in Debug mode when the Download Code button is clicked the fol lowing process is executed l 2 Resets the device using a software reset Downloads the program NOTE You might need to re
53. 347 397 W wait bp script file command 434 wait script file command 434 WARN command 287 Warn on Segment Overlap check box 93 WARNING IS FATAL command 288 Warning messages ANSI C Compiler 193 assembler 269 generating 287 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOg az linker locator 305 suppressing 284 Warnings page 91 92 WARNOVERLAP command 288 Watch window 320 adding new variables 321 changing values 321 removing expressions 321 viewing ASCII values 322 viewing ASCIZ values 322 viewing decimal values 322 viewing hexadecimal values 322 viewing NULL terminated ASCII 322 Watch Window button 28 wchar t 346 347 White octagon 311 Window menu 128 Windows menu Arrange Icons 128 Cascade 128 Close 128 Close All 128 New Window 128 Tile 128 WITH directive 247 With Include Files check box 66 Workspace Window button 17 WRG 225 WRITE FLASH function 175 WRITE NVDS function 176 WRITE NVDS GET STATUS function 177 Writing characters 375 Writing output 372 382 Writing strings 376 wsp file extension 44 X XDEF directive 242 XREF directive 243 264 Index Y Yellow arrow 311 Yellow arrow on red octagon 311 Z Z8 Encore developer s environment IDE window 15 menus 37 software installation 1 system requirements xvi toolbars 16 tutorial 1 Z8 Encore family specific functions 164 Z8 Encore MC Emulator requirements xviii ZDATE 150 ZDS Default Directory button 99 ZDS
54. All options can be modified later Project gt Settings Next Finish Cancel Figure 39 New Project Wizard Dialog Box Target Memory Configuration 17 Enter the memory ranges appropriate for the target CPU 18 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi Open Project Look in O Tutorial Debug ni sample zdsproj File name Files of type zos II Project Files zdsproj Cancel Figure 40 Open Project Dialog Box 2 Usethe Look In drop down list box to navigate to the appropriate 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 see Recent Projects on page 47 To delete a project file use the Open Project dialog box Highlight the file and press the Delete key Answer the prompt accordingly 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 zdspro An alternate file extension is used if provided when the project is cre ated NOTE The lt project n
55. Command Output win dow FLASH HI ELP The current Flash Loader command options are displayed in the Command Output win dow Flash Options PBF Page erase 1s enabled instead of mass erase for internal and external Flash programming UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual ZIlOog ax Compatibility ssues The following sections describe assembler and compiler compatibility Assembler Compatibility Issues on page 437 Compiler Compatibility Issues on page 440 ASSEMBLER COMPATIBILITY ISSUES The following table shows the equivalences between Z8 Encore directives and those of other assemblers that are also supported by the Z8 Encore assembler ZMASM directives that are compatible with Z8 Encore directives are also listed The Z8 Encore assembler directives in the left column are the preferred directives but the assembler also accepts any of the directives in the right column Table 19 Z8 Encore Directive Compatibility Z8 Encore Assembler Compatible With ALIGN align ASCII ascii ASCIZ asciz ASECT ASECT ASG ASG ASSUME ASSUME BES bes BREAK SBREAK Sbreak BSS bss CHIP chip cpu CONTINUE SCONTINUE continue DATA data DB byte ascii DEFB FCB STRING STRING byte asciz DD double DEFINE define DF float DL long l
56. EData ALIGN 2 Aligns on 2 byte boundary relocatable MAYINIT Clause A MAYINIT clause explicitly allows data in the segment to be initialized by for example DB directives Only segments in ROM or EROM can be directly initialized by assembler and the MAYINIT clause is not necessary for segments in these spaces The initialization of segments in RDATA or EDATA requires coordination of the assembler linker and star tup code If you need to initialize data in a segment in RDATA or EDATA use the MAY INIT clause to enable the initialization directives in that segment See the note in Predefined Segments on page 212 on how to use startup code to complete the initializa tion Syntax mayinit clause gt MAYINIT Example DEFINE mySeg SPACE EDATA MAYINIT 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 clause The default is no ORG and thus the segment is relocatable Syntax org clause gt ORG lt int_const gt Synonym ORIGIN Example DEFINE near code ORG FFF8 Uses current space byte alignment and absolute starting address at memory location SFFF8 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 V MV M 235 I SPACE Clause
57. Figure 47 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 breakpoint description Remove To delete a particular breakpoint highlight the breakpoint in the Breakpoints dialog box and click Remove Remove All To delete all of the listed breakpoints click Remove All UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 53 NOTE For more information on breakpoints see Using Breakpoints on page 326 Toggle Bookmark Select Toggle Bookmark from the Edit menu to insert a bookmark in the active file for the line wh
58. 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 file a cor responding 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 gen erated assembly code and the compiler generated assembly directives This file is placed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi in the directory specified by the Intermediate Files Directory check box in the General page See Intermediate Files Directory on page 58 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 g
59. I1 Of V MV M 278 I lt outputfile gt lt module list gt This command defines the executable file object modules and libraries involved in the linking process The default extension is 1od as specified by the FORMAT command module list gt is a list of object module or library path names to be linked together to cre ate the output file Example sample c ZDSII_Z8 Encore 4 11 0 lib zilog startups obj test obj c ZDSII_28 Encore 4 11 0 lib std chelpd lib c ZDSII_ Z8 Encore 4 11 0 lib std crtsdd lib A c ZDSII Z8 Encore 4 11 0 lib std fpsdd lib The preceding command links the two object modules and three library modules to gener ate the linked output file sample 1od in IEEE 695 format when the format OMF695 command is present NOTE 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 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 renamin
60. II installing 1 running from the command line 399 zdsproj file extension 3 ZILOG 150 Zilog functions EI 165 getch 165 init uart 167 kbhit 167 putch 168 select port 171 SET VECTOR 172 Zilog Standard Library changing source files 333 finding source files 333 header files 332 notes and tips 331 on chip peripherals 332 settings 78 88 switching UARTs 334 unresolved errors 333 unresolved symbols error 333 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog a using standard I O calls 334 Zilog Standard Library Peripheral Support check box 88 Zilog web site URL xx ZMASM compatibility 268 437 ZSL changing source files 333 definition 78 88 332 finding source files 333 header files 332 notes and tips 331 on chip peripherals 332 switching UARTs 334 unresolved errors 333 unresolved symbols error 333 using standard I O calls 334 ZSL page 78 79 zsldevinit asm file 332 initializations 332 Index
61. 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 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 variable with multiple memory space specifier 202 Unrecognized invalid type specifier A type specifier was expected and something different like a label or symbol was read Or a valid type specifier was read but cannot be used in this context 204 Ignoring space specifier 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 po
62. JR cc 1ab JP label S lab 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 1f 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 NOTE IFMA refers to argument numbers that are one based that is the first argument is numbered one UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i IIAN TELJI BOW M 262 I Exiting a Macro The MACEXIT directive is used to immediately exit a macro No further processing is per formed However the assembler checks for proper if then conditional directives A MACEXIT directive is normally used to terminate a recursive macro The following example is a recursive macro that demonstrates using MAXEXIT to termi nate the macro Example RECURS MAC MACRO ARG1 ARG2 IF ARG1 0 MACEXIT ELSE RECURS MAC ARG1 1 ARG2 DB ARG2 ENDIF ENDMACRO RECURS MAC RECURS MAC 1 a Delimiting Macro Arguments Macro arguments can be delimited by using the current macro delimiter characters defined using the MACDELIM directive The delimiters can be us
63. Manual i 1l rx fel 1 LJ t MV M 136 A rom pointer points to rom data For example char char char char char char Default Storage Specifiers p far fp far far fpf near pn near far npf rom near cpn p is a pointer to a near char small model far char large model fp is a pointer to a far char fp itself is stored in near memory for small model far memory for large model fpf is a pointer to a far char fpf itself is stored in far memory pn is a pointer to a near char small model far char large model pn itself is stored in near memory npf is a pointer to a near char npf itself is stored in far memory cpn is a pointer to a rom char cpn itself is stored in near memory The default storage specifier is applied if none is specified The default storage specifier for a given type of data depends on the memory model chosen See the following table for the default storage specifiers for each model type Table 1 Default Storage Specifiers Function Globals Locals String Const Parameters Pointer Small S rom near near near near near near far far far far far far Large L rom When the deprecated const ROM option is selected the default storage specifier for const qualified variables is rom in both the small and large models Zilog recommends that you use the rom keyword to explicitly place a variable i
64. N PRR roa BNO lt o lt Ht na O O OO CX ODO C3 L H lt pa N o lt o o N N lt lt lt lt lt lt lt lt lt lt lt _close periphdevic errno exit far heapbot far heaptop far stack flash optionl flash option2 len farbss len fardata len nearbss len neardata len pramseg low far romdata low farbss low fardata low near romdata low nearbss low neardata low pram romdata low pramseg main near heapbot near heaptop near stack _ Open periphdevic UM013033 0508 C 0038 zsldevinitdummy COD Zilog Developer Studio ll Z8 Encore User Manual p ES ZILOG sos C 0010 vect10 VECTORS 010 C 0012 vect12 VECTORS 012 C 0014 vect14 __ VECTORS 014 C 0016 vect16 _ VECTORS 016 C 0018 vect18 VECTORS 018 C 001A vectla VECTORS 01A C 001C vectlc VECTORS 01C C 001E vectle VECTORS O15 C 0020 vect20 VECTORS 020 C 0022 vect22 VECTORS 022 C 0024 vect24 VECTORS 024 C 0026 vect26 VECTORS 026 C 0028 vect28 VECTORS 028 C 002A vect2a VECTORS 02A C 002C vect2c _ VECTORS 02C C 002E vect2e __ VECTORS 02E C 0030 vect30 __ VECTORS 030 C 0032 vect32 VECTORS 032 C 0034 vect34 VECTORS 034 C 0036 vect36 VECTORS 036 C 0000 startupl VECTORS 002 C 006C startupl startup C 0038 zsldevinitdummy CODE E 0100 startupl FAR BSS C 00DF startupl st
65. Object formats for Linker 95 IEEE 695 95 Intel Hex16 95 Intel Hex32 95 OMF695 214 215 Object libraries 275 Objects and Libraries page 85 Octal numbers in assembly 224 offsetof macro 346 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog OMF695 format 214 215 Open button 17 Open dialog box 38 39 Open Project dialog box 44 open project script file command 423 open periphdevice function 332 333 open UARTXx function 335 Operator precedence in assembly 224 Operators 225 subtract 293 amp and 289 multiply 292 add 289 FTOL 222 LTOF 223 divide 291 shift left 293 gt gt shift right 293 bitwise exclusive or 294 or 293 not 294 arithmetic 221 BASE OF 290 Boolean 221 COPY BASE 291 COPY TOP 291 FREEMEM 291 HIGH 222 HIGH16 222 HIGHADDR 291 LENGTH 292 LOW 222 LOW16 222 LOWADDR 292 precedence 224 relational 221 TOP OF 293 Operators in assembly 225 option script file command 423 Options 423 assembler 424 Index compiler 425 general 426 librarian 427 linker 427 Options dialog box 122 Debugger tab 126 127 Editor tab 123 124 General tab 122 123 Opto isolated USB Smart Cable requirements xvii ORDER command 284 289 ORG clause 234 ORG directive 238 Output File Name field 94 Output page 13 93 94 Output to Pane 2 check box 50 Output Window button 18 P Page Length field 60 Page Width field 60 Para
66. P3AD TRAP P2AD TIMER2 PIAD TIMER1 POAD TIMERO MCT UARTO_RX UARTI_RX UARTO_TX UARTI_TX Dc C3 SPI C2 ADC CI P7AD CO P6AD POTRAP PSAD WOTRAP Syntax lt vector_directive gt gt VECTOR lt vector name gt lt expression gt Examples VECTOR WDT irq0 handler VECTOR TRAP irgl handler 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 The operands must be labels that are defined somewhere in the assembly file Synonyms global GLOBAL GLOBAL public def public Syntax lt xdef_directive gt gt XDEF ident list gt Examples XDEF label XDEF labell label2 label3 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual XREF Specifies that a list of labels in the operand field are defined in another module The refer ence 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
67. Relocatable text RData Initialized data Relocatable vectors nnmn ROM Interrupt vectors Absolute pramseg PRAM Code Relocatable NOTE Initialized segments in RDATA or EDATA such as NEAR BSS or FAR DATA require startup code to initialize them because only segments in ROM or EROM can actually be initialized by the assembler linker For an example of how to do this study the C startup code in ZILOGINSTALLNZDSII product versionNsrcNrtlNcommonN startups asm and the linker command files automatically generated for a C project The predefined segment text is generated by the compiler which moves it to either the near data or far data segment depending on the memory model that is in use See Memory Models on page 137 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i rian 1 6LJ L0 t MV M 213 I NOTE For every vector directive that locates an interrupt vector at address nnn where n represents a hexadecimal digit the assembler generates an absolute segment in ROM named vectors mnn NOTE The pramseg segment is available only for the subset of Z8 Encore CPUs that support the PRAM Program RAM address space 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 rem
68. Selected Debug Tool on page 118 Show CRC on page 119 Customize on page 119 Options on page 122 Flash Loader NOTE The Flash Loader dialog box needs to be closed and then opened again whenever a new chip is inserted or the power is cycled on the target board Use the following procedure to program internal Flash for the Z8 Encore 1 Ensure that the target board is powered up and the Z8 Encore target hardware is connected and operating properly 2 Select Flash Loader from the Tools menu The Flash Loader connects to the target and sets up communication The Flash Loader Processor dialog box is displayed with the appropriate Flash target options for the selected CPU UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog an Flash Loader Processor 78F 6423 Flash File Start Address File El Internal Start Address 000000 Path Flash Options Flash Configuration Intemal Flash cnc a Serialization Controls M Intemal Flash Enable File Offset 000000 Flash File Controls Erase Memory Erase Before Flashing Close Dialog when Complete Use Page Erase Li Figure 78 Flash Loader Processor Dialog Box 3 Click on the Browse button um to navigate to the hex file to be flashed 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
69. Synopsis include lt stdlib h gt void srand unsigned int seed UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I IER pg ZILogd IU U 384 amu Example int ij srand 1001 i rand sscanf Reads formatted data from a string Synopsis include lt stdio h gt int sscanf char s char format Returns The value of the macro EOF if an input failure occurs before any conversion Otherwise the 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 A sscanf buf amp d amp i strcat 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 Synopsis finclude lt string h gt char strcat char sl char s2 Returns The value of s1 Example char ptr char s1 80 Production char s2 Languages ptr strcat s1 s2 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i IIA fel 16LJ0UI amp Y Ly 385 amu 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
70. The compiler reports an Incompatible data types error for code that does not follow the preceding restriction Under the ANSI standard the const qualification on a parameter merely implies that the function cannot modify the parameter and a non const qualified argument can be passed as the corresponding parameter The effect of this deviation from the standard is primarily that in code that must be porta ble for all options of the compiler and linker such as the source code for library functions provided by the compiler parameters cannot be declared const On new applications Zilog discourages this use of the const keyword to place data in ROM Zilog recommends declaring constant data such as tables using the rom keyword UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual T I JR ENT ZIloQd amp M A 192 instead Where portability is a consideration this can easily be done by preprocessor mac ros For example ifdef EZ8 define ROM rom else define ROM const endif ROM struct TableElement table stuff Const Correctness in the Standard Header Files In general Zilog header files are not const correct due to the issue raised in const Key word and ROM on page 191 For example in the Zilog library strcpy is effectively declared as char strcpy char dst char src but the ANSI standard requires char strcpy char dst const char
71. User Manual o A AN Eg f AN I LUJL JI Y wd e INCLUDE on page 236 LIST on page 237 e NEWPAGE on page 237 e NOLIST on page 237 ORG on page 238 e SEGMENT on page 238 e SUBTITLE on page 239 TITLE on page 239 e VAR on page 239 VECTOR on page 241 e XDEF on page 242 e XREF on page 243 Structures and Unions in Assembly Code on page 243 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 Example ALIGN 2 DW EVEN LABEL COMMENT 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 assem bler treats as comments all text between the initial and final delimiter as well as all text on the same line as the final delimiter You must not use a label on this directive UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual r ga i A EC f Z IOO n i UJ LI UV U 228 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 a
72. X 16 most significant bits of X FTOL Operator The FTOL operator can be used to convert a floating point value to an integer For exam ple fval equ 12 34 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 V MV M 223 I segment CODE LD r0 FTOL fval 12 is loaded into r0 LTOF Operator The LTOF operator can be used to convert an integer value to a floating point value For example val equ 12 fval DF LTOF val 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 123 456 negative decimal 1 000 000 decimal number with underscores 123 NOT an integer but a name Underscore can be neither first nor last character 12E 45 decimal float 123 456 decimal float 123 45E6 decimal float Hexadecimal Numbers Hexadecimal numbers are signed 32 bit integers ending with the n or H suffix or starting with the prefix and consisting of the characters 0 9 and A F A hexadecimal number can have 1 to 8 characters Positive numbers are indicated by the absence of a sign Nega tive numbers are indicated by a minus sig
73. XP 16K Series devices have additional RAM that can optionally be used as Program RAM PRAM The Z8 Encore C Compiler provides syntax to place code for a function in PRAM This feature can be useful for keeping device power consumption low by arranging that frequently activated code be placed in PRAM so that the main body of code which often only needs to be executed at rare intervals remains in the more power intensive Flash memory The compiler provides a pragma pragma PRAM for this purpose This pragma has function scope and can only be used just before a function definition The code for such functions is then placed in a special segment called PRAMSEG For example pragma PRAM int func void return 2 The code for the func function is placed in the PRAMSEG segment Multiple functions in a program can be designated as PRAM functions by preceding each of them with pragma PRAM A copy of the PRAMSEG is kept in ROM and copied to PRAM by the C startup module For more details see Linker Command Files for C Programs on page 181 and Startup Files on page 177 Only the code for the function designated as PRAM is placed by the compiler in PRAM SEG Any functions called by such function are not automatically placed by the compiler in PRAMSEG For example pragma PRAM int func void return anotherfunc In the preceding example only the code for func is placed in PRAMSEG The code for anotherfunc is place
74. Z8 Encore User Manual i 1l r fel 1 LJ MV M 413 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 SUPPORTED SCRIPT FILE COMMANDS The Command Processor supports the following script file commands 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 checksum 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 UM013033 0508 The add file command adds the given file to
75. ZiLOG ZDSII_ZBEncorel_ 4 11 0 eampl Maem Disable All Remove Remove All a gt Cancel Figure 116 Viewing Breakpoints 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 UMO13033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual 2 n f LV 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 Build or Debug toolbar Place your cursor in the line in the file where you want to activate a disabled breakpoint right click to display the context menu and select Enable Breakpoint The white octagon becomes a red octagon to indicate that the breakpo
76. 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 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 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 encountered 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 claus
77. ace Sade cd eR Shad ER ed ats 422 open pro ect i i 2meveckeeeebieevesbbrebGeNtb E E a bad 423 OPHION E 423 PINE sn aio E es Deb Rede ad Sea obi REA 429 ner 429 nn aer 429 nae ED 430 p D 430 savemem yee ees eed eer eh dee ubDROUPePPHERREBRERIEPERPRROD PER 430 A RM 430 SUP cede eee ERR NR MINE LU LE 431 dq siii dd a od da 431 SICDOUL cra io peda 431 STOP e Sb aon MER a MERE need E hoes hea esd eX RS E 431 target CODY nici ecce Ease e d UR e o Mant rel ec e RR de pae rad d dent 431 target Creates ol lsosneblG S ia as 432 A deci Dp ee watauga anti ao deaf ae arl heal In EA nec deos 432 target help sese oes a dean a Rake ESEG ES S RA 432 target list gic esed eer paced re be dre jaan dae d vedo edad OI uere 432 target OpUOTs c sse ees Sese RA ii Aure UR dd addon 433 target Save o sos eek deed Y REP RE web ENG Ea Redd Gow re dues 433 ase P rET 433 target Setup aus ee deep Ue e RUF GS RU gi GLb wake a AR EE 434 Wall eo bae ED oC REC eei adsis uq Modo lien ol dak E id 434 Walt DD s isses e perder eS d eed mere ete tes a ep RES ERR 434 Running the Flash Loader from the Command Processor 0 0000e0es 434 Displaying Flash Help ove eicere aca 435 Setting Up Flash Options 0 0 n enn 435 Executing Flash Commands 2 0 00 ccc cette teens 435 Examples esee Re v RE A ii 436 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User M
78. as in previous applications However Zilog recommends remov ing them from your projects over time to avoid the issues that have caused these features to be deprecated UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog li Project Settings Configuration Debug m Sb General Deprecat Eh Assembler Fill c Place Const Variables in ROM Sil Code Generation Disable ANSI Promotions Eh Listing Files h Preprocessor Sak Advanced x 5s ZSL fi Linker SS Commands Sil Objects and Libraries 3 Address Spaces 3 Warnings h Output Eh Debugger Note Cancel Help Figure 55 Deprecated Page of the Project Settings Dialog Box Place Const Variables in ROM In ZDS II releases before 4 10 0 an option was provided to place all variables that were declared const in ROM memory in other words in the ROM address space see Linker Address Spaces Page on page 89 This option has now been deprecated The heart of the problem with this feature lies in the nature of Z8 Encore as a Harvard architecture that is one in which different address spaces are used for read only memory used for things like code and ROM data storage and memory that is writable used for most data in the pro gram The ANSI Standard and more fundamentally the design of the C language was written with the implicit assumption that only von Neumann architectures in which a sin
79. before being used in arithmetic or relational such as lt and operations By selecting the ANSI Promotions check box these rules are disregarded and the compiler can operate on char entities without promoting them This can make for smaller code because the com piler does not have to create extra code to do the promotions and then to operate on larger values In making this a deprecated feature Zilog has worked to make the compiler more efficient at avoiding truly needless promotions so that the code size penalty for observing the standard is negligible Disabling the promotions can often be a safe optimization to invoke but this is subject to several exceptions One exception is when an arithmetic overflow of the smaller variable is possible For example the result of adding char 10 to char 126 does not fit within an 8 bit char variable so the result is char 120 In such cases you get dif ferent results depending on whether ANSI promotions are enabled or disabled If you write char a 126 char b 10 int i a b then with ANSI promotions enabled you get the right answer 136 With ANSI promo tions disabled you get the wrong answer 120 The reason for the different result is that while in both cases there is a conversion from char to int the conversion is applied ear lier or later depending on this setting With ANSI promotions enabled the conversion is done as soon as possible so it occurs before the addition and
80. 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 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 o 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 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 t
81. by the Intermediate Files Directory field in the General page see Intermediate Files Directory on page 58 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 file Page Width When the assembler generates the listing file the Page Width field sets the maximum number of characters on a line The default is 80 the maximum width is 132 Page Length When the assembler generates the listing file the Page Length field sets the maximum number of lines between page breaks The default is 56 Jump Optimization When selected the Jump Optimization check box allows the assembler to replace relative jump instructions JR and DJNZ with absolute jump instructions when the target label is either e outside of the 127 to 128 range For example when the target is out of range the assembler changes UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual y o iH JE Sa PP BS I f 3 M i rr J LA AUS MA 61 DJNZ r0 lab to DJNZ r0 labl JR lab2 lab1 JP lab lab2 external to the assembly file When the target label is external to the assembly file the assembler always assumes that the target address is out of range It is usually preferable to allow the assembler to make these replacements because if the target of the jump is out of range the assemble
82. by the standard to be supported in a freestanding compiler such as the Z8 Encore C Compiler However the compiler does support many of the other stan dard 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 lt errno h gt 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 lt stddef h gt e lt stdio h gt Zilog supports only the portions of stdio h that make sense in the embedded environment 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 probl
83. char NULL Synopsis finclude stdlib h double atof char nptr Returns The converted value UM013033 0508 C Standard Library Example char str double x x atof str atoi 1 234 Zilog Developer Studio ll Z8 Encore User Manual Bl A a Z I 1 OO fl V MV M amu Converts the string pointed to by nptr to int representation Except for the behavior on error it is equivalent to int strtol nptr Synopsis include lt stdlib h gt int atoi char nptr Returns The converted value Example char str int x x atoi str atol char NULL 10 Converts the string pointed to by nptr to long int representation Except for the behav lor on error it is equivalent to strtol nptr Synopsis finclude lt stdlib h gt long int atol char nptr Returns The converted value Example char str 1234567 long int x x atol str bsearch char NULL 10 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual ZIlOG ase 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 fu
84. character 260 delimiter characters 262 delimiting arguments 262 diagnostics 338 empty arguments 148 error reporting 340 exiting 262 expanding 60 floating point 340 general utility 348 generated by IDE 151 input output 346 invocation 260 labels 261 limits 342 mathematical 343 NDEBUG 151 optional arguments 261 predefined 149 standard definitions 346 string handling 350 Make file exporting 101 makefile script file command 422 makrfile script file command 422 malloc function 349 369 Manage Configurations dialog box 104 105 MAP command 282 map file extension 283 Index Mark All button 49 Match Case check box 49 50 51 Match Whole Word Only check box 49 50 51 lt math h gt header 343 Mathematical functions 343 Mathematical macro 343 MAXHEXLEN command 283 Maximum Bytes per Hex File Line drop down list box 95 MAXLENGTH command 283 MAYINIT clause 234 MB LEN MAX 342 memchr function 351 369 memcmp function 350 370 memcpy function 350 370 memmove function 350 371 Memory accessing 211 defining holes 91 defining locations 211 filling 114 317 Flash 166 168 175 loading to file 116 319 saving to file 115 318 Memory management functions 349 Memory Model list box 64 Memory models defining 64 large 138 small 137 Memory range syntax 91 Memory window 314 changing values 316 cyclic redundancy check 319 filling memory 114 317 finding addresses 316 loading to file 116 319 saving t
85. code does not have to perform this function This can be achieved by adding the following code just before segment startup CLRERAM SET FALSE e Ifyou do not have any initialized global or static variables in far memory the startup code does not have to set the initialized global and static far variables to their initial value from rom For example for the small model far int val 20 Not OK to skip initializing far data Initialized global in far memory int val 20 OK to skip initializing far data Initialized global in near memory For the large model int val 20 Not OK to skip initializing far data Initialized global in far memory near int val 20 OK to skip initializing far data Initialized global in near memory Alternatively if your application does require global or static variables in far memory to have initialized values and you perform the initialization in your program as part of the code the startup code does not have to perform this function For example far int val void main void val 20 Initialization performed as part of the code This can be achieved by adding the following code just before segment startup COPYERAM SET FALSE UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual For the Z8 Encore 16K XP Series CPUs if you do not have any code in PRAM
86. code line indica tors e Ared 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 e A program counter code line indicator yellow arrow indicates a 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 the program counter 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 allows you to display the following Debug windows Registers Window on page 312 Special Function Registers Window on page 313 Clock Window on page 313 e Memory Window on page 314 e Watch Window on page 320 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOQ sz e Locals Window on page 322 e Call Stack Window on page 323 Symbols Window on page 324 e Disassembly Window on page 325 Simulated UART Output Window on page 326 bed Gal eel m EE fal Figure 98 Debug Windows Toolbar
87. connection NOTE The USB Smart Cable is a high power USB device Windows NT is not supported When Using the Opto Isolated USB Smart Cable High speed USB fully compatible with original USB Root direct or self powered hub connection UM013033 0508 Introduction Zilog Developer Studio ll Z8 Encore User Manual Z IEUS YJ xvii NOTE The USB Smart Cable is a high power USB device Windows NT is not supported When Using the Ethernet Smart Cable Ethernet 10Base T compatible connection When Using the Z8 Encore MC Emulator Internet browser Internet Explorer or Netscape e Ethernet 10Base T compatible connection One or more RS 232 communication ports with hardware flow control Z8 Encore Product Support CPU Family CPU Pin Count Evaluation Kit Name Z8Encore_F0830_ Series Z8F013x 20 28 Not applicable Z8F023x Z8F043x Z8F083x Z8F123x Z8Encore F083A Series Z8F043A 20 28 Z8F083A0128ZCOG Z8F083A Z8Encore XP 64XX Series Z8F 1621 40 44 Z8F64200100KITG Z8F 1622 64 68 Z8F2421 40 44 Z8F2422 64 68 Z8F3221 40 44 Z8F3222 64 68 Z8F4821 40 44 Z8F4822 64 68 Z8F4823 80 Z8F6421 40 44 Z8F6422 64 68 Z8F6423 80 UM013033 0508 Introduction Zilog Developer Studio ll Z8 Encore User Manual CPU Family CPU Pin Count Evaluation Kit Name Z8Encore XP F0822 Series Z8F0411 20 Z8F0412 28 Z8F0
88. 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 326 Disable All Breakpoints Button The Disable All Breakpoints button deactivates all breakpoints in the currently loaded project To delete breakpoints from your program use the Remove All Breakpoints button Remove All Breakpoints Button The Remove All Breakpoints button deletes all breakpoints in the currently loaded project To deactivate breakpoints in your program use the Disable All Breakpoints button Debug Windows Toolbar The Debug Windows toolbar allows you to display the Debug windows with the following buttons Registers Window Button on page 27 Special Function Registers Window Button on page 28 e Clock Window Button on page 28 e Memory Window Button on page 28 Watch Window Button on page 28 e Locals Window Button on page 28 Call Stack Window Button on page 28 e Symbols Window Button on page 28 e Disassembly Window Button on page 28 Simulated UART Output Window Button on page 28 Es El E Bed kl del Sl Ed 67 mul Figure 22 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 312 UM013033 0508 Using th
89. de o d hd ta baee d PR adco d d acid 283 NODEBUG 0 9x8 As IRR Mos SCR a DR Re Hoa CR a AUDIT Tete Va RN Ie a A 284 NOMAP ni ben bebe eerte hearers 284 NOWARN eet cade bem RR a TH PEE A ge 284 ORDER eo Sade Ue ded ded UE UE aes ee 284 RANGE 2231 be dede dto b dedos iia det Datus dan e quieto did 285 SEARGCHDP ATH ui a RC A die itn 285 SEQUENCE susto aid 286 SORT a t REEL ADHERE rao ctr getto Polen eee 286 SPLITTABLE 4s or eR CGEROERE CER EP ER EE eee Bieb 286 UNRESOLVED IS FATAL 65 vue RT ICE THE ici bs 287 WARN Uu a eer MA Sen EMILE 287 WARNING IS FATAL 1 pera Ed aor ed to do ee rbd car dE dolet 288 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User Manual ran ILU U EY M WARNOVERLAP tii a AH a ap eee A cone 288 Linker Expressions ocer ergi deber EEEE een a e 288 CC Ber Siok We aed lk Pate de tote AAN ARANA RA AA ets 289 amp And PI PT eee ee eee ee ee ee ee eee eee eee eee eee 289 BASE OF 124 2 pen bed d o bed aos POSADA ERA a eA daa Sula LA sob 290 COPY BASE zusenden Rd PR ERROR RA IR T HRS REET eR ORA 291 COPY TOP co HER eee Se RRs Id eed e 291 A s c cis A Du t SUR E SD A 29 FREEMENM atesora naa sa bate eui aud dana ami ELM EE 29 HIGHADDR adress xn VEU Ad VADE dra ACER deen SHE Ut epa ts 291 LENGTH sexi ser a iaa 292 LOWADDR 0er rr bits ES 292 E Multiply cs ica A AA daa 292 Decimal Numeric Values oooooooocoocorrrrr teen ene 292 Hexadecimal Numeric Values 0 0c cece eet ee
90. default noreduceopt Perform all the optimizations This 1s the default Note Debugging is allowed when this option is selected With noredeuceopt and debug the program can still be debugged but it might be limited for some cases noregvar Turns off the use of register variables optlink Sets the call frame as static promote Turns on ANSI promotion This is the default quiet Suppresses title information that is normally displayed to the screen Errors and warnings are still displayed reduceopt Reduces optimization for easier debugging The default is noreduceopt Note Debugging is allowed when this option is not selected With noredeuceopt and debug the program can still be debugged but it might be limited for some cases regvar val UM013033 0508 Specifies the number of registers used for variables The default is 8 registers Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual Zilog ass Table 9 Compiler Command Line Options Continued Option Name Description stdinc path Sets the path for the standard include files This defines the location of include files using the include lt file h gt 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 project directory 2 the c rt1 directory 3 the c myinc directory 4 the default directo
91. 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 If freed space is referenced the behavior is undefined UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i IIAN TELJI EY M 361 amu Synopsis finclude lt stdlib h gt void free void ptr Example char buf buf char calloc 40 sizeof char free buf frexp 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 finclude math h double frexp double value int exp Returns The value x such that x is a double 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 Example double y x 16 4 int n y frexp x amp n getchar 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 1s at end of file the end of file
92. due ub bare Parece d valorada oie dot 389 SUL SUM ove rc P TET 389 qu cT 390 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User Manual o iH JE ENT A pm BS I f 3 A tts LA ss BLA US ey jl xiii uj qu pm 391 Strtol A idaren haere sane mates P ERES 392 lan oodd ebore debui bd oe re utbs ton eani ts tue td adn back 393 A hes ke Nes ae bea a ee eae a eae ee meas 393 tOloOWEE ridad du San aod de dd boda doa on 393 iiv Ar 394 DN ADDED Ee wales hee Oe GOS ia 394 VB PPP rm 395 Va Stant etasyosa toes eima tite pride aub dde ve aub Satan aub Sci doutes atone 396 VDEIDEE n oco A Ni ais 397 VSDEIDU a deed x Sd are dA Sd Ed Ed ceded 397 Running ZDS II from the Command Lime 0 cece cece eee ee ee eee 399 Building a Project from the Command Line 0 c eee eee eee eee 399 Running the Assembler from the Command Line 000 e eee ee eee 400 Running the Compiler from the Command Line 002 e eee eee ee 400 Running the Linker from the Command Line 00 0000 e eee eee 401 Assembler Command Line Options ooo oooococooororr enna 402 Compiler Command Line Options 00 ete eens 404 Librarian Command Line Options 000 cece eh 407 Linker Command Line Options 0000 cette eens 407 Using the Command Processor 2 cece cc cece cece cece cece cere ences 408 Sample Command Script File 0 0 cc
93. fatal errors If this check box is selected the linker quits generating output 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 executable cannot be built when the program contains references to undefined external Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual symbols If this check box is deselected the linker proceeds with generating output files even if there are undefined symbols NOTE Selecting this check box displays any warning as errors regardless of the state of the Show Warnings check box in the General page see Show Warnings on page 58 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 Z8 Encore An overlap condition usually indicates an error in project configuration that must be corrected however the linker creates deliberate overlays for some functions when using static frames and these overlays are not reported as warnings These errors in Z8 Encore 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 Linker Output Page The options in the Output page a
94. 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zzilogi Find what Y Match whole word only Direction Match case C Up Cancel Regular expression Down Figure 43 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 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 SD ek a Click Find Next to jump to the next occurrence of the search text or click Mark All to display a cyan box next to each line containing the search text NOTE After clicking Find Nex
95. 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 start the search Replace To find and replace text in an active file use the following procedure 1 Select Replace from the Edit menu The Replace dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Replace Find what Replace with Match whole word only Replace In Match case C Regular expression e Whole file Cancel Figure 45 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 Whol
96. finclude lt string h gt char strchr 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 char sl char s2 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 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 UMO13033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i IIA fel 1 LJ V MV M 386 amu Synopsis include lt string h gt char strcpy char sl 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 include lt string h gt size t strcspn char sl char s2 Returns The len
97. following list C Runtime Library Check if you plan to make any calls to Large standard library functions and you do not plan to provide your own code for all library C Static Frames Dynamic Frames functions that plan to use Select the appropriate option below Floating Point Library Check Bac Net Finish Cancel Figure 4 New Project Wizard Dialog Box Build Options Step 11 Accept the defaults by clicking Next UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog The Target and Debug Tool Selection step of the New Project Wizard dialog box is displayed 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 39 or the General page of the Project Settings dialog box see General Page on page 56 For this tutorial project there are two targets displayed Z8F16800128ZCOG is the Z8F1680 28 Pin Development Kit s evaluation board Z8F16800144ZCOG is the Z8F 1680 Dual 44 Pin Development Kit s evaluation board For more information about which products each target supports see Z8 Encore Product Support on page xviii Clicking Setup in the Target area displays the Configure Target dialog box The Configure Target dialog box allows you to select the clock source and the appropriate clock frequency For the emulator this frequency must match the clock
98. form feed new line n carriage return r horizontal tab t or vertical tab v Synopsis include lt ctype h gt int isspace int c Example int r char cz r isspace c isupper Tests for any uppercase letter A to Z Synopsis include lt ctype h gt int isupper int c Example int x char c a r isupper c UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f Zzilog V M I 366 amu isxdigit 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 labs Computes the absolute value of a long j Synopsis finclude stdlib h long labs long j Example long i 193250 long j j labs i Idexp Multiplies a floating point number by an integral power of 2 A range error can occur Synopsis include lt math h gt double ldexp double 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 1dexp x exp UMO13033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual A Idiv Computes the quotient and remainder of the division of the numerator numer by the denominator denon If the division is inexact the sign of the quotient is that of the mathe matical quotient and the magnitude of the quotient
99. 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 4 Select the Internal Flash check box in the Flash Options area 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 5 To perform a cyclic redundancy check on the whole internal Flash memory click CRC The 16 bit CRC CCITT polynomial x 6 x x 1 is used for the CRC The CRC is preset to all 1s The least significant bit of the data 1s shifted through the UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual iH PES SN 7 IIO 0 LN E 112 polynomial first The CRC is inverted when it is transmitted If the device is not in Debug mode this command returns FFFFH for the CRC value The on chip debugger reads the program memory calculates the CRC value and displays the result in the Status area 6 Select the pages to erase before flashing in the Flash Configuration area Pages that are grayed out are not available 7 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
100. indicator for the stream is set and getchar returns EOF If a read error occurs the error indicator for the stream is set and getchar returns EOF UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f ZIlOQ V M M 362 d Example int i i getchar NOTE The UART needs to be initialized using the Zilog init uart function See init uart on page 167 gets Reads characters from a UART into the array pointed to by s until end of file is encoun tered or a new line character is read The new line character is discarded and a null char acter 1s written immediately after the last character read into the array Synopsis include 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 if r NULL No input NOTE The UART needs to be initialized using the Zilog init uart function See init uart on page 167 isalnum Tests for any character for which isalpha or isdigit is true Synopsis include lt ctype h gt int isalnum int c Example int r char c a r isalnum c UM013033 0508 C Standard Library isalpha Tests for any character for which isupper or islower is true Synopsis include lt ctype h gt int isalpha int c Example int t char c a
101. is changed to OCATE s uninit data at BASE OF EDATA UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual the lowest used address is 900 because LOCATE s_nvrblock at 900 and s nvrblock is in EDATA 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 name 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 Divide The Divide operator is used to perform division Syntax expression expression 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual Syntax HIGHADDR OF l
102. is the largest integer less than the mag nitude of the mathematical quotient Synopsis include lt stdlib h gt ldiv t ldiv long numer long denom Example long x 25000 long y 300 div t t int q int r t ldiv x y q t quot r t rem Computes the natural logarithm of x A domain error occurs if the argument is negative A range error occurs if the argument is zero Synopsis finclude math h double log double x Returns The natural logarithm Example double x 2 56 double y y log x UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i 1l rfl 1 LJ V MV M 368 amu log10 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 logl10 double 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 All accessible objects have values as of the time long jmp was called except that the val ues of objects of automatic storage class that do not have volatile type and have been c
103. linker generated output mapfile is the name of the map file created by the linker For example relist product map sdiopt Performs jump optimizations Translates any relative jumps to absolute jumps if the target is out of range This is the default setting version Prints the version number of the assembler warns Allows the generation of warning messages to the screen and listing file This is the default UM013033 0508 Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual i ran ILU U EY M I 404 COMPILER COMMAND LINE OPTIONS The following table 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 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 stdinc C ez8 include Table 9 Compiler Command Line Options Option Name asm Description 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 bfpack tight normal compatible
104. list box 44 Look in Subfolders check box 50 LOW operator 222 LOW 16 operator 222 LOWADDR operator 292 Ast file extension 214 L TOF operator 223 M MACDELIM directive 262 MACEXIT directive 262 Macro Assembler 210 adding null characters 220 arithmetic operators 221 automatic working register definitions 225 Index binary numbers 223 Boolean operators 221 case sensitivity 217 character constants 224 character strings 220 command line options 402 decimal numbers 223 directive compatibility 268 437 directives 226 error messages 269 expressions 220 floating point numbers 219 generating listing file 1st 214 generating object file 214 hexadecimal numbers 223 numeric representation 219 octal numbers 224 operator precedence 224 operators 225 relational operators 221 reserved words 218 running from the command line 400 setup 59 syntax 264 warning messages 269 MACRO directive 259 Macros 259 _ 151 151 AUS SIZED BY TYPE 149 _ BACKWARD COMPATIBLE BITFI ELDS 149 BITFIELDS OVERLAP AUS 149 BITFIELDS PACK L2R 149 CONST IN RAM _ 149 150 CONST IN ROM _ 149 150 CPU NAME 149 _ DATE 149 ENCORE _ 150 EZ8 150 _ FILE 149 FPLIB 150 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog az _ LINE 149 _ MODEL 150 NEW AU AT TYPE CHANGE _ 149 _ STDC 149 TIME _ 149 _ UNSIGNED CHARS 150 _ ZDATE _ 150 _ ZILOG 150 _DEBUG 151 assert 338 character handling 339 concatenation
105. ll Z8 Encore User Manual 1l r fel 1 LJ V MV M 308 751 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual 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 Using the Command Processor on page 408 The following topics are covered in this section e Status Bar on page 310 Code Line Indicators on page 311 Debug Windows on page 311 Using Breakpoints on page 326 From the Debug menu select Reset or any other execution command to enter Debug mode You are now in Debug mode as shown in the Output window Debug tab The Debug toolbar and Debug Windows toolbar are displayed as shown in the following figure UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Zilog sample ZDS I ZB Encore Family MAIN C ile Edit View Project Build Debug Tools Window Help Bg 2808 DA po Jemms ocu peas MSI EE ER E Standard Project Files startupLasm mE El main c MAIN C E
106. ll Z8 Encore User Manual Zzilogi initialize the variable argument va here vsprint d Sd Sd va UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Running ZDS II from the Command 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 zdsproj 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 The following sections describe how to run ZDS II from the command line Building a Project from the Command Line on page 399 Running the Assembler from the Command Line on page 400 Running the Compiler from the Command Line on page 400 Running the Linker from the Command Line on page 401 Assembler Command Line Options on page 402 e Compiler Command Line Options on page 404 e Librarian Command Line Options on page 407 Linker Command Line Options on page 407 BUILDING A PROJECT FROM THE COMMAND LINE To build a project from the command line use the following procedure 1 To see the current path type the following in a DOS window PATH 2 To set up the ZDS II bin directory for example C PROGRA 1 ZiLOG ZDSII_Z8Encore 4 11 0 bin in the path t
107. 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 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 n ptrs array ptr nott 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 ssas 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
108. 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 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 lt filename gt 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 define 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 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 const
109. 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 130 Label lt name gt is already declared An attempt was made to define two labels of the same name in the same scope UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U EY M 200 I 131 Label lt name gt not declared A goto statement was encountered with an undefined label 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 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
110. of an escape sequence requires more than 8 bits of storage 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 than one ASCII character 121 Illegal declaration specifier An attempt was made to declare an object with an illegal declaration specifier 122 Only type qualifiers 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 const and volatile 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
111. page 121 Customize Toolbars Tab The Toolbars tab lets you select the toolbars you want to display on the Z8 Encore devel oper s environment change the way the toolbars are displayed or create a new toolbar NOTE You cannot delete customize or change the name of the default toolbars UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi Customize Toolbars Commands Toolbars Iv Show Tooltips v Cool Look Large Buttons Command Processor Bookmarks Debug Windows Cancel Help Figure 86 Customize Dialog Box Toolbars Tab To display hide or change the appearance of toolbars use the following procedure 1 Select Customize from the Tools menu The Customize dialog box is displayed 2 Click on the Toolbars tab 3 Inthe Toolbars list box select the toolbars that you want displayed and deselect toolbars that you want hidden 4 Select the Show Tooltips check box if you want to display cue cards short descriptions of the main function of buttons when your mouse cursor is over a button Select the Cool Look check box to change how the buttons are displayed Select the Large Buttons check box to increase the size of the buttons Click Reset to restore the defaults 9 n Dw Click OK to apply your changes or Cancel to close the dialog box without making any changes UM013033 0508 Usin
112. page 160 shows an assembly source file referencing the sin function written in the large dynamic model The sin function is defined in the C run time library crtldd lib NOTE The C Compiler precedes the function names with an underscore in the generated assembly See Function Naming Convention on page 158 UM013033 0508 Using the ANSI C Compiler Assembly File globals on xref _sin Zilog Developer Studio ll Z8 Encore User Manual T 1 I Pp NT i I Z V MV M I segment far data 0 523599 val dl 3F060A96 res dl 0 segment code main PUSHX PUSHX PUSHX PUSHX CALL POP POP POP POP LDX LDX LDX LDX ret _valt _valt alc M M al sin R4 R4 R4 R4 Load the argument LSB first MSB last Call the function the result is in R0 R1 R2 R3 Pop the argument from stack _res RO Save the result MSB from RO LSB from R3 res res res 1 R1 2 R2 3 R3 Referenced C Function Prototype double sin double arg double is the same as float on Z8 Encore C Compiler COMMAND LINE OPTIONS The compiler like the other tools in ZDS Il can be run from the command line for pro cessing inside a script and so on See Compiler Command Line Options on page 404 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 libr
113. rebuild The rebuild command rebuilds the currently open project This command blocks the execution of other commands until the build process is complete The following is the syn tax of the 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 of the 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 126 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 Saving to a File on page 318 The following is the syntax of the savemem command savemem SPACE displayed spacename FORMAT lt HEX BIN TEXT gt lt PATH name 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 saved For example Savemem SPACE RDATA FORMAT BIN c temp file bin STARTADDRESS 20 ENDADDR
114. release 4 8 0 This change is taken care of automatically as long as you are using the standard Zilog library version of READ FLASH and including the standard header file ez8 h However since the new standard header uses the new prototype if you have customized READ FLASH in your application you need to make modifications so that the header and function declarations agree READ NVDS The READ NVDS function is a Zilog function that reads a value from NVDS memory at the specified address UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zzilog Synopsis include lt ez8 h gt reentrant char READ NVDS char address reentrant char nvds read char address Returns The function returns the character read from NVDS at the address specified Example include lt eZ8 h gt char x void main INIT FLASH _DEFFREQ Target clock frequency WRITE NVDS x 0x10 write x to NVDS at address 0x10 x READ NVDS 0x10 read NVDS at address 0x10 _DEFFREQ is automatically set from the IDE based on the clock frequency setting in the Configure Target dialog box READ NVDS GET STATUS The READ NVDS GET STATUS function is a Zilog function that reads a value from NVDS memory at the specified address and gets the status Synopsis include lt ez8 h gt int reentrant READ NVDS GET STATUS char addr int reentrant nvds read get status c
115. s2 size t n Returns The value of s1 Example char s1 10 char s2 10 COMPASS memcpy sl s2 8 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual gt B IIAN 1 LJ t MV M 371 amu memmove Moves n characters from the object pointed to by s2 into the object pointed to by sl Copying between objects that overlap takes place correctly Synopsis finclude lt string h gt void memmove void sl void s2 size t n Returns The value of s1 Example char s1 10 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 string h void memset void s int c size t n Returns The value of s Example char str 20 char c a memset str c 10 sizeof char modf 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 in the object pointed to by iptr Synopsis include lt math h gt double modf double value double iptr UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f ZIloQd V MV M 372 d Returns The signed fractional part of value Example double x 1 235 double f double I i modf x amp f pow Computes the x raised to the
116. semantically equivalent form the behavior is indeterminate Zilog Header Files The Zilog header files are described in the following sections e Architecture Specific Functions lt eZ8 H gt on page 162 e Nonstandard I O Functions lt sio h gt on page 163 Architecture Specific Functions lt eZ8 H gt A Z8 Encore specific header file ez8 h gt is provided that has prototypes for Zilog spe cific C library functions and macro definitions Macros lt eZ8 h gt has the macro definitions for all Z8 Encore microcontroller peripheral registers For example TOH Expands to unsigned char volatile near 0xF00 Refer to the Z8 Encore product specifications for the list of peripheral registers sup ported lt eZ8 h gt also has the macro definition for the Z8 Encore Flash option bytes FLASH OPTION Expands to a rom char at address 0x0 FLASH OPTION2 Expands to a rom char at address 0x1 lt eZ8 h gt also has a macro for interrupt vector addresses RESET Expands to Reset vector number Refer to the Z8 Encore product specifications for the list of interrupt vectors supported UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual zilogi Functions intrinsic void El void Enable interrupts intrinsic void DI void Disable interrupts intrinsic SET VECTOR int void func void Set interrupt vector void reentrant INIT FLASH unsigned short freq Initialize Fla
117. sign of the difference between the values of the first pair of characters that differ in the objects being compared int memcemp void s1 void s2 size t n Compares the first n characters int stremp char s1 char s2 Compares two strings int strncmp char s1 char s2 size t n Compares n characters of two strings UM013033 0508 C Standard Library Search void memchr void s int c size_t n char strchr char s int c size_t strespn char s1 char s2 char strpbrk char s1 char s2 char strrchr char s int c size t strspn char s1 char s2 char strstr char s1 char s2 char strtok char s1 char s2 Miscellaneous Zilog Developer Studio ll Z8 Encore User Manual Zilog Returns a pointer to the first occurrence within a specified number of characters of a given character in the buffer Finds first occurrence of a given character in string Finds first occurrence of a character from a given character in string Finds first occurrence of a character from one string to another Finds last occurrence of a given character in string Finds first substring from a given character set in string Finds first occurrence of a given string in another string Finds next token in string void memset void s int c size_tn Uses a given character to initialize a specified number of size_t strlen char s STANDARD FUNCTIONS The following functions are standard fu
118. skip initializing near data Initialized global in far memory Alternatively if your application does require global or static variables in near memory to have initialized values and you perform the initialization in your program as part of the code the startup code does not have to perform this function For example near int val void main void val 20 Initialization performed as part of the code This can be achieved by adding the following just before segment startup COPYRRAM SET FALSE e Ifyou do not have any uninitialized global or static variables in far memory the startup code does not have to clear the far uninitialized variables to zero UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual ZILOQ w For example for the small model far int val Not OK to skip clearing uninitialized far data Uninitialized global in far memory int val OK to skip clearing uninitialized far data Uninitialized global in near memory For the large model int val Not OK to skip clearing un initialized far data Uninitialized global in far memory near int val OK to skip clearing un initialized far data Uninitialized global in near memory Alternatively if your application does not assume that the far uninitialized global or static variables are initialized to zero by the C startup module the startup
119. 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 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 10000 NOTE Refer to Linker Expressions on page 288 for the format to write an expression MAP The MAP command causes the linker to create a link map file The link map file contains 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual Syntax MAP lt mapfile gt mapfile has the same name as the executable file with the map extension unless an opt
120. src As noted this is done to avoid compile time errors if the deprecated const variables in ROM compilation option were selected and then strcpy was called with an argument for src that had not been declared const ANSI Promotions Disabled The ANSI standard requires that integer variables smaller than int such as char always be promoted to int before any computation The Z8 Encore C Compiler is ANSI compliant in this regard when ANSI promotions are enabled The C Compiler analyzes and promotes variables smaller than int to int only where necessary to mimic the ANSI behavior For example for the following statement char ch1 ch2 ch3 chil ch2 ch3 The compiler does not promote ch2 and ch3 to int before the multiplication operation so the char result is not affected For the following statement char ch2 ch3 Dn a lli ch2 ch3 The compiler promotes ch2 and ch3 to int before the multiplication operation so the result is of type int UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual The Z8 Encore C Compiler also provides a deprecated option to disable ANSI promo tions The ANSI behavior is not guaranteed when this option is selected and Zilog does not recommend using this option Library Files Not Required for Freestanding Implementation As noted in Freestanding Implementation on page 189 only four of the standard library header files are required
121. startupf0lal obj C Startup object file for 1K XP large model lib zilog startupf04as obj C Startup object file for 4K XP small model lib zilog startupf04al obj C Startup object file for 4K XP large model lib zilog startupf1680s obj C Startup object file for 16K XP small model lib zilog startupf16801 o0bj Customizing Startup Files C Startup object file for 16K XP large model The C startup object files provided with the Z8 Encore C Compiler are generic files and can be tailored to meet the application requirements Before modifying the C startup mod ule perform the following steps 1 Copy the corresponding C startup source file to a new file in your project directory For the small model use startups asmas the file from which you copy for the large model use startupl asm 2 Add the newly copied C startup file to your project files by using the Add Files command from the Project menu 3 Select the Settings command from the Project menu The Project Settings dialog box is displayed 4 Select the Objects and Libraries page 5 Select the Included in Project and Use Standard Startup Linker Commands check boxes Use the following guidelines when customizing the C startup file e Ifyou do not have any uninitialized global or static variables in near memory the startup file does not have to clear the near uninitialized variables to zero For example for the large model near i
122. steps into the function at the PC If there is no function at the cur rent PC 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 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 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 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual 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 of the target create command target create NAME lt target name gt CPU lt cpu name gt For example target create NAME mytarget CPU eZ80190 target get
123. structured assembly test directives This means among other things that structured assembly test directives can be nested The structured assembly test directives can be nested up to 255 levels Using the Macro Assembler 253 e Nested SBREAK and SCONTINUI SWHILE directive Zilog Developer Studio ll Z8 Encore User Manual i I PES PN Z I1 Of V MV M 254 I E directives are associated with the most recent There is no preset limit on the number of statements that can appear in the statements sections there can be any number of assembler statements in each statements section including zero The operating system file system might impose limitations on file sizes and the user needs to consult the appropriate operating system users guide for such limitations e The SWHILE and w not legal to code a SWHTLI matching SWHILE directive appearing earlier in the source module e The SBREAK and CONTINUI enclosing WHILE and W directives It is not valid for the SBR any other context EAK and SCONTINUI e The SBREAK directive has an optional IF conditional parameter e The SCONTINUE directive has an optional 1F conditional parameter e None of the SWHILE discarded SBR EAK SCONTINUI Structured Assembly Processing E assembler directives can only appear between END directive
124. the command line 1 UM013033 0508 To see the current path type the following in a DOS window PATH To set up the ZDS II bin directory for example C PROGRA 1 ZiLOG ZDSII_Z8Encore 4 11 0 bin in the path type the following SET PATH PATH C Program Files ZiLOG ZDSII_ Z8Encore 4 11 0 bin The make utility is available in this directory Type PATH again to see the new path Open the make file in a text editor Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual i Il r fel 16LJ0UI V MV M 402 I 5 Ina Command Prompt window type the path to the linker and your linker file For example ez8link C Program Files ZiLOG ZDSII_ Z8Encore 4 11 0 samples F083A F083A_ledBlink src ledblink Debug linkemd ASSEMBLER COMMAND LINE OPTIONS The following table 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 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 stdinc C ez8 include 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 D
125. 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 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U IL YW Ly 414 For example add file c projectl main c batch 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 lt wait gt blocks other executing batch files until the invoked batch file is completed useful when nesting batch files For example BATCH commands txt batch wait d batch do_it cmd bp The bp command sets a breakpoint at a given label in the active file The syntax can take one of the following forms bp line lt line number 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 build The build command builds the currently open project based on the currently selected project build configuration This command blocks the execution of other commands until the build process is complete The following is the syntax of the build command build cancel all T
126. this check box increases the time taken for the code download to complete Select the Verify File Downloads Upon Completion check box to verify the 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 IV Save project before start of debug session V Reset to symbol main where applicable Iv Show DataTips pop up information Iv Hexadecimal Display Iv Verify File Downloads Read after Write Verify File Downloads Upon Completion On Connect To Target V Load debug information current project Iv Activate breakpoints Disable warning on Flash Optionbits programming Cancel Help Figure 92 Options Dialog Box Debugger Tab Window Menu The Window menu allows you to select the ways you want to arrange your files in the Edit w
127. to function f2 The number of pointers is specified by the first argument to fl UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual ZILOQ ase 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 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 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 va list ap char array M
128. to the token a t strtok NULL t points to the token oops ow xy t strtok NULL t points to the token c t strtok NULL t is a null pointer UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 V MV M 392 amu strtol Converts the string pointed to by nptr to long int representation 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 Leadi
129. type In Static frame applications any indirectly called function must be specified as the reentrant type using the reentrant keyword 224 Conflicting string placement directive in string constant There are multiple string placement directives in a string constant that attempt to direct the placement of the string in different address spaces 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 UM013033 0508 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 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 C Advanced Page on page 69 so that all calls to printf and sprintf are handled by the real printf or sprintf functions
130. void main INIT FLASH FREQ18432 Target clock frequency WRITE FLASH rom const 0x2f00 x write to Flash X READ FLASH rom const 0x2f00 read from Flash NOTE Do not write to Flash memory more than twice To write to Flash memory more than twice you need to do a page erase Beginning with the ZDS II for Z8 Encore release 4 8 there is a slight change in the function prototype for INIT_FLASH UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Previous Prototype fif defined Z8F642 void reentrant INIT FLASH unsigned short freq else void intrinsic reentrant INIT FLASH unsigned short freq fendif New Prototype void reentrant INIT FLASH unsigned short freq For most Z8 Encore microcontroller variants the intrinsic keyword has been deleted in the ZDS II release 4 8 0 This change is taken care of automatically as long as you are using the standard Zilog library version of INIT FLASH and including the standard header file ez8 h However since the new standard header uses the new prototype if you have customized INIT FLASH in your application you need to make modifications so that the header and function declarations agree 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 Synopsis include lt sio h gt int init
131. which is the value of the new origin Synonyms ORIGIN ORG Syntax org directive gt ORG int const Examples ORG 1000 Sets the location counter at 1000 in the address space of current segment ORG LOOP 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 DEFIN SEGMENT Specifies entry into a previously defined segment The s EGM E directive for the segment ENT 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 SEGM is encountered See Table 7 Predefined Segments on page 212 for the names of pre defined segments Synonyms Section SECTION UM013033 0508 ENT directive Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i I PES SN Z I1 Of V MV M 239 I Syntax lt segment_directive gt gt SEGMENT lt ident gt Exampl
132. window is sometimes displayed for one of the following reasons e The project was not built with debug information enabled You can enable the debug information with the Generate Debug Information check box on the General page of the Project Settings dialog box e An Assembly Only project includes VECTOR RESET xxx which has no associated debug information 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 see Using Breakpoints on page 326 Reset the debugger Stop debugging e Start or continue running the program Go Run to the cursor UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Zilogi Pause the debugging Break e Step into over or out of program instructions e 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 Simulated UART Output Led Lights Off Led Lights Red Led Lights Yellow Led Lights Green Figure 114 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 R
133. 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 STRUCTURED ASSEMBLY Structured assembly supports execution time selection of sequences of source statements based on execution time conditions The structured assembly directives test for a specified condition and execute a block of statements only if the condition is true The structured assembly directives when used in conjunction with the ability to assembly and link modules independently facilitate structured programming in assembly language It can be difficult to assimilate the logical structure of a traditional nonstructured assem bly language program Structured assembly language programs are generally easier to read and understand than nonstructured programs They might also be easier to debug and change The following sections describe structured assembly Structured Assembly Inputs on page 250 Structured Assembly Processing on page 254 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i f l A 1 I ILU amp M A 249 x The assembler directives associated with structured assembly are summarized in the fol lowing table Table 9 Assembler Directives for Structured Assembly Assembl
134. 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 DO 0 shows the null terminated string pointed to by the contents of register DO 0 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual examine for Variables The examine command displays the values of variables This command works for values of any type including arrays and structures The following is the syntax lt expression gt 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 x n 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 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 Filling Memory o
135. 0 read NVDS at address 0x10 1 gt gt 8 amp OXxFF extract data val amp OxFF extract read status STARTUP FILES The startup or C run time initialization file is an assembly program that performs required startup functions and then calls main which is the C entry point The startup program per forms the following C run time initializations e Initialize the register pointer and stack pointer e Clear the near and far uninitialized variables to zero Set the initialized near and far variables to their initial value from rom e For Z8 Encore XP 16K only initialize the segment pramseg from rom Set the initial value of the interrupt register pointer Allocate space for interrupt vectors and Flash option bytes Allocate space for the errno variable used by the C run time libraries The following table lists the startup files provided with the Z8 Encore C Compiler UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Table 3 Z8 Encore Startup Files Name lib zilog startups 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 startupf0las obj C Startup object file for 1K XP small model lib zilog
136. 0100 CHANGE TEXT EDATA CHANGE change FAR TXT FAR ORDER FAR BSS FAR SOOFFFF 0000FF SOOOEFF T TEXT FAR_DATA change NEAR TXT NEAR DATA E DATA DATA ORDER NEAR BSS NEAR DATA COPY NEAR DATA ROM UM013033 0508 Using the Linker Locator COPY FAR DATA ROM Zilog Developer Studio ll Z8 Encore User Manual Zilog 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 define len fardata define low nearbss define len nearbss define low farbss base of FAR DATA length of FAR DATA base of NEAR BSS length of NEAR BSS base of FAR BSS define len farbss length of FAR BSS define far heaptop define far stack highaddr of EDATA highaddr of EDATA define near stack highaddr of RDATA define far heapbot top of EDATA define near heaptop highaddr of RDATA define near heapbot top of RDATA define low pramseg define len pramseg define low pram romdata copy base of PRAMS define READ NVDS define WRITE NVDS base of PRAMSEG length of PRAMSEG E Q 1000 10B3 define READ NVDS GET STATUS 1000 define WRITE NVDS GET STATUS 10B3 Set frequency to 18432000 Hz define _ user frequ C sample sample
137. 013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual e H li PR PAG I Z V MV M 237 I Examples INCLUDE calc inc include calc header file INCLUDE test calc inc contains a path name INCLUDE calc inc ERROR use string constant LIST 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 BIST Syntax list directive LIST Example LIST NOLIST NEWPAGE Causes the assembler to start a new page in the output listing This directive has no effect If NOLIST is active No operand is allowed Synonyms page PAGE Syntax newpage directive gt NEWPAGE Example NEWPAGE NOLIST Turns off the generation of the listing file This mode remains in effect until a LIST direc tive is encountered No operand is allowed Synonym NOLIST UM013033 0508 Using the Macro Assembler Syntax lt nolist_directive gt gt NOLIST Example LIST NOLIST ORG Zilog Developer Studio ll Z8 Encore User Manual Zi y l A FN y VJ 238 E MV 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
138. 06 31 All Updated for the ZDS II 4 10 0 release September 30 2005 Optimizer Warning and Error Messages on page 207 Front End Warning and Error Messages on page 197 Debug Tool on page 100 Setup on page 97 Added new section Updated section Added Ethernet target Added Ethernet target UMO13033 0508 Revision History Zilog Developer Studio ll Z8 Encore User Manual Table of Contents Introduction seese dere ir orar aa xvi ZDS II System Requirements ssseseeseeee teen e ences xvi Supported Operating Systems 0 cette ene xvi Recommended Host System Configuration 00 00 cece eee eee ee xvi Minimum Host System Configuration 0 0 0 cece teens xvii When Using the Serial Smart Cable 00 0 eens xvii When Using the USB Smart Cable 2 0 0 xvii When Using the Opto Isolated USB Smart Cable ooooooooooo o xvil When Using the Ethernet Smart Cable 0 0 0 ccc cee eee xviii When Using the Z8 Encore MC Emulator 0 0 ce cece eens xviii Z8 Encore Product Support ssena anssen enearo xviii Zilog Technical Support rescrie vii erinti terea TEAN ENE EE EEEE E XX Getting Started sorori tive xem ae ma hc lee Roe ode ie tae ale la Wie iio id 1 Installing ZDS Senee ted wack sta A o A 1 Developer s Environment Tutorial 000s 1 Create a New Project ie led cr ia a oia ES 2 Adda File
139. 1 Linker Referenced Files 0 2 0 0 c cece cece eee 183 Linker Symbols uscar Rye RP eR PER ates 186 Sample Linker Command File ooooococoocoococororrr eee 187 ANSI Standard Compliance 0 0 ccc ccc eee eh 189 Freestanding Implementation 0 cee ees 189 Deviations from ANSIC 2 ect e nen neee 190 Warning and Error Messages cee cece ee teen eens 193 Preprocessor Warning and Error Messages 0 eee eee eect een 194 Front End Warning and Error Messages 0 00 c eee eee eee ne eee 197 Optimizer Warning and Error Messages 00 0 cee cece eee eee nee 207 Code Generator Warning and Error Messages 0 00 cece ee ne eens 209 Using the Macro Assembler 2 2c cece cece cece ec ccc cece hh eee nnn 210 Address Spaces and Segments 00 c cee eee ees 211 Allocating Processor Memory sese ne 211 Address Spaces iie A ERR RR T ape Re Dp de buta dde 211 Segments vo s c9 cw a NYSE GMEXR RE Het eed Gea I 211 Assigning Memory at Link Time 000 ccc ees 214 Output File s exeo bee ad et eU GR RR 214 Source Listing lst Format 2 0 0 ec ccc ees 214 Object Code ob Fil voii da lar rbi shee es 215 Source Language Structure 0 0 cece een en eee e eee 215 General Structure isses ence iet iei eae ere eee ews be piter Beam 216 Assembler Rules 0 ses n paw RR ERROR SRG SR Dek nas 217 EXPTESSIONS i444 emere dee dana eub
140. 14 36 Build toolbar 18 Build Type list box 40 build script file command 414 Building a project 13 103 from the command line 399 buildzsl bat 333 334 C C calling assembly from 157 calling from assembly 159 escape sequences 143 language described 337 preserving routines 159 return values 156 159 run time library 160 337 writing programs 132 C run time initialization file 177 customizing 178 Index C Runtime Library check box 87 C Startup Module area 86 Calculate Checksum dialog box 118 Call frames dynamic 139 static 138 Call Stack window 323 Call Stack Window button 28 Calling assembly from C 157 calloc function 349 356 cancel all script file command 414 cancel bp script file command 415 Cascade the files 128 Case sensitivity in assembler 217 C Compiler command line options 404 comments 147 compatibility issues 440 data type sizes 148 error messages 193 running from the command line 400 run time library 160 337 warning messages 193 writing C programs 132 cd script file command 415 ceil function 345 357 CHANGE command 278 Changing object size 377 char enumerations 144 CHAR BIT 342 CHAR MAX 342 CHAR MIN 342 Character case mapping functions 340 Character constants in assembly 224 Character strings in assembly 220 Character testing functions 339 Character handling functions 339 checksum script file command 415 Clear button 122 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual
141. 16 absolute data C 0016 C 0017 2h VECTORS 018 absolute data C 0018 C 0019 2h __ VECTORS 01A absolute data C 001A C 001B 2h __ VECTORS 01C absolute data C 001C C 001D 2h VECTORS O1E absolute data C 001E C 001F 2h __ VECTORS 020 absolute data C 0020 C 0021 2h VECTORS 022 absolute data C 0022 C 0023 2h VECTORS 024 absolute data C 0024 C 0025 2h VECTORS 026 absolute data C 0026 C 0027 2h VECTORS 028 absolute data C 0028 C 0029 2h __ VECTORS 02A absolute data C 002A C 002B 2h __ VECTORS 02C absolute data C 002C C 002D 2h VECTORS 0O2E absolute data C 002E C 002F 2h __ VECTORS 030 absolute data C 0030 C 0031 2h VECTORS 032 absolute data C 0032 C 0033 2h VECTORS 034 absolute data C 0034 C 0035 2h VECTORS 036 absolute data C 0036 C 0037 2h CODE normal data C 0038 C 006B 34h main TEXT normal data C 00E1 C 00E7 7h startup normal data C 006C C 00E0 75h UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual ZIlOG ase SEGMENTS WITHIN MODULES Module src boot common startupl asm File startupL obj Version 1 0 05 03 2006 09 11 37 Name Base Top Size Segment _ VECTORS 002 C 0002 C 0003 2h Segment FAR BSS E 0100 E 0102 3h Segment startup C 006C C 00E0 75h Segment workingreg R EO R EF 10h Module MAIN C File main obj Version 1 0 05 03 2006 10 58 46 Segment main TEXT C 00E1 C 00E7 7h Module COMMON FLASH1 C Library
142. 18 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 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 1s 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual iH PES PN 7 IIO 0 LN E 307 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 name
143. 21 e HIGH and LOW Operators on page 222 e HIGH16 and LOW16 Operators on page 222 e FTOL Operator on page 222 e LTOF Operator on page 223 e Decimal Numbers on page 223 e Hexadecimal Numbers on page 223 e Binary Numbers on page 223 e Octal Numbers on page 224 Character Constants on page 224 Operator Precedence on page 224 e Automatic Working Register Definitions on page 225 UM013033 0508 Using the Macro Assembler 220 Arithmetic Operators lt lt 2 gt xk Left Shift Arithmetic Right Shift Exponentiation Multiplication Division Modulus Addition Subtraction Zilog Developer Studio ll Z8 Encore User Manual T 1 I Pp NT i I Z V MV M I 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 Not Equal Greater Than Less Than Greater Than or Equal Less Than or Equal Boolean Operators UM013033 0508 Bitwise AND Bitwise inclusive OR Bitwise exclusive XOR Complement Boolean NOT Synonyms Synonyms Synonyms Synonyms Synonyms Synonyms Synonyms Synonyms Synonyms Synonyms eq EQ ne NE egt GT IlUiy LT ge GE le E and AND OL OR XOr XOR not NOT Using the Macro Assembler 221 Zil
144. 263 SPACE clause 235 Special function registers changing values 313 location 91 313 Special Function Registers window 313 Special Function Registers Window button 28 SPECIAL_CASE 313 SPLITTABLE command 286 sprintf function 347 382 sqrt function 345 383 Square root calculating 383 srand function 348 383 sscanf function 347 384 Standard button 86 Standard field 68 Starting a project 2 Startup files 177 customizing 178 STARTUP segment 181 Static frames 138 Static Frames button 64 Static library creating 39 Status bar 310 311 lt stdarg h gt header 345 STDC 149 lt stddef h gt header 346 lt stdio h gt header 346 lt stdlib h gt header 347 Step Into button 26 Step Out button 26 Step Over button 26 step script file command 431 stepin script file command 431 stepout script file command 431 Stop Build button 19 Stop Command button 22 Stop Debugging button 25 stop script file command 431 strcat function 350 384 strchr function 351 385 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog ass strcmp function 350 385 strcpy function 350 385 strcspn function 351 386 String comparison 385 386 String conversion functions 348 354 355 390 392 String placement 142 lt string h gt header 349 String handling functions 349 strlen function 351 386 strncat function 350 387 strncmp function 350 387 strncpy function 350 388 strpbrk function 351 388 strrchr function 351 389 strsp
145. 280 UNRESOLVED IS FATAL 287 WARN 287 WARNING IS FATAL 288 WARNOVERLAP 288 Linker expressions subtract 293 amp and 289 multiply 292 add 289 divide 291 lt lt shift left 293 gt gt shift right 293 bitwise exclusive or 294 or 293 not 294 BASE OF 290 COPY BASE 291 COPY TOP 291 decimal numeric values 292 FREEMEM 291 hexadecimal numeric values 293 HIGHADDR 291 LENGTH 292 LOWADDR 292 TOP OF 293 Linker locator error messages 305 Linker locator warning messages 305 Linking sequence creating 284 list bp script file command 421 LIST directive 237 Listing file assembly 214 Listing Files page 66 Load Debug Information Current Project check box 127 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog uc Load from File dialog box 117 319 Load Last Project on Startup check box 122 LOADMEM script file command 421 Local labels in assembly 263 Local macro label 261 Locals window 322 323 Locals Window button 28 LOCATE command 282 Locator detailed description 275 error messages 305 warning messages 305 lod file extension 95 log function 344 367 log script file command 421 log10 function 344 368 Logarithm computing 367 368 Logarithmic functions 344 long long int type 148 LONG_MAX 342 LONG_MIN 342 longjmp function 345 368 Look In drop down list box Add Files to Project dialog box 55 Select Linker Command File dialog box 83 Look In
146. 3 0508 floating point number in the range of represented value int log10 LDBL MAX and so on Minimum represented positive floating point numbers C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zzilog 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 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 Z8 Encore C Compiler Limits lt limits h gt 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 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 oftype signed char SHRT MAX Maximum value for an object oftype short int SHRT MIN Minimum val
147. 3 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual Zilog 290 Syntax lt expression gt amp lt expression gt BASE OF The BASE OF operator provides the lowest used address of a group address 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 EDATA 800 SBFF RAM allocation OCATE s uninit data at 800 OCATE s nvrblock at 900 DEFINE low data BASE OF s uninit data Using OCATE s uninit data at 800 or OCATE s uninit data at LOWADDR OF EDATA gives the same address the lowest possible address when RANGE EDATA 800 SBFF If OCATE s uninit data at 800
148. 421 20 Z8F0422 28 Z8F0811 20 Z8F0812 28 Z8F0821 20 Z8F0822 28 Z8F08200100KITG Z8Encore XP F0823 8Pin Series Z8F0113XB Z8F0123XB Z8F0213XB Z8F0223XB Z8F0413XB Z8F0423XB Z8F0813XB Z8F0823XB 8 Z8F04A08100KITG Z8Encore XP F0823 Series Z8F0113 Z8F0123 Z8F0213 Z8F0223 Z8F0413 Z8F0423 Z8F0813 Z8F0823 20 28 Z8F04A28100KITG Z8Encore XP F082A 8Pin Series Z8F011AXB Z8F012AXB Z8F021AXB Z8F022AXB Z8F041AXB Z8F042AXB Z8F081AXB Z8F082AXB Z8F04A08100KITG UM013033 0508 Introduction xix Zilog Developer Studio ll Z8 Encore User Manual CPU Family CPU Pin Count Evaluation Kit Name Z8Encore XP F082A Series Z8FO11A 20 28 Z8F04A28100KITG Z8F012A Z8F021A Z8F022A Z8F041A Z8F042A Z8F081A Z8F08A28100KITG Z8F082A Z8Encore_XP_F1680_Series_16K Z8F1680X 20 28 40 44 Z8F16800128ZCOG Z8F1681X Z8F16800144ZCOG Z8Encore_XP_F1680_Series_24K Z8F2480X 20 28 40 44 Z8F16800128ZCOG Z8F2481X Z8F16800144ZCOG Z8Encore_XP_F1680_Series_8K Z8F0880X 20 28 40 44 Z8F16800128ZCOG Z8F0881X Z8F 16800144ZCOG Z8Encore_Z8FMC16100_Series Z8FMC04100 28 32 Z8FMC160100KITG Z8FMC08100 Z8FMC16100 ZILOG TECHNICAL SUPPORT For technical questions about our products and
149. 4K increment UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual For example crc STARTADDRESS 1000 ENDADDRESS 1FFF debugtool copy 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 debugtool copy NAME lt new debug tool name gt creates a copy of the active debug tool named the value given for NAME debugtool copy NAME new debug tool name gt SOURCE existing debug tool name creates a copy of the SOURCE debug tool named the value given for NAME For example debugtool copy NAME Sim3 SOURCE eZ80190 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 of the debugtool create command debugtool create NAME lt debug tool name gt COMMTYPE 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 gt For example debugtool get ipAddress debugtool help The debugto
150. 5 __ AUS SIZED BY TYPE 149 Auto Indent check box 124 Automatic working register definitions 225 Automatically Reload Externally Modified Files check box 122 Index B Backslash used in assembly 216 _ BACKWARD COMPATIBLE BITFIELD S 149 BASE OF 280 290 batch script file command 408 414 Baud Rate list box 101 Baud rate choosing 101 Beginning a project 2 BFRACT directive 229 Binary numbers in assembly 223 Bit field Packing drop down list box 71 BITFIELDS OVERLAP AUS 149 BITFIELDS PACK L2R 149 BLKB directive 230 BLKL directive 230 BLKW directive 230 Blue dots 21 26 311 327 Bookmarks adding 33 deleting 34 finding 35 inserting 33 jumping to 35 moving to 35 next bookmark 35 previous bookmark 35 removing 34 setting 33 using 32 Bookmarks toolbar 22 23 Boolean operators in assembly 221 bp script file command 414 Break button 26 Breakpoints 327 adding 327 deleting 329 disabling 329 enabling 328 finding 328 jumping to 328 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ making active 328 making inactive 329 moving to 328 removing 329 viewing 328 Breakpoints dialog box 52 328 Broadcast Address field 100 bsearch function 349 355 BUFF SIZE macro 335 Build button 18 Build menu 102 Build 103 Clean 103 Compile 103 Manage Configurations 104 Rebuild All 103 Set Active Configuration 103 shortcuts 130 Stop Build 103 Update All Dependencies 103 Build Output window
151. 508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i I PES PN Z I1 Of V MV M 388 amu 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 Synopsis finclude string h char strncpy char sl 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 include lt string h gt char strpbrk char sl char s2 Returns A pointer to the character or a null pointer if no character from s2 occurs in sl Example char ptr char sl COMPASS char s2 PASS ptr strpbrk s1 s2 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i IIA fel 1 LJ V MV M 389 amu 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 char s int c Returns A po
152. 65 ISUPPEE iii a did 365 ISA a do it a e ds 366 EL MC 366 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User Manual ZIlOg IdE D csset ta ii ida p E anaes E oases leads oie ye Sa 366 E 367 ii A A A is 367 LO BNO esses icu ee Re d eRRRTQUU Re ab tee mere EE alas 368 long ip 2 hd da he Ue dac eq bacs so bad d Ode daddied ode ned 368 nro PPM 369 memchr ri ce Bess Roles ou wees BESGESRSURECIR REN nes UEM dr 369 sou MP 370 hunde PEDEM 370 t emmoVe Jc aeo hice hd A cba Sea anna lack ie 371 MESE o E LUE IS 371 MOJE iii rd bie els Chak GbR E needed 371 po x PDR 372 printi 2i hee eases IR ROS Eh hs RE be Medan ER EP ee eee ees 372 A aa a a E a a E a a a a 375 PU ro R EEA 376 RA 376 Cas id Ses aes is Somer faro Jaca pda oa 377 POANOC 4 ii it 377 SCANT a ER sala e eS pee Eare ia 378 Semp x sscckRa ce eee RR diene uq RR ea Bow Rr qe DE Ge ES 381 Jn MP UTI 382 dum a a ia rr is di 382 SPLIT ii e REA be 382 SO Art id ed Ni Ia Bans anid ees accio ad 383 Stand 23 bide ia rd td e ends 383 SS ack el Be pb deese ends dete quos rotae dee da Ru dete ds 384 DCUM DC rec 384 qud 385 iun A A A AA dada 385 NN 385 SMC ci A E A A io Sa eh es aos 386 ql rU 386 nuc M TR D EDT 387 au ACE MULT 387 S ncpy i noeh eed ned d ueesdie rede aed arene WERE RAN MES RUE ERR 388 dus cm 388 SUTChE s Iur ERREUR ERE PE SEINS Geaw eed Gena e e e dus 389 SUPSPM wy 65 5006 bob dd bd Rb hhh bce
153. 8 Encore User Manual Zilog 435 3 Inthe Command field in the Command Processor toolbar type in one of the command sequences in the following sections to use the Flash Loader Displaying Flash Help on page 435 Setting Up Flash Options on page 435 Executing Flash Commands on page 435 Examples on page 436 Displaying Flash Help Flash Setup Displays the Flash setup in the Command Output window Flash Help Displays the Flash command format in the Command Output window Setting Up Flash Options Flash Options lt File Name gt File to be flashed Flash Options OFFSET lt address gt Offset address in hex file Flash Options INTMEM Set to internal memory Flash Options NEBF Do not erase before flash Flash Options EBF Erase before flash Flash Options NISN Do not include serial number Flash Options ISN Include a serial number Flash Options NPBF Do not page erase Flash memory use mass erase Flash Options PBF Page erase Flash memory Flash Options SERIALADDRESS lt address gt Serial number address Flash Options SERIALNUMBER lt Number in Hex gt Initial serial number value Flash Options SERIALSIZE lt 1 8 gt Number of bytes in serial number Flash Options INCREMENT lt Decimal value gt Increment value for serial number Executing Flash Commands Flash READSERIAL Read the serial number Flash READSERIAL REPEAT Read the serial number and repeat Flash BURNSERIAL Program t
154. 8 Excessive Registers required at line lt num gt of function lt func gt Excessive Page 0 registers are required at line number lt num gt The compiler does not perform register spilling so complex expressions that generate this error must be factored into two or more expressions 309 Interrupt function lt name gt cannot have arguments A function declared as an interrupt function cannot have function arguments 310 Index out of range truncating index of lt num gt to 255 The compiler detected an array access outside of the 0 255 byte range Use a temporary variable if you need to access an array element outside of this range 312 Aggregate Copy out of range truncating copy size of lt num gt to 255 The compiler limits structure sizes to 255 bytes An attempt was made to copy structures greater than 255 bytes Use the memcpy library function if structures greater than 255 bytes are required 313 Bitfield Length exceeds x bits The compiler only accepts bit field lengths of 8 bits or less for char bit fields 16 bits or less for short and int bit fields and 32 bits or less for Long bit fields UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Using the Macro Assembler You use the Macro Assembler to translate Z8 Encore assembly language files with the asm extension into relocatable object modules with the obj extension After your relo catable object modules are complete
155. 8 To display all whitespace characters like spaces and tabs Whitespaces Find Ctrl F To find a specific value in the designated file Find Again F3 To repeat the previous search Find in Files Ctrl Shift F3 To find text in multiple files 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 Ctrl F2 To insert a bookmark in the active file for the line where your cursor Bookmark is located or to remove the bookmark for the line where your cursor is located Next F2 To position the cursor at the line where the next bookmark in the Bookmark 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 Shift F2 To position the cursor at the line where the previous bookmark in the Bookmark 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 project Bookmarks Project Menu Shortcuts There is one shortcut for the options on the Project menu Option Shortcut Description Settings Altt F7 To display the Project Settings dialog box Build Menu Shortcuts These are the shortcuts for the options on the Build menu Option Shortcu
156. 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 be converted 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 and printf Conversion Characters on page 374 Synopsis finclude lt stdio h gt int printf 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 By default Zilog compilers parse printf and sprintf format strings and generate calls to lower level support routines instead of generating calls to printf and sprintf For UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual ZILOG ws more information see the description of the genprintf option in Generate Printfs Inline on page 70 NOTE The UART needs to be initialized using the Zilog init uart function See init uart on page 167 printf Flag Characters The result of the conversion is left justified within the field F The result of a signed conversion always
157. AM RDATA EDATA in ROM so that it can be initialized at run time Syntax COPY lt segment gt lt name gt at lt expression gt lt segment gt can only be a segment lt name gt can only be an address space NOTE The linker recognizes the special space NULL NULL is not one ofthe spaces that an object file or library can reside in 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 Examples Example 1 To make a copy of a data segment in ROM use the following procedure 1 Inthe assembly code define a data segment for example dataseg to be a segment located in RDATA This is the run time location of dataseg 2 Use the following linker command COPY dataseg ROM The linker places the actual contents associated with dataseg in ROM the load time location and associates RDATA the run time location addresses with labels in dataseg UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual i I PES SN Z I1 Of amp Y Sj 280 I NOTE You need to copy the dataseg contents from ROM to RDATA at run time as part of the startup routine You
158. AXARGS int ptr no 0 if n ptrs MAXARGS n ptrs MAXARGS va start ap n ptrs while ptr no n ptrs UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual d 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 era 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 include lt stdio h gt int vprintf 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 Sd Sd 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 char format va_list arg Returns The number of characters written in the array not counting the terminating null character Example va_list va char buf 80 UM013033 0508 C Standard Library Zilog Developer Studio
159. Baie duty dhol deeds 220 Arithmetic Operators 2 0 0 ccc eee 221 Relational Operators 0 0 0 ect ntn teen eens 221 Boolean Operators merci eh eae wre kaw ei ea E vas 221 HIGH and LOW Operators 1 0 0 0 ccc cette eens 222 HIGH16 and LOW16 Operators 0 es 222 BTOLOperator 11 4 Ress GER ace eR aq ai 222 ETOF Operator uma m ee Sed ea dd ted ed iO gece 223 UM013033 0508 Table of Contents Directives ALIGN ELS ene Eee RE ERR RS Structured Assembly Structured Assembly Inputs Structured Assembly Processing Conditional Assembly ee E Macros Macro Definition 0 0 0 0 00 eee Concatenation 0 0 cc ccc Macro Invocation 000 ce eee eee UM013033 0508 Decimal Numbers oo ooooooooo oo Hexadecimal Numbers 0 Binary Numbers 0 00000 eee eee Octal Numbers 0 00000 cee eee eee Character Constants 00 00 00 cee Operator Precedence o oo ooooooooo o Automatic Working Register Definitions Ae io wees A A IE RR eek ere ind ave asl NEWPAGE eeee ee NOLIST ut aaa Sete Roo oo te ae ORG Zl seid 4s ia EG o EE ERE e ES VARS A E E EE E IE ADEE 2 uo ee ete e teh ts XREF vir sd ea ass ORO S es Structures and Unions in Assembly Code Zilog Developer Studio ll Z8 Encore User Manual ran ILU U EY M Table of Contents vii Zilog Developer Studio ll Z8 Encore User Manu
160. 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 Lp The Select Linker Command File dialog box is displayed Select Linker Command File Look in e sre amp er E3 cony File name Files of type Linker Command Files linkemd Ink y Cancel Figure 60 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 UM013033 0508 Using the Integrated Development Environment 83 Zilog Developer Studio ll Z8 Encore User Manual 4 Click Select The Use Existing button is the alternative to the Always Generate from Settings button see Always Generate from Settings on page 81 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 is applied every time When the Use Existing button is selected many project settings are grayed out including all the settings on the Linker pages These settings are disabled because when you have specified that an existing linker command file is to be used those settings have
161. Check on page 319 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 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOQ Changing 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 2 Type the new value and press the Enter key The changed value is displayed in red NOTE The ASCII text for the value is shown in the last column Viewing Addresses To quickly view or search for an address in the Memory window do the following 1 Inthe Memory window highlight the address in the Address field as shown in the following figure NOTE To view the values for other memory spaces replace the C with a different valid memory prefix You can also change the current memory space by selecting the space name in the Space drop down list box Ron Address aono Figure 103 Memory Window Starting Address 2 Type the address you want to find and press the Enter key For example find 0395 The system moves the selected address to the top of the Memory window as shown in the following figure UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Zilog su Space Rom y Add
162. Code 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 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 The structure and union directives are described in the following sections e STRUCT and ENDSTRUCT Directives on page 244 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i I PES PN Z I1 Of V M E 244 I e TAG Directive on page 245 e UNION Directive on page 247 e WITH and ENDWITH Directives on page 247 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 dir
163. Cursor button 26 Run time library 160 337 formatting 160 337 functions 351 nonstandard headers 161 standard headers 337 S Safest button 62 Safest configuration 62 Sample program 2 Save All button 17 Save As dialog box 45 101 102 Save as Type list box 45 Save button 17 Save Files Before Build check box 122 Save In drop down list box 102 Save In list box 45 Save Project Before Start of Debug Session check box 126 Save to File dialog box 116 318 Save Restore Project Workspace check box 122 SAVEMEM script file command 430 Saving a project 14 scanf function 347 378 conversion characters 380 SCHAR_MAX 342 SCHAR_MIN 342 SCOPE directive 263 Script file commands 413 definition 412 example 412 writing 412 Search functions 349 351 355 Index SEARCHPATH command 285 SEGMENT directive 213 238 Segments 181 211 276 absolute 211 213 214 234 276 address space 235 alignment 213 234 allocation order 286 attaching code 213 attaching data 213 copying 279 280 creating 213 defining 233 initialization 234 linking sequence 284 locating 234 282 moving 278 origin 213 predefined 212 relocatable 211 214 276 renaming 278 setting maximum size 283 setting ranges 285 splitting 286 types 211 user defined 213 Select Build Configuration list box 18 Select Configuration dialog box 103 Select Linker Command File dialog box 83 Select Project Name dialog box 3 40 select_port function 171 SEQUENCE comman
164. DIF assembler directives can be labeled If a label is specified a warning message is issued and the label is discarded REPEAT Structured Assembly Block Inputs The SREPEAT SBREAK SCONTINUE and SUNTIL assembler directives are used to test execution time conditions and conditionally execute object code based on the results of the test Syntax SREPEAT comment SCONTINUI SBRI statements EAK SIF condition2 comment statements E SIF condition3 comment statements SUNTIL condition comment The following qualifications elaborate the syntax and semantics of the structured assembly test directives Unless otherwise specified violations of these qualifications cause the assembly to fail UM013033 0508 The SREPEAT and SUNTIL assembler directives must be specified in that order The BREAK assembler directive is optional It can be specified an arbitrary number of times between The SCONTINUI the SREPEAT and SUNTIL assembler directives E assembler directive is optional It can be specified an arbitrary number of times between the SREPEAT and SUNTIL directives Any valid assembler statement can appear in the statements sections of the structured assembly test directives This means among other things that structured assembly test directives can be
165. Developer Studio ll Z8 Encore User Manual The following table lists some command line examples and the corresponding script file commands Table 12 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 general debug TRUE eZ8asm debug option linker igcase FALSE eZ8link NOigcase option librarian warn FALSE eZ8lib nowarn The following script file options are available Assembler Options on page 424 Compiler Options on page 425 Debugger Options on page 426 General Options on page 426 Librarian Options on page 427 Linker Options on page 427 ZSL Options on page 429 Assembler Options Table 13 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 UM013033 0508 Using the Command Processor 424 Zilog Developer Studio ll Z8 Enc
166. ED TO CHANGE MY SOURCE CODE BECAUSE OF ZSL No The sio c file of RTL has been modified to call ZSL APIs so you can continue to use the run time library RTL without changing your source code But Zilog advises you to change your source code to make direct calls to ZSL This is recommended for the fol lowing reasons The calls in RTL support only one UART UARTO or UART at any given time in the library You cannot switch between the UARTs dynamically There is a small code size increase in the RTL due to the additional overhead of calling ZSL APIs from sio c Future releases of RTL might or might not continue to support this method of indirectly accessing the UARTS via ZSL Zilog Standard Library Notes and Tips Zilog Developer Studio ll Z8 Encore User Manual C Standard Library The ANSI C Compiler provides a collection of run time libraries for use with your C pro grams The largest section of these libraries consists of an implementation of much of the C Standard Library The Z8 Encore 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 latter are described in Run Time Library on pa
167. ENGTH on page 292 UMO13033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual iH PES SN 7 IIO 0 amp Y Sj 289 e LOWADDR on page 292 e Multiply on page 292 e Decimal Numeric Values on page 292 e Hexadecimal Numeric Values on page 293 e Or on page 293 e lt lt Shift Left on page 293 e gt gt Shift Right on page 293 e Subtract on page 293 e TOP OF on page 293 e Bitwise Exclusive Or on page 294 e Not on page 294 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 Examples Correct example using segments SEQUENCE seg2 segl Calculate seg2 before segl LOCATE segl AT TOP OF seg2 1 Do not do this cannot use expression of segl to locate segl LOCATE segl AT TOP OF seg2 LENGTH OF segl Add The Add operator is used to perform addition of two expressions Syntax expression expression amp And The amp And operator is used to perform a bitwise amp of two expressions UM01303
168. ESS 100 Savemem SPACE ROM FORMAT HEX c temp file hex Savemem SPACE ROM FORMAT TEXT c temp file txt STARTADDRESS 1000 ENDADDRESS 2FFF 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 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U IL Y Ly 431 e 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 is the syntax of the step com mand step stepin The stepin command
169. EXP 342 Idexp function 344 366 Idiv function 349 367 ldiv t 347 LENGTH operator 292 Librarian command line options 407 options 427 Librarian page 77 78 Libraries defining 278 functions 351 object 275 Library functions 351 Limit Optimizations for Easier Debugging check box 63 lt limits h gt header 342 LINE 149 Line continuation in assembly 216 Link map file contents 282 creating 282 284 Linker commands 277 creating link map file 282 284 creating linking sequence 284 defining holes in memory 91 detailed description 275 error messages 305 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog 4 expressions 288 file format 281 generating debug information 281 284 generating warnings 287 invoking 276 objects manipulated during linking 275 opening 276 options 427 running 276 running from the command line 401 search order 285 starting 276 suppressing warnings 284 symbols 186 warning messages 305 Linker command file 276 commands 277 for C programs 181 linker symbols 186 referenced files 183 sample 187 Linker commands lt outputfile gt lt module list 278 BASE OF 280 CHANGE 278 COPY 279 COPY BASE OF 280 COPY TOP OF 280 DEBUG 281 DEFINE 281 FORMAT 281 GROUP 282 HEADING 282 LOCATE 282 MAP 282 MAXHEXLEN 283 MAXLENGTH 283 NODEBUG 284 NOMAP 282 284 NOWARN 284 ORDER 284 Index RANGE 285 SEARCHPATH 285 SEQUENCE 286 SORT 286 SPLITTABLE 286 TOP OF
170. Encore User Manual Variable Arguments lt stdarg h gt 0 0 345 Standard Definitions stdde h 0 0 eee eens 346 Input Output lt stdio h gt 2 een eee 346 General Utilities lt stdlib h gt 2 cence ees 347 String Handling lt string h gt 2 0 0 tenes 349 Standard Functions ERREUR TATUR P AR e A eee 351 A e Dala io EA 352 O rd muet tub dei eiue pic e dde on 352 COS ev 353 ASIN T I r 353 LM NETT 353 AOL iba pes BOB his es 354 MO EP NEP 354 AOL Bon edb Bia ee E hae Boa eee ee eee Ree eek NER Ede ds 355 A A a a 355 DSSALC ir as 355 callo ui sd etate Idae e e aa e e rH des 356 Jj CP rs 357 a In E E A E E E E A A aE 357 COn EEA E E EEO A ea AEE E E E E S 358 AIV rena aa aa a a E hoe a a a ae oe 358 XD e sia aa dt ba eut debetur ubt Deos durae debt ea 359 WANDS CE 359 PV OE secs CPP TDI 360 ini 360 i EET 360 lo E C Be edn ed a dle mds A he iat a E ES 361 geteliarz ceres does ha dks De RUE E Se A E ANA PEERS het ca 361 p qc 362 SO D L ec PU oe 362 alpha lt tc d ous tee ease ead cee KOSS NEAR IG bed PR Roe ee RAE S 363 BCD e dacs apt ise forse oan forts erie oU Wes a tent Poe eee Got faa urbain Ran Or acne 363 JSdIglt iine sce qa eR e equ RU UR dished quis ca E ee RR AS depen aUe UG aD eds 363 SOT ADS is ae ee oe or o ete do erede Bed ee BADR Gan ie te iba des 364 jn c PTT 364 uc TT 364 ijui PD wm 365 ISSPACG PEE 3
171. F1680 Series has a user controlled Program RAM PRAM area to store interrupt service routines ISRs of high frequency interrupts Program RAM ensures low average current and a quick response for high frequency interrupts To use this feature the ISRs in the ZSL UART must be provided with the option of being placed in the PRAM segment When you select the Place ISR into PRAM check box ZDS II addresses the zs1F1680U0XXX 1ib library zs1F1680U1XXX 1ib library or both libraries to place ISRs for UARTO and UARTI in PRAM You can place ISRs in PRAM only when the UART is set in interrupt mode To set the UART in interrupt mode edit the include zilog uartcontrol h header file by defining the UARTO MODE UARTI MODE symbol as MODE INTERRUPT and rebuilding the libraries For more information on rebuilding the ZSL see the Zilog Stan dard Library API Reference Manual RM0038 For the Z8 Encore XP F1680 Series the default ZSL libraries are in the zslF1680XXX 1ip files The following functions are placed in PRAM segment within each library zs1F1680U0XXX lib e VOID isr UARTO RX VOID VOID isr UARTO TX VOID zs1F1680U1XXX lib e VOID isr UART1 RX VOID VOID isr UART1 TX VOID Linker Commands Page The options in the Commands page are described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIl0d E Project Settings Config
172. FREQ14000 166 FREQ16000 166 FREQ18432 166 FREQ20000 166 frexp function 344 361 FTOL operator 222 Function names in assembly 158 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ asc Functions 344 abort 352 abs 352 acos 353 asctime 149 asin 353 atan 353 atan2 354 atof 354 atoi 355 atol 355 bsearch 355 calloc 356 ceil 357 character case mapping 340 character handling 339 character input 347 character output 347 character testing 339 comparison 350 concatenation 350 copying 350 cos 357 cosh 358 detailed descriptions of 351 DI 164 div 358 EI 165 error conditions 343 exp 359 fabs 359 floor 360 fmod 360 formatted input 347 formatted output 347 free 360 frexp 361 getch 165 getchar 361 gets 362 hyperbolic 344 Index INIT FLASH 166 init uart 167 integer arithmetic 349 isalnum 362 isalpha 363 iscntrl 363 isdigit 363 isgraph 364 islower 364 isprint 364 ispunct 365 isspace 365 isupper 365 isxdigit 366 kbhit 167 labs 366 ldexp 366 ldiv 367 log 367 log10 368 logarithmic 344 longjmp 368 malloc 369 mathematical 343 memchr 369 memcmp 370 memcpy 370 memmove 371 memory management 349 memset 371 miscellaneous 349 modf 371 multiplication 366 nearest integer 345 nonlocal jumps 345 nonstandard input 163 nonstandard output 163 pow 372 power 345 printf 372 pseudorandom sequence generation 348 UM013033 0508 Zilog Develop
173. For functions returning an aggregate see Special Cases on page 157 Deallocate the local frame set the stack pointer to the current value of frame pointer if required and restore the frame pointer from stack If the called function is a monitor function only restore the interrupt control register IRQCTL from the stack Return All registers other than the return register are considered as caller save that is they are saved and restored by the caller function The flag register is not saved and restored by the caller function For a static frame function steps 2 and 5 are only done if the debug Debug or reduceopt Limit Optimizations for Easier Debugging option is selected NOTE In the case of a monitor function add 1 to the offsets of all arguments on the stack to take into account the insertion of the saved interrupt control register IRQCTL on the stack Return Value The compiler places the return values of a function in the following registers Return Type Return Value Registers char RO short RO R1 int RO R1 long RO R1 R2 R3 float RO R1 R2 R3 double RO R1 R2 R3 UMO13033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Return Type Return Value Registers near RO far RO R1 rom RO R1 For functions returning an aggregate see Special Cases on page 157 for details on how they are returned Special Cases Som
174. I External Dependencies Expected Output Welcome to ZiLOG Developer Studio Hello world 3 HE 3 HE 3 3 3 3 3 3 J 3 3 3 3 3 3 3 3 J amp HE 3 3 J 3 3 HEHE METETE 9 3 3 3 9 J 3 3 3 3 3 3 9 9 3 3 9 3 3 3 3 3 3 3 3 9 3 3 3 3 3 3 3 30 include lt stdio h gt Xdefine ZDS NAME ZiLOG Developer Studio void main EC int d zl int i 5 4 El sample Connected to target Simulator Starting debug session project sample configuration Debug Loading file C Program Files ZiLOGNZDSII_Z8Encore _4 11 0 samples Tutorial Debug sample lod Loading file C Program Files ZiLOGNZDSII_Z8Encore _4 11 0 samples Tutorial Debug sample lod success TTP To Build Debug A Findin Files A Findin Files A _ For Help press F1 Ln 26 Col 1 STOP Figure 97 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 then 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 executi
175. I EE LOW MACEXIT MI ASG byte ELSE E NDMAC Fr P El COPY DD DMA DW24 E NDMACRO iral RROR FCB G HIGH IFNDEF IFZ GI LFRACT EF MACFIRST MLIST Using the Macro Assembler MNOLIST NEWPAGE N O OV U U z O ca D x E N G ca ES Q H PP EXPRESSION MODULE NOCONDLIST rr4 STRUCT TIMERO TRAP UBFRACT ULFRACT USER EXIT WDT ZBR El D N ZIF ZW E ND NC NOLIST OFF rrl10 rr6 SHORTRI SUBTITLI TIMER1 UARTO_RX UFRACT ULT ital Q CI USER WARNING word ZCONTINUE ZIGNORE ZWHILE Assembler Numeric Representation Zilog Developer Studio ll Z8 Encore User Manual ZIlOg Ej N NOMACLIST O PAGEWIDTH PP IFDEF PP MACEXIT U P SBLOCK PW ri3 r4 r9 rr12 rr8 ro r1 r5 ELIF EVAL IFMA PP MACRO PP VAR 4 RE SET LE SCOPI SP 14 GI T TAG TIMER3 UART1_RX UGT UN SUPPORTED VECTOR XREF NOTE Additionally do not use the instruction mnemonics or assembler directives as symbol or variable names Numbers are represented internally as signed 32 bit integers Floating point n
176. 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 Syntax IFSAME lt string_const gt lt string_const gt lt code_body gt ELSE lt code_body gt ENDIF UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 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 lt arg_number gt is 0 the result is TRUE if no arguments were provided otherwise the result is FALSE Syntax IFMA lt arg_number gt lt code_body gt ELSE lt code_body gt ENDIF MACROS Macros allow a sequence of assembly source lines to be represented by a single 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 expand
177. M 373 amu 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 e 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 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 e Anoptional h specifies that a following d i o 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 i 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 e A character that specifies the type of conversion to be applied e
178. M013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual The effect of this drop down list box on overall program size and speed can only be assessed globally across the entire application which the compiler cannot do automati cally 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 drop down list box might make 2 functions larger and the other 48 functions smaller Also if those two func tions run slower with the drop down list 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 Because the effect of applying this drop down list box must be evaluated across an appli cation as a whole user experimentation is required to test this for an individual applica tion Only a small fraction of applications benefit from setting the Use Register Variables drop down list box to Off NOTE This drop down list box interacts with the Limit Optimizations for Easier Debugging check box on the C page see Limit Optimizations for Easier Debugging on page 63 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 drop down list box is disabled grayed out when t
179. Met xe A ERROR EUER be RR Daw Gam Ed abe RR 128 Shortcut Keys ions eese eb Eo b ass elt du tuba Duet dosed 129 File Men Shortcuts 1 nere pe PREX a gece 129 Edit Menu Shortcuts 2 02 0 eect e ene eens 129 Project Menu Shortcuts ee eer Re ars rip dialed PA P P ons 130 Build Menu Shortcuts 0 ccc s 130 Debug Men Shortcuts 1 25 oues eee Ue ae Os ENE Ra Rs 131 Using the ANSI C Compiler oooooooooooomocnocnorocrororononororonono 132 Language Extensions lesse ttt nett teen eee 132 Additional Keywords for Storage Specification 00000 c eee eee 134 Memory Models ereti enrere cette e 137 Call Frames y eoa ne dda bah QU ACERO a Rha daa a e alee 138 Interrupt Support 0 0 etn ene nen en eas 140 Monitor Function Support 0 0 0 teen ene 141 String Placement 23x54 dea Geo hae Coa Re ee eee TAE E ea weak 142 Inline Assembly ieor coe eee ERE ces Pee ds Gos 143 Placement Directives seeren bean eae ene Pare EATE EAEE 143 Char and Short Enumerations 0000 cece cece cece ene nee 144 Setting Flash Option Bytes in C o 0ooooooooooooror eens 145 Program RAM Support Z8 Encore XP 16K Series Only 146 Preprocessor warning Directive Support 00 0 cece eee eens 147 Supported New Features from the 1999 Standard 0 0000 c eee 147 Type SIZES aii Bes Packs HAUG AS ce bed Relea Sed MP Ree noe ees 148 Predefined Macros siei dia nie cece cece cent s 149 Example
180. NOLOGY DESCRIBED HEREIN OR OTHERWISE The information contained within this document has been verified according to the general principles of electrical and mechanical engineering Z8 Z8 Encore and Z8 Encore XP are registered trademarks of Zilog Inc All other product or service names are the property of their respective owners UMO13033 0508 Revision History Zilog Developer Studio ll Z8 Encore User Manual o ef pf d v v Revision Date Level Section Description May 2008 33 All Updated for the ZDS II 4 11 0 release December 32 Using the Command Processor appendix Updated 2006 on page 408 Firmware Upgrade Selected Debug Tool on page 118 Uarts on page 79 New Project on page 39 and Debugger Page on page 96 Flash Loader on page 110 Using the Macro Assembler chapter and Compatibility Issues appendix Appendix D Using the Command Processor Structures and Unions in Assembly Code on page 243 ORG on page 238 Memory Window on page 314 Added path for Ethernet Smart Cable upgrade information Described new Place ISR into PRAM check boxes Added description of the Use Page Erase Before Flashing check Added description of the Use Page Erase check box Deleted PL PW PAGEWIDTH and PAGELENGTH Added the checksum fillmem loadmem and savemem commands Added new section Updated section Updated the note about PRAM July 20
181. 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi seconds which can be viewed in the Debug Clock window when running the simulator 3 Click OK Add Click Add to display the Create New Target Wizard dialog box Create New Target Wizard Create Target This wizard will allow you to quickly create a new Target Please enter a Target Name 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 V Place Target File in Project Directory The Cancel button will end the process without creating a Target Cancel Figure 67 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Copy Target Copy or Move Source Use Selected Target 28F64200100KIT C Target File El Delete Source Target After Copy Destination
182. Name for New Target iz8F64200100KIT Place T arget File in Project Directory C ZDS Default Directory C Another Location SaaS E T Figure 68 Target Copy or Move Dialog Box 1 Select a target in the Target area of the Debugger page 2 Click Copy 3 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 i 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 4 Select the Delete Source Target After Copy check box if you do not want to keep the original target 5 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 6 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIlOG 100 Debug Tool Select the appropriate debug tool from the Current drop down list box Ifyou select EthernetSmartCable and click Setup in the Debug Tool area the Setup Ethernet Smart Cable Communication dialog box is displayed NOTE I
183. O isr timer0 See SET VECTOR on page 172 for supported values of vectnum _At Keyword The At keyword described in Placement Directives on page 143 can be used in con junction with the interrupt keyword to associate an interrupt handler with an interrupt vector Because the interrupt vectors of the Z8 Encore microcontroller are usually in ROM only one handler can be associated with an interrupt vector For example include lt eZ8 h gt void interrupt isr timerO void At TIMERO Monitor Function Support A special function qualifier type is provided to support users who are interested in creating a real time operating system RTOS kernel for the Z8 Encore Functions defined with this qualifier are treated differently from other functions at the point of function entry and function exit At function entry the global interrupt status is saved on the stack and inter rupts are then disabled before any other action is taken including the setup of the normal stack frame if any Upon exit from a monitor function the last thing that happens before returning from the function is that the previous interrupt state is restored from the stack These operations are useful or perhaps even critical in designing an RTOS and also pro vide the fastest possible way of disabling interrupts in a critical section of kernel code To define a function of this type use the monitor pragma as in the following code pra
184. PU has multiple address spaces the C Compiler provides language extensions to specify the storage for string constants Inline Assembly on page 143 The C Compiler provides directives for embedding assembly instructions and directives into the C program Placement Directives on page 143 The placement directives allow users to place objects at specific hardware addresses and align objects at a given alignment Char and Short Enumerations on page 144 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 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Setting Flash Option Bytes in C on page 145 The Z8 Encore CPU has two Flash option bytes The C Compiler provides language extensions to define these Flash option bytes Program RAM Support Z8 Encore XP 16K Series Only on page 146 The Z8 Encore XP 16K Series devices have additional RAM that can be used as Program RAM PRAM optionally The Z8 Encore C Compiler provides syntax to place code for a function in PRAM Preprocessor warning Directive Support on page 147 The C Compiler supports warning directives in addition to error directives for diagnostic message generation Supported New Features from the 1999 Standard on page 147 The Z8 Encore C Compiler is based on the 1989 ANSI C standard Some new
185. 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 was 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual T I PES NT Z ILIO XV M M 306 712 Space space is not located on a segment base The address space is not aligned with a segment boundary 713 Space lt space gt is 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 7
186. 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 Bit field Packing This drop down list box can be set to Backward Compatible Most Compact or Nor mal The Most Compact setting which is the default for new projects packs the bit fields as tightly as possible This packing saves data space in your application The Normal set ting preserves the declared type of all the individual bit fields That is in an example like the following typedef struct UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual char bf1 6 short bf2 9 long bf3 17 bf struct the N
187. Push the frame pointer onto the stack and allocate the local 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 3 Execute the code for the function 4 Ifthe function returns a scalar value place it in the return value registers For functions returning an aggregate see Special Cases on page 157 5 Deallocate the local frame set the stack pointer to the current value of frame pointer and restore the frame pointer from stack 6 Ifthe called function is a monitor function only restore the interrupt control register IRQCTL from the stack 7 Return All registers other than the return register are considered as caller save that is they are saved and restored by the caller function The flag register is not saved and restored by the caller function The function call mechanism described in this section 1s a dynamic call mechanism In a dynamic call mechanism each function allocates memory on the stack for its locals and temporaries during the run time of the program When the function has returned the UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual memory that it was using is freed from the stack The following figure shows a diagram of the Z8 Encore C Compiler dynamic call frame layout NOTE For functions that are declared to be monitor functions by the use of p
188. Registers Window NOTE You cannot modify the registers or memory while in run mode Click the Registers Window button to show or hide the Registers window The Registers window displays all the registers in the standard Z8 Encore architecture Registers SP O 7FE R R2 00 R3 R5 00 R6 R8 00 R9 Ril oo R12 R14 oo Ri15 RP EO RRO 0000 RR4 0000 RR 6 0000 RR10 0000 RR12 0000 C 0 1 RR14 0000 0 H 0 Figure 99 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 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOQ as Special Function Registers Window Click the Special Function Registers Window button to open one of ten Special Function Registers windows The Special Function Registers window displays all the special func tion registers in the standard Z8 Encore architecture 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 Group FLASH FCTL 00 FSTAT 00 FPS 00 FPROT 00 FFREQH 00 FFREQL 00 Figure 100 Special Function Registers Window NOTE There are several SFRs that when read are cleared or clear an associated register To prevent the debugger from changin
189. 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 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 500 Instruction not supported The instruction is not supported on the specified CPU 501 CPU not specified The CPU has not been specified 502 Symbol not a struct union The name of a structure of union is required 503 STRUCT ENDSTRUCT name mismatch The optional name on a ENDSTRUCT or ENDWITH directive does not match the name on the opening STRUCT or WITH directive UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 504 Directive not permitted in struct Attempt to use a directive not permitted inside a STRUCT or UNION definition 505 Nested STRUCT directive Attempt to nest STRUCT directives 506 No active WITH statement ENDWITH directive does not have a matching WITH directive 507 WITH symbol resolves ambiguously A symbol matches more than one name inside a nested WITH directive 508 Unused COUNT on TAG directive Attempt to specify a repeat count on a TAG dir
190. S 024 Module common vect26 asm Library 09 17 43 Name chelpD lib Version C 001B 2h 1 0 05 03 2006 Top Size C 001D 2h 1 0 05 03 2006 Top Size C 001F 2h 1 0 05 03 2006 Top Size C 0021 2h 1 0 05 03 2006 Top Size C 0023 2h 1 0 05 03 2006 Top Size Cr0025 2h UMO13033 0508 Using the Linker Locator 301 chelpD lib C 0026 Version Zilog Developer Studio ll Z8 Encore User Manual Zilog chelpD lib Version chelpD lib Version chelpD lib Version chelpD lib Version Segment _ VECTORS 026 Module common vect28 asm Library 09 17 43 Name Segment VECTORS 028 Module common vect2a asm Library 09 17 43 Name Segment VECTORS 02A Module common vect2c asm Library 09 17 43 Name Segment VECTORS 02C Module common vect2e asm Library 09 17 43 Name Segment VECTORS 02E Module common vect30 asm Library 09 17 43 Name Segment VECTORS 030 Module common vect32 asm Library 09 17 43 Name chelpD lib Version C 0027 2h 1 0 05 03 2006 Top Size C 0029 2h 1 0 05 03 2006 Top Size C 002B 2h 1 0 05 03 2006 Top Size C 002D 2h 1 0 05 03 2006 Top Size C 002F 2h 1 0 05 03 2006 Top Size C 0031 2h UMO13033 0508 Using the Linker Locator 302 Zilog Developer Studio ll Z8 Encore User Manual Zilog Segment VECTORS 032 C 0032 C 0033 2h Module common Nvect34
191. SE UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual ZSL Options For ZSL options the tool_name is middleware For example option middleware usezsl TRUE Table 18 ZSL Options Option Name Corresponding Option in Project Settings Dialog Box Acceptable Values usezsl ZSL page Include Zilog Standard Library Peripheral Support TRUE FALSE check box or Objects and Libraries page Zilog Standard Library Peripheral Support check box zslports ZSL page Ports area comma delimited string Port A Port D zsluarts ZSL page Uarts area comma delimited string UART0 UART1 print The print command writes formatted data to the Command Output window and the log if 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 lt format_string gt expression expression 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 quit The quit command exits the current debug session The following is the syntax of the quit command quit UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual
192. Sd i guis Include Zilog Standard Library Peripheral Support Sil Code Generation h Listing Files 3 Preprocessor Sil Advanced Sil Deprecated 5 ZSL El Linker h Commands h Objects and Libraries 3 Address Spaces SS Warnings Sh Output Sa Debugger Note OK Cancel Help Figure 57 ZSL Page Z8 Encore XP F1680 Series of the Project Settings Dialog Box Include Zilog Standard Library Peripheral Support Select the Include Zilog Standard Library Peripheral Support check box to use the func tions contained in the Zilog Standard Library Some of the functions in the C Standard Library especially I O functions like printf rely on lower level functions that they call to eventually interact with hardware devices such as UARTs The Zilog Standard Library provides these lower level support functions specialized to Z8 Encore There fore if you choose to deselect this check box and avoid using the functions of the ZSL you must provide your own replacements for them or else rewrite the calling functions in the C run time library so that the ZSL functions are not called Ports In the Ports area select the check boxes for the ports that you are going to use Uarts In the Uarts area select the check boxes for the UARTS that you are going to use UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual I1 OTI ILUO LUJ EY M 80 The Z8 Encore XP
193. Selects the bit field packing algorithm The tight setting produces the most compact packing which is the default The normal setting allocates space in the structure that corresponds exactly to the declared type of each bit field The compatible setting produces a packing that is compatible with the less efficient algorithm that was used before ZDS II release 4 11 0 If you have an older project that uses both C and assembly code to access bit fields you probably need to use bfpack compatible const ram rom Selects where const variables are placed The default is to place const variables in ram This is a depreciated option use the rom keyword instead of const to place const data in rom cpu cpu Sets the CPU debug Generates debug information for the symbolic debugger This is the default define def Defines a symbol and sets it to the constant value For example define myvar 0 The alternate syntax define myvar is the same as define myvar 1 fastcall Pass parameters in registers fplib Links with the floating point emulation library 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 jmpopt Turns on application of branch optimizations keepasm Keeps the compiler generated assembly file keeplst Keeps the assembly listing file 1st UM013033
194. Studio ll Z8 Encore User Manual Zilog 2 Inthe Configuration drop down list box make sure that the Debug build configuration is selected For your convenience the Debug configuration is a predefined configuration of defaults set for debugging For more information on project configurations such as adding your own configuration see Set Active Configuration on page 103 lil Project Settings Configuration Debug y Sis Assembler fi c CPU Family Z8Encore XP F1 B8 Series 16K y Sil Code Generation 3 Listing Files CPU Z8F1680xJ be SS Preprocessor Build ES Si Advanced lv Show Warnings Sil Deprecated IV Generate Debu 5s ZSL i i un Intermediate Files Directory Command Ae TE C Program Files ZiLOG ZDSII_Z8Encorel_4 11 0 s il 3 Address Spaces E Warnings SS Output 5d Debugger mo 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 Cancel Help Figure 9 General Page of the Project Settings Dialog Box 3 Select the Assembler page 4 Make sure that the Generate Assembly Listing Files Ist check box is selected UM013033 0508 Getting Started li Project Settings Zilog Developer Studio ll Z8 Encore User Manual Zilog Configuration Debug z 5e General 2m 2 Rl c Sil Code Generation h Listing Files 3 Preprocessor Sil Advanced Sh Deprecated Hd ZSL i Lin
195. TH DS 1 DAYDS 1 YEAR DS 2 DSIZE ENDSTRUCT DATI Gl NAMELEN EQU 30 EMPLOYEE STRUCT NAME DS NAMELEN SOCIAL DS 10 START TAG DATE SALARY DS 1 ESIZE ENDSTRUCT EMPLOYEE EWYEARS TAG DATE EWYEARS DS DSIZE he TAG directive in the last example above creates the symbols NEWYEARS MONTH EWYEARS DAY and NEWYEARS YEAR The space for NEWYEARS is allocated by the Ds directive 2g 22 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zn E ZIt Og 247 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 count name_2 DS count2 tname 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 wit
196. The linker issues a warning if it is asked to COPY any noncontiguous segment UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual iH JE ms fl a PB I f y A I1 LJ LJ Z V MV M 287 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 1f the linker cannot resolve any undefined symbol By default the linker proceeds with gen erating output files if there are any undefined symbols Syntax UNRESOLVED gt IS gt FATAL
197. The source file contains only white spaces blanks tabs new lines comments and so on after preprocessing 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 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 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 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
198. The target get command displays the current value for the given data item for the active target The following is the syntax of the target get command target get lt data item gt 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 of the 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 displays the names of all available targets restricted to the currently configured CPU family target list CPU lt cpu name gt displays the names of all available targets associated with the given CPU name target list FAMILY lt family name gt displays the names of all available targets associated with the given CPU family name UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual zilog ass For example target list FAMILY eZ80 target options NOTE See a target in the following directory for a list of categories and options ZILOGINSTALLVZDSII product versionNtargets lt ZDS Installation Directory Ntargets 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_eZ80Acclaim version where lt version gt might b
199. UCT directive 244 ENDWITH directive 247 ER 225 FCALL directive 155 FRAME directive 154 FTOL operator 222 hex file extension 95 LTOFoperator 223 map file extension 283 R 225 RR 225 STRUCT directive 244 Index TAG directive 245 UNION directive 247 WITH directive 247 WRG 225 divide 291 shift left 293 lt assert h gt header 338 lt ctype h gt header 339 lt errno h gt header 340 lt eZ8 h gt header 162 lt float h gt header 340 lt limits h gt header 342 lt math h gt header 343 lt outputfile gt lt module list gt command 278 lt setjmp h gt header 345 lt sio h gt header 163 lt stdarg h gt header 345 lt stddef h gt header 346 lt stdio h gt header 346 lt stdlib h gt header 347 lt string h gt header 349 gt gt shift right 293 script file command for expressions 419 for variables 420 bitwise exclusive or 294 _ 151 151 underscore for assembly routine names 158 for external identifiers 162 for macro names 162 AUS SIZED BY TYPE _ 149 _ BACKWARD COMPATIBLE BITFIELD S 149 BITFIELDS OVERLAP AUS 149 BITFIELDS PACK L2R CONST IN RAM 149 150 CONST IN ROM 149 150 CPU NAME _ 149 DATE 149 ENCORE 150 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ 4 EZ8 150 _ FILE 149 FPLIB 150 LINE 149 _ MODEL _ 150 NEW AU AT TYPE CHANGE 149 _ STDC 149 TIME 149 __UNSIGNED CHARS _ 150 vectors nn
200. User Manual i I PES SN Z I1 Of V MV M 394 amu Returns If the argument is an uppercase letter the tolower function returns the corresponding lowercase letter if any otherwise the argument is returned unchanged Example char c A Int i i tolower c toupper Converts a lowercase letter to the corresponding uppercase letter 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 i 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Returns The first invocation of the va_arg macro after that of the va_start
201. Value column Changing Values To change values in the Watch window do the following 1 Inthe 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 Removing an Expression To remove an expression from the Watch window do the following 1 In the Expression column click once on the expression you want to remove 2 Press the Delete key to clear both columns UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Viewing a Hexadecimal Value To view the hexadecimal values of an expression type hex expression in the Expression column and press the Enter key For example type hex tens The hexadecimal value dis plays in the Value column To view the hexadecimal values for all expressions select Hexadecimal Display from the context menu 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 Viewing a Decimal Value To view the decimal values of an expression type dec expression in the Expression col umn and press the Enter key For example type dec huns The decimal value displays in the Value column To view the decimal values for all expressions select Hexadecimal Display from the con text menu Viewing an ASCII Value To view the ASCII values of an expression type ascii expression in the Expression col umn and
202. Windows 98 SE NOTE The USB Smart Cable is not supported on 64 bit Windows Vista and Windows XP for ZDS II Z8 Encore versions 4 10 1 or earlier Recommended Host System Configuration e Windows XP Professional Pentium III 500 MHz processor or higher e 128 MB RAM or more UM013033 0508 Introduction Zilog Developer Studio ll Z8 Encore User Manual e 135 MB hard disk space includes application and documentation e Super VGA video adapter CD ROM drive for installation e USB high speed port when using the USB Smart Cable e RS232 communication port with hardware flow control Internet browser Internet Explorer or Netscape Minimum Host System Configuration Windows 98 SE Pentium II 233 MHz processor 96 MBRAM e 35 MB hard disk space application only e Super VGA video adapter e CD ROM drive for installation e USB full speed port when using the USB Smart Cable Windows 98 SE only e RS232 communication port with hardware flow control Internet browser Internet Explorer or Netscape When Using the Serial Smart Cable e RS 232 communication port with hardware flow and modem control signals NOTE Some USB to RS 232 devices are not compatible because they lack the necessary hardware signals and or they use proprietary auto sensing mechanisms which prevent the Smart Cable from connecting When Using the USB Smart Cable High speed USB fully compatible with original USB e Root direct or self powered hub
203. Z8 Encore User Manual 54 Special Function Registers Window on page 313 e Clock Window on page 313 e Memory Window on page 314 Watch Window on page 320 e Locals Window on page 322 e Call Stack Window on page 323 e Symbols Window on page 324 Disassembly Window on page 325 Simulated UART Output Window on page 326 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 Output windows Project Menu The Project menu allows you to add to your project remove files from your project set configurations for your project and export a make file The Project menu contains the following options e Add Files on page 54 Remove Selected File s on page 55 Settings on page 55 Export Makefile on page 101 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi Add Files To Project Look in e Tutorial O e E3 El main c File name Files of type Source Files c asm
204. Zilog Clock window 313 314 Clock Window button 28 Close Dialog When Flash Complete check box 112 Code Generation page 62 Code line indicators 311 Code segment 212 Command field 22 Command line building a project from 399 examples 424 running the assembler from 400 402 running the compiler from 400 404 running the librarian from 407 running the linker from 401 running ZDS II from 399 Command Output window 37 Command Processor quick tour 408 running the Flash Loader from 434 Command Processor toolbar 22 Command script file commands 413 example 412 writing 412 Commands linker 277 linker command file 277 running 408 Commands page 81 Commands tab 121 Commands to Keep field 122 Comment in assembly language 216 COMMENT directive 227 Comments 147 Comparing characters 370 387 Comparing strings 385 386 Comparison functions 350 Compatibility of assembly directives 268 437 Compile Assemble File button 18 Index Compiler command line options 404 comments 147 compatibility issues 440 data type sizes 148 error messages 193 options 425 running from the command line 400 run time library 160 337 setting options 440 warning messages 193 writing C programs 132 Compiling a project 103 Computing string length 386 Concatenating strings 384 387 Concatenation character 260 Concatenation functions 350 Conditional assembly 256 Conditional assembly directives 256 IF 257 IFDEF 258 IFMA 259 261 IFSAME 258 Con
205. Zilog function that selects the UART The default is _UARTO The init uart function can 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 kbhit use the selected UART You can also change the selected UART using the select port function without having to reinitialize the UART Synopsis finclude sio h int select port int port Returns A zero is returned on success a nonzero is returned on failure UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Example include lt stdio h gt include lt sio h gt void main void init uart UARTO DEFFREQ DEFBAUD init uart UART1 DEFFREQ 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 Z8 Encore 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
206. Zzilog Zilog Developer Studio II Z8 Encore User Manual UM013033 0508 o A AN Esain I ILL J LA Y MA a N Warning DO NOT USE IN LIFE SUPPORT LIFE SUPPORT POLICY ZILOG S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION As used herein Life support devices or systems are devices which a are intended for surgical implant into the body or b support or sustain life and whose failure to perform when properly used in accordance with instructions for use provided in the labeling can be reasonably expected to result in a significant injury to the user A critical component is any component in a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system or to affect its safety or effectiveness Document Disclaimer 2008 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 TECH
207. 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 storage class An attempt was made to take the address of a variable with register storage 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
208. a single line and without backslashes and your assembly file For example ez8asm include include cpu 2Z28F6423 test asm RUNNING THE COMPILER FROM THE COMMAND LINE To run the compiler from the command line l UM013033 0508 To see the current path type the following in a DOS window PATH Running ZDS II from the Command Line OV we gm de Zilog Developer Studio ll Z8 Encore User Manual I PES PN 7 NO amp Y hy 401 To set up the ZDS II bin directory for example C PROGRA 1 ZiLOG ZDSII_Z8Encore 4 11 0 bin in the path type the following SET PATH PATH C Program Files ZiLOG ZDSII_ Z8Encore 4 11 0 bin The make utility is available in this directory Type PATH again to see the new path Open the make file in a text editor Copy the options in the CFLAGS section In a 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 For example ez8cc cpu 28F6423 define 28F6423 asmsw cpu Z8F6423 test c 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 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 RUNNING THE LINKER FROM THE COMMAND LINE To run the linker from
209. 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 Identifier lt name gt is not a member of lt name gt 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i Il r fel 1 LJ V MV M 201 I 144 Cannot compare a pointer to a non pointer An attempt was made to compare a pointer to a non pointer 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 t
210. abc 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 238 for a list of predefined segments see Predefined Seg ments on page 212 The following sections describe the supported clauses e ALIGN Clause on page 233 e MAYINIT Clause on page 234 ORG Clause on page 234 SPACE Clause on page 235 Synonym define Syntax segment definition gt DEF INE lt ident gt lt space_clause gt align_clause gt lt org_clause gt lt mayinit_clause gt Examples DEFINE near code Uses the defaults of the current Space byte alignment and relocatable DEFINE irq table ORG FFF8 Uses current space byte alignment and absolute starting address at memory location SFFF8 ALIGN Clause Allows you to select the alignment boundary for a segment The linker places modules in this segment on the defined boundary The boundary expressed in bytes must be a power of two 1 2 4 8 and so on UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i IIAN 1 LJl t MV M 234 I Syntax align clause gt ALIGN int const Example DEFINE fdata SPACE
211. ace a copy of the initialized data segments NEAR DATA and FAR DATA into the ROM address space At run time the C startup module then copies the initialized data back from the ROM address space to the RData NEAR DATA segment and EData FAR DATA segment address spaces 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 pram romdata copy base of PRAMSEG define low pramseg base of PRAMSEG define len pramseg length of PRAMSEG 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 EData define far heaptop highaddr of EData define far stack highaddr of EData define near heapbot top of RData define near heaptop highaddr of RData define near stack highaddr of RData UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual These are the linker symbol definit
212. address that you want to read in the Address Hex field 3 Select the number of bytes to read from Bytes drop down list box 4 Click Read Serial to check the serial number for the current device 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 This opera tion actually flashes the device To fill a specified address range of memory do the following 1 2 3 UM013033 0508 Select the memory space in the Space drop down list box Right click in the list box to display the context menu Select Fill Memory The Fill Memory dialog box is displayed Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIlOg us Fill Memory Fill Value Address Range FF NE C 00 End Address Hex 0000FF C Other Start Address Hex 000000 Cancel Figure 79 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 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 t
213. age of the Project Settings Dialog Box 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 on the default ZDS II include directories UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual The following is the ZDS II default include directory ZDS Installation Directory gt include std where ZDS Installation Directory gt is the directory in which Zilog Developer Studio was installed By default this is C Program Files ZiLOG ZDSII_Z8Encore version where lt version gt might be 4 11 0 or 5 0 0 Defines The Defines field is equivalent to placing symbol EQU value in your assembly source code It is useful for conditionally built code Each defined symbol must have a corre sponding value lt name gt lt value gt Multiple symbols can be defined and must be sepa rated 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
214. ailure Example include lt sio h gt char ch c unsigned char err void main init uart UARTO0 DEFFREQ DEFBAUD err putch ch Send character to UARTO NOTE Before using this function the init uart function needs to be called to initialize and select the UART The default UART is UARTO READ FLASH The READ FLASH function is a Zilog function that reads a value from Flash memory at the specified address UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog se Synopsis tinclude lt eZ8 h gt char reentrant READ FLASH rom const void addr Returns The function returns data read from the specified address addr Example include lt eZ8 h gt char x void main INIT FLASH DEFFREQ Target clock frequency WRITE FLASH rom const 0x2f00 x write to Flash x READ FLASH rom const 0x2f00 read from Flash NOTE Beginning with the ZDS II for Z8 Encore release 4 8 there is a slight change in the function prototype for READ FLASH Previous Prototype if defined Z8F642 char reentrant READ FLASH rom const void addr else char intrinsic reentrant READ FLASH rom const void addr endif New Prototype char reentrant READ FLASH rom const void addr For most Z8 Encore processor variants the intrinsic keyword has been deleted in the ZDS II
215. ains 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 RAM using the following directives DEFINE MYDATA SPACE RDATA SEGMENT MYDATA or DEFINE MYDATA SPACE EDATA 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 233 The SEGMENT direc tive attaches code and data to a segment The SEGMENT directive makes that segment the current segment Any code or data following the directive resides in the segment until another SEGMENT directive is encountered For more information about the SEGMENT directive see SEGMENT on page 238 A segment can also be defined with a boundary alignment and or origin 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Assigning M
216. aken 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 number 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual ZILOQ ws 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 b
217. al iH PES NT 7 NO V MV M viii Local Macro Labels is iere tree nr nies pan en e de da xo bent UR 261 Optional Macro Arguments aoaaa sansene hs 261 Exiting a Macro i oer deat Ga e b eed ea ica dh be d oe eed Pad 262 Delimiting Macro Arguments 0 000 c eect ee 262 Labels cotidiana cod bros 263 Anonymous Labels oooomcisoroscoca rs 263 Local Labels mor a 263 Importing and Exporting Labels 0 0 264 Label S Paces PTT LEEREN 264 Label Check Suseni acea Qe e UA CRA eate E a RON pe a dah dante bans 264 Source Language Syntax 0 cect eee teens 264 Compatibility Issues 2 0 0 ehh 268 Warning and Error Messages 00 cece ccc tee he 269 Using the Linker L catOr eese od oo dnie ee So eres ass eer E err ih 275 Linker Functions diia e cadat Idee D eA e d e Gu i ea 275 Invoking the Linker 1 0 eect me 276 Linker Commands i iius gosh dan eR ead Medd tae dedu reducere donated dawns 277 lt outputfile gt lt module list 2 0 0 ttt 278 CHANGE soda rs v edes 278 CORY E 279 DEBUG acertar Gi THEE TERT 281 DEFINE uoo oa Phan pe ee Rh RC CR Ra CER ca SCA D Pel UNDE Riad 281 FORMAT soendei aeae da wae Rae 281 GROUP usada beeeH bI bMS 282 HEADING pt A eee 282 LOCATE cso cbc dh RE eee ee ERAS S ROS ESS RES HS EO ee ee eee CES 282 MAP i2 3desa us taba s RO or Bb dU edes ata tc a Sedi tar 282 MAXHEXLEN 3 54 2043 333 3390548 dot Y 2I Sp SORS S dO Ra NAS 283 MAXLENGTH s ura orbs Ee rt ta
218. ally add 3 4 Inthe Tabs area do the following indented lines indentation to your files 3 UM013033 0508 If you 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 see following figure 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 preceding figure Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilog Custom colors 8 832 2537 BE I8 825 235 UOI Define Custom Colors gt gt Figure 90 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi Font Font style Regular Courier New C Fixedsys i SES T IBMPCDOS O Lucida Console T MS Gothic Terminal WST_Czec Sample AaBbYyZzz Script Western Figure 91 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
219. aluated as char for example char OxFF Librarian Page NOTE This page is available for Static Library projects only The options in the Librarian page are described in this section To configure the librarian use the following procedure 1 Select Settings from the Project menu The Project Settings dialog box is displayed 2 Select the Librarian page UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilog EN Project Settings Configuration Debug y Sk General amp Librarian Sis Assembler C Sis Code Generation Output file Name a E ea Files ZiLOG ZDSII_ZBEncorel_4 11 0 samples Debug MyLib lib SR Advanced Sil Deprecated h Librarian Figure 56 Librarian Page of the Project Settings Dialog Box 3 Use the Output File Name field to specify where your static library file is saved ZSL Page In the Project Settings dialog box select the ZSL page The ZSL page allows you to use the Zilog Standard Library ZSL in addition to the run time library described in Using the ANSI C Compiler on page 132 The ZSL page contains functions for controlling the UART device driver and GPIO ports The options on the ZSL page are described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilog E Project Settings Configuration Debug
220. alue is rounded to fit within the allowed precision 451 Floating point over under flow The floating point value cannot be represented 452 General floating point error The assembler detects an expression operand that is out of range for the intended field and generates appropriate error messages 453 Fractional number too big small The fractional number cannot be represented 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 feature encountered An obsolete feature was encountered 470 Missing token error A token needs to be added 475 User error General purpose error UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 476 Reference to external label may not always fit in the offset field of that jump instruc tion You have used a jump instruction to jump to an external label but the type of jump instruction you have used might not provide a large enough displacement If you want to keep this type of jump instruction you must check manually to make sure that the desired jump is within the available range Alternatively you can either change to a different type of jump instruction or enable jump optimization which will automatically change the type of jump instruction when the destination is an external label 480 Relist map file error A map file will not be generated 481
221. ame 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 122 a file named lt project name gt wsyp 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi Close Project Select Close Project from the File menu to close the currently active project Save Select Save from the File menu to save the active file Save As To save a selected file with a new name perform the following steps 1 Select Save As from the File menu The Save As dialog box is displayed Save in O sic gt e E FA E zsldevinit asm E zeFMC160100KIT ztot g motordemo zdsproj E main c File name main c Save as type an Files Cancel Figure 41 Save As Dialog Box 2 Use the Save In drop down list box to navigate to the appropriate folder 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
222. ame 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 Z8 Encore 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 63 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 deselected 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 Intermediate Files Directory This directory specifies the locat
223. 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 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 118 Escape sequence ASCII code too large to fit in char The binary value
224. and ANDX as described in the eZ8 CPU User Manual UM0128 This is sometimes referred to as RP based page addressing because the upper 4 bits of the address are taken from RP 0 3 anda page from 00H to FFH of addressing is taken from the low 8 bits of the operand The point to be careful about is that to use this type of addressing you have to use the hexadecimal digit E as the top nibble of your instruction For example LDX E25 213 writes to a destination address whose lower 8 bits are 25H and whose upper 4 bits are taken from the RP as intended Conversely if you write LDX 25 213 this latter instruction is converted by the assembler into the only accepted form of LDx that matches the operands that are given specifically 25 is taken to be the 12 bit operand 025H and that is used as the destination of the load DIRECTIVES Directives control the assembly process by providing the assembler with commands and information These directives are instructions to the assembler itself and are not part of the microprocessor instruction set The following sections provide details for each of the sup ported assembler directives ALIGN on page 227 e COMMENT on page 227 e CPU on page 228 e Data Directives on page 228 e DEFINE on page 233 e DS on page 235 e END on page 235 e EQU on page 236 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore
225. ant throughout the translation unit The following additional macros are predefined by the Z8 Encore C Compiler CONST IN RAM This macro is defined if the const ram command line compilation option 1s used CONST IN ROM This macro is defined if the const rom command line compilation option is used __ ENCORE This macro is defined and set to 1 for the Z8 Encore compiler and is otherwise undefined E28 This macro is defined and set to 1 for the Z8 Encore compiler and is otherwise undefined FPLIB _ This macro is defined on all Zilog compilers and indicates whether the floating point library is available If the floating point library is available the macro expands to 1 otherwise it expands to 0 _ MODEL This macro indicates the memory model used by the compiler as follows O Small model 3 Large model ZDATE This macro expands to the build date of the compiler in the format YYYYMMDD For example if the compiler were built on May 31 2006 then ZDATE expands to 20060531 This macro gives a means to test for a particular Zilog release or to test that you are using a version of the compiler that was released after a particular new feature has been added ZILOG This macro is defined and set to 1 on all Zilog compilers to indicate that the compiler is provided by Zilog All predefined macro names begin with two underscores and end with two underscores The following sections de
226. ant to change 5 Click Copy Debug Menu Use the Debug menu to access the following functions for the debugger Connect to Target on page 107 Download Code on page 107 e Verify Download on page 108 Stop Debugging on page 108 Reset on page 108 Go on page 109 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual o iH JE Sa A a 8 I f y f kts GZ AS MA 1 0 7 Run to Cursor on page 109 e Break on page 109 Step Into on page 109 e Step Over on page 110 e Step Out on page 110 e Set Next Instruction on page 110 NOTE For more information on the debugger see Using the Debugger on page 309 Connect to Target The Connect to Target command starts a debug session using the following process 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box The following options are ignored if selected Reset to Symbol main Where Applicable check box Verify File Downloads Read After Write check box Verify File Downloads Upon Completion check box This command does not download the software Use this command to access target regis ters memory and so on without loading new code o
227. ant 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 cannot be first or last token in replacement string The macro definition cannot have operator in the beginning or end UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i IION IEJ tU Uy 196 U I 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 linenum 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 if directive was not terminated 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 en
228. anual Compatibility Issues 4 rr rrr tr he ete Wilko E E o n nare 9 Hee 437 Assembler Compatibility Issues 2 0 0 0 0 0 ct ee 437 Compiler Compatibility Issues sesseeeeeee eee ae 440 Inilex 5s xi maio vo Se sw sy qe ac qe opas ie qe miebe dc Ie Rue No ca e aie cd vc ie ie lune a m e Ide 445 UMO13033 0508 Table of Contents XV Zilog Developer Studio ll Z8 Encore User Manual V MV br xvi Introduction The following sections provide an introduction to the Zilog Developer Studio II e ZDS II System Requirements on page xvi e Zilog Technical Support on page xx ZDS Il SYSTEM REQUIREMENTS To effectively use Zilog Developer System II you need a basic understanding of the C and assembly languages the device architecture and Microsoft Windows The following sections describe the ZDS II system requirements Supported Operating Systems on page xvi Recommended Host System Configuration on page xvi Minimum Host System Configuration on page xvii e When Using the Serial Smart Cable on page xvii When Using the USB Smart Cable on page xvii When Using the Opto Isolated USB Smart Cable on page xvii e When Using the Ethernet Smart Cable on page xviii When Using the Z8 Encore MC Emulator on page xviii e Z8 Encore Product Support on page xviii Supported Operating Systems e Windows Vista Business e Windows XP Professional e Windows 2000 SP4
229. ard is the default NOREPLACE Optional parameter to use to prevent the overwriting of existing projects For example new project testl zdsproj Z8Encore exe new project testl zdsproj Z8Encore 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 of the open project command open project project name For example open project testl zdsproj open project c projects testl zdsproj option 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 gt exprl expr2 exprN where expr is lt option name option value For example option general debug TRUE option compiler debug TRUE keeplst TRUE option debugger readmem TRUE option linker igcase FALSE option linker rom 0000 FFFF option general cpu z8f64 NOTE Many of these script file options are also available from the command line For more details see Running ZDS II from the Command Line on page 399 UM013033 0508 Using the Command Processor Zilog
230. are allocated on the stack which is also located in the RData address space The address of a local or parameter is an 8 bit address Global variables can be manually placed into the EData or ROM address space by using the address specifiers far and rom respectively Local nonstatic vari ables and parameters are always allocated in the RData address space and any address specifiers used in their declarations are ignored Use of the small memory model does not impose any restriction on your code size only data memory is affected by the choice of model The small memory model always produces more efficient code than the large model if your application can use it The use of the small model places stringent limits on the data space available for the stack and data It does help to produce smaller code by enabling the compiler to use shorter instructions with more compact addressing modes If you are near but slightly over the data space limits of the small model you might still be able to use the small model by declaring enough selected global or static variables as far to get your use of RData down to the available space The code used to access those far vari ables is less efficient than the default data access code so if you follow this plan you need to choose variables that are seldom accessed to be far NOTE printf usually cannot be used with the small model because the stack grows too large and corrupts the data UM013033 0508 Us
231. 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 stream 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 include lt stdio h gt int scanf char format Returns The value of the macr
232. arget setup wait The wait command instructs the Command Processor to wait the specified milliseconds before executing the next command The following is the syntax of the wait command wait lt milliseconds gt 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 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 Z8 Encore microcontroller selected in the CPU Family and CPU fields of the General page of the Project Settings dialog box see General Page on page 56 2 Select USBSmartCable as your debug tool see Debug Tool on page 100 and click Setup to select the appropriate serial number UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z
233. aries 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 Because the linker command file coordinates the actions of the compiler and linker it is appropriate to discuss this topic in this section UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 182 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 Z8 Encore CPU using a hierarchical memory model containing 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 with it that identifies valid addresses for that space The hierarchical memory model for the Z8 Encore CPU is shown in the following figure The next figure depicts how the linker links and locat
234. aries consists of an implementation of much of the C Standard Library A small library of functions specific to Zilog or to Z8 Encore is also provided You can run the buildrtl bat batch file to generate the libraries from the RTL source that might have been modified by you directly into the following directory ZILOGINSTALL ZDS11_product_version lib std where UM013033 0508 Using the ANSI C Compiler 160 Zilog Developer Studio ll Z8 Encore User Manual e 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 25 04 0 The Z8 Encore 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 the ANSI C Standard They are described in detail in C Standard Library on page 337 The deviations from the ANSI Standard in these files are summarized in Library Files Not Required for Freestanding Implementation on page 193 The ZDS II for Z8 Encore microcontrollers comes wi
235. artup 00000102 User Defined 00000EFF User Defined 00000EFF User Defined C 0000 FLASH1 flash optionl segment C 0001 FLASH2 flash option2 segment 00000003 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined 00000100 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined 00000000 User Defined C 00E1 MAIN main TEXT 000000EF User Defined 000000FF User Defined 000000FF User Defined Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U BEN M 305 amu READ NVDS 00001000 User Defined READ NVDS GET STATUS 00001000 User Defined WRITE NVDS 00001083 User Defined WRITE NVDS GET STATUS 000010B3 User Defined 68 external symbol s START ADDRESS C 006C set in module srce boot common startupl asm END OF LINK MAP 0 Errors 0 Warnings 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 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 MAU of memory boundary
236. as a separate control to allow for special handling as explained in Floating Point Library on page 88 NOTE None of the libraries mentioned here are available for Assembly Only projects 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 Using the ANSI C Compiler on page 132 If your project makes any calls to standard library functions you need to select the C Runtime Library check box unless you prefer to pro vide your own code for all library functions that you call As noted in Additional Object Library Modules on page 85 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 C Runtime Library check box Calls to standard library functions will then call the func tions in the Zilog default library except when your own customized versions exist UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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
237. asm Library chelpD lib Version 1 0 05 03 2006 09 17 43 Segment _ VECTORS 034 C 0034 C 0035 2h Module common Nvect36 asm Library chelpD lib Version 1 0 05 03 2006 09 17 43 Segment _ VECTORS 036 C 0036 C 0037 2h Module zsldevinitdummy asm File zsldevinitdummy obj Version 1 0 05 03 2006 09 26 51 Segment CODE C 0038 C 0038 1h EXTERNAL DEFINITIONS Symbol Address Module Segment close periphdevic C 0038 zsldevinitdummy CODE framereset C 005D framer CODE _ frameset C 0045 frame CODE _ frameset0 C 0043 frame CODE _ frameset00 C 0041 frame CODE iframeset00 C 0039 frame CODE intrp E 0102 startupl FAR BSS _ open periphdevic C 0038 zsldevinitdummy CODE _ user frequency 01194000 User Defined VECTOR 002 0000 startupl VECTORS 002 lt ECTOR 004 ECTOR 006 ECTOR 008 ECTOR 00A ECTOR 00C ECTOR 00E ECTORS 004 ECTORS 006 ECTORS 008 ECTORS 00A ECTORS 00C ECTORS 00E 0004 vect04 oV 0006 vect06 oV 0008 vect08 oV 000A vect0a V V V lt lt lt S 000C vectOc NK 000E vect0e OOOO OON lt UM013033 0508 Using the Linker Locator 303 lt ECTO ECTO ECTO ECTOR ECTOR ECTO ECTO ECTO ECTO ECTOR ECTOR 024 ECTOR 026 ECTOR 028 ECTOR 02A ECTOR 02C ECTOR 02E ECTOR 030 ECTOR 032 ECTOR 034 ECTOR 036 _ VECTOR reset _c_ startup o ai H lt o lt lt lt NN
238. ated 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 two mechanisms for interrupt vector setup SET VECTOR Intrinsic Function on page 140 e At Keyword on page 141 SET VECTOR Intrinsic Function SET VECTOR can be used to specify the address of an interrupt handler for an interrupt vector Because the interrupt vectors of the Z8 Encore microcontroller are usually in ROM they cannot be modified at run time The SET VECTOR function works by switch ing 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 eZ8 h gt extern void interrupt isr timer0 void void main void UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual o ef pf I LI v v SET VECTOR TIMER
239. 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 For example e rtl c myinc In this example the compiler looks for the include file in 1 the project directory 2 the c rt1 directory 3 the c myinc directory 4 the default directory The default standard includes are located in the following directories lt ZDS Installation Directory gt include std lt ZDS Installation Directory gt include zilog where ZDS Installation Directory gt is the directory in which Zilog Developer Studio was installed By default this is C Program Files ZiLOG ZDSII Z8Encore lt ver sion where lt version gt might be 4 11 0 or 5 0 0 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 include file n in the compiler If more than one path is used the paths are sepa rated by semicolons For example C NEtl c Mnyinc In this example the compiler looks for the include file in 1 the project directory 2 the c rt1 directory 3 the c myinc directory 4 the directory ofthe file from wh
240. ble 11 Script File Commands Continued ZDS II Menus ZDS II Commands Dialog Box Options Script File Commands Location Project Settings Address ROM option linker rom page 427 Spaces page RData option linker rdata EData option linker edata NVDS only available for Z8 option linker nvds Encore XP 4K and 16K devices Use PRAM checkbox option linker praminuse Use PRAM field option linker pram PRAM is only available for the Z8 Encore XP F1680 series Project Settings Warnings Treat All Warnings as Fatal option linker warnisfatal page 427 page Treat Undefined Symbols as Fatal option linker undefisfatal Warn on Segment Overlap option linker warnoverlap Project Settings Output Output File Name option linker of page 427 page Generate Map File option linker map Sort Symbols By option linker sort Show Absolute Addresses in option linker relist Assembly Executable Formats option linker exeform Fill Unused Hex File Bytes with option linker padhex OxFF Maximum Bytes per Hex File Line option linker maxhexlen Project Settings Debugger Use Page Erase Before Flashing page Target target set page 433 Setup target options page 433 Add target create page 432 Copy target copy page 431 Delete Debug Tool debugtool set page 417 Setup debugtool set page 417 Export Makefile makfile page 422 makefile page 422 Build Build build page 414 Rebuild All rebuild page 430 Stop Build stop page 431 Set Active Configuration set config page 430 Manage C
241. block If no condition is specified on the SCONTINUE condition or if the condition is true execution of code generated from statements in the block resumes at the beginning of the block SWHILE Sequence of Operations The following sequence of operations is performed in processing the SWHILE structured assembly test directives 1 The assembler generates object code to evaluate the conditions specified on the SWHILE directive and on any optional SBREAK and CONTINUE directives 2 Atexecution time the object code generated from statements in the structured assembly block are executed while the specified condition is true 3 At execution time object code generated from BREAK directives is executed at the point where it appears in the block If no condition is specified on the SBREAK condition or if the condition is true the SWHILE loop is exited 4 Atexecution time object code generated from CONTINUE directives is executed at the point where it appears in the block If no condition is specified on the SCONTINUE condition or if the condition is true execution of code generated from statements in the block resumes at the beginning of the block CONDITIONAL ASSEMBLY Conditional 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
242. c eee eens 412 Supported Script File Commands 00 0 cece eee nes 413 add file io RE ERA SS ed Hea Redd Goa heed aos 413 hod mper mE 414 Dia ars nee ee eT ee duce ree qup ud eee ree ee eT a 414 DUI ue a meta ded ie Medo CE ia geek UA CE eRe Fal od 414 cancelalbs e a dn dE a IRE amas 414 cancel Op du LRL bein eel eerie tas 415 i rn 415 checksum nce RR geek adi 415 CIC hospi bu deed o mob rd dardos 415 debugtool copy sssseseeee es 416 deb gtool Create isses erue dace Qe ope des epe a RE e c eqs 416 debustool get i vs es Eureka ear e RR RE EAE TE OE Bac RR d 416 debugtool help cerien ic Re beads hela DPRPERPER ERE RES 416 Cebustool list 1 oa att ew eode ee o e ea AE a eese 417 debugtoolsave oooooooooororrr e res 417 deb gtool set 1222s sese ded Reed rre abeo esed edades dures 417 debugtool setup ssssseseeee en 418 defin s vu RE A A CEU EMEN ET ue 418 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User Manual Zilog iv delete Config PT 418 examine for Expressions 0 ccc eee ett eens 419 examine for Variables 00 0 ccc cece tenn ene nes 420 lira Raed ed alate a antl ded edt edid Sag dru OR Red 420 FIMM 2322222 bed est did d dee dud 420 BO e senis p t ER S ol A EAE LR ia EH ne dte dee oae 421 list DP a bid 421 loa dE bai rd ed 421 iia a a a a its 421 makfile or makefile 0 0 e a Rd e aas 422 new pro lect cz Med e a Sw Ge BR wh ERR oh
243. can use the COPY BASE OF and COPY TOP OF linker expressions to get 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 dataseg Example 2 To copy multiple segments to ROM use the following procedure 1 Inthe assembly code define the segments for example strseg text and dataseg to be segments located in RDATA This is the run time location of the segments 2 Use the following linker commands CHANGE strseg dataseg CHANGE text dataseg COPY dataseg ROM The linker renames strseg and text as dataseg and performs linking as described in the previous example You need to write only one loop to perform the copy from ROM to RDATA at run time instead of three one loop each for strseg text and dataseg Example 3 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 is needed for linking and debugging Example 4 To generate debug information without generating code Use the COPY command in the linker to copy the segment to the predefi
244. ce ment e N mystring This defines a near string constant The string is stored in RData The address of the string is a near pointer F mystring This defines a far string constant The string is stored in EData The address of the string is a far pointer R mystring This defines a rom string constant The string is stored in ROM The address of the string is a rom 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 void funcf far char str while str putch str putch n void funcr rom char str while str putch str putch n void main void UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual funcn N nstr funcf F fstr funcr R rstr Inline Assembly There are two methods of inserting assembly language within C code Inline Assembly Using the Pragma Directive on page 143 e Inline Assembly Using the asm Statement on page 143 Inline Assembly Using the Pragma Directive The first method uses the pragma feature of ANSI C with the following syntax pragma asm assembly line gt This pragma can be inserted anywhere within the C source file The contents of assembly line must be legal assembly language syntax The usual C escape sequences such as n Nc and r are properly translate
245. code for the Z8 Encore Zilog recommends that you use the Z8 Encore directives described previously in this chapter because the behavior of these directives is thoroughly validated with each release of the Z8 Encore assembler UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual ga i A EC f Z IOO n i LJ LI l 46 V U 269 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 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
246. cro Assembler lt float_const gt lt decfloat gt lt float_frac gt frac const exp part float power label lt string_const gt lt ident gt lt ident_list gt lt macro_def gt lt macro_invoc gt lt a rg gt lt public_definition gt lt scalar_definition gt lt segment_definition gt lt space_clause gt lt align_clause gt lt org_clause gt lt mayinit_clause gt lt space gt COMPATIBILITY ISSUES Zilog Developer Studio ll Z8 Encore User Manual Zilog oss lt decfloat gt lt float_frac gt lt float_power gt lt float_const gt lt exp_part gt digit digit _ E digit digit digit _ lt exp_part gt lt ident gt lany Jetter _ 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 macro argument PUBLIC lt ident list gt EXTERN lt ident list gt lt type gt lt value gt DEF INE lt ident gt lt space_clause gt lt align_clause gt lt org_clause gt SPACE lt space gt ALIGN lt int_const gt ORG lt int_const gt MAYINIT RDATA EDATA ROM PRAM Compatibility between Z8 Encore assembler directives and those of other assemblers supported by the Z8 Encore assembler are listed in Compatibility Issues on page 437 If you are developing new
247. d The compiler does not process the assembly line Except for escape sequences it is passed through the compiler verbatim Inline Assembly Using the asm Statement The second method of inserting assembly language uses the asm statement asm lt assembly line gt The asm statement cannot be within an expression and can be used only within the body of a function The assembly line 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 lt assembly line gt except for translating the standard C escape sequences The compiler prefixes the name of every global variable with _ Global variables can therefore be accessed in inline assembly by prefixing their name with _ The local vari ables and parameters cannot be accessed in inline assembly Placement Directives The Zilog C Compiler provides language extensions for the following e Placement of a Variable on page 144 Placement of Consecutive Variables on page 144 e Alignment of a Variable on page 144 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual e H I PES SN 7 IIO 0 amp Y Sj 144 Placement of a Variable The following syntax can be used to declare a global or static variable at an address char placed char At Oxff placed char is assigned an address Oxff far struct char ch int ii ss At Oxeff
248. d 286 289 Serial Number list box 101 Serial number choosing 101 Serial Smart Cable requirements xvii Serial Value field 113 Set Bookmark button 23 set config script file command 430 Set Next Instruction button 26 SET VECTOR 140 172 setjmp function 345 381 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOD ase lt setjmp h gt header 345 Setting breakpoints 327 Setup button Target area 97 Setup Ethernet Smart Cable Communication dialog box 100 Setup Serial Communication dialog box 101 Setup USB Communication dialog box 101 SFR definition 91 313 short enumerations 144 Shortcut keys 129 Show Absolute Addresses in Assembly List ings check box 95 Show CRC dialog box 117 119 320 Show DataTips Pop Up Information check box 126 Show the Full Path in the Document Window s Title Bar check box 122 SHRT_MAX 342 SHRT_MIN 342 Simulated UART Output window 326 Simulated UART Output Window button 28 sin function 344 382 Sine computing 382 sinh function 344 382 lt sio h gt header 163 size_t 346 347 349 Small and Debuggable button 63 Small and Debuggable configuration 63 Small memory model 90 137 Smallest integer computing 357 Smallest Possible button 63 Smallest Possible configuration 63 Smart Cables Available area 100 Software installation 1 SORT command 286 Sort Symbols By area 95 Sorting arrays 376 Sorting functions 349 Source line contents 216 definition 216 Index labels 216
249. d in a segment in ROM To place anotherfunc in PRAM you need to precede it with pragma PRAM also For example pragma PRAM int anotherfunc void UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual return 2 The same is true for any library functions called from such functions If you want to avoid having these functions executed from Flash which might partially defeat the power sav ing goal of placing the functions that call them in PRAM you need to include the source for the library function in your project and precede the library function with pragma PRAM if it is a C function or if it is an assembly function change the segment of the func tion to PRAMSEG using the segment PRAMSEG assembler directive NOTE The pragma PRAM declaration has function scope and will affect the next function definition as opposed to a function declaration that is a function prototype that the compiler encounters For this reason quite unexpected results can ensue if this pragma is used in a function prototype especially when function declarations and definitions are grouped separately as is common practice Therefore it is recommended that you avoid using this pragma in function prototypes Preprocessor warning Directive Support A preprocessor line of the form warning token sequence causes the compiler to write a warning message consisting of the token sequence The compiler continues t
250. d 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 739 Invalid space lt space gt is defined The named address space is not valid It must be either a group or an address space 740 Space lt space gt is 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 lt message gt General purpose error message for reporting out of range errors An address does not fit within the valid range 748 lt message gt 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio
251. d 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 group 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 lt name gt lt expression gt 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 ROM 0000 SOFFF 4000 S4FFF If a 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 288 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_Z8Encore 4 11 0 lib std UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U EY M 286 I SEQUENCE The SEQUENCE command fo
252. de lt eZ8 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 saves the previous interrupt status and disables inter rupts The previous interrupt status is returned from TDI This function is intended to be paired with a later call to RI which restores the previously existing interrupt status See RI on page 171 for a discussion of that function The TDI function is an intrinsic func tion and is inline expanded Synopsis finclude lt eZ8 h gt intrinsic unsigned char TDI void UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog as Example include lt eZ8 h gt void main void unsigned char istat istat TDI Test and Disable Interrupts Do Something RI istat Restore Interrupts WRITE_FLASH The WRITE_FLASH function is a Zilog function that writes a value to Flash memory at the specified address Synopsis include lt ez8 h gt void reentrant WRITE FLASH rom const void addr char val Returns If successful the function returns zero otherwise it returns a nonzero value Example include lt eZ8 h gt char x void main INIT FLASH DEFFREQ Target clock freq
253. de 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 Selecting 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 69 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 NOTE This check box interacts with the Generate Debug Information check box see Generate Debug Information on page 58 Memory Model The Memory Model drop down list box allows you to choose between the two memory models Small or Large Select Small for a small memory model or select Large for a large memory model Using the small mode
254. ded by 1 to indicate that the corresponding argument is a pointer to double rather than a pointer to float or by L to 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 below the scanf function returns Failures are described as input failures due to the unavailability of input characters or matching failures due to inappropriate input UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual 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 if 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 Input white space characters as specified by the isspace function
255. dif found endif directive without a corresponding i directive was found 032 Division by zero encountered Divide by zero in constant expression found 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 Using the ANSI C Compiler UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual 038 User supplied text A user created error or warning directive has been encountered The user supplied text from the directive is printed with the error warning message 039 Unexpected end of file An end of file encountered with in a comment string or character 040 Unmatched Zelse found else directive without a corresponding if directive was found 041 Unmatched elif found elif directive without a corresponding if directive was found 042 preceded by non whitespace character The preprocessor line has characters other than white space blanks tabs new lines comments etc before 043 Unterminated quoted character An end of line was encountered within a quoted character 044 Empty file encountered
256. ding 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 eg 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 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 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 rig
257. directives in assembly 228 Data type sizes 148 _ DATE _ 149 DB directive 231 DBL DIG 340 DBL MANT DIG 340 DBL MAX 340 DBL MAX 10 EXP 340 DBL MAX EXP 340 DBL MIN 340 DBL MIN 10 EXP 341 DBL MIN EXP 341 DD directive 231 Deallocating space 360 _DEBUG 151 DEBUG command 281 Debug configuration 103 Debug information generating 281 284 Debug menu 106 Break 109 Connect to Target 107 Download Code 107 Go 109 Reset 108 Run to Cursor 109 Set Next Instruction 110 shortcuts 131 Step Into 109 Step Out 110 Step Over 110 Stop Debugging 108 Verify Download 108 Debug mode RUN 310 STEP 310 STOP 310 switching to 309 Debug Output window 36 Debug Tool area 100 101 Debug toolbar 23 24 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ Debug windows 53 Debug Windows toolbar 27 312 Debugger description 96 309 status bar 310 Debugger page 96 Debugger script file commands 413 example 412 writing 412 Debugger tab 126 debugtool copy script file command 416 debugtool create script file command 416 debugtool get script file command 416 debugtool help script file command 416 debugtool list script file command 417 debugtool save script file command 417 debugtool set script file command 417 debugtool setup script file command 418 Dec button 113 Decimal numbers in assembly 223 Decimal numeric values 292 Decimal values viewing 322 DEFINE 213 233 281 Defines field 60 defines
258. directory where additional object files and modules that you want linked with your application are located You do not need to add modules that are otherwise spec ified 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 with commas NOTE 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 including UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 t
259. displayed after clicking the Reset button to enter Debug mode Double click in the gutter to the left of the line where you want to add an active breakpoint You can set an active breakpoint in any line with a blue dot displayed to the left of the line the blue dots are displayed after clicking the Reset button to enter Debug mode Inactive breakpoints can be placed on any line but cannot be made active A red octagon shows that you have set a breakpoint at that location define ZDS NAME ZiLOG Developer Studio void main A int d e Ent ors Hh Int ch static char welcome Welcome to ZDS _NAME static char s Hello world puts welcome puts s putchar n Figure 115 Setting a Breakpoint UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Zzilogi 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 Right click in the Edit window to display the context menu select Edit Breakpoints to display the Breakpoints dialog box You can use the Breakpoints dialog box to view go to enable disable or remove break points in an active project when in or out of Debug mode Breakpoints E 001 C Program Files ZiLOG ZDSII_Z8Encore _4 11 0 samp Goto Code 002 C Program Files ZiLOG ZDSII Z8Encore 4 11 0 sampl 003 C Program Filee
260. ds page Always Generate from Settings button TRUE FALSE directives Additional Linker Directives dialog box string Contains the text for additional directives This is ignored if useadddirective is false edata Address Spaces page EData field string min max for Sets the size range for the EDATA memory space example 0000 FFFF exeform Output page Executable Formats area string IEEE 695 or Sets the resulting executable format Intel Hex32 fplib Objects and Libraries page Floating Point Library drop down string real dummy list box or none 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 Toggles map file generation maxhexlen Output page Maximum Bytes per Hex File Line check box 16 32 64 or 128 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual i IIAN 1 LJ V M M 428 Table 17 Linker Options Continued Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values nvds Address Spaces page NVDS field string min max for Sets the size range for the NVDS memory space example 00 FF obj libmods Objects and Libraries page Additional Object Library string separate multiple Modules field modules names with Sets the objec
261. e SEGMENT code predefined segment DEFINE data user defined SUBTITLE Causes a user defined subtitle to be displayed below the TITLE on each page ofthe listing file The new subtitle remains in effect until the next SUBTITLE directive The operand must be a string constant Syntax lt subtitle_directive gt gt SUBTITLE lt string_const gt Example SUBTITLE My Project Subtitle 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 string constant Synonym title Syntax title directive gt TITLE string const 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 causes an error if EQU was used instead of VAR Synonym VAR SET SET UM013033 0508 Using the Macro Assembler 000000 000000 000000 000006 000002 000002 000007 000007 00000D 000004 000004 Syntax label VAR expression Example 000000FF FF 4641494C 4544 00 00000000 50415353 4544 00 00000007 07 UM013033 0508 PPP PpPrPrPrrrPrPrrrrrPr PrP reer ee co 1 Os 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Zilog Developer Studio ll Z8 Enc
262. e IF on page 257 e IFDEF on page 258 e IFSAME on page 258 e IFMA on page 259 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 if true and 0 if false 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual zilogi NOTE Conditional assembly can be nested IF Evaluates a Boolean expression If the expression evaluates to 0 the result is false other wise the result is true Synonyms if IF IFN IFNZ COND IFTRUE IFNFALSE 1F Sif IFTRUE Syntax IF cond expression code body gt ELIF cond expression code body ELSE code body ENDIF n Example IF XYZ process code body 0 if XYZ is not 0 Code Body 0 ENDIF IF XYZ 3 process code body 1 if XYZ is not 3 Code Body 1 ELIF ABC process code body 2 if XYZ 3 and ABC is not 0 Code Body 2 gt ELSE otherwise process code body 3 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual up Code Body 3 ENDIF
263. e 4 11 00r5 0 0 To set a target value use one of the following syntaxes target options CATEGORY lt Category gt OPTION Option lt token name gt lt value to set target options CATEGORY lt Category gt lt token name gt lt value to set target options token name gt lt value to set gt To select a target use the following syntax target options NAME lt 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 lt 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 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 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual 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 of the target setup command t
264. e char 120 With ANSI promotions enabled the expression eval uates directly to char 120 There are two more types of code constructs that behave differently from the ANSI Stan dard when the ANSI promotions are disabled These occur when an expression involving unsigned chars is then assigned to a signed int result and when relational operators are used to compare an unsigned char to a signed char Both of these are generally poor pro gramming practice due to the likelihood of operand signs not being handled consistently The following code illustrates the cases where the code behaves differently depending on the setting of the Disable ANSI Promotions check box When ANSI promotions are on the code prints the following START EQUAL SIGNED DONE When ANSI promotions are off the code prints the following START NOT EQUAL UNSIGNED DONE In every case the difference occurs because when promotions are on the unsigned chars are first promoted to signed ints and then the operation occurs with promotions off the operations occur first and then the promotion happens afterward In every case except the second test the code with promotions off has to invoke the ANSI Standard s rules for how to convert a negative result into an unsigned type another indication that it is generally poorly written code for which this setting makes a difference in program behavior include lt stdio h gt unsigned char uchl 1 un
265. e Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Special Function Registers Window Button The Special Function Registers Window button displays or hides the Special Function Registers window This window is described in Special Function Registers Window on page 313 Clock Window Button The Clock Window button displays or hides the Clock window This window is described in Clock Window on page 313 Memory Window Button The Memory Window button displays or hides the Memory window This window is described in Memory Window on page 314 Watch Window Button The Watch Window button displays or hides the Watch window This window is described in Watch Window on page 320 Locals Window Button The Locals Window button displays or hides the Locals window This window is described in Locals Window on page 322 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 323 Symbols Window Button The Symbols Window button displays or hides the Symbols window This window is described in Symbols Window on page 324 Disassembly Window Button The Disassembly Window button displays or hides the Disassembly window This win dow is described in Disassembly Window on page 325 Simulated UART Output Window Button The Simulated UART Output Window button displays or hide
266. e Setup Serial Communication dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Setup Serial Communication Baud Rate 57600 z Port COM1 Y DK Cancel OK Figure 70 Setup Serial Communication Dialog Box Use the Baud Rate drop down list box to select the appropriate baud rate 19200 38400 57600 or 115200 The default is 57600 Select the host COM port connected to your target NOTE ZDS Il sets the COM port settings for data parity stop and flow control You do not need to set these Click OK e Ifyou select USBSmartCable and click Setup in the Debug Tool area the Setup USB Communication dialog box is displayed Setup USB Communication Serial Number 051201 002f OK Cancel Figure 71 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 is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Z1L0G w Save in gt StarterProject include library output source E starter Debug mak File name
267. e Word Only check box if you want to ignore the search text when it occurs as part of longer words 5 Select the Match Case check box if you want the search to be case sensitive 6 Select the Regular Expression check box if you want to use regular expressions 7 Select whether you want the text to be replaced in text currently selected or in the whole file 8 Click Find Next to jump to the next occurrence of the search text and then 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 m to Line Number E Bo j GoTo To Figure 46 Go to Line Number Dialog Box Enter the desired line number in the edit field and click Go To UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Manage Breakpoints To view go to or remove breakpoints select Manage Breakpoints from the Edit menu You can access the dialog box during Debug mode and Edit mode Breakpoints E 001 C Program Files ZiLOG ZDSII_Z8Encore _4 11 0 sampl Go to Code 002 C Program Files ZiLOG ZDSII_Z8Encore _4 11 0 sampl 003 C Program Fles ZILOGNZDSIl Z8Encorel_4 11 0 eamnp BEEREEEREE Disable All Remove Remove All 7 gt Cancel
268. e 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 written 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 include lt stdio h gt int putchar int c Returns The character written If a write error occurs putchar returns EOF Example int ij charc a i putchar c NOTE The UART needs to be initialized using the Zilog init uart function See init uart on page 167 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual puts Writes the string pointed to by s to the serial port and appends a new line character to the output The terminat
269. e function 4 Ifthe function returns a scalar value place it in the return registers For functions returning an aggregate see Special Cases on page 157 5 Set the stack pointer to the current value of the frame pointer and restore the frame pointer from the stack 6 Ifthe called function is a monitor function only restore the interrupt control register IRQCTL from the stack 7 Return For a static frame function steps 2 and 5 are only done if the debug Debug or reduceopt Limit Optimizations for Easier Debugging option is selected All registers other than the return register are considered as caller save that is they are saved and restored by the caller function The flag register is not saved and restored by the caller function The preceding function call mechanism is a static call mechanism The structure of a static call frame is described in Structure of a Static Call Frame on page 154 Structure of a Static Call Frame For the static frame function fun the local variables and parameters are allocated in a frame labeled fun for a large model and n fun for a small model The parameters are numbered from left to right and are named as x fun where x indicates the number associated with the parameter In the following example 0 fun represents the leftmost parameter ch1 and 1 fun represents the next parameter ch2 C Source Small Model void fun char chl char ch2 Static Frame in Generated As
270. e function calls do not follow the mechanism described in Function Call Mechanism Dynamic Frame on page 152 Such cases are described in the following sections e Returning Structure on page 157 e Not Allocating a Local Frame on page 157 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 frame for a function in the following case e The function does not have any local stack variables stack arguments or compiler generated temporaries and e The function does not return a structure and The function is compiled without the debug option CALLING ASSEMBLY FUNCTIONS FROM C The Z8 Encore C Compiler allows mixed C and assembly programming A function writ ten in assembly can be called from C if the assembly function follows the C calling con ventions as described in Calling Conventions on page 151 This section covers the following topics Function Naming Convention on page 158 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Argument Locations on page 158 Return Values on page 159 Preservi
271. e gt gt lt value _list gt lt value gt lt value gt gt lt expression gt lt string_const gt B D D gt D D D D F The BLKB BLKL and BLKW directives can be used to allocate a block of byte long or word data respectively BFRACT and UBFRACT Declaration Types Syntax BFRACT signed fractional 8 bits UBFRACT unsigned fractional 8 bits Examples BFRACT 3 0 1 2 0 2 Reserve space for five 8 bit Signed fractional numbers Initialize first 3 with 0 1 last 2 with a 0 2 UBFRACT 50 0 1 50 0 2 Reserve space for 100 8 bit unsigned fractional numbers Initialize first 50 with a 0 1 second 50 with a 0 2 BFRACT 0 5 Reserve space for one 8 bit signed fractional number and initialize it to 0 5 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual FRACT and UFRACT Declaration Types Syntax FRACT signed fractional 8 bits UFRACT unsigned fractional 8 bits Examples FRACT 3 0 1 2 0 2 Reserve space for five 16 bit Signed fractional numbers Initialize first 3 with 0 1 last 2 with a 0 2 UFRACT 50 0 1 50 0 2 Reserve space for 100 16 bit unsigned fractional numbers Initialize first 50 with a 0 1 second 50 with a 0 2 FRACT 0 5 Reserve space for one 16 bit signed fractional number and initialize it to 0 5 BLKB Declaration Type Syntax BLKB number of bytes 8 bits each init value Examples
272. e linker commands 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 z sproj for example the default linker command file name is test debug linkcmd You can add additional directives to the linking process by spec ifying them in the Additional Linker Directives dialog box see Additional Directives on page 82 Alternatively you can define your own linker command file by selecting the Use Existing button see Use Existing on page 83 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 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 the Output page see Linker Output Page on page 93 The map Generate Map File sort Sort Symbols By Address and maxhexlen Maximum Bytes per Hex File Line settings are also generated from options selected in the Output page The warnoverlap Warn on Segment Overlap and unresolved Treat Undefined Symbols as Fatal options are generated f
273. e 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 437 Invalid array index A negative number or zero has been used for an array instance index You must use positive numbers 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 must be among those listed under the VECTOR directive 442 Missing delay slot instruction Add a delay slot instruction such as BRANCH or LD UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual T I PES NT Z Il Of V M M 272 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 446 Missing wend at EOF There is no Swend directive 447 Missing Srepeat at EOF There is no matching repeat forthe while directive 448 Segment stack overflow Do not allocate returned structures on the stack 450 Floating point precision error The floating point value cannot be represented to the precision given The v
274. e 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 and ORDER UM013033 0508 Using the Integrated Development Environment NOTE Zilog Developer Studio ll Z8 Encore User Manual Zilog 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 xx 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 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
275. eature and to address the original code size issue has expended more effort to reduce code size and remove truly unnecessary promotions while observing the ANSI standard For this reason the Disable ANSI Promotions check box is now available only as a deprecated feature It remains available because some users have carefully created working code that might depend on the old behavior and might have to expend additional effort now to keep their code working without the deprecated feature UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual When the Disable ANSI Promotions check box is deselected the compiler performs inte ger type promotions when necessary so that the program s observed behavior is as defined by the ANSI C Standard Integer type promotions are conversions that occur automatically when a smaller for example 8 bits variable is used in an expression involving larger for example 16 bits variables For example when mixing chars and ints in an expression the compiler casts the chars into ints Conversions of this kind are always done regardless of the setting of the Disable ANSI Promotions check box The ANSI Standard has special rules for the handling of chars and shorts and it is the application of these special rules that is disabled when the check box is selected The spe cial rules dictate that chars both signed and unsigned must always be promoted to ints
276. ebugger tab of the Options dialog box The following options are ignored if selected Reset to Symbol main Where Applicable check box Verify File Downloads Read After Write check box Verify File Downloads Upon Completion check box This button does not download the software 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 This button is available only when not in Debug mode For the Serial Smart Cable ZDS II performs an on chip debugger reset and resets the CPU at the vector reset location 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 Starting in version 4 10 0 the Download Code button can also program Flash memory A page erase is done instead of a mass erase for both internal and external Flash memory Use this button anytime during a debug session This button is not enabled when the target is the simulator NOTE The current code on the target is overwritten If ZDS II is not in Debug mode when the Download Code button is clicked the following process is executed 1 Initializes the communication to the target hardware 2 Resets the device with a hardware reset by drivi
277. ect 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 and where necessary the linker address space ranges and selected debugger target based on the selected CPU UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 can 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 63 Second the generated code sets up the stack fr
278. ect the memory space in the Space drop down list box 2 Right click in the list box to display the context menu 3 Select Load from File The Load from File dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Load From File File Name Ed File Format C Text Start Address Hex ex Hex C Binary Cancel Figure 81 Load from File Dialog Box 4 Inthe File Name field enter the path and name of the file to load or click the Browse button d to search for the file 5 Inthe Start Address Hex field enter the start address 6 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 To perform a cyclic redundancy check CRC select Show CRC from the context menu The checksum is displayed in the Show CRC dialog box CRC 0xB038 Figure 82 Show CRC Dialog Box 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 is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZILOG us Calculate Checksum File Name nd Checksum Close Figure 83 Calculate Checksum Dialog Box 2 Click on the Browse but
279. ective used outside of a STRUCT or UNION directive 509 Label previously declared in different space A label has been previously declared on an XREF directive in a different space than it is being defined in UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Using the Linker Locator The linker locator in the Z8 Encore developer s environment 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 loca tor 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 loaded onto the target system and debugged using the Zilog Developer Studio II This section describes the following Linker Functions on page 275 e Invoking the Linker on page 276 Linker Commands on page 277 e Linker Expressions on page 288 Sample Linker Map File on page 294 Warning and Error Messages on page 305 LINKER FUNCTIONS The following five major types of objects are manipulated during the linking process e Libraries Object libraries are collections of object modules created by the Librarian e Modules Modules are created by assembling a file with the assembler or compiling a file with the compiler e Address spaces Each
280. ectives 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 repeatedly 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 if used indicates a starting offset value to use for the first element encountered otherwise the starting offset defaults to zero If parent is 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 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 accordingl
281. ed Load From File File Name e File Format Start Address Hex C Text Hex C Binary Cancel Figure 107 Load from File Dialog Box 4 Inthe File Name field enter the path and name of the file to load or click the Browse button 4 to search for the file 5 Inthe Start Address Hex field enter the start address 6 Select whether to load the file as text hex hexadecimal or binary 7 Click OK to load the file s contents into the selected memory Performing a Cyclic Redundancy Check NOTE The Show CRC command is not available if the active debug tool is the Simulator Use the following procedure to perform a cyclic redundancy check CRC for the whole internal Flash memory 1 Select the Rom space in the Space drop down list 2 Right click in the Memory window list box to display the context menu 3 Select Show CRC The Show CRC dialog box is displayed with the result UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOG sx Show CRC CRC 0xB038 Figure 108 Show CRC Dialog Box Watch Window Click the Watch Window button to show or hide the Watch window Expression C 01010B 0x54 0x69 Ox4C Ox4F 0x47 0x20 0x44 0x65 0x76 0x65 Ox6C Ox6F 0x70 0x65 0x72 0x73 0x20 0x53 0x74 0x75 El zds H H H H H H H H H H H H H H H H H H H E lt Figure 109 Watch Window The Watch window displays all the variables and thei
282. ed The following sections describe how to define and invoke macros Macro Definition on page 259 e Concatenation on page 260 Macro Invocation on page 260 Local Macro Labels on page 261 Optional Macro Arguments on page 261 Exiting a Macro on page 262 e Delimiting Macro Arguments on page 262 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 1 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U EY M 260 I Example store MACRO regl reg2 reg3 ADD regl reg2 LD reg3 regl ENDMAC store 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 po
283. ed data to stdout int scanf char format Reads formatted data from stdin int sprintf char s char format Writes formatted data to string int sscanf char s char format Reads formatted data from string int vprintf char format va list arg Writes formatted data to stdout int vsprintf char s char format va_list arg Writes formatted data to a string 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 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 ldiv t size t wchar t UM013033 0508 Structure type that is the type of the value returned by the div function Structure type that is the type of the value returned by the Idiv function Unsigned integral type of the result of the sizeof operator Integral type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zzilog Macros EDOM Expands to distinct nonzero integral constant expressions ERANGE Expands to distinct nonzero integral constant expressions EXIT SUCCESS Expands to integral expression that indicates successful term
284. ed to Zilog Standard Libraries can be found under the following directory ZILOGINSTALLVZDSII product versionNincludeNzilog where e ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files VMZiLOG product is the specific Zilog product For example product can be Z8Encore ZNEO eZ80Acclaim Crimzon or Z8GP version is the ZDS II version number For example version might be 4 11 0 or 250 0 WHAT IS THE ZSLDEVINIT ASM FILE zsldevinit asm is a device initialization file It contains routines to initialize the devices you have selected in the ZSL page of the Project Settings dialog box WHAT INITIALIZATIONS ARE PERFORMED IN THE ZSLDEVINIT ASM FILE The open periphdevice routine in zsldevinit asm initializes the GPIO ports and UART devices The functions in the file also initialize other dependent parameters like the clock speeds and UART FIFO sizes WHAT CALLS THE OPEN PERIPHDEVICE FUNCTION If the standard startup files are used the open periphdevice function is called by the startup routine just before calling the main function UM013033 0508 Zilog Standard Library Notes and Tips Zilog Developer Studio ll Z8 Encore User Manual Zilog ws WHEN I USE ZILOG STANDARD LIBRARIES IN MY APPLICATION AND BUILD FROM THE COMMAND LINE WHY DO SEE UNRESOLVED ERRORS Include zsldevinit asm in your project The open periphdevice functi
285. ed to include commas and spaces that are not normally allowed as part of an argument The default delimiters are brackets but braces and parentheses are also allowed Example 1 Delimiter changed to MACDELIM BRA MACRO ARG1 JP ARG1 ENDMACRO LAB BRA NE LAB Example 2 Using default delimiter BRA MACRO ARG1 JP ARG1 ENDMACRO LAB BRA NE LAB UM013033 0508 Using the Macro Assembler LABELS Zilog Developer Studio ll Z8 Encore User Manual Labels are considered symbolic representations of memory locations and can be used to reference that memory location within an expression See Label Field on page 216 for the form of a legal label The following sections describe labels Anonymous Labels on page 263 Local Labels on page 263 Importing and Exporting Labels on page 264 Label Spaces on page 264 Label Checks on page 264 Anonymous Labels The ZDS II assembler supports anonymous labels The following table lists the reserved symbols provided for this purpose Table 10 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 next anonymous label defined after
286. efines 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 genobj Generates an object file with the obj 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 The default setting is noigcase 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 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 UM013033 0508 Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual Zilog 403 Table 8 Assembler Command Line Options Continued Option Name Description nodebug Does not create a debug information file for the symbolic debugger This is the default setting nog
287. eld 59 Increment Dec field 114 INIT FLASH function 166 init uart function 167 Input output macro 346 Insert Breakpoint command 327 Insert Spaces button 124 Insert Remove Breakpoint button 21 26 327 Inserting breakpoints 327 Installation 1 Installing ZDS II 1 Instructions in assembly 217 INT MAX 342 Integer arithmetic functions 349 Intel Hex16 format 95 Intel Hex32 format 95 Intermediate Files Directory field 58 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual 459 Internal Flash check box 111 interrupt handlers 140 interrupt keyword 140 INTERRUPT mode 335 Intrinsic functions 441 IP Address field 100 isalnum function 339 362 isalpha function 339 363 iscntrl function 339 363 isdigit function 339 363 isgraph function 339 364 islower function 339 364 isprint function 339 364 ispunct function 339 365 isspace function 340 365 isupper function 340 365 isxdigit function 340 366 J jmp_buf 345 Jump Optimization check box 60 K kbhit function 167 Keep Tabs button 124 keepasm 215 L Labels 263 B 263 F 263 anonymous 263 assigning to a space 264 exporting 264 importing 264 in assembly language 216 263 local 263 Index local 263 location checks 264 labs function 349 366 Large memory model 138 Largest integer computing 360 LDBL_DIG 341 LDBL_MANT DIG 341 LDBL_MAX 341 LDBL MAX 10 EXP 341 LDBL MAX EXP 341 LDBL MIN 341 LDBL MIN 10 EXP 342 LDBL MIN
288. elect 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 Linker Output Page on page 93 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zil0d 10 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 a Standard project the New Project Wizard dialog box is displayed For Assembly Only executable projects continue to step 12 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 v Standard C Startup Module plan to provide your own RENE startup code uncheck the M C Runtime Library option V Floating Point Library requires the C Runtime Library H Select the appropriate memory model from the following list C Runtime Library Check if you plan to make any calls to Large standard library functions and you do not plan to provide your own code for all library C Static Frames Dynamic Frames functions that plan to use Select the appropriate option below Floating Point Library Check Finish Cancel
289. em UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual iH JE Sa fl a 8 I f y A i 1 A J YY Z V V M 194 This section covers the following Preprocessor Warning and Error Messages on page 194 e Front End Warning and Error Messages on page 197 Optimizer Warning and Error Messages on page 207 e Code Generator Warning and Error Messages on page 209 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 not match those of the previous definition 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 lt name gt An attempt was made to call lt name gt macro with a parenthesis embedded in the argument list that did not match up 006 Cannot redefine lt name gt keyword An attempt was
290. emory 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 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 For more information about link commands see Linker Commands on page 277 OUTPUT FILES The assembler creates the following files and names them the name of the source file but with a different extension 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 Assembly Listing Files 1st check box in the Assembler page of the Project Settings dialog box See Generate Assembly Listing Files lst on page 67 source ob is an object file in relocatable OMF695 format The assembler creates lt source gt obj does not assemble files with these extensions therefore the data contained in Do not use source input files with 1st or obj extensions The assembler Caution the files is lost Source Listing
291. enerated 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 58 C Preprocessor Page NOTE For Assembly Only projects the Preprocessor page is not available The options in the Preprocessor page are described in this section L Project Settings Configuration Debug m 3 General E Preproce xh Assembler Preprocessor Definitions flc Sis Code Generation RE XP Fi B80 SERIES 15K Z8ENCORE F1580 SIMULATE 3 Listing Files Standard Include Path Sil Advanced E Eh Deprecated ZSL User Include Path 3 El Linker NM 3 SS Commands 2 Objects and Libraries SBA Address Spaces Sa Warnings 3 Output Sil Debugger Note Cancel Help Figure 53 Preprocessor Page of the Project Settings Dialog Box UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Nod ILU LUI E M I 68 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
292. enobj Does not generate an object file with the obj extension The default setting is genobj noigcase Enables case sensitivity of user defined symbols This is the default nolist Does not create a list file The default setting is 1ist 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 Sets 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
293. er 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 gram 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 calculate a file checksum update the firmware and customize of the Z8 Encore developer s environment The Tools menu has the following options e Flash Loader on page 110 Calculate File Checksum on page 117 Firmware Upgrade
294. er Directive Description SIF SREPEAT WHILE Structured assembly test primary SELSEIF Structured assembly test alternate SELSE Structured assembly test default SBREAK SCONTINUE Structured assembly test control SSENDIF SUNTIL SWEND Structured assembly test end The assembler directives shown in the table are known collectively as structured assembly test directives and are always used together to form a homogeneous structured assembly block The assembler supports one decision structure TF and two looping structures SWHILE and SREPEAT The assembler supports a decision structure with the SIF SELSEIF SELSE and SENDIF directives These directives generate code to test one or more execution time conditions and execute a block of statements based on the result of the tests For example for the following decision structure S Sif r0 0 ld rO r1 Selse ld r0 r2 Sendif the assembler generates the following code 000000 A6E000 A 2 Sif r0 0 000003 EB 05 000005 E4E1E0 A 3 ld r0 rl 000008 8B 03 A 4 Selse 00000A E4E2E0 A 5 ld r0 r2 00000D A 6 Sendif The assembler supports two types of looping structures with the SWHILE SWEND and SREPEAT SUNTIL directive pairs The SWHILE directive generates code to test an execution time condition and executes a block of statements while the condition is true Since the test i
295. er Studio ll Z8 Encore User Manual ZILOQ as putch 168 putchar 375 puts 376 qsort 376 rand 377 READ FLASH 168 READ NVDS 170 READ NVDS GET STATUS 170 realloc 377 RI 171 scanf 378 search 349 351 select port 171 SET VECTOR 172 setjmp 381 sin 382 sinh 382 sorting 349 sprintf 382 sqrt 383 srand 383 sscanf 384 strcat 384 strchr 385 stremp 385 strcpy 385 strcspn 386 string conversion 348 strlen 386 strncat 387 strncmp 387 strncpy 388 strpbrk 388 strrchr 389 strspn 389 strstr 389 strtod 390 strtok 391 strtol 392 tan 393 tanh 393 Index TDI 174 testing characters 362 363 364 365 366 tolower 393 toupper 394 trigonometric 344 va_arg 394 va_end 395 va_start 396 vprintf 397 vsprintf 397 WRITE_FLASH 175 WRITE_NVDS 176 WRITE NVDS GET STATUS 177 Z8 Encore family specific 164 G General page 9 56 57 General tab 122 Generate Assembly Listing Files lst check box 60 67 Generate Assembly Source Code check box 66 Generate C Listing Files lis check box 66 Generate Debug Information check box 58 Generate Map File check box 94 Generate Printfs Inline check box 70 getch function 165 getchar function 347 361 gets function 347 362 Go button 20 Go To button 51 Go to Code button 52 328 Go to Line Number dialog box 51 go script file command 421 GROUP command 282 Groups allocation order 286 definition 276 linking sequence 284 locating 282 renaming 278
296. er to a signed type with a pointer to an unsigned type and vice versa 216 lt name gt Initialization needs curly braces An attempt is made to initialize a structure of union without enclosing the initialization in curly braces and 217 Cannot open include file lt name gt An attempt to open the include file lt name gt failed Check the path of lt name gt in combination with the usrinc and stdinc command line options for the existence of the file 218 Function definition declared auto An attempt is made to define a function with auto storage class 219 Parameter type given in both old style and new style While defining a function an attempt is made to specify the parameter type in both old style and new style 220 Cannot perform pointer arithmetic on function pointer An attempt is made to perform pointer arithmetic on function pointer 221 Type defaults to int A variable declared with no type is treated as of type int A function declared with no return type is treated as a function returning int UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 5 H iH PES SN 7 Il Of V MV M 207 I 222 Statement has no effect If the statement is not modifying any variables and only reading them this warning is generated If the variable read is a volatile variable this warning is not generated 223 Indirectly called function must be of reentrant
297. erased or overridden UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zzilogi 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 Directives check box 2 Click Edit The Additional Linker Directives dialog box 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 59 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 executabl
298. erate Printfs Inline check box is selected the UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual gt ran ILU LUI EN M 71 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 or sprintf 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 To reduce overall code size by selecting this check box the following conditions are nec essary e All calls to printf 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 timerWarningMessage sprintf timerWarningMessage reset time e hevprintf and vsprintf functions cannot be used even if the format string is a string literal If the Generate
299. ere the file is included UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi 5 the directories listed under the stdinc command 6 the default directory C Advanced Page NOTE For Assembly Only projects the Advanced page is not available The Advanced page is used for options that most users will rarely need to change from their default settings li Project Settings Configuration Debug bed 5e General Sie Assembler Bl e Sil Code Generation Eh Listing Files 3 Preprocessor E Ss Deprecated Bit field Packing Most Compact y 5 ZSL fi Linker 2 Commands h Objects and Libraries 3 Address Spaces E Warnings Sak Output ak Debugger v Generate Printfs Inline Note Some items on this page are disabled due to the use of the Limit Optimizations for Easier Debugging option on the C Code Generation page Cancel Help Figure 54 Advanced Page of the Project Settings Dialog Box Use Register Variables Setting this drop down list box to Normal or Aggressive allows the compiler to allocate local variables in registers rather than on the stack when possible This usually makes the resulting code smaller and faster and therefore the default is that this drop down list box is enabled However in some applications this drop down list box might produce larger and slower code when a function contains a large number of local variables U
300. ere 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 on the Z8 Encore developer s environment The View menu contains these options e Debug Windows on page 53 e Workspace on page 54 e Output on page 54 e Status Bar on page 54 Debug Windows When you are in Debug mode running the debugger you can select any of the ten Debug windows From the View menu select Debug Windows and then the appropriate Debug window The Debug Windows submenu contains the following Registers Window on page 312 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll
301. ers see Ignore Case of Symbols on page 58 Assembler reserved words are not case sensitive Assembler Rules The following sections describe the assembler rules Reserved Words on page 218 e Assembler Numeric Representation on page 219 Character Strings on page 220 UM013033 0508 Using the Macro Assembler Reserved Words Zilog Developer Studio ll Z8 Encore User Manual ZIlOg ns 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 assume Copy ELSEIF ENDMACRO even global long MNOLIST ELSEIF iral Z DMODULE ESECT FILE GLOBAL I2C IFNDIFF IGNORE LIST MACCNTR MACLIST UM013033 0508 ascii asciz bes block data def emsg ENDIF ENDSTRUCT ENDWITH extern FCALL IF include MACEND MACRO NEWBLOCK ORG ref RR Space STRING UNION USECT word WRG _WRG ADC ASECT ASSUME BLKL BLKP CO CHIP COMMENT DATA DB DEFINE DF DPTR DS END ENDC ENDS ENDSTRUCT EXIT F FLAGS FRACT GLOBALS GREGISTER IFDIFF IFE IFNMA IFNSAME INCLUDE E long ONGREG MACDELIM MACEND MACNOTE MESSAGE CONDLIST to K E tj O FRAME IFFALSE IFNTRU
302. es Click Yes to save and then rebuild the project General Page From the Project Settings dialog box select the General page The options on the General page are described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog li Project Settings Configuration Debug y ile Assembler 3 fal c CPU Family Z8Encore XP F1680 Series 16K y SA Code Generation Listing Files CPU Z8F1680xJ h Preprocessor Build Sis Advanced M Show W amings SS Deprecated IV 5e ZSL T i ina Intermediate Files Directory a d E AE dirae C Program FilesvZiLOGXZDSII Z8Encorel 4 11 0 s w 5h Address Spaces Sil Warnings Sa Output Sh Debugger Note Some items on this page are disabled due to the use of the Limit Optimizations for Easier Debugging option on the C Code Generation page Cancel Help Figure 49 General Page of the Project Settings Dialog Box CPU Family The CPU Family drop down list box allows you to select the appropriate Z8 Encore fam ily For a list of CPU families see Z8 Encore Product Support on page xviii CPU The CPU drop down list box defines which CPU you want to define for the target For a list of CPUs see Z8 Encore Product Support on page xviii 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 sel
303. es segments in different object modules Z8 Encore Memory Spaces PRAM Space ROM Space RData Space EData Space Program RAM Flash Register File Register File A PRAMSEG fname TEXT ROM DATA ROM TEXT NEAR BSS NEAR DATA FAR BSS FAR DATA Segment Segment Segment Segment Segment Segment Segment Segment VECTORS STARTUP NEAR TEXT FAR TEXT Segment Segment Segment Segment Note PRAM and PRAMSEG are only available on Z8 Encore 16K XP devices Figure 95 Z8 Encore Hierarchical Memory Model UM013033 0508 Using the ANSI C Compiler Module one obj Zilog Developer Studio ll Z8 Encore User Manual 183 Module two obj Module three obj U1 V1 x1 V3 X3 v v2 v x2 v2 Space PRAM Space RData Space ROM Space EData Note PRAM is only available on Z8 Encore 16K XP devices Figure 96 Multiple File Linking 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 that you selected A list of the system object files and libraries is given in the following table The linker command file automatically selects and links to the appropriate version of the C run time and if neces sary floating point libraries from the list shown in the following table based on your project settings File Table 5 Linker Referenced Files Description startups obj
304. fa 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 1101 7 112 4040 00 90 23 01 40 3f Ethernet Smart Cable lt a Broadcast Address 255 255 255 255 Refresh Smart Cable Selected IP Address 192 168 1 50 TCP Port 4040 OK Cancel PUSE Figure 69 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 e Ifyou select SerialSmartCable and click Setup in the Debug Tool area th
305. features from the 1999 standard are supported in this compiler for ease of use Additional Keywords for Storage Specification The near far and rom 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 the const and volatile keywords in the ANSI C standard The storage speci fiers can only be used to control the allocation of global and static data The allocation 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 data allocation for various storage class specifiers is as follows e near A variable declared with the near storage specifier is allocated in the 8 bit addressable RData near RAM address space The address range for these variables 1s 00 FF The corresponding assembler address space for these variables is RData You can set this address range within 00 FF based on device type and application requirement For example near int ni ni is placed in RData address space far A variable declared with the far storage specifier is allocated in the 12 bit addressable EData far RAM address space The address range for these variables is 100 FFF The corresponding assembler address space for these variables is EData You can set this address range within 100 FFF ba
306. figuration Name field 105 Configurations adding new 104 setting 103 Configure Target dialog box 97 Connect to Target button 19 const keyword 191 CONST IN RAM _ 149 150 CONST IN ROM _ 149 150 Context menus Call Stack window 323 Disassembly window 325 in Edit window 32 in Project Workspace window 30 Locals window 322 Simulated UART Output window 326 Watch window 321 322 control UARTx function 335 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ Converting letter case 393 394 Converting strings 390 392 COPY BASE OF command 280 COPY BASE operator 291 Copy button 17 99 COPY command 279 Copy Configuration Settings dialog box 106 Copy Settings From list box 105 106 Copy Settings To field 106 COPY TOP OF command 280 COPY TOP operator 291 Copying characters 370 388 Copying functions 350 Copying strings 385 Copying values 371 cos function 344 357 cosh function 344 358 cosine calculating 357 151 CPU directive 228 CPU Family list box 40 57 CPU list box 40 57 CPU selection 57 CPU NAME 149 CpuflashDevice xml file 111 CRC 119 CRC script file command 415 Create New Target Wizard dialog box 98 Creating a project 2 lt ctype h gt header 339 Current drop down list box 100 Customer service xx Customer support xx Customize dialog box 119 Commands tab 121 Toolbars tab 119 120 Cut button 17 Cyclic redundancy check 119 Index D Data
307. fining 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 and any additional object library modules specified in the Objects and Libraries page of the Project Settings dialog box see Linker Objects and Libraries Page on page 84 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 81 You can add additional linker commands by selecting the Additional Direc tives check box and clicking Edit see Additional Directives on page 82 If you want to override the automatically generated linker command file select the Use Existing button see Use Existing on page 83 The linker can also be invoked fr
308. from the File menu The New Project dialog box is displayed New Project Project Name MIDA Project Type Standard y CPU Family 28 ncore_XP_64XX_Series CPU Z8F6423 Build Type Executable y Finish Cancel Figure 1 New Project Dialog Box 2 Fromthe New Project dialog box click on the Browse button Ed to navigate to the directory where you want to save your project The Select Project Name dialog box is displayed UMO13033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog Select Project Name Look in G Tutorial f er E3 File name Files of type Project Files zdsproj Cancel Figure 2 Select Project Name Dialog Box Use the Look In drop down list box to navigate to the directory where you want to save your project For this tutorial place your project in the following directory lt ZDS Installation Directory gt samples Tutorial If Zilog Developer Studio was installed in the default directory the following is the actual path C Program Files ZiLOG ZDSII_ Z8Encore 4 11 0 samples Tutorial NOTE You can create a new folder where you want to save your project For example C lt New Folder gt 4 22 go cL gv Ipa UM013033 0508 In the File Name field type sample for the name of your project The Z8 Encore developer s environment creates a project file Project files have the zdsproj extension for example
309. 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 found 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 string h char strtok char sl char s2 Returns A pointer to the first character of a token or a null pointer if there is no token Example include lt string h gt static char str a b p yte char t t strtok str t points
310. g Developer Studio ll Z8 Encore User Manual iH 2 fl PR PB 7 EN y i I 1 J LL IJ V MV M 284 expression is the maximum size Example MAXLENGTH CODE SFF NOTE Refer to Linker Expressions on page 288 for the format to write an expression NODEBUG The NODEBUG command suppresses the linker from generating debug information This option is applicable only if the executable file is IEEE 695 Syntax NODEBUG NOMAP The NOMAP command suppresses generation of a link map file The default is to generate a link map file Syntax NOMAP 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 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 LN E 285 I Example ORDER GDATA GTEXT where GDATA and GTEXT are groups In this example all address spaces associate
311. g 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 NOTE The linker recognizes the special space NULL NULL is not one of the spaces that an object file or library can reside in 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 See also the examples for the COPY command COPY on page 279 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual i IIA fel 1 LJ li amp YW Ly 279 I Examples To change the name of a segment for example strseg to another segment name for example codeseg use the following command CHANGE strseg codeseg To move a segment for example dataseg to a different address space for example EDATA use the following command CHANGE dataseg EDATA 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 R
312. g the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Customize Commands Tab The Commands tab lets you modify the following by selecting the category File Toolbar on page 16 e Find Toolbar on page 21 Build Toolbar on page 18 e Debug Toolbar on page 23 e Debug Windows Toolbar on page 27 Bookmarks Toolbar on page 22 Command Processor Toolbar on page 22 Menu Bar on page 37 To see a description of each button on the toolbars highlight the icon as shown in the fol lowing figure Customize Toolbars Commands Categories Buton c Eg 8x8 m A Debug Windows Bookmarks 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 87 Customize Dialog Box Commands Tab UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual iH 2 fl PR PB 7 EN y i I QB J LL IJ V MV M 122 Options The Options dialog box contains the following tabs e Options General Tab on page 122 e Options Editor Tab on page 123 e Options Debugger Tab on page 126 Options General Tab The General tab has the following check boxes Select the Save Files Before Build check box to save files before you build This option is selec
313. g 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 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Z1109 a 3172251 in the following figure 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 clocks 3172251 seconds 0 172105 Figure 101 Clock Window Memory Window Click the Memory Window but
314. ge 160 The standard header files and functions are with minor exceptions fully compliant 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 193 The standard header files provided with the compiler are listed in the following table 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 Standard Header Files on page 338 e Standard Functions on page 351 Table 11 Standard Headers Header Description lt assert h gt Diagnostics lt ctype h gt Character handling functions lt errno h gt Error numbers lt float h gt Floating point limits lt limits h gt Integer limits lt math h gt Math functions lt setjmp h gt Nonlocal jump functions lt stdarg h gt Variable arguments functions lt stddef h gt Standard defines lt stdio h gt Standard input output functions lt stdlib h gt General utilities functions lt string h gt String handling functions UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual NOTE The standard include header files are located in the following directory lt ZDS Installation Directory gt include std where ZDS Installation Directory gt is the directory in which Zilog Devel
315. ght be 4 11 0 or 4 11 0 You can run the buildallzsl bat batch file to generate the libraries directly into the following directory ZILOGINSTALLVZDSII product versionNlibNzilog The buildallzsl bat batch file is in the following directory ZILOGINSTALLVZDSII product version src Refer to the Zilog Standard Library API Reference Manual RM0038 for more details UMO13033 0508 Zilog Standard Library Notes and Tips Zilog Developer Studio ll Z8 Encore User Manual ELA ss WHAT IS THE DIFFERENCE BETWEEN THE INTERRUPT MODE AND THE POLL MODE IN THE UARTS In INTERRUPT mode the API uses UART interrupts to transmit and receive characters to and from the UARTS so the operation is asynchronous In POLL mode the API polls the UART device for the transmission and reception of data so the operation is synchronous blocking in nature WHAT ARE THE DEFAULT SETTINGS FOR THE UART DEVICE UART devices are initialized with 38400 baud 8 data bits 1 stop bit and no parity Also the UART by default is configured to work in poll mode HOW CAN I CHANGE THE DEFAULT UART SETTINGS FOR MY APPLICA TION UARTS can be initialized to the required settings by passing the appropriate parameters in the control UARTx API Refer to the Zilog Standard Library API Reference Manual RM0038 for more details I AM USING THE UART IN THE INTERRUPT MODE WHY DO I SEEM TO LOSE SOME OF THE DATA WHEN I TRY TO PRINT OR TRY TO RECEIVE A LARGE AMOUNT OF DATA
316. gma monitor void my kernel fn void oan This feature does not work properly for functions that are also declared as interrupt service routines Avoid combining the use of the monitor and interrupt qualifiers for the same function NOTE The pragma monitor declaration has function scope and will affect the next function definition as opposed to a function declaration that is a function prototype that the compiler encounters For this reason quite unexpected results can ensue if this pragma is used in a function prototype especially when function declarations and definitions are grouped separately as is common practice In the case of monitor these results might cause serious problems in your application by disabling interrupts in a function where this was not your intention Therefore it is recommended that you avoid using this pragma in function prototypes UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual e H I PES SN Z I1 Of amp Y Ly 142 String Placement When string constants literals like mystring are used in a C program they are stored by the C Compiler in the RData address space for the small memory model and in the EData address space for the large memory model However sometimes this default place ment of string constants does not allow you adequate control over your memory use Therefore language extensions are provided to give you more control over string pla
317. gs dialog box select the Debugger page lil Project Settings Configuration Debug m h General Debugger E E Y Use page erase before flashing Sil Code Generation epa Listing Files E Preprocessor 28F168001282C0G ZDS Default Advanced A Deprecated 5e ZSL fg Linker SS Commands h Objects and Libraries 3 Address Spaces Add Copy Delete Warm ia Debug Tool Ez Debugger Current USBSmartCable y Setup Note OK Cancel Help Figure 65 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 Z8 Encore simulator the USB Smart Cable the serial Smart Cable and the Ethernet Smart Cable UM013033 0508 Using the Integrated Development Environment
318. gth of the segment Example int pos char s1 xyzabc char s2 abc pos strcspn s1 s2 strlen Computes the length of the string pointed to by s Synopsis include lt string h gt size t strlen char s Returns The number of characters that precede the terminating null character UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual S Example char s1 COMPASS int a i strlen s1 strncat 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 string h char strncat char sl 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 include lt string h gt int strncmp char sl char s2 size t n 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 UMO13033 0
319. hanged 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 nested 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 amp YW Ly 369 amu 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 Retur
320. har addr Returns The function returns the value read and the status of NVDS read as per the device specifi cation The status is in the lower byte of the return value The upper byte of the return value contains the data read Example finclude lt eZ8 h gt char x wstatus rstatus unsigned int val void main UM013033 0508 Using the ANSI C Compiler wstatus Zilog Developer Studio ll Z8 Encore User Manual Zzilogi WRITE NVDS GET STATUS x 0x10 write x to NVDS at address 0x10 and get the status val R EAD NVDS GET STATUS 0x10 read NVDS at address 0x10 x val gt gt 8 amp OxFF extract data rstatus val amp OxFF extract read status 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 existing interrupt status See TDI on page 174 for a discussion of that function The interrupt sta tus to be restored is passed as a parameter to RI This function is an intrinsic function and is inline expanded Synopsis include lt eZ8 h gt intrinsic void RI unsigned char istat Example include lt eZ8 h gt void main void unsigned char istat istat TDI Test and Disable Interrupts Do Something RI istat Restore Interrupts select_port The select port function is a
321. he 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 drop down list 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 Select the Limit Optimizations for Easier Debugging check box see Limit Optimizations for Easier Debugging on page 63 e Set the Use Register Variables drop down list box to Off 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 dow that is 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 generate the required output When the Gen
322. he Project Settings dialog box on the C pages or by using the pragma directives described in this section If the pragma directive is inserted in your code it overrides the selections you made in the Project Settings dialog box pragma alias Enables alias checking The compiler assumes that program variables can be aliased This pragma is the default pragma noalias Disables alias checking Before using this pragma be sure that the program does not use aliases either directly or indirectly An alias occurs when two variables can reference the same memory location The following example illustrates an alias func int x p p amp x both x and p refer to same location If both p and x are used below the assignment then malignant aliases exist and the NOALIAS switch must not be used Otherwise alias is benign and the NOALIAS switch can be used UM013033 0508 Compatibility Issues Zilog Developer Studio ll Z8 Encore User Manual 441 pragma cpu lt cpu name gt Defines the target processor to the compiler pragma globalcopy Enables global copy propagation pragma noglobalcopy Disables global copy propagation pragma globalcse Enables global common elimination unless local common subexpressions are disabled pragma noglobalcse Disables global copy subexpression elimination pragma globaldeadvar Enables global dead variable removal pragma noglobaldeadvar
323. he cancel all command clears all breakpoints in the active file The following is the syntax of the cancel all command cancel all UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual i IION ILU U IL Y Ly 415 amu cancel bp The cancel bp command clears the breakpoint at the bp list index Use the list 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 cd The cd command changes the working directory to dir The following is the syntax of the cd command c lt dir gt For example cd c Ntemp cd another dir checksum The checksum command calculates the checksum of a hex file The following is the syn tax ofthe checksum command checksum filename For example if you use the following command checksum ledblink hex The file checksum for the example is OxCEA3 crc The CRC command performs a cyclic redundancy check CRC The syntax can take one of two forms crc calculates the CRC for the whole Flash memory crc STARTADDRESS address ENDADDRESS endaddress 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 ENDADDRESS must be a 4K increment if the end address is not a 4K increment it is rounded up to a
324. he compilation process with warning as opposed to error For example the following line in the C source warning This is a test message causes the compiler to generate the following warning Test c 2 9 WARNING 38 This is a test message Supported New Features from the 1999 Standard The Z8 Encore 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 147 Trailing Comma in Enum on page 148 Empty Macro Arguments on page 148 Long Long Int Type on page 148 C Style Comments Comments preceded by and terminated by the end of a line as in C are supported UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual o iH JE Sa fl a 8 7 I f y A i 1 A J YY IGN A 1 4 8 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 Ssin cat3 Hello World Empty arg Long Long Int Type The 1ong long int type is allowed In the Z8 Encore C Compiler this type is treated as
325. he 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 Z8 Encore specific configuration such as interrupt vector table initialization See Lan guage Extensions on page 132 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 gt src boot common startupX 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 Z8Encore lt ver sion where lt version gt might be 4 11 0 or 5 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 Works
326. he moment when it is needed Another way of saving space when data space RData and EData is at a premium is to declare initialized tables that are not modified in the code with the rom keyword The tradeoff here is that the execution speed is likely to be somewhat slower because the num ber of addressing modes available to the compiler for accessing rom variables is very small Call Frames Call frames hold the arguments local variables and other pertinent information of an instantiation of a procedure or function at a time The Zilog Z8 Encore C Compiler sup ports two types of call frames Static Frames on page 138 e Dynamic Frames on page 139 Static Frames In the static frames scheme for each function in the program a single frame is statically allocated at compile time for storing the call frame containing the parameters and local variables of the function Static call frames can significantly increase code efficiency However this is a restrictive call frame scheme This option must be used with some care because errors ensue if it is applied blindly and your code uses either recursion or calls through function pointers You can avoid those errors by finding the functions that use those language features and UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual declaring them reentrant In the case of function pointers it is the functions to which the pointers refer
327. he serial number Flash BURNSERIAL REPEAT Program the serial number and repeat Flash ERASE Erase Flash memory Flash ERASE REPEAT Erase Flash memory and repeat UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual ZILOG ass 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 Caution Exampl es 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 The following are valid examples FLASH Options INTMEM FLASH Options c NtestingNtest hex FLASH BURN REPEAT or 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 F ASH V ERIFY E The file t est hex is verified against internal Flash memory ASH SI ETUP The current Flash Loader parameters settings are displayed in the
328. hin 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 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i I PES PN Z I1 Of V MV M 248 I 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
329. his 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 box 2 Right click in the list box to display the context menu 3 Select Save to File The Save to File dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIlOg ue Save To File File Name Address Range File Format Start Address Hex 00 Text Hex C Binary Cancel Figure 80 Save to File Dialog Box End Address Hex FF 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 4 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 Select how many bytes per line or enter the number of bytes in the Other field 8 Click OK to save the memory to the specified file Loada 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 memory 1 Sel
330. ht 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual 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 sequence 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 wi
331. ialization feature 1 Select the Enable check box 2 Select the Include Serial in Programming check box This option programs the serial number after the selected hex file has been written to Flash 3 Type 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Type the location you want the serial number located 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 then write the serial number If you want to check a serial number that has already been programmed at an address do the following 1 Select the Enable check box 2 Type the
332. ight clicking in the Simulated UART Output window displays a context menu that pro vides access to the following features 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 327 Viewing Breakpoints on page 328 Moving to a Breakpoint on page 328 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual zilogi Enabling Breakpoints on page 328 Disabling Breakpoints on page 329 Removing Breakpoints on page 329 Inserting Breakpoints There are three ways to place a breakpoint in your file Click on the line of code where you want to insert an active breakpoint You can set an active breakpoint in any line with a blue dot displayed to the left of the line the blue dots are displayed after clicking the Reset button to enter Debug mode Click the Insert Remove Breakpoint button M on the Build or Debug toolbar Click on the line where you want to add an active breakpoint right click to display the context menu and select Insert Breakpoint You can set an active breakpoint in any line with a blue dot displayed to the left of the line the blue dots are
333. ile Toolbar New Button The New button creates a new file Open Button The Open button opens an existing file Save Button The Save button saves the active file 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Output Window Button The Output Window button shows or hides the Output window Build Toolbar The Build toolbar allows you to build your project set breakpoints and select a project configuration with the following controls and buttons e Select Build Configuration List Box on page 18 e Compile Assemble File Button on page 18 Build Button on page 18 Rebuild All Button on page 18 Stop Build Button on page 19 Connect to Target Button
334. ile command 420 EXIT FAILURE macro 348 EXIT SUCCESS macro 348 exp function 344 359 Expand Macros check box 60 exponential 344 Exponential functions 344 359 Exporting project as make file 101 from the command line 400 Expressions FTOL operator 222 L TOF operator 223 arithmetic operators 221 automatic working register definitions 225 binary numbers 223 Boolean operators 221 character constants 224 decimal numbers 223 hexadecimal numbers 223 HIGH operator 222 HIGHI06 operator 222 in assembly 220 linker 288 LOW operator 222 LOW 16 operator 222 octal numbers 224 operator precedence 224 operators 225 Index relational operators 221 EXTERN directive 264 External references resolving 281 EZ8 150 lt eZ8 h gt header 162 F fabs function 345 359 False macro 339 FAQ txt location of xxi far storage specifier 134 FAR BSS segment 181 far_bss segment 212 FAR_DATA segment 181 far_data segment 212 FAR_TEXT segment 181 far_txt segment 212 _ FILE 149 File adding 6 54 opening 8 reading 8 viewing 8 File extensions hex 95 lod 95 Ast 214 map 283 obj 214 215 wsp 44 zdsproj 3 File menu 38 Close File 39 Close Project 45 Exit 47 New File 38 New Project 39 Open File 38 Open Project 43 Print 45 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ s Print Preview 46 Print Setup 47 Recent Files 47 Recent Projects 47 Save 45 Save All 45 Save As 45 Save Project 44
335. in needs to be of type void any returned value is ignored Also main is not passed any arguments In short the follow ing is the prototype for main 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 Z8 Encore C Compiler does not support a double precision floating point type The type double is accepted but is treated as if it were float const Keyword and ROM The Z8 Encore C Compiler by default assumes const in RAM and places const vari ables without any storage qualifications in RData for the small model and EData for the large model With the const in RAM option in affect the C Compiler follows the ANSI C standard rules for const parameters However the C Compiler also provides a deprecated option to place such const variables in ROM memory instead When this option is selected the treatment of the const key word is emphatically non ANSI Specifically when this option is selected the const key word is treated as equivalent to rom Then the function prototype void foo const char src implies that the src string is in ROM memory and any code that calls foo should pass only a const or rom string as src string argument This restriction comes because the Z8 Encore microcontroller has different machine instructions for accessing its different memory spaces LDC LD and LDX This is a deviation from ANSI C
336. ination status EXIT FAILURE Expands to integral expression that 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 The general utilities are listed and briefly described in the following sections e String Conversion on page 348 e Pseudorandom Sequence Generation on page 348 Memory Management on page 349 Searching and Sorting Utilities on page 349 Integer Arithmetic on page 349 Miscellaneous on page 349 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 double atof char nptr Converts string to double int atoi char nptr Converts string to int long int atol char nptr Converts string to long double strtod char nptr char endptr Converts string pointed to by nptr to a double long int strtol char nptr char endptr int base Converts string to a long decimal integer that is equal to a number with the specified radix Pseudorandom Sequence Generation int rand void Gets a pseudorandom number void srand unsigned int seed Initializes pseudorandom series UM013033 0508 C Standard Libra
337. increase the upper bound of your EData range to 5FF e NVDS The Z8 Encore XP 4K and 16K devices contain a Non Volatile Data Storage NVDS element with a size of up to 128 bytes This memory features an endurance of 100 000 write cycles For more information about NVDS see the Non Volatile Data Storage chapter of the Z8 Encore XP 4K Series Product Specification e PRAM Program RAM The Z8 Encore XP F1680 Series devices feature an area of Program RAM that can be used for storing some code in RAM This area can be used to help keep device operating power low by for example storing interrupt service routines here that would activate the code in Flash memory when some external event has occurred UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual PRAM when available is an optional feature If you want to use this memory as Program RAM select the Use PRAM check bo the PRAM field PRAM begins at data address 1 512 or 1024 bytes depending on your device I x and then adjust the address range in E000 and can have a maximum size of f you deselect the PRAM check box this memory is not available as PRAM but instead can be mapped as additional EData memory see the EData memory discussion NOTE It is your responsibility to set the Flash option bytes to reflect whether you are using this memory as PRAM or as EData This needs to be done inside your p
338. indow and allows you to activate the Project Workspace window or the Output window UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual The Window menu contains the following options New Window on page 128 Close on page 128 Close All on page 128 Cascade on page 128 Tile on page 128 Arrange Icons on page 128 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 Help Topics on page 128 Technical Support on page 129 About on page 129 Help Topics Select Help Topics to display the ZDS II online help UM013033 0508 Using the Integrated Development Environment Technical Support Zilog Developer Studio ll Z8 Encore User Manual ZILOU Select Technical Support to access Zilog s Technical Support web site About Select Abo
339. ing 440 Alias defined 440 ALIGN clause 234 ALIGN directive 227 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ az Allocating space 369 Always Generate from Settings button 81 Always Rebuild After Configuration Activated check box 122 Anonymous labels 263 Another Location button 99 Another Location field 99 ANSI C language described 337 ANSI C Compiler command line options 404 comments 147 compatibility issues 440 data type sizes 148 error messages 193 running from the command line 400 run time library 160 337 warning messages 193 writing C programs 132 arc cosine computing 353 arc sine computing 353 arc tangent computing 353 354 Argument location 158 variable 345 Arithmetic operators in assembly 221 Array function 356 ASCII values viewing 322 ASCIZ values viewing 322 asctime function 149 asin function 344 353 asm statement 143 Assembler 210 adding null characters 220 arithmetic operators 221 automatic working register definitions 225 binary numbers 223 Boolean operators 221 case sensitivity 217 character constants 224 character strings 220 command line options 402 Index decimal numbers 223 directive compatibility 268 437 directives 226 error messages 269 expressions 220 floating point numbers 219 generating listing file 1st 214 generating object file 214 hexadecimal numbers 223 numeric representation 219 octal numbers 224 operator precedence 224 operators 225 opti
340. ing button ends the current debug session To stop program execution click the Break button Go Button Click the Go button to execute project code from the current program counter If not in Debug mode when the Go button is clicked the following process is executed 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Downloads the program UM013033 0508 Using the Integrated Development Environment 25 Zilog Developer Studio ll Z8 Encore User Manual 5 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If it is a C project ZDS II resets to the main function if it is found 6 Executes the program from the reset location 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
341. ing 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 nonnegative value Example int Ah char strp COMPASS i puts str NOTE The UART needs to be initialized using the Zilog init uart function See init uart on page 167 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 compared 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 void qsort void base size t nmemb size t size int compar void void Example int lst 5 8 2 9 int compare void x void y qsort lst sizeof int 4 compare int compare void x void y int a int x UM013033 0508 C Standard Library rand Zilog Developer Studio ll Z8 Encore User Manual gt f AN 1 LJ LJ V MV M int b int y if a lt b return 1 if a b return 0 return 1 The compare functi
342. ing the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Large Memory Model In the large memory model global variables are allocated in the EData address space The address of these variables is 16 bits The locals and parameters are allocated on the stack which is also located in the EData address space The address of a local or parameter is a 16 bit address Global variables can be manually placed into the RData or ROM address space by using the address specifiers near or rom respectively Local nonstatic vari ables and parameters are always allocated in the EData address space and any address specifiers used in their declarations are ignored If you are forced to use the large model because of your data space and stack requirements you can still get some of the benefit of the more efficient code that is typical of the small model To do so carefully choose the most frequently used global or static variables and declare them near This helps with both code size and even more so with execution speed because more frequently executed code is more efficient One way of minimizing the amount of data space RData and EData your application needs is to allocate a single buffer in data space to hold for example the largest of a num ber of strings you might need to display The numerous strings are stored permanently in ROM where space is often less limited Each string in turn is then copied from ROM to data space at t
343. inks 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 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 Select Configuration Figure 73 Select Configuration Dialog Box 2 Highlight the configuration that you want to use and click OK UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZILOG 10s There are two standard configuration settings 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
344. int is 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 Click the Disable All Breakpoints button on the Debug toolbar 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 right click to display the context menu and select Disable Breakpoint 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 e 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 Breakpoints button on the Build or Debug toolbar There are four ways to delete a single breakpoint Double click on the red octagon to remove the breakpoint UM013033 0508 Using the Debugger UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual Select Manage Breakpoints from the Edit menu to disp
345. inter 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 initialize an array element a structure or union member with an expression that cannot be evaluated at compile time 208 Operands are not cast compatible An attempt was made to cast an operand to an incompatible type for example casting a rom pointer to a far pointer UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 V MV M 206 I 209 Ignoring space specifier e g near far on function An attempt was made to declare a function as near or far 210 Invalid use of placement or alignment option 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 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 point
346. inter 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 include lt string h gt size t strspn char sl char s2 Returns The length of the segment Example char s1 cabbage char s2 abc size t res res strspn sl s2 strstr Locates the first occurrence of the string pointed to by s2 in the string pointed to by s1 Synopsis include lt string h gt char strstr char sl char s2 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 V MV M 390 amu 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 Converts the string pointed to by nptr to double representation 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 con taining 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 charac
347. ints 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 10 DB val part2 At 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 Syntax lt macroname gt lt arg gt lt arg gt Example store R1 R2 R3 This macro invocation when used after the macro is defined as in Macro Definition on page 259 causes registers R1 and R2 to be added and the result stored in register R3 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Local Macro Labels Local macro labels allow labels to be used within multiple macro expansions 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
348. ion 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog 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 Linker Output Page on page 93 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 assembled The options on the Assembler page are described in this section lil Project Settings Configuration Debug E Si General m Includes e B A 3 Code Generation a 3 Listing Files Defines ge Preprocessor _Z8F1680 J 1 ZBENCORE XP F1580 SERIES 15K 1 Z8EN SBR Advanced SS Deprecated Listing Files Sd Z5L IV Generate Assembly Listing Files Ist ial Expand Macros Page Width 80 ommands 2 Objects and Libraries Page Length 56 3 Address Spaces 3 Warnings Advanced 3 32 Output Iv Jump Optimization Debugger Note Cancel Help Figure 50 Assembler P
349. ional lt mapfile gt is specified Example MAP myfile map Link Map File A sample map file is shown in Sample Linker Map File on page 294 NOTE The link map file base name is the same as your executable file with the map extension and resides in the same directory as the executable file The link map has a wealth of information about the memory requirements of your program Views of memory use from the space segment and module perspective are given as are the names and locations of all public symbols For the Z8 Encore link map file the C prefix indicates ROM the E prefix indicates EDATA the R prefix indicates RDATA and the P prefix indicates PRAM For additional information see also Generate Map File on page 94 MAXHEXLEN The MAXHEXLEN command causes the linker to fix the maximum data record size for the Intel hex output The default is 64 bytes Syntax MAXHEXLEN lt IS gt lt 16 32 64 128 255 gt Examples maxhexlen 16 or MAXHEXLEN IS 16 MAXLENGTH The MAXLENGTH command causes a warning message to be issued if a group address space or segment is longer than the specified size The RANGE command sets address boundaries The MAXLENGTH command allows further control of these boundaries Syntax MAXLENGTH lt name gt lt expression gt lt name gt can be a group address space or segment UM013033 0508 Using the Linker Locator Zilo
350. ions described in Table 6 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 sample test C PROGRA 1 ZiLOG ZD3E4C 1 0 lib startupl obj foo obj C PROGRA 1 ZiLOG ZD3E4C 1 0 lib chelpd lib C PROGRA 1 ZiLOG ZD3E4C 1 0 lib crtldd lib Y C PROGRA 1 ZiLOG ZD3E4C 1 0 lib fpldd lib C PROGRA 1 ZiLOG ZD3E4C 1 0 zilog csioldd lib 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 code generator helper library chelpd 1ib the C run time library for the large dynamic model with debug crtldd lib the floating point library fp1dd 1ib and the C Serial IO library for that same configuration csioldd 1ib An important point to understand in using the linker is that the linker intelligently links in only those object modules that are necessary to resolve its list of unresolved symbols Also the Zilog version of the C Standard Library is organized so that each module con tains only a single function or in a few cases a few closely related functions So although the C run time library contains a very large number of functions from the C Standard
351. isplays warnings LINKER COMMAND LINE OPTIONS UM013033 0508 See Using the Linker Locator on page 275 for the structure of the command file Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual 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 integrated development environment IDE This sec tion covers the following topics Sample Command Script File on page 412 Supported Script File Commands on page 413 Running the Flash Loader from the Command Processor on page 434 You can run commands in one of the following ways Using the Command Processor toolbar in the IDE 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 22 e Using the batch command to run a command script file from the Command Processor toolbar 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 need to precede the script file with an at symbol e when passing the command file to the IDE on the command line For example zds2ide c path to command file runall cmd zds2ide commands txt Processed commands are echoed and associated results are di
352. isters Automatic working register definitions allow you to specify which mode the assembler uses The default is 12 bit mode ER Indicates that the enclosed address is to be encoded as a 8 bit register pair address Only valid in 1dx instruction R Indicates that the lower nibble of the enclosed label has to be encoded in the instruction RR Indicates that the enclosed label is at the even boundary and the lower nibble is to be encoded in the instruction WRG Computes the value to store in the RP register so that the given label can be accessed using the 4 or 8 bit addressing mode The following examples show how to use automatic working register definitions lab equ 54 ldx r1 ER lab is encoded as 8754E1 ldx ER lab r2 is encoded as 97E254 ldx rp f WRG wbase If wbase is at 234 this is equivalent to the following ldx rp 1532 ld r0 R reg If reg is at 43 this is equivalent to the following ld r0 3 ldc r2 RR rreg If rreg is at 46 this is equivalent to the following ldc r2 rr6 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual T I JR ENT ZIlOQ V M I 226 I Define Bank0 Space RData org 0 segment Bank0 testme ds 1 segment Code srp WRG testme incw RR testme NOTE You must be careful if you want to use escaped mode addressing with 8 bit addresses in extended addressing instructions such as LDX ADDX
353. ith the given name Use debugtool list to view available debug tools Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual debugtool setup 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 options 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 TRACE or SIMULATE 1 The defines command can take one of three forms 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 lt compiler assembler gt replace lt new define lt old define gt replaces lt old define gt with lt new define gt for the compiler or assembler defines as indicated by the first parameter If lt o d define gt is not found no change is made 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 examp
354. ker SS Commands h Objects and Libraries 3 Address Spaces Sis Warnings Sh Output Eh Debugger Note ea Includes TN Defines _28F1680 1 ZBENCORE XP F1580 SERIES 15K 1 Z8EN Listing Files Iv Generate Assembly Listing Files lst Page Width 80 Page Lenath 56 Advanced Expand Macros v Jump Optimization Cancel Help Figure 10 Assembler Page of the Project Settings Dialog Box 5 Select the Code Generation page 6 Make sure that the Limit Optimizations for Easier Debugging check box is selected UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog E Project Settings Configuration Debug E SS General amp Code Generation Sls Assembler eflc C Safest 3 Code Generation C Small And Debuggable 3 Listing Files C Smallest Possible ee User Defined Eh Deprecated 5 ZSL El Linker V Limit Optimizations for Easier Debugging 5e Commands i e o 2 Objects and Libraries Memory Model Large z 3 Address Spaces Frames Dynamic y Si Warnings Parameter Passing Register y a Output SS Debugger Note OK Cancel Figure 11 Code Generation Page of the Project Settings Dialog Box 7 Select the Advanced page 8 Make certain that the Generate Printfs Inline check box is selected UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog
355. l 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 The following table 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 8 Operator Precedence Level 1 Level 2 5 unary high low Level 3 iis Level 4 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 a 1 2 1 lt lt 2 1 1 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zilog 225 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 a 1 lt lt 2 1 lt lt 2 1 lt lt 1 The modified constant expression evaluates to 6 H Automatic Working Register Definitions Z8 Encore supports 4 8 and 12 bit addressing of reg
356. l results in more compact code and might reduce 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 sup port such applications See Memory Models on page 137 for full details of the memory models Frames Select Static for static frames or select Dynamic for dynamic frames The use of static frames generally helps reduce code size but this option can only be used if your code obeys certain restrictions Specifically recursive function calls either direct or indirect and calls made with function pointers cannot be used with static frames except by the selective application of the reentrant keyword More detailed information on the trade offs between static and dynamic frames can be found in Call Frames on page 138 Parameter Passing When you select Memory the parameters are placed on the stack for dynamic frame func tions For static frame functions the parameters are placed in static memory register file UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual See Function Call Mechanism Dynamic Frame on page 152 and Function Call Mech anism Static Frame on page 153 for further details When you select Register the working registers R8 R13 a
357. labels in the operand field are defined in another module 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual IIA fel 1 LJ MV M 270 412 EOF encountered within an if End of file encountered within a conditional directive 413 Illegal floating point expression An illegal value was found in a floating point expression This error is normally caused by the use of labels in the expression 414 Illegal floating point initializer in scalar directive You cannot use floating point values in scalar storage directives 415 Illegal relocatable initialization in float directive You cannot use relocatable labels in a float storage directive 416 Unsupported illegal directives General purpose error when the assembler recognizes only part of a source line The assembler might generate multiple errors for the directive 417 Unterminated quoted string You must terminate
358. lay 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 right click to display the context menu and select Remove Breakpoint Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Zilog Standard Library Notes and Tips Review these questions to learn more about the Zilog Standard Library ZSL UM013033 0508 What is ZSL on page 332 Which on chip peripherals are supported on page 332 Where can I find the header files related to Zilog Standard Libraries on page 332 What is the zsldevinit asm file on page 332 What initializations are performed in the zsldevinit asm file on page 332 What calls the open_periphdevice function on page 332 When I use Zilog Standard Libraries in my application and build from the command line why do I see unresolved errors on page 333 I do not use the standard boot up module but I have manually included Zilog Standard Libraries When I link my code with the library why do I get an unresolved symbols error on page 333 Where can I get the ZSL source files on page 333 T need to change the ZSL source code How can I genera
359. le Bm Follow the setup instructions on your screen The installer displays a default location for ZDS II You can change the location if you want to DEVELOPER S ENVIRONMENT TUTORIAL This tutorial shows you how to use the Zilog Developer Studio II To begin this tour you need a basic understanding of Microsoft Windows Estimated time for completing this exercise is 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 UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog e Set Up the Project on page 8 Save the Project on page 14 When you complete this tour you have a sample lod file that is used in debugging NOTE Be sure to read Using the Integrated Development Environment on page 15 to learn more about all the dialog boxes and their options discussed in this tutorial For the purpose of this quick tour your Z8 Encore developer s environment directory will be referred to as lt ZDS Installation Directory gt which equates to the following path ZILOGINSTALL NZDSII Z8Encore lt version gt where e ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files VMZiLOG version is the ZDS II version number For example version might be 4 11 0 or 25 04 0 Create a New Project 1 To create a new project select New Project
360. le 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 of the delete config command delete config config name gt If config name gt is active the first remaining build configuration if any is made active If config name gt does not exist no action is taken For example delete config MyDebug UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual Zilog 419 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 exam ine command takes the following form lt data_type gt lt radix gt lt expr gt lt count gt lt data_type gt can consist of one of the following types short int eger long ascii asciz radix can consist of one of the following types dec imal hex adecimal oct al bin ary Omitting a data type or radix results in using the data type or radix pseudo variable respectively lt count gt represents the number of items to display The following are examples X shows the value of
361. le int x 25 int y 3 div t t UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zilog 359 int q int rj t div x y q t quot r t rem exp Computes the exponential function of x A range error occurs if the magnitude of x is too large Synopsis finclude lt math h gt double exp double x Returns The exponential value Example double y 1234 double x x exp y fabs Computes the absolute value of a floating point number x Synopsis tinclude lt math h gt double fabs double x Returns The absolute value of x Example double y 6 23 double x x fabs y UMO13033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i 1l rfl 1 LJ V MV M 360 amu floor Computes the largest integer not greater than x Synopsis tinclude lt math h gt double floor double x Returns The largest integer not greater than x expressed as a double Example double y 6 23 double x x floor y fmod Computes the floating point remainder of x y If the quotient of x y cannot be represented the behavior is undefined Synopsis include lt math h gt double fmod double x double y 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 i where the magnitude of f is less than the magni tude of y Example double y 7 23
362. ledblink inc 26 SCK_CLKIN EQU 504 External clock signal on PB3 8 Pin PAl ledblink inc 30 CLOCK EXTERNAL CLKIN EQU SCK CLKIN Search complete 3 occurrences found Build Debug A Find in Files Find in Files 2 A Messages Command Figure 30 Find in Files Output Window UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog Alledblink asm 53 CKSEL EQU SCK_CLKIN ledblink inc 26 5CK_CLKIN EQU 04 External clock signal on PB3 8 Pin PAl ledblink inc 30 CLOCK EXTERNAL CLKIN EQU SCK CLKIN Search complete 3 occurrences found T P K Build A Debug A Find in Files Find in Files 2 Messages A Command 7 Figure 31 Find in Files 2 Output Window Messages Output Window The Messages Output window holds informational messages intended for the user The Message Output window is activated given focus when error messages are added to the window s display Warning and informational messages do not automatically activate the Message Output window Loading project C Program Files ZiLOGNZDSII_Z8Encore _4 11 0 samples Z8F1680_44Pin a ERROR Could not load information for the target Z8F16800144ZCOG Please select a d Activated debug tool USBSmartCable E ERROR Could not load information for the target Z8F16800144ZCOG Please select a d Project loaded Creating project C NProgram Files ZiLOGNZDSII_Z8Encore _4 11 0 sample
363. lib C serial IO library for 16K XP large static model with debug information csiof1680sd lib C serial IO library for 16K XP small dynamic model no debug information csiof1680sdd lib C serial IO library for 16K XP small dynamic model with debug information csiof1680ss lib C serial IO library for 16K XP small static model no debug information csiof1680ssd lib C serial IO library for 16K XP small static model with debug information csiofmcld lib C serial IO library for MC large dynamic model no debug information csiofmcldd lib C serial IO library for MC large dynamic model with debug information csiofmcls lib C serial IO library for MC large static model no debug information csiofmelsd lib C serial IO library for MC large static model with debug information csiofmesd lib C serial IO library for MC small dynamic model no debug information csiofmesdd lib C serial IO library for MC small dynamic model with debug information csiofmess lib C serial IO library for MC small static model no debug information csiofmessd lib C serial IO library for MC small static model with debug information csiof8pinld lib C serial IO library for 8 pin large dynamic model no debug information csiof8pinldd lib C serial IO library for 8 pin large dynamic model with debug information csiof8pinls lib C serial IO library for 8 pin large static model no debug information
364. lized NVDS Non Volatile Data Storage and PRAM Program RAM spaces which are described more fully in Linker Address Spaces Page on page 89 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual The following sections describe segments Predefined Segments on page 212 User Defined Segments on page 213 Predefined Segments For convenience the segments listed in the following table are predefined by the assem bler Each segment gets assigned to one of the address spaces All of the predefined seg ments listed here can be aligned on any byte boundary Table 7 Predefined Segments Segment ID Space Contents Default Origin near_bss RData Uninitialized data Relocatable far_bss EData Uninitialized data Relocatable near data RData Initialized data Relocatable far data EData Initialized data Relocatable rom data ROM Initialized data Relocatable near txt RData String constants Relocatable far txt EData String constants Relocatable rom text ROM String constants Relocatable code ROM Code
365. llowing topics Using the Context Menus on page 32 e Using Bookmarks on page 32 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 you are running in Debug mode Cut copy and paste text Show whitespace 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 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 32 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 por
366. lows arga R8 R9 argb R10 R11 R12 R13 argc 2 argd 3 Return Values The assembly function must return the value in the location specified by the C calling con vention as described in Calling Conventions on page 151 For example if you are using the following C prototype long myfunc short arga long argb short argc The assembly function must return the long value in registers RO R1 R2 and R3 Preserving Registers The Z8 Encore C Compiler implements a caller save scheme The caller function pre serves the registers and the called assembly function is not expected to save and restore any registers that it uses 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 In the C functions all registers other than return registers are considered as caller save Therefore the caller assembly function must make sure that it saves on the stack any reg Isters that are in use before calling the C function and which also need to be available after the call The caller assembly procedure then restores those registers after the return from the C function The flag register need not be saved and restored by the caller assembly function The following example Assembly File on page 160 and Referenced C Function Proto type on
367. lpD lib Ij C 000E Version Zilog Developer Studio ll Z8 Encore User Manual Zilog C 000F 2h 1 0 05 03 2006 chelpD lib Version chelpD lib Version chelpD lib Version chelpD lib Version Segment _ VECTORS OOE Module commonivect10 asm Library 09 17 43 Name Segment _ VECTORS 010 Module commonNvecti2 asm Library 09 17 43 Name Segment VECTORS 012 Module common vect14 asm Library 09 17 43 Name Segment _ VECTORS 014 Module common vectl6 asm Library 09 17 43 Name Segment _ VECTORS 016 Module common vect18 asm Library 09 17 43 Name Segment _ VECTORS 018 Module common vectla asm Library 09 17 43 Name chelpD lib Version UMO13033 0508 Using the Linker Locator 300 chelpD lib C 001A Version Zilog Developer Studio ll Z8 Encore User Manual Zilog chelpD lib Version chelpD lib Version chelpD lib Version chelpD lib Version Segment _ VECTORS 01A Module common vectic asm Library 09 17 43 Name Segment _ VECTORS 01C Module common vectle asm Library 09 17 43 Name Segment _ VECTORS 01E Module common vect20 asm Library 09 17 43 Name Segment VECTORS 020 Module common vect22 asm Library 09 17 43 Name Segment _ VECTORS 022 Module common vect24 asm Library 09 17 43 Name Segment X VECTOR
368. lper 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 1s 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 258 Variable lt name gt may be used before it is defined If there is at least one path through the function that uses a local variable before it is defined this warning is reported UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual ga i fi PA F Z IOO n i LJ LI l 6 V U 209 Code Generator Warning and Error Messages 303 Case value lt number gt already 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 30
369. lt 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 UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual zilog Using the Integrated Development Environ ment The following sections discuss how to use the integrated development environment IDE e Toolbars on page 16 e Windows on page 29 Menu Bar on page 37 Shortcut Keys on page 129 To effectively understand how to use the developer s environment be sure to go through the tutorial in Getting Started on page 1 After the discussion of the toolbars and windows this section discusses the menu bar 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 dis cussed as a part of the Project menu section ZDS II Z8 Encore Family Ele Edit View Project Build Debug Tools Window Help ec ue ae pulli amp e a6 AE esa 7 Hd Build Debug A Find in Files Find in Files 2 Messages Command La Ln 1 Col 1 Figure 15 Z8 Encore Integrated Development Environment Window UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual For a table of all the shortcuts used in the Z8 Enco
370. 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 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 syntax can take one of the following forms new project pathN name target exe lib lt cpu gt NOREPLACE new project pathN name target project type lt exe lib gt cpu NOREPLACE where e 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 e target must match that of the IDE that is the Z8 Encore IDE can only create Z8 Encore based projects UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual lt exe lib gt The type parameter 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 canbe Standard or Assembly Only Stand
371. menu to save all open files and the currently loaded project Print Select Print from the File menu to print the active file UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi 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 the following figure main c is in Print Preview mode test ZDS II ZB Encore Family main c OB Next Page F Two Page Zoom In C Program Files SILOGI ZDSI DsEncore 411 05 amples DSF MC IS SSF MC 16 M main c Copt ient L1 Tues ine AM plants Reserv 3 Phee arios BLOC hbtor Denm Augue t 4th 2005 This code operates the basic PLLwith camensatlon This dew can run In speed control or torque control nede Bv sett ina Loon select Loop select O for torque current loop lom select 1 for Deed loo e Pot et set current or m ad comma depending on she mda Joni Icat lon pot lubtor LEDNDI ZO Sav phase Ne 4 poles d EF test peak Bad EF peek voltage line to line 4 AR Period Eod EF per jod ooa zec IE Pera DPI N22 0 0410 virad zec per phase peak value z Barat ina off of 34 sul BF and vow Div der Is and with OON fH Iter capacit
372. meter Passing drop down list box 64 Paste button 17 PC definition 311 Place Const Variables in ROM check box 73 Place Target File In area 99 Place Target File in Project Directory check box 98 Placing breakpoints 327 POLL mode 335 Ports area 79 pow function 345 372 Power functions 345 pragma alias 440 pragma asm 143 pragma bss 442 pragma cpu 441 pragma globalcopy 441 pragma globalcse 441 pragma globaldeadvar 441 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ pragma globalfold 441 pragma intrinsics 441 pragma jumpopt 442 pragma localcopy 442 pragma localcse 442 pragma localfold 442 pragma localopt 442 pragma noalias 440 pragma noglobalcopy 441 pragma noglobalcse 441 pragma noglobaldeadvar 441 pragma noglobalfold 441 pragma nointrinsics 441 pragma nojumpopt 442 pragma nolocalcopy 442 pragma nolocalcse 442 pragma nolocalfold 442 pragma nolocalopt 442 pragma noopt 442 pragma nooptlink 443 pragma nopeephole 443 pragma nopromote 443 pragma nosdiopt 443 pragma nostkck 443 pragma nostrict 444 pragma optlink 442 pragma optsize 443 pragma optspeed 443 pragma peephole 443 pragma promote 443 pragma sdiopt 443 pragma stkck 443 pragma strict 443 pragma using 440 PRAM 90 146 PRAMSEG 146 PRAMSEG segment 181 Predefined macros 149 Predefined segments 212 Preprocessing predefined macros 149 Preprocessor Definitions field 68 Index Pre
373. 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 Z8 Encore family member For more information about address spaces see Address Spaces on page 211 UMO13033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual Groups A group is a collection of logical address spaces They are typically used for convenience of locating a set of address spaces 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 211 for more information about using predefined segments de
374. n Edit Menu The Edit menu provides access to basic editing text search and breakpoint and bookmark manipulation features The following options are available Undo on page 48 e Redo on page 48 Cut on page 48 Copy on page 48 Paste on page 48 e Delete on page 48 Select AII on page 48 Show Whitespaces on page 48 Find on page 48 Find Again on page 49 e Find in Files on page 49 Replace on page 50 Go to Line on page 51 Manage Breakpoints on page 52 Toggle Bookmark on page 53 e Next Bookmark on page 53 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 48 Previous Bookmark on page 53 Remove All Bookmarks on page 53 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 active 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
375. n preceding the number Underscores _ can be inserted between hexadecimal digits to improve readability but only when the prefix 1s used instead of the H suffix For example ABCDEFFFH hexadecimal SABCDEFFF hexadecimal OFFFFh negative hexadecimal SABCD EFFF hexadecimal number with underscore ADCOD H NOT a hexadecimal number but a name underscores not allowed with the H suffix 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 224 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 preceding the number Underscores can be inserted between octal digits to improve readability For example 12340 octal number 12340 negative octal number 1 2340 octa
376. n function 351 389 strstr function 351 389 strtod function 348 390 strtok function 351 391 strtol function 348 392 STRUCT directive 244 Structured assembly 248 directives 249 inputs 250 processing 254 Structures in assembly 243 SUBTITLE directive 239 subtract 293 Symbols window 324 Symbols Window button 28 Symbols public 281 Syntax Coloring dialog box 125 System requirements xvi T Tab Size field 124 TAG directive 245 tan function 344 393 Tangent calculating 393 tanh function 344 393 Index Target area 97 Target Copy or Move dialog box 99 target copy script file command 431 target create script file command 432 Target File button 99 target get script file command 432 target help script file command 432 Target list box 42 target list script file command 432 target options script file command 433 target save script file command 433 434 target set script file command 433 Target selecting 96 TCP Port field 100 TDI function 174 Technical service xx Technical support xx text segment 212 Tile the files 128 TIME _ 149 TITLE directive 239 tolower function 340 393 Toolbars 16 Bookmarks 22 Build 18 Command Processor 22 Debug 23 Debug Windows 27 311 File 16 Find 21 Toolbars tab 119 Tools menu 110 Calculate File Checksum 117 Customize 119 Firmware Upgrade 118 Flash Loader 110 Options 122 Show CRC 119 TOP OF command 280 TOP OF operator 293 toupper function 340 394 UM013033 0508 Zil
377. n page 216 Comment Line on page 216 e Label Field on page 216 Instruction on page 217 Directive on page 217 Case Sensitivity on page 217 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 It can be defined by an EQU directive using the following syntax label EQU expression See EQU on page 236 for more information on this type of label definition NOTE Any instruction followed by a colon is treated as a label UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual o iH JE Sa A a 8 lj f y f Z I1 LJ LJ J Roa YH 21 T Any instruction not followed by a colon is treated as an instruction even if it starts in the first column 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 charac
378. n page 317 The following is the syntax 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 VALUE AA STARTADDRESS 1000 ENDADDRESS 2FFE UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual 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 from the current location and stops at the address associated with the given symbol assuming the given symbol is valid and available If the symbol is not found the command has no effect This version of the go command can only be used during a debug session The following are examples go go myfunc list bp The 1ist 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
379. n segment 212 _ ZDATE _ 150 ZILOG _ 150 Align keyword 144 _At keyword 141 placement of a variable 144 placement of consecutive variables 144 _DEBUG 151 far heapbot 186 far heaptop 187 far stack 186 len farbss 186 len fardata 186 len nearbss 186 len neardata 186 len pramseg 186 low far romdata 186 low farbss 186 low fardata 186 low near romdata 186 low nearbss 186 low neardata 186 low pram romdata 186 low pramseg 186 monitor pragma 141 near heapbot 186 near heaptop 187 near stack 186 VECTORS nnn segment 181 or 293 not 294 Index A Abnormal termination 352 abort function 349 352 abs function 349 352 Absolute segments 213 214 234 definition 211 276 locating 282 Absolute value computing 352 359 366 acos function 344 353 Activate Breakpoints check box 127 Add button 98 add file script file command 413 Add Files to Project dialog box 7 54 55 Add Project Configuration dialog box 105 Adding breakpoints 327 Adding files to a project 6 54 Additional Directives check box 82 Additional Linker Directives dialog box 82 Additional Object Library Modules field 85 Address button 95 Address Hex field 114 Address range syntax 91 Address spaces allocation order 286 definition 275 grouping 282 linking sequence 284 locating 282 moving 278 renaming 278 setting maximum size 283 setting ranges 91 285 Address Spaces page 89 Addresses finding 316 viewing 316 Advanced page 12 69 Alias checking enabl
380. n the Disassembly window For more information on breakpoints see Using Breakpoints on page 326 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 326 Remove All Breakpoints Button The Remove All Breakpoints button deletes all breakpoints in the currently loaded project To deactivate breakpoints in your program use the Disable All Breakpoints button Find Toolbar The Find toolbar provides access to text search functions with the following controls Find in Files Button on page 21 Find Field on page 21 la Figure 18 Find Toolbar Find in Files Button This button opens the Find in Files dialog box allowing you to search for text in multiple files 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Command Processor Toolbar The Command Processor toolbar allows you to execute IDE and debugger commands with the following controls
381. n 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 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 UM013033 0508 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 MAX and so on Minimum represented positive floating point numbers C Standard Library DBL MIN EXP DBL MIN 10 EXP 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 FLT ROUND LDBL DIG LDBL MANT DIG LDBL MAX LDBL MAX EXP Zilog Developer Studio ll Z8 Encore User Manual ZILOQ an 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 i
382. n 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 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 FLT MIN and so on Radix of exponent representation Rounding mode for floating point addition indeterminable 0 toward zero 1 to nearest 2 toward positive infinity 3 toward negative infinity 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 LDBL MAX 10 EXP Maximum integer such that 10 raised to that power approximates a LDBL MIN UM01303
383. n the rom address space when desired rather than use that deprecated option see Place Const Variables in ROM on page 73 UM013033 0508 Using the ANSI C Compiler struct Zilog Developer Studio ll Z8 Encore User Manual Space Specifier on Structure and Union Members Ignored The space specifier for a structure or union takes precedence over any space specifier declared for an individual member of the structure When the space specifier of a member does not match the space specifier of its structure or union the space specifier of the mem ber is ignored For example near char num Warning near space specifier is ignored near char ptr Correct ptr points to a char in near memory far ptr itself is stored in the memory space of structure far mystruct All of mystruct is allocated in far memory Memory Models The Z8 Encore C Compiler provides two memory models e Small Memory Model on page 137 Large Memory Model on page 138 Each of these models directs the compiler where to place data in memory by default to maximize the efficiency of an application This feature allows you to control where global and static data are allocated as well as where frames containing local and parameter data are stored Small Memory Model In the small memory model global variables are allocated in the RData address space The address of these variables is 8 bits The locals and parameters
384. nally vis ible exceptions 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 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 The following sections list and briefly describe the mathematics functions e Trigonometric on page 344 e Hyperbolic on page 344 Exponential and Logarithmic on page 344 Power on page 345 Nearest Integer on page 345 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual zilogi 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 do
385. nction call and return discipline Type jmp buf An array type suitable for holding the information needed to restore a calling environment Functions int setjmp 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 A function can be called with a variable number of arguments of varying types The 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 va_end function 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zilog 346 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
386. nction 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 tinclude lt stdlib h gt void bsearch void key void base size t nmemb size t size int compar void 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 void x void y int main void int result result bsearch amp k list 4 sizeof int compare int compare void x 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 void x 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual S Synopsis finclude 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 Compute
387. nction that writes a value to NVDS memory at the specified address Synopsis include lt ez8 h gt reentrant int WRITE NVDS char value char address reentrant int nvds write char value char address Returns If successful the function returns zero otherwise it returns a nonzero value Example include lt eZ8 h gt char x void main INIT FLASH _DEFFREQ Target clock frequency WRITE NVDS x 0x10 write x to NVDS at address 0x10 x READ NVDS 0x10 read NVDS at address 0x10 _DEFFREQ is automatically set from the IDE based on the clock frequency setting in the Configure Target dialog box WRITE NVDS GET STATUS The WRITE NVDS GET STATUS function is a Zilog function that writes a value to NVDS memory at the specified address and gets the status UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Synopsis include lt ez8 h gt char reentrant WRITE NVDS GET STATUS char value char addr char reentrant nvds write get status char value char addr Returns The function returns the status of NVDS write as per the device specification Example include lt eZ8 h gt char x wst atus rstatus unsigned int val void main wstatus writ val R x va rstatus WRITE NVDS GET STATUS x 0x10 e x to NVDS at address 0x10 and get the status EAD NVDS GET STATUS 0x1
388. nctions abort abs atan2 atof calloc ceil exp fabs frexp getchar iscntrl isdigit ispunct isspace Idexp Idiv malloc memchr memset modf UM013033 0508 bytes in the buffer Finds length of string acos asin atan atoi atol bsearch cos cosh div floor fmod free gets isalnum isalpha isgraph islower isprint isupper isxdigit labs log log10 longjmp memcmp memcpy memmove pow printf putchar C Standard Library Zilog Developer Studio ll Z8 Encore User Manual puts qsort rand realloc scanf setjmp sin sinh sprintf sqrt srand sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr strtod strtok strtol tan tanh tolower toupper va_arg va_end va_start vprintf vsprintf abort Causes an abnormal termination of the program Synopsis finclude lt stdlib h gt void abort void TIP The abort function is usually called by the assert macro If you use asserts in your application you might want to permanently place a breakpoint in abort to sim plify debugging when asserts fail abs Computes the absolute value of an integer 3 If the result cannot be represented the behav ior is undefined Synopsis include lt stdlib h gt int abs int j Returns The absolute value Example int I 5632 int j j abs 1 UM013033 0508 C Standard Library acos asin atan Zilog Developer Studio ll Z8 Encore User Manual i ran ILU U EY M amu
389. nctions useful for manipulating character arrays and other objects treated as character 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zilog ase Macro NULL Expands to a null pointer constant Functions The string handling functions are listed and briefly described in the following sections Copying on page 350 e Concatenation on page 350 Comparison on page 350 e Search on page 351 Miscellaneous on page 351 Copying void memcpy void s1 void s2 size t n Copies a specified number of characters from one buffer to another void memmove void s1 void s2 size t n Moves a specified number of characters from one buffer to another char strcpy char s1 char s2 Copies one string to another char strncpy char s1 char s2 size t n Copies n characters of one string to another Concatenation char strcat char s1 char s2 Appends a string char strncat char s1 char s2 size t n Appends n characters of string Comparison The sign of the value returned by the comparison functions is determined by the
390. nd line options Table 10 Librarian Command Line Options Option Name Description file Takes options from a file This option can be used only on the command line not inside a file help Displays the librarian help screen Libfile Specifies the library to create modify or extract from This must precede any commands to modify or read from a library List Instructs the librarian to list the contents of the library Note The command is 1ist or LIST not list noquiet Displays the title information nowarn Suppresses warning messages t objectfile Instructs the librarian to add objectfile to the library If object file is already there generates a message and ignores the command t tobjectfile Instructs the librarian to remove objectfile from the library if necessary then to add the new version objectfile Instructs the librarian to mark objectfile for removal from the library Removal does not actually occur until a rebuild command objectfile Instructs the librarian to extract objectfile from the library 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 Rebuild Instructs the librarian to rebuild the library removing any object files marked for removal and otherwise compacting the library version Displays the version number of the librarian warn D
391. nd spanning multiple source lines The dollar sign is a delimiter that marks the line as the end of the comment block CPU Defines to the assembler which member of the Z8 Encore family is targeted From this directive the assembler can determine which instructions are legal as well as the locations of the interrupt vectors within the CODE space NOTE The CPU directive is used to determine the physical location of the interrupt vectors Syntax cpu definition gt CPU cpu name Example CPU Z8F6423 Data Directives Data directives allow you to reserve space for specified types of data The following data directives are available e BFRACT and UBFRACT Declaration Types on page 229 e FRACT and UFRACT Declaration Types on page 230 e BLKB Declaration Type on page 230 e BLKL Declaration Type on page 230 e BLKW Declaration Type on page 230 DB Declaration Type on page 231 e DD Declaration Type on page 231 DF Declaration Type on page 231 DL Declaration Type on page 232 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zzilogi DW Declaration Type on page 232 e DW24 Declaration Type on page 232 Syntax data directive gt type value list type gt BFRACT gt BLKB gt BLKL LKW Hj U Uu E W24 RACT gt UBFRACT gt UFRACT lt value_list gt gt lt valu
392. nd the FAQ ntm1 file in the following directory ZILOGINSTALLWXZDSII 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 Z8Encore ZNEO eZ80Acclaim Crimzon or Z8GP version is the ZDS II version number For example version might be 4 11 0 or 50 0 Troubleshooting section Zilog Standard Library Notes and Tips on page 331 UM013033 0508 Introduction Zilog Developer Studio ll Z8 Encore User Manual Getting Started This section provides a tutorial of the developer s environment so you can be working with the ZDS II graphical user interface in a short time The following topics are covered Installing ZDS II on page 1 Developer s Environment Tutorial on page 1 INSTALLING ZDS II There are two ways to install ZDS II FromaCD a Insert the CD in your CD ROM drive b Follow the setup instructions on your screen The installer displays a default location for ZDS II You can change the location if you want to e Fromwww zilog com Navigate to http www zilog com software zds2 asp v p Click on the link for the version that you want to download Click Download a 9 In the File Download dialog box click Save Navigate to where you want to save ZDS II Click Save Double click the executable fi
393. ned NULL space If you copy the segment to the NULL space the region is still allocated but no data is writ ten for it COPY myseg NULL UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual 281 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 symbol name gt expression symbol name is the name assigned to the public symbol expression is the value assigned to the public symbol Example DEFINE copy size copy top of data seg copy base of data seg NOTE Refer to Linker Expressions on page 288 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 File Extension IEEE 695 format OMF695 lod Intel 32 bit format INTEL32 hex The default setting is IEEE 695 Syntax FORMAT type Example FORMAT OMF695 INTEL32 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual GROUP The GROUP command provides a method of collecting multiple address
394. ng low far romdata Base of the rom copy of far data segment after linking low pramseg Base of pramseg segment after linking len pramseg Length of pramseg segment after linking low pram romdata Base of the rom copy of pramseg 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 EData near stack Top of stack for small model is set as highest address of RData far heapbot Base of heap for large model is set as highest allocated EData address near heapbot UM013033 0508 Base of heap for small model is set as highest allocated RData address Using the ANSI C Compiler 186 Zilog Developer Studio ll Z8 Encore User Manual y o iH JE Sa fl a 8 7 I f y A i 1 A J YY IGN A 1 8 7 Table 6 Linker Symbols Continued Symbol Description far heaptop Top of heap for large model is set as highest address of EData near heaptop Top of heap for small model is set as highest address of RData Sample Linker Command File The sample default linker command file for a project using the large dynamic compilation model is discussed here as a good example of the contents of a linker command file in practice and how th
395. ng Registers on page 159 Function Naming Convention Assembly function names must be preceded with 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 generated assembly by the compiler Argument Locations The assembly function must assign the location of the arguments following the C calling conventions as described in Calling Conventions on page 151 For example if you are using the following C prototype void myfunc short arga long argb char argc short argd The location of the arguments must be as follows for a static frame function arga 0 myfunc argb 1 myfunc argc 2 myfunc argd _3 myfunc The location of the arguments must be as follows for a static frame function with register parameter passing arga R8 R9 argb R10 R11 R12 R13 argc 0 myfunc argd 1 myfunc For a dynamic frame function the arguments will be on stack Their offsets from the stack pointer at the entry point of the assembly function are as follows arga 2 argb 4 argc 8 argd 9 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 159 For a dynamic frame function with register parameter passing some of the arguments will be in registers and some on stack Their registers offsets from the stack pointer at the entry point of the assembly function are as fol
396. ng pin 2 of the debug header low 3 Configures the device using the settings in the Configure Target dialog box 4 Downloads the program 5 Issues a software reset through the debug header serial interface UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 6 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If it is a C project ZDS II resets to the main function if it is found If ZDS II is already in Debug mode when the Download Code button is clicked the fol lowing process is executed 1 Resets the device using a software reset 2 Downloads the program You might need to reset the device before execution because the program counter might have been changed after the download Reset Button Click the Reset button in the Build or Debug toolbar to reset the program counter to the beginning of the program If ZDS II is not in Debug mode the Reset button starts a debug session using the follow ing process 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Downloads the program 5 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If itis a C project ZDS II resets to the main function if it is found If ZDS II is already in Debug mode the Reset bu
397. ng 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 char nptr char endptr int base Returns The converted value or zero if an inappropriate character occurs 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 amp ptr 10 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i ran ILU U V M M d tan The tangent of x measured in radians A large magnitude argument can yield a result with little or no significance Synopsis finclude math h double tan double x Returns The tangent value Example double x 2 22 double y y tan x tanh Computes the hyperbolic tangent of x Synopsis include lt math h gt double tanh double 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore
398. no effect NOTE 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 the Project Workspace window see Project Workspace Window on page 29 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 Linker Objects and Libraries Page The options in the Objects and Libraries page are described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi lil Project Settings Configuration Debug m Sb General Objects a Eh Assembler E Ic Additional Object Library Modules Sh Code Generation ES 3 Listing Files C Startup Module SS Preprocessor Standard 3 Advanced C Included In Project Eh Deprecated 1 5s ZSL Fis Linker Use Default Libraries SS Commands v C Runtime Library Floating Point Library Real E Sil Address Spaces i R Warnings Zilog Standard Library Peripheral Support Sak Output Eh Debugger Note Cancel Help Figure 61 Objects and Libraries Page of the Project Settings Dialog Box Additional Object Library Modules Click on the Browse button m next to the Additional Object Library Modules field to navigate to the
399. no unnec essary code size penalty when you select the 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 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 70 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 point operations In that case selecting Dummy keeps your code size from bloating unnece
400. not the functions that make the calls that must be marked as reentrant The advantage of static frames is that because the compiler knows the absolute address of each function parameter it can generate more compact code to access parameters than in dynamic frames where they must be accessed by offsetting from the stack pointer For the Z8 Encore instruction set architecture this code size savings is substantial The savings comes primarily not from using less space for frames but from using less code to access data in the frames Thus it is primarily a savings in code space not in data space It could actually require more data space although to mitigate this the Z8 Encore linker uses call graph techniques to overlay some function frames that cannot be simultaneously active The disadvantages of static frames are that they do not support two features of the C lan guage recursion and making calls through function pointers To allow a broader range of applications to get the benefits of using static frames the Z8 Encore compiler provides the reentrant keyword as another C language extension Dynamic Frames The most familiar type of call frames used exclusively by most desktop oriented compil ers are dynamic frames when a function is called space is dynamically allocated on the stack to hold its return address function parameters and local variables Dynamic frames hold arguments and local variables on the run time stack allow rec
401. ns 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 Example char buf buf char malloc 40 sizeof char if buf NULL success else fail memchr Locates the first occurrence of c converted to an unsigned char in the initial n charac ters of the object pointed to by s Synopsis finclude lt string h gt void memchr 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zilog 370 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 include lt string h gt int memcmp void sl 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 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 include lt string h gt void memcpy void sl void
402. nt val Not OK to skip clearing uninitialized near data Uninitialized global in near memory UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual ZILOG a int val OK to skip clearing uninitialized near data Uninitialized global in far memory For the small model int val Not OK to skip clearing uninitialized near data Uninitialized global in near memory far int val OK to skip clearing uninitialized near data Uninitialized global in far memory Alternatively if your application does not assume that the near uninitialized global or static variables are initialized to zero by the C startup module the startup code does not have to perform this function This can be achieved by adding the following code just before segment startup CLRRRAM SET FALS T e Ifyou do not have any initialized global or static variables in near memory the startup code does not have to set the initialized global and static near variables to their initial value from rom For example for the large model near int val 20 Not OK to skip initializing near data Initialized global in near memory int val 20 OK to skip initializing near data Initialized global in far memory For the small model int val 20 Not OK to skip initializing near data Initialized global in near memory far int val 20 OK to
403. o EOF if an input failure occurs before any conversion Otherwise the scanf 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Zilogi 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 1oat with three decimal place precision scanf 2d S f amp varl amp 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 correspon
404. o file 115 318 viewing addresses 316 Memory Window button 28 memset function 351 371 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZIlog ass Menu bar 37 Menus Build 102 Edit 47 File 38 Help 128 Project 54 right click 34 shortcuts 129 Tools 110 View 53 Window 128 Messages Output window 37 Miscellaneous functions 349 _ MODEL _ 150 modf function 344 371 Modules defining 278 definition 275 _monitor pragma 141 Moving characters 371 N Name button 95 Name for New Target field 99 NDEBUG 151 NDEBUG macro 338 near storage specifier 134 NEAR BSS segment 181 near_bss segment 212 NEAR DATA segment 181 near_data segment 212 NEAR TEXT segment 181 near_txt segment 212 Nearest integer functions 345 New button 17 New project adding files 6 54 building 13 configuring 8 Index creating 2 39 deleting files from 39 saving 14 setting up 8 New Project dialog box 2 4 39 40 New Project Wizard dialog box 4 5 6 41 42 43 new project script file command 422 NEW AU AT TYPE CHANGE 149 NEWPAGE directive 237 Next Bookmark button 23 NODEBUG command 284 NOLIST directive 237 NOMAP command 282 284 Non Volatile Data Storage 90 314 NOWARN command 284 ntext 326 NULL macro 346 348 350 NULL using 278 279 NULL terminated ASCII viewing 322 Numbers binary 223 decimal 223 hexadecimal 223 octal 224 NVDS 90 314 O obj file extension 214 215 Object code file 215
405. o 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 must 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i IIAN ILU U EY M 202 I 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 158 Cannot subtract
406. ode generation are shown at the bottom of the dialog box Limit Optimizations for Easier Debugging Memory Model and Frames For convenience three of the most commonly used combinations of these options can be obtained by clicking one of the radio buttons Safest Small and Debuggable or Smallest Possible When one of these radio button settings 1s selected the fundamental options in the bottom of the dialog box are updated to show their new values but they are not available for individual editing To edit the fundamental options individu ally select the User Defined button You can then update the fundamental settings to any combination you like Safest The Safest configuration sets the following values for the individual options the Limit Optimizations for Easier Debugging check box is selected the large memory model is used if available see Memory Model on page 64 the frames are dynamic This is the safest possible configuration in that using the large model avoids possible problems with running out of data space in the small model and using dynamic frames avoids UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual potential problems with static frames due to the use of recursion or function pointers Also because the optimizations are limited you can proceed to debug your application with ease However this configuration definitely produces larger code than othe
407. ode or data cannot be placed within the ranges a range error is generated Linker Warnings Page The options in the Warnings page are described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog lil Project Settings Configuration Debug m Sak General Warning ile Assembler i El G Treat All Warnings as Fatal Code Generation V Treat Undefined Symbols as Fatal Listing Files P a Y wan on Segment Overlap reprocessor Sil Advanced Eh Deprecated 5s ZSL El Linker SS Commands Sil Objects and Libraries 3 Address Spaces gt Sak Output Eh Debugger Note NOTE UMO13033 0508 Cancel Help Figure 63 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 errors regardless of the state of the Show Warnings check box in the General page see Show Warnings on page 58 Treat Undefined Symbols as Fatal When selected this check box causes the linker to treat undefined external symbol warnings as
408. odel with debug information crtls lib C run time library for large static model no debug information crtlsd lib C run time library for large static model with debug information ertsd lib C run time library for small dynamic model no debug information ertsdd lib C run time library for small dynamic model with debug information crtss lib C run time library for small static model no debug information crtssd lib C run time library for small static model with debug information fpld lib Floating point library for large dynamic model no debug information fpldd lib Floating point library for large dynamic model with debug information fpls lib Floating point library for large static model no debug information fplsd lib Floating point library for large static model with debug information fpsd lib Floating point library for small dynamic model no debug information fpsdd lib Floating point library for small dynamic model with debug information fpss lib Floating point library for small static model no debug information fpssd lib Floating point library for small static model with debug information csiold lib C serial IO library for large dynamic model no debug information csioldd lib C serial IO library for large dynamic model with debug information csiols lib C serial IO library for large static model no debug information csiolsd lib C serial IO library for large static model with debug information csiosd lib C serial IO library fo
409. og Developer Studio ll Z8 Encore User Manual HIGH and LOW Operators The HIGH and LOW operators can be used to extract specific bytes from an integer expression The LOW operator extracts the byte starting at bit 0 of the expression while the HIGH operator extracts the byte starting at bit 8 of the expression HIGH and LOW can also be used to extract portions of a floating point value For example LOW X 8 least significant bits of X HIGH X 8 most significant bits of X NOTE The following is the syntax of these operators lt operator gt lt expression gt For example HIGH lt expression gt HIGH and Low takes the entire expression to the right of it as its operand This means that an expression such as HIGH PAOUT LOW PAOUT amp 0 is parsed as in effect HIGH PAOUT LOW PAOUT f0 If HIGH is only intended to operate on PAOUT in this example its operation must be restricted with parentheses For example HIGH PAOUT LOW PAOUT amp 0 HIGH16 and LOW16 Operators The HIGH16 and LOW16 operators can be used to extract specific 16 bit words from an integer expression The LOW16 operator extracts the word starting at bit 0 of the expres sion the HIGH16 operator extracts the word starting at bit 16 of the expression HIGH16 and LOW16 can also be used to extract portions of a floating point value For example LOW16 X 16 least significant bits of X HIGH16
410. og Developer Studio ll Z8 Encore User Manual ZILOQ ar Treat All Warnings as Fatal check box 92 Treat Undefined Symbols as Fatal check box 92 Trigonometric functions 344 True macro 339 Tutorials Command Processor 408 developer s environment 1 Type sizes 148 U UARTs changing default settings 335 INTERRUPT mode 335 POLL mode 335 switching 334 Uarts area 79 UBFRACT directive 229 UCHAR_MAX 342 UFRACT directive 230 UINT_MAX 342 ULONG MAX 342 Underscore 162 UNION directive 247 Unions in assembly 243 UNRESOLVED IS FATAL command 287 UNSIGNED CHARS _ 150 Up button 49 USB Smart Cable requirements xvii Use Default Libraries area 87 Use Existing button 83 Use Page Erase Before Flashing check box 42 97 Use Register Variables drop down list box 69 Use Selected Target button 99 Use Standard Startup Linker Commands check box 87 User Defined button 63 User Defined configuration 63 Index User field 68 User defined segments 213 USHRT_MAX 342 V va arg function 346 394 va end function 346 395 va list 345 va start function 346 396 Values return 156 159 VAR directive 239 Variable arguments 345 _151 VECTOR directive 241 __vectors_nnn segment 212 Verify button 113 Verify Download button 25 Verify File Downloads Read After Write check box 127 Verify File Downloads Upon Completion check box 127 View menu 53 Debug Windows 53 Output 54 Status Bar 54 Workspace 54 vprintf function 347 397 vsprintf function
411. oject Settings Assembler Includes option assembler include page 424 page Defines option assembler define Generate Listing Files 1st option assembler list Expand Macros option assembler listmac Page Width option assembler pagewidth Page Length option assembler pagelen Jump Optimization option assembler sdiopt Project Settings Code Safest option compiler codegen page 425 Generation page Small and Debuggable option compiler codegen Smallest Possible option compiler codegen User Defined option compiler codegen Limit Optimizations for Easier option compiler reduceopt Debugging Memory Model option compiler model Frames option compiler optlink Parameter Passing option compiler fastcall UM013033 0508 Using the Command Processor Zilog Developer Studio Il Z8 Encore User Manual i ZILOQd l4 V Y Table 11 Script File Commands Continued ZDS II Menus ZDS II Commands Dialog Box Options Script File Commands Location Project Settings Listing Generate C Listing Files lis option compiler list page 425 Files page With Include Files option compiler listinc Generate Assembly Source Code option compiler keepasm Generate Assembly Listing Files option compiler keeplst Ist Project Settings Preprocessor Definitions option compiler define page 425 Preprocessor page Standard Include Path option compiler stdinc User Include Path option compiler usrinc Project Settings Advanced Use Regis
412. ol help command displays all debugtool commands The following is the syntax of the debugtool help command debugtool help UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual ZIt Og 417 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 COMMTYPE 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 debugtool save NAME lt Debug Tool Name gt saves the given debug tool For example debugtool save NAME USBSmartCable debugtool set 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 UM013033 0508 debugtool set lt data item new value gt sets data item to new value for the active debug tool Use debugtool setup to view available data items and current values For example debugtool set ipAddress 123 456 7 89 debugtool set debug tool name gt activates the debug tool w
413. om 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 Running ZDS II from the Command Line on page 399 To invoke the linker through the ZDS II Command Processor see Using the Command Processor on page 408 UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual LINKER COMMANDS The following sections describe the commands of a linker command file lt outputfile gt lt module list gt on page 278 CHANGE on page 278 COPY on page 279 DEBUG on page 281 DEFINE on page 281 FORMAT on page 281 GROUP on page 282 HEADING on page 282 LOCATE on page 282 MAP on page 282 MAXHEXLEN on page 283 MAXLENGTH on page 283 NODEBUG on page 284 NOMAP on page 284 NOWARN on page 284 ORDER on page 284 RANGE on page 285 SEARCHPATH on page 285 SEQUENCE on page 286 SORT on page 286 SPLITTABLE on page 286 UNRESOLVED IS FATAL on page 287 WARN on page 287 WARNING IS FATAL on page 288 WARNOVERLAP on page 288 NOTE Only the lt outputfile gt lt module list and the FORMAT commands are required All commands and operators are not case sensitive UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual i I PES PN Z
414. on The status can be STOP STEP or RUN The STOP mode indicates that your program is not executing The STEP mode indicates that a Step operation using the Step Into Step Over or Step Out command is in progress The RUN mode indicates that the program is executing after a Go command has been issued In RUN mode the following debug operations are avail able Reset Stop Debugging and Break UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual NOTE When the program is in RUN mode disabling a breakpoint temporarily stops and resumes program execution If a breakpoint is reached before it is disabled program execution does not resume When the program is in RUN mode enabling the breakpoint also temporarily stops and resumes program execution but if the program reaches a breakpoint after you enable it the program stops or breaks You must press the Go button again to continue the program execution See Using Breakpoints on page 326 for more information about breakpoints View read memory Step Into Step Over Step Out and Go are disabled in RUN mode NOTE The status bar is either a box displayed in the upper right corner under the title bar or a horizontal bar under the buttons depending on your screen resolution 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
415. on has some external definitions for example clock speed that are used to calculate the baud rate for the UARTS I DO NOT USE THE STANDARD BOOT UP MODULE BUT HAVE MANU ALLY INCLUDED ZILOG STANDARD LIBRARIES WHEN I LINK MY CODE WITH THE LIBRARY WHY DO GET AN UNRESOLVED SYMBOLS ERROR Include zsldevinit asm in your project The open periphdevice function has some external definitions for example clock speed that are used to calculate the baud rate for the UARTS WHERE CAN I GET THE ZSL SOURCE FILES The source files for ZSL can be found under the following directory ZILOGINSTALLYZDS11 product versionNsrc where e ZILOGINSTALL is the ZDS Il installation directory For example the default installation directory is C Program Files ZiLOG product is the specific Zilog product For example product can be Z8Encore ZNEO eZ80Acclaim Crimzon or Z8GP version 1s the ZDS II version number For example version might be 4 11 0 or 5 0 0 I NEED TO CHANGE THE ZSL SOURCE CODE HOW CAN GENERATE A NEW LIBRARY WITH THESE CHANGES INCLUDED The installation contains the batch file buildallzsl bat under the following directory ZILOGINSTALLYZDS11 product versionNsrc where e ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files ZiLoG productis the specific Zilog product For example product can be 28Encore ZNEO eZ80Acclaim Crimzon
416. on page 19 Download Code Button on page 19 Reset Button on page 25 Go Button on page 20 e Insert Remove Breakpoint Button on page 21 Enable Disable Breakpoint Button on page 21 Remove AII Breakpoints Button on page 21 Debug Es Xt El MM dm Figure 17 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 103 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual o iH AE Sa PP BS ll f 3 i rr J LA AS MA 1 9 Stop Build Button The Stop Build button stops a build in progress Connect to Target Button The Connect to Target button starts a debug session using the following process 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Configures and executes the debugger options selected in the D
417. on prototype is as shown in the preceding example void x int compare 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 iz srand 1001 i rand realloc UM013033 0508 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 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 Synopsis include 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 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Example char buf buf char malloc 40 sizeof char buf char realloc buf 80 sizeof char if buf NULL success else fail
418. onfigurations set config page 430 delete config Debug Stop Debugging quit page 429 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual o A lj Z Table 11 Script File Commands Continued dn ZDS II Commands Dialog Box Options Script File Commands Location Reset reset page 430 Go go page 421 Break stop page 431 Step Into stepin page 431 Step Over step page 431 Step Out stepout page 431 Tools Flash Loader page 434 Calculate File Checksum checksum page 415 Show CRC crc page 415 SAMPLE COMMAND SCRIPT FILE A script file is a text based file that contains a collection of commands The file can be created with any editor that can save or export files in a text based format Each command must be listed on its own line Anything following a semicolon is considered a com ment The following is a sample command script file change to correct default directory cd m Z8Encore 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 UM013033 0508 Using the Command Processor 412 Zilog Developer Studio ll
419. ong DR none UM013033 0508 Compatibility Issues Z Table 19 Z8 Encore Directive Compatibility Continued Zilog Developer Studio ll Z8 Encore User Manual 438 Z8 Encore Assembler Compatible With DS block DW word word int DW24 word24 trio DW24 ELIF ELIF ELSEIF ELSEIF SELSEIF Selseif ELSE ELSE SELSE Selse END end ENDIF endif ENDIF ENDC SENDIF Sendif ENDMAC endm ENDMACRO ENDMACRO ENDMAC ENDM ENDM MAC MACEND ENDSTRUCT ENDSTRUCT ERROR emsg EQU equ EQU EQUAL equal EVAL EVAL FCALL FCALL FILE file FRAME FRAME GREG GREGISTER IF if IF IFN IFNZ COND IFTRUE IFNFALSI SIF S if IFTRUE INCLUDE include copy LIST list on or off LIST ACCNTR none ACEXI none ACLIST none ACNOTE mmsg ACRO macro MACRO LIST none OLIST none NEWBLOCK NEWBLOCK NEWPAGE page len width PAGE UM013033 0508 Compatibility Issues Zilog Developer Studio ll Z8 Encore User Manual Table 19 Z8 Encore Directive Compatibility Continued Z
420. ons 424 relational operators 221 reserved words 218 running from the command line 400 setup 59 syntax 264 warning messages 269 Assembler page 10 59 Assembly language adding null characters 220 argument location 158 arithmetic operators 221 automatic working register definitions 225 backslash 216 binary numbers 223 blank lines 216 Boolean operators 221 calling C functions from 159 calling from C 157 case sensitivity 217 character constants 224 character strings 220 comments 216 conditional 256 decimal numbers 223 decision structure 249 directive compatibility 268 437 directives 217 226 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ELLOU is embedding in C 164 expressions 220 floating point numbers 219 function names 158 hexadecimal numbers 223 instructions 217 labels 216 263 line continuation 216 line definition 216 line length 216 looping structures 249 macro expansion 60 numeric representation 219 octal numbers 224 operator precedence 224 operators 225 preserving registers 159 relational operators 221 reserved words 218 return values 156 159 source line 216 structure 216 structured 248 structured assembly directives 249 structured assembly inputs 250 structured assembly processing 254 structures 243 syntax 264 unions 243 assert macro 338 lt assert h gt header 338 atan function 344 353 atan2 function 344 354 atof function 348 354 atoi function 348 355 atol function 348 35
421. op 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 Save To File File Name By Address Range File Format Start Address Hex 00 C Text e Hex C Binary End Address Hex FF Figure 106 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 B 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 Ifthe file format is text select the number of bytes per line or enter a number in the Other field 8 Click OK to save the memory to the specified file UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOQ as Loading from a File 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 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 Load from File The Load from File dialog box is display
422. oper Studio was installed By default this would be C Program Files ZiLOG ZDSII_Z8Encore version where version might be 4 11 00r5 0 0 STANDARD HEADER FILES The following sections describe the standard header files Diagnostics lt assert h gt on page 338 e Character Handling lt ctype h gt on page 339 e Errors lt errno h gt on page 340 Floating Point lt float h gt on page 340 Limits lt limits h gt on page 342 e Mathematics lt math h gt on page 343 e Nonlocal Jumps lt setjmp h gt on page 345 Variable Arguments lt stdarg h gt on page 345 e Standard Definitions lt stddef h gt on page 346 Input Output lt stdio h gt on page 346 e General Utilities lt stdlib h gt on page 347 e String Handling lt string h gt on page 349 Diagnostics lt assert h gt The lt assert h gt header declares one macro and refers to another macro Macro void assert int expression The behavior of the assert macro depends on whether the NDEBUG macro has been defined or not On Debug builds those for which NDEBUG is not defined the assert macro puts diagnostics into programs When it is executed if expression is false that is evaluates 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 number the latter are respec
423. or De Pef erence 2V gu a7 SKa 9 37 C O ONE fe M23 1449 REC 1 7KHE Peq C S3 w ECCLE M minciude em be include main h amutat ten Lod up Table ro contable detemine which RM channels are turned on only tao at any ran Vims ined char Cantable s H I off A ox D oz 035 o 1E 0 16 ow Gen oo since WAH md NW amp L are opos ite polar itv the polar itv bits In RKTLI need to be fl Icod An the channel D i Chamel on this causes ANA and PAL on Separate phases vine sync ram unsigned char Canpol 5 T ff Inwerted version of Cav pol ian uns Igned char ncam pol e Ln 1 Col 1 Figure 42 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 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 applicatio
424. or Z8GP UM013033 0508 Zilog Standard Library Notes and Tips Zilog Developer Studio ll Z8 Encore User Manual version is the ZDS II version number For example version might be 4 11 0 or 500 Generate a new set of libraries by building the project using ZDS II and copy the library files generated under the project directory to the following directory ZILOGINSTALL ZDSII product version lib zilog Alternatively you can run the batch file buildallzsl bat to generate the libraries directly into the following directory ZILOGINSTALL ZDSII product version lib zilog Refer to the Zilog Standard Library API Reference Manual RM0038 for more details HOW CAN I USE STANDARD I O CALLS LIKE PRINTF AND GETCH The standard I O calls such as printf getch and putch are routed to UARTO by default You can route them to UARTI by setting the UARTI as the default device To do so open the uartcontrol h file and change the macro value for DEFAULT UART from UARTO to UARTI and rebuild the library The uartcontrol h file is in the following directory ZILOGINSTALLVZDSII product versionNincludeNzilog where e ZILOGINSTALL is the ZDS II installation directory For example the default installation directory is C Program Files MZiLOG productis the specific Zilog product For example product can be 28Encore ZNEO eZ80Acclaim Crimzon or Z8GP version is the ZDS II version number For example version mi
425. or layout problems UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 hex which is a backward compatible superset of the Intel Hex16 format IEEE 695 is the default format for debugging in ZDS II and the Intel hex format is useful for compatibility with some third party tools You can also select both check bo
426. ore User Manual Table 13 Assembler Options Continued Description or Corresponding Option in Project Option Name Settings Dialog Box Acceptable Values pagewidth Assembler page Page Width field integer quiet Toggles quiet assemble TRUE FALSE sdiopt Assembler page Jump Optimization check box TRUE FALSE Toggles Jump Optimization Compiler Options Table 14 Compiler Options Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values bfpack Advanced page Bit Field Packing field tight compatible codegen Code Generation page Safest Small and Debuggable Smallest safest Possible and User Defined buttons smalldebug smallest userdefined const Deprecated page Place Const Variables in ROM ROM RAM Selects where const variables are placed For example option compiler const RAM define Preprocessor page Preprocessor Definitions field string separate multiple defines with semicolons fastcall Code Generation page Parameter Passing drop down list box true false Select true for register parameter passing or false for memory parameter passing genprintf Advanced page Generate Printfs Inline check box TRUE FALSE keepasm Listing Files page Generate Assembly Source Code check box keeplst Listing Files page Generate Assembly Listing Files lst check TRUE FALSE box list Listing Files page Genera
427. ore User Manual ZILOQ 2 SEGMENT NEAR DATA ALIGN 2 STRVAR VAR FFH DB STRVAR SEGMENT TEXT L 0 DB FAILED DB 0 SEGMENT NEAR DATA ALIGN 2 STRVAR VAR L 0 fail str DB STRVAR SEGMENT TEXT L 1 DB PASSED DB 0 STRVAR VAR L 1 SEGMENT NEAR DATA ALIGN 2 pass str DB STRVAR Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zilog 241 VECTOR Initializes an interrupt or reset vector to a program address vector name gt specifies which vector is being selected Except for Z8 Encore MC or 16K XP parts which are covered in the succeeding tables vector name must be one of the following RESET P3AD WDT P2AD TRAP PIAD TIMER2 POAD TIMERI TIMER3 TIMERO UARTI RX UARTO RX UARTI TX UARTO TX DMA Dc C3 SPI C2 ADC Cl P7AD CO P6AD POTRAP primary oscillator fail trap for Z8F04A series PSAD WOTRAP watchdog oscillator fail trap for Z8F04A series P4AD For Z8 Encore MC Motor Control CPUs lt vector name gt must be one of the follow ing RESET SPI WDT 12C TRAP CO PWMTIMER PB PWMFAULT P7A P31 ADC P6A P2A CMP P5A PIA TIMERO P4A POA UARTO_RX POTRAP UARTO_TX WOTRAP UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zilog 242 For the Z8 Encore 16K XP CPUs lt vector name gt must be one of the following RESET P4AD WDT
428. ormal setting sets aside 1 byte the size of a char for b 1 2 bytes the size of a short for b 2 and 4 bytes the size of a long for 5 3 This packing is sometimes easier to use when writing both C and assembly code to access the same bit field structures because the sizes and offsets are more readily predictable Finally the Backward Compatible set ting preserves a somewhat more complicated packing scheme that was used by the Z8 Encore compiler before release 4 11 0 That previous scheme remains unchanged when Backward Compatible is selected except to correct a problem in the handling of mixed bit fields that is those in which bit fields of different nominal types are included in the same structure as in the example above If you have a legacy application in which you access the same bit fields using both C and assembly code you need to either use the Backward Compatible setting or rewrite your assembly code to access the bit fields using one of the new bit field packing options C Deprecated Page NOTE For Assembly Only projects the Deprecated page is not available The Deprecated page contains options from older releases of ZDS II that because of Issues found in extended experience with those particular options across many applica tions are no longer recommended for use Zilog strongly recommends that you not use these features in new projects If you have older projects that use these options they will continue to be supported
429. oscillator on Y4 For the development kit this frequency must match the clock oscillator on Y1 For more information about configuring the target see Setup on page 97 For details about the available debug tools and how to configure them see Debug Tool on page 100 12 Select the Z8F16800128ZCOG check box New Project Wizard Step 2 Target and Debug Tool Selection Target A target is a logical A representation of a target V Use page erase before flashing system Select the available Target target that best fits your target system or create your own Ea zaF 168001282006 ASHEN Click Setup to configure the 128F168001442COG ZDS Default target as needed Refer to the User Manual for details on managing and configuring targets Debug Tool A debug tool Setup Add Copy Delete represents debug communication hardware such Deus Tod as the USB Smart Cable or a Current Simulator g simulator Select the debug lt lt Back Next gt gt Finish Cancel Figure 5 New Project Wizard Dialog Box Target and Debug Tool Selection Step 13 Click Next UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog The Target Memory Configuration step of the New Project Wizard dialog box is displayed New Project Wizard Step 3 Target Memory Configuration Linker Address Spaces Use the provided fields to define the E Ensure that the ranges below are valid fo
430. ot allocate memory The TAG directive to define a structure union element has the following form stag STRUCT offset parent name_1 DS countl name _2 DS count2 tname TAG stagx count ssize ENDSTRUCT stag UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zilog ass The TAG directive to assign a label to have a structure type has the following form mame TAG stag Apply stag to name 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 MON
431. ox 6 Click Close 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 To copy the settings from an existing configuration to an existing configuration do the following 1 From the Build menu select Manage Configurations The Manage Configurations dialog box is displayed UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIlOG snc Manage Configurations Remove Copy Close Figure 76 Manage Configurations Dialog Box 2 From the Manage Configurations dialog box click Copy The Copy Configuration Settings dialog box is displayed Copy Configuration Settings Copy Settings From Copy Settings To Debug v Release WARNING All settings for selected configurations in the copy to list will be overwritten Copy Close Figure 77 Copy Configuration Settings Dialog Box 3 Select the configuration with the desired settings from the Copy Settings From drop down list box 4 Highlight the configuration s in the Copy Settings To field that you w
432. pace is provided with the EXTERN or XREF directive the space of the segment where the EXTERN directive was encountered is used as the location of the label Label Checks The assembler performs location checks when a label is used as an operand including for ward referenced labels Thus when a label that is not located in the proper space is used as an operand the assembler flags a warning Example EXTERN labell ROM JP labell valid ld r0 labell invalid SOURCE LANGUAGE SYNTAX The syntax description that follows is given to outline the general assembler syntax It does not define assembly language instructions source line gt lt if statement gt lt Label_field gt lt instruction_field gt lt EOL gt gt lt Label field gt lt directive_field gt lt EOL gt gt Label field gt lt EOL gt gt lt EOL gt if statement gt if section gt lt else statement gt gt ENDIF if section gt if conditional lt code body gt UM013033 0508 Using the Macro Assembler lt if_conditional gt lt else_statement gt lt cond_expression gt 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 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOG xcs IF lt cond_expression gt I FDEF lt ident gt IFSAME lt st
433. pace 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 While you are responsible for writing your own startup code when selecting this option ZDS Il automatically inserts some needed linker commands into your linker command file These commands are helpful in getting your project properly configured and initial ized because all C startup modules have to do many of the same tasks 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 277 for a description of these commands Use Standard Startup Linker Commands If you select this check box the same linker commands that support the standard startup module are inserted into your linker command file even
434. 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 15 General Options Option Name Corresponding Option in Project Settings Dialog Box Acceptable Values cpu General page CPU drop down field string valid CPU name Sets the CPU UM013033 0508 Using the Command Processor Table 15 General Options Continued Zilog Developer Studio ll Z8 Encore User Manual Option Name Corresponding Option in Project Settings Dialog Box Acceptable Values 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 Sets the output directory warn General page Show Warnings check box TRUE FALSE Librarian Options Table 16 Librarian Options Option Name Corresponding Option in Project Settings Dialog Box Acceptable Values outfile Librarian page Output File Name field Sets the output file name for the built library Linker Options Table 17 Linker Options string library file name with option path Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values createnew Comman
435. page 151 Calling Assembly Functions from C on page 157 Calling C Functions from Assembly on page 159 e Command Line Options on page 160 e Run Time Library on page 160 e Startup Files on page 177 Segment Naming on page 181 Linker Command Files for C Programs on page 181 e ANSI Standard Compliance on page 189 Warning and Error Messages on page 193 For more information on using the compiler in the developer s environment refer to Get ting Started on page 1 and Using the Integrated Development Environment on page 15 NOTE 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 using the Command Processor see Using the Command Processor on page 408 LANGUAGE EXTENSIONS To give you additional control over the way the Z8 Encore 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 Additional Keywords for Storage Specification on page 134 The compiler divides the Z8 Encore CPU memory into three memory spaces ROM RData near RAM and EData far RAM It provides the following keywords with which you can control the storage location of data in these memory spaces near UM013033 0508 Using the ANSI C Compiler UM013033 0508 Zilog Develope
436. parameter An attempt was made to call a function whose formal parameter list has fewer elements than the number of arguments in the call UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i I PES SN 7 IIO 0 V MV M 203 I 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 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 t
437. piler when the keepasm option is used or when the Generate Assembly Source check box is selected see Generate Assembly Source Code on page 66 and the map file to change all of the rel ative 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 SOURCE LANGUAGE STRUCTURE The following sections describe the form of an assembly source file General Structure on page 216 Assembler Rules on page 217 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual ga i fi PA F Z IOO n i UJ LI t V U 216 General Structure Every nonblank line in an assembly source file is either a source line or a comment line The assembler ignores blank lines Each line of input consists of ASCII characters termi nated by a carriage return An input line cannot exceed 512 characters A backslash 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 in the C programming language Place a space or any other character after the backslash if you do not want the line to be contin ued The following sections describe the general source language structure Source Line o
438. power of y A domain error occurs if x is zero and y is less than or equal to zero or if x is negative and y is not an integer A range error can occur Synopsis include lt math h gt double pow double x double y Returns The value of x raised to the power y Example double x 2 0 double y 3 0 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 e 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual i I PES SN Z I1 Of V MV
439. press the Enter key For example type ascii ones The ASCII value displays in the Value column Viewing a NULL Terminated ASCII ASCIZ String To view the NULL terminated ASCII ASCIZ values of an expression type asciz expression in the Expression column and press the Enter key For example type asciz ones The ASCIZ value displays in the Value column Locals Window Click the Locals Window button to show or hide the Locals window The Locals window 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 on the Advanced page of the Project Settings dialog box See Use Register Variables on page 69 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Zilog Cx01010B 0x54 0x69 Ox4C Ox4F 0x47 0x20 0x44 0x65 0x76 0x65 Ox6C Ox6F 0x70 MES x72 0x73 MTTTTTTTTTTTTTTTT Figure 110 Locals Window Call Stack Window Click the Call Stack Window button to show or hide the Call Stack window If you want to copy text from the Call Stack Window select the text and then select Copy from the con text menu Call Stack cy main line 197 file C Program File
440. processor page 67 Previous Bookmark button 23 Print button 17 Print Preview window 46 print script file command 429 printf function 347 372 conversion characters 374 flag characters 374 Program and Verify button 113 Program button 113 Program RAM 90 146 Project adding files 6 54 building 13 103 compiling 103 configuring 8 103 creating 1 2 39 customized configuration 104 deleting files from 39 exporting as make file 101 saving 14 setting up 8 Project Directory button 99 Project file creating 3 Project menu 54 Add Files 54 Export Makefile 101 Remove Selected File s 55 Settings 55 shortcuts 130 Project Settings dialog box 55 Address Spaces page 89 Advanced page 12 69 Assembler page 10 59 Code Generation page 61 62 Code Generation page 11 Commands page 80 81 Debugger page 96 Deprecated page 72 73 General page 9 56 57 Librarian page 77 78 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ 4 Listing Files page 65 66 Objects and Libraries page 84 85 Output page 13 93 94 Preprocessor page 67 Warnings page 91 92 ZSL page 78 79 Project Type field 40 Project Workspace window 29 30 Pseudorandom sequence generation 348 377 383 ptrdiff t 346 Public symbols creating 281 putch function 168 putchar function 347 375 puts function 347 376 pwd script file command 429 Q qsort function 349 376 Quick tour Command Processor 408 quit script file command 429 Quotient compu
441. provided they are previously defined Labels are not allowed in the expres sion NOTE There are restrictions on exporting EQU defined symbolic names using the XDEF directive or importing them using XREF Specifically a floating point string or symbolic register name EQU cannot be exported In the following example length width and area can be exported but myreg cannot Synonyms equ EQU EQUAL EQUAL Syntax label EQU expression Examples length EQU 6 first dimension of rectangle width EQU 11 second dimension of rectangle area EQU length width area of the rectangle myreg EQU rr4 symbolic name of a register pair 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 after 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 Syntax include directive gt INCLUDE lt string_const gt UM
442. r Studio ll Z8 Encore User Manual far rom These keywords can also be used to specify the memory space to which a pointer is pointing to Memory Models on page 137 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 Call Frames on page 138 Call frames hold the arguments local variables and other pertinent information of an instantiation of a procedure or function at a time The Zilog Z8 Encore compiler supports two types of call frames static and dynamic Dynamic call frames are allocated on the run time stack Static call frames are allocated in static memory The call frame can affect the efficiency of your application nterrupt Support on page 140 The Z8 Encore CPU supports various interrupts The C Compiler provides language extensions to designate a function as an interrupt service routine and provides features to set each interrupt vector Monitor Function Support on page 141 The C Compiler provides a special function type to be used in monitor applications to support efforts to create a real time operating system kernel for Z8 Encore String Placement on page 142 Because the Z8 Encore C
443. r combi nations Many users select this configuration initially when porting applications to Z8 Encore so that they do not have to worry immediately about whether their projects can meet the requirements for using the small model or static frames Particularly large and complex applications also often must use this configuration perhaps deselecting the Limit Optimizations for Easier Debugging check box for production builds Small and Debuggable The Small and Debuggable configuration sets the following values for the individual options Limit Optimizations for Easier Debugging check box is selected the memory model is small the frames are static This is the same as the Smallest Possible configura tion except that optimizations are reduced to allow easier debugging The other caveats to using the Smallest Possible configuration also apply to this configuration If you can meet the other restrictions required by the Smallest Possible configuration you might find it useful to work with this configuration when you are debugging the code and then switch to the Smallest Possible configuration for a production build Smallest Possible This configuration sets the following values for the individual options Limit Optimiza tions for Easier Debugging check box is deselected the memory model is small the frames are static This configuration generates the smallest possible code size but this configuration does not work for every project It is yo
444. r has predefined spaces and seg ments The following sections describe address spaces and segments Allocating Processor Memory on page 211 Address Spaces on page 211 Segments on page 211 e Assigning Memory at Link Time on page 214 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 are located at the specified physical memory address e Relocatable segments A relocatable segment is a segment without a specified origin At link time linker commands 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 memory regions for the Z8 Encore microprocessor are represented by the address spaces listed in Linker Address Spaces Page on page 89 Briefly the main address spaces are the ROM space used for program storage and some constant data and the data spaces RData and EData Both RData and EData are used to store nonconstant data RData is 8 bit addressable memory with a maximum range of 00H FFH and EData is 12 bit addressable memory with a maximum range of 100H EFFH Some CPUs also have specia
445. r small dynamic model no debug information csiosdd lib C serial IO library for small dynamic model with debug information UMO13033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Table 5 Linker Referenced Files Continued File Description csioss lib C serial IO library for small static model no debug information csiossd lib C serial IO library for small static model with debug information crtf04ald lib C run time library for XP large dynamic model no debug information ertf04aldd lib C run time library for XP large dynamic model with debug information crtf04als lib C run time library for XP large static model no debug information crtf04alsd lib C run time library for XP large static model with debug information crtf04asd lib C run time library for XP small dynamic model no debug information crtf04asdd lib C run time library for XP small dynamic model with debug information crtf04ass lib C run time library for XP small static model no debug information crtf04assd lib C run time library for XP small static model with debug information csiof1680ld lib C serial IO library for 16K XP large dynamic model no debug information csiof16801dd lib C serial IO library for 16K XP large dynamic model with debug information csiof1680ls lib C serial IO library for 16K XP large static model no debug information csiof16801sd
446. r to avoid overwriting the target s code with the same code This command is not enabled when the target is the simulator This command is available only when not in Debug mode For the Serial Smart Cable ZDS II performs an on chip debugger reset and resets the CPU at the vector reset location 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 Starting in version 4 10 0 the Download Code command can also program Flash memory A page erase is done instead of a mass erase for both internal and external Flash memory Use this command anytime during a debug session This command is not enabled when the debug tool is the simulator NOTE The current code on the target is overwritten UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual If ZDS II is not in Debug mode when the Download Code command is selected the fol lowing process is executed 1 Initializes the communication to the target hardware Resets the device with a hardware reset by driving pin 2 of the debug header low Configures the device using the settings in the Configure Target dialog box 2 3 4 Downloads the program 5 Issues a software reset through the debug header serial interface 6 Configures and executes the debugger op
447. r 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 Updated values appear in red UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual 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 on the Advanced page of the Project Settings dialog box See Use Register Variables on page 69 The following sections describe how to use the Watch window Adding New Variables on page 321 Changing Values on page 321 Removing an Expression on page 321 Viewing a Hexadecimal Value on page 322 Viewing a Decimal Value on page 322 Viewing an ASCII Value on page 322 Viewing a NULL Terminated ASCII ASCIZ String on page 322 Adding New Variables To add new variables in the Watch window select the variable in the source file drag and drop it into the window Another way to add new variables is to use the following proce dure 1 Click once on new watch in the Expression column This activates the column so that you can type the expression accurately 2 Type the expression and press the Enter key The value is displayed in the
448. r would otherwise not be able to generate correct code for the jump However if you are very concerned about monitoring the code size of your assembled application you can deselect the Jump Optimization check box You will then get an error message from the assembler if the target label is in the same assembly file or from the linker if it is not every time the assembler is unable to reach the target label with a relative jump This might give you an opportunity to try to tune your code for greater efficiency The default is checked C Code Generation Page NOTE For Assembly Only projects the Code Generation page is not available The options in the Code Generation page are described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog E Project Settings Configuration Debug Eh General E Code Generatio E ile Assembler e El C C Safest Eh Code Generation C Small And Debuggable Sil Listing Files C Smallest Possible 2E User Defined Eh Deprecated 5s ZSL El Linker Limit Optimizations for Easier Debugging ils Commands D 8 2 Objects and Libraries Memory Model Large ad 3 Address Spaces Frames Dynamic y Sg Warnings Parameter Passing Register y a Output h Debugger Note Figure 51 Code Generation Page of the Project Settings Dialog Box When this page is selected the fundamental options related to c
449. r your target The ranges of available memory on ranges below were initialized based on the selected CPU your target system This ROM RData information allows the developer s environment to 000000 003FFF 000020 0000FF inform you when your code or EData NVDS data has grown beyond your 0001 00 0007FF 000000 0000FF system s capability and to V PRAM automatically locate your code DOE 000 00E 3FF or data Linker Address Spaces All options can be modified later Project Settings Figure 6 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 file to the sample project 1 From the Project menu select Add Files The Add Files to Project dialog box is displayed UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog Add Files To Project Look in Tuoid v e Ee El main c File name Files of type Source Files c asm s src Cancel Figure 7 Add Files to Project Dialog Box 2 In the Add Files to Project dialog box use the Look In drop down list box to navigate to the tutorial direc
450. racter 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 int isgraph int c Tests for printable character except space int islower int c Tests for lowercase character int isprint int c Tests for printable character int ispunct int c Tests for punctuation character UM013033 0508 C Standard Library int isspace int c int isupper int c int isxdigit int c Zilog Developer Studio ll Z8 Encore User Manual Zilog Tests for white space character Tests for uppercase character Tests for hexadecimal digit Character Case Mapping int tolower int c int toupper int c Errors lt errno h gt Tests character and converts to lowercase if uppercase Tests character and converts to uppercase if lowercase The lt errno h gt 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 o
451. ragma monitor the saved value of the interrupt control register IRQCTL will be inserted on the stack between the caller s frame pointer and the return address Run Time Stack SP Temporaries Locals Low Address FP Callers Frame Pointer Small Model 8 0 Large Model 16 0 Return Address 16 0 Parameter 0 Parameter 1 Figure 94 Dynamic Call Frame Layout High Address Function Call Mechanism Static Frame A function caller function performs the following tasks when it calls another function which has a static call frame called function 1 Foranon varargs function load parameters into the corresponding static locations for the function For a varargs function a dynamic frame is always used and all parameters are pushed on the stack in reverse order 2 Then call the function The call instruction pushes the return address on the top of the stack 3 On return from the function the return address is automatically popped from the stack by the ret instruction The called function performs the following tasks 1 Ifthe called function is a monitor function only push the existing value of the interrupt control register IRQCTL on the stack and disable interrupts UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual 2 Push the frame pointer onto the stack and set the frame pointer to the current value of the stack pointer 3 Execute the code for th
452. rces the linker to allocate a group address space or segment in the order specified Syntax SEQUENCE lt name gt lt name_list gt lt 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 IS ASCENDING UP DESCENDING DOWN NAME indicates sorting by symbol name ADD d ESS 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
453. re User Manual 255 e The SWHILE and WEND directives must be properly balanced that is there must be exactly one SWEND directive for each SWHILE directive and the SWHILE directive must precede its corresponding WEND directive The structured assembly block must be completely specified with a single assembly unit An assembly unit is a single source file or a single macro definition Sequence of Operations The following sequences of operations are performed in processing structured assembly test directives e IF Sequence of Operations on page 255 e REPEAT Sequence of Operations on page 255 e WHILE Sequence of Operations on page 256 SIF Sequence of Operations The following sequence of operations is performed in processing the 1F structured assembly test directives 1 The assembler generates object code to evaluate the conditions specified on the SIF directive and on any optional SELSEIF directives If the condition is true at execution time the object code generated from the statements associated with the SIF directive are executed 2 Ifthe condition specified on the TF directive is false at execution time the assembler generated object code successively evaluates the conditions specified on the SELSEIF directives if there are any until a true condition is evaluated On evaluating a true SELSEIF condition the object code generated from the sta
454. re developer s environment see Shortcut Keys on page 129 TOOLBARS The toolbars give you quick access to most features of the Z8 Encore developer s envi ronment 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 the button is displayed Also you can drag and move the toolbars to different areas on the screen The following toolbars are available File Toolbar on page 16 Build Toolbar on page 18 Find Toolbar on page 21 Command Processor Toolbar on page 22 Bookmarks Toolbar on page 22 Debug Toolbar on page 23 Debug Windows Toolbar on page 27 NOTE For more information on Debugging see Using the Debugger on page 309 File Toolbar The File toolbar allows you to perform basic functions with your files using the following buttons UM013033 0508 New Button on page 17 Open Button on page 17 Save Button on page 17 Save All Button on page 17 Cut Button on page 17 Copy Button on page 17 Paste Button on page 17 Delete Button on page 17 Print Button on page 17 Workspace Window Button on page 17 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIlOg e Output Window Button on page 18 Dc Eoi 5 m X DA Figure 16 F
455. re are a small number of areas in which the Z8 Encore C Compiler does not behave as specified by the standard These areas are described in the following sections Prototype of Main on page 190 Double Treated as Float on page 191 const Keyword and ROM on page 191 Const Correctness in the Standard Header Files on page 192 e ANSI Promotions Disabled on page 192 Library Files Not Required for Freestanding Implementation on page 193 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 Z8 Encore C Compiler uses main as the function called at program startup Because the Z8 Encore compiler provides a free standing 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 because there is no operating system for a value to be returned to and it is UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual also not intended to terminate If main does terminate and the standard Zilog Z8 Encore C startup module is in use control simply goes to the following statement exit JR exit For this reason in the Z8 Encore C Compiler ma
456. re described in this section UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog a li Project Settings Configuration Debug 7 5e General E Outp to Sis Assembler Output File Name T as OU TERR C Program FilesZiLOG ZDSII Z8Encore 4 11 0 samples Tut ils Listing Files V Generate Map File E beg Sort Symbols By Name Address vance Deprecated Show Absolute Addresses in Assembly Listings 5s ZSL Executable Formats IEEE 695 fl Intel Hex32 Records Commands SS Objects and Libraries Fill Unused Hex File Bytes with OxFF 3 Address Spaces Maximum Bytes per Hex File Line 64 y SS Warnings 3d Output E Debugger Note Figure 64 Output Page of the Project Settings Dialog Box Output File Name You can change the name of your executable including the full path name 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 282 Inside the map file symbols are listed in the order specified by the Sort Symbols By area see Sort Symbols By on page 95 NOTE The link map is an important place to look for memory restriction
457. re used to place the scalar parameters of function The rest of the parameters are placed in memory See Function Call Mechanism Register Parameter Passing on page 155 for further details In most cases selecting Register results in a smaller overall code size for your applica tion but this is not guaranteed check your results using the map file to make certain Also if your application uses both C and assembly code and the assembly code accesses any parameters to a C function you must make sure that the location of those C parameters that is assumed in the assembly code continues to match the option you have selected for Parameter Passing See Calling Conventions on page 151 for more details C Listing Files Page NOTE For Assembly Only projects the Listing Files page is not available The options in the Listing Files page are described in this section UM013033 0508 Using the Integrated Development Environment 65 Zilog Developer Studio ll Z8 Encore User Manual ZILOG lil Project Settings Configuration Debug m Sb General Listing Fi Sil Assembler z C ue as Gals Gonerstion Generate C Listing Files lis Tm 3 3 Preprocessor Generate Assembly Source Code SR Advanced A eR Deprecated Y Generate Assembly Listing Files Ist 5s ZSL fi amp Linker SS Commands Eh Objects and Libraries 3 Address Spaces 3 Warnings 5s Output 5d Debugger Note Cancel Help Figure 52 Listing
458. ress Cto 395 Figure 104 Memory Window Requested Address Filling 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 list 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 Fill Memory Fill Value Address Range FF C 7F C 00 C Other Start Address Hex 000000 End Address Hex 0000FF tees Figure 105 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 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 UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual ZILOQ as This address range is used to fill memory with the specified value 6 Click OK to fill the selected memory Saving 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 dr
459. rform basic commands in the developer s environment New File on page 38 Open File on page 38 Close File on page 39 e New Project on page 39 Open Project on page 43 Save Project on page 44 Close Project on page 45 Save on page 45 Save As on page 45 e Save All on page 45 e Print on page 45 Print Preview on page 46 Print Setup on page 47 e Recent Files on page 47 e Recent Projects on page 47 e Exit on page 47 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 which allows you to open the files for your project UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilod Look in e SIC e amp ck E3 E ledblink asm Files of type Source Files c asm s src Cancel Figure 34 Open Dialog Box NOTE To delete a file from your project use the Open Project dialog box Highlight the file and press the Delete key Answer the prompt accordingly 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 New Project E Project Name C Program Files ZiLOG
460. rge Synopsis include lt math h gt double sinh double x Returns The hyperbolic sine value 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f Z f I V MV M 383 amu character is written at the 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 char format Returns The number of characters written in the array not counting the terminating null character Example int d 51 char buf 40 sprint buf COMPASS d d sqrt Computes the nonnegative square root of x A domain error occurs if the argument is neg ative Synopsis include lt math h gt double sqrt double x Returns The value of the square root Example double x 25 0 double y y sqrt x 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
461. ring_const gt lt string_const gt IFMA lt int_const gt ELSE lt code_body gt IF cond expression code body else statement A lt expression gt lt expression gt lt relop gt lt expression gt lt gt lt gt lt source_line gt ident mnemonic operand directive valid instruction mnemonic addressing mode expression valid instruction addressing mode Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual ZIlOg ace lt directive gt gt ALIGN lt int_const gt lt array_definition gt gt CONDLIST ON OFF gt END lt expression gt gt ENDWITH lt ident gt ENDSTRUCT lt ident gt gt lt ident gt EQU lt expression gt gt ERROR lt string_const gt gt EXIT lt string_const gt gt FCALL lt ident gt gt FILE lt string_const gt gt FRAME lt ident gt lt ident gt lt space gt gt GLOBALS ON OFF gt INCLUDE lt string_const gt gt LIST ON OFF gt lt macro_def gt gt macro invoc gt MACDELIM lt char_const gt gt MACLIST ON OFF gt NEWPAGE gt NOLIST gt ORG lt int_const gt gt lt public_definition gt gt scalar definition me SCOPE gt segment definition gt SEGMENT lt ident gt gt SUBTITLE lt string_const gt a SYNTAX lt target_microprocessor gt gt TAG ident lt in
462. rinsic void EI void Example include lt eZ8 h gt void main void EI Enable interrupts getch The getch function 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 int getch void Returns The next character that is received at the selected UART Example include lt sio h gt int val void main init uart UARTO DEFFREQ DEFBAUD val getch Get character from _UARTO UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog 166 NOTE Before using this function the init uart function needs to be called to initialize and select the UART The default UART is UARTO INIT FLASH The INIT FLASH function is a Zilog function that sets the target clock frequency for Flash write The following target clock frequencies are predefined in e28 h for conve nience Synopsis FREQ20000 for20MHz FREQ18432 for 18 432 MHz FREQ16000 forl6MHz FREQ14000 for 14 MHz FREQ12000 for 12 MHz FREQ08000 for 8 MHz FREQ04000 for 4MHz include lt eZ8 h gt void reentrant INIT FLASH unsigned short freq Returns None Example include lt eZ8 h gt char x
463. rning on Flash Optionbits Program ming check box 127 Disassembly window 325 Disassembly Window button 28 div function 349 358 div t 347 DL directive 232 Down button 49 Download Code button 19 24 DS directive 235 DW directive 232 233 Dynamic frames 139 Dynamic Frames button 64 Index E EData 90 Edit Breakpoints command 328 Edit button 82 Edit menu 47 Copy 48 Cut 48 Delete 48 Find 48 Find Again 49 Find in Files 49 Go to Line 51 Manage Breakpoints 52 Paste 48 Redo 48 Replace 50 Select All 48 shortcuts 129 Show Whitespaces 48 Undo 48 Edit window 30 31 code line indicators 311 Editor tab Options dialog box 123 EDOM 340 348 EI 165 Embedding assembly in C 164 Enable All button 52 328 Enable Breakpoint command 329 Enable check box 113 114 Enable Disable Breakpoint button 21 27 _ ENCORE _ 150 END directive 235 ENDMACRO directive 259 ENDSTRUCT directive 244 ENDWITH directive 247 enum declarations with trailing commas 148 enumeration data type 144 EOF macro 346 EQU directive 236 ER 225 ERANGE 340 348 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ as Erase Before Flashing check box 112 ERASE button 112 errno macro 340 lt errno h gt header 340 Error conditions 340 343 Error messages ANSI C Compiler 193 assembler 269 linker locator 305 Ethernet Smart Cable requirements xvili Executable Formats area 95 Executable formats for Linker 95 exit script f
464. rogram so that the part will still get configured correctly even when the hex file is downloaded outside of ZDS II The PRAM M bit is bit 1 of Flash option byte 1 see the product specification Writing to the Flash option bytes must be done only once and takes effect when your hex file is downloaded to Flash Therefore if you wanted to set all the other bits of Flash option byte 1 to their default value of 1 but set the PRAM M bit to 0 to indicate that you will not be using this memory as Program RAM use the following code in your program include lt eZ8 h gt FLASH OPTIONI OxFD This example is only for illustration of course it is your responsibility to make sure that all bits of the Flash option bytes are set as you need them for your application NOTE Data addresses F00 through FFF are reserved for special function registers SFRs Address ranges are set in the Address Spaces fields ory range The following is the syntax of a mem low address gt high address gt low address gt high address gt where ow address gt is the hexadecimal lower boundary of a range and lt high address gt is the hexadecimal higher boundary of the range The 00 df 0000 ffff 0000 1fff 4000 5fff Holes in your memory can be defined for the linker following are legal memory ranges using this mechanism The linker does not place any code or data outside of the ranges specified here If your c
465. rom options selected in the Warnings page see Linker Warnings Page on page 91 The other options shown here are all generated from the settings selected in the General page of the Project Settings dialog box see General Page on page 56 RANGE ROM 0 SFFFF RANGE RDATA 20 SFF RANGE EDATA 100 SEFF The ranges for the three address spaces are defined here These ranges are taken from the settings in Address Spaces page see Linker Address Spaces Page on page 89 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zzilog 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 preceding commands The NEAR TEXT and FAR TEXT segments contain constant strings in RData and EData 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 These 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 EData space Similarly NEAR DATA follows after NEAR BSS in the RData space COPY NEAR DATA ROM COPY FAR DATA ROM This COPY command is a linker directive to make the linker pl
466. rs and set to 0 or 1 as to whether bitfields back left to right that is from most significant to least significant bit Defined if const objects are placed in RAM memory Defined if const objects are placed in ROM memory Defined on all Zilog compilers and expands to the CPU name as passed on the compile line This macro expands to the current date 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 This macro expands to the current source file name a string literal This macro expands to the current line number a decimal constant Defined on all Zilog compilers and set to 0 or 1 as to whether a change in the type of bit field members requires beginning a new byte in the bitfield packing A 1 indicates that it does This macro is defined as the decimal constant 1 and indicates conformance with ANSI C This macro expands to the compilation time in the format hh mm ss a string literal Using the ANSI C Compiler 149 Zilog Developer Studio ll Z8 Encore User Manual Zzilogi UNSIGNED CHARS Defined if the type char is equivalent to the type unsigned char None of these macro names can be the subject ofa define ora undef preprocessing directive The values of these predefined macros except for LINE and FILE remain const
467. ry Zilog Developer Studio ll Z8 Encore User Manual i IIAN 1 LJl XV MV M 349 amu Memory Management The order 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 size t size int Performs binary search compar void void void qsort void base size t nmemb size t size int compar void Performs a quick sort void 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 Idiv_t ldiv long int numer long int denom Computes long quotient and remainder Miscellaneous void abort void Abnormal program termination String Handling lt string h gt The lt string h gt header declares several fu
468. ry If the file is not found after searching the entire path the compiler flags an error The default standard includes are located in the following directories ZDS Installation Directory NincludeWilog where ZDS Installation Directory is the directory in which Zilog Developer Studio was installed By default this is C Program Files ZiLOG ZDSII Z8Encore version where lt version gt might be 4 11 00r5 0 0 Omitting this switch tells the compiler to search only the current and default directories usrinc path Sets the search path for user include files This defines the location of include files using the include 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 project directory 2 the c rt1 directory 3 the c myinc directory 4 the directory of the file from where the file is included 5 the directories listed under the st dinc command 6 the default 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 UM013033 0508 Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual n l LIBRARIAN COMMAND LINE OPTIONS The following table describes the librarian comma
469. s or between SREPEAT and SUNTIL E directives to appear in END directives must be coded in matching pairs That is it is E directive without a matching w later in the source module nor is it legal to code an wl END directive appearing END directive without a E and SWEND assembler directives can be labeled If a label is specified a warning message is issued and the label is The following sections describe the assembly time processing of structured assembly directives Validity Checks on page 254 Sequence of Operations on page 255 Validity Checks The following validity checks are performed on the structured assembly block input data Unless otherwise specified violations cause the assembly to fail e The syntax of the structured assembly block must conform to the requirements specified in Structured Assembly Inputs on page 250 e The SIF and SENDIF directives must be properly balanced that is there must be exactly one SENDIF directive for each 1F directive and the IF directive must precede its corresponding SENDIF directive e The SREPEAT and SUNTIL directives must be properly balanced that is there must be exactly one SUNTIL directive for each SREPEAT directive and the SRE directive must precede its corresponding UNTIL directive UM013033 0508 P EAT Using the Macro Assembler Zilog Developer Studio ll Z8 Enco
470. s 293 OE OTT T 293 lt lt Shift Left 241 4 ood re oet Reed ee de tiae dea tec e be aedes 293 Po OH MIO poet eee ee iia JE ORE ARI CR RERBA RC IRURE AR 293 UDCA IRR Sate a it Ped aed teed eee a d 293 TORO E RR SRE RR IRA BERR ERO OE RR HER OE 293 Bitwise Exclusive Or 000 rn 294 MONG Bois betd plut doo hb Oo bb Das dub oto disces dicic ra slt d rid edd 294 Sample Linker Map File o oooocococcococcoconc I 294 Warning and Error Messages ooooooococorrrr eee hh 305 Using th Debugger 5 teer ry nm Wate o aa BW aoe iw a a Re 309 Status Bat bz o ba EONS Oh WHOS RSG ERR ede ROS Bed eos 310 Code Line indicators ecan decet Ee a bei eer eres e Dressed e bos woo 311 Debug Windows ooooooocorr ee ha 311 Registers Window esses be A ea ad V RT RA ads 312 Special Function Registers Window 0 0 cece eee eee 313 Clock Window 2000 ke eX ER DR REESE RIT DAR 313 Memory Window ooooooooorr eer hs 314 Watch Window 6 ccc ehh hs 320 Locals WindOW mid ese dee exu rd A er prete edere Pes ds 322 Call Stack Window ccc ccc cece hh 323 Symbols Window 0 ooooooooooo cnet nen eens 324 Disassembly Window 00 00 c cece cee e 325 Simulated UART Output Window sseeesee e 326 Using Breakpoints viii a pte e dee eed AIEO VOR CR E ewe 326 Inserting Breakpoints 0 0 een teen ene 327 Viewing Breakpoints 0 ccc cee nett eeenee 328 UM013033 0508 Table of Conten
471. s 6 METTI 151 Macros Generated by the IDE 2 6 cette enna 151 Calling Conventions veia a eu tee vale a taa o pad ia 151 Function Call Mechanism Dynamic Frame 0ooooocoococcccco 152 Function Call Mechanism Static Frame 1 0 0 0 0 eee nee 153 Function Call Mechanism Register Parameter Passing 155 Ret in Value i0id c e08 dice qe e ere E SR HEP be ee 156 Special Cases aux eset wae er UR RU au e accedere ROO gts 157 Calling Assembly Functions from C 2 ett nee 157 Function Naming Convention 0 0c cece teen eens 158 Argument Locations 0 cece ehh rr 158 Rot Values au co E AAA id 159 Preserving Registers 2 0 0 ccc tenet teens 159 Calling C Functions from Assembly 00 000 cece eens 159 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User Manual ran ILU U V MV M Assembly Pile cue ere ra e Oe rele aede ea e E haps e ure br d 160 Referenced C Function Prototype 0 0 0 160 Command Line Options 0 ccc ha 160 Run Time Library gi es 2 4 a e Saw e aer Gee eas 160 Zilog Header Files 2 oed Gena e eR sedi daa abeo deus be adea 162 Zilog Functions near Sees he e eH ERE ES HERR ge 164 Startup Files ecu peser REDEEM Bed nies Sede Bore Had ees E Re eds 177 Customizing Startup Files 0 0 ccc ttt eens 178 Segment Naming oo ooo hh mrs 181 Linker Command Files for C Programs 0 000 c ccc eee eee enn 18
472. s Tutorial samp m Actimatad tarcet TRR168 nn1207C0 C vj gt Build Debug A Find in Files A Find in Files 2 A Messages Command la gt Figure 32 Messages Output Window Command Output Window The Command Output window holds the output from the execution of commands ebugTool Create NAME lt Debug Tool Name COMMTYPE lt tool type Create a Debug Tool ebugTool Save NAME lt Debug Tool Name gt Save a Specified Debug Tool ebugTool Save Save the Active Debug Tool L be Build A Debug A Find in Files A Find in Files 2 A Messages x Figure 33 Command Output Window MENU BAR The menu bar lists menu items that you use in the Z8 Encore developer s environment Each menu bar item when selected 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 fol lowing items are listed on the menu bar File Menu on page 38 Edit Menu on page 47 View Menu on page 53 UM013033 0508 Using the Integrated Development Environment Project Menu on page 54 Build Menu on page 102 e Debug Menu on page 106 Tools Menu on page 110 Window Menu on page 127 Help Menu on page 128 File Menu Zilog Developer Studio ll Z8 Encore User Manual as ms d f D Fr uU I f n ats UA I S Www ed 38 The File menu enables you to pe
473. s performed before executing the block the block might not be executed For example for the following looping structure Swhile r0 0 ld r2 r0 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual i I PES PN 7 IIO 0 V MV M 250 I dec r0 Swend the assembler generates the following code 00000D A6E000 A 10 Swhile r0 0 000010 6B 06 000012 E320 A 11 ld r2 Qr0 000014 30E0 A 12 dec ro 000016 8B F5 A 13 Swend 000018 A 14 The REPEAT directive generates code to test an execution time condition after execut ing a block of statements and repeatedly executes the block until the condition is true Because the test is performed after executing the block the block is executed at least once For example for the following looping structure Srepeat ld r1 r0 dec r0 Suntil eq the assembler generates the following code 000018 A6E000 A 17 Srepeat 000018 6B 06 A 18 ld r1 r0 00001A E320 A 19 dec ro 00001C 30E0 A 20 until eq 00001E 8B F5 A 21 Structured Assembly Inputs The following sections describe the structured assembly input requirements IF Structured Assembly Block Inputs on page 250 REPEAT Structured Assembly Block Inputs on page 252 e WHILE Structured Assembly Block Inputs on page 253 IF Structured Assembly Block Inputs The SIF SELSEIF SELSE and SENDIF as
474. s 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 Press 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 following the Output windows Build Output Window on page 36 e Debug Output Window on page 36 Find in Files Output Windows on page 36 Messages Output Window on page 37 Command Output Window on page 37 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 delete all text in the Output window
475. s segment2 at the address of the last used location of segment 1 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 21 Copyright C 1999 2004 ZiLOG LINK MAP DATE Wed May 03 10 58 46 2006 PROCESSOR assembler FILES C NPROGRA 1NZiLOGNZDSII 3 main obj C PROGRA 1 ZiLOG ZDSII 3 C PROGRA 1 ZiLOG ZDSII_ 3 C PROGRA 1 ZiLOG ZDSII_ 3 C PROGRA 1 ZiLOG ZDSII_ 3 C PROGRA 1 ZiLOG ZDSII_ 3 UM013033 0508 06050201 eng Inc All Rights Reserved O lib zilog startupL obj ONlibNstdNchelpD lib O lib std crtLDD 1lib 0 lib std pLDD lib ONlibNzilogNcsioLDD lib OMlibNzilogNzsldevinitdummy obj Using the Linker Locator COMMAND LIST Zilog Developer Studio ll Z8 Encore User Manual ZILOG ns Linker Command File sample Debug Generated by ZDS II Z8 Encore Family 4 10 0 Build 06050301 eng IDE componen compiler options b 4 10 06050201 eng const RAM define Z8F6423 define Z8ENCORE 64K SERIES
476. s the Simulated UART Out put window This window is described in Simulated UART Output Window on page 326 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zil0d WINDOWS The following ZDS II windows allow you to see various aspects of the tools while work ing with your project Project Workspace Window on page 29 Edit Window on page 30 Output Windows on page 35 Project Workspace Window The Project Workspace window on the left side of the developer s environment allows you to view your project files xx y Standard Project Files ledblink asm C 4Prd y External Dependencies ez8 ine C Prograi ez8dev inc C Prod ledblink ine C Prod test123 Figure 23 Project Workspace Window for Standard Projects UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIl0d 2 3 Assembly Only Project Files ledblink asm C Program External Dependencies ez8 inc C Program Files ez8dev inc C Program ledblink inc C Program R atest Figure 24 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 allows you to do the follo
477. s the smallest integer not less than x Synopsis dinclude lt math h gt double ceil double x Returns The smallest integer not less than x expressed as a double Example double y 1 45 double x x ceil y COS 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 Returns The cosine value UMO13033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f ZILOQ ICY M 358 amu Example double y 1234 double x x cos y cosh Computes the hyperbolic cosine of x A range error occurs if the magnitude of x is too large Synopsis finclude math h double cosh double 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 denon If the division is inexact the sign of the quotient is that of the mathe matical quotient and the magnitude of the quotient is the largest integer less than the mag nitude of the mathematical quotient Synopsis include 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 Examp
478. scribe predefined macros Examples on page 151 Macros Generated by the IDE on page 151 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i I PES PN Z I1 Of amp Y Sj 151 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 ENCORE printf for Z8 Encore endif ifdef EZ8 printf with eZ8 Cpu endif ifdef ZDATE _ printf built on d n ZDATE endif Macros Generated by the IDE In addition to the above predefined macros the ZDS II IDE generates the following mac TOS DEBUG Generated for DEBUG builds This macro can be tested to insert additional code in debug builds for sanity checking or to simplify debugging NDEBUG Generated for release builds This macro if defined prevents the assert macro from generating any code _ lt cpu gt Where lt cpu gt is the CPU name for example _28F1680 or _Z8F0830 _ lt variant gt Where lt variant gt is the specific variant of the CPU for example Z8F2480XX20XXSG or Z8F0880XX20XXEG The macros generated by the IDE can be checked and added to by going to the Prepro cessor page of the Project Settings dialog box see C Preprocessor Page on page 67 CALLING CONVENTIONS The Z8 Encore C Compiler imposes a strict
479. script file command 418 Delete Bookmarks button 23 Delete button 17 99 delete config script file command 418 Delete Source Target After Copy check box 99 Deleting files from a project 39 Deprecated page 73 Developer s environment menus 37 software installation 1 system requirements xvi toolbars 16 tutorial 1 DF directive 231 DI 164 Index Directives warning support 147 SBREAK 252 253 SCONTINUE 252 253 SELSE 250 SELSEIF 250 SENDIF 250 SIF 249 250 255 SSREPEAT 250 252 255 SUNTIL 252 SWEND 253 SWHILE 249 253 256 COMMENT 227 ENDSTRUCT 244 ENDWITH 247 STRUCT 244 TAG 245 UNION 247 WITH 247 ALIGN 227 BFRACT 229 BLKB 230 BLKL 230 BLKW 230 compatibility 268 437 conditional assembly directives 256 CPU 228 data 228 DB 231 DD 231 DEFINE 213 233 definition 226 DF 231 DL 232 DS 235 DW 232 233 END 235 ENDMACRO 259 EQU 236 EXTERN 264 FRACT 230 UMO13033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOPD ass IF 257 IFDEF 258 IFMA 259 IFSAME 258 in assembly 217 226 INCLUDE 236 LIST 237 MACDELIM 262 MACEXIT 262 MACRO 259 NEWPAGE 237 NOLIST 237 ORG 238 SCOPE 263 SEGMENT 213 238 structured assembly 249 SUBTITLE 239 TITLE 239 UBFRACT 229 UFRACT 230 VAR 239 VECTOR 241 XDEF 242 XREF 243 264 Disable All Breakpoints button 27 Disable All button 52 329 Disable ANSI Promotions check box 74 Disable Breakpoint command 329 Disable Wa
480. sed on device type and application requirement For example far int fi fi is placed in EData address space UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual NOTE In the Z8 Encore compiler the peripheral registers address FOO FFF are also mapped to the far storage specifier no separate keyword is provided For example define TOCTLO unsigned char volatile far 0xF06 TOCTLO 0x12 rom A variable declared with the rom storage specifier is allocated in the 16 bit addressable nonvolatile memory The address range for these variables is 0000 FFFF The lower portion of this address space is used for the Flash option bytes and interrupt vector table The corresponding assembler address space for these variables is ROM You can set this address range within 0000 FFFF based on his device type and application requirement For example rom int ri ri is placed in ROM address space Flash FFFF Register File rom 0000 Figure 93 Z8 Encore Memory Layout Storage Specification for Pointers To properly access near far and rom objects using a pointer the compiler provides the ability to associate the storage specifier with the pointer type UM013033 0508 near pointer A near pointer points to near data far pointer A far pointer points to far data Using the ANSI C Compiler rom pointer Zilog Developer Studio ll Z8 Encore User
481. sembler directives are used to test execu tion time conditions and conditionally execute object code based on the results of the test Syntax SIF condition comment statements SELSEIF condition2 comment statements UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual e H I PES PN Z I1 Of V MV M 251 I SELSE comment statements SENDIF comment The following qualifications elaborate the syntax and semantics of the structured assembly test directives Unless otherwise specified violations of these qualifications cause the assembly to fail e The SIF SELSEIF SELSE and SENDIF assembler directives must be specified in that order e The SELSEIF assembler directive is optional It can be specified an arbitrary number of times between the SIF and SENDIF assembler directives The SELSE assembler directive is optional It can be specified at most once between the 1F and SENDIF directives e Ifused the SELSE assembler directive must be coded after any SELSEIF directives Any valid assembler statement can appear in the statements sections of the structured assembly test directives This means among other things that structured assembly test directives can be nested The structured assembly test directives can be nested up to
482. sembly FRAME n fun n fun RDATA L fun DS 1 0 fun DS 1 The FRAME directive defines the beginning of the static call frame of a function It con tinues to the next segment directive in assembly and has the following form FRAME lt framename gt lt segname gt space UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual o ef pf I LI v v where e lt framename is the name of the frame being declared e lt segname gt is the name of the local and parameter segment e lt space gt is the address space that holds the static frame If the static frame function calls other functions then they must be referred to within the FRAME segment of the static frame function This reference is done by including the FCALL directive The FCALL directive helps the linker to optimally allocate the static call frames using the call graph technique FCALL lt framename gt where framename is the name of the frame of the function called from the static frame function For example void fun char chl char ch2 funl ch1 FRAME n fun n fun RDATA FCALL n funl X uns DS 1 _0 fun DS 1 Function Call Mechanism Register Parameter Passing A function caller function performs the following tasks when it calls another function using the register parameter passing scheme with a dynamic or static frame 1 Foranon varargs function
483. set command uses the following process 1 ZDS II performs a hardware reset 2 Configures the device using the settings in the Configure Target dialog box 3 If files have been modified ZDS II asks Would you like to rebuild the project before downloading the modified program If there has been no file modification the code is not reloaded The Serial Smart Cable performs an on chip debugger reset Go Select Go from the Debug menu to execute project code from the current program counter If not in Debug mode when the Go command is selected the following process is exe cuted 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Downloads the program 5 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If it is a C project ZDS II resets to the main function if it is found 6 Executes the program from the reset location 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 win dow The cursor must be placed on a valid code line a C source line with a blue dot dis played 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 count
484. set of rules on function calls Except for spe cial 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 program to fail The following sections describe the calling conventions Function Call Mechanism Dynamic Frame on page 152 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Function Call Mechanism Static Frame on page 153 Function Call Mechanism Register Parameter Passing on page 155 Return Value on page 156 Special Cases on page 157 Function Call Mechanism Dynamic Frame A function caller function performs the following tasks when it calls another function that has a dynamic call frame called function 1 Push 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 2 Then call the function The call instruction pushes the return address on the top of the stack 3 Onreturn from the called function caller pops the arguments off the stack or increments the stack pointer The called function performs the following tasks 1 Ifthe called function is a monitor function only push the existing value of the interrupt control register IRQCTL on the stack and disable interrupts 2
485. set the device before execution because the program counter might have been changed after the download UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Verify Download Button The Verify Download button determines download correctness by comparing executable file contents to target memory Reset Button Click the Reset button in the Build or Debug toolbar to reset the program counter to the beginning of the program If ZDS II is not in Debug mode the Reset button starts a debug session using the follow ing process 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Downloads the program 5 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If itis a C project ZDS II resets to the main function if it is found If ZDS II is already in Debug mode the Reset button uses the following process 1 ZDS II performs a hardware reset 2 Configures the device using the settings in the Configure Target dialog box 3 Iffiles have been modified ZDS II asks Would you like to rebuild the project before downloading the modified program If there has been no file modification the code is not reloaded For the Serial Smart Cable ZDS II performs an on chip debugger reset Stop Debugging Button The Stop Debugg
486. sh frequency char reentrant READ FLASH rom const void addr Read Flash memory void reentrant WRITE FLASH rom const void addr char val Write Flash memory char reentrant READ NVDS char addr Read NVDS memory int reentrant WRITE_NVDS char value char addr Write NVDS memory int reentrant READ NVDS GET STATUS char addr Read NVDS get status char reentrant WRITE NVDS GET STATUS char value char addr Write NVDS get status intrinsic void RI unsigned char istat Restores interrupts intrinsic unsigned char TDI void Tests and disables interrupts Nonstandard I O Functions lt sio h gt This header contains nonstandard Z8 Encore specific input output macros and functions Macros _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 Functions int 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 unsigned char kbhit void Checks the receive data available on selected UART reentrant unsigned char 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 UM013033 0508 Using the ANSI C Compiler NOTE These I O functions are pro
487. shortcuts 129 File Name field 45 102 File Offset field 112 File toolbar 16 17 File Type drop down list box 124 Fill Memory dialog box 115 317 Fill Unused Hex File Bytes with OxFF check box 95 FILLMEM script file command 420 Find button 50 Find dialog box 48 49 Find field 21 50 Find in Files 2 Output window 37 Find in Files button 21 Find in Files dialog box 49 50 Find in Files Output window 36 Find list box 50 Find Next button 49 51 Find toolbar 21 Find What field 49 51 Find What list box 49 51 Finding characters 385 388 389 Finding strings 389 Flash Configuration area 112 Flash Loader running from the Command Processor 434 using the GUI 110 Flash Loader Processor dialog box 111 Flash memory reading to 168 setting the target clock frequency 166 writing to 175 Index Flash memory setting Flash option bytes in C 145 Flash option bytes 145 162 Flash Options area 111 FLASH OPTIONI 145 FLASH OPTION2 145 FLASH OPTIONBITS 313 lt float h gt header 340 Floating Point Library drop down list box 88 floor function 345 360 FLT_DIG 341 FLT MANT DIG 341 FLT MAX 341 FLT MAX 10 EXP 341 FLT MAX EXP 341 FLT MIN 341 FLT MIN 10 EXP 341 FLT MIN EXP 341 FLT RADIX 341 FLT ROUND 341 fmod function 345 360 fname TEXT segment 181 Font dialog box 126 FORMAT command 281 FPLIB 150 FRACT directive 230 Frames dynamic 139 static 138 free function 349 360 FREEMEM operator 291 FREQ04000 166 FREQO08000 166 FREQ12000 166
488. signed char uch2 2 unsigned char uch3 128 int intl char chl 2 UM013033 0508 Using the Integrated Development Environment int main void puts START intl uchl uch2 if intl 1 else puts EQUAL if uch3 lt chl puts UNSIGNED else puts SIGNED puts DONE puts NOT EQUAL Zilog Developer Studio ll Z8 Encore User Manual IION ILUO LI EN M 77 amu nopromote 00FFh FFFFh promote FFFFh FFFFh nopromote uchar 80h uchar FEh promote int 128 int 2 The following recommended programming practices are good practice in any case for pro ducing code that is both correct and efficient These practices are especially important to avoid trouble if you are using the deprecated Disable ANSI Promotions option Use variables of type char or unsigned char wherever the expected range of values for the variable is 128 127 or 0 255 respectively Use explicit casts to int unsigned int long or unsigned long where the result of an expression is expected to overflow the larger of the two operand types Even with ANSI promotions disabled the compiler automatically promotes a smaller operand so that the types of the operands match e Itis good programming practice to use explicit casts even where automatic promotions are expected Explicitly cast constant expressions that you want to be ev
489. snippet when the const ROM option has been selected and fails otherwise when const data is stored in RAM The bottom form fails when const ROM but succeeds otherwise There can never be a case when both calls succeed because the second pointer argument of rom src strcpy is a fundamentally different type pointing into a different space than the second pointer argument of strcpy In short the result of these architectural constraints is that if the Place Const Variables in ROM check box is selected it is impossible for the compiler to treat the const keyword in a way that complies with the ANSI C Standard Itis better to not select this deprecated option and let the compiler use const variables in RAM when needed and to use the rom keyword explicitly to declare any data such as tables that you really do want to locate in ROM Disable ANSI Promotions The option of enabling or disabling ANSI promotions refers to promoting char and short values to ints when doing computations as described in more detail in this sec tion Disabling the promotions was made a user option in earlier releases of ZDS II with the goal of reducing code size because the promotions called for by the ANSI C standard are often unnecessary and can lead to considerable code bloat However over time sev eral problems were found in the compiler s ability to apply this option consistently and correctly in all cases Therefore Zilog no longer recommends the use of this f
490. splayed in the Command Output window in the IDE and if logging is enabled see log on page 421 in the log file as well Commands are not case sensitive In directory or path based parameters you can use 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 UM013033 0508 Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual The following table lists ZDS II menu commands and dialog box options that have corre sponding script file commands Table 11 Script File Commands ZDS Il Menus ZDS II Commands Dialog Box Options Script File Commands Location File New Project new project page 422 Open Project open project page 423 Exit exit page 420 Edit Manage Breakpoints list bp page 421 Go to Code Enable All Disable All Remove cancel bp page 415 Remove All cancel all page 414 Project Add Files add file page 413 Project Settings General CPU Family page 426 page CPU option general cpu Show Warnings option general warn Generate Debug Information option general debug Ignore Case of Symbols only option general igcase available for Assembly Only projects Intermediate Files Directory option general outputdir Pr
491. ssarily e None If you 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 an error or warning message about an undefined symbol Zilog Standard Library Peripheral Support Select this check box to use the Zilog Standard Library ZSL in addition to the run time library described in the Using the ANSI C Compiler chapter The ZSL contains func tions for controlling the UART device driver and GPIO ports NOTE Inthe ZDS II 4 10 0 release the ZSL page is unavailable if you have selected one of the CPUs in the F1680 CPU family For these parts only basic UART support is available at this time This basic support consists of support for only those functions that are required to support I O functions in the C standard library such UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi as printf If you need this type of UART support for the F1680 family of CPUs select the C Runtime Library check box see C Runtime Library on page 87 Linker Address Spaces Page The options on the Address Spaces page are described in this section lil Project Settings Configuration Debug hd h General E Address Sil Assembler El e Sil Code Generation ROM RData 3 Li
492. 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 statement 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 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 326 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Enable Disable Breakpoint Button The Enable Disable Breakpoint button activates or deactivates the existing breakpoint at the line
493. sting Files 000000 003FFF 000020 0000FF h Preprocessor EData Iv Use PRAM 3 Advanced 0001 00 0007FF 00E 000 00E 3FF Eh Deprecated Eh ZSL El Linker SS Commands SS Objects and Libraries EY Address Spaces Sk Warnings Eh Output 7 Debugger Note Cancel Help Figure 62 Address Spaces Page of the Project Settings Dialog Box Memory ranges are used to determine the amount of memory available on your target sys tem Using this information Z8 Encore developer s environment lets you know when your code or data has grown beyond your system s capability The system also uses mem ory ranges to automatically locate your code or data The Address Spaces fields define the memory layout of your target system The Address Spaces page of the Project Settings dialog box allows you to configure the ranges of mem ory available on your target Z8 Encore microcontroller These ranges vary from processor to processor as well as from target system to target system UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZDS II divides Z8 Encore memory into several spaces some of which are available only on selected processor types ROM The ROM space is used for code storage and can also be used for the storage of constant data The ROM memory is located at program addresses 0000H xxxxH where xxxxH is the highest location in program memory e RData register data
494. t Does not flag warnings for obsolete features UM013033 0508 Compatibility Issues Index Symbols Bytes drop down list box 114 include 66 68 pragma alias 440 pragma asm 143 pragma cpu 441 pragma globalcopy 441 pragma globalcse 441 pragma globaldeadvar 441 pragma globalfold 441 pragma interrupt 140 pragma intrinsics 441 pragma jumpopt 442 pragma localcopy 442 pragma localcse 442 pragma localfold 442 pragma localopt 442 pragma noalias 440 pragma nobss 442 pragma noglobalcopy 441 pragma noglobalcse 441 pragma noglobaldeadvar 441 pragma noglobalfold 441 pragma nointrinsics 441 pragma nojumpopt 442 pragma nolocalcopy 442 pragma nolocalcse 442 pragma nolocalfold 442 pragma nolocalopt 442 pragma noopt 442 pragma nooptlink 443 pragma nopeephole 443 pragma nopromote 443 pragma nosdiopt 443 pragma nostkck 443 pragma nostrict 444 pragma optlink 442 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual EILOU s pragma optsize 443 pragma optspeed 443 pragma peephole 443 pragma PRAM 146 pragma promote 443 pragma sdiopt 443 pragma stkck 443 pragma strict 443 pragma using 440 warning directives 147 261 amp and 289 multiply 292 add 289 ENDIF 250 SBREAK 252 253 SCONTINUE 252 253 SELSE 250 SELSEIF 250 SIF 249 250 255 SSREPEAT 250 252 255 SUNTIL 252 SWEND 253 SWHILE 249 253 256 COMMENT directive 227 ENDSTR
495. t 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 are 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zzilogi Find in Files Find 2 In file types c h asm s inc Cancel In folder C Program Files ZiLOG ZDSII_Z8Encore _4 11 0 samples T uto Me Match whole word only D Look in Subfolders Match case Output to pane 2 Figure 44 Find in Files Dialog Box 2 Enter the text 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 EJ or the In Folder drop down list box to select where the
496. t Description Build F7 To build your file and or project Stop Build Ctrl Break To stop the build of your file and or project UM013033 0508 Using the Integrated Development Environment Debug Menu Shortcuts Zilog Developer Studio ll Z8 Encore User Manual 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 F5 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 UMO13033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Using the ANSI C Compiler The following sections provide you information on writing C programs with the ANSI C Compiler Language Extensions on page 132 Type Sizes on page 148 Predefined Macros on page 149 Calling Conventions on
497. t constant 32 bits UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual d Example DF 0 1 0 2 Reserve space for 2 32 bit single precision signed floating point numbers Initialize the first with 0 1 and the last with 0 2 DF 5 Reserve space for 1 word signed floating point number and initialize it to 0 5 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 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 When used for an ASCII character string as in the first example here each letter gets 16 bits with the upper 8 bits zero DW24 Declaration Type Synonyms word24 trio DW24 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Syntax DW24 word data 24 bits Examples dw24 123456 Reserve one 24 bit entity and initialize it with 123456 trio 789abc Reserve one 24 bit entity and initialize it with 798
498. t library modules to be linked into the result file commas of Output page Output File Name field string path and file Sets the output file path and name name excluding file extension padhex Output page Fill Unused Hex File Bytes with OxFF check TRUE FALSE box pram Address Spaces page Use PRAM field string min max for example 00 FF praminuse Address Spaces page Use PRAM check box true false Valid for the Z8 Encore XP F1680 Series devices only rdata Address Spaces page RData field string min max for example 00 FF relist Output page Show Absolute Addresses in Assembly Listings TRUE FALSE check box rom Address Spaces page ROM field string min max for Sets the size range for the ROM memory space example 00 FF sort Output page Sort Symbols By buttons string startuplnkcmds Objects and Libraries page Use Standard Startup Linker string standard or Commands check box included startuptype Objects and Libraries page C Startup Module area string standard or included useadddirectives Commands page Additional Directives check box TRUE FALSE usecrun Objects and Libraries page C Runtime Library check box TRUE FALSE Toggles the inclusion of the C run time library undefisfatal Warnings page Treat Undefined Symbols as Fatal check box TRUE FALSE warnisfatal Warnings page Treat All Warnings as Fatal check box TRUE FALSE warnoverlap Warnings page Warn on Segment Overlap check box TRUE FAL
499. t 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 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 NOTE See BASE OF Versus LOWADDR OF on page 290 for an explanation of the difference between these two operators Multiply The Multiply operator is used to multiply two expressions Syntax expression expression 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 digits UM013033 0508 Using the Linker Locator Zilog Developer Studio ll Z8 Encore User Manual 293 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
500. t_const gt gt TITLE lt string_const gt gt UNION gt lt ident gt VAR lt expression gt gt WARNING lt string_const gt gt WITH lt ident gt lt array_definition gt gt type elements gt lt initvalue gt lt initvalue gt UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual ZILOQ z lt type gt gt BFRACT gt BLKB gt BLKL gt BLKW gt DB gt DD gt DF gt DL gt DW gt DW24 gt FRACT gt UBFRACT gt UFRACT lt elements gt gt lt int_const gt lt initvalue gt gt lt instances gt lt value gt lt instances gt gt lt int_const gt lt value gt gt lt expression gt lt string_const gt lt expression gt gt C expression7 gt lt expression gt lt binary_op gt lt expression gt gt lt unary_op gt lt expression gt gt lt int_const gt gt float const gt label gt HIGH lt expression gt gt LOW lt expression gt gt OFF SET lt expression gt lt binary_op gt gt gt gt gt gt gt gt lt lt gt amp gt gt lt unary_op gt gt gt Pa gt int const gt digit digit _ gt hexdigit hexdigit 8H gt bindigit bindigit _ B gt lt char_const gt lt char_const gt gt any UM013033 0508 Using the Ma
501. ta address E000 and can have a maximum size of 512 or 1024 bytes depending on your device If you deselect the PRAM check box this memory is not available to the compiler Also the compiler does not know if this memory is reconfigured as additional Register RAM memory without the user expanding the Linker Address EData range as described below The PRAM can be used as additional on chip Register RAM by setting the PRAM M option bit low in the device option bits When the PRAM M option bit is set the low the PRAM at 0xE000 is no longer available and the memory is used as additional Register RAM If you want to map PRAM to Register RAM you need to increase the range for EData in the Address Spaces page to include the appropriate amount of PRAM and set the option bit low For example FLASH OPTION1 OxFD Then if your device supports 0x800 bytes of Register RAM and 0x400 bytes of PRAM the EData range can be extended to 0xBFF by mapping the PRAM to Register RAM In this example the new address range for Rdata is 0x0 OxFF and the new address range for Edata is 0x100 0xBFF When the address range is extended the complier takes full advantage of the extra memory The following sections describe how to use the Memory window Changing Values on page 316 Viewing Addresses on page 316 Filling Memory on page 317 Saving to a File on page 318 Loading from a File on page 319 Performing a Cyclic Redundancy
502. te C Listing Files lis check box TRUE FALSE listinc Listing Files page With Include Files check box TRUE FALSE UM013033 0508 Only applies if 1ist option is currently true Using the Command Processor Zilog Developer Studio ll Z8 Encore User Manual Table 14 Compiler Options Continued Description or Corresponding Option in Project Settings Option Name Dialog Box Acceptable Values model Code Generation page Model L Large S Small Selects the memory model Select S for a small memory model which is the most efficient model Select L for a large memory model which is less efficient than the small model The default is L optlink Code Generation page Frames TRUE for static Uses a static frame for local variables and function arguments frames FALSE for This switch is required if the supplied run time library is used dynamic frames Although this switch is not required in other cases it results in smaller faster executables by minimizing use of the stack optspeed Toggles optimizing for speed TRUE optimize for speed FALSE optimize for size promote Deprecated page Disable ANSI Promotions check box TRUE FALSE NOTE This option is deprecated FALSE disables the ANSI promotions reduceopt Code Generation page Limit Optimizations for Easier TRUE FALSE Debugging check box regvar Advanced page Use Register Variables off normal aggressive stdinc Preprocessor
503. te a new library with these changes included on page 333 How can I use standard I O calls like printf and getch on page 334 What is the difference between the Interrupt mode and the Poll mode in the UARTs on page 335 What are the default settings for the UART device on page 335 How can I change the default UART settings for my application on page 335 T am using the UART in the interrupt mode Why do I seem to lose some of the data when I try to print or try to receive a large amount of data on page 335 When I call open UARTx function by configuring it in INTERRUPT mode the control never comes back to my program and my program behaves indifferently Why is this on page 335 Where can I find sample applications that demonstrate the use of ZSL on page 335 I have used init uart and other functions provided in the RTL Do I need to change my source code because of ZSL on page 336 Zilog Standard Library Notes and Tips Zilog Developer Studio ll Z8 Encore User Manual ZILOU WHAT IS ZSL The Zilog Standard Library ZSL is a set of library files that provides an interface between the user application and the on chip peripherals of the ZDS I microprocessors controllers WHICH ON CHIP PERIPHERALS ARE SUPPORTED Version 1 0 of ZSL supports UARTs and GPIO peripherals WHERE CAN I FIND THE HEADER FILES RELATED TO ZILOG STANDARD LIBRARIES The header files relat
504. ted 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 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 e Select the Automatically Reload Externally Modified Files check box to automatically reload externally modified files This option is not selected by default 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 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 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilogi Options General Editor Debugger V Save files before build Iv Always rebuild af
505. tements associated with the SELSETF directive are executed 3 Ifall conditions on the 1F and SELSEIF directives are false at execution time and an SELSE directive is present the object code generated from the statements associated with the SELSE directive are executed 4 Ifno tested condition is true and if no SELSE directive is specified no statements in the structured assembly block are executed SSREPEAT Sequence of Operations The following sequence of operations is performed in processing the SREPEAT struc tured assembly test directives 1 The assembler generates object code to evaluate the conditions specified on the SUNTIL directive and on any optional SBREAK and SCONTINUE directives 2 Atexecution time the object code generated from statements in the structured assembly block are executed until the specified condition is true UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual 256 3 At execution time object code generated from BREAK directives is executed at the point where it appears in the block If no condition is specified on the SBREAK condition or if the condition is true the SREPEAT loop is exited 4 At execution time object code generated from CONTINUE directives is executed at the point where it appears in the
506. ter Variables option compiler regvar page 425 page Generate Printfs Inline option compiler genprintf Bit Field Packing option compiler bfpack Project Settings Deprecated Place Const Variables in ROM option compiler const page 425 page Disable ANSI Promotions option compiler promote Project Settings Librarian Output File Name option librarian outfile page 427 page Project Settings ZSL page Include Zilog Standard Library option middleware usezsl page 429 Peripheral Support Ports option middleware zslports Uarts option middleware zsluarts Project Settings Commands Always Generate from Settings option linker createnew page 427 page Additional Directives option linker useadddirective Edit Additional Linker option linker directives Directives dialog box Use Existing option linker linkctlfile Project Settings Objects Additional Object Library Modules option linker objlibmods page 427 and Libraries page Standard option linker startuptype only available for Static Included in Project option linker startuptype Library projects Use Standard Startup Linker option linker startuplnkcmds Commands C Runtime Library option linker usecrun Floating Point Library option linker fplib Zilog Standard Library Peripheral option middleware usezsl page 429 Support UM013033 0508 Using the Command Processor 410 Zilog Developer Studio ll Z8 Encore User Manual Z itan POY an Ta
507. ter configuration activated Automatically reload externally modified files Load last project on startup Show the full path in the document window s title bar IV Save restore project workspace Command Processor History Commands to keep 15 Clear DK Cancel Help Comcel Heb Figure 88 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 UM013033 0508 Using the Integrated Development Environment Options General Editor Debugger Zilog Developer Studio ll Z8 Encore User Manual Zio us File Type Tabs Tab Size 4 C Insert Spaces Keep Tabs Iv Auto Indent Font Font Courier Size 10 Select Font Color Default Text Selection Number perator Comment Keyword moo e Foreground Background Sample hAaBbCcExYyZz Cancel Help Figure 89 Options Dialog Box Editor Tab Select a file type from the File Type drop down list box You can select C files assembly files or other files and windows 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 Select the Auto Indent check box if you want the IDE to automatic
508. ter 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 if 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 include lt stdlib h gt double strtod 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 value causes underflow zero is returned and the macro errno acquires the value ERANGE Example char ptr char s 0 1456 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual A 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
509. ters 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 can only be defined once The maximum label length is 129 characters Labels that can be interpreted as hexadecimal numbers are not allowed For example ADH ABEFH cannot be used as labels See Labels on page 263 and Hexadecimal Numbers on page 223 for more informa tion 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 an 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 Z8 Encore CPU instructions see the eZ8 CPU Instruction Set Description section in the eZ6 CPU User Manual UM0128 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 226 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 invoke the assembler and ignore the case of user defined identifi
510. th additional Zilog specific func tions to program the Z8 Encore peripherals These additional functions together form the Zilog Standard Library ZSL and are described in the Z8 Encore Using Zilog Standard Library ZSL White Paper WP0010 The following sections describe the use and format of the nonstandard Zilog specific run time libraries Zilog Header Files on page 162 Zilog Functions on page 164 The Zilog specific header files provided with the compiler are listed in the following table and described in Zilog Header Files on page 162 Table 2 Nonstandard Header Files Header Description eZ8 h Z8 Encore defines and functions sio h Serial input output functions 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 is C Program Files ZiLOG ZDSII_ Z8ENCORE lt ver sion where lt version gt might be 4 11 0 or 5 0 0 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual begin with an underscore are also reserved If the program redefines a reserved external identifier even with a
511. th 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 the n directive setjmp Saves its calling environment in its jmp buf argument for later use by the 1ongjmp func tion Synopsis include lt setjmp h gt int setjmp jmp buf env 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual T I JR E f Z f I V MV M 382 amu Example int i jmp buf env i setjmp env longjmp env i sin Computes the sine of x measured in radians A large magnitude argument can yield a result with little or no significance Synopsis include lt math h gt double sin double x Returns The sine value Example double x 1 24 double y y sin x sinh Computes the hyperbolic sine of x A range error occurs if the magnitude of x is too la
512. the startup code does not have to copy the PRAM code from rom to its PRAM location This can be achieved by adding the following code just before segment startup COPYPRAM S ET FALSE For Z8 Encore microcontroller devices with small Flash memory sizes especially the pre ceding steps can be very useful to reduce the code size of the C startup module SEGMENT NAMING The compiler places code and data into separate segments in the object file The different segments used by the compiler are listed in the following table Table 4 Segments Segment Description NEAR DATA near initialized global and static data NEAR BSS near uninitialized global and static data NEAR TEXT near constant strings FAR DATA far initialized global and static data FAR BSS far uninitialized global and static data FAR TEXT far constant strings ROM DATA rom global and static data ROM TEXT rom constant strings PRAMSEG Program ram code fname TEXT rom code for file fname fname is translated in some cases VECTORS nn rom interrupt vector at address nnn STARTUP rom C startup LINKER COMMAND FILES FOR C PROGRAMS This section describes how the Z8 Encore linker is used to link a C program For a more detailed description of the linker and the various commands it supports see Using the Linker Locator on page 275 A C program consists of compiled and assembled object module files compiler libr
513. 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 8 To check the memory click Memory The View Edit Memory dialog box is displayed In the View Edit Memory window you can do the following Select the appropriate memory space from the Space drop down list box Move to a different address by typing the address in the address field and pressing the Enter key Fill Memory on page 114 Save Memory to a File on page 115 Load a File into Memory on page 116 Perform a Cyclic Redundancy Check on page 117 9 Select the Erase Before Flashing check box to erase all Flash memory before writing the hex file to Flash memory You can also delete the Flash memory by clicking ERASE Clicking ERASE Caution deletes only the pages that are selected 10 Select the Use Page Erase check box if you want the internal Flash to be page erased Deselect this check box if you want the internal Flash to be mass erased 11 Select the Close Dialog When Flash Complete check box to close the dialog box after writing the hex file to Flash memory 12 If you want to use the serialization feature or want to check a serial number that has already been programmed at an address see Serialization on page 113 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore
514. the result is correct even though it is too large to fit into a char With ANSI promotions disabled the conversion is not done until a larger type is explicitly called for in the code Therefore the addition is done with chars the overflow occurs and only after that is the result converted to int By the ANSI Standard these special promotions are only applied to chars and shorts If you have the analogous code with the sum of two ints being assigned into a long the compiler does not automatically promote the ints to longs before adding them and if the sum overflows the int size then the result is always wrong whether ANSI promotions are in effect or not In this sense the ANSI promotions make the handling of char types incon sistent compared to the treatment of other integer types UM013033 0508 Using the Integrated Development Environment 75 Zilog Developer Studio ll Z8 Encore User Manual gt ran ILU LUI EN M 76 It is better coding practice to show such promotions explicitly as in the following int i int a int b Then you get the same answer whether promotions are enabled or disabled If instead you write char c a b then even with ANSI promotions enabled you do not get the right answer You did not anticipate that the arithmetic operation can overflow an 8 bit value With ANSI promo tions disabled the value of the expression 136 is truncated to fit into the 8 bit result again yielding the valu
515. the same as 1ong which is allowed by the standard TYPE SIZES The type sizes for the basic data types on the Z8 Encore C Compiler are as follows int 16 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 Z8 Encore C Compiler are as follows near pointer 8 bits far pointer 16 bits rom pointer 16 bits All data are aligned on a byte boundary Avoid writing code that depends on how data are aligned UM013033 0508 Using the ANSI C Compiler PREDEFINED MACROS The Z8 Encore C Compiler comes with the following standard predefined macro names UM013033 0508 AUS SIZED BY TYPE _ BACKWARD COMPATIBLE BITFIELDS _ BITFIELDS OVERLAP AUS __BITFIELDS PACK I2R __ CONST IN RAM CONST IN ROM CPU NAME DATE FIE LINE NEW AU AT TYPE CHANGE STDC TME Zilog Developer Studio ll Z8 Encore User Manual Zilog Defined on all Zilog compilers and set to 0 or 1 as to whether the size of a bitfield depends on the type s of the bitfield members Defined on all Zilog compilers and set to 0 or 1 as to whether the implementation of bitfields is compatible with that used before January 2007 Defined on all Zilog compilers and set to 0 or 1 as to whether a bitfield member that requires more bits than remains in the current byte must begin a new byte A 0 indicates that it does Defined on all Zilog compile
516. 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 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 277 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 Z8 Encore there are two available libraries the C run time library and the Zilog Standard Library ZSL The subset of the run time library dedicated to floating point operations also h
517. ting 358 367 R R 225 rand function 348 377 RAND MAX macro 348 RANGE command 285 Range error generating 91 RData 90 READ FLASH function 168 READ NVDS function 170 READ NVDS GET STATUS function 170 Reading input 378 readme txt location of xx realloc function 349 377 Rebuild All button 18 rebuild script file command 430 Index Red octagon 311 327 reentrant keyword 139 Refresh button 100 Registers changing values 312 preserving 159 Registers window 312 Registers Window button 27 Regular Expression check box 49 51 Relational operators in assembly 221 Release configuration 103 Relocatable segments 211 214 276 Remainder computing 360 Remove All Breakpoints button 21 27 Remove All button 52 329 Remove Breakpoint command 330 Remove button 52 330 Replace All button 51 Replace button 51 Replace dialog box 50 51 Replace With field 51 Replace With list box 51 Reserved words in assembly 218 in headers 161 Reset button 20 25 Reset to Symbol main Where Applicable check box 126 reset script file command 430 Return values 156 159 Revision history iii RI function 171 Right click menus in Edit window 34 ROM memory 90 rom storage specifier 135 ROM DATA segment 181 rom data segment 212 ROM TEXT segment 181 rom text segment 212 RR 225 UM013033 0508 Zilog Developer Studio ll Z8 Encore User Manual ZILOQ ac RTL definition 336 switching to ZSL 336 Run Command button 22 Run to
518. tion left of the file window The cursor can be quickly positioned on a lines containing bookmarks UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi Hello world 3 3 3 3C 3 3 3 3 3 3 3 3 FE 3 3 3 FE 3 FE 3 9 3 FE 3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 3 3 3 3 3 3 9 3 39 3 9 3 3 NI include lt stdio h gt define ZDS NAME ZiLOG Developer Studio void main int d int l s 5 int chs static char welcome Welcome to ZDS_NAME static char s Hello world puts welcome puts s putchar n end of file x Figure 26 Bookmark Example To insert a bookmark position the cursor on the desired line of the active file and perform one of the following actions UMO13033 0508 Right click in the Edit window and select Insert Bookmark from the resulting context menu Select Toggle Bookmark from the Edit menu Type Ctrl F2 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Zilog a Hello world HE 3 3 3 FE 3 39 3 3 3 3 3 3 3 3 9 9 FE 3 TE 9 9 3 3 9 TE TE 3 9 2 3 3 9 9 9 3 3 9 TE TE 3 3 9 TE 3 9 TE 2E TE 3 9 2 TE 3
519. tions selected in the Debugger tab of the Options dialog box If it is a C project ZDS II resets to the main function if it is found If ZDS II is already in Debug mode when the Download Code command is selected the following process is executed 1 Resets the device using a software reset 2 Downloads the program You might need to reset the device before execution because the program counter might have been changed after the download Verify Download Select Verify Download from the Debug menu to determine download correctness by comparing executable file contents to target memory Stop Debugging Select Stop Debugging from the Debug menu to exit Debug mode 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 ZDS II is not in Debug mode the Reset command starts a debug session using the fol lowing process 1 Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box 4 Downloads the program 5 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If it is a C project ZDS II resets to the main function if it is found UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual If ZDS II is already in Debug mode the Re
520. tively the values of the preprocessing macros FILE and __LINE__ on the serial port It then calls abort which calls exit If expression is true that is evaluates to nonzero the assert macro returns no value UMO13033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual up On Release builds strictly speaking when NDEBUG is defined on the compile line the assert macro has no effect Example include lt assert h gt char str COMPASS int main void assert str 0 C OK nothing happens assert str 0 B Oops something wrong here return 0 Character Handling lt ctype h gt The lt ct ype 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 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 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 Cha
521. to the Project 200 ii De CEA ETE ER a bs ae 6 Set Up the Project vna dl Gow Reed eb us 8 Save the Project so oss edere na OO dae hh doe adit ce tse rs 14 Using the Integrated Development Environment cece cece cececeees 15 TOO ats i eos bh dad bre del aia oda detiene dut 16 File Toolb t sreci or A ten eRe anne a PRIN 16 Build Toolbar esses eee nem e Er ere y Gras 18 Find Toolbar ciar ee e c OR PCR ARE eo dot ea n 21 Command Processor Toolbar 1 0 0 unauna nannaa 22 Bookmarks Toolbar ose edet pete RR ACE RR ache ew RS 22 Debug Toolbar 2 0 0 ccc e mn 23 Debug Windows Toolbar 0 0c ccc e 27 bn T 29 Project Workspace Window 0 0 cece ccc cette e 29 Edit Window osuna bte edo hhh ea qub Odi ehh Abend 30 Output Windows o oooooooocor ehh 35 Menu Bar dd Seach BANE aio ER Ae eda 37 File Men s ues eR ea rer oe ee dese ea du o eu A e n 38 Edit Men coelo eed eh ares eis bane pa epee E PERITI PEE 47 View Menu AAA a een alee 53 Project MENU s o ahd onc taa oer Re eR eS Hah Ted ME agen ag eg 54 Build MENU 2 221 eR b oH oe e did Dat onda sod dda 102 UM013033 0508 Table of Contents Zilog Developer Studio ll Z8 Encore User Manual ran ILU U V MV M Debug Menu cuco ata ewe Pewee hs fee e e E pe d a pac tale dads 106 Tools Menu eene e rRRU DURER HRHERFREGTRE EFE RE ae PEE ee Reyes 110 Window Men serere bd Rete dete en oem RON dt ICE RIA REOR s 127 Help
522. ton 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 Calculate Checksum File Name C Program Files ZiLOG ZDSII_Z8Encore _4 11 0 samp El Close Figure 84 Calculate Checksum Dialog Box Checksum 0x524F 3 Click Close Firmware Upgrade Selected Debug Tool NOTE This command is available only when a supporting debug tool is selected see Debug Tool on page 100 Use one of the following files for instructions on how to upgrade your firmware e USB Smart Cable lt ZDS Installation Directory gt bin firmware USBSmartCable USBSmartCable upgrade information txt e Ethernet Smart Cable lt ZDS Installation Directory gt bin firmware EthernetSmartCable EthernetSmartCable upgrade information txt UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual ZIlOg us 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 for the whole internal Flash memory 1 Select Show CRC from the Tools menu The Show CRC dialog box is displayed with the result Show CRC CRC 0xB038 Figure 85 Show CRC Dialog Box Customize The Customize dialog box contains the following tabs e Customize Toolbars Tab on page 119 e Customize Commands Tab on
523. ton to open one of ten Memory windows Space Ron Address C 0000 Figure 102 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 a C to denote the code address space with an R to denote the RData address space or with an N to denote the NVDS address space NOTE For RData the Memory window shows the whole internal data memory The Z8 Encore XP F082A Series and non 24K F1680 devices contain a Non Volatile Data Storage NVDS element with a size of up to 128 bytes This memory features an endurance of 100 000 write cycles For more information about NVDS see the Non Volatile Data Storage chapter of the Z8 Encore XP F0824A Series UM013033 0508 Using the Debugger Zilog Developer Studio ll Z8 Encore User Manual Product Specification PS0228 The Z8 Encore XP F1680 Series devices feature an area of Program RAM that can be used for storing some code in RAM This area can be used to help keep device operating power low by for example storing interrupt service routines here that would activate the code in Flash memory when some external event has occurred PRAM when available is an optional feature If you want to use this memory as Program RAM set the desired address range in the PRAM field in the Address Spaces page of the Project Settings dialog box PRAM begins at da
524. 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 Before Using Technical Support Before you use technical support consult the following documentation UM013033 0508 readme txt file Introduction XX Zilog Developer Studio ll Z8 Encore User Manual Zilog xxi 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 ZILOGINSTALLWMZDSII 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 Z8Encore ZNEO eZ80Acclaim Crimzon or Z8GP version is the ZDS II version number For example version might be 4 11 0 or 980 0 e FAQ 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 fi
525. tory lt ZDS Installation Directory gt samples Tutorial 3 Select the main c file and click Add The main c file is displayed under the Standard Project Files folder in the Project Workspace window on the left side of the IDE UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog sample ZDS II Z8 Encore Family DER Eje Edit View Project Build Debug Tools Window Help D E G CD Smp f 9555 gt a E I x Standard Project Files El main c External Dependencies gt a Build Debug Find in Files Find in Files 2 Messages Command ll 4 For Help press F1 Ln 1 Col 1 sei OVR READ 7 Figure 8 Sample Project NOTE To view any of the files in the Edit window during the quick tour 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 those tools For more information see Settings on page 55 UM013033 0508 Getting Started Zilog Developer
526. ts Zilog Developer Studio ll Z8 Encore User Manual o A AN Eg AN kts LA Y MA Moving to a Breakpoint 0 0 0 ccc cette ene n ene 328 Enabling Breakpoints 2 0 cc eee cee eee etn enn eee 328 Disabling Breakpoints 0 c cece teen eee 329 Removing Breakpoints 0c cece eee teen een ees 329 Zilog Standard Library Notes and Tips 0 cece cece cece rere e cee evene 331 Whatis ZSE RC m 332 Which on chip peripherals are supported 1 2 0 0 cece cee eee 332 Where can I find the header files related to Zilog Standard Libraries 332 What is the zsldevinit asm file 2 2 ketenes 332 What initializations are performed in the zsldevinit asm file o 332 What calls the open periphdevice function 00 cee ee eee 332 When I use Zilog Standard Libraries in my application and build from the command line why do I see unresolved errors o o ooooo oo 333 I do not use the standard boot up module but I have manually included Zilog Standard Libraries When I link my code with the library why do I get an unresolved symbols error 00 000 c eee eee eee eee 333 Where can I get the ZSL source files 2 2 eee eee eee 333 I need to change the ZSL source code How can I generate a new library with these changes included 0 0 ccc ccc cece eens 333 How can I use standard I O calls like printf and getch
527. tton uses the following process 1 ZDS II performs a hardware reset 2 Configures the device using the settings in the Configure Target dialog box 3 Iffiles have been modified ZDS II asks Would you like to rebuild the project before downloading the modified program If there has been no file modification the code is not reloaded For the Serial Smart Cable ZDS II performs an on chip debugger reset Go Button Click the Go button to execute project code from the current program counter If not in Debug mode when the Go button is clicked the following process is executed l Initializes the communication to the target hardware 2 Resets the device 3 Configures the device using the settings in the Configure Target dialog box UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 4 Downloads the program 5 Configures and executes the debugger options selected in the Debugger tab of the Options dialog box If it is a C project ZDS II resets to the main function if it is found 6 Executes the program from the reset location 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 i
528. uart int port unsigned long freq unsigned long baud Returns Returns 0 if initialization is successful and 1 otherwise Example include lt stdio h gt include lt sio h gt void main init uart UART0 DEFFREQ DEFBAUD printf Hello UARTO n Write to _UARTO _DEFFREQ is automatically set from the IDE based on the clock frequency setting in the Configure Target dialog box See Setup on page 97 kbhit The kbhit function is a Zilog function that determines whether there 1s receive data avail able on the selected UART UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog 168 Synopsis include lt sio h gt unsigned char kbhit void Returns Returns if there is receive data available on the selected UART otherwise it returns 0 Example include lt sio h gt unsigned char hit void main init uart UARTO DEFFREQ DEFBAUD hit kbhit Check if any character available on _UARTO 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 The putch function is a Zilog function that sends a character to the selected UART and returns the error status Synopsis include lt sio h gt reentrant unsigned char putch char ch Returns A zero is returned on success a nonzero is returned on f
529. uble cos double x Calculates cosine of x double sin double x Calculates sine of x double tan double x Calculates tangent of x 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 Exponential and Logarithmic 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 double log double x Calculates natural logarithm of x double log10 double x Calculates base 10 logarithm of x double modf double value Breaks down x into integer the value returned by modf double iptr and fractional n parts UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Z i aoe 6 M i 345 amu o Power double pow double x double y Calculates x to the y double sqrt double 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 Nonlocal Jumps lt setjmp h gt The lt set3mp h gt header declares two functions and one type for bypassing the normal fu
530. ue for an object of type short int UCHAR MAX Maximum value for an object oftype 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 If the 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 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 UM013033 0508 C Standard Library Zilog Developer Studio ll Z8 Encore User Manual Mathematics lt math h gt The lt math h gt 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 Z8 Encore 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 exter
531. uency WRITE FLASH rom const 0x2f00 x write to Flash x READ FLASH rom const 0x2f00 read from Flash NOTE Do not write to Flash memory more than twice To write to Flash memory more than twice you need to do a page erase When you use the WRITE_FLASH function to write to Flash the target clock frequency needs to be initialized using the INIT_FLASH function see page 166 Beginning with the ZDS II for Z8 Encore release 4 8 there is a slight change in the func tion prototype for WRITE_FLASH Previous Prototype dif defined Z8F642 void reentrant WRITE FLASH rom const void addr char val else UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog 176 void intrinsic reentrant WRITE FLASH rom const void addr char val endif New Prototype void reentrant WRITE FLASH rom const void addr char val For most Z8 Encore microcontroller variants the intrinsic keyword has been deleted in the ZDS II release 4 8 0 This change is taken care of automatically as long as you are using the standard Zilog library version of WRITE_FLASH and including the standard header file ez8 h However since the new standard header uses the new prototype if you have customized WRITE_FLASH in your application you need to make modifications so that the header and function declarations agree WRITE_NVDS The WRITE NVDS function is a Zilog fu
532. umbers are 32 bit IEEE standard single precision values The assembler detects an expression oper and that is out of range for the intended field and generates appropriate error messages UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Character Strings Character strings consist of printable ASCII 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 treated as a character constant The assembler does not automatically insert null character 0 s at the end of a text string A character string cannot be used as an operand For example DB STRING a string DB STRING O C printable string DB STRING S embedded quote DB a b c character constants EXPRESSIONS In most cases where a single integer or float value can be used as an operand an expres sion can also be used The assembler evaluates expressions in 32 bit signed arithmetic or 64 bit floating point arithmetic Logical expressions are bitwise operators The assembler detects overflow and division by zero errors The following sections describe the syntax of writing an expression Arithmetic Operators on page 221 Relational Operators on page 221 Boolean Operators on page 2
533. ur sion and allow reentrancy Dynamic frames are the usual way of storing information about an instance of a function call Passing argument in dynamic frames is done by push ing the arguments on the stack in reverse right to left order Reentrant Keyword This keyword notifies the compiler that in an application that otherwise uses static frames a dynamic frame must be used for any function declared reentrant For example to declare the recursive fn function as using a dynamic call frame use the following syntax reentrant int recursive fn int k if k 0 return 1 return k recursive fn k 1 When the static call frame option is selected all call frames are assumed static by the com piler unless the reentrant storage class is used in the function declaration Obviously if large numbers of functions in an application must be declared reentrant the benefit of using static frames diminishes proportionately When the dynamic call frame option is selected all call frames are assumed reentrant by the compiler UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Interrupt Support To support interrupts the Z8 Encore C Compiler provides the following features e interrupt Keyword on page 140 Interrupt Vector Setup on page 140 interrupt Keyword Functions that are preceded by pragma interrupt or are associated with the interrupt storage class are design
534. ur responsibility to make sure these settings will work for you There are three issues to be aware of First all optimizations are applied which can make debugging somewhat confusing if this becomes troublesome try changing to the Small But Debuggable configuration Second the use of the small model restricts the amount of data space that is available which could cause problems see Memory Models on page 137 for details Third static frames can only be used if your entire application obeys certain restrictions which are described in Call Frames on page 138 User Defined When the User Defined configuration is selected the individual settings for the Limit Optimizations for Easier Debugging Memory Model and Frames options can be changed individually This gives you the maximum freedom to set up your project as you choose and to experiment with all possible settings 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual 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 co
535. uration Debug v 5e General Sa Assembler 2 flc h Code Generation is Listing Files 3 Preprocessor Sil Advanced 7 Additional Directives Ed Sil Deprecated s C Use Existing Fig Linker a no E SS Commands h Objects and Libraries 3 Address Spaces SS Warnings Fh Output Eh Debugger Always Generate From Settings Note Selecting the Use Existing option disables all configurable linker options OK Cancel Help Figure 58 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 83 NOTE Even though selecting the Always Generate from Settings check box 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
536. ut to display installed product and component version information SHORTCUT KEYS The following sections list the shortcut keys for the Zilog Developer Studio II File Menu Shortcuts on page 129 Edit Menu Shortcuts on page 129 Project Menu Shortcuts on page 130 Build Menu Shortcuts on page 130 e Debug Menu Shortcuts on page 131 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 Alt 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 command action you performed Redo Ctrl Y To redo the last command action you performed Cut Ctrl X To delete selected text from a file and put 1t 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual Option Shortcut Description Select All Ctrl A To highlight all text in the active file Show Ctrl Shift
537. vided in each of two libraries e A limited C Serial IO library e A full fledged Zilog Standard Library ZSL Zilog Developer Studio ll Z8 Encore User Manual iH JE Sa fl a 8 I f y A i 1 A J YY Z V V M 164 When you select ZSL these functions are linked from ZSL otherwise these functions are linked from the C Serial IO library Zilog Functions The following functions are Zilog specific DI on page 164 e EP on page 165 e getch on page 165 e INIT FLASH on page 166 e init uart on page 167 e kbhit on page 167 e putch on page 168 READ FLASH on page 168 READ NVDS on page 169 READ NVDS GET STATUS on page 170 e RI on page 171 e select port on page 171 e SET VECTOR on page 172 e TDI on page 174 e WRITE FLASH on page 175 e WRITE_NVDS on page 176 e WRITE NVDS GET STATUS on page 176 DI The DI function is a Zilog function that disables all interrupts This is an intrinsic function and is inline expanded Synopsis include lt eZ8 h gt intrinsic void DI void UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual zilog ses Example include lt eZ8 h gt void main void DI Disable interrupts EI The EI function is a Zilog function that enables all interrupts This is an intrinsic function and is inline expanded Synopsis include lt eZ8 h gt int
538. void va_start va_list ap parmN Sets ap to the beginning of argument list type va_arg va_list ap type Returns the next argument from list void va_end va_list ap Should mark the end of usage of ap but has no effect in Zilog implementation Standard Definitions lt stddef h gt 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 Integral type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales 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 UM013033 0508 C Standard Library Functions Zilog Developer Studio ll Z8 Encore User Manual ZILOD Formatted Input Output int printf char format Writes formatt
539. wing e Dock the Project Workspace window e Hide the Project Workspace window Add files to the project Remove the highlighted file from the project Build project files or external dependencies Assemble or compile the highlighted file e Undock the Project Workspace window allowing it to float in the Edit window Edit Window The Edit window on the right side of the developer s environment allows you to edit the files in your project UM013033 0508 Using the Integrated Development Environment startupl asm XREF len neardata XREF low near romdata ENDIF IF COPYERAM XREF _low_fardata XREF len fardata XREF low far romdata NDIF signed char field width field width x signed char precision precision Zilog Developer Studio ll Z8 Encore User Manual Zilog CONST char set begin pointer to firs CONST char set end pointer to last unsigned char pad whole unsigned char pad pre fract Figure 25 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 ofan Ctrl opening or closing brace and press Ctrl E or Ctrl to move the cursor to the matching opening or closing brace This section covers the fo
540. xecutable format defaults to IEEE 695 when you create an executable project 10d To change the executable format see Linker Output Page on page 93 11 Click OK to save all the settings on the Project Settings dialog box The Development Environment prompts 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 12 Click Yes to build the project The developer s environment builds the sample project 13 Watch the compilation process in the Build Output window UM013033 0508 Getting Started Zilog Developer Studio ll Z8 Encore User Manual Zilog sample ZDS II Z8 Encore Family File Edit Yiew Project Build Debug Tools Window Help beug aena ua lon jem m El LJ Standard Project Files El main c EH Extemal Dependencies sample Configuration Debug Project settings or configuration has changed forcing Rebuild C NPROGRA 1 ZiLOG ZDSII 1 0 samplessTutorial main c Linking Build completed omm TS o Build Debug A Find in Files Find in Files 2 A Messages Command La Ln 1 Col 1 ae OVR READ 7 Figure 14 Build Output Window When the Build completed message is displayed in the Build Output window you have successfully bui
541. xes which produces executable files in 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 OxFF This option is sometimes required for compatibility with other tools that set otherwise uninitialized bytes to OxFF so that the hex file checksum calculated in ZDS II matches the checksum calculated in the other tools NOTE 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 option is available only when the Intel Hex32 Records executable format is selected 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 UM013033 0508 Using the Integrated Development Environment Zilog Developer Studio ll Z8 Encore User Manual zilogi Debugger Page In the Project Settin
542. y 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 ENDSTRUCT 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 UM013033 0508 Using the Macro Assembler Zilog Developer Studio ll Z8 Encore User Manual Zn E ZIt Og 245 An example structure definition is as follows DATE STRUCT MONTH Dsl DAY DS 1 YEAR DS 2 DSIZE ENDSTRUCT DATE NOTE 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 Nested STRUCT and UNION directives 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 n
543. ype 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 int 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 UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual i IIA fel ILU LI V MV M 204 I 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 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 zero negative or omitted An attempt was made to omit the dimension of an array which is not the rightmost dimension or any dimension of the array was set as less than or equal to zero 186 First dimension of lt name gt
544. ype the following SET PATH PATH C Program Files ZiLOG ZDSII_ Z8Encore 4 11 0 bin The make utility is available in this directory 3 Type PATH again to see the new path 4 Open the project using the IDE UM013033 0508 Running ZDS II from the Command Line Zilog Developer Studio ll Z8 Encore User Manual 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 RUNNING THE ASSEMBLER FROM THE COMMAND LINE To run the assembler from the command line 1 E pa To see the current path type the following in a DOS window PATH To set up the ZDS II bin directory for example C PROGRA 1 ZiLOG ZDSII_Z8Encore 4 11 0 bin in the path type the following C gt SET PATH PATH S C Program Files ZiLOG ZDSII_ Z8Encore 4 11 0 bin The make utility is available in this directory Type PATH again to see the new path Open the make file in a text editor Copy the options in the ASFLAGS section In a Command Prompt window type the path to the assembler the options from the ASFLAGS section on
545. ype to be other than int to save UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual Zilog 145 space The following syntax is provided by the C Compiler to declare them as char or short char enum RED 0 YELLOW BLUE INVALID color short enum EW 0 PEN acmogz ES E qe gt E J status void main void if color RED status FIXED else status OPEN Setting Flash Option Bytes in C The Z8 Encore CPU provides up to two Flash option bytes to configure the device These Flash option bytes can be set in C using the following syntax include lt eZ8 h gt FLASH OPTION1 val FLASH OPTION2 val where FLASH OPTIONI is the Flash option byte at address 0 FLASH OPTION is the Flash option byte at address 1 For example include lt eZ8 h gt FLASH OPTIONI OxFF FLASH OPTION2 OxFF UM013033 0508 Using the ANSI C Compiler Zilog Developer Studio ll Z8 Encore User Manual iH JE ms n PR PS 7 Ha y he V MV M 146 void main void This example sets the Flash option bytes at addresses 0 and 1 as 0xFF 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 Program RAM Support Z8 Encore XP 16K Series Only The Z8 Encore
546. zed linkage calling conventions UM013033 0508 Compatibility Issues Zilog Developer Studio ll Z8 Encore User Manual H 8 JR j j rr u f n i I L V7 LA DK M A pragma nooptlink Disables optimized linkage calling conventions pragma optsize Optimizes code to minimize size pragma optspeed Optimizes code to minimize execution time pragma peephole Enables peephole optimizations pragma nopeephole Disables peephole optimizations pragma promote Enables ANSI integer promotions pragma nopromote Disables ANSI integer promotions pragma sdiopt Performs span dependent instruction optimization This optimization results in branches generated by the compiler taking the shortest form possible This pragma is the default pragma nosdiopt Disables span dependent instruction optimizations pragma stkck Performs stack checking pragma nostkck Does not perform stack checking pragma strict Checks for conformance to the ANSI standard and its obsolescent features These include old style parameter type declarations empty formal parameter lists and calling functions with no prototype in scope When any of these features are used a warning is flagged The UM013033 0508 Compatibility Issues 443 Zilog Developer Studio ll Z8 Encore User Manual 444 compiler requires this switch for proper code generation because it makes use of a static frame pragma nostric
Download Pdf Manuals
Related Search
Related Contents
Black & Decker PW1300 User's Manual Yamaha RX-V2300 Receiver Bedienungsanleitung Manual do usuário TraxBot - ROS Driver Guide v1.1 - ISR Copyright © All rights reserved.
Failed to retrieve file