Zilog Z80380 User Manual

Browse online or download User Manual for Sensors Zilog Z80380. Zilog Z80380 User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 116
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews

Summary of Contents

Page 1 - User’s Manual

UM004001-COR1103380 C-CompilerUser’s Manual

Page 3 - ABOUT THIS MANUAL

ASCII Character SetB–6 UM004001-COR1103p 112 70 Lowercase Pq 113 71 Lowercase Qr 114 72 Lowercase Rs 115 73 Lowercase St 116 74 Lowercase Tu 117 75 L

Page 4

UM004001-COR1103 C–1380 C-COMPILER USER’S MANUALAPPENDIX C PROBLEM/SUGGESTION REPORT FORMIf you experience any problems while using this product, or i

Page 6 - Linking Files

UM004001-COR1103 Glossary-1380 C-COMPILER USER’S MANUALGLOSSARYAABS Absolute ValueAddress Space Physical or logical area of the target system’s Memory

Page 7 - Run Time Environment

GlossaryGlossary-2 UM004001-COR1103Bit A digit of a binary system. It has only two possible values: 0 or 1.BPS Bits Per Second. Number of binary digi

Page 8

UM004001-COR1103 Glossary-3GlossaryControl Section A continuous logical area containing code or user data. Each control section has a name. The linke

Page 9 - LIST OF TABLES

GlossaryGlossary-4 UM004001-COR1103IM Immediate Data Addressing Mode.IMASK Interrupt Mask Register.IMR Interrupt Mask Register.INC Increment.INCW Incr

Page 10

UM004001-COR1103 Glossary-5GlossaryJP Jump.JR Jump Range.Library A File Created by a Librarian. This file contains a collection of object modules that

Page 11 - LIST OF FIGURES

GlossaryGlossary-6 UM004001-COR1103OPC Operation Code.Op Code Operation Code.OTP One-Time Programmable.PCON Port configuration register.PER Peripheral

Page 12

UM004001-COR1103 Glossary-7GlossaryPublic/Global Symbol A programming variable that is available to more than one program file.PUSH Store a Value In t

Page 13 - INTRODUCTION

UM004001-COR1103 xiFigure Page380 C-COMPILER USER’S MANUALLIST OF FIGURESFIGURE 1-1 DEVELOPMENT FLOW . . . . . . . . . . . . . . . . . . . . . . . .

Page 14 - ZDS ENVIRONMENT

GlossaryGlossary-8 UM004001-COR1103SMR Stop Mode Recovery.SN Serial Number.SOIC Small Outline IC.SP Stack Pointer.SPH Stack Pointer High.SPI Serial Pe

Page 15 - MINIMUM REQUIREMENTS

UM004001-COR1103 Glossary-9GlossarySWI Software Interrupt.Symbol Definition Symbol defined when the symbol name is associ- ated with a certain amount

Page 16 - REGISTRY KEYS

GlossaryGlossary-10 UM004001-COR1103USART Universal Synchronous/Asynchronous Receiver/Transmitter. Can handle synchronous as well as asynchronous tra

Page 17 - INSTALLING ZDS

UM004001-COR1103 Glossary-11GlossaryZASM ZiLOG Assembler. ZiLOG’s program development environment for DOS.ZDS ZiLOG Developer Studio. ZiLOG’s program

Page 19 - Introduction Sample Session

UM004001-COR1103 Index-1380 C-COMPILER USER’S MANUALINDEXA–DASCII Character Set . . . . . . . . . . . .B-1Assembly FileGeneration . . . . . . . . . .

Page 20 - Create a File

IndexIndex-2 UM004001-COR1103strpbrk function . . . . . . . . . . . . 4-19strrchr function. . . . . . . . . . . . . 4-20strspn function . . . . . . .

Page 22 - 1–10 UM004001-COR1103

UM004001-COR1103 1–1380 C-COMPILER USER’S MANUALCHAPTER 1 INTRODUCTIONINTRODUCTIONThe 380 C-Compiler conforms to the ANSI’s definition of a “freestand

Page 23 - CONFIGURE SETTINGS

Introduction Introduction1–2 UM004001-COR1103FIGURE 1-1. DEVELOPMENT FLOWZDS ENVIRONMENTZiLOG Developer Studio is an integrated development environme

Page 24 - • Optimization levels

UM004001-COR1103 1–3Introduction Minimum Requirements• Build and link a project file• Compile, assemble and link files• Prepare code for ROM release (

Page 25 - UM004001-COR1103 1–13

Installing the 380 C-compiler Introduction1–4 UM004001-COR1103INSTALLING THE 380 C-COMPILERTo install the 380 C-Compiler, insert the 380 C-Compiler CD

Page 26 - Configuring Warnings

INSTALLING ZDSPerform the following steps to install ZDS: 1. Insert the ZiLOG Developer Studio CD-ROM into the host CD ROM drive. The Emulator Softwa

Page 27 - UM004001-COR1103 1–15

Sample Session Introduction1–6 UM004001-COR1103SAMPLE SESSIONThe 380 C-Compiler is a modular component that is part of the ZDS development environ-men

Page 28 - 1–16 UM004001-COR1103

UM004001-COR1103 1–7Introduction Sample Session9. Click Save. The file name appears in the Project Name field in the New Project dialog box.10.Select

Page 29

ii UM004001-COR1103©2003 by ZiLOG, Inc. All rights reserved. No part of this document may be copied or reproduced in any form or by any means without

Page 30 - Code Generation Configuration

Sample Session Introduction1–8 UM004001-COR11032. Select Set default include path to compiler settings in the Settings window. Selecting this option s

Page 31 - COMPILE A PROJECT

UM004001-COR1103 1–9Introduction Sample Session5. Type the following code in the edit window:#include <stdlib.h>int randnum;int main(){ srand

Page 32 - DOWNLOADING A COMPILED FILE

Sample Session Introduction1–10 UM004001-COR11037. Hold the Control key and select the following files:– libc.lib (standard C library) – lhf.lib (libr

Page 33 - TECHNICAL SUPPORT

UM004001-COR1103 1–11Introduction Sample Session16.Type the following code in the edit window:#include <stdlib.h>int randnum;int main(){ sran

Page 34

Sample Session Introduction1–12 UM004001-COR1103• Warnings• Optimization levels• Preprocessor symbol definitions• Code generation configurationPerform

Page 35 - OVERVIEW

UM004001-COR1103 1–13Introduction Sample Session• The Generate debug information option generates symbolic debug information in the output object modu

Page 36 - DEFAULT MEMORY QUALIFIERS

Sample Session Introduction1–14 UM004001-COR1103Configuring WarningsThe C-Compiler Optimizations page allows the user to control the informational and

Page 37 - I/O ADDRESS SPACES

UM004001-COR1103 1–15Introduction Sample SessionConfiguring Optimization LevelsThe C-Compiler Optimizations page allows the user to select an optimiza

Page 38 - ACCCESING I/O ADDRESS SPACE

Sample Session Introduction1–16 UM004001-COR1103• The Level 2 optimization option performs:– constant propagation– copy propagation– dead code elimina

Page 39 - INTERRUPT FUNCTIONS

UM004001-COR1103 1–17Introduction Sample SessionDefining Preprocessor SymbolsThe C-Compiler Preprocessor page allows you to define preprocessor defini

Page 40 - COMMAND LINE FORMAT

UM004001-COR1103 iii380 C-COMPILER USER’S MANUAL PREFACEABOUT THIS MANUALWe recommend that you read and understand everything in this manual before s

Page 41 - COMMAND LINE SWITCHES

Sample Session Introduction1–18 UM004001-COR1103• The Additional Include Directories field is used to enter additional search paths the C-compiler sho

Page 42 - COMMAND LINE EXAMPLES

UM004001-COR1103 1–19Introduction Compiling and DownloadingCOMPILING AND DOWNLOADINGThe following section shows how to compile a C file using ZDS and

Page 43 - • Level 2 optimization

Compiling and Downloading Introduction1–20 UM004001-COR1103DOWNLOADING A COMPILED FILEPerform the following steps to load the a HEX file.NOTE: A term

Page 44 - LEVEL 2 OPTIMIZATIONS

UM004001-COR1103 1–21Introduction Technical SupportDownload a HEX filePerform the following steps to download a HEX file into the EEPROM memory on top

Page 46 - OBJECT SIZES

UM004001-COR1103 2–1380 C-COMPILER USER’S MANUALCHAPTER 2 C-COMPILER OVERVIEWOVERVIEWThe 380 C compiler is an optimizing compiler that translates stan

Page 47 - • Code Section (.text)

Language Extensions C-Compiler Overview2–2 UM004001-COR1103– Support for interrupt functions– Intrinsic functions are provided for in-line assembly.•

Page 48 - INCORPORATING C WITH ASSEMBLY

UM004001-COR1103 2–3C-Compiler Overview pointers POINTERSA pointer to a qualified memory type can not be converted to a different qualified memory typ

Page 49 - Referenced C file

I/O ADDRESS SPACES C-Compiler Overview2–4 UM004001-COR1103ACCCESING I/O ADDRESS SPACEThe Z380 instruction set does not allow indirect acess of the int

Page 50

UM004001-COR1103 2–5C-Compiler Overview INTERRUPT FUNCTIONSINTERRUPT FUNCTIONSInterrupt functions are declared by preceding their definition with #pra

Page 52

INTERRUPT FUNCTIONS C-Compiler Overview2–6 UM004001-COR1103USING THE DOS COMMAND LINEThe z380 C compiler can be invoked from the DOS command line.COMM

Page 53 - • COFF Format Executable File

UM004001-COR1103 2–7C-Compiler Overview INTERRUPT FUNCTIONSCOMMAND LINE SWITCHESThe following command-line switches are recognized.TABLE 2-2. COMMAND

Page 54 - USING THE LINKER IN ZDS

INTERRUPT FUNCTIONS C-Compiler Overview2–8 UM004001-COR1103NOTE: Other switches are for ZiLOG use only in this version.COMMAND LINE EXAMPLESCompiling

Page 55

UM004001-COR1103 2–9C-Compiler Overview Optimization LevelsOPTIMIZATION LEVELSThe Z380 C-compiler allows the user to manually specify the level of opt

Page 56 - LINKER SYMBOLS

Optimization Levels C-Compiler Overview2–10 UM004001-COR1103Level 1 OptimizationsThe following is a description of the optimizations that are performe

Page 57 - LINKER COMMAND FILE

UM004001-COR1103 2–11C-Compiler Overview Understanding errorsJump to Jump OptimizationTargets in the control statement are replaced by the ultimate ta

Page 58 - Linker Command DEFINE

Included Files C-Compiler Overview2–12 UM004001-COR1103INCLUDED FILESA path to included files must be defined before the C-Compiler can recognize incl

Page 59

UM004001-COR1103 2–13C-Compiler Overview Section NamesSECTION NAMESThe compiler places code and data into separate sections in the object file. Every

Page 60 - LINKER COMMAND LINE

Incorporating Assembly with C C-Compiler Overview2–14 UM004001-COR1103INCORPORATING ASSEMBLY WITH CThe Z380- C-Compiler allows the user to incorporate

Page 61 - COMMAND LINE SPECIFICATIONS

UM004001-COR1103 2–15C-Compiler Overview Incorporating C with assemblycall.ib _imul; (hl)=productadd sp,4; clean the stackret; return result in (hl)Re

Page 62 - LINKER COMMAND LINE OPTIONS

UM004001-COR1103 vChapter Title and Subsections Page380 C-COMPILER USER’S MANUALTABLE OF CONTENTSChapter 1 IntroductionINTRODUCTION . . . . . . . .

Page 64 - COMMAND LINE OPTIONS

UM004001-COR1103 3–1380 C-COMPILER USER’S MANUALCHAPTER 3 LINKING FILESINTRODUCTIONThe purpose of the Zilog cross linker is to read relocatable object

Page 65 - CHAPTER 4

Introduction Linking Files3–2 UM004001-COR1103• Reads in Relocatable object modules and library files in Common Object File Format (COFF) or ZiLOG Obj

Page 66 - IGURE 4-1. FRAME LAYOUT

UM004001-COR1103 3–3Linking Files Using the Linker with the C-compilerOutputting OMF FilesDepending upon the options specified by the user, the linker

Page 67 - USING THE RUN-TIME LIBRARY

Invoking the Linker Linking Files3–4 UM004001-COR1103RUN TIME INITIALIZATION FILEThe C run-time initialization file is an assembly program that initia

Page 68

UM004001-COR1103 3–5Linking Files Invoking the LinkerNOTE: The user needs to include the C-run time initialization file that is appropriate for the

Page 69 - abs FUNCTION

Linker symbols Linking Files3–6 UM004001-COR1103• linker-command-file is the command file to be linked by the linker. Sample command files are provide

Page 70 - atof, atoi, atol FUNCTIONS

UM004001-COR1103 3–7Linking Files Linker Command File LINKER COMMAND FILEThe linker command file is text file that contains the linker command and opt

Page 71 - FUNCTIONS

Linker Command File Linking Files3–8 UM004001-COR1103make a copy of an initialized RAM data section in a ROM address space, so that the RAM may be ini

Page 72 - Parameter Description

UM004001-COR1103 3–9Linking Files Linker Command File The “Expression Formats” section, which follows, explains different types of expressions that ca

Page 73

vi UM004001-COR1103Chapter Title and Subsections Page POINTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 74

Linker Command Line Linking Files3–10 UM004001-COR1103Linker Command RANGEThis command sets the lower and upper limits of a control section or an addr

Page 75

UM004001-COR1103 3–11Linking Files Linker Command LineCOMMAND LINE SPECIFICATIONSThe following rules govern the command line specification:• ZLD exami

Page 76

Linker Command Line Linking Files3–12 UM004001-COR1103LINKER COMMAND LINE OPTIONSLinker options are specified by prefixing an option word with a minus

Page 77 - srand FUNCTION

UM004001-COR1103 3–13Linking Files Using the LibrarianSymbol File In Zilog Symbol Format A symbol file in the Zilog symbol format is generated when th

Page 78

COMMAND LINE OPTIONSCommand line options are specified by prefixing an option letter with a minus (-). The com-mand line options are summarized in Ta

Page 79

UM004001-COR1103 4–1380 C-COMPILER USER’S MANUALCHAPTER 4 RUN TIME ENVIRONMENTFUNCTION CALLSThe C-compiler imposes a strict set of rules on function c

Page 80

Function Calls Run Time Environment4–2 UM004001-COR1103FIGURE 4-1. FRAME LAYOUT RESPONSIBILITIES OF A CALLED FUNCTIONA called function must perform t

Page 81

UM004001-COR1103 4–3Run Time Environment Using the Run-Time LibrarySPECIAL CASES FOR A CALLED FUNCTIONThe following exceptions apply to special cases

Page 82

Using the Run-Time Library Run Time Environment4–4 UM004001-COR1103INSTALLED FILESThe following header files are installed in the C-Compiler installat

Page 83

UM004001-COR1103 4–5Run Time Environment Library FunctionsLIBRARY FUNCTIONSRun-time library routines are provided for the following:• Buffer Manipulat

Page 84

UM004001-COR1103 viiChapter Title and Subsections PageLINKER COMMAND LINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 85

Library Functions Run Time Environment4–6 UM004001-COR1103 atof, atoi, atol FUNCTIONS Header file statement: #include <stdlib.h>Syntax: double

Page 86

UM004001-COR1103 4–7Run Time Environment Library Functionsdiv FUNCTIONHeader file statement: #include <stdlib.h>Syntax: div_t div( int num, int

Page 87 - Return Value

Library Functions Run Time Environment4–8 UM004001-COR1103int isspace( int c );int isupper( int c );int isxdigit( int c );Each function in the is fami

Page 88

UM004001-COR1103 4–9Run Time Environment Library FunctionsFunction Test Conditionisalnum Alphanumeric (‘A’-‘Z’, ‘a’-‘z’, or ‘0’-‘9’)isalpha Letter (‘A

Page 89

Library Functions Run Time Environment4–10 UM004001-COR1103memchr FUNCTIONHeader file statement: #include <string.h>Syntax: void *memchr( const

Page 90 - 4–26 UM004001-COR1103

UM004001-COR1103 4–11Run Time Environment Library Functionsmemcpy FUNCTIONHeader file statement: #include <string.h>Syntax: void *memcpy (void *

Page 91 - APPENDIX A

Library Functions Run Time Environment4–12 UM004001-COR1103memset FUNCTIONHeader file statement: #include <string.h>Syntax: void *memset (void

Page 92

UM004001-COR1103 4–13Run Time Environment Library Functions srand FUNCTIONHeader file statement: #include <stdlib.h>Syntax: void srand( unsigne

Page 93 - LINK FILE

Library Functions Run Time Environment4–14 UM004001-COR1103strchr FUNCTIONHeader file statement: #include <string.h> Syntax: char *strchr (const

Page 94

UM004001-COR1103 4–15Run Time Environment Library Functionsstrcmp FUNCTIONHeader file statement: #include <string.h> Syntax: int strcmp (const

Page 95 - APPENDIX B

viii UM004001-COR1103Chapter Title and Subsections Pagestrrchr FUNCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 96

Library Functions Run Time Environment4–16 UM004001-COR1103strcpy FUNCTIONHeader file statement: #include <string.h> Syntax: char *strcpy (char

Page 97

UM004001-COR1103 4–17Run Time Environment Library Functionsstrlen FUNCTIONHeader file statement: #include <string.h> Syntax: size_t strlen (cons

Page 98

Library Functions Run Time Environment4–18 UM004001-COR1103strncmp FUNCTIONHeader file statement: #include <string.h> Syntax: int strncmp (const

Page 99

UM004001-COR1103 4–19Run Time Environment Library Functionsstrncpy FUNCTIONHeader file statement: #include <string.h> Syntax: char *strncpy (cha

Page 100

Library Functions Run Time Environment4–20 UM004001-COR1103strrchr FUNCTIONHeader file statement: #include <string.h> Syntax: char *strrchr (con

Page 101 - APPENDIX C

UM004001-COR1103 4–21Run Time Environment Library Functionsstrstr FUNCTIONHeader file statement: #include <string.h> Syntax: char *strstr( cons

Page 102

Library Functions Run Time Environment4–22 UM004001-COR1103Return ValueThe first time strtok is called, it returns a pointer to the first token in str

Page 103 - GLOSSARY

UM004001-COR1103 4–23Run Time Environment Library Functions[whitespace] [{ + | -}] [0 [{ x | X }]] [digits]If base is between 2 and 36, then it is use

Page 104 - Glossary-2 UM004001-COR1103

Library Functions Run Time Environment4–24 UM004001-COR1103tolower, toupper FUNCTIONSHeader file statement: #include <ctype.h>Syntax: int tolowe

Page 105 - UM004001-COR1103 Glossary-3

UM004001-COR1103 4–25Run Time Environment Library Functions va_arg, va_end, va_start FUNCTIONS Header file statement: #include <stdarg.h> Syntax

Page 106 - Glossary-4 UM004001-COR1103

UM004001-COR1103 ixTable Page380 C-COMPILER USER’S MANUALLIST OF TABLESTABLE 2-1 I/O MACHINE INSTRUCTIONS . . . . . . . . . . . . . . . . . . . . . .

Page 107 - UM004001-COR1103 Glossary-5

Library Functions Run Time Environment4–26 UM004001-COR1103• The va_arg macro does the following:– Retrieves a value of type from the location given b

Page 108 - Glossary-6 UM004001-COR1103

UM004001-COR1103 A–1380 C-COMPILER USER’S MANUALAPPENDIX A INITIALIZATION AND LINK FILES;-------------------------------------------------------------

Page 109 - UM004001-COR1103 Glossary-7

Initialization File Initialization and Link FilesA–2 UM004001-COR1103ld.ib hl,.BSS_LENGTH; Check for non-zero lengthld bc,hl ; *ld de,hl ; *swap de ;

Page 110 - Glossary-8 UM004001-COR1103

UM004001-COR1103 A–3Initialization and Link Files Link file__exit:jr $ ; ?;***********************************************************************.de

Page 112 - Glossary-10 UM004001-COR1103

UM004001-COR1103 B–1380 C-COMPILER USER’S MANUALAPPENDIX B ASCII CHARACTER SETTABLE B-1. ASCII CHARACTER SET Graphic Decimal Hexadecimal Comments0 0

Page 113 - UM004001-COR1103 Glossary-11

ASCII Character SetB–2 UM004001-COR110316 10 Data Link Escape17 11 Device Control 118 12 Device Control 219 13 Device Control 320 14 Device Control 4

Page 114

UM004001-COR1103 B–3ASCII Character Set ( 40 28 Opening (Left) Parenthesis) 41 29 Closing (Right) Parenthesis* 42 2A Asterisk+ 43 2B Plus, 44 2C Comm

Page 115 - UM004001-COR1103 Index-1

ASCII Character SetB–4 UM004001-COR1103@ 64 40 Commercial AtA 65 41 Uppercase AB 66 42 Uppercase BC 67 43 Uppercase CD 68 44 Uppercase DE 69 45 Up

Page 116 - Index-2 UM004001-COR1103

UM004001-COR1103 B–5ASCII Character Set X 88 58 Uppercase XY 89 59 Uppercase YZ 90 5A Uppercase Z[ 91 5B Opening (Left) Bracket\ 92 5C Reverse Sl

Comments to this Manuals

No comments