um0144
ZiLOG Developer Studio II—
eZ80Acclaim!TM
User Manual
UM014418-0205
www.zilog.com
This publication is subject to replacement by a later edition. To determine whether a later edition exists, or
to request copies of publications, contact:
ZiLOG Worldwide Headquarters
532 Race Street
San Jose, CA 95126
Telephone: 408.558.8500
Fax: 408.558.8300
www.ZiLOG.com
Document Disclaimer
ZiLOG is a registered trademark of ZiLOG Inc. in the United States and in other countries. All other products and/or service
names mentioned herein may be trademarks of the companies with which they are associated.
©2005 by ZiLOG, Inc. All rights reserved. Information in this publication concerning the devices, applications, or technology
described is intended to suggest possible uses and may be superseded. ZiLOG, INC. DOES NOT ASSUME LIABILITY FOR OR
PROVIDE A REPRESENTATION OF ACCURACY OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED
IN THIS DOCUMENT. ZiLOG ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED HEREIN
OR OTHERWISE. Devices sold by ZiLOG, Inc. are covered by warranty and limitation of liability provisions appearing in the
ZiLOG, Inc. Terms and Conditions of Sale. ZiLOG, Inc. makes no warranty of merchantability or fitness for any purpose Except
with the express written approval of ZiLOG, use of information, devices, or technology as critical components of life support systems is not authorized. No licenses are conveyed, implicitly or otherwise, by this document under any intellectual property rights.
UM014418-0205
ZiLOG Developer Studio II
eZ80Acclaim!TM
iii
Revision History
Date
Revision
Level
Section
November 15
2004
“Set Up the Ethernet” on page 20
Description
Updated values in clock frequency table for
CR 4966.
“Set Up the Serial SmartCable” on page 23 Updated values in clock frequency table for
CR 4966.
UM014418-0205
“Set Up the USB SmartCable” on page 26
Updated values in clock frequency table for
CR 4966.
“Communication” on page 131
Updated values in clock frequency tables for
CR 4966.
“Operator Precedence” on page 300
Added note for CR 4297.
“Representing Immediate Value” on
page 321
Added section for CR 4297.
Revision History
ZiLOG Developer Studio II
eZ80Acclaim!TM
iv
Date
Revision
Level
Section
December 16
2004
UM014418-0205
Description
“Linker Command File” on page 125
Added note.
“.libcmd” on page xxviii
Added section.
“Configuration” on page 187
Updated for CR 4485.
“Local Optimizations” on page 104
Added sentence about Optimize for Speed.
“Global Optimizations” on page 106
Added sentence about Optimize for Speed.
“.lst” on page xxix
Added paragraph to note.
“Perform Re-List” on page 117
Added paragraph to section.
“New Project” on page 80
Added note about illegal characters.
“Standard Include Path” on page 111
Added sentence about location of default files.
“Boot Module” on page 122
Updated text about files for default boot
module.
“Executable Formats” on page 129
Added sentence about Intel Hex16 and Hex32.
Chapter 1, “Getting Started,” on page 1
Changed Cycle-Accurate Simulator to
Instruction Set Simulator.
Chapter 3, “Debugging,” on page 164
Changed Cycle-Accurate Simulator to
Instruction Set Simulator.
“set config” on page 48
Added section for CR 5019.
“How do I use interrupts in my program?”
on page 268
Added note for CR 3628.
Revision History
ZiLOG Developer Studio II
eZ80Acclaim!TM
v
Date
January
2005
Revision
Level
Section
Description
17
“VECTOR” on page 312
Updated section for CR 5288.
Preface (page xxv), Chapter 1 (page 1),
Chapter 2 (page 64), Chapter 4 (page 190)
Added to the description of
ZILOGINSTALL\ZDSII_product_version for
CR 5347.
“Set Up an Ethernet, Serial, or USB Target” Added a description of the Wait States dropon page 136
down list box for CR 5359.
“Flash Loader” on page 149
Added a description of the Wait States dropdown list box for CR 5359.
“Configuration” on page 187
Added a description of the Wait States dropdown list box for CR 5359.
“Set Up the Serial SmartCable” on page 23 Added a description of the Wait States dropdown list box for CR 5359.
February
2005
18
UM014418-0205
“Set Up the USB SmartCable” on page 26
Added a description of the Wait States dropdown list box for CR 5359.
“Set Up the Ethernet” on page 20
Added a description of the Wait States dropdown list box for CR 5359.
“How do I embed assembly into my C
code?” on page 274
Changed example for CR 5454.
“#pragma intrinsics: <state>” on page 257
Expanded description for CR 5496.
“Keywords” on page 376
Updated for CR 5505.
Revision History
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
vi
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Manual Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi
Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi
Readme.txt File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi
Quick Tours in eZ80Acclaim! Developer’s Environment . . . . . . . . . . . . . . . . . . xxvii
ZiLOG Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Supported ZiLOG Parts and Emulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
ZiLOG Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Supported ZiLOG Emulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.hex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.libcmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.linkcmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.lis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
.lnk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
.lod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
.lst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
.mak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
.map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
.obj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
.pro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
.s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
.src . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
.srec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
.wsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
.zdsproj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Supported Host System Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Supported Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Recommended Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Minimum Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
When Using USB SmartCable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
When Using Serial SmartCable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
When Using eZ80Acclaim! ZPAK II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
UM014418-0205
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
vii
Software Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
eZ80Acclaim! Developer’s Environment Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Developer’s Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Programmer’s Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
ANSI C-Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Macro Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Linker/Locator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Integrated Command Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Instruction Set Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Emulator Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Developer’s Environment Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Create a New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Add a File to the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Set Up the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Save the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Debugging Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Set Up the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Switch to Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Disassemble the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Set and Clear Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Emulator Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Change CPU Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Set Up the Ethernet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Set Up the Serial SmartCable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Set Up the USB SmartCable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Instruction Set Simulator Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Change CPU Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Set Up the Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Command Processor Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Write a Command Script File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Running the Flash Loader from the Command Processor . . . . . . . . . . . . . . . . . . . . 51
Running ZDS II from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Building a Project from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Running the Compiler from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Running the Assembler from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Running the Linker from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
UM014418-0205
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
viii
2
Main Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Edit Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Build Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Command Processor Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debug Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debug Windows Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Project Workspace Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Edit Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Build Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debug Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Find in Files Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Find in Files 2 Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Messages Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Command Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
New File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Open File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Close File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Open Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Save Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Close Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Save As . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Save All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Print Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Print Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Recent Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Recent Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Edit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Redo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Cut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
64
65
65
66
67
68
69
71
72
72
73
75
76
76
77
77
77
78
78
79
79
79
80
82
83
83
83
83
84
84
84
85
85
86
86
86
86
86
86
86
87
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
ix
Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Go to Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Find in Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Replace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
View Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Debug Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Project Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Add Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Remove Selected File(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Export Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Build Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Compile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Rebuild All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Stop Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Update All Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Set Active Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Manage Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Tools Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Flash Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Customize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Window Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
New Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Close All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Cascade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Tile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Arrange Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Help Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Help Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Online Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
UM014418-0205
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
x
3
Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Code Line Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debug Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debug Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Reset Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stop Debugging Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Go Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Run to Cursor Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Break Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step Into Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step Over Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step Out Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Set Next Instruction Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Insert/Remove Breakpoint Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Enable/Disable Breakpoint Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Disable All Breakpoints Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Remove All Breakpoints Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debug Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Registers Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Special Function Registers Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Clock Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Memory Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Watch Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Locals Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Call Stack Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Symbols Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Disassembly Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Inserting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Viewing Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Moving to a Breakpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Enabling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Disabling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Removing Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Instruction Set Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RAM-Based Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ROM/Flash-Based Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
164
165
166
166
166
167
167
167
167
167
167
167
168
168
168
168
168
168
169
169
170
170
171
176
178
178
179
179
180
180
181
182
182
183
183
184
184
185
187
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xi
4
Using the ANSI C-Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Fractional Fixed-Point Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assigning Values to fract Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Default Promotions on fract Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Fractional Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Passing fract Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scaled Fractional Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Language Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
const Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fract Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
eZ80Acclaim! C-Compiler Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assigned Variable Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assigned Function Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Register Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the Run-Time Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errors <errno.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Standard Defines <stddef.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Diagnostics <assert.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Character Handling <ctype.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Limits <limits.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Floating Point <float.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mathematics <math.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Nonlocal Jumps <setjmp.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Variable Arguments <stdarg.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Input/Output <stdio.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
General Utilities <stdlib.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
String Handling <string.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Architecture-Specific Functions <eZ80.h> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Run-Time Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
acos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
asin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
assert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
atan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
atan2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
atof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
atoi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
atol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
bsearch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
calloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ceil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
190
191
191
191
192
193
193
194
194
194
194
194
195
195
196
198
198
199
199
200
201
203
204
205
206
206
208
210
210
210
211
211
212
212
213
213
213
214
214
215
215
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xii
cos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cosh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
div . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
floor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
free . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
frexp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isalnum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isalpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iscntrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isdigit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isgraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
islower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ispunct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isupper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isxdigit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
labs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ldexp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ldiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
log10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
longjmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
malloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
memchr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
memcmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
memcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
memmove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
memset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
modf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
pow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
printf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
putchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
puts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
qsort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
rand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
216
216
217
217
218
218
218
219
219
220
220
221
221
221
222
222
222
223
223
223
224
224
224
225
225
226
226
226
227
228
228
229
229
229
230
230
231
234
234
234
235
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xiii
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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Setting C-Compiler Options Using #Pragmas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma alias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma noalias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma cpu <cpu name> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma globalcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma noglobalcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma globalcse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
235
236
239
240
240
240
241
241
242
242
243
243
243
244
244
245
245
246
246
247
247
247
248
249
250
251
251
251
252
252
253
254
255
255
256
256
256
256
256
256
257
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xiv
#pragma noglobalcse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma globaldeadvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma noglobaldeadvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma globalfold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma noglobalfold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma intrinsics: <state> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nointrinsics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nobss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma jumpopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nojumpopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma localcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nolocalcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma localcse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nolocalcse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma localfold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nolocalfold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma localopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nolocalopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma noopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma optlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nooptlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma optsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma optspeed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma peephole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nopeephole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma promote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nopromote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma sdiopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nosdiopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma stkck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nostkck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma strict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#pragma nostrict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Embedding Assembly in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C Variables in Embedded Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Calling Assembly from C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assigned Function Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Calling Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Troubleshooting C Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I speed up the compiler? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
257
257
257
257
257
257
257
257
257
257
258
258
258
258
258
258
258
258
258
258
258
258
259
259
259
259
259
259
259
259
259
259
259
260
260
262
262
262
264
264
265
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xv
5
How do I call assembly from C? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Why does the compiler generate temporary variables? . . . . . . . . . . . . . . . . . . . . .
How do I make my C program smaller? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Why is my code bigger when I select Optimize for Size
than when I select Optimize for Speed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I make my C program faster? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I create an interrupt handler in C? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Can interrupt handlers take arguments? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I use interrupts in my program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
What registers are preserved by an interrupt handler written in C? . . . . . . . . . . . .
What is a register variable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I locate a variable at a specific location in memory? . . . . . . . . . . . . . . . .
How do I embed assembly into my C code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Is there a predefined compiler macro I can use for
eZ80Acclaim!-specific code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Why do floating-point operations give incorrect results? . . . . . . . . . . . . . . . . . . . .
Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preprocessor Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Front-End Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Code Generator Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the Macro Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Address Spaces and Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Allocating Processor Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Address Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assigning Memory at Link Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Output Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Source Listing (.lst) Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Object Code (.obj) File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Source Language Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
General Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assembler Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Boolean Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HIGH and LOW Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Decimal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hexadecimal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Binary Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Octal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
265
265
266
267
267
267
268
268
272
273
273
274
275
276
276
276
279
288
290
291
291
291
292
293
294
294
295
295
295
296
298
298
298
298
299
299
299
299
300
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xvi
Character Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ALIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.COMMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DEFINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EQU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NEWPAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOLIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ORG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SEGMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TITLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VECTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XDEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XREF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conditional Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conditional Assembly Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MACRO Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Macro Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Local Macro Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Optional Macro Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exiting a Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Delimiting Macro Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Local Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Importing and Exporting Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Label Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Label Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Representing Immediate Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Source Language Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Compatibility Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Troubleshooting the Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
300
300
301
301
301
302
303
306
308
308
308
309
309
310
310
310
311
311
312
312
313
313
313
315
316
316
317
317
317
318
318
319
319
319
319
319
320
321
322
325
328
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xvii
6
Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the Linker/Locator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Linker Interactions with the Compiler and Assembler . . . . . . . . . . . . . . . . . . . . . . . . .
Address Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Linker Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Components for All Linker Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Linker Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
<outputfile>=<module list> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CHANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COLOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DEBUG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DEFINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FORMAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GROUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HEADING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LOCATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MAXHEXLEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MAXLENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOCOLOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NODEBUG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOMAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOWARN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SEARCHPATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SEQUENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SPLITTABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UNRESOLVED IS FATAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
WARN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
WARNING IS FATAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
WARNOVERLAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Linker Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+ (Add) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
& (And) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
BASE OF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COPY BASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
328
334
335
337
337
339
340
341
343
343
344
344
345
346
346
346
347
347
347
353
353
353
354
354
354
354
355
355
355
356
356
357
357
358
358
358
359
359
360
360
361
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xviii
COPY TOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/ (Divide) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FREEMEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HIGHADDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LOWADDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
* (Multiply) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Decimal Numeric Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hexadecimal Numeric Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| (Or) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
<< (Shift Left) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
>> (Shift Right) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- (Subtract) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TOP OF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
^ (Bitwise Exclusive Or) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
~ (Not) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Troubleshooting the Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I control the link order? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I speed up the linker? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I generate debug information without generating code? . . . . . . . . . . . . . .
How can I debug code already burned in ROM? . . . . . . . . . . . . . . . . . . . . . . . . . .
How much memory is my program using? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I create a hex file? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How do I determine the size of my actual hex code? . . . . . . . . . . . . . . . . . . . . . . .
Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A ANSI C Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
String Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Punctuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Arithmetic Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Other Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sequence Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
361
361
361
362
362
362
363
363
363
364
364
364
364
364
365
365
365
365
366
366
367
369
369
369
369
373
374
374
375
376
376
377
382
386
387
388
388
389
389
390
393
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xix
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Primary Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Postfix Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unary Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Cast Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Multiplicative Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Additive Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bitwise Shift Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Equality Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bitwise AND Operator (&) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bitwise Exclusive OR Operator (^) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bitwise Inclusive OR Operator (|) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical AND Operator (&&) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical OR Operator (||) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conditional Operator (?:) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comma Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constant Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Storage-Class Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Type Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Structure and Union Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Enumeration Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Declarators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Type Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Type Definitions and Type Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Labeled Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Compound Statement (or Block) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Expression and Null Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Selection Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Iteration Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Jump Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
External Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
393
395
395
399
402
402
403
404
405
406
406
407
407
408
408
409
409
411
411
412
413
413
413
413
414
416
419
420
424
425
426
429
429
429
430
430
431
432
433
434
436
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xx
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Function Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
External Object Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B ANSI C Preprocessing Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conditional Inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Source File Inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Macro Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Argument Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The # Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The ## Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Rescanning and Further Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scope of Macro Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Line Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Error Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pragma Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Null Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Predefined Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Menu Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Edit Menu Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Project Menu Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Build Menu Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
436
436
436
436
439
441
441
443
443
443
443
444
444
444
445
445
446
446
446
447
447
448
448
448
451
451
451
451
451
452
452
453
454
454
454
455
455
456
464
Table of Contents
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxi
List of Figures
Figure 1. New Project Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 2. Configure New Project Dialog Box—Step 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 3. Configure New Project Dialog Box—Step 2 . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 4. Test Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 5. General Tab in Project Settings Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 6. C (Compiler) Tab in Project Settings Dialog Box . . . . . . . . . . . . . . . . . . . . . . 14
Figure 7. Debugger Tab in Project Settings Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 8. Build Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 9. Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 10. Disassembly Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Figure 11. Setup Simulator Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 12. eZ80Acclaim! Integrated Development Environment (IDE) Window . . . . . 64
Figure 13. File Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Figure 14. Edit Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Figure 15. Build Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Figure 16. Command Processor Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Figure 17. Debug Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Figure 18. Debug Windows Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Figure 19. Project Workspace Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Figure 20. Edit Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Figure 21. Inserting a Bookmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Figure 22. Bookmark Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Figure 23. Build Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Figure 24. Debug Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Figure 25. Find in Files Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Figure 26. Find in Files 2 Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Figure 27. Messages Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Figure 28. Command Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Figure 29. Open Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Figure 30. New Project Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Figure 31. Configure New Project Dialog Box—Step 1 . . . . . . . . . . . . . . . . . . . . . . . . . 81
Figure 32. Open Project Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Figure 33. Save As Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
UM014418-0205
List of Figures
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxii
Figure 34. Print Preview Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Figure 35. Go to Line Number Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Figure 36. Find Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Figure 37. Find in Files Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Figure 38. Replace Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Figure 39. Breakpoints Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Figure 40. Add Files to Project Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Figure 41. Project Settings Dialog Box–General Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Figure 42. Project Settings Dialog Box (C Tab, General Category) . . . . . . . . . . . . . . . . 96
Figure 43. Project Settings Dialog Box (C Tab, Code Generation Category) . . . . . . . . 97
Figure 44. Project Settings Dialog Box (C Tab, Optimizations Category) . . . . . . . . . . 104
Figure 45. Project Settings Dialog Box (C Tab, Data Types Category) . . . . . . . . . . . . 108
Figure 46. Project Settings Dialog Box (C Tab, Listing Files Category) . . . . . . . . . . . 109
Figure 47. Project Settings Dialog Box (C Tab, Preprocessor Category) . . . . . . . . . . . 111
Figure 48. Project Settings Dialog Box–Assembler Tab . . . . . . . . . . . . . . . . . . . . . . . . 112
Figure 49. Project Settings Dialog Box–ZSL Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Figure 50. Project Settings Dialog Box (Linker Tab, General Category) . . . . . . . . . . . 116
Figure 51. Select Link Configuration Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Figure 52. Project Settings Dialog Box (Linker Tab, Input Category) . . . . . . . . . . . . . 122
Figure 53. Additional Linker Directives Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Figure 54. Custom Linker Command File Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . 126
Figure 55. Project Settings Dialog Box (Linker Tab, Address Spaces Category) . . . . 127
Figure 56. Project Settings Dialog Box (Linker Tab, Output Category) . . . . . . . . . . . . 129
Figure 57. Project Settings Dialog Box–Debugger Tab . . . . . . . . . . . . . . . . . . . . . . . . 130
Figure 58. Setup TcpIP Communication Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Figure 59. Setup Serial Communication Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Figure 60. Setup USB Communication Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Figure 61. Setup Simulator Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Figure 62. Configure Target Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Figure 63. Create New Target Wizard Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Figure 64. Copy a Target Wizard Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Figure 65. Save As Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Figure 66. Select Configuration Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Figure 67. Select Active Configuration List Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Figure 68. Project Settings Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Figure 69. Manage Configurations Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
UM014418-0205
List of Figures
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxiii
Figure 70. Add Project Configuration Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 71. Manage Configurations Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 72. Copy Configuration Settings Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 73. Flash Loader Processor Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 74. Customize Dialog Box—Toolbars Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 75. New Toolbar Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 76. Customize Dialog Box—Commands Tab . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 77. Options Dialog Box—General Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 78. Options Dialog Box—Editor Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 79. Syntax Coloring Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 80. Font Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 81. Options Dialog Box—Debugger Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 82. Options Dialog Box—File Types Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 83. Debug and Debug Window Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 84. Debug Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 85. Debug Windows Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 86. Registers Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 87. Special Function Registers Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 88. Clock Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 89. Memory Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 90. Memory Window—Starting Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 91. Memory Window—Requested Address . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 92. Fill Memory Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 93. Save to File Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 94. Load from File Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 95. Watch Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 96. Locals Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 97. Call Stack Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 98. Symbols Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 99. Disassembly Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 100. Setting a Breakpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 101. Viewing Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 102. Linker Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 103. Modules and Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 104. Segment and Space Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 105. Linker Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM014418-0205
147
148
148
150
154
155
156
157
158
159
160
161
162
165
166
169
169
170
170
171
172
172
173
174
175
176
178
178
179
179
181
182
336
336
338
339
List of Figures
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxiv
List of Tables
Table 1. Script File Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table 2. Command Line Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 3. Assembler Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 4. Compiler Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 5. Debugger Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 6. Librarian Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 7. Linker Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 8. General Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 9. Assembler Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Table 10. Compiler Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Table 11. Librarian Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Table 12. Linker Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Table 13. Passing Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Table 14. Returning Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Table 15. Standard Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Table 16. Nonstandard Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Table 17. Passing Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Table 18. Returning Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Table 19. eZ80Acclaim! Address Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Table 20. Predefined Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Table 21. Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Table 22. eZ80Acclaim! Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Table 23. eZ80Acclaim! Directive Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Table 24. Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Table 25. Trigraph Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
UM014418-0205
List of Tables
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxv
Preface
This user manual describes the eZ80Acclaim! instruction set developer’s environment.
MANUAL ORGANIZATION
This manual includes the following:
Chapter 1, “Getting Started,” briefly describes the tools that make up eZ80Acclaim!
developer’s environment including the developer’s environment as well as quick tours that
show you how to use the developer’s environment. See page 1.
Chapter 2, “Main Components,” contains all the main components of the eZ80Acclaim!
developer’s environment and briefly explains their options. The main components are the
toolbars, windows, menu bar, and dialog boxes associated with the menu choices. See
page 64.
Chapter 3, “Debugging,” contains information on debugging your program as well as
information on how to use the debugger with the ZiLOG simulator and emulator drivers.
See page 164.
Chapter 4, “Using the ANSI C-Compiler,” contains detailed information about using the
eZ80Acclaim! developer’s environment ANSI C-Compiler, such as formatting run-time
libraries. See page 190.
Chapter 5, “Using the Macro Assembler,” contains detailed information on how to use the
eZ80Acclaim! developer’s environment Macro Assembler as well as a description of the
assembler’s source language syntax. See page 290.
Chapter 6, “Using the Linker/Locator,” contains detailed information about the
eZ80Acclaim! developer’s environment linker/locator including the commands supported
by the linker. See page 334.
Appendix A, “ANSI C Language,” contains the ANSI C language supported by the
eZ80Acclaim! developer’s environment ANSI C-Compiler. See page 373.
Appendix B, “ANSI C Preprocessing Directives,” describes the ANSI C preprocessor
commands supported by the eZ80Acclaim! developer’s environment ANSI C-Compiler.
See page 441.
Appendix C, “Shortcut Keys,” lists the shortcut keys for the eZ80Acclaim! developer’s
environment. See page 454.
Note: For quick access to specific information, refer to the Index on page 464.
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxvi
CONVENTIONS
The following conventions provide consistent user instructions and examples:
•
Menu commands and software button names are indicated in boldface letters. System
responses or prompts are not in boldface.
•
Carriage returns follow all user entries unless otherwise noted. The carriage return key
is referred to as the Return key.
•
The phrase CTRL X (where x is any key) means to press the key labeled CTRL while
simultaneously pressing another key; for example, CTRL Y.
The following conventions are used in this manual.
italics
Expressions in italics indicate variables to be replaced by specific values. For example, the
statement: watch <identifier> requires you to substitute a value for <identifier>.
Bold
Menu commands and software button names are bold to make them stand out in the text.
Likewise, bold is used to denote your executing a command (Press OK).
Monospaced type
This font represents information that you type or on-screen text (Type
a: setup).
ADDITIONAL INFORMATION
Before you use technical support, consult the following documentation:
Readme.txt File
Refer to the Readme.txt file in the following directory for last minute tips and information about problems that might occur while installing or running eZ80Acclaim! developer’s environment:
ZILOGINSTALL\ZDSII_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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxvii
Quick Tours in eZ80Acclaim! Developer’s Environment
After reading Chapter 1, “Getting Started” (starting on page 1), and Chapter 2, “Main
Components” (starting on page 64), you will have a familiarity with the eZ80Acclaim!
developer’s environment. Be sure to go through the quick tours starting on page 7.
ZILOG TECHNICAL SUPPORT
For technical questions about our products and tools or for design assistance, please use
our web page:
http://www.zilog.com
You must provide the following information in your support ticket:
•
•
•
•
•
Product release number (Located in the heading of the toolbar)
Product serial number
Type of hardware you are using
Exact wording of any error or warning messages
Any applicable files attached to the e-mail
To receive ZilOG Developer Studio (ZDS) II product updates and notifications, register at
the Technical Support web page.
SUPPORTED ZILOG PARTS AND EMULATORS
The eZ80Acclaim! developer’s environment supports ZiLOG parts and emulators.
ZiLOG Parts
To find out which ZiLOG parts are supported, use the following procedure:
1. Open a ZDS II project.
2. From the Project menu, select Settings.
The Project Settings dialog box is displayed.
3. Use the CPU Family and CPU drop-down list boxes on the General tab to see the
supported ZiLOG parts.
Supported ZiLOG Emulators
To find out which ZiLOG emulators are supported, use the following procedure:
1. Open a ZDS II project.
2. From the Project menu, select Settings.
The Project Settings dialog box is displayed.
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxviii
3. Select the Debugger tab.
The Select Target area lists the available emulators when the USB, Serial, and
Ethernet check boxes are selected.
FILE TYPES
This section describes the file types used with the ZiLOG Developer Studio II.
.asm
This extension indicates that the file is an assembly language file.
.c
This extension indicates that the file is a C source file.
.hex
The linker/locator can generate several different object formats including Intel Hex
Records (.hex). Use the Executable Formats area in the Output category on the Linker tab
of the Project Settings dialog box to choose this format. See “Executable Formats” on
page 129.
.lib
Static libraries have the .lib extension and are a collection of .obj files. To create a
static library, select New Project from the File menu. In the File Name field, type the
name of your library. You do not have to type the extension .lib. The extension is added
automatically. The eZ80Acclaim! developer’s environment creates a library file. See
“New Project” on page 80.
.libcmd
This extension indicates that the file is a librarian command file.
.linkcmd
Starting with the ZDS II 4.9 release, this extension indicates that the file is a linker command file, an input file for the linker.
.lis
Select the Generate Compiler Listing File (.lis) check box in the Listing Files category of
the C (Compiler) tab of the Project Settings dialog box to tell the compiler to create a listing file (with the .lis file extension). All source lines are duplicated in this file, as are
any errors encountered by the compiler. See “Generate Compiler Listing File (.lis)” on
page 109.
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxix
.lnk
Before the ZDS II 4.9 release, linker command files had the .lnk extension. These files
are displayed as shortcuts in Windows Explorer. You can open and read these files using
the ZDS II editor.
.lod
The linker/locator can generate several different object formats including IEEE 695
(.lod). Use the Executable Formats area in the Output category on the Linker tab of the
Project Settings dialog box to choose this format. See “Executable Formats” on page 129.
.lst
This extension indicates an assembly listing file. To generate an assembly listing file,
select the Generate Listing File (.lst) check box of the Assembler tab of the Settings dialog
to tell the assembler to create an assembly listing file. The default is checked. See “Generate Listing File (.lst)” on page 113.
Select the Generate Listing File (.lst) check box of the Listing Files category of the C
(Compiler) tab to tell the compiler whether to keep the assembly source file after compiling your code. This can be useful when you want to inspect or modify the assembly code
generated by the compiler. Deselecting this option causes the compiler to remove the .lst
file after it has been assembled. See “Generate Listing File (.lst)” on page 110.
Note: The addresses in the assembly listing are relative. To convert the relative addresses into
absolute addresses, use the -relist option for the assembler. See “Source Listing (.lst)
Format” on page 294.
To generate a listing file with absolute addresses (source_file_name.lst), select
the Perform Re-List check box and the Generate Map File check box (see “General
Category” on page 116). In addition, if your project contains C source files, select
the Generate Assembly Source (.src) check box (see “Listing Files Category” on
page 109).
.mak
This extension indicates that the file is a project make file. The format is
<project_name><current_configuration>.mak. To generate a make file, see “Export
Makefile” on page 141.
.map
The Generate Map File check box in the General category of the Linker tab on the Project
Settings dialog box determines whether the linker generates a link map file each time it is
run. The link map file is named your project’s name with the .map extension. See “Gener-
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxx
ate Map File” on page 117, “MAP” on page 347, and “How much memory is my program
using?” on page 369.
.obj
Use the ANSI C-Compiler to convert your C source files with the .c extension into relocatable object modules with the .obj extension. The ANSI C-Compiler can be configured
using the Project Settings dialog box (C tab). See “C (Compiler) Tab” on page 95.
Use the Macro Assembler to translate eZ80Acclaim! assembly language files with the
.asm extension into relocatable object modules with the .obj extension. The Macro
Assembler is configured using the Project Settings dialog box (Assembler tab). See
“Assembler Tab” on page 112. After your relocatable object modules are complete, convert them into an executable program using the linker/locator.
.pro
Before the ZDS II 4.9 release, project files had the .pro extension.
.s
This extension indicates that the file is an assembly source file.
.src
This extension indicates that the file is an assembly source file that was generated by the
compiler.
.srec
The linker/locator can generate several different object formats including Motorola
S-Records (.srec). Use the Executable Formats area in the Output category on the Linker
tab of the Project Settings dialog box to choose this format. See “Executable Formats” on
page 129.
.wsp
This extension indicates that the file is a workspace file.
From the File menu, select Save Project. Saving your project creates a <name>.wsp file
where <name> is your project file name. This .wsp file contains all user interface specific
project configuration information such as window and toolbar positions. The .wsp file
resides in the same directory as your project file. See “Save Project” on page 83.
.zdsproj
Starting with the ZDS II 4.9 release, project files have the .zdsproj extension and are
typically named after your project's name. The eZ80Acclaim! developer’s environment
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
xxxi
creates a project file. The .zdsproj file contains configuration information for your
project. To create a new project, select New Project from the File menu. In the File Name
edit field, type the name of your project. You do not have to type the extension .zdsproj.
It is added automatically. See “New Project” on page 80.
UM014418-0205
Preface
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
1
1
Getting Started
This chapter describes the tools that make up the eZ80Acclaim! developer’s environment
and provides a quick tour of the eZ80Acclaim! developer’s environment and Debug mode,
so you can be working with our graphical user interface in a short time. The following topics are covered:
•
•
•
•
•
•
•
•
•
UM014418-0205
“Supported Host System Configuration” on page 2
“Software Installation” on page 3
“eZ80Acclaim! Developer’s Environment Tools” on page 3
“Developer’s Environment Quick Tour” on page 7
“Debugging Quick Tour” on page 16
“Emulator Quick Tour” on page 20
“Instruction Set Simulator Quick Tour” on page 29
“Command Processor Quick Tour” on page 31
“Running ZDS II from the Command Line” on page 54
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
2
SUPPORTED HOST SYSTEM CONFIGURATION
To effectively use this software and documentation, you need a basic understanding of the
C and assembly languages, the eZ80Acclaim! architecture, and Microsoft Windows.
Supported Operating Systems
•
•
•
•
MS Windows 98 SE
Windows NT 4.0 SP6
Windows 2000 SP4
Windows XP Pro SP1
Recommended Configuration
•
•
•
•
•
•
•
•
•
Pentium III/500-MHz processor or higher
128-MB RAM or more
110-MB hard disk space (includes application and documentation)
Super VGA video adapter
CD-ROM drive for installation
Ethernet 10Base-T compatible connection
USB 2.0 High-Speed port (when using USB SmartCable)
One or more RS232 communication ports
Internet browser (Internet Explorer or Netscape)
Minimum Configuration
•
•
•
•
•
•
•
•
•
•
UM014418-0205
Windows 98 SE or Windows NT 4.0 SP6
Pentium II 233-MHz processor
96-MB RAM
25-MB hard disk space (application only)
Super VGA video adapter
CD-ROM drive for installation
Ethernet 10Base-T compatible connection
USB 1.1 Full-Speed port (when using USB SmartCable; Windows 98 SE only)
One or more RS232 communication ports
Internet browser (Internet Explorer or Netscape)
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
3
When Using USB SmartCable
•
•
USB 2.0 full- or high-speed or USB 1.1 full-speed
Root (direct) or self-powered hub connection
Notes: The USB SmartCable is a high-power USB device.
Windows NT is not supported.
When Using Serial SmartCable
•
RS232 communication port with hardware flow and modem control signals
Note: Some USB to RS232 devices are not compatible because they lack the necessary
hardware signals and/or they use proprietary auto-sensing mechanisms that prevent
the SmartCable from connecting.
When Using eZ80Acclaim! ZPAK II
•
Ethernet 10Base-T compatible connection
Note: The memory requirements might vary from system to system depending on the size of the
assembly or C source files. If your system has only 8 MB of RAM, C source files with
large functions and very large assembly files might cause an out-of-memory message on
your system.
SOFTWARE INSTALLATION
Perform the following procedure to install the eZ80Acclaim! developer’s environment:
1. Insert the CD in your CD-ROM drive.
2. Follow the setup instructions on your screen.
Install the application in the location where you want it.
EZ80ACCLAIM! DEVELOPER’S ENVIRONMENT TOOLS
The eZ80Acclaim! developer’s environment is a tightly coupled collection of software
development tools under the direction of a developer’s environment, similar to Microsoft’s
Developer Studio. The developer’s environment lets you configure, manage, and execute
each of the tools in the system.
The eZ80Acclaim! developer’s environment is for the eZ80Acclaim! family of processors.
Using the eZ80Acclaim! developer’s environment, embedded applications are developed
more efficiently and intuitively than ever before.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
4
With the eZ80Acclaim! developer’s environment, you access all the tools through the
eZ80Acclaim! developer’s environment. Those tools include the following:
•
•
•
•
•
•
•
•
•
•
“Developer’s Environment” on page 4
“Programmer’s Editor” on page 5
“ANSI C-Compiler” on page 5
“Macro Assembler” on page 5
“Linker/Locator” on page 6
“Integrated Command Processor” on page 6
Automated make facility
“Debug Mode” on page 7
“Instruction Set Simulator” on page 7
“Emulator Drivers” on page 7
These tools are briefly discussed in this chapter. The quick tours start on page 7. To read
detailed information about the main components in the Developer’s Environment as well
as about the menus and dialog boxes, see Chapter 2, “Main Components,” starting on
page 64.
Developer’s Environment
The eZ80Acclaim! developer’s environment allows you to use standard Windows techniques to organize projects, write code, compile or assemble files, create executable programs, and debug programs without leaving Windows or using a DOS window.
The developer’s environment includes the following main components.
Menu Bar
•
•
•
•
•
•
•
•
UM014418-0205
“File Menu” on page 78
“Edit Menu” on page 86
“View Menu” on page 90
“Project Menu” on page 92
“Build Menu” on page 141
“Tools Menu” on page 149
“Window Menu” on page 162
“Help Menu” on page 163
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
5
Toolbars
•
•
•
•
•
•
“File Toolbar” on page 65
“Edit Toolbar” on page 66
“Build Toolbar” on page 67
“Command Processor Toolbar” on page 68
“Debug Toolbar” on page 69
“Debug Windows Toolbar” on page 71
Windows
•
•
•
•
•
•
•
•
“Project Workspace Window” on page 72
“Edit Window” on page 73
“Build Output Window” on page 75
“Debug Output Window” on page 76
“Find in Files Output Window” on page 76
“Find in Files 2 Output Window” on page 77
“Messages Output Window” on page 77
“Command Output Window” on page 77
Programmer’s Editor
The eZ80Acclaim! developer’s environment comes with a Windows-based programmer's
editor.
ANSI C-Compiler
The ANSI C-Compiler is an optimizing compiler that supports memory models. Use the
ANSI C-Compiler to convert your C source files with the .c extension into relocatable
object modules with the .obj extension. The ANSI C-Compiler can be configured using
the Project Settings dialog box (C tab). The eZ80Acclaim! developer’s environment ANSI
C-Compiler also comes with a powerful optimizer that can be configured using the Project
Settings dialog box (Code Generation, Optimizations categories on the C tab). See “C
(Compiler) Tab” on page 95 for information on the C (Compiler) tab options.
Note: For reference information on the compiler, see Chapter 4, “Using the ANSI C-Compiler,”
starting on page 190.
Macro Assembler
The Macro Assembler supports a wide range of conditional assembly directives and
assembler options. Use the Macro Assembler to translate eZ80Acclaim! assembly
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
6
language files with the .asm extension into relocatable object modules with the .obj
extension. After your relocatable object modules are complete, convert them into an executable program using the linker/locator. The Macro Assembler is configured using the
Project Settings dialog box (Assembler tab). See “Assembler Tab” on page 112 for information on the Assembler tab options.
Note: For reference information on the assembler, see Chapter 5, “Using the Macro Assembler,”
starting on page 290.
Linker/Locator
The linker/locator has a rich command language that enables you to link object modules
and libraries and locate code and data anywhere in memory. Use the linker/locator to
merge relocatable object modules and libraries into an executable program. An executable
program can be sent to an EPROM programmer to produce a final product or to the debugger for testing.
The linker/locator uses linker command files to control the linking and locating process.
Linker command files can be created by the developer’s environment for you, or you can
create your own. In most cases, the developer’s environment creates your linker command
files for you. However, if your application requires special linking, refer to “Linker Commands” on page 341 for the commands that make up a linker command file.
Note: The best way to create your own linker command file is to have the developer’s
environment create a template for you and then modify the template to meet your needs
with the editor.
The eZ80Acclaim! developer’s environment linker/locator can generate several different
object formats including IEEE 695 (.lod), Intel Hex Records (.hex), and Motorola SRecords (.srec), which are useful when programming an EPROM after testing is complete. IEEE 695 is the default format of the linker/locator because it is the preferred format
for debugging.
The linker/locator can be configured, including the object format to be used, using the
Project Settings dialog box (Linker tab). See “Linker Tab” on page 116 for information on
the Linker tab options.
Note: For reference information on the linker/locator, see Chapter 6, “Using the Linker/Locator,”
starting page 334.
Integrated Command Processor
The Command Processor allows you to use commands or script files to automate the
execution of a significant portion of the Integrated Development Environment’s (IDE’s)
functionality. This is useful for tasks such as regression testing. Please see the “Command
Processor Quick Tour” on page 31 for details on using the Command Processor and
descriptions of supported commands.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
7
Debug Mode
The Debug mode gives you complete control over your programs while running them on
the eZ80Acclaim! Instruction Set Simulator or the ZiLOG emulator. After an executable
file is generated using the linker/locator, you can test your program using the debugger
running within the eZ80Acclaim! developer’s environment. The debugger is invoked
when you select Reset from the Debug submenu of the Build menu.
The debugger (Debug mode) requires that a driver be selected before your programs can
be executed. A driver can be either the Instruction Set Simulator or an emulator driver.
You can change the driver in the Project Settings dialog box (Debugger tab).
Note: For more information on debugging, see Chapter 3, “Debugging,” starting on page 164.
Instruction Set Simulator
The eZ80Acclaim! developer’s environment Instruction Set Simulator interfaces with
the debugger to simulate the execution of programs without using an emulator or target
hardware. The eZ80Acclaim! Simulator is selected using the Project Settings dialog
box (Debugger tab). See “Debugger Tab” on page 130 for information on the Debugger
tab options. The Instruction Set Simulator uses the debugger commands to perform
complicated tasks such as simulating serial I/O and interrupts. See “Instruction Set Simulator” on page 184 for more information.
Emulator Drivers
To find out which ZiLOG emulators are supported, use the following procedure:
1. Open a ZDS II project.
2. From the Project menu, select Settings.
The Project Settings dialog box is displayed.
3. Select the Debugger tab.
The Select Target area lists the available emulators when the USB, Serial, and
Ethernet check boxes are selected.
DEVELOPER’S ENVIRONMENT QUICK TOUR
Before you begin this tour, you need a basic understanding of Microsoft Windows and a
basic understanding of Microsoft Developer’s Studio. Estimated time for completing this
exercise is 15 minutes.
Note: Be sure to read Chapter 2, “Main Components,” starting on page 64 to learn more about
all the dialog boxes and their options discussed in this tour.
In this tour, you do the following:
•
UM014418-0205
“Create a New Project” on page 8
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
8
•
•
•
“Add a File to the Project” on page 11
“Set Up the Project” on page 12
“Save the Project” on page 16
When you complete this tour, you have a test.lod file that is used in the Debugging
Quick Tour.
Sample Program
There are quick demonstration projects included in ZDS II. This quick tour shows you
how to use the eZ80Acclaim! developer’s environment by creating a project. The file for
the sample program is located in the following directory:
ZILOGINSTALL\ZDSII_product_version\applications\product\product_example\
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
– version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
Create a New Project
1. To create a new project, select New Project from the File menu.
From the New Project dialog box, click on the Browse button (
) to navigate to the
directory where you want your project to reside. For this quick tour, place your project
in the following directory:
ZILOGINSTALL\ZDSII_product_version\applications\product\product_example\
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
– version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
2. In the File Name field, type the name of your project. Name this project test.
The eZ80Acclaim! developer’s environment creates a project file. Project files have
the .zdsproj extension and are typically named after your project's name. You do
not have to type the extension .zdsproj. It is added automatically.
3. Click Select to return to the New Project dialog box.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
9
4. In the CPU Family drop-down list box, select a product family.
5. In the CPU drop-down list box, select a CPU.
6. In the Project Type drop-down list box, select the appropriate format. For this project,
select Executable. See Figure 1.
Figure 1. New Project Dialog Box
The default is to create an IEEE 695 executable format (.lod). For more information,
see “Linker Tab” on page 116.
7. Click Continue.
The Configure New Project dialog box is displayed (Figure 2).
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
10
Figure 2. Configure New Project Dialog Box—Step 1
8. Click Next.
9. Make certain that All RAM is selected in the Link Configurations drop-down list box
(Figure 3).
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
11
Figure 3. Configure New Project Dialog Box—Step 2
10. Click Next.
11. Click Finish.
ZDS II creates a new project and adds a file, zsldevinit.asm, to the project in the
Project Workspace window. See Figure 4.
Note: This file, zsldevinit.asm, is a ZiLOG Standard Library (ZSL) device initialization file
that initializes the UART and required GPIO devices. For more information on ZSL, see
the ZSL API Reference Manual (RM0038).
Add a File to the Project
In this section, you add main.c to the test project.
1. From the Project menu, select Add Files.
2. In the Add Files to Project dialog box, navigate to the following directory:
ZILOGINSTALL\ZDSII_product_version\applications\product\product_example\
where
– ZILOGINSTALL is the ZDS II installation directory. For example, the default
installation directory is C:\Program Files\ZiLOG.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
12
–
–
product is the specific ZiLOG product. For example, product can be Z8Encore!,
eZ80Acclaim!, Crimzon, or Z8GP.
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
3. Highlight main.c by clicking on it:
4. Click Add to add this file to the test project (see Figure 4).
Figure 4. Test Project
Notes: To view the files in the Edit window during the quick tour, double-click each file name in
the Project Workspace window.
To delete a file from a project, select the file in the tree view and press Delete.
Set Up the Project
Before you save and build the test project, check the settings in the Project Settings dialog box.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
13
1. From the Project menu, select Settings.
The Project Settings dialog box includes six tabs you must go through to set up the
project settings. Within the C (Compiler) and Linker tabs are categories that allow you
to set up subsettings on that specific tab’s category. For more information, see
“Settings” on page 93.
2. In the drop-down list box in the upper left corner of the Project Settings dialog box,
make sure that Debug is selected (Figure 5).
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 144.
Figure 5. General Tab in Project Settings Dialog Box
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
14
3. On the C (Compiler) tab, do the following:
– Make sure Generate Debug Info is selected in the Debug Information drop-down
list box in the General category.
– In the Watch Compilation Process drop-down list box, make sure Quiet is
selected.
In the Build Output window, the compiler displays messages during each pass
along with the name of each function as it is being processed.
– In the Optimizations drop-down list box, make sure Custom is selected.
See Figure 6.
Figure 6. C (Compiler) Tab in Project Settings Dialog Box
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
15
4. On the Debugger tab, select the Simulator check box in the Select Target area.
See Figure 7.
Figure 7. Debugger Tab in Project Settings Dialog Box
5. Click OK to save all the settings on the Project Settings dialog box.
6. Click Yes to the warning message: "The project settings have changed
since the last build. Would you like to rebuild the affected
files?"
The developer’s environment builds the test project.
Watch the compilation process in the Build Output window (see Figure 8).
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
16
Figure 8. Build Output Window
When the Build completed message is displayed in the Build Output window, you
have successfully built the test project and created a test.lod file to debug in the
Debugging Quick Tour.
Save the Project
You need to save your project. From the File menu, select Save Project.
DEBUGGING QUICK TOUR
This tour is designed to acquaint you with the eZ80Acclaim! developer’s environment
debugger. You must have an executable file called test.lod before continuing with this
quick tour. By completing the steps in Developer’s Environment quick tour, the system
creates a test.lod file in the following directory:
ZILOGINSTALL\ZDSII_product_version\applications\product\product_example\
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
17
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
Estimated time for completing this exercise is 15 minutes.
Note: Before doing this tour, read Chapter 2, “Main Components,” starting on page 64 to learn
more about the Debug toolbar (page 166) and Debug Windows toolbar (page 169).
In this tour, you do the following:
•
•
•
•
“Set Up the Debugger” on page 17
“Switch to Debug Mode” on page 17
“Disassemble the Code” on page 19
“Set and Clear Breakpoints” on page 19
Set Up the Debugger
Drivers are used to manage communication between your PC and the target device. A target device can be either an emulator or a simulator. By selecting a driver from the Driver
drop-down list box on the Project Settings dialog box (Debugger tab), you define where
your code runs.
For the purpose of this tour, a driver has been selected for you. Make sure the driver, the
Instruction Set Simulator, is applicable for your intended use.
Notes: For more information on using the Instruction Set Simulator with the eZ80Acclaim!
developer’s environment, see “Command Processor Quick Tour” on page 31 before
returning to the next section of this tour.
For more information on using an emulator such as ZPAK II with the eZ80Acclaim!
developer’s environment, see “Emulator Quick Tour” on page 20 before returning to the
next section of this tour.
Switch to Debug Mode
Click the Reset button (
) on the Build toolbar to switch to Debug mode.
In Debug mode, the developer’s environment displays messages in the Debug Output window. The Debug toolbar and Debug Windows toolbar are displayed. The main.c file is
opened in the Edit window with the PC code line indicator (yellow arrow) at line 5. Blue
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
18
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.
The status bar displays the current status of your program’s execution. The status can be
STOP, STEP, or RUN. In STOP mode, your program is not executing. In STEP mode, a
Step Into, Step Over, or Step Out command is in progress. In RUN mode, a Go command
has been issued with no animate active.
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.
See Figure 9.
Figure 9. Debug Mode
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
19
Disassemble the Code
Use the following procedure to disassemble the code:
1. From the Debug Windows toolbar, click the Disassembly Window button (
display the Disassembly window (Figure 10).
) to
Figure 10. Disassembly Window
The Disassembly window displays assembly-level code corresponding to the sourcelevel code. The debugger lets you set breakpoints and step the code at the assembly
level as well as the C level.
2. Click the Step Into button once.
The Step Into button executes the code one statement at a time.
3. Close the Disassembly window.
Set and Clear Breakpoints
Note: You can add a maximum of three breakpoints to a program.
Use the following procedure to set a breakpoint:
1. Click the Reset button on the Build or Debug toolbar.
The PC code line indicator stops on line 5 of the main.c file.
2. Place your cursor on line 18.
3. Click the Insert/Remove Breakpoint button (
).
A red octagon is displayed to the left of line 18.
4. Click the Go button (
) to execute the code up to this line.
The PC code line indicator stops on the breakpoint at line 18.
5. Click the Enable/Disable Breakpoint button (
UM014418-0205
).
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
20
The breakpoint turns white, indicating that it is disabled.
6. Place your cursor in the gutter to the left of line 22 of the main.c file and doubleclick.
A red octagon is displayed to the left of line 22.
7. Click the Go button.
The PC code line indicator stops on the breakpoint at line 22.
8. Click the Remove All Breakpoints button (
).
The breakpoints on lines 18 and 22 are deleted.
9. Click the Stop Debugging button (
) to exit the debugger.
You have successfully completed the Debugging Quick Tour for the eZ80Acclaim! developer’s environment.
EMULATOR QUICK TOUR
Use the Debugging Quick Tour in conjunction with this quick tour. Follow the steps in this
section for changing the CPU and setting up the emulator and then return to the Debugging Quick Tour.
Change CPU Selection
The CPU selection must be supported by the emulator you are using. Make sure the CPU
Family and CPU drop-down list boxes on the Project Settings dialog box (General tab) is
changed. See “CPU” on page 94.
Set Up the Ethernet
Use the following procedure to configure the emulator through the Ethernet:
1. From the Project menu, select Settings.
2. Click the Debugger tab.
3. Select the Ethernet check box.
4. Select an Ethernet target from the Select Target area.
5. Click Communication.
The Setup TcpIP Communication dialog box is displayed.
a. Type the IP address in the IP Address field.
b. Type the port number in the TCP Port field.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
21
c. Select the Use Alternate ZDI Clock Frequency check box if you want to use the
ZDI clock frequency.
In previous versions of the ZDS II, you were required to choose the appropriate
ZDI clock frequency. In releases after 4.7.2, that option has been replaced with the
system clock and oscillator frequency so that ZDS can choose the appropriate ZDI
communication rate(s).
ZDS uses the information in the following table to make the ZDI clock frequency
selection:
ZDI Clock Frequency
System Clock Frequency (alternate)
1 MHz
2-6 (2-6) MHz
2 MHz
4-12 (6-12) MHz
4 MHz
8-24 (12-24) MHz
8 MHz
16-50 (24-50) MHz
If a reliable connection cannot be established and the system clock frequency is
within an overlapping area, you can override the default choice by selecting the
Use Alternate ZDI Clock Frequency check box. Selecting the alternate system
clock table changes the ZDI clock frequency used by ZDS. For instance, if the
system clock is 20 MHz, the 4-MHz ZDI clock rate might prove to be more
reliable then the 8-MHz rate.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine.
d. Click OK.
6. Click Setup.
The Configure Target dialog box is displayed.
Note: The options displayed in the Configure Target dialog box depend on the CPU you
selected in the General tab of the Project Settings dialog box.
ZDS II writes the initialization parameters to the target while the connection is being
established. This allows for a virtual reset condition to be created using the following:
a. Type the address of the first line of code to be executed in the Program Counter
(hex) field.
b. Type the the upper address of RAM (24-bit address boundary) in the SPL Stack
Pointer (hex) field. This option is used while in ADL mode.
c. Type the upper address of RAM (16-bit address boundary) in the SPS Stack
Pointer (hex) field. This option is used while in non-ADL mode.
d. Choose a chip select register from the Chip Select Registers drop-down list box.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
22
The chip select registers control the type of access, address bounds, and wait state
assertion.
e. Enter the lower bound for the chip select register in the Lower Bound (hex) field.
f.
Enter the upper bound for the chip select register in the Upper Bound (hex) field.
g. Enter the control register in the Control Register (hex) field.
h. Enter the bus mode in the Bus Mode (hex) field.
i.
Select the Start in ADL Mode check box for 24-bit linear addressing. Deselect the
check box for 16-bit addressing.
j.
Select the Enable Data RAM check box to enable the general-purpose internal
RAM block. Enter the address in the Address Upper Byte (hex) field.
k. Select the Enable EMAC RAM check box to enable the Ethernet Media Access
Controller’s internal RAM. Enter the address in the Address Upper Byte (hex)
field.
l.
Select the Enable MACC RAM check box to enable the multiply-accumulate
engine’s internal RAM block. Enter the address in the Address Upper Byte (hex)
field.
m. Select the Enable Flash check box if you want to use internal Flash. Enter the
address in the Address Upper Byte (hex) field. This shifts Flash and affects the
pages displayed in the Flash Loader Processor dialog box. Select the number of
wait states from the Wait States drop-down list box. The wait states value is based
on the value of the system clock frequency according to the following table:
Wait States
System Clock (MHz)
0
<12
1
12-23.9
2
24-35.9
3
36-47.9
4
48-59.9
5
60-71.9
6
72-84
7
>84
You can select any wait states value; however, 5, 6, and 7 are not recommended
for performance reasons. Based on the currently configured system clock
frequency, ZDS II suggests the appropriate wait states value by appending an
asterisk to it in the Wait States drop-down list box. The asterisk moves to different
values when the system clock frequency is changed in the same dialog box. When
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
23
the target clock frequency is changed, you must update the wait states value if
needed.
n. To use the oscillator, select the Oscillator button and enter the frequency in the
System Clock Frequency (Hz) field.
o. To use the phase-locked loop, select the Phase-Locked Loop button, enter the
clock frequency in the System Clock Frequency (Hz) field, enter the oscillator
frequency in the Oscillator Frequency (Hz) field, select a charge pump current,
and select a lock criteria.
The eZ80F91 device contains a Phase-Locked Loop (PLL) module, the output of
which can be used as the system clock. This allows the application to run at 50
MHz with an oscillator frequency between 1 and 10 MHz. Since the system
defaults to using the oscillator upon power-on or hardware reset, the application
program must enable and select the PLL as the source of the system clock. This
also requires the ZDI clock frequency to change if a debug session is started so
that a reliable connection can be maintained. ZDS automatically changes the rate
after the first Reset or Go command is invoked and the Change ZDI Clock Upon
Reset check box has been selected.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine. For information about how to set up the charge pump
current and lock criteria, see the “Phase Locked Loop” chapter of the eZ80F91
MCU Product Specification (PS0192).
p. Click OK.
7. Click OK to close and save the settings for the Project Settings dialog box.
Set Up the Serial SmartCable
Use the following procedure to configure the emulator through the serial SmartCable:
1. From the Project menu, select Settings.
2. Click the Debugger tab.
3. Select the Serial check box.
4. Select a serial target from the Select Target area.
5. Click Communication.
The Setup Serial Communication dialog box is displayed.
a. Use the Baud Rate drop-down list box to select the appropriate baud rate: 19200,
38400, 57600, or 115200. The default is 57600.
b. Use the Port drop-down list box to select the appropriate port: COM1, COM2,
COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM10, COM11,
COM12, COM13, COM14, COM15, or COM16. The default is COM1.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
24
c. Select the Use Alternate ZDI Clock Frequency check box if you want to use the
ZDI clock frequency.
In previous versions of the ZDS II, you were required to choose the appropriate
ZDI clock frequency. In releases after 4.7.2, that option has been replaced with the
system clock and oscillator frequency so that ZDS can choose the appropriate ZDI
communication rate(s).
ZDS uses the information in the following table to make the ZDI clock frequency
selection:
ZDI Clock Frequency
System Clock Frequency (alternate)
1 MHz
2-6 (2-6) MHz
2 MHz
4-12 (6-12) MHz
4 MHz
8-24 (12-24) MHz
8 MHz
16-50 (24-50) MHz
If a reliable connection cannot be established and the system clock frequency is
within an overlapping area, you can override the default choice by selecting the
Use Alternate ZDI Clock Frequency check box. Selecting the alternate system
clock table changes the ZDI clock frequency used by ZDS. For instance, if the
system clock is 20 MHz, the 4-MHz ZDI clock rate might prove to be more
reliable then the 8-MHz rate.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine.
d. Click OK.
6. Click Setup.
The Configure Target dialog box is displayed.
Note: The options displayed in the Configure Target dialog box depend on the CPU you
selected in the General tab of the Project Settings dialog box.
ZDS II writes the initialization parameters to the target while the connection is being
established. This allows for a virtual reset condition to be created using the following:
a. Type the address of the first line of code to be executed in the Program Counter
(hex) field.
b. Type the the upper address of RAM (24-bit address boundary) in the SPL Stack
Pointer (hex) field. This option is used while in ADL mode.
c. Type the upper address of RAM (16-bit address boundary) in the SPS Stack
Pointer (hex) field. This option is used while in non-ADL mode.
d. Choose a chip select register from the Chip Select Registers drop-down list box.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
25
The chip select registers control the type of access, address bounds, and wait state
assertion.
e. Enter the lower bound for the chip select register in the Lower Bound (hex) field.
f.
Enter the upper bound for the chip select register in the Upper Bound (hex) field.
g. Enter the control register in the Control Register (hex) field.
h. Enter the bus mode in the Bus Mode (hex) field.
i.
Select the Start in ADL Mode check box for 24-bit linear addressing. Deselect the
check box for 16-bit addressing.
j.
Select the Enable Data RAM check box to enable the general-purpose internal
RAM block. Enter the address in the Address Upper Byte (hex) field.
k. Select the Enable EMAC RAM check box to enable the Ethernet Media Access
Controller’s internal RAM. Enter the address in the Address Upper Byte (hex)
field.
l.
Select the Enable MACC RAM check box to enable the multiply-accumulate
engine’s internal RAM block. Enter the address in the Address Upper Byte (hex)
field.
m. Select the Enable Flash check box if you want to use internal Flash. Enter the
address in the Address Upper Byte (hex) field. This shifts Flash and affects the
pages displayed in the Flash Loader Processor dialog box. Select the number of
wait states from the Wait States drop-down list box. The wait states value is based
on the value of the system clock frequency according to the following table:
Wait States
System Clock (MHz)
0
<12
1
12-23.9
2
24-35.9
3
36-47.9
4
48-59.9
5
60-71.9
6
72-84
7
>84
You can select any wait states value; however, 5, 6, and 7 are not recommended
for performance reasons. Based on the currently configured system clock
frequency, ZDS II suggests the appropriate wait states value by appending an
asterisk to it in the Wait States drop-down list box. The asterisk moves to different
values when the system clock frequency is changed in the same dialog box. When
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
26
the target clock frequency is changed, you must update the wait states value if
needed.
n. To use the oscillator, select the Oscillator button and enter the frequency in the
System Clock Frequency (Hz) field.
o. To use the phase-locked loop, select the Phase-Locked Loop button, enter the
clock frequency in the System Clock Frequency (Hz) field, enter the oscillator
frequency in the Oscillator Frequency (Hz) field, select a charge pump current,
and select a lock criteria.
The eZ80F91 device contains a Phase-Locked Loop (PLL) module, the output of
which can be used as the system clock. This allows the application to run at 50
MHz with an oscillator frequency between 1 and 10 MHz. Since the system
defaults to using the oscillator upon power-on or hardware reset, the application
program must enable and select the PLL as the source of the system clock. This
also requires the ZDI clock frequency to change if a debug session is started so
that a reliable connection can be maintained. ZDS automatically changes the rate
after the first Reset or Go command is invoked and the Change ZDI Clock Upon
Reset check box has been selected.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine. For information about how to set up the charge pump
current and lock criteria, see the “Phase Locked Loop” chapter of the eZ80F91
MCU Product Specification (PS0192).
p. Click OK.
7. Click OK to close and save the settings for the Project Settings dialog box.
Set Up the USB SmartCable
Use the following procedure to configure the emulator through the USB SmartCable:
1. From the Project menu, select Settings.
2. Click the Debugger tab.
3. Select the USB check box.
4. Select a USB target from the Select Target area.
5. Click Communication.
The Setup USB Communication dialog box is displayed.
a. Use the Serial Number drop-down list box to select the appropriate serial number.
b. Select the Use Alternate ZDI Clock Frequency check box if you want to use the
ZDI clock frequency.
In previous versions of the ZDS II, you were required to choose the appropriate
ZDI clock frequency. In releases after 4.7.2, that option has been replaced with the
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
27
system clock and oscillator frequency so that ZDS can choose the appropriate ZDI
communication rate(s).
ZDS uses the information in the following table to make the ZDI clock frequency
selection:
ZDI Clock Frequency
System Clock Frequency (alternate)
1 MHz
2-6 (2-6) MHz
2 MHz
4-12 (6-12) MHz
4 MHz
8-24 (12-24) MHz
8 MHz
16-50 (24-50) MHz
If a reliable connection cannot be established and the system clock frequency is
within an overlapping area, you can override the default choice by selecting the
Use Alternate ZDI Clock Frequency check box. Selecting the alternate system
clock table changes the ZDI clock frequency used by ZDS. For instance, if the
system clock is 20 MHz, the 4-MHz ZDI clock rate might prove to be more
reliable then the 8-MHz rate.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine.
c. Click OK.
6. Click Setup.
The Configure Target dialog box is displayed.
Note: The options displayed in the Configure Target dialog box depend on the CPU you
selected in the General tab of the Project Settings dialog box.
ZDS II writes the initialization parameters to the target while the connection is being
established. This allows for a virtual reset condition to be created using the following:
a. Type the address of the first line of code to be executed in the Program Counter
(hex) field.
b. Type the the upper address of RAM (24-bit address boundary) in the SPL Stack
Pointer (hex) field. This option is used while in ADL mode.
c. Type the upper address of RAM (16-bit address boundary) in the SPS Stack
Pointer (hex) field. This option is used while in non-ADL mode.
d. Choose a chip select register from the Chip Select Registers drop-down list box.
The chip select registers control the type of access, address bounds, and wait state
assertion.
e. Enter the lower bound for the chip select register in the Lower Bound (hex) field.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
28
f.
Enter the upper bound for the chip select register in the Upper Bound (hex) field.
g. Enter the control register in the Control Register (hex) field.
h. Enter the bus mode in the Bus Mode (hex) field.
i.
Select the Start in ADL Mode check box for 24-bit linear addressing. Deselect the
check box for 16-bit addressing.
j.
Select the Enable Data RAM check box to enable the general-purpose internal
RAM block. Enter the address in the Address Upper Byte (hex) field.
k. Select the Enable EMAC RAM check box to enable the Ethernet Media Access
Controller’s internal RAM. Enter the address in the Address Upper Byte (hex)
field.
l.
Select the Enable MACC RAM check box to enable the multiply-accumulate
engine’s internal RAM block. Enter the address in the Address Upper Byte (hex)
field.
m. Select the Enable Flash check box if you want to use internal Flash. Enter the
address in the Address Upper Byte (hex) field. This shifts Flash and affects the
pages displayed in the Flash Loader Processor dialog box. Select the number of
wait states from the Wait States drop-down list box. The wait states value is based
on the value of the system clock frequency according to the following table:
Wait States
System Clock (MHz)
0
<12
1
12-23.9
2
24-35.9
3
36-47.9
4
48-59.9
5
60-71.9
6
72-84
7
>84
You can select any wait states value; however, 5, 6, and 7 are not recommended
for performance reasons. Based on the currently configured system clock
frequency, ZDS II suggests the appropriate wait states value by appending an
asterisk to it in the Wait States drop-down list box. The asterisk moves to different
values when the system clock frequency is changed in the same dialog box. When
the target clock frequency is changed, you must update the wait states value if
needed.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
29
n. To use the oscillator, select the Oscillator button and enter the frequency in the
System Clock Frequency (Hz) field.
o. To use the phase-locked loop, select the Phase-Locked Loop button, enter the
clock frequency in the System Clock Frequency (Hz) field, enter the oscillator
frequency in the Oscillator Frequency (Hz) field, select a charge pump current,
and select a lock criteria.
The eZ80F91 device contains a Phase-Locked Loop (PLL) module, the output of
which can be used as the system clock. This allows the application to run at 50
MHz with an oscillator frequency between 1 and 10 MHz. Since the system
defaults to using the oscillator upon power-on or hardware reset, the application
program must enable and select the PLL as the source of the system clock. This
also requires the ZDI clock frequency to change if a debug session is started so
that a reliable connection can be maintained. ZDS automatically changes the rate
after the first Reset or Go command is invoked and the Change ZDI Clock Upon
Reset check box has been selected.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine. For information about how to set up the charge pump
current and lock criteria, see the “Phase Locked Loop” chapter of the eZ80F91
MCU Product Specification (PS0192).
p. Click OK.
7. Click OK to close and save the settings for the Project Settings dialog box.
Now return to “Switch to Debug Mode” on page 17 in the Debugging Quick Tour and follow the procedures in that tour.
INSTRUCTION SET SIMULATOR QUICK TOUR
Use the Debugging Quick Tour in conjunction with this tour. Follow the steps in this section for changing the CPU, setting up the simulator, and then returning to the Debugging
Quick Tour.
Drivers are used to manage communication between your PC and the target device. A target device can be either an emulator or a simulator. By selecting a driver from the Driver
drop-down list box on the Project Settings dialog box (Debugger tab), you define where
your code runs.
Change CPU Selection
The CPU selection must be supported by the simulator you are using. Make sure the CPU
Family and CPU drop-down list boxes on the Project Settings dialog box (General tab) is
changed.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
30
Set Up the Simulator
For the purpose of the Debugging Quick Tour, a driver has been selected for you. Make
sure the driver, the eZ80Acclaim! Simulator, is applicable for your intended use.
1. Select Settings from the Project menu.
2. Click the Debugger tab.
3. Select the Simulator check box in the Select Target area.
4. Click Setup.
The Setup Simulator dialog box (Figure 11) is displayed.
Figure 11. Setup Simulator Dialog Box
5. In the Clock Speed (MHz) field, type the appropriate speed.
The default is 20.000000.
6. Move the thumb bar or scroll the scroll bar to adjust the Simulator Throttle from 1% to
100%.
A 1% throttle means that the simulator uses approximately 1% of the system's
resources while executing your program's instructions. This leaves plenty of power to
do other things while the simulator is running. A throttle of 100% uses virtually all of
your CPU’s processing time to execute your program, allowing it to complete faster
but slows any other Windows functions down considerably. The recommended setting
is 50%.
7. Select the Load Memory Files check box if you want the debugger to automatically
load your memory files into the target platform's memory each time the debugger is
executed.
8. Select the Write Memory Files check box if you want the debugger to automatically
write your memory files into the target platform's memory each time the debugger is
executed.
9. Click OK to close and save the settings for the Setup Simulator dialog box.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
31
10. Click OK to close and save the settings for the Project Settings dialog box.
Now return to “Switch to Debug Mode” on page 17 in the Debugging Quick Tour and follow the procedures in that tour.
COMMAND PROCESSOR QUICK TOUR
The Command Processor allows you to use commands or script files to automate the execution of a significant portion of the IDE’s functionality.
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.
•
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"
•
Using the command script file when the IDE is started.
You need to precede the script file with an at symbol (@) 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
Commands and associated results are displayed in the Command Output window in the
IDE and, if logging is enabled (see “log” on page 40), in the log file as well. You can prevent commands from being displayed by preceding a command with an at (@) symbol (for
example, @print "hello"), but the results are still displayed.
Write a 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 comment.
Sample Command Script File
; change to correct default directory
cd "m:\eZ80Acclaim!\test\focustests"
open project "focus1.zdsproj"
log "focus1.log" ; Create log file
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
32
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
open project "focus2.zdsproj"
reset
bp done
go
wait 2000 ; Wait 2 seconds
log "focus2.log" ; Open log file
log on ; Enable logging
print "pc = %x" reg PC
log off ; Disable logging
quit ; Exit 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
Table 1 lists ZDS II menu commands and dialog box options that have corresponding
script file commands.
Table 1. Script File Commands
ZDS II
Menus
ZDS II Commands
File
Edit
Dialog Box Options
Script File Commands
Page
New Project
new project
page 40
Open Project
open project
page 41
Exit
exit
page 39
list bp
page 40
cancel bp
cancel all
page 37
page 37
add file
page 36
Breakpoints
Go to Code
Enable All
Disable All
Remove
Remove All
Project
Add Files
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
33
Table 1. Script File Commands (Continued)
ZDS II
Menus
ZDS II Commands
Dialog Box Options
Script File Commands
Page
Project Settings (General
tab)
CPU Family
CPU
Output Files Directory
option general cpu
option general outputdir
Table 8
on
page 47
Project Settings (C tab,
General category)
Debug Information
Optimizations
Watch Compilation Process
Max Errors
Use Floating Point Library
option compiler debug
option compiler optspeed
option compiler watch
option compiler maxerrs
option compiler fplib
Table 4
on
page 42
Project Settings (C tab,
Code Generation category)
Debug Information
Const Variable Placement
Alias Checking
ANSI Promotions
Strict ANSI Conformance
One Code Segment Per Module
Use Intrinsics
Generate Printfs Inline
option compiler debug
option compiler const
option compiler alias
option compiler promote
option compiler strict
Table 4
on
page 42
Type
option compiler localopt
Table 4
option compiler globalopt on
option compiler optspeed
page 42
option compiler localcse
option compiler globalcse
option compiler localfold
option compiler globalfold
option compiler localcopy
option compiler globalcopy
option compiler peephole
option compiler loopopt
option compiler sdiopt
option compiler jmpopt
option compiler optspeed
Project Settings (C tab,
Optimizations category)
Optimizations
Common Subexpressions
Constant Folding
Copy Propagation
Peephole Optimizations
Loop Optimizations
Span-Dependent Instructions
Branch Optimizations
Optimize for
Project Settings (C tab, Data Char
Types category)
Short
Float
Long
Int
Double
Bitfield
UM014418-0205
option compiler intrinsic
option compiler charsize
Table 4
option compiler shortsize
on
option compiler floatsize
page 42
option compiler longsize
option compiler intsize
option compiler doublesize
option compiler bitfieldsize
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
34
Table 1. Script File Commands (Continued)
ZDS II
Menus
ZDS II Commands
Dialog Box Options
Script File Commands
Page
Project Settings (C tab,
Listing Files category)
Generate Compiler Listing File (.lis)
List Include Files in .lis
Expand Macros on Error
Generate Assembly Source (.src)
Interleave Source and Assembly
Generate Listing File (.lst)
option compiler list
option compiler listinc
option compiler expmac
option compiler keepasm
option compiler intsrc
option compiler keeplst
Table 4
on
page 42
Project Settings (C tab,
Preprocessor category)
Preprocessor Definitions
Standard Include Paths
User Include Paths
option compiler define
option compiler stdinc
option compiler usrinc
Table 4
on
page 42
Project Settings (Assembler Debug Information
tab)
Jump Optimization
Generate Object
Ignore Case
Generate Listing File (.lst)
Expand Macros
Page Length
Page Width
Display Errors/Warnings Only
Display Warnings
Include Path
Defines
option assembler debug
Table 3
option assembler sdiopt
on
option assembler genobj
page 42
option assembler igcase
option assembler list
option assembler listmac
option assembler pagelen
option assembler pagewidth
option assembler quiet
option assembler warn
Project Settings (Linker tab, Output File Name
General category)
Object/Library Modules
Generate Warnings
Generate Debug Info
Generate Map File
Ignore Case
Symbol Cross-Reference
option linker of
option linker objlibmods
option linker warn
option linker debug
option linker map
option linker igcase
option linker xref
Table 7
on
page 46
Project Settings (Linker tab, Object/Library Modules
Input category)
Boot Module
Linker Command File
option linker objlibmods
option linker startup
option linker createnew
option linker linkctlfile
option linker usecrun
Table 7
on
page 46
option linker rom
option linker ram
option linker extio
option linker intio
option linker flashinfo
Table 7
on
page 46
Use C Runtime Library
Project Settings (Linker tab, Rom
Address Spaces category)
Ram
ExtIO
IntIO
FlashInfo
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
35
Table 1. Script File Commands (Continued)
ZDS II
Menus
Build
ZDS II Commands
Script File Commands
Page
Project Settings (Linker tab, Output File
Output category)
Executable Formats
Use Runtime Library
option linker of
option linker exeform
option linker usecrun
Table 7
on
page 46
Project Settings (Debugger
tab, Simulator)
Simulator
Simulator Throttle
Load Memory Files
Write Memory Files
Clock Speed
option debugger driver
option debugger readmem
option debugger writemem
option debugger throttle
option debugger clock
Table 5
on
page 46
Project Settings (Debugger
tab, Ethernet)
Ethernet
TCP Port
Clock Frequency (MHz)
option debugger driver
option debugger port
option debugger clock
Table 5
on
page 46
Project Settings (Debugger
tab, Serial)
Serial
Baud Rate
Port
Clock Frequency (MHz)
option debugger driver
option debugger baud
option debugger port
option debugger clock
Table 5
on
page 46
Project Settings (Debugger
tab, USB)
USB
Serial Number
Clock Frequency (MHz)
option debugger driver
option debugger port
option debugger clock
Table 5
on
page 46
Export Makefile
make
page 40
Build
build
page 37
Rebuild All
rebuild
page 48
Stop Build
stop
page 49
quit
reset
go
page 48
page 48
page 39
stop
stepin
step
stepout
page 49
page 49
page 49
page 49
Debug
Tools
Dialog Box Options
Connect to Target
Download Code
Stop Debugging
Reset
Go
Run to Cursor
Break
Step Into
Step Over
Step Out
Set Next Instruction
Flash Loader
page 51
Commands are not case sensitive.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
36
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 examples 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"
add file
The add file command adds the given file to the currently open project. If the full path
is not supplied, the current working directory is used. The following is the syntax of the
add file command:
add file "<filename>"
For example:
add file "blah.asm"
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] "<filename>"
<wait>
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 bp command has
the following syntax:
bp [temporary] [module <mod>] line <expr> \
[:<count>][condition]"<cond>"] \
[do"<commands>"]
[:<count>] is the number of times the IDE can encounter the breakpoint before stopping
execution.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
37
<commands> is a list of commands to execute after encountering the breakpoint.
<cond> is a string interpreted as an expression whose value must be nonzero before the
debugger executes <commands>. If <cond> displays without <commands> and if
<cond> equals zero, the debugger executes a go command.
Note: You can add a maximum of three breakpoints to a program.
For example:
bp main
bp line 20
build
The build command builds the currently open project. 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
The cancel all command clears all breakpoints in the active file. The following is the
syntax of the cancel all command:
cancel all
For example:
cancel all
cancel bp
The cancel bp command clears the breakpoint at bp list index num in the active file. The
following is the syntax of the cancel bp command:
cancel bp <num>
For example:
cancel bp 3
cd
The cd command changes the working directory to dir. The following is the syntax of the
cd command:
cd "<dir>"
For example:
cd "c:\temp"
cd "../another_dir"
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
38
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 examine command takes the following form:
? [<data_type>] [<radix>] <expr> [:<count>]
<data_type> can consist of one of the following types:
short
int[eger]
long
ascii
asciz
<radix> can consist of one of the following types:
dec[imal]
hex[adecimal]
oct[al]
bin[ary]
Omitting a <data_type> or <radix> results in using the $data_type or $radix pseudovariable, respectively.
[:<count>] represents the number of items to display.
? x
shows the value of x using $data_type and $radix.
? ascii STR
shows the ASCII string representation of STR.
? 0x1000
shows the value of 0x1000 in the $data_type and $radix.
? *0x1000
shows the byte at address 0x1000.
? *0x1000 :25
shows 25 bytes at address 0x1000.
? L0
shows the value of register D0:0 using $data_type and $radix.
? asciz D0:0
shows the null-terminated string pointed to by the contents of register D0:0.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
39
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:
? <expression>
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
go
The go command starts or runs the debugger on the target machine. The go command can
take one of three forms:
•
go
resumes execution from the current location.
•
go <identifier>
resumes execution at the function identified by <identifier>.
•
go lines <expression>
resumes execution at the line number of the file currently shown in the Edit window
identified by the value of <expression>.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
40
list bp
The list bp command displays a list of all of the current breakpoints of the active file.
The following is the syntax of the list bp command:
list bp
log
The log command defines the file to use as your script (sets the log file). The log command can take one of three forms:
•
log "<filename>" [APPEND]
sets the file name for the script file. If APPEND is not provided, this command results
in a new log when the log is next activated.
•
log on
loads the file (activates the log).
•
log off
quits and logs off the file (deactivates the log).
For example:
log "buildall.log"
@log on
@log off
make
The make command exports a buildable project in make file format. The following is the
syntax of the make command:
make label -f "<filename>"
For example:
make Debug -f sampleproject_Debug.mak
make rebuild -f sampleproject_Debug.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 following is the syntax of the new project
command:
new project "<name>" "<target>" "<exe|lib>" [NOREPLACE]
<name> is the name of the new project.
<target> must match that of the IDE (that is, the eZ80Acclaim! IDE can only create
eZ80Acclaim!-based projects).
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
41
<exe|lib> The type parameter must be either exe (Executable) or lib (Static Library).
NOREPLACE Optional parameter to use to prevent the overwriting of existing projects
For example:
new project "test1.zdsproj" "eZ80Acclaim!" "exe"
new project "test1.zdsproj" "eZ80Acclaim!" "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 specified project does not exist. The following is the syntax of the open project command:
open project "<project_name>"
For example:
open project "test1.zdsproj"
open project "c:\projects\test1.zdsproj"
option
The option command manipulates project settings for 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> expr1 expr2 . . . exprN,
where
expr is (<option name> = <option value>)
For example:
option
option
option
option
option
option
option
assembler debug = TRUE
compiler alias = TRUE
debugger readmem = TRUE
librarian warn = FALSE
linker igcase = "FALSE"
linker code = 0000-FFFF
general cpu=ez80F91
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 54.
Table 2 lists some command line examples and the corresponding script file commands.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
42
Table 2. Command Line Examples
Script File Command Examples
Corresponding Command Line Examples
option compiler keepasm = TRUE
eZ80cc -keepasm
option compiler keepasm = FALSE
eZ80cc -nokeepasm
option compiler const = RAM
eZ80cc -const:RAM
option assembler debug = TRUE
eZ80asm -debug
option linker igcase = "FALSE"
eZ80link -NOigcase
option librarian warn = FALSE
eZ80lib -nowarn
Table 3 through Table 8 list the available script file options for each tool.
Table 3. Assembler Options
Option Name
Description
Acceptable Values
debug
Toggles debug information.
TRUE, FALSE
genobj
Toggles object generation.
TRUE, FALSE
igcase
Toggles Ignore Case.
TRUE, FALSE
list
Toggles listing file generation.
TRUE, FALSE
listmac
Toggles macro expansion.
TRUE, FALSE
pagelen
Sets page length.
integer
pagewidth
Sets page width.
integer
quiet
Toggles quiet assemble.
TRUE, FALSE
sdiopt
Toggles Jump Optimization.
TRUE, FALSE
warn
Toggles display warnings.
TRUE, FALSE
Table 4. Compiler Options
Option Name
Description
Acceptable Values
alias
Toggles checking alias information.
TRUE, FALSE
asm
Runs the assembler. The default is TRUE.
TRUE, FALSE
asmsw="string"
Passes assembler switches in string to assembler. For example:
option compiler asmsw="-define:TEST"
string
bitfieldsize=n Sets the size of a short data type in bits. The default is 24.
Changing this value can cause the compilation to fail.
UM014418-0205
integer
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
43
Table 4. Compiler Options (Continued)
Option Name
Description
Acceptable Values
charsize=n
Sets the size of a char data type in bits. The default is 8.
Changing this value can cause the compilation to fail.
integer
const
Selects where const variables are placed. For example:
option compiler const=RAM
RAM, ROM
cpu=cpu
Sets the CPU and model. For example:
option compiler cpu=EZ80F91
string
debug
Toggles debug information generation.
TRUE, FALSE
define=def
Sets preprocessor definitions.
string
doublesize=n
Sets the size of a short data type in bits. The default is 32.
Changing this value can cause the compilation to fail.
integer
embedded
Runs the compiler in embedded mode. This switch allows the
near, far, interrupt, and other embedded keywords to be
used. The eZ80CC compiler requires this switch for proper code
generation. The default is TRUE.
TRUE, FALSE
expmac
Toggles the expansion of macros on error. The default is FALSE.
TRUE, FALSE
floatsize=n
Sets the size of a short data type in bits. The default is 32.
Changing this value can cause the compilation to fail.
integer
fplib
Toggles the use of the floating-point library. The default is FALSE. TRUE, FALSE
globalcse
Toggles application of global common subexpression
optimizations.
TRUE, FALSE
globalcopy
Toggles the application of global copy propagation optimizations.
TRUE, FALSE
globaldead
The compiler removes code that never gets executed.
TRUE, FALSE
globalfold
Toggles the application of global constant folding optimizations.
TRUE, FALSE
globalopt
Toggles global optimizations.
TRUE, FALSE
help
Prints a list of options.
intrinsics
Toggles use of intrinsics.
TRUE, FALSE
intsize=n
Sets the size of an int data type in bits. The default is 24.
Changing this value can cause the compilation to fail.
integer
intsrc
Toggles the interleaving of source and assembly in generated list
file.
TRUE, FALSE
jmpopt
Toggles application of branch optimizations.
TRUE, FALSE
keepasm
Keeps the assembler source file. The default is FALSE.
TRUE, FALSE
keeplnk
Keeps the .linkcmd linker command file. This file is created in
order to link applications. The default is FALSE.
TRUE, FALSE
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
44
Table 4. Compiler Options (Continued)
Option Name
Description
Acceptable Values
keeplst
Toggles the generation of assembly listing files (.lst). The
default is FALSE.
TRUE, FALSE
link
Runs the linker. The default is FALSE.
TRUE, FALSE
list
Toggles the generation of list file (.lis). The default is FALSE.
TRUE, FALSE
listinc
Toggles the listing of includes in generated list file.
TRUE, FALSE
localcopy
Toggles the application of local copy propagation optimizations.
TRUE, FALSE
localcse
Toggles application of local common subexpression optimizations. TRUE, FALSE
localfold
Toggles the application of local constant folding optimizations.
TRUE, FALSE
localopt
Toggles local optimizations.
TRUE, FALSE
longsize=n
Sets the size of a long data type in bits. The default is 32.
Changing this value can cause the compilation to fail.
integer
loopopt
Toggles application of loop optimizations.
TRUE, FALSE
maxerrs
Sets the compilation errors maximum. The default is 50.
integer
model=model
This option is ignored for this processor.
optlink
This option is ignored for this processor.
optsize
Optimizes code for size. The default is TRUE.
TRUE, FALSE
optspeed
Toggles optimizing for speed.
TRUE (optimize for
speed), FALSE (optimize
for size)
peephole
Toggles application of peephole optimizations.
TRUE, FALSE
promote
Toggles ANSI promotions.
TRUE, FALSE
quiet
Suppresses title information that is normally displayed to the
TRUE, FALSE
screen. Errors and warnings are still displayed. The default setting
is to display title information.
regvar
Toggles use of register variables.
TRUE, FALSE
sdiopt
Toggles application of span-dependent instructions optimizations.
TRUE, FALSE
shortsize=n
Sets the size of a short data type in bits. The default is 16.
Changing this value can cause the compilation to fail.
integer
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
45
Table 4. Compiler Options (Continued)
Option Name
Description
Acceptable Values
stdinc=path
Sets the path for the standard include files. This defines the location string (separate multiple
of include files using the #include file.h syntax. Multiple paths paths with semicolons)
are separated by semicolons. For example:
option compiler stdinc="c:\Z8rtl;c:\myinc"
In this example, the compiler looks for the include file in
1. the default directory
2. the c:\Z8rtl directory
3. the c:\myinc directory
If the file is not found after searching the entire path, the compiler
flags an error.
Omitting this switch tells the compiler to search only the current
directory.
stkck
Performs stack checking. The default is FALSE.
TRUE, FALSE
strict
Toggles strict ANSI conformance. The default is TRUE.
TRUE, FALSE
strtabsz=n
Sets the amount of memory to use to store strings and identifier
names. The default and maximum are both 32000 bytes.
integer
trace1
Debug information for internal use.
trace2
Debug information for internal use.
trace3
Debug information for internal use.
usrinc=path
Sets the search path for user include files. This defines the location string (separate multiple
of include files using the #include "file.h" syntax. Multiple
paths with semicolons)
paths are separated by semicolons. For example:
option compiler usrinc="c:\ZiLOGrtl;c:\myinc"
In this example, the compiler looks for the include file in
1. the default directory
2. the c:\ZiLOGrtl directory
3. the c:\myinc directory
If the file is not found after searching the entire path, the compiler
flags an error.
Omitting this switch tells the compiler to search only the current
directory.
version
Prints the version number of the compiler.
watch
Toggles watch compilation.
UM014418-0205
TRUE, FALSE
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
46
Table 5. Debugger Options
Option Name
Description
Acceptable Values
baud
Sets the baud rate for communication with the emulator.
integer
clock
Sets the clock speed (simulator only).
string (for example, 20.00000)
driver
Sets the debug driver (simulator or emulator interface) driver.
string
ice
Selects an emulator.
integer
port
Sets the communication port (emulator only).
integer
readmem
Toggles load memory from file on debugger startup.
TRUE, FALSE
simio
Enables/disables simulated I/O devices.
TRUE, FALSE
throttle
Sets the simulator throttle percent (simulator only).
integer (0–100)
upload
Toggles loading program on startup.
TRUE, FALSE
writemem
Toggles the saving of memory to file on debugger exit.
TRUE, FALSE
Table 6. Librarian Options
Option Name
Description
Acceptable Values
outfile
Sets the output file name for the built library.
string
warn
Toggles the display of warnings.
TRUE, FALSE
Table 7. Linker Options
Option Name
Description
Acceptable Values
createnew
Toggles the creation of linker command files on build.
integer: 0 (create new file), 1
(use existing file)
debug
Toggles debug information generation.
TRUE, FALSE
exeform
Sets the resulting executable format.
string: “IEEE 695”, "Intel
Hex16", "Intel Hex32",
“Motorola S"
extio
Sets the size range for the Extio memory space.
string (min–max, for example,
“00–FF”)
flashinfo
Sets the size range for the FlashInfo memory space.
string (min–max, for example,
“00–FF”)
igcase
Toggles case sensitivity.
TRUE (case insensitive),
FALSE (case sensitive)
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
47
Table 7. Linker Options (Continued)
Option Name
Description
Acceptable Values
intio
Sets the size range for the Intio memory space.
string (min–max, for example,
“00–FF”)
linkctlfile Sets the linker command file (path and) name. The value is only string
used when createnew is set to 1.
map
Toggles map file generation.
TRUE, FALSE
objlibmods
Sets the object/library modules to be linked into the result file.
string
of
Sets the output file (path and) name.
string
ram
Sets the size range for the RAM memory space.
string (min–max, for example,
“00–FF”)
rom
Sets the size range for the ROM memory space.
string (min–max, for example,
“00–FF”)
startup
Sets the startup module.
string
usecrun
Toggles the inclusion of the C run-time library.
TRUE, FALSE
warn
Toggles the display of warnings.
TRUE, FALSE
xref
Toggles symbol cross reference.
TRUE, FALSE
Table 8. General Options
Option Name
Description
Acceptable Values
cpu
Sets the CPU.
string
outputdir
Sets the output directory.
string
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. The following is the syntax of the print command:
print "<format_string>" expression1 expression2 ... expressionN
For example:
PRINT "the pc is %x" REG PC
print "pc: %x, sp: %x" REG PC REG SP
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
48
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 debugger. The following is the syntax of the quit command:
quit
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
syntax of the rebuild command:
rebuild
reset
The reset command restarts the program in the debugger. The following is the syntax 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 dialog box (see page 160), the PC resets to the first line of the program.
set config
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:
•
•
Selects (makes active) config_name if it exists.
Creates a new configuration named config_name if it does not yet exist. 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
config_name exists, the copy_from_config_name parameter is ignored. If the value
passed as copy_from_config_name does not exist, a default configuration is created.
Note: The active/selected configuration is used with commands like option tool
name="value" and build.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
49
step
The step command performs count steps (stepovers) in the active file. If the count is not
provided, a single step is performed. The following is the syntax of the step command:
step [count]
For example:
step
step 3
stepin
The stepin command steps into the function at the PC. If there is no function at the current PC, this command is equivalent to step 1. The following is the syntax of the
stepin command:
stepin
stepout
The stepout command steps out of the function. The following is the syntax of the
stepout command:
stepout
stop
The stop command pauses the debugger when it is running. The following is the syntax
of the stop command:
stop
Target Copy
The Target Copy command copies the current selected target. The following is the syntax of the Target Copy command:
Target Copy NAME = "<New Target Name>" COMMTYPE = "<Communication Type>"
Target Create
The Target Create command creates a target. The following is the syntax of the
Target Create command:
Target Create FAMILY="<cpuFamily>" CPU="<cpu>" COMMTYPE="<Communication Type>"
Target Help
The Target Help command displays all target commands. The following is the syntax
of the Target Help command:
Target Help
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
50
Target List
The Target List command saves the selected target and displays possible target
choices. The following is the syntax of the Target List command:
Target List
Target Options
Note: See a target in the following directory for a list of categories and options:
ZILOGINSTALL\ZDSII_product_version\targets
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
To set a target value, use one of the following syntaxes:
Target Options CATEGORY="<Category>" OPTION="<Option>" "<token name>"="<value to set>"
Target Options CATEGORY="<Category>" "<token name>"="<value to set>"
Target Options "<token name>"="<value to set>"
To select a target, use the following syntax:
Target Options NAME ="<Target Name>"
Target Save
The Target Save command saves a target. To save the selected target, use the following
syntax:
Target Save
To save a specified target, use the following syntax:
Target Save NAME ="<Target Name>"
Target Setup
The Target Setup command saves the selected target and displays the current configuration. The following is the syntax of the Target Setup command:
Target Setup
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
51
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 <milliseconds>
For example:
wait 5000
wait bp
The wait bp command instructs the command processor to wait until the debugger stops
executing. The optional max_milliseconds parameter provides a method to limit the
amount of time a wait takes (that is, wait until the debugger stops or max_milliseconds
passes). The following is the syntax of the wait bp command:
wait bp [max_milliseconds]
For example:
wait bp
wait bp 2000
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 processes 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 EZ80L92, EZ80190, EZ80F91, EZ80F92, or
EZ80F93 selected in the CPU field on the General tab of the Project Settings dialog
box (see “General Tab” on page 93). The Flash Loader requires RAM memory for
execution and also requires the correct external Flash memory chip select parameters
and memory limits. If there is internal RAM memory, the Flash Loader uses that
memory for execution. The parameters are entered in the Configure Target dialog box
(see page 136). The ZPAK II Ethernet address is also needed by the Flash Loader and
can be entered in the Setup TcpIP Communication dialog box (see page 131).
2. In the Command field (in the Command Processor toolbar), type in the following
command sequences to use the Flash Loader:
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
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
52
Setting Up Flash Options
Flash Options "<File Name>"
File to be flashed
Flash Options FLASHBASE = "<address>"
Start location for external Flash
Flash Options NUMFLASH = <1-8>
Number of stack Flash devices
Flash Options OFFSET = "<address>"
Offset address in hex file
Flash Options INTMEM
Set to internal memory
Flash Options EXTMEM
Set to external memory
Flash Options BOTHMEM
Set to internal and external
memory
Flash Options MANUF="<manufacture name>" DEVICE="<Name of Device>" Set the Flash device
Flash Options NEBF
Do not erase before flash
Flash Options EBF
Erase before flash
Flash Options NEIP
Do not erase info page
Flash Options EIP
Erase info page
Flash Options NISN
Do not include serial number
Flash Options ISN
Include a serial number
Flash Options SERIALADDRESS = "<address>"
Serial number address
Flash Options SERIALNUMBER = "<Number in Hex>"
Initial serial number value
Flash Options SERIALSIZE = <1-8>
Number of bytes in serial number
Flash Options INCREMENT = "<Decimal value>"
Increment value for serial number
Flash Options NIP
No info page
Flash Options IP
Info page
Executing Flash Commands
Flash READSERIAL
Read the serial number
Flash READSERIAL REPEAT
Read the serial number and repeat
Flash BURNSERIAL
Burn the serial number
Flash BURNSERIAL REPEAT
Burn the serial number and repeat
Flash ERASE
Erase Flash memory
Flash ERASE REPEAT
Erase Flash memory and repeat
Flash BURN
Burn Flash memory
Flash BURN REPEAT
Burn Flash memory and repeat
Flash BURNVERIFY
Burn and verify Flash memory
Flash BURNVERIFY REPEAT
Burn and verify Flash memory and repeat
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
53
Flash VERIFY
Verify Flash memory
Flash VERIFY REPEAT
Verify Flash memory and repeat
Caution: The Flash Loader dialog box and the Command Processor interface use the same parameters. If an option is not specified with the Command Processor interface, the current setting in the Flash Loader dialog box is used. If a setting is changed in the Command
Processor interface, the Flash Loader dialog box settings are changed.
Examples
The following are valid examples for a target with an eZ80F91 and external Flash memory:
FLASH
FLASH
FLASH
FLASH
FLASH
Options INTMEM
Options "c:\testing\test.hex"
Options OFFSET="0x1000"
Options EBF
BURN REPEAT
or
flash
flash
flash
flash
flash
options intmem
options "c:\testing\test.hex"
options offset="0x1000"
options ebf
burn repeat
The file test.hex is loaded into internal Flash memory with a value of 0x1000 added to
all addresses. The Flash memory is erased before flashing. After the flashing is completed,
you are prompted to program an additional unit.
FLASH VERIFY
The file test.hex is verified against internal Flash memory with a offset value of
0x1000.
FLASH Options MANUF="Micron" DEVICE="MT28F008B3xx-xxB"
FLASH VERIFY
The file test.hex (from the first example) is verified against the external specific Flash
device.
FLASH SETUP
The current Flash Loader parameters settings are displayed in the Command Output window.
FLASH HELP
The current Flash Loader command options are displayed in the Command Output window.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
54
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.
Building a Project from the Command Line
To build a project from the command line, use the following procedure:
1. Add the ZDS II bin directory (for example, C:\Program
Files\ZiLOG\ZDSII_eZ80Acclaim!_4.4.0\bin) to your path by setting the
PATH environment variable.
The make utility is available in this directory.
2. Change to the project directory.
3. Export a buildable project in make file format. For example:
make Debug -f sampleproject_Debug.mak
make rebuild -f sampleproject_Debug.mak
Running the Compiler from the Command Line
To run the compiler from the command line:
1. Open the make file in a text editor.
2. Copy the options in the CFLAGS section.
3. 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:
C:\PROGRA~1\ZiLOG\ZDSII_eZ80Acclaim!_4.4.0\bin\eZ80cc -alias -asm -const:RAM
-debug -define:_EZ80F91 -NOexpmac -NOfplib -intsrc -intrinsic -NOkeepasm
-NOkeeplst -NOlist -NOlistinc -maxerrs:50 -NOmodsect -promote -quiet -NOstrict
-NOwatch -optsize -localopt -localcse -localfold -localcopy -peephole
-globalopt -NOglobalcse -NOglobalfold -NOglobalcopy -NOloopopt -NOsdiopt
-NOjmpopt
-stdinc:"..\include;C:\PROGRA~1\ZiLOG\ZDSII_eZ80Acclaim!_4.4.0\include"
-usrinc:"..\include" -cpu:EZ80F91 -bitfieldsize:24 -charsize:8 -doublesize:32
-floatsize:32 -intsize:24 -longsize:32 -shortsize:16 -asmsw:"-cpu:EZ80F91"
test.c
Notes: If you use DOS, use double quotation marks for the -stdinc and -usrinc commands
for the C-Compiler. For example:
-stdinc:"C:\eZ80Acclaim!\include"
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
55
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:\eZ80Acclaim!\include}'
Running the Assembler from the Command Line
To run the assembler from the command line:
1. Open the make file in a text editor.
2. Copy the options in the AFLAGS section.
3. In a Command Prompt window, type the path to the assembler, the options from the
AFLAGS section (on a single line and without backslashes), and your assembly file.
For example:
C:\PROGRA~1\ZiLOG\ZDSII_eZ80Acclaim!_4.4.0\bin\eZ80asm -debug -genobj
-NOigcase -include:"..\include" -list -NOlistmac -name -pagelen:56
-pagewidth:80 -quiet -warn -NOzmasm -cpu:EZ80F91 test.asm
Running the Linker from the Command Line
To run the linker from the command line:
1. Open the make file in a text editor.
2. In a Command Prompt window, type the path to the linker and your linker file. For
example:
C:\PROGRA~1\ZiLOG\ZDSII_eZ80Acclaim!_4.4.0\bin\eZ80lnk @e:\ez80\rtl\testfiles\test\test.linkcmd
Command Line Options
Table 9, Table 10, Table 11, and Table 12 describe the command line options.
Notes: If you use DOS, use double quotation marks for the -stdinc and -usrinc commands
for the C compiler. For example:
-stdinc:"C:\eZ80Acclaim!\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:\eZ80Acclaim!\include}'
Table 9. 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.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
56
Table 9. Assembler Command Line Options (Continued)
Option Name
Description
-define:name[=value]
Defines a symbol and sets it to the constant value. For example:
-define:DEBUG=0
This option is equivalent to the C #define 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. This is the default setting.
-include:path
Allows the insertion of source code from another file into the current source file during
assembly.
-list
Generates an output listing with the .lst 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.
-nodebug
Does not create a debug information file for the symbolic debugger. This is the default
setting.
-nogenobj
Does not generate an object file with the .obj extension. The default setting is
genobj.
-noigcase
Enables case sensitivity of user-defined symbols. The default setting is igcase.
-nolist
Does not create a list file. The default setting is list.
-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
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
57
Table 9. Assembler Command Line Options (Continued)
Option Name
Description
-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 is to display title information.
-relist:mapfile
Generates an absolute listing by making use of information contained in a linker map
file. This results in a listing that matches linker-generated output. mapfile is the name of
the map file created by the linker. For example:
-relist:product.map
-sdiopt
Performs span-dependent optimizations. The smallest instruction size allowed is
selected for all size optimizable instructions. This is the default setting.
-trace
Debug information for internal use.
-version
Prints the version number of the assembler.
-warns
Toggles display warnings.
Table 10. Compiler Command Line Options
Option Name
Description
-alias
Enables alias checking. The compiler assumes that program variables can be aliased. The
default is noalias.
-asm
Assembles compiler-generated assembly file. This switch results in the generation of an
object module. The assembly file is deleted if no assemble errors are detected and the
keepasm switch is not given. The default is asm.
-asmsw:"sw"
Passes sw to the assembler when assembling the compiler-generated assembly file.
-bitfieldsize:n
Sets the size of container type for bitfield in bits. The default is 16. Changing this value
can cause the compilation to fail.
-charsize:n
Sets the size of a char data type in bits. The default is 8. Changing this value can cause the
compilation to fail.
-const:[ram|rom] Selects where const variables are placed.
-cpu:cpu
Sets the CPU. For example:
-cpu:EZ80F91
-debug
Generates debug information for the symbolic debugger.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
58
Table 10. Compiler Command Line Options (Continued)
Option Name
Description
-define:def
Defines a symbol and sets it to the constant value. For example:
-define:DEBUG=0
This option is equivalent to the C #define statement. The alternate syntax,
-define:myvar, is the same as -define:myvar=1.
-doublesize:n
Sets the size of double data type in bits. The default is 32. Changing this value can cause
the compilation to fail.
-expmac
Expands macros in displayed source lines when an error is detected. This is useful for
debugging macro expansions. The default is noexpmac.
-floatsize:n
Sets the size of float data type in bits. The default is 32. Changing this value can cause the
compilation to fail.
-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.
-globalcopy
Turns on the application of global copy propagation optimizations.
-globalcse
Turns on application of global common subexpression optimizations.
-globaldead
Removes code that never gets executed.
-globalfold
Turns on the application of global constant folding optimizations.
-globalopt
Turns on global optimizations.
-help
Displays the compiler help screen.
-intrinsics
Specifies that intrinsic functions are to be expanded to inline code.
-intsize:n
Sets the size of an int data type in bits. The default is 16. Changing this value can cause
the compilation to fail.
-intsrc
Integrates source code with the compiler assembly language output. This is the default.
-jmpopt
Turns on application of branch optimizations.
-keepasm
Keeps the compiler-generated assembly file. The default is nokeepasm.
-keeplnk
Keeps the .linkcmd linker command file. This file is created in order to link
applications. The default is nokeeplnk.
-keeplst
Keeps the assembly listing file (.lst). The default is nokeeplst.
-link
Links after assembly.
-list
Generates a .lis source listing file. The default is nolist.
-listinc
Displays included files in the compiler listing file.
-localcopy
Turns on the application of local copy propagation optimizations.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
59
Table 10. Compiler Command Line Options (Continued)
Option Name
Description
-localcse
Turns on machine-level (local) common subexpression elimination optimization. This is
the default.
-localfold
Turns on the application of local constant folding optimizations.
-localopt
Turns on local optimizations.
-longsize:n
Sets the size of a long data type in bits. The default is 32. Changing this value can cause
the compilation to fail.
-loopopt
Turns on application of loop optimizations.
-maxerrs:n
Specifies the maximum number of errors allowed before aborting the compilation process.
The default is 50.
-model:model
This option has no effect on the eZ80Acclaim! compiler.
-noalias
Disables alias checking. Use of this switch can reduce the size of executable files and
speed program execution. However, before specifying noalias, 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=&x;
/* both "x" and "*p" refer to same location */
.
.
.
}
If both *p and x are used below the assignment, malignant aliases exist, and the noalias
switch must not be used. Otherwise, the alias is benign, and the noalias switch can be
used.
-noasm
Does not assemble the compiler-generated assembly file. This default is asm.
-nocode
Internal use only.
-nodebug
Does not generate symbol debug information.
-noexpmac
Does not expand macros in the compiler listing file. This is the default.
-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. The default is genprintf.
-noglobalcopy
Turns off the application of global copy propagation optimizations.
-noglobalcse
Turns off application of global common subexpression optimizations.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
60
Table 10. Compiler Command Line Options (Continued)
Option Name
Description
-noglobaldead
The compiler does not remove code that never gets executed.
-noglobalfold
Turns off the application of global constant folding optimizations
-noglobalopt
Turns off global optimizations.
-nointrinsics
Specifies that intrinsic functions are not to be expanded to inline code.
-nointsrc
Does not integrate source code with the assembly language output. The default is
intsrc.
-nojmpopt
Turns off application of branch optimizations.
-nokeepasm
Deletes the compiler-generated assembly file. This is the default.
-nokeeplnk
Does not keep the .linkcmd linker command file. This is the default.
-nokeeplst
Does not keep the assembly listing file (.lst). This is the default.
-nolink
Does not link. 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.
-nolocalcopy
Turns off the application of local copy propagation optimizations.
-nolocalcse
Turns off the application of local common subexpression optimizations.
-nolocalfold
Turns off the application of local constant folding optimizations.
-nolocalopt
Turns off local optimizations.
-noloopopt
Turns off the application of loop optimizations
-noopt
Disables optimization.
-nop1
Internal use only.
-nop2
Internal use only.
-nopeephole
Turns off the application of peephole optimizations.
-nopromote
Turns off ANSI promotions.
-noquiet
Displays the title information.
-noregvar
This option has no effect on eZ80Acclaim!.
-nosdiopt
Disables span-dependent instruction optimizations.
-nostkck
Does not perform stack checking. This is the default.
-nostrict
Does not flag warnings for obsolete features. This is the default.
-nowatch
Does not display passes of the compiler as they are invoked.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
61
Table 10. Compiler Command Line Options (Continued)
Option Name
Description
-optsize
Optimizes code for size.
-optspeed
Optimizes code for speed. This is the default.
-peephole
Turns on the application of peephole optimizations.
-promote
Turns on ANSI promotions.
-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.
-regvar
This option has no effect on eZ80Acclaim!.
-sdiopt
Performs span-dependent instructions optimization. This optimization results in branches
generated by the compiler taking the shortest form possible. This is the default.
-shortsize:n
Sets the size of a short data type in bits. The default is 16. Changing this value can cause
the compilation to fail.
-stdinc:"path"
Sets the path for the standard include files. This defines the location of include files using
the #include file.h syntax. Multiple paths are separated by semicolons. For example:
-stdinc:"c:\Z8rtl;c:\myinc"
In this example, the compiler looks for the include file in
1. the default directory
2. the c:\Z8rtl directory
3. the c:\myinc directory
If the file is not found after searching the entire path, the compiler flags an error.
Omitting this switch tells the compiler to search only the current directory.
-stkck
Performs stack checking.
-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
compiler requires this switch for proper code generation because it makes use of a static
frame.
-strtabsz:n
Sets the amount of memory to use to store strings and identifier names. The default and
maximum are both 32000 bytes.
-trace1
Debug information for internal use.
-trace2
Debug information for internal use.
-trace3
Debug information for internal use.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
62
Table 10. Compiler Command Line Options (Continued)
Option Name
Description
-usrinc:"path"
Sets the search path for user include files. This defines the location of include files using
the #include "file.h" syntax. Multiple paths are separated by semicolons. For
example:
-usrinc:"c:\ZiLOGrtl;c:\myinc"
In this example, the compiler looks for the include file in
1. the default directory
2. the c:\ZiLOGrtl directory
3. the c:\myinc directory
If the file is not found after searching the entire path, the compiler flags an error.
Omitting this switch tells the compiler to search only the current directory.
-version
Prints the version number of the compiler.
-watch
Displays passes of the compiler as they are invoked.
Table 11. Librarian Command Line Options
Option Name
Description
-help
Displays the librarian help screen.
-list
Generates an output listing with the .lst extension. This is the default setting.
-noquiet
Displays the title information.
-nowarn
Suppresses warning messages.
-quiet
Suppresses title information that is normally displayed to the screen. Errors and warnings are still
displayed. The default setting is to display title information.
-version
Displays the version number.
-warn
Displays warnings.
Table 12. Linker Command Line Options
Option Name
Description
copy segment = space
Makes a copy of a segment into a specified address space.
-debug
Turns on debug information generation.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
63
Table 12. Linker Command Line Options (Continued)
Option Name
Description
define symbol = expr
Defines a symbol and sets it to the constant value. For
example:
-define:DEBUG=0
This option is equivalent to the C #define statement. The
alternate syntax,
-define:myvar, is the same as -define:myvar=1.
-format:[intel|intel32|srec|omf695] Sets the format of the hex file output of the linker to srec
(Motorola S-records), intel or intel32 (Intel Hex
records), or omf695 (IEEE695 format).
-igcase
Suppresses case sensitivity of user-defined symbols. When
this option is used, the linker converts all symbols to
uppercase. This is the default setting.
locate segment at expr
Specifies the address where a group, address space, or
segment is to be located.
-nodebug
Turns off debug information generation.
-noigcase
Enables case sensitivity of user-defined symbols. The default
setting is igcase.
order segment_list or space_list
Establishes a linking sequence and sets up a dynamic range
for contiguously mapped address spaces.
range space = address_range
Sets the lower and upper bounds of a group, address space, or
segment.
sequence segment_list or space_list
Allocates a group, address space, or segment in the order
specified.
UM014418-0205
1 Getting Started
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
64
2
Main Components
This chapter discusses all the main components of the eZ80Acclaim! developer’s environment:
•
•
•
“Toolbars” on page 65
“Windows” on page 72
“Menu Bar” on page 78
To effectively understand how to use the developer’s environment, be sure to go through
the quick tours in Chapter 1, “Getting Started,” on page 1.
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 “Command Processor Quick Tour” on page 31.
After the discussion of the toolbars and windows, this chapter discusses the menu bar (see
Figure 12) from left to right—File, Edit, View, Project, Build, Tools, Window, and Help—
and the dialog boxes accessed from the menus. For example, the Project Settings dialog
box is discussed as a part of the Project menu section. Refer to the List of Figures on
page xxi if you want to see a list of the dialog boxes and their respective page numbers.
Figure 12. eZ80Acclaim! Integrated Development Environment (IDE) Window
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
65
For a table of all the shortcuts used in the eZ80Acclaim! developer’s environment, see
Appendix C, “Shortcut Keys,” starting on page 454.
TOOLBARS
The toolbars give you quick access to most features of the eZ80Acclaim! developer’s
environment. You can use these buttons to perform any task.
Note: There are cue cards for the toolbars. As you scroll 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.
These are the available toolbars:
•
•
•
•
•
•
“File Toolbar” on page 65
“Edit Toolbar” on page 66
“Build Toolbar” on page 67
“Command Processor Toolbar” on page 68
“Debug Toolbar” on page 69
“Debug Windows Toolbar” on page 71
Note: For more information on Debugging, refer to Chapter 3, “Debugging,” starting on
page 164.
File Toolbar
The File toolbar (Figure 13) allows you to perform basic functions with your files.
Figure 13. File 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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
66
Save All Button
The Save All button saves all files.
Cut Button
The Cut button deletes selected text from a file and puts it on the clipboard.
Copy Button
The Copy button copies selected text from a file and puts it on the clipboard.
Paste Button
The Paste button pastes the current contents of the clipboard into a file.
Delete Button
The Delete button deletes selected text from a file and puts it on the clipboard.
Print Button
The Print button prints the active file.
Workspace Window Button
The Workspace Window button shows or hides the Project Workspace window.
Output Window Button
The Output Window button shows or hides the Build Output window.
Edit Toolbar
The Edit toolbar (Figure 14) allows you to perform basic edit functions.
Figure 14. Edit Toolbar
Find in Files Button
This button opens the Find in Files dialog box for you to search files.
Find Field
To locate text in the currently selected 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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
67
Build Toolbar
The Build toolbar (Figure 15) allows you to build your projects and select a project configuration.
Figure 15. Build Toolbar
Select Active Configuration List Box
The Select Active Configuration drop-down list box lets you select the configuration for
your project. See “Set Active Configuration” on page 144 for more information.
Compile/Assemble File Button
The Compile/Assemble File button compiles or assembles the active file in the Edit
window.
Build Button
The Build button builds your project by compiling and/or assembling any files that have
changed since the last build and then relinks the project.
Rebuild All Button
The Rebuild All button rebuilds all files and relinks the project.
Stop Build Button
The Stop Build button stops a build in progress.
Connect to Target
The Connect to Target button starts a debug session and initializes the communication to
the target hardware. Clicking this button does not download the software or reset to main.
Use this button to access target registers, memory, and so on, without loading new code or
to avoid overwriting the target’s code with the same code. This button is not enabled when
the target is the simulator.
Download Code
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 hardware if it has not been done yet. Use this button anytime during a debug session.
Note: The current code on the target is overwritten.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
68
Reset Button
The Reset button resets the debugger. By default, clicking the Reset button 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 dialog box (see page 160), the PC resets to the first
line of the program.
Go Button
The Go button invokes Debug mode (makes the debugger run). Be sure you have worked
through the “Debugging Quick Tour” on page 16 before you run the debugger.
Insert/Remove Breakpoint Button
The Insert/Remove Breakpoint button allows you to add a breakpoint in a file at the line
where the cursor is or to delete a breakpoint from the line where the cursor is. You can set
a breakpoint in any line with a blue dot displayed to the left of the line (shown in Debug
mode only).
Note: You can add a maximum of three breakpoints to a program.
Enable/Disable Breakpoint Button
The Enable/Disable Breakpoint button allows you to activate a breakpoint in a file at the
line where the cursor is or deactivate a breakpoint at the line where the cursor is. A red
octagon indicates an enabled breakpoint; a white octagon indicates a disabled breakpoint.
Remove All Breakpoints Button
The Remove All Breakpoints button deletes all breakpoints in all open files.
Command Processor Toolbar
The Command Processor toolbar (Figure 16) allows you to execute IDE and debugger
commands. See “Supported Script File Commands” on page 32 for a list of supported
commands.
Figure 16. Command Processor Toolbar
Run Command Button
The Run Command button executes the command in the Command field. Click the Stop
Command button to stop the command being run. The Command Output window displays
the results of the command.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
69
Stop Command Button
The Stop Command button stops the command being run from the Command field.
Command Field
The Command field allows you to enter a new command. Click the Run Command
button to execute the command. Click the Stop Command button to stop the command
being run. The Command Output window displays the results of the command.
To enlarge 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.
Debug Toolbar
The Debug toolbar (Figure 17) allows you to perform debugger functions.
Figure 17. Debug Toolbar
Download Code
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 hardware if it has not been done yet. Use this button anytime during a debug session.
Note: The current code on the target is overwritten.
Reset Button
The Reset button resets the debugger. By default, clicking the Reset button 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 dialog box (see page 160), the PC resets to the first
line of the program.
Stop Debugging Button
The Stop Debugging button exits you out of the debugger (leaves Debug mode).
To stop Debug mode, click the Break button.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
70
Go Button
The Go button invokes Debug mode (makes the debugger run). Be sure you have worked
through “Debugging Quick Tour” on page 16 before you run the debugger.
Run to Cursor Button
The Run to Cursor button makes the debugger run to the line containing the cursor. You
can only use this command for a line with a blue dot displayed to the left of the line.
Break Button
The Break button pauses the program execution and stops the debugging in progress.
Step Into Button
The Step Into button executes the code one statement at a time.
Step Over Button
The Step Over button steps to the next statement, regardless of whether the current statement is a call to another function.
Step Out Button
The Step Out button executes the remaining lines in the current function and returns to
execute the next statement in the the caller function.
Set Next Instruction Button
The Set Next Instruction button sets the next instruction at the current line.
Insert/Remove Breakpoint Button
The Insert/Remove Breakpoint button allows you to add a breakpoint in a file at the line
where the cursor is or to delete a breakpoint from the line where the cursor is. You can set
a breakpoint in any line with a blue dot displayed to the left of the line.
Note: You can add a maximum of three breakpoints to a program.
Enable/Disable Breakpoint Button
The Enable/Disable Breakpoint button allows you to activate a breakpoint in a file at the
line where the cursor is or deactivate a breakpoint at the line where the cursor is. A red
octagon indicates an enabled breakpoint; a white octagon indicates a disabled breakpoint.
Disable All Breakpoints Button
The Disable All Breakpoints button deactivates all breakpoints in all open files. To delete
breakpoints from your program, use the Remove All Breakpoints button.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
71
Remove All Breakpoints Button
The Remove All Breakpoints button deletes all breakpoints in all open files. To deactivate
breakpoints in your program, use the Disable All Breakpoints button.
Debug Windows Toolbar
The Debug Windows toolbar (Figure 18) allows you to display the Debug windows.
Figure 18. Debug Windows Toolbar
Registers Window Button
The Registers Window button displays or hides the Registers window.
Special Function Registers Window Button
The Special Function Registers Window button displays or hides the Special Function
Registers window.
Clock Window Button
The Clock Window button displays or hides the Clock window.
Memory Window Button
The Memory Window button displays or hides the Memory window.
Watch Window Button
The Watch Window button displays or hides the Watch window.
Locals Window Button
The Locals Window button displays or hides the Locals window.
Call Stack Window Button
The Call Stack Window button displays or hides the Call Stack window.
Symbols Window Button
The Symbols Window button displays or hides the Symbols window.
Disassembly Window Button
The Disassembly Window button displays or hides the Disassembly window.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
72
WINDOWS
The eZ80Acclaim! developer’s environment contains the following windows that allow
you to see various aspects of the tools while working with your project:
•
•
•
•
•
•
•
•
“Project Workspace Window” on page 72
“Edit Window” on page 73
“Build Output Window” on page 75
“Debug Output Window” on page 76
“Find in Files Output Window” on page 76
“Find in Files 2 Output Window” on page 77
“Messages Output Window” on page 77
“Command Output Window” on page 77
Project Workspace Window
The Project Workspace window (Figure 19) on the left side of the eZ80Acclaim! developer’s environment allows you to view your project files.
Figure 19. Project Workspace Window
To use the right-click menus in the Project Workspace window, highlight a file or folder
and then click on the right button of your mouse.
Depending on which file or folder is highlighted, the right-click menu allows you to do the
following:
•
•
UM014418-0205
Dock the Project Workspace window
Hide the Project Workspace window
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
73
•
•
•
•
Remove the highlighted file from the project
Build project files or external dependencies
Build or compile the highlighted file
Undock the Project Workspace window, allowing it to float in the Edit window
Edit Window
The Edit window (Figure 20) on the right side of the eZ80Acclaim! developer’s environment allows you to edit the files in your project.
Figure 20. Edit Window
There are three right-click menus in the Edit window, depending on where you click.
When you right-click on the title bar of a file, the Dock right-click menu allows you to do
the following:
•
Dock or undock the file
You can dock the file to the top, left, bottom, or right of the Edit window.
•
Return the moved window to its original position (MDI Child)
You can select the position of the window: minimized, maximized, or restored (MDI
Child as).
When you right-click in a file, the right-click menu allows you to do the following
(depending on whether you are running in Debug mode):
•
•
UM014418-0205
Cut, copy, and paste text
Go to the Disassembly window
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
74
•
•
•
•
•
•
•
•
•
•
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 “Inserting Bookmarks” on page 74)
When you right-click outside of all files, the right-click menu allows you to do the following:
•
Show or hide the Output windows, Project Workspace window, status bar, File
toolbar, Build toolbar, Edit toolbar, Command Processor toolbar, Debug toolbar,
Debug Windows toolbar
•
•
Change the way files are displayed in the Edit window (Workbook Mode)
Customize the buttons and toolbars
Inserting Bookmarks
You can use the Edit window right-click menu to insert a bookmark.
1. Click on the line where you want the bookmark and click your right mouse button to
bring up the right-click menu (Figure 21).
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
75
Figure 21. Inserting a Bookmark
2. Select Insert Bookmark.
A cyan box represents the bookmark, as shown in Figure 22.
Figure 22. Bookmark Example
To remove a bookmark, click your cursor in a line with a bookmark, right-click to bring up
the right-click menu, and select Remove Bookmark.
Build Output Window
The Build Output window (Figure 23) holds all text messages generated by the tools,
including error and warning messages generated by the compiler, assembler, and linker.
The scroll bars are used to move through the messages. Use the right-click menu to copy
text from or to delete all text in the Output window.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
76
Figure 23. Build Output Window
Debug Output Window
The Debug Output window (Figure 24) holds all text messages generated by the debugger,
while you are in Debug mode. The scroll bars are used to move through the messages. Use
the right-click menu to copy text from or to delete all text in the Output window.
Figure 24. Debug Output Window
Find in Files Output Window
The Find in Files Output window (Figure 25) holds the results of the Find in Files command (available from the Edit menu and the Edit toolbar). The scroll bars are used to
move through the messages. Use the right-click menu to copy text from or to delete all text
in the Output window.
Figure 25. Find in Files Output Window
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
77
Find in Files 2 Output Window
The Find in Files 2 Output window (Figure 26) holds the results of the Find in Files command (available from the Edit menu and the Edit toolbar) when the Output to Pane 2 check
box is selected. The scroll bars are used to move through the messages. Use the right-click
menu to copy text from or to delete all text in the Output window.
Figure 26. Find in Files 2 Output Window
Messages Output Window
The Messages Output window (Figure 27) holds informational messages intended for the
user. The scroll bars are used to move through messages. Use the right-click menu to copy
text from or to delete all text in the Output window.
Figure 27. Messages Output Window
Command Output Window
The Command Output window (Figure 28) holds all text messages and output generated
by the IDE as it executes commands. The scroll bars are used to move through messages.
Use the right-click menu to copy text from or to delete all text in the Output window.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
78
Figure 28. Command Output Window
Menu Bar
The menu bar lists menu items that you use in the eZ80Acclaim! 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 following items are avaiable from the menu bar:
•
•
•
•
•
•
•
•
“File Menu” on page 78
“Edit Menu” on page 86
“View Menu” on page 90
“Project Menu” on page 92
“Build Menu” on page 141
“Tools Menu” on page 149
“Window Menu” on page 162
“Help Menu” on page 163
FILE MENU
The File menu enables you to perform basic commands in the developer’s environment:
•
•
•
•
•
•
•
•
•
UM014418-0205
“New File” on page 79
“Open File” on page 79
“Close File” on page 79
“New Project” on page 80
“Open Project” on page 82
“Save Project” on page 83
“Close Project” on page 83
“Save” on page 83
“Save As” on page 83
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
79
•
•
•
•
•
•
•
“Save All” on page 84
“Print” on page 84
“Print Preview” on page 84
“Print Setup” on page 85
“Recent Projects” on page 86
“Recent Projects” on page 86
“Exit” on page 86
New File
Select New File from the File menu to create a new file in the Edit window.
Open File
Select Open File from the File menu to display the Open dialog box (Figure 29), which
allows you to open the files for your project.
Figure 29. Open Dialog Box
Note: To delete a file from your project, use the Open 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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
80
New Project
To create a new project, do the following:
1. Select New Project from the File menu.
The New Project dialog box is displayed as shown in Figure 30.
Figure 30. New Project Dialog Box
2. From the New Project dialog box, click on the Browse button (
directory where you want to save your project.
) to navigate to the
3. In the 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: ( ) $ , + [ ] ' &
4. Click Select to return to the New Project dialog box.
5. In the Target drop-down list box, select the appropriate target. For eZ80Acclaim!
developer’s environment targets, select eZ80Acclaim!.
6. In the Project Type drop-down list box, select Executable to build an application or
select Static Library to build a static library.
The default is Executable, which creates an IEEE 695 executable format (.lod). For
more information, see “Linker Tab” on page 116.
7. Click Continue.
The Configure New Project dialog box is displayed (Figure 31).
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
81
Figure 31. Configure New Project Dialog Box—Step 1
8. Select whether your project is linked to the C run-time library, floating-point library,
or neither; select whether your project is linked to the standard startup module; click
Next.
9. Select the target hardware and link configurations from the drop-down list boxes and
click Next.
Select the configuration that best fits your target. The project settings are modified
accordingly. ZDS II automatically generates a linker command file using the project
settings. You can choose to include your own linker command file.
– All RAM
This configuration produces a single memory image that resides and executes
from RAM. This configuration is most useful when emulating code from RAM on
the eZ80L92 and eZ80190 evaluation boards. Using the ZDS II standard startup
module with this configuration produces the most effective run-time environment.
– Standard
This configuration produces the most common embedded environment. Code
resides in Flash/ROM, and data is placed in RAM. Using the ZDS II standard
startup module with this configuration produces the most effective run-time
environment.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
82
–
–
Copy to RAM
This configuration produces a memory image that resides in Flash/ROM and is
copied to RAM for execution. This configuration is typically used to take
advantage of RAM's faster operation. Using the ZDS II standard startup module
with this configuration produces the most effective run-time environment.
Custom
Choose this option if the other three options do not provide the right
configuration. As a result, you are required to enter the most information about
your target configuration. You need to include you own startup module for this
selection.
10. Enter the memory ranges appropriate for the target CPU and click Finish.
Open Project
To open an existing project, use the following procedure:
1. Select Open Project from the File menu.
The Open Project dialog box is displayed, as shown in Figure 32.
Figure 32. Open Project Dialog Box
2. Use the Look In drop-down list box to navigate to the appropriate directory where
your project is located.
3. Click Open to open to open your project.
Notes: To quickly open a project you were working in recently, see “Recent Projects” on page 86.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
83
To delete a project file, use the Open 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. Saving your
project creates a <name>.wsp file where <name> is your project file name. This .wsp file
saves all the configurations for your project and for the eZ80Acclaim! developer’s environment.
Note: The .wsp file resides in the same directory as your project file. If you delete this file, you
lose the configurations for your project.
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 selected 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, as shown in Figure 33.
Figure 33. Save As Dialog Box
2. Use the Save In drop-down list box to navigate to the appropriate folder.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
84
3. Enter the new file name in the File Name field.
4. Use the Save as Type drop-down list box to select the file type.
5. Click Save.
A copy of the file is saved with the name you entered.
Save All
Select Save All from the File menu to save all of the files.
Print
Select Print from the File menu to print the file you have active in the Edit window.
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. In the Edit window, highlight the file you want to show a Print Preview.
2. From the File menu, select Print Preview.
The file is shown in Print Preview in a new window. As shown in Figure 34, main.c
is in Print Preview mode.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
85
Figure 34. Print Preview Window
3. To print the file, click Print.
To cancel the print preview, click Close. The file returns to its edit mode in the Edit
window.
Print Setup
Select Print Setup from the File menu to display the Print Setup dialog box, which allows
you to determine the printer’s setup before you print the file.
Recent Files
Select Recent Files from the File menu to quickly open a previously opened file.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
86
Recent Projects
Select Recent Projects from the File menu to quickly open a previously opened project.
Exit
Select Exit from the File menu to exit the application. Your project is automatically saved
before the eZ80Acclaim! developer’s environment closes.
EDIT MENU
The Edit menu lets you perform basic editing commands and contains the following
options:
•
•
•
•
•
•
•
•
•
•
•
“Undo” on page 86
“Redo” on page 86
“Cut” on page 86
“Copy” on page 86
“Paste” on page 87
“Delete” on page 87
“Go to Line” on page 87
“Find” on page 87
“Find in Files” on page 88
“Replace” on page 89
“Breakpoints” on page 89
Undo
Select Undo from the Edit menu to undo the last command or action you performed.
Redo
Select Redo from the Edit menu to redo the last command or action you performed.
Cut
Select Cut from the Edit menu to delete selected text from a file and put it on the clipboard.
Copy
Select Copy from the Edit menu to copy selected text from a file and put it on the clipboard.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
87
Paste
Select Paste from the Edit menu to paste the current contents of the clipboard into a file.
Delete
Select Delete from the Edit menu to delete selected text from a file.
Go to Line
Select Go to Line from the Edit menu to display the Go to Line Number dialog box, as
shown in Figure 35.
Figure 35. Go to Line Number Dialog Box
Enter the line number in the edit field and click Go To to advance the program counter to
the selected line of code.
Find
To find text, use the following procedure:
1. Select Find from the Edit menu.
The Find dialog box is displayed as shown in Figure 36.
Figure 36. 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. (If you select text in a source file before displaying the
Replace dialog box, the text is displayed in the Find What field.)
3. Select the Match Case button if you want the search to be case sensitive
4. Select the Regular Expression button if you want to use regular expressions.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
88
5. Select the Wrap Around Search button to have the whole file searched.
6. Select the direction of the search with the Up or Down button.
7. 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 Next, the dialog box closes. You can press the F3 key to find the next
occurrence of the search term without displaying the Find dialog box again.
Find in Files
To find text in multiple files, use the following procedure:
1. Select Find in Files from the Edit menu.
The Find in Files dialog box is displayed as shown in Figure 37.
Figure 37. Find in Files Dialog Box
2. Enter the text to search for in the Find field or select a recent entry from the Find dropdown list box.
3. Select the file type to search from the In File Types drop-down list box.
4. Use the Browse button ( ) or the In Folder drop-down list box to select where the
files are located that you want to search.
5. Select the Match Whole Word Only button if you want to only find words.
6. Select the Match Case button if you wan the search to be case sensitive.
7. Select the Look in Subfolders button if you want to search within subfolders.
8. Select the Output to Pane 2 button 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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
89
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 as shown in Figure 38.
Figure 38. Replace 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. (If you select text in a source file before displaying the
Replace dialog box, the text is displayed in the Find What field.)
3. Enter the replacement text in the Replace With field or select a recent entry from the
Replace With drop-down list box.
4. Select the Match Case button if you want the search to be case sensitive
5. Select the Regular Expression button if you want to use regular expressions.
6. Select the Wrap Around Search button to have the whole file searched.
7. Select the direction of the search with the Up or Down button.
8. Click Find Next to jump to the next occurrence of the search text, click Replace to
replace the highlighted text, or click Replace All to automatically replace all instances
of the search text.
Breakpoints
Select Breakpoints from the Edit menu to view, go to, or remove breakpoints. You can
access the dialog box (see Figure 39) during Debug mode and Release mode.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
90
Figure 39. Breakpoints Dialog Box
Go to Code
To move the cursor to a particular breakpoint you have set in a file, highlight the breakpoint in the Breakpoints dialog box and click Go to Code.
Enable All
To make all listed breakpoints active, click Enable All.
Disable All
To make all listed breakpoints inactive, click Disable All.
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.
Note: For more information on breakpoints, see “Using Breakpoints” on page 180.
VIEW MENU
The View menu allows you to select the windows you want on the eZ80Acclaim! developer’s environment.
The View menu contains these options:
•
•
UM014418-0205
“Debug Windows” on page 91
“Workspace” on page 91
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
91
•
•
“Output” on page 91
“Status Bar” on page 91
Debug Windows
When you are in Debug mode (running the debugger), you can select any of the eight
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 169
“Special Function Registers Window” on page 170
“Clock Window” on page 170
“Memory Window” on page 171
“Watch Window” on page 176
“Locals Window” on page 178
“Call Stack Window” on page 178
“Symbols Window” on page 179
“Disassembly Window” on page 179
Note: For more information on the Debug windows, see Chapter 3, “Debugging,” starting on
page 164.
Workspace
Select Workspace from the View menu if you want to have the Project Workspace window displayed.
Output
Select Output from the View menu if you want to have the Build Output window displayed.
Status Bar
Select Status Bar from the View menu if you want to have the status bar, beneath the
Build Output window, displayed.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
92
PROJECT MENU
The Project menu allows you to add files to your project, set configurations for your
project, and export a make file.
The Project menu contains the following options:
•
•
•
•
“Add Files” on page 92
“Remove Selected File(s)” on page 93
“Settings” on page 93
“Export Makefile” on page 141
Add Files
To add files to your project, use the following procedure:
1. From the Project menu, select Add Files.
2. In the Add Files to Project dialog box (Figure 40), navigate to the appropriate
directory where the files you want to add are saved.
Figure 40. Add Files to Project Dialog Box
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.
If you select files with .htm, .html, .class, .jar, .jpg, .jpeg, .wav, or .gif extensions, the
files are converted to C files and saved in the Web Files folder in the Project
Workspace window. If a web file is deleted, ZDS II displays an error during the build
process.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
93
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.
The Project Settings dialog box has the following six tabs you must go through to set up
the project settings:
•
•
•
•
•
•
“General Tab” on page 93
“C (Compiler) Tab” on page 95
“Assembler Tab” on page 112
“ZSL Tab” on page 115
“Linker Tab” on page 116
“Debugger Tab” on page 130
Within the C (Compiler) and Linker tabs are categories that allow you to set up subsettings
on that specific tab’s category. The categories for the C (Compiler) tab are General, Code
Generation, Optimizations, Listing Files, and Preprocessor. The categories for the Linker
tab are General, Input, and Output.
Note: If you change project settings that affect the build, the following message is displayed:
“The project settings have changed since the last build. Would you
like to rebuild the affected files?” Click Yes to save and then rebuild the
project.
General Tab
From the Project Settings dialog box, select the General tab.
The options on the General tab (Figure 41) are described in this section.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
94
Figure 41. Project Settings Dialog Box–General Tab
CPU Family
The CPU Family drop-down list box allows you to select the eZ80 or eZ80Acclaim! family.
CPU
The CPU drop-down list box defines which CPU you want to define for the target.
To change the CPU for your project, select the appropriate CPU in the CPU drop-down list
box.
Note: Selecting a CPU does not automatically select include files for your C or assembly source
code. Include files must be manually included in your code. Selecting a new CPU
automatically updates the ROM range for that CPU.
Output Files Directory
The Output Files Directory field contains the path where your output files are created and
stored. The following is the default directory:
ZILOGINSTALL\ZDSII_product_version\samples
where
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
95
•
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
For more information for output files for the linker, see “Linker Commands” on page 341.
C (Compiler) Tab
From the Project Settings dialog box, select the C tab. The contents of the C (Compiler)
tab determine which options are to be applied to the compiled files.There are six categories available:
•
•
•
•
•
•
“General Category” on page 96
“Code Generation Category” on page 97
“Optimizations Category” on page 103
“Data Types Category” on page 107
“Listing Files Category” on page 109
“Preprocessor Category” on page 111
The options on the C tab of the Project Settings dialog box are described in this section.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
96
General Category
Figure 42 shows the General category of the C tab.
Figure 42. Project Settings Dialog Box (C Tab, General Category)
Debug Information
The Debug Information drop-down list box lets you generate information for debugging
by selecting Generate Debug Info. If you do not want to generate Debug information,
select None.
Optimizations
The Optimizations drop-down list box allows you to select the optimizations you want.
The choices are Disable, Maximize Speed, Minimize Size, and Custom.
The eZ80Acclaim! developer’s environment ANSI C-Compiler comes with a powerful
optimizer that makes your programs smaller and/or faster. If you leave all optimizer
options set at the defaults, you get the best possible code while minimally interfering with
debugging.
Watch Compilation Process
The Watch Compilation Process drop-down list box tells the compiler to display messages
during each pass of the compiler as it is running, along with the name of each function as
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
97
it is being processed, in the Build Output window. Select Verbose for long compilation
processes so that you know how the compiler is progressing. To show minimal messages
during compiling, select Quiet or Default.
Max Errors
The Max Errors field allows you to define the maximum number of errors encountered
before the compiler stops processing your source file. The default is 50.
Use Floating Point Library
The Use Floating Point Library check box tells the compiler whether floating-point operations are used. This option must be selected if you are using any floating-point operations.
Caution: This option is not selected automatically; therefore, if you use floating-point operations,
you must set it. Deselecting this option might significantly reduce code size and compile
time. However, if you use floating-point operations without setting this option, unexpected results occur.
Code Generation Category
Figure 43 shows the Code Generation category of the C tab.
Figure 43. Project Settings Dialog Box (C Tab, Code Generation Category)
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
98
Debug Information
The Debug Information drop-down list box lets you generate information for debugging
by selecting Generate Debug Info. If you do not want to generate Debug information,
select None.
Const Variable Placement
The Const Variable Placement area lets you choose where const variables are placed. You
can select RAM or ROM; RAM is the default.
Alias Checking
The Alias Checking check box tells the compiler not to perform some optimizations
because more than one pointer to the same object might exist. Deselecting this option
might result in more efficient code. However, if you access a variable in more than one
way, the compiler might generate incorrect code. The default is checked.
Note: Aliasing seldom appears in most C programs. The #pragma alias and #pragma
noalias ANSI preprocessor directives can be placed in your C source files to control the
alias checking at the function level.
ANSI Promotions
When selected, the ANSI Promotions check box tells the compiler to perform integer type
promotions when necessary so that the program’s observed behavior is as defined by the
ANSI C Standard. The check box is deselected by default. 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 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 turned off when the check box is deselected. The
special rules dictate that chars (both signed and unsigned) must always be promoted to ints
before being used in arithmetic or relational (such as < and ==) operations. By deselecting
the ANSI Promotions check box, these rules are disregarded and the compiler can operate
on char entities without promoting them. This makes for substantially smaller code
because the compiler does not have to create extra code to do the promotions and then to
operate on larger values.
This is almost always a safe optimization to invoke. 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 different results depending on whether ANSI promotions are turned
on or off. If you write
char a = 126;
char b = 10;
int i = a + b:
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
99
then with ANSI promotions turned on, you get the right answer: 136. With ANSI promotions turned off, 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 earlier or later depending on this setting. With ANSI promotions turned on, the conversion is
done as soon as possible, so it occurs before the addition, and the result is correct even
though it is too large to fit into a char. With ANSI promotions turned off, 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 inconsistent compared to the treatment of other integer types.
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 turned on or off. 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 promotions turned off, the value of the expression (136) is truncated to fit into the 8-bit result,
again yielding the value (char) -120. With ANSI promotions turned on, the expression
evaluates directly to (char) -120. In this case, disabling ANSI promotions gives you the
same wrong answer more efficiently!
There are two more types of code constructs that behave differently from the ANSI Standard when the ANSI promotions are turned off. 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 programming 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 ANSI Promotions check box. When ANSI promotions are on, the code
prints the following:
START
EQUAL
EQUAL
EQUAL
SIGNED
DONE
When ANSI promotions are off, the code prints the following:
START
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
100
NOT EQUAL
NOT EQUAL
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 <stdio.h>
unsigned char uch1 = 1;
unsigned char uch2 = 2;
unsigned char uch3 = 128;
int int1;
int int2;
char ch1 = -2;
char *neq_str = "NOT EQUAL";
char *eq_str = "EQUAL";
int main(void)
{
puts("START");
int1 = uch1 - uch2;
if (int1 != -1)
puts(neq_str);
else
puts(eq_str);
//nopromote:00FFh != FFFFh
int2 = ~uch3;
if (int2 != ~128)
puts(neq_str);
else
puts(eq_str);
//nopromote:007Fh != FF7Fh
int2 = -uch3;
if (int2 != -128)
puts(neq_str);
else
puts(eq_str);
//nopromote:0080h != FF80h
//promote:
//promote:
//promote:
FFFFh == FFFFh
FF7Fh == FF7Fh
FF80h == FF80h
if (uch3 < ch1)
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
101
puts("UNSIGNED");
else
puts("SIGNED");
//nopromote:(uchar)80h < (uchar)FEh
//promote:
(int)
128 > (int)
-2
puts("DONE.");
}
To produce code that is both efficient and correct, it is recommended that you adhere to the
following programming practices:
1. Turn ANSI promotions off (this is now the default).
2. Use variables of type char or unsigned char wherever the expected range of values for
the variable is [-128..127] or [0..255] respectively.
3. 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 turned off, the compiler automatically promotes a smaller operand
so that the types of the operands match.)
4. It is good programming practice to use explicit casts, even where automatic
promotions are expected.
To control ANSI promotions using ZDS II and the XTools tool chain, you can do the following:
•
Insert the #pragma promote and #pragma nopromote preprocessor directives
into your source file for function-level control over the ANSI promotions.
•
Explicitly cast constant expressions that you want to be evaluated as char (for
example, (char)0xFF).
•
Deselect the ANSI Promotions check box.
By deselecting this check box, the compiler generates smaller, faster code because
implicit conversions from chars to ints or from ints to longs are no longer inserted.
Select the ANSI Promotions check box when you need a local stack frame that is longer
than 127 bytes.
Strict ANSI Conformance
When selected, the Strict ANSI Conformance check box tells the compiler to look for
strict conformance to the ANSI standard. The default is checked. The use of any obsolete
feature, such as old-style function argument syntax and missing function prototypes,
causes the compiler to generate warning messages.
Note: The ZDS II compiler is more sensitive to ANSI standards than the ZDS compiler. While it
is preferred that nonstandard code is updated, in cases where this is not an option, deselect
the Strict ANSI Conformance check box.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
102
One Code Segment per Module
When selected, the One Code Segment per Module check box tells the compiler to check
that only one code segment is used for each module. The default is checked.
Use Intrinsics
When selected, the Use Intrinsics check box tells the compiler to generate in-line code
functions whenever possible. This setting affects only the compiler-defined intrinsics: EI,
DI, and SET_VECTOR. These functions can be generated in-line for more efficient or
generic code. However, the code size might increase if you use the intrinsics function frequently. You cannot define your own intrinsics. The default is checked.
Note: SET_VECTOR is not actually a function call and is always expanded by the
complier. It is not affected by the Use Intrinsics check box.
Generate Printfs Inline
Normally, a call to printf() or sprintf() parses the format string at run time to generate the required output. When the Generate Printfs Inline check box is selected, the format
string is parsed at compile time, and direct inline calls to the lower level helper functions
are generated. This results in significantly smaller overall code size because the top-level
routines to parse a format string are not linked into the project, and only those lower level
routines that are actually used are linked in, rather than every routine that could be used by
a call to printf. The code size of each routine that calls printf() 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 necessary:
•
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);
•
The functions vprintf() and vsprintf() cannot be used, even if the format string
is a string literal.
If the Generate Printfs Inline check box is selected and these conditions are not met, the
compiler warns you that the code size cannot be reduced. In this case, the compiler generates 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
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
103
level functions require more space with no compensating savings from removing the toplevel 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.
This is a new setting in ZDS II release 4.9. Deselecting the Generate Printfs Inline check
box makes the compiler behave as it did in all previous releases.
Optimizations Category
The ANSI C-Compiler comes with a powerful optimizer that makes your programs
smaller and/or faster. If you leave all Optimizer options set at their defaults, you get the
best possible code while minimally interfering with debugging. However, eZ80Acclaim!
developer’s environment gives you the ability to selectively disable most optimizations
using the Project Settings dialog box (C tab, Optimizations category).
Note: Some optimizations are performed regardless of optimizer settings because disabling them
causes an exponential expansion in code size. Changing any option and clicking OK
causes a message to display asking you if you want to “dirty” the C source files. If you
click Yes, all C files are recompiled when you run the make utility.
The optimizer independently performs local and global optimizations that you select in the
Type drop-down list box. Local optimizations are performed on a basic block basis. That
is, their scope is very limited, confined to straight-line code with no jumps or loops.
Global optimizations are performed at the function level and work across jumps and loops.
Figure 44 shows the Optimizations category of the C tab.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
104
Figure 44. Project Settings Dialog Box (C Tab, Optimizations Category)
Local Optimizations
Local optimizations are performed on a basic block basis. A basic block is a straight
line code that can only be entered at the top and exited at the bottom. Local optimizations
improve your program byScleaning up inefficiencies induced by C, compiler code
generation, or poor coding practices. Because these inefficiencies are very common, local
optimizations can improve your code's performance by up to 50%.
Normally, set all local optimizations because having them set causes the compiler to generate more efficient code and has negligible affects on debugging capabilities. However, if
the generated code contains errors, deselecting one of these optimizations might give you
a workaround.
For local optimizations, do the following:
1. Select Local from the Type drop-down list box.
2. In the Optimizations drop-down list box, select Maximize Speed or Minimize Size
for preset optimization configurations; select Disable for no optimizations; or select
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
105
Custom to choose which optimizations are performed. A description of each of the
optimizations follows:
– The Common Subexpressions check box controls the execution of common
subexpression elimination. Common subexpressions are expressions that occur
more than once in your program. As long as there is an efficient location to store
the expression’s value, subsequent occurrences of the expression need not be
recalculated. Instead, the result of the first occurrence of the expression is used.
For example:
a = b + c;
d = b + c;
–
is converted to
a = b + c;
d = a;
The Constant Folding check box determines whether constant folding
optimization is performed. Constant folding is performed when an expression
contains constant values that can be folded into a single constant without changing
the value of the expression. For example:
c = 10 * 10;
is converted to
c = 100;
if statements are another example of constant folding. For example:
#define X 10
if (X > 10)
++x;
else
--x;
–
–
UM014418-0205
--x;
The Copy Propagation check box determines whether the copy propagation
optimization is performed. Copy propagation is a special case of common
subexpression elimination where constant values can be substituted for arbitrarily
complex expressions. For example:
a = 10;
b = 10;
c = a * b;
–
is converted to
is converted to
a = 10;
b = 10;
c = 10 * 10;
The Peephole Optimizations check box determines whether peephole
optimizations are performed. Peephole optimizations are target-specific
optimizations that take into account the nuances of the eZ80Acclaim!’s instruction
set. These optimizations convert short sequences of instructions (not necessarily
contiguous) into shorter, more efficient sequences.
For the Optimize For buttons, select Speed or Size.
When your code is small and has two to three switch statements, it is
recommended to Optimize for Speed to generate smaller code.
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
106
Global Optimizations
Global optimizations are performed at the function, rather than the basic block, level.
Global optimizations can significantly increase code efficiency in some cases. However,
global optimizations rarely improve code efficiency by more than 10%.
Some global optimizations, especially common subexpression elimination, might make
debugging difficult because code is moved around in seemingly random ways.
Not all global optimizations are implemented for all target processors.
For global optimizations, do the following:
1. Select Global from the Type drop-down list box.
2. In the Optimizations drop-down list box, select Maximize Speed or Minimize Size
for preset optimization configurations; select Disable for no optimizations; or select
Custom to choose which optimizations are performed. A description of each of the
optimizations follows:
– The Loop Optimizations check box determines whether optimizations are
performed on loops in your program. Loop optimizations can improve
performance by rearranging code so that it is executed inside the loop only if
absolutely necessary. Also, the location of the comparison for loop termination
might be moved in order to minimize the number of jumps necessary to
implement the loop.
– The Common Subexpressions check box determines whether global common
subexpressions are eliminated. Global common subexpressions are similar to
local common subexpressions but are performed across basic blocks. For
example:
a = b + c;
if (x)
d = b + c;
else
e = b + c;
–
–
UM014418-0205
is converted to
a = b + c;
if (x)
d = a;
else
e = a;
The Span-Dependent Instructions check box determines whether span-dependent
instructions are optimized. Span-dependent instructions are those that can
have more than one form based on the distance of the instruction from its
destination. Relative jumps and calls are the primary span-dependent instructions.
The span-dependent instruction optimization modifies all such instructions to be
of the smallest form possible.
The Branch Optimizations check box determines whether branch optimizations
are performed. Branch optimizations reduce the number of branches necessary to
implement your flow of control. Typically, nested if-else statements and switch
statements cause unconditional branches to other unconditional branches. The
branch optimization removes these redundant branches.
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
107
–
The Constant Folding check box determines whether the global constant folding
optimization is performed. Global constant folding is similar to local constant
folding but is performed across basic blocks. For example:
a = 10;
b = 20;
if (x)
c = a + b;
–
a = 10;
b = 20;
if (x)
c = 30;
The Copy Propagation check box determines whether the global copy propagation
optimization is performed. Global copy propagation is similar to local copy
propagation, but is performed across basic blocks. For example:
a = 10;
b = 20;
if (x)
c = a + b;
–
is converted to
is converted to
a = 10;
b = 20;
if (x)
c = 10 + 20;
For the Optimize For buttons, select Speed or Size.
When your code is small and has two to three switch statements, it is
recommended to Optimize for Speed to generate smaller code.
Data Types Category
Figure 46 shows the Data Types category of the C tab.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
108
Figure 45. Project Settings Dialog Box (C Tab, Data Types Category)
Object Sizes
Object sizes are the number of bits for each base type (short, int, and so on) in C. If you are
porting existing code from one target platform to another—for example, from another
software vendor to eZ80Acclaim! developer’s environment—knowing the size of each
object and setting up eZ80Acclaim! developer’s environment to match the import size can
save you a significant amount of time.
The Object Size group contains the following:
•
•
•
•
•
•
•
UM014418-0205
Char
Short
Float
Long
Int
Double
Bitfield
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
109
The drop-down list boxes for the object sizes are used to define the sizes of data objects to
the C-Compiler. The list boxes allow you to configure the number of bits of each of the
base data types. Modifying the sizes of data types can be useful when porting existing
code from another target processor or from another software vendor. Some data types cannot be modified and are therefore grayed.
Caution: Your programs might not run correctly if you compile files from the same program under
different object size settings. Also, changing object sizes might prevent you from using
the C run-time library routines.
Listing Files Category
Figure 46 shows the Listing Files category of the C tab.
Figure 46. Project Settings Dialog Box (C Tab, Listing Files Category)
Generate Compiler Listing File (.lis)
When selected, the Generate Compiler Listing File (.lis) check box tells the compiler to
create a listing file (with the .lis file extension). All source lines are duplicated in this
file, as are any errors encountered by the compiler.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
110
List Include Files in .lis
When selected, the List Include Files in .lis check box tells the compiler whether the contents of all files included using the #include preprocessor directive must be duplicated in
the compiler listing file. This can be helpful if there are errors in included files.
Expand Macros on Error
When selected, the Expand Macros on Error check box tells the compiler to expand all C
macros on C source lines written to the message window when an error occurs. This
option helps in detecting macro expansion errors in your C code.
Generate Assembly Source (.src)
When selected, the Generate Assembly Source (.src) check box tells the compiler to create
the assembly source code.
Interleave Source and Assembly
When selected, the Interleave Source and Assembly check box tells the compiler to
include the associated C source code in the generated assembly source files.
Generate Listing File (.lst)
When selected, the Generate Listing File (.lst) check box tells the compiler whether to
keep the assembly source file after compiling your code. This can be useful when you
want to inspect or modify the assembly code generated by the compiler. Deselecting this
option causes the compiler to remove the .lst file after it has been assembled.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
111
Preprocessor Category
Figure 47 shows the Preprocessor category of the C tab.
Figure 47. Project Settings Dialog Box (C Tab, Preprocessor Category)
Preprocessor Definitions
The Preprocessor Definitions field is equivalent to placing #define preprocessor directives before any lines of code in your program. It is useful for conditionally compiling
code. Do not put a space between the symbol\name and equal sign; however, multiple
symbols can be defined and must be separated by commas.
Standard Include Path
The Standard 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 <file.h> preprocessor directive. If more than one path is used, the paths
are separated by semicolons (;). The compiler first checks the current directory, then the
paths in the Standard field. The default standard includes are located in the following
directory:
ZILOGINSTALL\ZDSII_product_version\include\std directory
where
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
112
•
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
User Include Path
The User 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.h" in the compiler. If more than one path is used, the paths are separated by
semicolons (;). The compiler first checks the current directory, then the paths in the User
field.
Assembler Tab
In the Project Settings dialog box, select the Assembler tab. The assembler uses the contents of the Assembler tab to determine which options are to be applied to the files assembled.
The options on the Assembler tab (Figure 48) are described in this section.
Figure 48. Project Settings Dialog Box–Assembler Tab
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
113
Debug Information
When selected, the Debug Information check box tells the assembler to place debugging
information into relocatable object modules. The default is checked.
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
•
outside of the +127 to –128 range
For example, when the target is out of range, the assembler changes
DJNZ r0, lab
to
DJNZ r0, lab1
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. However, if you do not want the assembler to
make these replacements, deselect Jump Optimization.
The default is checked.
Generate Object
When selected, the Generate Object check box tells the assembler to generate relocatable
object files. The default is checked.
Ignore Case
When selected, the Ignore Case check box tells the assembler to convert all symbols to
uppercase.
Generate Listing File (.lst)
When selected, the Generate Listing File check box tells the assembler to create an assembly listing file. The default is checked.
Expand Macros
When selected, the Expand Macros check box tells the assembler to expand macros in the
assembly listing file.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
114
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.
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.
Display Errors/Warnings Only
When selected, the Display Errors/Warnings Only check box tells the assembler if it can
display messages other than errors and warnings in the Build Output window.
Display Warnings
When selected, the Display Warnings check box tells the assembler to display warnings in
the Build Output window.
Include Path
The Include Path 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 Include Path field, and finally on the default ZDS II include directories.
The ZDS II default include directories are:
ZILOGINSTALL\ZDSII_product_version\include\std
ZILOGINSTALL\ZDSII_product_version\include\zilog
and for some other IDEs:
ZILOGINSTALL\ZDSII_product_version\include
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.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 corresponding value (<name>=<value>). Multiple symbols can be defined and must be separated by commas.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
115
ZSL Tab
In the Project Settings dialog box, select the ZSL tab. The ZSL tab allows you to use the
ZiLOG Standard Library (ZSL) in addition to the run-time library (described in Chapter 4,
Using the ANSI C-Compiler). The ZSL contains functions for controlling the UART
device driver. These functions are described in detail in the ZiLOG Standard Library API
Reference Manual (RM0037).
The options on the ZSL tab (Figure 49) are described in this section.
Figure 49. Project Settings Dialog Box–ZSL Tab
Use ZiLOG Standard Library
Select the Use ZiLOG Standard Library check box to use the functions contained in the
ZiLOG Standard Library.
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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
116
Linker Tab
In the Project Settings dialog box, select the Linker tab. There are four categories available:
•
•
•
•
“General Category” on page 116
“Input Category” on page 122
“Address Spaces Category” on page 127
“Output Category” on page 128
The options on the Linker tab are described in this section.
General Category
Figure 50 shows the General category of the Linker tab.
Figure 50. Project Settings Dialog Box (Linker Tab, General Category)
Output File Name
You can change the name of your executable in the Output File Name field. After your
program is linked, the appropriate extension is added.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
117
Object/Library Modules
Use the Object/Library Modules field to list object files and libraries that you want linked
into the project executable. Separate modules with a comma.
Generate Warnings
This check box determines whether the linker generates warning messages. If you do not
select this option, the linker does not display warning messages in the message window.
Generate Debug Info
This check box determines whether the linker places debugging information into your executable files. This option is applicable only if you select the executable format IEEE 695.
Note: The Generate Debug Information options on the C tab must be checked before this check
box has any effect.
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 your project’s name with the .map extension. See page 347
and page 369.
Note: The link map is an important place to look for memory restriction or layout problems.
Ignore Case
This check box determines whether the linker ignores the case of public symbols.
Symbol Cross-Reference
This check box determines whether the linker generates symbol cross-references in the
map file. If disabled, this option speeds up your linking process.
Perform Re-List
This check box determines whether the linker includes a “relist” target in the generated
make file and whether the build target uses it. This feature is not checked by default.
To generate a listing file with absolute addresses (source_file_name.lst), you need to
also select the Generate Map File check box. In addition, if your project contains C source
files, select the Generate Assembly Source (.src) check box in the Listing Files category of
the C tab.
Note: If the Generate Assembly Source (.src) check box on the C tab (Listing Files
category) is not checked, only the assembly files are relisted.
Link Configuration
Click Link Configuration to display the Select Link Configuration dialog box
(Figure 51).
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
118
Figure 51. Select Link Configuration Dialog Box
1. Select a configuration.
Select the configuration that best fits your target. The project settings are modified
accordingly. ZDS II automatically generates a linker command file using the project
settings. You can choose to include your own linker command file.
Note: ZDS II—eZ80Acclaim! allows you an amazing amount of control over where
physical blocks of RAM and ROM (both internal and external) are located in the
system. However, any blocks of Flash memory that use different programming
algorithms must be separated by at least 0x40 bytes. If this is not done, you cannot
flash the project on the target. As an example, the internal and external Flash
memory on the eZ80F91 development kit use different Flash algorithms so the
Target memory range must contain at least a 0x40 byte gap between these two
Flash regions.
–
All RAM
This configuration produces a single memory image that resides and executes
from RAM. This configuration is most useful when emulating code from RAM on
the eZ80L92 and eZ80190 evaluation boards. Using the ZDS II standard startup
module with this configuration produces the most effective run-time environment.
In this configuration, the linker maps all segments associated with the logical
ROM address space to physical RAM. ZDS II therefore automatically generates
two linker commands:
GROUP MEMORY=ROM,RAM
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
119
This command defines a new address space (MEMORY) that contains the existing
logical address spaces RAM and ROM.
RANGE MEMORY $0 : $FFFF
This command defines the physical address range for the combined spaces.
ZDS II creates the RANGE command starting with the lowest address specified in
the Address Spaces category of the Linker tab and ending with the highest
address. The lowest address is min(min(ROM), min(RAM)) and the highest
address is max(max(ROM),max(RAM)). These two ZDS II-generated commands
are critical for building an All RAM configuration.
Both the GROUP MEMORY and RANGE MEMORY commands are required for the All
RAM configuration. If the RANGE MEMORY command is omitted, the result can be
wasted space. To illustrate the effects of such an error, suppose the Address
Spaces category of the Linker tab has the following values for a 64K memory
machine:
ROM 0-7FFF
RAM 8000-FFFF
If the All RAM configuration is not used to create the linker command file, ZDS
II converts the values in the Address Spaces category of the Linker tab to the
following linker commands:
RANGE ROM $0 : $7FFF
RANGE RAM $8000 : $FFFF
which, if followed by
GROUP MEMORY=ROM,RAM
would result in ROM segments starting at address 0h and RAM segments starting
at 8000h, potentially wasting space if the ROM segments do not fully occupy the
range from 0h - 7FFFh. The RANGE MEMORY 0h : FFFFh command overrides
the RANGE commands for the component address spaces and binds the RAM
segments immediately after the ROM segments.
Note: The names following the = in the GROUP command define an ordering for the new
GROUP. In the preceding example, all of the ROM segments are allocated memory
at lower addresses than the RAM segments. However, the GROUP statement locates
all of the RAM segments first. For example:
GROUP MEMORY=RAM,ROM
–
Standard
This configuration produces the most common embedded environment. Code
resides in Flash/ROM, and data is placed in RAM. Using the ZDS II standard
startup module with this configuration produces the most effective run-time
environment.
In the Standard configuration, the hardware has both physical RAM and physical
ROM. The Linker commands generated by ZDS II map logical RAM segments to
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
120
physical RAM and logical ROM segments to physical ROM. Suppose the
Address Spaces category of the Linker tab contained the following values:
ROM 0-7FFF
RAM A000-FFFF
ZDS II generates the following code for the linker command file:
RANGE ROM $0 : $7FFF
RANGE RAM $A000 : $FFFF
The linker uses the COPY command on segments to better support standalone C
programs. When running a C program under an operating system such as
Windows or UNIX, all initialized variables are set to their starting values upon the
start of program execution. In a standalone C implementation, however, there is
no operating system to reload variables with their initial values. With no operating
system, if an embedded application runs for a while and is then restarted at
main(), the values of initialized variables will not be restored to their original
value. The linker’s COPY command, together with the startup module, provides a
means to reinitialize variables.
The linker normally loads the DATA segment (initialized data) into RAM. Once
the initialized data has been loaded into RAM and modified by program
execution, in the absence of the COPY mechanism the only way to reload the
initial DATA segment would be to download the code to the target board again.
This approach is not practical for most embedded systems. (The embedded
application would have to save all the initialized data and reload the initial values
upon RESET, for example.)
The COPY command (for example, COPY DATA ROM) causes the linker to put a
copy of the DATA segment in the ROM space at load time. The standard startup
module will always copy the DATA segment to RAM before calling main(). The
COPY command copies segments into spaces only. Any other copy combination
generates an error. The startup module requires additional linker commands to
perform the copy. The “Components for All Linker Configurations” on page 340
describes these commands.
The ORDER command allows the user to define the sequence of segments within a
memory space. In the Standard configuration, ZDS II generates the following
command to put the initialized data segment at a lower address than the
uninitialized data segment:
ORDER DATA,BSS
–
UM014418-0205
Copy to RAM
This configuration produces a memory image that resides in Flash/ROM and is
copied to RAM for execution. This configuration is typically used to take
advantage of RAM's faster operation. Using the ZDS II standard startup module
with this configuration produces the most effective run-time environment.
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
121
This configuration provides support for copying code as well as data segments
from physical ROM to physical RAM. The idea is to compensate for the
performance penalty often associated with running code from ROM. A ROM
instruction fetch, for example, might require more wait states than a RAM
instruction fetch. It is therefore more efficient to run code from RAM than to run it
from ROM, provided the target system has enough RAM for the program code
and data. As in the other configurations, ZDS II automatically generates linker
commands in the linker command file to support this operating mode, when Copy
to RAM is selected.
To run code from the RAM space, the Linker must do two things:
— Reassign all of the CODE segment addresses to RAM instead of ROM.
— Place a copy of the CODE segment in ROM for an application restart (the
startup module re-copies it from ROM to RAM upon restart).
The linker CHANGE command allows you either to rename a segment or reassign a
segment to another space. For example
CHANGE TEXT is DATA
CHANGE CODE is RAM
CHANGE STRSECT is CODE
causes the linker to
1. Combine the TEXT segment into the DATA segment.
2. Reassign the CODE segment to the RAM space.
3. Combine the STRSECT segment into the CODE segment.
These three CHANGE commands reassign all addresses in the CODE, TEXT, and
STRSECT segments into RAM, for the fastest possible execution.
The final step requires the RAM space to be copied in ROM space, so that it can
be reloaded from ROM when the application starts. Adding the following code
COPY DATA ROM
COPY CODE ROM
–
causes both the CODE and DATA segments to be copied to ROM. These segments
are then copied by the startup code to the appropriate RAM addresses, completing
the actions associated with the Copy to RAM configuration.
Custom
Choose this option if the other three options do not provide the right
configuration. As a result, you are required to define all of the segment-to-space
mappings, depending on the hardware configuration of the application board. You
need to include your own startup module for this selection.
2. Click OK.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
122
Input Category
Figure 52 shows the Input category of the Linker tab.
Figure 52. Project Settings Dialog Box (Linker Tab, Input Category)
Object/Library Modules
Use the Object/Library Modules field to list object files and libraries that you want linked
into the project executable. Separate modules with a comma.
Boot Module
All C programs require some initialization before the main function is called. This is typically done in a boot module. In the Boot Module area, select one of the three buttons:
•
Select the Included in Project button if you have already specified a boot module to be
included in your project. This button is selected by default.
•
Select the Default button to link the boot module supplied with ZDS II into the project
executable.
The default boot module comprises three of the following files:
– vectors16.obj for eZ80190, eZ80L92, eZ80F92, and eZ80F93 devices
This object contains an interrupt vector and jump table that must reside in the first
64-KB boundry and an interrupt vector jump table that can reside anywhere
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
123
within the 16-MB memory space and can be initialized by calling
init_default_vectors() from main().
vectors16.obj contains a Reset/Restart table that must reside at address 0000h
for handling Hardware Reset and the RST xx instructions. Currently, all RST xx
instructions cause full software reboot.
The source file for vectors16.obj is in the following directory:
ZILOGINSTALL\ZDSII_product_version\src\rtl\common
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!, eZ80Acclaim!, Crimzon, or Z8GP.
— version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
– vectors24.obj for the eZ80F91 device
vectors24.obj contains an interrupt vector table that can reside anywhere
within the 16-MB memory space and can be initialized by calling
init_default_vectors() from main().
vectors24.obj contains a Reset/Restart table that must reside at address 0000h
for handling Hardware Reset and the RST xx instructions. Currently, all RST xx
instructions cause full software reboot.
The source file for vectors24.obj is in the following directory:
ZILOGINSTALL\ZDSII_product_version\src\rtl\common
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!, eZ80Acclaim!, Crimzon, or Z8GP.
— version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
– init_params_190.obj, init_params_l92.obj, init_params_f93.obj,
init_params_f92.obj, or init_params_f91.obj
Initializes the memory device arrangement according to the Debuggers Chip
Select Initialization Parameters and the Stack Pointer according to the Target
RAM range. Disables peripheral interrupts.
The source files for these files are in the following directory:
ZILOGINSTALL\ZDSII_product_version\src\rtl\product
where
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
124
— 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!, eZ80Acclaim!, Crimzon, or Z8GP.
— version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
–
cstartup.obj
Initializes the C run-time environment
The source file for cstartup.obj is in the following directory:
ZILOGINSTALL\ZDSII_product_version\lib\zilog
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!, eZ80Acclaim!, Crimzon, or Z8GP.
— version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
For example, if you are using eZ80F91 and choose to include the default boot module,
vectors24.obj, init_params_f91.obj, and cstartup.obj are linked in to
your program.
•
Select the Custom button to define the file name and path of a custom boot module.
Caution: If you select the Included in Project button or the Custom button and use the startup
source or object provided with the tools (init_params_f91.asm, which includes
sysclk.asm or corresponding .obj files), building the project results in linker errors
and warnings. Follow these steps to add the correct linker directives to initialize variables
in your project:
1. Open your project.
2. From the Project menu, select Settings.
3. In the Input category of the Linker tab, select the Default button and click OK.
4. Click Yes to the warning message: "The project settings have changed
since the last build. Would you like to rebuild the affected
files?"
The linker command file is generated even if the build is not successful.
5. Open the generated linker command file (project_name.linkcmd) and copy
everything from ORDER .RESET,.IVECTS,.STARTUP,CODE,DATA to the fifth
blank line or before this line:
"C:\Program Files\ZiLOG\ZDSII_eZ80Acclaim!_x.x.x\samples\StarterProject\starter"= \
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
125
6. Paste the directives into the Additional Linker Directives dialog box (page 122).
7. Click OK to return to the Project Settings dialog box.
8. Click OK to save your settings.
9. Click Yes to the warning message: "The project settings have changed
since the last build. Would you like to rebuild the affected
files?"
10. Reset your project settings and rebuild your project.
Linker Command File
The linker is automatically invoked when you click the Build button or Rebuild All button
on the Build toolbar to your project. The linker executes controls found in a predetermined
linker command file. In the Linker Command File area, select one of the three buttons:
•
Select the Create New button if you want ZDS II to automatically generate a linker
command file. This button is selected by default.
When you select the Create New button, the Add Directives button is enabled. Click
Add Directives to display the Additional Linker Directives dialog box (Figure 53).
Figure 53. Additional Linker Directives Dialog Box
You do not need to add any directives if you select the All RAM, Standard, or Custom
link configuration (in the Configure New Project dialog box or the Select Link
Configuration dialog box) and select the Create New button in the Input category of
the Linker tab. If you use these settings, ZDS II creates the initial linker command file.
The only time you need to add directives is if you have, for example, a module that
must be loaded at a specific address or if you want to change the order sections are
loaded into memory. For more information about changing the link order, see “How
do I control the link order?” on page 365.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
126
If you are using IPWorks, IPWorks supplies a linker command file, so you need to
select the Use Existing button in the Input category of the Linker tab to prevent ZDS II
from creating a new linker command file.
After you finish adding directives, click OK.
•
Select the Custom button to define the file name and path of a custom linker command
file.
When you select the Custom button, the Edit Custom button is enabled. Click Edit
Custom to display the Custom Linker Command File dialog box (Figure 54).
Figure 54. Custom Linker Command File Dialog Box
After you finish editing the linker command file, click Accept Changes.
Note: If you are using a custom link file and then change to a different processor or
processor family, you need to update the linker file manually.
•
UM014418-0205
Select the Use Existing button and use the Browse button (
command file the linker uses.
) to select which linker
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
127
Use C Runtime Library
The Use C Runtime Library check box allows you to use the run-time library. If you select
this button, you cannot select the None button in the Startup Module area.
Note: When you have an assembly project, deselect this check box to turn off the run-time
library. If you do not deselect this check box, you get the message Symbol: Linker
Warning: 724 "_main has not been defined."
Address Spaces Category
Figure 55 shows the Address Spaces category of the Linker tab.
Figure 55. Project Settings Dialog Box (Linker Tab, Address Spaces Category)
Memory ranges are used to determine the amount of memory available on your target system. Using this information, eZ80Acclaim! developer’s environment lets you know when
your code or data has grown beyond your system’s capability. The system also uses memory ranges to automatically locate your code or data.
The Address Spaces fields define the memory layout of your target system. The Address
Spaces category of the Linker tab of the Project Settings dialog box allow you to configure
the ranges of memory available on your target digital signal processor. These ranges vary
from processor to processor, as well as from target system to target system.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
128
Depending on your CPU selection, the Address Spaces category can contain the following
fields:
•
•
•
•
•
Rom
Ram
ExtIO
IntIO
FlashInfo
Address ranges are set in the Address Spaces fields. The following is the syntax of a memory range:
<low address> – <high address> [,<low address> – <high address>] ...
where <low address> is the hexadecimal lower boundary of a range and <high address> is
the hexadecimal higher boundary of the range. The following are legal memory ranges:
00-df
0000-ffff
0000-1fff,4000-5fff
Holes in your memory can be defined for the linker using this mechanism. The linker does
not place any code or data outside of the ranges specified here. If your code or data cannot
be placed within the ranges, a range error is generated.
Note: ZDS II—eZ80Acclaim! allows you an amazing amount of control over where physical
blocks of RAM and ROM (both internal and external) are located in the system. However,
any blocks of Flash memory that use different programming algorithms must be separated
by at least 0x40 bytes. If this is not done, you cannot flash the project on the target. As an
example, the internal and external Flash memory on the eZ80F91 development kit use
different Flash algorithms so the target memory range must contain at least a 0x40 byte gap
between these two Flash regions.
Output Category
Figure 56 shows the Output category of the Linker tab.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
129
Figure 56. Project Settings Dialog Box (Linker Tab, Output Category)
Output File
You can change the name of your executable in the Output File field. After your program
is linked, the appropriate extension is added.
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 (.lod), Intel Hex16
and Hex32 (.hex), and Motorola S-Records (.srec) which are useful when programming an EPROM after testing is complete. IEEE 695 is the default format of the linker/
locator because it is the preferred format for debugging. Select Intel Hex16 or Hex32 to
generate a hex file. You can select more than one check box.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
130
Debugger Tab
In the Project Settings dialog box, select the Debugger tab (Figure 57).
Figure 57. Project Settings Dialog Box–Debugger Tab
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.
From the Build menu, go to the Debug submenu and select Reset. This moves you into
Debug mode.
You are now in Debug mode as shown in the Output window (Debug tab). The Debug
toolbar and Debug Windows toolbar are displayed.
Your understanding of the debugger design can improve your productivity because it
affects your view of how things work. The debugger requires a driver that is specific to a
target platform. A target platform can be a simulator or emulator. A simulator requires no
hardware because it simulates the function of your target platform on your PC. Drivers for
emulators require that your PC be connected to the appropriate hardware. Currently, the
debugger supports drivers for the eZ80Acclaim! simulator, the serial SmartCable, and the
USB SmartCable, depending on your CPU and whether you are using an emulator.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
131
Select Target Area
Select a target to configure in the Select Target area.
Communication
Note: The Communication button is not available if the Simulator is selected.
Use the Communication button to do the following:
•
•
•
“Set Up Communication for an Ethernet Target” on page 131
“Set Up Communication for a Serial Target” on page 132
“Set Up Communication for a USB Target” on page 133
Set Up Communication for an Ethernet Target
1. Select the Ethernet check box.
2. Select an Ethernet target from the Select Target area.
3. Click Communication.
The Setup TcpIP Communication dialog box (Figure 58) is displayed.
Figure 58. Setup TcpIP Communication Dialog Box
4. Type the IP address in the IP Address field.
5. Type the port number in the TCP Port field.
6. Select the Use Alternate ZDI Clock Frequency check box if you want to use the ZDI
clock frequency.
In previous versions of the ZDS II, you were required to choose the appropriate ZDI
clock frequency. In releases after 4.7.2, that option has been replaced with the system
clock and oscillator frequency so that ZDS can choose the appropriate ZDI
communication rate(s).
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
132
ZDS uses the information in the following table to make the ZDI clock frequency
selection:
ZDI Clock Frequency
System Clock Frequency (alternate)
1 MHz
2-6 (2-6) MHz
2 MHz
4-12 (6-12) MHz
4 MHz
8-24 (12-24) MHz
8 MHz
16-50 (24-50) MHz
If a reliable connection cannot be established and the system clock frequency is within
an overlapping area, you can override the default choice by selecting the Use
Alternate ZDI Clock Frequency check box. Selecting the alternate system clock table
changes the ZDI clock frequency used by ZDS. For instance, if the system clock is 20
MHz, the 4-MHz ZDI clock rate might prove to be more reliable then the 8-MHz rate.
ZDS assumes that the system clock change occurs somewhere after reset and before
the main() routine.
7. Click OK.
Set Up Communication for a Serial Target
1. Select the Serial check box.
2. Select a serial target from the Select Target area.
3. Click Communication.
The Setup Serial Communication dialog box (Figure 59) is displayed.
Figure 59. Setup Serial Communication Dialog Box
4. Use the Baud Rate drop-down list box to select the appropriate baud rate: 19200,
38400, 57600, or 115200. The default is 57600.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
133
5. Use the Port drop-down list box to select the appropriate port: COM1, COM2, COM3,
COM4, COM5, COM6, COM7, COM8, COM9, COM10, COM11, COM12, COM13,
COM14, COM15, or COM16. The default is COM1.
6. Select the Use Alternate ZDI Clock Frequency check box if you want to use the ZDI
clock frequency.
In previous versions of the ZDS II, you were required to choose the appropriate ZDI
clock frequency. In releases after 4.7.2, that option has been replaced with the system
clock and oscillator frequency so that ZDS can choose the appropriate ZDI
communication rate(s).
ZDS uses the information in the following table to make the ZDI clock frequency
selection:
ZDI Clock Frequency
System Clock Frequency (alternate)
1 MHz
2-6 (2-6) MHz
2 MHz
4-12 (6-12) MHz
4 MHz
8-24 (12-24) MHz
8 MHz
16-50 (24-50) MHz
If a reliable connection cannot be established and the system clock frequency is within
an overlapping area, you can override the default choice by selecting the Use
Alternate ZDI Clock Frequency check box. Selecting the alternate system clock table
changes the ZDI clock frequency used by ZDS. For instance, if the system clock is 20
MHz, the 4-MHz ZDI clock rate might prove to be more reliable then the 8-MHz rate.
ZDS assumes that the system clock change occurs somewhere after reset and before
the main() routine.
7. Click OK.
Set Up Communication for a USB Target
1. Select the USB check box.
2. Select a UiSB target from the Select Target area.
3. Click Communication.
The Setup USB Communication dialog box (Figure 60) is displayed.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
134
Figure 60. Setup USB Communication Dialog Box
4. Use the Serial Number drop-down list box to select the appropriate serial number.
5. Select the Use Alternate ZDI Clock Frequency check box if you want to use the ZDI
clock frequency.
In previous versions of the ZDS II, you were required to choose the appropriate ZDI
clock frequency. In releases after 4.7.2, that option has been replaced with the system
clock and oscillator frequency so that ZDS can choose the appropriate ZDI
communication rate(s).
ZDS uses the information in the following table to make the ZDI clock frequency
selection:
ZDI Clock Frequency
System Clock Frequency (alternate)
1 MHz
2-6 (2-6) MHz
2 MHz
4-12 (6-12) MHz
4 MHz
8-24 (12-24) MHz
8 MHz
16-50 (24-50) MHz
If a reliable connection cannot be established and the system clock frequency is within
an overlapping area, you can override the default choice by selecting the Use
Alternate ZDI Clock Frequency check box. Selecting the alternate system clock table
changes the ZDI clock frequency used by ZDS. For instance, if the system clock is 20
MHz, the 4-MHz ZDI clock rate might prove to be more reliable then the 8-MHz rate.
ZDS assumes that the system clock change occurs somewhere after reset and before
the main() routine.
6. Click OK.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
135
Setup
Use the Setup button to do one of the following:
•
•
“Set Up the Simulator” on page 135
“Set Up an Ethernet, Serial, or USB Target” on page 136
Set Up the Simulator
1. Select the Simulator check box in the Select Target area.
2. Click Setup.
The Setup Simulator dialog box (Figure 61) is displayed.
Figure 61. Setup Simulator Dialog Box
3. In the Clock Speed (MHz) field, type the appropriate speed.
The default is 20.000000.
4. Move the thumb bar or scroll the scroll bar to adjust the Simulator Throttle from 1% to
100%.
A 1% throttle means that the simulator uses approximately 1% of the system's
resources while executing your program's instructions. This leaves plenty of power to
do other things while the simulator is running. A throttle of 100% uses virtually all of
your CPU’s processing time to execute your program, allowing it to complete faster
but slows any other Windows functions down considerably. The recommended setting
is 50%.
5. Select the Load Memory Files check box if you want the debugger to automatically
load your memory files into the target platform's memory each time the debugger is
executed.
6. Select the Write Memory Files check box if you want the debugger to automatically
write your memory files into the target platform's memory each time the debugger is
executed.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
136
7. Click OK.
Set Up an Ethernet, Serial, or USB Target
1. Select the Ethernet, Serial, or USB target check box.
2. Select an Ethernet, serial, or USB target in the Select Target area.
3. Click Setup.
The Configure Target dialog box (Figure 62) is displayed.
Figure 62. Configure Target Dialog Box
Note: The options displayed in the Configure Target dialog box depend on the CPU you
selected in the General tab of the Project Settings dialog box.
ZDS II writes the initialization parameters to the target while the connection is being
established. This allows for a virtual reset condition to be created using the following:
a. Type the address of the first line of code to be executed in the Program Counter
(hex) field.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
137
b. Type the upper address of RAM (24-bit address boundary) in the SPL Stack
Pointer (hex) field. This option is used while in ADL mode.
c. Type the upper address of RAM (16-bit address boundary) in the SPS Stack
Pointer (hex) field. This option is used while in non-ADL mode.
d. Choose a chip select register from the Chip Select Registers drop-down list box.
The chip select registers control the type of access, address bounds, and wait state
assertion.
e. Enter the lower bound for the chip select register in the Lower Bound (hex) field.
f.
Enter the upper bound for the chip select register in the Upper Bound (hex) field.
g. Enter the control register in the Control Register (hex) field.
h. Enter the bus mode in the Bus Mode (hex) field.
i.
Select the Start in ADL Mode check box for 24-bit linear addressing. Deselect the
check box for 16-bit addressing.
j.
Select the Enable Data RAM check box to enable the general-purpose internal
RAM block. Enter the address in the Address Upper Byte (hex) field.
k. Select the Enable EMAC RAM check box to enable the Ethernet Media Access
Controller’s internal RAM. Enter the address in the Address Upper Byte (hex)
field.
l.
Select the Enable MACC RAM check box to enable the multiply-accumulate
engine’s internal RAM block. Enter the address in the Address Upper Byte (hex)
field.
m. Select the Enable Flash check box if you want to use internal Flash. Enter the
address in the Address Upper Byte (hex) field. This shifts Flash and affects the
pages displayed in the Flash Loader Processor dialog box. Select the number of
wait states from the Wait States drop-down list box. The wait states value is based
on the value of the system clock frequency according to the following table:
Wait States
UM014418-0205
System Clock (MHz)
0
<12
1
12-23.9
2
24-35.9
3
36-47.9
4
48-59.9
5
60-71.9
6
72-84
7
>84
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
138
You can select any wait states value; however, 5, 6, and 7 are not recommended
for performance reasons. Based on the currently configured system clock
frequency, ZDS II suggests the appropriate wait states value by appending an
asterisk to it in the Wait States drop-down list box. The asterisk moves to different
values when the system clock frequency is changed in the same dialog box. When
the target clock frequency is changed, you must update the wait states value if
needed.
n. To use the oscillator, select the Oscillator button and enter the frequency in the
System Clock Frequency (Hz) field.
o. To use the phase-locked loop, select the Phase-Locked Loop button, enter the
clock frequency in the System Clock Frequency (Hz) field, enter the oscillator
frequency in the Oscillator Frequency (Hz) field, select a charge pump current,
and select a lock criteria.
The eZ80F91 device contains a Phase-Locked Loop (PLL) module, the output of
which can be used as the system clock. This allows the application to run at 50
MHz with an oscillator frequency between 1 and 10 MHz. Since the system
defaults to using the oscillator upon power-on or hardware reset, the application
program must enable and select the PLL as the source of the system clock. This
also requires the ZDI clock frequency to change if a debug session is started so
that a reliable connection can be maintained. ZDS automatically changes the rate
after the first Reset or Go command is invoked and the Change ZDI Clock Upon
Reset check box has been selected.
ZDS assumes that the system clock change occurs somewhere after reset and
before the main() routine. For information about how to set up the charge pump
current and lock criteria, see the “Phase Locked Loop” chapter of the eZ80F91
MCU Product Specification (PS0192).
4. Click OK.
Add
To add a new target, use the following procedure:
1. Click Add.
The Create New Target Wizard dialog box (Figure 63) is displayed.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
139
Figure 63. Create New Target Wizard Dialog Box
2. Enter a unique target name into the field.
3. Use the Target Communication drop-down list box to select the appropriate
communication method.
4. Click Finish.
Your new target name is listed in the Select Target area.
Copy
To copy an existing target, use the following procedure:
1. Select a target in the Select Target area that you want to copy.
2. Click Copy.
The Copy a Target Wizard dialog box (Figure 64) is displayed.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
140
Figure 64. Copy a Target Wizard Dialog Box
3. Enter a unique target name into the field.
4. Use the Target Communication drop-down list box to select the appropriate
communication method.
5. Click Finish.
Your new target name is listed in the Select Target area.
Delete
To delete a target, use the following procedure:
1. Select the name of the target you want to delete in the Select Target area.
2. Click Delete.
3. Click Yes to the warning message to confirm that you want to delete the selected
target.
The deleted target is no longer listed in the Select Target area.
USB
Select the USB check box to display the USB targets in the Select Target area.
Serial
Select the Serial check box to display the serial targets in the Select Target area.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
141
Ethernet
Select the Ethernet check box to display the Ethernet targets in the Select Target area.
Export Makefile
Export Makefile exports a buildable project in external make file format. To do this, complete the following procedure:
1. From the Project menu, select Export Makefile.
The Save As dialog box (Figure 65) is displayed.
Figure 65. Save As Dialog Box
2. 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 and click Save.
You do not have to type the extension .mak. The extension is added automatically.
The project is now available as an external make file.
BUILD MENU
With the Build menu, you can build individual files as well as your project. You can also
use this menu to select or add configurations for your project.
The Build menu has the following options:
•
•
UM014418-0205
“Compile” on page 142
“Build” on page 142
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
142
•
•
•
•
•
•
“Rebuild All” on page 142
“Stop Build” on page 142
“Update All Dependencies” on page 142
“Debug” on page 142
“Set Active Configuration” on page 144
“Manage Configurations” on page 146
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 assembles any files that have changed since the last build and then relinks the project.
Rebuild All
Select Rebuild All from the Build menu to rebuild all the files in your project. This option
also relinks the project.
Stop Build
Select Stop Build from the Build menu to stop a build in progress.
Update All Dependencies
Select Update All Dependencies from the Build menu to update your source file
dependencies.
Debug
From the Build menu, you can access the following functions for the debugger:
•
•
•
•
•
•
•
UM014418-0205
“Connect to Target” on page 143
“Download Code” on page 143
“Stop Debugging” on page 143
“Reset” on page 143
“Go” on page 143
“Run to Cursor” on page 143
“Break” on page 144
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
143
•
•
•
•
“Step Into” on page 144
“Step Over” on page 144
“Step Out” on page 144
“Set Next Instruction” on page 144
Note: For more information on the debugger, see Chapter 3, “Debugging,” starting on page 164.
Connect to Target
The Connect to Target button starts a debug session and initializes the communication to
the target hardware. Clicking this button does not download the software or reset to main.
Use this button to access target registers, memory, and so on, without loading new code or
to avoid overwriting the target’s code with the same code. This button is not enabled when
the target is the simulator.
Download Code
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 hardware if it has not been done yet. Use this button anytime during a debug session.
Note: The current code on the target is overwritten.
Stop Debugging
Select Stop Debugging from the Debug submenu to exit Debug mode.
Reset
Select Reset from the Debug submenu to reset the debugger. By default, selecting Reset
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 dialog box (see page 160), the PC
resets to the first line of the program.
Go
Select Go from the Debug submenu to invoke Debug mode (make the debugger run). Be
sure you have worked through “Debugging Quick Tour” on page 16 before you run the
debugger.
Run to Cursor
Select Run to Cursor from the Debug submenu to make the debugger run to the line containing the cursor.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
144
Break
Select Break from the Debug submenu to break the program execution and stop the
debugging in progress.
Step Into
Select Step Into from the Debug submenu to execute the code one statement at a time.
Step Over
Select Step Over from the Debug submenu to step to the next statement, regardless of
whether the current statement is a call to another function.
Step Out
Select Step Out from the Debug submenu to execute the remaining lines in the current
function and returns to execute the next statement in the the caller function.
Set Next Instruction
Select Set Next Instruction from the Debug submenu to set the next instruction at the current line.
Set Active Configuration
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 having to remember all the setting changes that need to be made for each type of build that
might be necessary during the creation of a project. All changes to project settings are
stored in the current configuration setting.
Note: To add your own configuration(s), see “Manage Configurations” on page 146.
There are three ways to change the configuration settings:
•
•
•
UM014418-0205
“Select Configuration Dialog Box” on page 145
“Select Active Configuration List Box” on page 145
“Project Settings Dialog Box” on page 145
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
145
Select Configuration Dialog Box
You can use the Select Configurations dialog box to select the active configuration you
want.
1. From the Build menu, select Set Active Configuration to display the Select
Configuration dialog box (Figure 66).
Figure 66. Select Configuration Dialog Box
2. Highlight the configuration and click OK.
Select Active Configuration List Box
You can use the Select Active Configuration drop-down list box (Figure 67) in the
eZ80Acclaim! developer’s environment. This list box is part of the Build toolbar.
Figure 67. Select Active Configuration List Box
Project Settings Dialog Box
You can use the Project Settings dialog box (from the Project menu, select Settings) to
select the configuration for your project (see Figure 68).
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
146
Figure 68. Project Settings Dialog Box
1. From the Project menu, select Settings to display the Project Settings dialog box.
2. In the drop-down list box in the upper left corner of the dialog box, select the
configuration.
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.
This displays the Manage Configurations dialog box shown in Figure 69.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
147
Figure 69. Manage Configurations Dialog Box
2. From the Manage Configurations dialog box, click Add.
The Add Project Configuration dialog box (Figure 70) is displayed.
Figure 70. Add Project Configuration Dialog Box
3. Type the name of the configuration in the Configuration Name field.
4. Select a target from the Target drop-down list box.
5. Select a similar configuration from the Copy Settings From drop-down list box.
6. Click OK.
Your new configuration is displayed in the configurations list in the Manage
Configurations dialog box.
7. Click Close.
8. Select the new configuration in the Select Active Configuration drop-down list box on
the Build toolbar (on the eZ80Acclaim! developer’s environment).
Now that you have created a blank template, you are ready to select the settings for
this new configuration.
9. From the Project menu, select Settings to display the Project Settings dialog box.
10. Select the settings for the new configuration and click OK.
11. From the File menu, select Save All.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
148
To copy all settings from an existing project configuration, do the following:
1. From the Build menu, select Configurations.
The Manage Configurations dialog box (Figure 71) is displayed.
Figure 71. Manage Configurations Dialog Box
2. From the Manage Configurations dialog box, click Copy.
The Copy Configuration Settings dialog box (Figure 72) is displayed.
Figure 72. Copy Configuration Settings Dialog Box
3. Select which configuration to copy all settings from in the Copy Settings From dropdown list box.
4. Select a configuration to which to copy the settings in the Copy Settings To dropdown list box. Use the Control or Shift key while clicking on the configurations to
select more than one configuration.
5. Click Copy.
6. Click Close to return to the Manage Configurations dialog box.
7. Click Close.
Caution: The values for all existing settings in the configurations selected in the Copy Settings To
list box are overwritten.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
149
TOOLS MENU
The Tools menu lets you set up the Flash Loader and customize the appearance of the
eZ80Acclaim! developer’s environment.
The Tools menu has the following options:
•
•
•
“Flash Loader” on page 149
“Customize” on page 154
“Options” on page 156
Flash Loader
Use the following procedure to burn internal and external Flash for the eZ80 and
eZ80Acclaim!:
1. Ensure that the target board is powered up and the emulator is connected and
operating properly.
2. In the Configure Target dialog box (see page 136), do the following:
a. Ensure that the ROM/RAM Chip Select Registers fields define the target RAM
properly.
b. Make certain the Enable Flash check box is selected. Enter the address in the
Address Upper Byte (hex) field. This shifts Flash and affects the pages displayed
in the Flash Loader Processor dialog box. Select the number of wait states from
the Wait States drop-down list box. The wait states value is based on the value of
the system clock frequency according to the following table:
Wait States
System Clock (MHz)
0
<12
1
12-23.9
2
24-35.9
3
36-47.9
4
48-59.9
5
60-71.9
6
72-84
7
>84
You can select any wait states value; however, 5, 6, and 7 are not recommended
for performance reasons. Based on the currently configured system clock
frequency, ZDS II suggests the appropriate wait states value by appending an
asterisk to it in the Wait States drop-down list box. The asterisk moves to different
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
150
values when the system clock frequency is changed in the same dialog box. When
the target clock frequency is changed, you must update the wait states value if
needed.
Caution: The Flash Loader downloads a selected hex file to target Flash. The Flash Loader uses
internal RAM if it is available, and the ROM/RAM Chip Select Registers fields in the
Configure Target dialog box define where RAM is for a CPU that does not have internal
RAM (such as the eZ80L92). The defined RAM addresses must not overlap the defined
Flash addresses.
3. Select Flash Loader from the Tools menu.
The Flash Loader connects to the target and sets up communication. The Flash Loader
Processor dialog box (see Figure 73) is displayed with the appropriate Flash target
options for the selected CPU.
Figure 73. Flash Loader Processor Dialog Box
4. Click on the Browse button (
) to navigate to the hex file to be flashed.
5. Select the Flash targets in the Flash Options area.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
151
The Flash Options displayed in the Flash Loader Processor dialog box depend on the CPU
Note: you selected in the General tab of the Project Settings dialog box (see “General Tab” on
page 93).
You must select at least one of the following check boxes in the Flash Options area
before erasing or flashing a target:
Internal Flash
The internal Flash memory configuration is defined in the CpuFlashDevice.xml
file. The device is the currently selected microcontroller or microprocessor. When the
internal Flash is selected, the address range is displayed in the Flash Configuration
area with an INT extension.
External Flash
If you select the External Flash check box, select which Flash devices you want to
program. The Flash devices are defined in the FlashDevice.xml file.
The device is the current external Flash device’s memory arrangement. When an
external Flash device is selected, the Flash Loader uses the address specified in the
Flash Base field to begin searching for the selected Flash device. The Flash Loader
reads each page of memory from the FlashDevice.xml file, checking if the page is
enabled by the Chip Select settings. It then queries the actual address to verify that the
correct Flash device is found. If the correct Flash device is found, the page’s range
with an EXT extension and Chip Select is displayed in the Flash Configuration area.
The external Flash device options are predefined Flash memory arrangements for
specific Flash devices such as the Micron MT28F008B3. The Flash Loader uses the
external Flash device option arrangements as a guide for erasing and loading the Intel
hexadecimal file in the appropriate blocks of memory.
Note: The Flash Loader is unable to identify, erase, or write to a page of Flash that is
protected through hardware. For example, a target might have a write enable
jumper to protect the boot block. In this case, the write enable jumper must be set
before flashing the area of Flash. The Flash Loader displays this page as disabled.
6. In the Flash Base field, type where you want the Flash programming to start.
The Flash base defines the start of external Flash.
7. In the Units drop-down list box, select the number of Flash devices to program.
For example, if you have two devices stacked on top of each other, select 2 in the
Units list box.
8. Select the pages to erase before flashing in the Flash Configuration area.
Pages that are grayed out are not available.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
152
To select all the pages, use the right-click menu or delete the file name in the File
field.
9. In the File Offset field, type the appropriate offset values to offset the base address of
the hex file.
Note: The hex file address is shifted by the offset defined in the Start Address area. You need to
allow for the shift in any defined jump table index. This offset value also shifts the erase
range for the Flash.
10. Select the Erase Flash Before Burning check box to erase all Flash memory before
writing the hex file to Flash memory.
Caution: You can also delete the Flash memory by clicking ERASE. Clicking ERASE deletes
only the pages that are selected.
11. Select the Do Not Erase Info Page check box to keep the data in the Info page.
12. Select the Close Dialog When Flash Complete check box to close the dialog box after
writing the hex file to Flash memory.
13. If you want to use the serialization feature or want to check a serial number that has
already been burned at an address, see “Serialization” on page 152.
14. Program the Flash memory by clicking one of the following buttons:
– Click Fast Burn to write the hex file to Flash memory and perform no checking
while writing.
– Click Burn 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.
15. 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: ZiLOG also provides a target-based external Flash Loader utility for reprogramming Flash
memory. It is designed primarily for field upgrades to stand-alone systems. For more
information about this external Flash Loader utility, refer to the External Flash Loader
Product User Guides (PUG0016 and PUG0018).
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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
153
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 serialization feature:
1. Select the Include Serial in Burn check box. This option burns the serial number after
the selected hex file has been written to Flash.
2. Select the Enable check box.
3. Type in the start value for the serial number in the Serial Value field and select the Dec
button for a decimal serial number or the Hex button for a hexadecimal serial number.
4. Type the location you want the serial number located in the Address Hex field.
5. Select the number of bytes that you want the serial number to occupy in the # Bytes
drop-down list box.
6. 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 burned in, the serial number is
then incremented or decremented by the amount in the Increment Dec (+/-) field.
7. Select the Erase Before Flashing check box. This option erases the Flash before
writing the serial number.
8. Click Burn Serial to write the serial number to the current device or click Fast Burn
or Burn 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 burned at an address, do the following:
1. Select the Enable check box.
2. Type the 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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
154
Customize
The Customize dialog box contains the following tabs:
•
•
“Toolbars Tab” on page 154
“Commands Tab” on page 155
Toolbars Tab
The Toolbars tab (Figure 74) lets you select the toolbars you want to display on the
eZ80Acclaim! developer’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.
Figure 74. Customize Dialog Box—Toolbars Tab
To create a new toolbar, use the following procedure:
1. Select Customize from the Tools menu.
The Customize dialog box is displayed.
2. Click on the Toolbars tab.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
155
3. Click New.
The New Toolbar dialog box is displayed as shown in Figure 75.
Figure 75. New Toolbar Dialog Box
4. In the Toolbar Name field, type the name of the new toolbar.
5. Click OK.
The new toolbar is displayed as a gray box.
You can change the name by selecting the new toolbar in the toolbars list box, typing a
new name in the Toolbar Name field, and pressing the Enter key.
6. Click the Commands tab.
7. Drag buttons from any category to your new toolbar.
Note: To delete the new toolbar, select the new toolbar in the Toolbars list box and click Delete.
8. Click OK to apply your changes or click Cancel to close the dialog box without
making any changes.
Commands Tab
The Commands tab lets you modify the following by selecting the categories:
•
•
•
•
•
•
•
“File Toolbar” on page 65
“Edit Toolbar” on page 66
“Build Toolbar” on page 67
“Debug Toolbar” on page 69
“Debug Windows Toolbar” on page 71
“Command Processor Toolbar” on page 68
“Menu Bar” on page 78
To see a description of each button on the toolbars, highlight the icon as shown in
Figure 76.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
156
Figure 76. Customize Dialog Box—Commands Tab
Options
The Options dialog box contains four tabs:
•
•
•
•
“General Tab” on page 156
“Editor Tab” on page 157
“Debugger Tab” on page 160
“File Types Tab” on page 161
General Tab
The General tab (Figure 77) has five check boxes:
•
Select the Save Files Before Build check box to save files before you build. This
option is selected by default.
•
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.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
157
•
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.
Figure 77. Options Dialog Box—General Tab
Editor Tab
Use the Editor tab to change the default settings of the editor for your assembly, C, and
default files:
1. From the Tools menu, select Options.
The Options dialog box is displayed.
2. Click on the Editor tab (Figure 78).
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
158
Figure 78. Options Dialog Box—Editor Tab
3. Select a file type from the File Type drop-down list box.
4. In the Tabs area, do the following:
– Use the Tab Size field to change the number of spaces that a tab indents code.
– Select the Insert Spaces button or the Keep Tabs button.
– Select the Show Tabs check box if you want a symbol displayed in your code
indicating tab placement.
5. Click Syntax Coloring.
The Syntax Coloring dialog box is displayed as shown in Figure 79.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
159
Figure 79. Syntax Coloring Dialog Box
–
–
–
Select the Use Syntax Coloring check box if you want the program to be color
coded. Use the Current Colors area to define which colors are assigned to
keywords, quotes, comments, default text, and the background.
Select the Case Sensitive check box if you want the compiler to distinguish
between upper case and lower case letters.
Use the Comment Definitions areas to define comment characters.
6. Click OK to close the Syntax Coloring dialog box.
7. On the Editor tab, click Select Font.
8. The Font dialog box is displayed as shown in Figure 80.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
160
Figure 80. Font Dialog Box
You can change the font, font style, font size, and script style.
9. Click OK to close the Font dialog box.
10. Click OK to close the Options dialog box.
Debugger Tab
The Debugger tab (Figure 81) has six 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
submenu, 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).
•
When the Show DataTips Pop-Up Information check box is selected, you can hold the
mouse cursor over a variable in a C file in the Edit window in Debug mode, and the
value is displayed.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
161
•
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 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 submenu 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 submenu
or from the Connect to Target button). This option is selected by default.
Figure 81. Options Dialog Box—Debugger Tab
File Types Tab
Use the File Types tab (Figure 82) to add a new directory for specified file types in the
Project Workspace window.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
162
Figure 82. Options Dialog Box—File Types Tab
1. In the File Groups field, type the name of the new directory.
2. In the Associated File Types field, type the file extensions to store in the new
directory.
Use a comma to separate the file types.
3. Click Add.
4. Click OK.
WINDOW MENU
The Window menu allows you to select the ways you want to arrange your files in the Edit
window and allows you to activate the Project Workspace window or the Output window.
The Windows menu contains the following options:
•
•
•
•
•
UM014418-0205
“New Window” on page 163
“Close” on page 163
“Close All” on page 163
“Cascade” on page 163
“Tile” on page 163
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
163
•
“Arrange Icons” on page 163
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 163
“Online Registration” on page 163
“About” on page 163
Help Topics
Select Help Topics to display the ZDS II online help.
Online Registration
Select Online Registration to display the ZiLOG Customer Support web page.
To register your copy of ZDS II, log in to ZiLOG Support.
About
Select About to display the registration key and version information.
UM014418-0205
2 Main Components
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
164
3
Debugging
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
“Command Processor Quick Tour” on page 31). The following topics are covered in this
chapter:
•
•
•
•
•
•
•
“Status Bar” on page 165
“Code Line Indicators” on page 166
“Debug Output Window” on page 166
“Debug Toolbar” on page 166
“Debug Windows” on page 169
“Using Breakpoints” on page 180
“Target Configuration” on page 184
From the Build menu, go to the Debug submenu and select Reset. This moves you into
Debug mode.
You are now in Debug mode as shown in the Output window (Debug tab). The Debug
toolbar and Debug Windows toolbar are displayed as shown in Figure 83.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
165
Figure 83. Debug and Debug Window Toolbars
Note: If you edit and build code while in Debug mode, you need to stop and restart the debugger
to load the new code. The new code is not automatically reloaded.
STATUS BAR
The status bar displays the current status of your program’s execution. The status can be
STOP, STEP, or RUN. In STOP mode, your program is not executing. In STEP mode, a
Step Into, Step Over, or Step Out command is in progress. In RUN mode, a Go command
has been issued with no animate active.
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.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
166
CODE LINE INDICATORS
The Edit window displays your source code with line numbers and code line indicators.
The debugger indicates the status of each line visually with the following code line indicators:
•
A red octagon indicates an active breakpoint at the code line; a white octagon
indicates a disabled breakpoint.
•
Blue dots are displayed to the left of all valid code lines; these are lines where
breakpoints can be set, the program can be run to, and so on.
Note: Some source lines do not have blue dots because the code has been optimized out of the
executable (and the corresponding debug information).
•
A PC code line indicator (yellow arrow) indicates a code line at which the program
counter (PC) is located.
•
A PC code line indicator on a breakpoint (yellow arrow on a red octagon) indicates a
code line indicator has stopped on a breakpoint.
If the program counter steps into another file in your program, the Edit window switches
to the new file automatically.
DEBUG OUTPUT WINDOW
The Debug Output window displays the result of certain commands and error messages.
Error messages are displayed in red. The window also displays command output from
debugger script files.
DEBUG TOOLBAR
The Debug toolbar (Figure 84) allows you to perform debugger functions.
Figure 84. Debug Toolbar
Download Code
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 hardware if it has not been done yet. Use this button anytime during a debug session.
Note: The current code on the target is overwritten.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
167
Reset Button
The Reset button resets the debugger. If you deselect the Reset to Symbol 'main' (Where
Applicable) check box on the Debugger tab of the Options dialog box (see page 160), the
PC resets to the first line of the program.
Stop Debugging Button
The Stop Debugging button exits you from the debugger (leave Debug mode).
To stop Debug mode, use the Break button (described on page 167).
Go Button
The Go button invokes Debug mode (makes the debugger run). Be sure you have worked
through “Debugging Quick Tour” on page 16 before running the debugger.
The Go button executes the code until there is either a breakpoint or the STOP command
is initiated. In Normal execution mode, the status bar changes to RUN. In Stepped execution mode, the status bar changes to STEP. This command cannot be used if the program
execution status is RUN, as shown in the status bar.
Note: This command cannot be invoked when the program execution status is not in the STOP
mode. An error message, ERROR - Process is still running, displays.
Run to Cursor Button
The Run to Cursor button makes the debugger run to the line containing the cursor. You
can only use this command for a line with a blue dot displayed to the left of the line.
Break Button
The Break button pauses the program execution and stops the debugging in progress.
Step Into Button
The Step Into button on the Debug toolbar executes one line of code. If the line is a module with debug information, this command steps into the module. If the Disassembly window is opened, this command executes one line of the assembly code; otherwise, it
executes one line of source code.
Note: The status bar changes to STEP until the line is executed. Then the status bar changes back
to STOP.
Step Over Button
The Step Over button steps to the next statement, regardless of whether the current statement is a call to another function.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
168
Step Out Button
The Step Out button executes the remaining lines in the current function and returns to
execute the next statement in the the caller function.
The Step Over button on the Debug toolbar executes one line of code. If the Disassembly
window is opened, the Step Over command executes one line of the assembly code; otherwise, the Step Over command executes one line of source code.
Note: The message ERROR - PC has entered an unknown region is displayed when
there is no debugging information available. If you use the default startup module in the
compiler and the default linker, you are not able to step into the program until the main
module is executed because there is no debug information available in the startup program.
You have to set a breakpoint and execute the code continuously (using the Go command)
until it reaches the main module. The status bar changes to STEP until the code stopped
line is executed. Then, the status bar changes back to STOP.
Set Next Instruction Button
The Set Next Instruction button allows you to set the next instruction at the current line.
Insert/Remove Breakpoint Button
The Insert/Remove Breakpoint button allows you to add a breakpoint in a file at the line
where the cursor is or to delete a breakpoint from the line where the cursor is. You can set
a breakpoint in any line with a blue dot displayed to the left of the line. For more information on breakpoints, see “Using Breakpoints” on page 180.
Note: You can add a maximum of three breakpoints to a program.
Enable/Disable Breakpoint Button
The Enable/Disable Breakpoint button allows you to activate a breakpoint in a file at the
line where the cursor is or deactivate a breakpoint at the line where the cursor is. A red
octagon indicates an enabled breakpoint; a white octagon indicates a disabled breakpoint.
For more information on breakpoints, see “Using Breakpoints” on page 180.
Disable All Breakpoints Button
The Disable All Breakpoints button deactivates all breakpoints in all open files. 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 all open files. To deactivate
breakpoints in your program, use the Disable All Breakpoints button.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
169
DEBUG WINDOWS
The Debug Windows toolbar (Figure 85) allows you to open the following Debug windows:
•
•
•
•
•
•
•
•
•
“Registers Window” on page 169
“Special Function Registers Window” on page 170
“Clock Window” on page 170
“Memory Window” on page 171
“Watch Window” on page 176
“Locals Window” on page 178
“Call Stack Window” on page 178
“Symbols Window” on page 179
“Disassembly Window” on page 179
Figure 85. Debug Windows Toolbar
Registers Window
Click the Registers Window button to show or hide the Registers window. The Registers
window (Figure 86) displays all the registers in the standard eZ80Acclaim! architecture.
Figure 86. Registers Window
To change register values, do the following:
1. In the Registers window, highlight the value you want to change.
2. Type the new value and press the Enter key.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
170
The changed value is displayed in red.
Special Function Registers Window
Click the Special Function Registers Window button to show or hide the Special Function
Registers window. The Special Function Registers window (Figure 87) displays all the
special function registers in the standard eZ80Acclaim! architecture.
Figure 87. Special Function Registers Window
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 (689
in Figure 88), type 0, and press the Enter key. Updated values are displayed in red.
Figure 88. Clock Window
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
171
Memory Window
Click the Memory Window button to show or hide the Memory window (Figure 89).
Figure 89. Memory Window
The Memory window displays data located in program memory. The address is displayed
in the far left column with an E# to denote the Extio address space, I# to denote the Intio
address space, or M# to denote the Memory address space.
Changing Values
To change the values in the Memory window, do the following:
1. In the window, highlight the value you want to change.
The values begin in the column to the right of 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. In the Memory window, highlight the address in the Address field, as shown in
Figure 90.
Note: To view the values for other memory spaces, replace the I 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.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
172
Figure 90. Memory Window—Starting Address
2. Type the address you want to find and press the Enter key.
For example, find 0000B4.
The system moves the selected address to the top of the Memory window, as shown in
Figure 91.
Figure 91. 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 (Extio, Intio, or Memory) in the Space drop-down list.
2. Right-click in the Memory window list box to display the right-click menu.
3. Select Fill Memory.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
173
The Fill Memory dialog box is displayed, as shown in Figure 92.
Figure 92. Fill Memory Dialog Box
4. In the 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.
Saving to a File
Use this procedure to save memory specified by an address range to a binary, hexadecimal, or text file.
Perform the following steps to save memory to a file:
1. Select the memory space (Extio, Intio, or Memory) in the Space drop-down list.
2. Right-click in the Memory window list box to display the right-click menu.
3. Select Save to File.
The Save to File dialog box is displayed, as shown in Figure 93.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
174
Figure 93. Save to File Dialog Box
4. In the File Name field, enter the path and name of the file you want to save the
memory to or click the Browse button (
) to search for a file or directory.
5. Type the start address in hexadecimal format in the Start Address (Hex) field and type
the end address in hexadecimal format in the End Address (Hex) field.
This specifies the address range of memory to save to the specified file.
6. Select whether to save the file as text, hex (hexadecimal), or binary.
7. Click OK to save the memory to the specified file.
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 memory:
1. Select the memory space (Extio, Intio, or Memory) in the Space drop-down list.
2. Right-click in the Memory window list box to display the right-click menu.
3. Select Load from File.
The Load from File dialog box is displayed, as shown in Figure 94.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
175
Figure 94. Load from File Dialog Box
4. In the File Name field, enter the path and name of the file to load or
click the Browse button (
) to search for the file.
5. In the 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.
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.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
176
Watch Window
Click the Watch Window button to show or hide the Watch window.
Note: Figure 95 shows an example of using the Watch window.
Figure 95. Watch Window
The Watch window displays all the variables and their values defined using the WATCH
command. If the variable is not in scope, the variable is not displayed. The values in the
Watch window change as the program executes. 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 right-click menu.
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 procedure:
1. Click once on <new watch> in the Expression column.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
177
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 Value column.
Changing Values
To change values in the Watch window, do the following:
1. In the window, highlight the value you want to change.
2. Type the new value and press the Enter key.
The changed value is displayed in red.
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.
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 displays in the Value column.
To view the hexadecimal values for all expressions, select Hexadecimal Display from the
right-click 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 column and press the Enter key. For example, type dec huns. The decimal value displays in
the Value column.
Note: To view the decimal values for all expressions, select Hexadecimal Display from the
right-click menu.
Viewing an ASCII Value
To view the ASCII values of an expression, type ascii expression in the Expression column and press the Enter key. For example, type ascii ones. The ASCII value displays
in the Value column.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
178
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
(Figure 96) 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 rightclick menu.
Figure 96. Locals Window
Call Stack Window
Click the Call Stack Window button to show or hide the Call Stack window (Figure 97).
Figure 97. 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.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
179
If you want to copy text from the Call Stack Window, select the text and then select Copy
from the right-click menu.
Symbols Window
Click the Symbols Window button to show or hide the Symbols window (Figure 98).
Figure 98. Symbols Window
The Symbols window displays the address for each symbol in the program.
Disassembly Window
Click the Disassembly Window button to show or hide the Disassembly window
(Figure 99).
Figure 99. 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.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
180
When you right-click in the Disassembly window, the right-click 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 180.
•
•
•
•
•
•
•
•
Reset the debugger
Stop debugging
Start or continue running the program (Go)
Run to the cursor
Pause the debugging (Break)
Step into, over, or out of program instructions
Set the next instruction at the current line
Enable and disable source annotation and source line numbers
USING BREAKPOINTS
This section to describes how to work with breakpoints while you are debugging. The following topics are covered:
•
•
•
•
•
•
“Inserting Breakpoints” on page 180
“Viewing Breakpoints” on page 181
“Moving to a Breakpoint” on page 182
“Enabling Breakpoints” on page 182
“Disabling Breakpoints” on page 183
“Removing Breakpoints” on page 183
Inserting Breakpoints
Note: You can add a maximum of three breakpoints to a program.
There are three ways to place a breakpoint in your file:
•
Click on the line of code where you want to insert the breakpoint. You can set a
breakpoint in any line with a blue dot displayed to the left of the line (shown in Debug
mode only).
Click the Insert/Remove Breakpoint button (
UM014418-0205
) on the Build or Debug toolbar.
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
181
•
Click on the line where you want to add a breakpoint and select Insert Breakpoint
from the right-click menu. You can set a breakpoint in any line with a blue dot
displayed to the left of the line (shown in Debug mode only).
•
Double-click in the gutter to the left of the line where you want to add a breakpoint.
You can set a breakpoint in any line with a blue dot displayed to the left of the line
(shown in Debug mode only).
A red octagon shows that you have set a breakpoint at that location (see Figure 100).
Figure 100. Setting a Breakpoint
Viewing Breakpoints
There are two ways to view breakpoints in your project:
•
Select Breakpoints from the Edit menu to display the Breakpoints dialog box
(Figure 101).
•
Select Edit Breakpoints from the right-click menu to display the Breakpoints dialog
box.
You can use the Breakpoints dialog box to view, go to, enable, disable, or remove breakpoints in an active project when in or out of Debug mode.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
182
Figure 101. 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 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 Breakpoints from the Edit menu.
The Breakpoints dialog box is displayed.
2. Click Enable All.
Check marks are displayed to the left of all enabled breakpoints.
3. Click OK.
There are three ways to enable one breakpoint:
•
Double-click on the white octagon to remove the breakpoint and then double-click
where the octagon was to enable the breakpoint.
•
Place your cursor in the line in the file where you want to activate a disabled
breakpoint and click the Enable/Disable Breakpoint button on the Build or Debug
toolbar.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
183
•
Place your cursor in the line in the file where you want to activate a disabled
breakpoint and select Enable Breakpoint from the right-click menu.
The white octagon becomes a red octagon to indicate that the breakpoint is enabled.
Disabling Breakpoints
There are two ways to make all breakpoints in a project inactive:
•
Select 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 and select Disable Breakpoint from the right-click menu.
The red octagon becomes a white octagon to indicate that the breakpoint is disabled.
Removing Breakpoints
There are two ways to delete all breakpoints in a project:
•
Select Breakpoints from the Edit menu to display the Breakpoints dialog box. Click
Remove All and then click OK. The breakpoints are removed from the Breakpoints
dialog box and the file.
•
Click the Remove All Breakpoints button on the Build or Debug toolbar.
There are four ways to delete one breakpoint:
•
•
Double-click on the red octagon to remove the breakpoint.
Select Breakpoints from the Edit menu to display the Breakpoints dialog box. Click
Remove and then click OK. The breakpoint is removed from the Breakpoints dialog
box and the file.
•
Place your cursor in the line in the file where there is a breakpoint and click the Insert/
Remove Breakpoint button on the Build or Debug toolbar.
•
Place your cursor in the line in the file where there is a breakpoint and select Remove
Breakpoint from the right-click menu.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
184
TARGET CONFIGURATION
ZDS II gives you three target choices:
•
•
•
“Instruction Set Simulator” on page 184
“RAM-Based Target” on page 185
“ROM/Flash-Based Target” on page 187
This section describes how to configure ZDS II for each of these targets and how to debug
for each of these targets.
Instruction Set Simulator
The eZ80Acclaim! Instruction Set Simulator interfaces with the debugger to simulate the
execution of programs without using an emulator or target hardware. The Instruction Set
Simulator uses the commands of the debugger to perform tasks such as simulating timers
and interrupts. The Instruction Set Simulator is selected using the Debugger tab of the
Project Settings dialog box. See “Debugger Tab” on page 130 for information on the
Debugger tab options.
Programmable Reload Timer Simulation
The Instruction Set Simulator also supports the programmable reload timer peripheral
simulation for eZ80Acclaim! devices. You can operate the timers by using the
eZ80Acclaim! I/O instructions to write into the respective control registers. The peripheral
registers can be viewed in the I/O space of the Watch window (see “Watch Window” on
page 176). Currently, viewing the registers in the Special Function Registers window is
not supported. Refer to the individual device product specification for a detailed description on timers.
Configuration
1. Select Settings from the Project menu.
2. Click the Debugger tab.
3. Select the Simulator check box in the Select Target area.
4. Click Setup.
The Setup Simulator dialog box is displayed.
– Use the Simulator Throttle to select the code execution speed (which simulates
memory access speed).
– Use the Clock Speed (MHz) field to specify the CPU clock frequency.
– Select the Load Memory Files check box to load memory from file.
– Select the Write Memory Files check box to write memory to a file.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
185
Starting a Debug Session
To begin debugging, use the following procedure:
1. Click on the Reset button on the Build toolbar.
2. Begin debugging.
RAM-Based Target
RAM-based debugging is typically used for development purposes. Debugging in RAM allows you to peek and poke memory and use software breakpoints.
Configuration
1. From the Project menu, select Settings.
The Project Settings dialog box is displayed.
2. On the Debugger tab, select the Ethernet check box and select an Ethernet target from
the Select Target area.
3. Click Communication to configure the target.
The Setup TcpIP Communication dialog box is displayed.
4. Following the configuration procedures defined in the eZ80Acclaim! Quick Start
Guide to set up the communication with the target.
5. Click Setup to configure the target.
The Configure Target dialog box is displayed.
6. Configure the Chip Select registers for a RAM-based project.
Note: See the eZ80190, eZ80L92, eZ80F91, eZ80F92, and eZ80F93 product
specifications for more information about the register settings.
For example, the following settings are for the eZ80F91 sample project with a DebugRAM build configuration:
– Select the Start in ADL Mode check box if C source code is being used.
– In the Program Counter (hex) field, enter 000000h.
This is the address of the first line of code to be executed (typically the low
address of ROM space).
– In the SPL Stack Pointer (hex) field, enter FFFFFFh.
This is the address of the stack starting point (typically the upper address of
RAM).
– In the SPS Stack Pointer (hex) field, enter FFFFh.
This is the address of the stack starting point (typically the upper address of
RAM).
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
186
–
–
–
–
–
–
–
–
Enter the target configuration in the ROM/RAM Chip Select Registers area.
For CS0, disable external Flash by doing the following:
Enter 00h – 00xxxxh in the Upper Bound (hex) field.
Enter 00h – 00xxxxh in the Lower Bound (hex) field.
Enter 00h in the Control Register (hex) field to disable it.
For CS1, enable RAM from 0-07FFFFh for code by doing the following:
Enter 00h – 00xxxxh in the Upper Bound (hex) field.
Enter 00h – 07xxxxh in the Lower Bound (hex) field.
Enter 28h in the Control Register (hex) field for memory access and one wait
state.
For CS2, enable the LED matrix by doing the following:
Enter 80h – 80xxxxh in the Upper Bound (hex) field.
Enter BFh – BFxxxxh in the Lower Bound (hex) field.
Enter 28h in the Control Register (hex) field for memory access and one wait
state.
For CS3, disable the EMAC device by doing the following:
Enter 00h – 00xxxxh in the Upper Bound (hex) field.
Enter 00h – 00xxxxh in the Lower Bound (hex) field.
Enter 00h in the Control Register (hex) field to disable it.
Select the Enable Internal DATA RAM check box to enable internal RAM for data
memory and stack.
Unselect the Enable EMAC RAM check box to disable it.
Unselect the Enable Flash check box to disable it.
7. Click OK.
8. In the Output category of the Linker tab, select the IEEE 695 check box.
Starting a Debug Session
To begin debugging, use the following procedure:
1. Click the Connect to Target button on the Build toolbar.
2. Click the Download Code button on the Build toolbar.
3. Click the Reset button on the Build toolbar.
4. Begin debugging.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
187
ROM/Flash-Based Target
ROM/Flash-based debugging is typically used by production or targets that do not have
RAM. To debug in ROM/Flash, the debugger uses one of the four hardware breakpoints
for run control. You can use the three remaining hardware breakpoints.
Note: The only limitation in debugging in ROM/Flash is that you cannot poke (write) during
debugging while peek (view) might work depending on Flash configurations. This
limitation is not related to the registers of F91.
Configuration
1. From the Project menu, select Settings.
The Project Settings dialog box is displayed.
2. On the C (Compiler) tab, select Generate Debug Info from the Debug Information
drop-down list box in the General category and select Generate Debug Info from the
Debug Information drop-down list box in the Code Generation category.
3. On the Assembler tab, select the Debug Information check box.
4. On the Debugger tab, select the Ethernet check box and select an Ethernet target from
the Select Target area.
5. Click Communication to configure the target.
The Setup TcpIP Communication dialog box is displayed.
6. Follow the configuration procedures defined in the eZ80Acclaim! Quick Start Guide
to set up the communication with the target.
7. Click Setup to configure the target.
The Configure Target dialog box is displayed.
8. Select the Enable Flash check box if you want to use internal Flash. Enter the address
in the Address Upper Byte (hex) field. This shifts Flash and affects the pages
displayed in the Flash Loader Processor dialog box. Select the number of wait states
from the Wait States drop-down list box. The wait states value is based on the value of
the system clock frequency according to the following table:
Wait States
UM014418-0205
System Clock (MHz)
0
<12
1
12-23.9
2
24-35.9
3
36-47.9
4
48-59.9
5
60-71.9
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
188
Wait States
System Clock (MHz)
6
72-84
7
>84
You can select any wait states value; however, 5, 6, and 7 are not recommended for
performance reasons. Based on the currently configured system clock frequency, ZDS
II suggests the appropriate wait states value by appending an asterisk to it in the Wait
States drop-down list box. The asterisk moves to different values when the system
clock frequency is changed in the same dialog box. When the target clock frequency is
changed, you must update the wait states value if needed.
9. Configure the Chip Select registers for a ROM/Flash-based project.
Note: See the eZ80190, eZ80L92, eZ80F91, and eZ80F92 product specifications for
more information about the register settings.
For example, the following settings are for the eZ80F91 sample project with a
Release-Flash build configuration:
– Select the Start in ADL Mode check box if C source code is being used.
– Enter 000000h in the Program Counter (hex) field.
This is the address of the first line of code to be executed (typically the low
address of ROM space).
– Enter FFFFFFh in the SPL Stack Pointer (hex) field.
This is the address of the stack starting point (typically the upper address of
RAM).
– Enter FFFFh in the SPS Stack Pointer (hex) field.
This is the address of the stack starting point (typically the upper address of
RAM).
– Enter the target configuration.
– For CS0, disable external Flash by doing the following:
Enter 13h (13FFFFh) in the Upper Bound (hex) field.
Enter 04h (040000h) in the Lower Bound (hex) field.
Enter E8h in the Control Register (hex) field to disable it.
– For CS1, enable RAM from C00000h-C7FFFFh.
Enter C7h (C7FFFFh) in the Upper Bound (hex) field.
Enter C0h (C00000h) in the Lower Bound (hex) field.
Enter 28h in the Control Register (hex) field for memory access and one wait
state.
– For CS2, enable the LED matrix.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
189
–
–
–
–
–
–
Enter BFh (BFFFFFh) in the Upper Bound (hex) field.
Enter 80h (800000h) in the Lower Bound (hex) field.
Enter 28h in the Control Register (hex) field for memory access and one wait
state.
For CS3, disable the EMAC device.
Enter 00h (00FFFFh) in the Upper Bound (hex) field.
Enter 00h (000000h) in the Lower Bound (hex) field.
Enter 00h in the Control Register (hex) field to disable it.
Select the Enable Internal DATA RAM check box to enable internal RAM for data
memory and stack.
Enter FFh (FFE000h - FFFFFFh) in the Map RAM to Page field.
Unselect the Enable EMAC RAM check box to disable it.
Select the Enable Flash check box to enable Flash for code space.
Enter 00h (000000h - 03FFFFh) in the Map Flash to Page field.
10. Click OK.
11. In the Output category of the Linker tab, select the IEEE 695 and Intel Hex32 –
Records check boxes.
Starting a Debug Session
To begin debugging, use the following procedure:
1. Download code into the target using the integrated Flash Loader. Select Flash Loader
from the Tools menu and follow the procedure in “Flash Loader” on page 149 for
flashing a target.
2. Click the Connect to Target button on the Build toolbar.
3. Click the Reset button on the Build toolbar.
4. Begin debugging.
UM014418-0205
3 Debugging
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
190
4
Using the ANSI C-Compiler
This chapter provides you information on writing C programs with the ANSI C-Compiler:
•
•
•
•
•
•
•
•
•
•
•
“Fractional Fixed-Point Representations” on page 191
“Language Extensions” on page 194
“eZ80Acclaim! C-Compiler Naming Conventions” on page 194
“Register Use” on page 195
“Using the Run-Time Library” on page 196
“Run-Time Library Functions” on page 210
“Setting C-Compiler Options Using #Pragmas” on page 256
“Embedding Assembly in C” on page 260
“Calling Assembly from C” on page 262
“Troubleshooting C Programs” on page 264
“Warning and Error Messages” on page 276
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 “Command Processor Quick Tour” on page 31.
For more information on using the compiler in the developer’s environment, refer to
Chapter 1, “Getting Started,” starting on page 1 and Chapter 2, “Main Components,” starting on page 64.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
191
FRACTIONAL FIXED-POINT REPRESENTATIONS
The compiler uses fractional fixed-point arithmetic for improved efficiency over floatingpoint representations. Only signed fractional numbers are supported. A signed fractional variable n is always within the range:
–1 < = n < 1
When representing a signed fractional number, the most significant bit represents the sign
and the remaining bits represent the two's complement of the fraction. The binary point is
immediately after the sign bit.
When determining the value of a fractional number, look at each bit of the fraction as a
negative power of two:
s
.
2-1
2-2
2-3
2-4
2-5
2-6
2-7
2-8
2-9
2-10
2-11
2-12
2-13
2-14
2-15
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
If the sign bit is negative, take the two's complement of the value before decoding the fractional number. For example, to decode the value 0xb000 into a real number representation,
first negate the value to obtain 0x5000. Then, sum the powers of two for each bit set as follows:
s
0x5000 = 0
2-1
. 1
2-2
2-3
2-4
2-5
2-6
2-7
2-8
2-9
2-10
2-11
2-12
2-13
2-14
0
1
0
0
0
0
0
0
0
0
0
0
0
2-1 =.5
2-3 =.125
Therefore, signed 0xb000 represents –(.5 + .125) = –0.625.
Assigning Values to fract Variables
When assigning values of fract variables, floating-point constant syntax can be used.
For example:
short signed fract f = -.5;
f= -5/.9;
Default Promotions on fract Variables
Because fract variables are not supported by ANSI, you need to define the behavior of a
fractional fixed-point number system. The compiler chooses a fractional fixed-point system over a floating-point system for efficiency reasons and assumes that efficiency is
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
192
more important than accuracy. For these reasons, the behavior of the fractional fixed-point
system differs from the ANSI C model for integral numbers in two ways:
•
•
Default integral promotions do not occur.
Fractional values are considered a higher order type than floating-point values.
Default Integral Promotions
In the fractional system, unlike ANSI's integral system, default integral promotions do not
occur. For example, ANSI states that any time a translator cannot ensure that an overflow
condition does not occur, all subordinate types must be promoted to the default integral
types. If the compiler cannot be certain of producing correct results, it must convert chars
and shorts to ints within an expression. This action ensures accuracy but might result
in inefficient code.
The compiler’s fractional fixed-point system does not perform these promotions unless
explicitly used as an operand of an operator where the other operand is of a higher order
type. For example:
char signed fract f1,f2,f3;
f1 = f2 + f3;
Neither f2 nor f3 are promoted to signed int fract type as integral types are. This
practice maintains the efficiency implied in the use of fractional numbers as opposed to
floating-point numbers. However, the compiler can promote to higher order fractional
types if necessary. For example:
char signed fract f1,f2;
short signed fract f3;
f1 = f2 - f3;
The compiler promotes f2 to a signed short fract and performs a short fract subtraction.
The compiler demotes the result to a signed char fract and stores the result in f1.
Fractional Values
In the fractional fixed-point system, fractional values are considered a higher order type
than floating-point values. If floats or doubles are in an expression containing fracts, the
floats and doubles are converted to fracts as necessary, even though a loss of accuracy
might occur. The fractional fixed-point model assumes that the operation's efficiency is
more important than its accuracy.
Fractional Expressions
All operations, with the exception of modulo (%), are legal within fractional expressions
and behave the way they do with other types. However, to support scaled fractional numbers, the compiler uses certain variations from the strict fractional model.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
193
For instance, the compiler allows the use of integral numbers within fractional expressions. It treats the scalar as though it were a fractional number that is the size of the base
type of the value. For example:
int fract f1,f2;
int i;
f1 = f2 + i;
Basic Fractional Arithmetic
The compiler supports signed fractional arithmetic for the +, -, *, and / operators.
Bitwise Logical and Shift Operators
The compiler supports all bitwise logical operators, including &, |, ^, <<, and >> for fractional types, although ANSI does not allow these operations for floating-point types. Use
these operators to vary the position of the binary point in a fractional number. This feature
can be very useful when the result of a fractional expression is not within the range of –1
to +1 or 0 to +1 but a wider range such as -3 to +3.
Passing fract Arguments
When passing fract arguments to a function with a prototype in scope, the compiler performs the usual conversions. However, if no prototype is in scope, the compiler converts
all char and short fract values into signed int fracts.
Scaled Fractional Arithmetic
You can alter the range of a fractional fixed-point value by modifying where its implied
binary point resides. You can perform this operation using the shift operators as follows:
signed short fract f1,f2,f3;
int int_part;
signed int fract fract_part;
f2 = (short fract).55 > > 3;
f3 = (short fract).55 > > 3;
f1 = f2 + f3;
/* .55 + .55 = 1.1 */
int_part = (f1 & 0xe000) >> 13;
fract_part = f1 < < 3;
/* 1 */
/* 1 */
Although fract arithmetic assumes that the binary point is just after the most significant bit
(or after the sign bit), you can perform the same operations on fracts that have been shifted
to move the binary point.
Note: However, be careful when dealing with negative signed fracts and make sure that all values
involved in an operation have their binary points aligned.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
194
Note: The eZ80Acclaim! C-Compiler is optimized for embedded applications in which execution
speed and code size are crucial. Consequently, it does not support returning a struct by
value from a function. Instead, use the more efficient coding style of passing a pointer to
the struct, which allows the called function to modify the struct that is pointed to.
LANGUAGE EXTENSIONS
To give you additional control over the way the compiler allocates storage and to enhance
its ability to handle common real-time constructs, the compiler implements several extensions to the ANSI C standard. The following language extensions are discussed in this section:
•
•
const Keyword
fract Keyword
const Keyword
The const keyword signifies data to be placed in program ROM.
The following is an example of const declaration:
const int ca[]={0,1,2,3,4,5,6,7,8,9};/* located in ROM */
fract Keyword
The compiler extends the ANSI C language to include support for a new base type called
fract that supports fixed-point fractional numbers. Declaring a fract variable is very
similar to declaring an integer. Only signed fracts are supported. The following are
examples of legal fractional variable declarations.
signed int fract cf;
short fract sf;
signed fract f[10];
/* signed character fract */
/* signed short fract */
/* array of signed int fracts */
The short, int, and long base typed determine the size of the object based upon the
default base type sizes for the target processor.
EZ80ACCLAIM! C-COMPILER NAMING CONVENTIONS
Assigned Variable Names
When the compiler generates the assembly file, all names of global static variables are
prefixed with an underscore.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
195
Names of local static variables are prefixed with an underscore followed by a function
number so as not to get assembly errors when the same local static variable occurs more
than once in the same file.
Assigned Function Names
Assembly routine names must be preceded with an _ (underscore). When the compiler
generates the assembly file, all function names are prefixed with an underscore. For example, when calling the function myfunc(), the assembly has an entry label:
_myfunc:
REGISTER USE
All arguments are passed on the stack and are passed in reverse order.
For example, foo(a,b,c) pushes arguments c, b, and then a.
Table 13 shows how arguments of different types are passed.
Table 13. Passing Arguments
Type
Size
Memory (Low to High)
char
3 bytes
xx ?? ??
short
3 bytes
xx xx ??
int
3 bytes
xx xx xx
long
6 bytes
xx xx xx xx ?? ??
float
6 bytes
xx xx xx xx ?? ??
double
6 bytes
xx xx xx xx ?? ??
pointer 3 bytes
xx xx xx
Table 14 shows how values are returned.
Table 14. Returning Values
UM014418-0205
Type
Register
Register Use
char
A
xx
short
HL
?? xx xx
int
HL
xx xx xx
long
E:HL
xx : xx xx xx
float
E:HL
xx : xx xx xx
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
196
Table 14. Returning Values
Type
Register
Register Use
double
E:HL
xx : xx xx xx
pointer
HL
xx xx xx
The caller must preserve registers across function calls.
For example:
LD IX,123456h
PUSH HL
CALL foo
POP BC
LEA HL,IX+6
;
;
;
;
Push argument
Might modify IX
Remove argument
Might give wrong value
So, if an assembly routine calls a C routine, you must preserve all registers other than the
return value register if the register’s value is needed after the call.
For example:
LD IX,123456h
PUSH IX
; Must be pushed before arguments are pushed
PUSH HL
; Push argument
CALL foo
POP BC
; Remove argument
POP IX
; Must be popped after arguments are deallocated
LEA HL,IX+6
USING THE RUN-TIME LIBRARY
The ANSI C-Compiler provides a collection of run-time libraries for use with your C programs. The following sections describe the use and format of the run-time libraries.
Each library function is declared in a header. The #include preprocessor directive makes
the header's contents available. The header declares a set of related functions plus any necessary types and additional macros needed to facilitate their use. All external identifiers
declared in any of the headers are reserved, whether or not the associated header is
included. All external identifiers and macro names that begin with an underscore are also
reserved. If the program redefines a reserved external identifier, even with a semantically
equivalent form, the behavior is indeterminate.
Standard and nonstandard headers are listed in Table 15 and Table 16 and described in the
following sections.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
197
Table 15. Standard Headers
Header
Description
Page
<errno.h>
Errors
page 198
<stddef.h>
Standard defines
page 198
<assert.h>
Diagnostics
page 199
<ctype.h>
Character-handling functions
page 199
<limits.h>
Integer limits
page 200
<float.h>
Floating-point limits
page 201
<math.h>
Math functions
page 203
<setjmp.h>
Nonlocal jump functions
page 204
<stdarg.h>
Variable arguments functions
page 205
<stdio.h>
Standard input/output functions
page 206
<stdlib.h>
General utilities functions
page 206
<string.h>
String-handling functions
page 208
Note: The standard include header files are located in the following directory:
ZILOGINSTALL\ZDSII_product_version\include\std
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
Table 16. Nonstandard Headers
Header
Description
Page
<eZ80.h>
eZ80/eZ80Acclaim!-specific functions and defines
page 210
Note: The nonstandard include header files are located in the following directory:
ZILOGINSTALL\ZDSII_product_version\include\zilog
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
198
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
If a file with any of these names, not provided as part of the compiler, is placed in any of
the standard places for a source file to be included, the behavior is undefined.
Headers can be included in any order; each can be included more than once in a given
scope, with no adverse effect. Headers are included in the code before the first reference to
any of the functions it declares, types or macros it defines.
Errors <errno.h>
The <errno.h> header defines macros relating to the reporting of error conditions.
Macros
EDOM
Expands to a distinct nonzero integral constant expression.
ERANGE
Expands to a distinct nonzero integral constant expression.
errno
A modifiable value that has type volatile int. Several libraries set errno to a
positive value to indicate an error. errno is initialized to zero at program startup,
but it is never set to zero by any library function. The value of errno can be set to
nonzero by a library function even if there is no error, depending on the behavior
specified for the library function in the ANSI Standard.
Additional macro definitions, beginning with E and an uppercase letter, can also be specified by the implementation.
Standard Defines <stddef.h>
The following types and macros are defined in several headers referred to in the descriptions of the functions declared in that header, as well as the common standard
<stddef.h> header.
Types
ptrdiff_t
UM014418-0205
Signed integral type of the result of subtracting two pointers.
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
199
size_t
Unsigned integral type of the result of the sizeof operator.
wchar_t
Integral type whose range of values can represent distinct codes for all
members of the largest extended character set specified among the
supported locales.
Macros
errno
Expands to a modifiable value that has type volatile int, the value of which
is set to a positive error number by several library functions. It is initialized
to zero at program startup, but is never set to zero by any library function.
The value of errno can be set to nonzero by a library function call whether
or not there is an error, provided the use of errno is not documented in the
description of the function in the Standard.
NULL
Expands to a null pointer constant.
offsetof
(type, identifier)
The offset in bytes, from the beginning of a structure designated by type, to
the member designated by identifier.
Diagnostics <assert.h>
The <assert.h> header declares one macro and refers to another macro.
Macro
NDEBUG
The <assert.h> header defines the assert() macro. It refers to the macro NDEBUG
that is not defined in the header. If NDEBUG is defined as a macro name before the
inclusion of this header, the assert() macro is defined simply as:
#define assert(ignore)((void) 0)
Function
void assert(int expression);
Tests for logic error.
Character Handling <ctype.h>
The <ctype.h> header declares several functions useful for testing and mapping 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 macro EOF. If the argument has any other value, the behavior is undefined.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
200
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.
Character Testing
int isalnum(int c);
Tests for alphanumeric character.
int isalpha(int c);
Tests for alphabetic character.
int iscntrl(int c);
Tests for control character.
int isdigit(int c);
Tests for decimal digit.
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.
int isspace(int c);
Tests for white-space character.
int isupper(int c);
Tests for uppercase character.
int isxdigit(int c);
Tests for hexadecimal digit.
Character Case Mapping
int tolower(int c);
Tests character and converts to lowercase if uppercase.
int toupper(int c);
Tests character and converts to uppercase if lowercase.
Limits <limits.h>
The <limits.h> header defines macros that expand to various limits and parameters.
Sizes of Integral Types
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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
201
SCHAR_MAX
Maximum value for an object of type signed char.
SCHAR_MIN
Minimum value for an object of type signed char.
SHRT_MAX
Maximum value for an object of type short int.
SHRT_MIN
Minimum value for an object of type short int.
UCHAR_MAX
Maximum value for an object of type unsigned char.
UINT_MAX
Maximum value for an object of type unsigned int.
ULONG_MAX
Maximum value for an object of type unsigned long int.
USHRT_MAX
Maximum value for an object of type unsigned short int.
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.
If the 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.
Floating Point <float.h>
The <float.h> header defines macros that expand to various limits and parameters.
Characteristics of Floating Types
DBL_DIG
Number of decimal digits of precision.
DBL_MANT_DIG
Number of base-FLT_RADIX digits in the floating-point mantissa.
DBL_MAX
Maximum represented floating-point numbers.
DBL_MAX_EXP
Maximum integer such that FLT_RADIX raised to that power
approximates a floating-point number in the range of represented
numbers.
DBL_MAX_10_EXP
Maximum integer such that 10 raised to that power approximates a
floating-point number in the range of represented value
((int)log10(FLT_MAX), and so on).
DBL_MIN
Minimum represented positive floating-point numbers.
DBL_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.
DBL_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(FLT_MIN), and so on).
FLT_DIG
Number of decimal digits of precision.
FLT_MANT_DIG
Number of base-FLT_RADIX digits in the floating-point mantissa.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
202
FLT_MAX
Maximum represented floating-point numbers.
FLT_MAX_EXP
Maximum integer such that FLT_RADIX raised to that power
approximates a floating-point number in the range of represented
numbers.
FLT_MAX_10_EXP
Maximum integer such that 10 raised to that power approximates a
floating-point number in the range of represented value
((int)log10(FLT_MAX), and so on).
FLT_MIN
Minimum represented positive floating-point numbers.
FLT_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.
FLT_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(FLT_MIN), and so on).
FLT_RADIX
Radix of exponent representation.
FLT_ROUND
Rounding mode for floating-point addition.
-1 indeterminable
0 toward zero
1 to nearest
2 toward positive infinity
3 toward negative infinity
LDBL_DIG
Number of decimal digits of precision.
LDBL_MANT_DIG
Number of base-FLT_RADIX digits in the floating-point mantissa.
LDBL_MAX
Maximum represented floating-point numbers.
LDBL_MAX_EXP
Maximum integer such that FLT_RADIX raised to that power
approximates a floating-point number in the range of represented
numbers.
LDBL_MAX_10_EXP
Maximum integer such that 10 raised to that power approximates a
floating-point number in the range of represented value
((int)log10(FLT_MAX), and so on).
LDBL_MIN
Minimum represented positive floating-point numbers.
LDBL_MIN_EXP
Minimum negative integer such that FLT_RADIX raised to that power
approximates a positive floating-point number in the range of
represented numbers.
LDBL_MIN_10_EXP
Minimum negative integer such that 10 raised to that power
approximates a positive floating-point number in the range of
represented values ((int)log10(FLT_MIN), and so on).
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
203
Mathematics <math.h>
The <math.h> header declares several mathematical functions and defines three macros.
The functions take double-precision arguments and return double-precision values. Integer
arithmetic functions and conversion functions are discussed later.
Macros
EDOM
Expands to distinct nonzero integral constant expressions.
ERANGE
Expands to distinct nonzero integral constant expressions.
HUGE_VAL
Expands to a positive double expression, not necessarily represented as a float.
Treatment of Error Conditions
The behavior of each of these functions is defined for all values of its arguments. Each
function must return as if it were a single operation, without generating any externally visible 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 specified value; the integer expression errno acquires the value of the macro EDOM.
Similarly, a range error occurs if the result of the function cannot be represented as a double 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 macro
HUGE_VAL, with the same sign as the correct value of the function; the integer expression errno acquires the value of the macro ERANGE. If the result underflows (the magnitude of the result is so small that it cannot be represented in an object of the specified
type), the function returns zero.
Functions
Trigonometric
double acos(double x);
Calculates arc cosine of x.
double asin(double x)
Calculates arc sine of x.
double atan(double x);
Calculates arc tangent of x.
double atan2(double y, double x);
Calculates arc tangent of y/x.
double cos(double x);
Calculates cosine of x.
double sin(double x);
Calculates sine of x.
double tan(double x);
Calculates tangent of x.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
204
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 ldexp(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, double *iptr);
Breaks down x into integer (the value returned
by modf) and fractional (n) parts.
Power
double pow(double x, double y);
Calculates x to the y.
double sqrt(double x);
Finds square root of x.
Nearest Integer, abs
remdouble 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 <setjmp.h>
The <setjmp.h> header declares two functions and one type for bypassing the normal
function call and return discipline.
Type
jmp_buf
UM014418-0205
An array type suitable for holding the information needed to restore a calling
environment.
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
205
Functions
int setjmp(jmp_buf env);
Saves a stack environment.
void longjmp(jmp_buf env, int val);
Restores a saved stack environment.
Variable Arguments <stdarg.h>
The <stdarg.h> 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
function va_end. The called function declares a variable (referred to as ap in this
section) having type va_list. The variable ap can be passed as an argument to another
function.
Variable Argument List Access Macros and Function
The va_start and va_arg macros described in this section are implemented as macros, not
as real functions. If #undef is used to remove a macro definition and obtain access to a
real function, the behavior is undefined.
Functions
void va_start(va_list ap, parmN);
Sets pointer to beginning of argument list.
type va_arg (va_list ap, type);
Retrieves argument from list.
void va_end(va_list ap);
Resets pointer.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
206
Input/Output <stdio.h>
The <stdio.h> header declares input and output functions.
Functions
Formatted Input/Output
int printf(const char *format, ...);
Writes formatted data to stdout.
int scanf(const char *format, ...);
Reads formatted data from stdin.
int sprintf(char *s, const char *format, ...);
Writes formatted data to string.
int sscanf(const char *s, const char *format, ...);
Reads formatted data from string.
int vsprintf(char *s, const 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 (macro version).
int puts(const char *s);
Writes a line to stdout.
General Utilities <stdlib.h>
The <stdlib.h> header declares several types, functions of general utility, and macros.
Types
div_t
Structure type that is the type of the value returned by the div function.
ldiv_t
Structure type that is the type of the value returned by the ldiv function.
size_t
Unsigned integral type of the result of the sizeof operator.
wchar_t
Integral type whose range of values can represent distinct codes for all members of
the largest extended character set specified among the supported locales.
Macros
EDOM
Expands to distinct nonzero integral constant expressions.
ERANGE
Expands to distinct nonzero integral constant expressions.
HUGE_VAL
Expands to a positive double expression, not necessarily represented as a
float.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
207
MB_CUR_MAX
Expands to a positive integer expression whose value is the maximum
number of bytes in multi-byte character for the extended character set
specified by the current locale.
NULL
Expands to a null pointer constant.
RAND_MAX
Expands to an integral constant expression, the value of which is the
maximum value returned by the rand function.
Functions
String Conversion
The atof, atoi, and atol functions do not affect the value of the macro errno on an
error. If the result cannot be represented, the behavior is undefined.
double atof(const char *nptr);
Converts string to float.
int atoi(const char *nptr);
Converts string to int.
long int atol(const char *nptr);
Converts string to long.
double strtod(const char *nptr,
char **endptr);
Converts string pointed to by nptr to a double.
long int strtol(const char *nptr,
char **endptr, int base);
Converts string to a long decimal integer that is
equal to a number with the specified radix.
Pseudorandom Sequence Generation
int rand(void)
Gets a pseudorandom number.
void srand(unsigned int seed);
Initializes pseudorandom series.
Memory Management
The order and contiguity of storage allocated by successive calls to the calloc, malloc,
and realloc functions is 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 reallocated).
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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
208
Searching and Sorting Utilities
void *bsearch(void *key, void *base, size_t nmemb, size_t size, int
(*compar)(void *, void *));
Performs binary search.
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.
ldiv_t ldiv(long int numer, long int denom);
Computes long quotient and remainder.
String Handling <string.h>
The <string.h> header declares several functions useful for manipulating character
arrays and other objects treated as character arrays. Various methods are used for determining the lengths of arrays, but in all cases a char* or void* argument points to the initial
(lowest addressed) character of the array. If an array is written beyond the end of an object,
the behavior is undefined.
Type
size_t
Unsigned integral type of the result of the sizeof operator.
Macro
NULL
Expands to a null pointer constant.
Functions
Copying
void *memcpy(void *s1, const void *s2, size_t n);
Copies a specified number of characters
from one buffer to another.
void *memmove(void *s1, const void *s2, size_t n); Moves a specified number of characters
from one buffer to another.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
209
char *strcpy(char *s1, const char *s2);
Copies one string to another.
char *strncpy(char *s1, const char *s2, size_t n);
Copies n characters of one string to another.
Concatenation
char *strcat(char *s1, const char *s2);
Appends a string.
char *strncat(char *s1, const char *s2, size_t n);
Appends n characters of string.
Comparison
The sign of the value returned by the comparison functions is determined by the sign of
the difference between the values of the first pair of characters that differ in the objects
being compared.
int memcmp(const void *s1, const void *s2, size_t n);
Compares the first n characters.
int strcmp(const char *s1, const char *s2);
Compares two strings.
int strncmp(const char *s1, const char *s2, size_t n);
Compares n characters of two strings.
Search
void *memchr(const void *s, int c,size_t n);
Returns a pointer to the first occurrence, within a
specified number of characters, of a given
character in the buffer.
char *strchr(const char *s, int c);
Finds first occurrence of a given character in string.
size_t strcspn(const char *s1, const char *s2); Finds first occurrence of a character from a given
character in string.
char *strpbrk(const char *s1, const char *s2); Finds first occurrence of a character from one
string to another.
char *strrchr(const char *s, int c);
Finds last occurrence of a given character in string.
size_t strspn(const char *s1, const char *s2); Finds first substring from a given character set in
string.
char *strstr(const char *s1, const char *s2);
Finds first occurrence of a given string in another
string.
char *strtok(char *s1, const char *s2);
Finds next token in string.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
210
Miscellaneous
void *memset(void *s, int c, size_t n);
Uses a given character to initialize a specified
number of bytes in the buffer.
size_t strlen(const char *s);
Finds length of string.
Architecture-Specific Functions <eZ80.h>
To access the many special function registers (SFRs) and memory-mapped I/O registers in
the eZ80Acclaim!, the file eZ80.h contains macros and structures. These macros and
structures make using the eZ80Acclaim! architecture easier.
Note: Each eZ80Acclaim! family member has a separate header file named after the family
member (for example, eZ80L92.h). However, you can include the eZ80.h header file
instead, which uses compiler defines to select the correct SFRs for an eZ80Acclaim! family
member.
RUN-TIME LIBRARY FUNCTIONS
This section covers the following:
abs
acos
asin
assert
atan
atan2
atof
atoi
atol
bsearch
calloc
ceil
cos
cosh
div
exp
fabs
floor
fmod
free
frexp
getchar
gets
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
labs
ldexp
ldiv
log
log10
longjmp malloc
memchr
memcmp memcpy
memmove
memset
modf
pow
printf
putchar
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
abs
Computes the absolute value of an integer j. If the result cannot be represented, the behavior is undefined.
Synopsis
#include <stdlib.h>
int abs(int j);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
211
Returns
The absolute value.
Example
int I=-5632;
int j;
j=abs(I);
acos
Computes the principal value of the arc cosine of x. A domain error occurs for arguments
not in the range [-1,+1].
Synopsis
#include <math.h>
double acos(double x);
Returns
The arc cosine in the range [0, pi].
Example
double y=0.5635;
double x;
x=acos(y)
asin
Computes the principal value of the arc sine of x. A domain error occurs for arguments not
in the range [-1,+1].
Synopsis
#include <math.h>
double asin(double x);
Returns
The arc sine in the range [-pi/2,+pi/2].
Example
double y=.1234;
double x;
x = asin(y);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
212
assert
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 respectively the values of the preprocessing macros __FILE__ and
__LINE__) on the serial port using the putch() function. It then loops forever.
Synopsis
#include <assert.h>
void assert(int expression);
Returns
If expression is true (that is, evaluates to nonzero), the assert macro returns no value.
Example
#include <assert.h>
char str[] = "COMPASS";
int main(void)
{
assert(str[0] == 'B');
return 0;
}
atan
Computes the principal value of the arc tangent of x.
Synopsis
#include <math.h>
double atan(double x);
Returns
The arc tangent in the range (-pi/2, +pi/2).
Example
double y=.1234;
double x;
x=atan(y);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
213
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 <math.h>
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, it is equivalent to strtod (nptr, (char **)NULL).
Synopsis
#include <stdlib.h>
double atof(char *nptr);
Returns
The converted value.
Example
char str []="1.234";
double x;
x= atof(str);
atoi
Converts the string pointed to by nptr to int representation. Except for the behavior on
error, it is equivalent to (int)strtol(nptr, (char **)NULL, 10).
Synopsis
#include <stdlib.h>
int atoi(char *nptr);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
214
Returns
The converted value.
Example
char str []="50";
int x;
x=atoi(str);
atol
Converts the string pointed to by nptr to long int representation. Except for the behavior
on error, it is equivalent to strtol(nptr, (char **)NULL, 10).
Synopsis
#include <stdlib.h>
long int atol(char *nptr);
Returns
The converted value.
Example
char str[]="1234567";
long int x;
x=atol(str);
bsearch
Searches an array of nmemb objects, the initial member of which is pointed to by base, for
a member that matches the object pointed to by key. The size of each object is specified by
size.
The array has been previously sorted in ascending order according to a comparison 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 argument is considered to be respectively less than, equal to, or greater
than the second.
Synopsis
#include <stdlib.h>
void *bsearch(void *key, void *base,
size_t nmemb, size_t size,
int (*compar)(void *, void *));
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
215
Returns
A pointer to the matching member of the array or a null pointer, if no match is found.
Example
int 1st[]={2,5,8,9};
int k=8;
int compare (int x, int y);
int *result;
result = bsearch(&k, 1st, 4, sizeof(int), compare);
calloc
Allocates space for an array of nmemb objects, each of whose size is size. The space is initialized to all bits zero.
Synopsis
#include <stdlib.h>
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
Computes the smallest integer not less than x.
Synopsis
#include <math.h>
double ceil(double x);
Returns
The smallest integer not less than x, expressed as a double.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
216
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
#include <math.h>
double cos(double x);
Returns
The cosine value.
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
#include <math.h>
double cosh(double x);
Returns
The hyperbolic cosine value.
Example
double y=.1234;
double x
x=cosh(y);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
217
div
Computes the quotient and remainder of the division of the numerator numer by the
denominator denom. If the division is inexact, the sign of the quotient is that of the mathematical quotient, and the magnitude of the quotient is the largest integer less than the magnitude of the mathematical quotient.
Synopsis
#include <stdlib.h>
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;
int rem;
/* quotient */
/* remainder */
Example
int x=25;
int y=3;
div_t t;
int q;
int r;
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
#include <math.h>
double exp(double x);
Returns
The exponential value.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
218
Example
double y=.1234;
double x;
x=exp(y)
fabs
Computes the absolute value of a floating-point number x.
Synopsis
#include <math.h>
double fabs(double x);
Returns
The absolute value of x.
Example
double y=6.23;
double x;
x=fabs(y);
floor
Computes the largest integer not greater than x.
Synopsis
#include <math.h>
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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
219
Synopsis
#include <math.h>
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 - i * y + f for some integer i, where the magnitude of f is less than the magnitude of y.
Example
double y=7.23;
double x=2.31;
double z;
z=fmod(y,x);
free
Causes the space pointed to by ptr to be deallocated, that is, made available for further
allocation. If ptr is a null pointer, no action occurs. Otherwise, if the argument does not
match a pointer earlier returned by the calloc, malloc, or realloc function, or if the
space has been deallocated by a call to free or realloc, the behavior is undefined. If
freed space is referenced, the behavior is undefined.
Synopsis
#include <stdlib.h>
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
#include <math.h>*
double frexp(double value, int *exp);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
220
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,&n);
getchar
Waits for the next character to appear at the serial port and return its value.
Synopsis
#include <stdio.h>
int getchar(void);
Returns
The next character from the input stream pointed to by stdin. If the stream is at end-of-file,
the end-of-file indicator for the stream is set and getchar returns EOF. If a read error
occurs, the error indicator for the stream is set and getchar returns EOF.
Example
int i;
i=getchar();
gets
Reads characters from a UART into the array pointed to by s, until end-of-file is encountered or a new-line character is read. The new-line character is discarded and a null character is written immediately after the last character read into the array.
Synopsis
#include <stdio.h>
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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
221
Example
char *r;
char buf [80];
r=gets(buf);
if (r==NULL)
/*No input*/
isalnum
Tests for any character for which isalpha or isdigit is true.
Synopsis
#include <ctype.h>
int isalnum(int c);
Example
int r;
char c='a';
r=isalnum(c)
isalpha
Tests for any character for which isupper or islower is true.
Synopsis
#include <ctype.h>
int isalpha(int c);
Example
int r;
char c='a';
r=isalpha(c)
iscntrl
Tests for any control character.
Synopsis
#include <ctype.h>
int iscntrl(int c);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
222
Example
int r;
char c=NULL;
r=iscntrl(c);
isdigit
Tests for any decimal digit.
Synopsis
#include <ctype.h>
int isdigit(int c);
Example
int r;
char c='4';
r=isdigit(c);
isgraph
Tests for any printing character except space (' ').
Synopsis
#include <ctype.h>
int isgraph(int c);
Example
int r;
char c='';
r=isgraph(c);
islower
Tests for any lowercase letter 'a' to 'z'.
Synopsis
#include <ctype.h>
int islower(int c);
Example
int r;
char c='a';
r=islower(c);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
223
isprint
Tests for any printing character including space (' ').
Synopsis
#include <ctype.h>
int isprint(int c);
Example
int r;
char c='1';
r=isprint(c);
ispunct
Tests for any printing character except space (' ') or a character for which isalnum is true.
Synopsis
#include <ctype.h>
int ispunct(int c);
Example
int r;
char c='a';
r=ispunct(c);
isspace
Tests for the following white-space characters: space (' '), form feed ('\f'), new line ('\n'),
carriage return ('\r'), horizontal tab ('\t'), or vertical tab ('\v').
Synopsis
#include <ctype.h>
int isspace(int c);
Example
int r;
char c='';
r=isspace(c);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
224
isupper
Tests for any uppercase letter 'A' to 'Z'.
Synopsis
#include <ctype.h>
int isupper(int c);
Example
int r;
char c='a';
r=isupper(c);
isxdigit
Tests for any hexadecimal digit '0' to '9' and 'A' to 'F'.
Synopsis
#include <ctype.h>
int isxdigit(int c);
Example
int r;
char c='f';
r=isxdigit(c)
labs
Computes the absolute value of a long int j.
Synopsis
#include <stdlib.h>
long int labs(long int j);
Example
long int i=-193250;
long int j
j=labs(i);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
225
ldexp
Multiplies a floating-point number by an integral power of 2. A range error can occur.
Synopsis
#include <math.h>
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=ldexp(x,exp);
ldiv
Computes the quotient and remainder of the division of the numerator numer by the
denominator denom. If the division is inexact, the sign of the quotient is that of the mathematical quotient, and the magnitude of the quotient is the largest integer less than the magnitude of the mathematical quotient.
Synopsis
#include <stdlib.h>
ldiv_t ldiv(long int numer, long int denom);
Example
long int x=25000;
long int y=300;
div_t t;
int q;
int r;
t=div(x,y);
q=t.quot;
r=t.rem;
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
226
log
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
#include <math.h>
double log(double x);
Returns
The natural logarithm.
Example
double x=2.56;
double y;
y=log(x);
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 <math.h>
double log10(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 setjmp 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 setjmp has executed a return statement in the
interim, the behavior is undefined.
All accessible objects have values as of the time longjmp was called, except that the
values of objects in the automatic storage class that are not volatile might be indeterminate.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
227
As it bypasses the usual function call and returns mechanisms, the longjmp function executed correctly in contexts of interrupts, signals, and any of their associated functions.
However, if the longjmp 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 <setjmp.h>
void longjmp(jmp_buf env, int val);
Returns
After longjmp is completed, program execution continues as if the corresponding call to
setjmp had just returned the value specified by val. The longjmp function cannot cause
setjmp to return the value 0; if val is 0, setjmp returns the value 1.
Example
int i;
jmp_buf (env)
i=setjmp(env)
longjmp(env,i);
malloc
Allocates space for an object whose size is specified by size.
Note: The existing implementation of malloc() depends on the heap area being located from
the bottom of the heap (referred to by the symbol __heapbot = top of RAM) 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
#include <stdlib.h>
void *malloc(size_t size);
Returns
A pointer to the start (lowest byte address) of the allocated space. If the space cannot be
allocated, or if size is zero, the malloc function returns a null pointer.
Example
char *buf;
buf=(char *) malloc(40*sizeof(char));
if(buf !=NULL)
/*success*/
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
228
else
/*fail*/
memchr
Locates the first occurrence of c (converted to an unsigned char) in the initial n characters
of the object pointed to by s.
Synopsis
#include <string.h>
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.
Example
char *p1;
char str[]="COMPASS";
c='p';
p1=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 <string.h>
int memcmp(void *s1, 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));
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
229
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 <string.h>
void *memcpy(void *s1, void *s2, size_t n);
Returns
The value of s1.
Example
char s1[10];
char s2[10] = "COMPASS";
memcpy(s1, s2, 8);
memmove
Moves n characters from the object pointed to by s2 into the object pointed to by s1. Copying between objects that overlap takes place correctly.
Synopsis
#include <string.h>
void *memmove(void *s1, 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
#include <string.h>
void *memset(void *s, int c, size_t n);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
230
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 <math.h>
double modf(double value, double *iptr);
Returns
The signed fractional part of value.
Example
double x=1.235;
double f;
double I;
i=modf(x, &f);
pow
Computes the x raised to the power of y. A domain error occurs if x is zero and y is less
than or equal to zero, or if x is negative and y is not an integer. A range error can occur.
Synopsis
#include <math.h>
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;
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
231
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 subsequent 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 evaluated but otherwise ignored. The printf function returns when the end of the format
string is encountered.
Each conversion specification is introduced by the character %. After the %, the following
appear in sequence:
•
•
Zero or more flags that modify the meaning of the conversion specification.
•
An optional 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.
•
An optional 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 l (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
a long_double argument. If an h, l, or L appears with any other conversion character, it
is ignored.
•
•
A character that specifies the type of conversion to be applied.
UM014418-0205
An optional decimal integer specifying a minimum field width. If the converted value
has fewer characters than the field width, it is padded on the left (or right, if the left
adjustment flag, described later, has been given) to the field width. The padding is
with spaces unless the field width integer starts with a zero, in which case the padding
is with zeros.
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
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
232
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 the “printf Flag Characters” section.
Synopsis
#include <stdio.h>
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);
printf Flag Characters
-
The result of the conversion is left-justified within the field.
+
The result of a signed conversion always begins with a plus or a minus sign.
space
If the 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,o,u,x,X
UM014418-0205
The int argument is converted to signed decimal (d or i), 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.
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
233
f
The double argument is converted to decimal notation in the style [-]ddd.ddd,
where the number of digits after the decimal point is equal to the precision
specification. If the precision is missing, it is taken as 6; if the precision is
explicitly zero, no decimal point appears. If a decimal point appears, at least one
digit appears before it. The value is rounded to the appropriate number of digits.
e,E
The double argument is converted in the style [-]d.ddde+dd, where there is one
digit before the decimal point and the number of digits after it is equal to the
precision; when the precision is missing, six digits are produced; if the precision
is zero, no decimal point appears. The value is rounded to the appropriate number
of digits. The E conversion character produces a 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 lE+100,
additional exponent digits are written as necessary.
g,G
The double argument is converted in style f or e (or in style E in the case of a G
conversion character), with the precision specifying the number of significant
digits. The style used depends on the value converted; style e is used only if the
exponent resulting from the conversion is less than -4 or greater than the
precision. Trailing zeros are removed from the result; a decimal point appears
only if it is followed by a digit.
c
The int argument is converted to an unsigned char, and the resulting
character is written.
s
The argument is taken to be a (const char *) pointer to a string. Characters
from the string are written up to, but not including, the terminating null character,
or until the number of characters indicated by the precision are written. If the
precision is missing it is taken to be arbitrarily large, so all characters before the
first null character are written.
p
The argument is taken to be a (const void) pointer to an object. The value of
the pointer is converted to a sequence of hex digits.
n
The argument is taken to be an (int) pointer to an integer into which is written
the number of characters written to the output stream so far by this call to
printf. No argument is converted.
%
A % is 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 conversion result.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
234
putchar
Writes a character to the serial port.
Synopsis
#include <stdio.h>
int putchar(int c);
Returns
The character written. If a write error occurs, putchar returns EOF.
Example
int i;
charc='a';
i=putchar(c);
puts
Writes the string pointed to by s to the serial port and appends a new-line character to the
output. The terminating null character is not written.
Synopsis
#include <stdio.h>
int puts(char *s);
Returns
EOF if an error occurs; otherwise, it is a non-negative value.
Example
int i;
char strp[]="COMPASS";
i=puts(str);
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 argument 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
unspecified.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
235
Synopsis
#include <stdlib.h>
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(void *, void *));
Example
int lst[]={5,8,2,9};
int compare (int x, int y);
qsort (lst, sizeof(int), 4, compare);
rand
Computes a sequence of pseudorandom integers in the range 0 to RAND_MAX.
Synopsis
#include <stdlib.h>
int rand(void)
Returns
A pseudorandom integer.
Example
int i;
srand(1001);
i=rand();
realloc
Changes the size of the object pointed to by ptr to the size specified by size. The contents
of the object are unchanged up to the lesser of the new and old sizes. If ptr is a null pointer,
the realloc function behaves like the malloc function for the specified size. Otherwise,
if ptr does not match a pointer earlier returned by the calloc, malloc, or realloc function, 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 <stdlib.h>
void *realloc(void *ptr, size_t size);
Returns
Returns a pointer to the start (lowest byte address) of the possibly moved object.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
236
Example
char *buf;
buf=(char *) malloc(40*sizeof(char));
buf=(char *) realloc(buf, 80*sizeof(char));
if(buf !=NULL)
/*success*/
else
/*fail*/
scanf
Reads input from the stream pointed to by stdin, under control of the string pointed to by
format that specifies the admissible input sequences and how they are to be converted for
assignment, using subsequent arguments as pointers to the object to receive the converted
input. If there are insufficient arguments for the format, the behavior is undefined. If the
format is exhausted while arguments remain, the excess arguments are evaluated but otherwise ignored.
The format is composed of zero or more directives from the following list:
•
•
•
one or more white-space characters
an ordinary character (not %)
a conversion specification
Each conversion specification is introduced by the character %. After the %, the following
appear in sequence:
•
•
•
An optional assignment-suppressing character *.
•
A character that specifies the type of conversion to be applied. The valid conversion
characters are described below.
UM014418-0205
An optional decimal integer that specifies the maximum field width.
An optional h, l or L indicating the size of the receiving object. The conversion
characters d, l, 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 l 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 l to indicate that it is a pointer to unsigned_long_int.
Finally, the conversion character e, f, and g can be preceded by l 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, l, or L appears with any other conversion
character, it is ignored.
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
237
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).
A directive composed of white space is executed by reading input up to the first nonwhite-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 following steps:
1. Input white-space characters (as specified by the isspace function) are skipped, unless
the specification includes a ’[’, ’c,’ or ’n’ character.
2. 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.
3. 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” on page 238 for valid input information.
Synopsis
#include <stdio.h>
int scanf(char *format, ...);
Returns
The value of the macro 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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
238
Examples
int i
scanf("%d", &i);
The following example reads in two values. var1 is an unsigned char with two decimal
digits, and var2 is a float with three decimal place precision.
scanf("%2d,%f",&var1,&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.
i
Matches an optionally signed integer, whose format is the same as expected for the
subject sequence of the strtol function with the value 0 for the base argument. The
corresponding argument is a pointer to integer.
o
Matches an optionally signed octal integer, whose format is the same as expected for the
subject sequence of the strtol function with the value 8 for the base argument. The
corresponding argument is a pointer to integer.
u
Matches an unsigned decimal integer, whose format is the same as expected for the
subject sequence of the strtol function with the value 10 for the base argument. The
corresponding argument is a pointer to unsigned integer.
x
Matches an optionally signed hexadecimal integer, whose format is the same as expected
for the subject sequence of the strtol function with the value of 16 for the base argument.
The corresponding argument is a pointer to integer.
e,f,g
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 right bracket character is the matching right
bracket that ends the specification. If a - character is in the scanlist and is neither the first
nor the last character, the behavior is indeterminate.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
239
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 with an input
failure; otherwise, unless execution of the current directive is terminated with a matching
failure, execution of the following directive (if 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 longjmp function.
Synopsis
#include<setjmp.h>
int setjmp(jmp_buf env);
Returns
If the return is from a direct invocation, the setjmp function returns the value zero. If the
return is from a call to the longjmp function, the setjmp function returns a nonzero
value.
Example
int i;
jmp_buf(env);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
240
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 <math.h>
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 large.
Synopsis
#include <math.h>
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 character is written at the end of the characters written; it is not counted as part of the returned
sum.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
241
Synopsis
#include <stdio.h>
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 non-negative square root of x. A domain error occurs if the argument is negative.
Synopsis
#include <math.h>
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.
Synopsis
#include <stdlib.h>
void srand(unsigned int seed);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
242
Example
int i;
srand(1001);
i=rand();
sscanf
Reads formatted data from a string.
Synopsis
#include <stdio.h>
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 i;
sscanf(buf,"&d",&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 character at the end of s1.
Synopsis
#include <string.h>
char *strcat(char *s1, char *s2);
Returns
The value of s1.
Example
char *ptr;
char s1[80]="Production";
char s2[]="Languages";
ptr=strcat(s1,s2);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
243
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
#include <string.h>
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 <string.h>
int strcmp(char *s1, 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
undefined.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
244
Synopsis
#include <string.h>
char *strcpy(char *s1, char *s2);
Returns
The value of s1.
Example
char s1[80], *s2;
s2=strcpy(s1,"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 <string.h>
size_t strcspn(char *s1, char *s2);
Returns
The length 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 <string.h>
size_t strlen(char *s);
Returns
The number of characters that precede the terminating null character.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
245
Example
char s1[]="COMPASS";
int i;
i=strlen(s1);
strncat
Appends no more than n characters of the string pointed to by s2 (not including the terminating 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
#include <string.h>
char *strncat(char *s1, char *s2, size_t n);
Returns
The value of s1.
Example
char *ptr;
char strl[80]="Production";
char str2[]="Languages";
ptr=strncat(str1,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 <string.h>
int strncmp(char *s1, 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);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
246
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
#include <string.h>
char *strncpy(char *s1, 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 <string.h>
char *strpbrk(char *s1, char *s2);
Returns
A pointer to the character or a null pointer if no character from s2 occurs in s1.
Example
char *ptr;
char s1[]="COMPASS";
char s2[]="PASS";
ptr=strpbrk(s1,s2);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
247
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
#include <string.h>
char *strrchr(char *s, int c);
Returns
A pointer to the character or a null pointer if c does not occur in the string.
Example
char *ptr;
char s1[]="COMPASS";
ptr=strrchr(s1,'p');
strspn
Finds the first substring from a given character set in a string.
Synopsis
#include <string.h>
size_t strspn(char *s1, char *s2);
Returns
The length of the segment.
Example
char s1[]="cabbage";
char s2[]="abc";
int res,
res=strspn(s1,s2);
strstr
Locates the first occurrence of the string pointed to by s2 in the string pointed to by s1.
Synopsis
#include <string.h>
char *strstr(char *s1, char *s2);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
248
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 containing a decimal point, then an optional letter e or E followed by an optionally signed integer, then an
optional floating suffix. If an inappropriate character occurs before the first digit following
the e or E, the exponent is taken to be zero.
The first inappropriate character ends the conversion. If endptr is not a null pointer, a
pointer to that character is stored in the object endptr points to; if an inappropriate character 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 conversion is negated.
Synopsis
#include <stdlib.h>
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";
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
249
double res;
res=strtod(s,&ptr);
strtok
A sequence of calls to the strtok function breaks the string pointed to by s1 into a
sequence of tokens, each of which is delimited by a character from the string pointed to by
s2. The first call in the sequence has s1 as its first argument and is followed by calls with a
null pointer as their first argument. The separator string pointed to by s2 can be different
from call to call.
The first call in the sequence searches s1 for the first character that is 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 current 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 above.
Synopsis
#include <string.h>
char *strtok(char *s1, char *s2);
Returns
A pointer to the first character of a token or a null pointer if there is no token.
Example
#include <string.h>
static char str[] = "?a???b, , ,#c";
char *t;
t = strtok(str,"?"); /* t points to the token "a" */
t = strtok(NULL,","); /* t points to the token
"??b " */
t = strtok(NULL,"#,"); /* t points to the token "c" */
t = strtok(NULL,"?"); /* t is a null pointer */
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
250
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 function), 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 character occurs before the first digit or recognized letter, the value of nptr is stored.
If the value of base is 0, the sequence of characters from the first digit to the character
before the first inappropriate character is interpreted as an integer constant according to
the rules of this section. If a minus sign appears immediately before the first digit, the
value resulting from the conversion is negated.
If the value of base is between 2 and 36, it is used as the base for conversion. Letters from
a (or A) through z (or Z) are ascribed the values 10 to 35; a letter whose value is greater
than or equal to the value of base ends the conversion. Leading zeros after the optional
sign are ignored, and leading 0x or 0X is ignored if the value of base is 16. If a minus sign
appears immediately before the first digit or letter, the value resulting from the conversion
is negated.
Synopsis
#include <stdlib.h>
long int 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 errno macro acquires
the value ERANGE.
Example
char *ptr;
char s[]="12345";
long int res;
res=strtol(s,&ptr,10);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
251
tan
The tangent of x (measured in radians). A large magnitude argument can yield a result
with little or no significance.
Synopsis
#include <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 <math.h>
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 <ctype.h>
int tolower(int c);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
252
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 <ctype.h>
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 <stdarg.h>
type va_arg(va_list ap, type);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
253
Returns
The first invocation of the va_arg macro after that of the va_start macro returns the
value of the argument after that specified by parmN. Successive invocations return the values 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 f1.
#define MAXARGS 31
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_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
f1(int, ...);.
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).
If the va_end function is not invoked before the return, the behavior is undefined.
Synopsis
#include <stdarg.h>
void va_end(va_list ap);
Example
The function f1 gathers into an array a list of arguments that are pointers to strings (but not
more than MAXARGS arguments), then passes the array as a single argument to function f2.
The number of pointers is specified by the first argument to f1.
#define MAXARGS 31
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
254
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_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
f1(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 definition (the one just before the , ...). The va_start macro initializes ap for subsequent use
by va_arg and va_end.
Synopsis
#include <stdarg.h>
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 f1.
#define MAXARGS 31
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_no++] = va_arg(ap, char *);
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
255
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
f1(int, ...);.
vprintf
Equivalent to printf, with the variable argument list replaced by arg, which has been initialized by the va_start macro (and possibly subsequent va_arg calls). The vprintf
function does not invoke the va_end function.
Synopsis
#include <stdarg.h>
#include <stdio.h>
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 %d %d",va)
vsprintf
Equivalent to sprintf, with the variable argument list replaced by arg, which has been
initialized by the va_start macro (and possibly subsequent va_arg calls). The
vsprintf function does not invoke the va_end function.
Synopsis
#include <stdarg.h>
#include <stdio.h>
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];
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
256
/*initialize the variable argument va here*/
vsprint("%d %d %d",va);
SETTING C-COMPILER OPTIONS USING #PRAGMAS
Compiler options can be set in the Project Settings dialog box (on the C tab) or by using
the #pragma directives discussed in this section. See “C (Compiler) Tab” on page 95. 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. See
“Alias Checking” on page 98. 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 = &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.
#pragma cpu <cpu name>
Defines the target processor to the compiler.
#pragma globalcopy
Enables global copy propagation.
#pragma noglobalcopy
Disables global copy propagation.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
257
#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
Disables global dead variable removal.
#pragma globalfold
Enables global constant folding.
#pragma noglobalfold
Disables global constant folding.
#pragma intrinsics: <state>
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.
<state> can be ON or OFF. This pragma, with <state> ON, is the default.
#pragma nointrinsics
Disables the INTRINSICS switch.
#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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
258
#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 optimized linkage calling conventions.
#pragma nooptlink
Disables optimized linkage calling conventions.
#pragma optsize
Optimizes code to minimize size.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
259
#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
compiler requires this switch for proper code generation because it makes use of a static
frame.
#pragma nostrict
Does not flag warnings for obsolete features.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
260
EMBEDDING ASSEMBLY IN C
There are two methods of inserting assembly language within C code. The first uses the
#pragma feature of ANSI C with the following syntax:
#pragma asm “<assembly line>”
#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
(that is, \n, \t, \r, ...) can be used with the usual meanings. The compiler does not
process the <assembly line>. Except for escape sequences, <assembly line> is passed
through the compiler to the assembler verbatim.
The second method of inserting assembly language is using the asm statement. The asm
statement can only be used within the body of a function and takes the following form:
asm(“<assembly line>”);
The asm statement cannot be within a C expression and can be used only within the body
of a function. To insert assembly text anywhere within the assembly file generated by the
compiler, you must use #pragma instead.
The <assembly line> must contain valid assembler statements, or errors are reported at
assembly time.
Caution: The compiler does not check for conflicts between the code in the <assembly line> and
compiler-generated code. For example, the compiler might use the HL register even if
<assembly line> also uses the HL register. Therefore, exercise extreme care when using
the asm statement. View the code the compiler generates before inserting asm statements.
As with the #pragma asm form, the compiler does not process the <assembly line>
except for translating the standard C escape sequences.
C Variables in Embedded Assembly
Assembly language routine names must be prefixed by an underscore if the routine is
going to be called from C. For example, to call myfunc() from C, the assembly code file
must have the label _myfunc: and the name externally defined (for example, xdef
_myfunc).
int ia[10];
int i, x, y;
int *p;
void test(int w, int z)
{
p = ia;
for (i=0; i<3; ++i) {
asm(" LD A,(\p+1)");
asm(" LD (\i),A");
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
261
asm(" LD A,(\y)");
asm(" LD (\x),A");
}
return;
}
Here is the generated assembly code:
FILE
".\EMBED.C"
.assume ADL=1
SEGMENT BSS
_ia:
DS
30
DS
3
DS
3
DS
3
_i:
_x:
_y:
_p:
;
;
;
1
2
3
;
4
;
5
;
6
_test:
DS
3
int ia[10];
int i, x, y;
int *p;
SEGMENT code
void test(int w, int z)
{
PUSH
LD
ADD
;
7
LD
LD
LD
LD
;
8
JMP
L_0:
;
9
LD A,(_p+1)
;
10
LD (_i),A
;
11
LD A,(_y)
;
12
LD (_x),A
asm(" LD A,(\p+1)");
asm(" LD (\i),A");
asm(" LD A,(\y)");
asm(" LD (\x),A");
LD
UM014418-0205
IX
IX,0
IX,SP
p = ia;
BC,_ia
(_p),BC
BC,0
(_i),BC
for (i=0; i<3; ++i) {
L_2
BC,(_i)
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
262
INC
LD
BC
(_i),BC
}
LD
LD
OR
SBC
JP
BC,3
HL,(_i)
A,A
HL,BC
M,L_0
return;
;
13
L_2:
;
;
14
15
}
LD
SP,IX
POP
IX
RET
;************************** _test **************************
;Name
Addr/Register
Size
Type
;_i
STATIC
3
variable
;_p
STATIC
3
variable
;_ia
STATIC
30
variable
;z
IX+9
3
parameter
;w
IX+6
3
parameter
; Stack Frame Size: 12 (bytes)
;
Spill Code: 0 (instruction)
XDEF
XDEF
XDEF
XDEF
XDEF
XDEF
END
_test
_p
_y
_x
_i
_ia
CALLING ASSEMBLY FROM C
Assigned Function Names
Assembly routine names must be preceded with an _ (underscore). When the compiler
generates the assembly file, all function names are prefixed with an underscore. For example, when calling the function myfunc(), the assembly has the following entry label:
_myfunc:
Calling Conventions
All arguments are passed on the stack and are pushed starting with the rightmost argument
(that is, right-to-left order). For example, foo(a,b,c) pushes arguments c, b, and then a.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
263
Arguments pushed on the stack can be accessed from assembler routines with positive offsets from the IX register by starting the assembly routine with the following code:
PUSH
LD
ADD
IX
IX,0
IX,SP
The first argument pushed is at IX+3. For example, to load the first argument pushed into
BC, you would use LD BC,(IX+3). Since arguments are pushed right-to-left, the first
argument listed for the function will be at the largest offset from IX. For example, with
foo(a,b,c), where all arguments are type int, argument a will be at IX+9. Table 17
shows the size of various arguments, so you can calculate where subsequent arguments are
located. If the assembly routine has no arguments, this prolog can be omitted.
If you use the preceding prolog to access arguments, the SP and IX registers must be
restored before returning to the C routine. For example:
LD
POP
RET
SP,IX
IX
; Omit IF SP is unchanged by routine
Table 17 shows how arguments of different types are passed.
Table 17. Passing Arguments
Type
Size
Memory (Low to High)
char
3 bytes
xx ?? ??
short
3 bytes
xx xx ??
int
3 bytes
xx xx xx
long
6 bytes
xx xx xx xx ?? ??
float
6 bytes
xx xx xx xx ?? ??
double
6 bytes
xx xx xx xx ?? ??
pointer 3 bytes
xx xx xx
Table 18 shows how values are returned.
Table 18. Returning Values
UM014418-0205
Type
Register
Register Use
char
A
xx
short
HL
?? xx xx
int
HL
xx xx xx
long
E:HL
xx : xx xx xx
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
264
Table 18. Returning Values (Continued)
Type
Register
Register Use
float
E:HL
xx : xx xx xx
double
E:HL
xx : xx xx xx
pointer
HL
xx xx xx
The compiler assumes that only the IX and SP registers are preserved across function
calls. These registers must be preserved by the callee. If the caller is an assembly routine,
the caller must preserve any registers it wants to keep. For example:
LD HL,123ABCh
PUSH HL
;
CALL _foo
;
POP BC
;
LD BC,(HL) ;
Push HL as argument
void foo(int *p) -- C routine
Remove argument
WRONG! Expecting HL to be preserved
So, if an assembly routine calls a C routine, you must preserve all registers needed after
the call. For example:
LD HL,123ABCh
PUSH HL
;
PUSH HL
;
CALL foo
POP BC
;
POP HL
;
LD BC,(HL) ;
Save HL
Push argument
Remove argument
Restore HL
HL contains 123ABCH
Data Alignment
The compiler aligns all data items on the nearest byte boundary.
TROUBLESHOOTING C PROGRAMS
Review this section to learn the answers to the following questions:
•
•
•
•
•
“How do I speed up the compiler?”
•
•
“How do I make my C program faster?” on page 267
UM014418-0205
“How do I call assembly from C?” on page 265
“Why does the compiler generate temporary variables?” on page 265
“How do I make my C program smaller?” on page 266
“Why is my code bigger when I select Optimize for Size than when I select Optimize
for Speed?” on page 267
“How do I create an interrupt handler in C?” on page 267
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
265
•
•
•
•
•
•
•
“Can interrupt handlers take arguments?” on page 268
•
“Why do floating-point operations give incorrect results?” on page 276
“How do I use interrupts in my program?” on page 268
“What registers are preserved by an interrupt handler written in C?” on page 272
“What is a register variable?” on page 273
“How do I locate a variable at a specific location in memory?” on page 273
“How do I embed assembly into my C code?” on page 274
“Is there a predefined compiler macro I can use for eZ80Acclaim!-specific code?” on
page 275
How do I speed up the compiler?
Use the following tips to lower compiler execution times:
•
The best way to improve speed is to select Maximize Speed from the Optimizations
drop-down list box in the General category on the C tab in the Project Settings dialog
box. See “Optimizations” on page 96.
•
If you select Custom from the Optimizations drop-down list box in the General
category on the C tab in the Project Settings dialog box (page 96), you can try
selecting and deselecting various optimizations in the Optimizations category on the C
tab (page 103).
•
There are two standard configuration settings. The Debug configuration skips some
optimizations to make the code easier to debug. Selecting the Release configuration
might allow additional optimizations that would improve the speed. To switch
configurations, see “Set Active Configuration” on page 144.
How do I call assembly from C?
For more information on this feature, see “Calling Assembly from C” on page 262.
Why does the compiler generate temporary variables?
The compiler generates temporary values whenever it needs to save an intermediate result.
In the following example
c = a + b + c
in processing the right-hand side of the assignment from left to right, the compiler has to
store the results of a+b somewhere, so the sum can be added to c. The compiler cannot
use a or b for storage because that would replace the previous values stored, and c cannot
be used for a+b because c has not been added in yet. To avoid destroying any of the
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
266
variables, the compiler creates a temporary (for example, t1) and generates the following
code:
t1 = b+c
c= a+t1
You can also remove temporaries by reordering the calculation to something like the following:
c += a
c += b
which avoids generating a temporary. Temporary variables are reused as needed by the
compiler and are not accessible from C. The compiler determines the minimal amount of
storage for temporaries for each function. The space is allocated from the stack at the
beginning of a function and removed when the function exits.
Other common expressions that produce temporaries are
•
the ternary ?: combination as in p - q > t ? r : s where the value of p-q needs
to be saved
•
*p++ where the pointer p must be dereferenced before it is incremented
The *p++ example uses a variable of type *p indirectly, and the compiler creates a
temporary for this variable. Subscripting (for example, x[i+j+1]= 5*g+2) often
generates temporary variables as well.
How do I make my C program smaller?
Use one of the following ways to make your C programs smaller:
•
The eZ80Acclaim! developer’s environment ANSI C-Compiler has an optimizer that
can be configured to optimize for speed or size or a combination. In the Project
Settings dialog box (C tab, “Optimizations Category” on page 103), select Minimize
Size from the Optimizations drop-down list box or insert #pragma optsize in your
code to generate smaller code. In some instances, this selection can reduce your code
size by as much as 50%.
Note: Decreasing the program size might increase execution time, so you might want to generate
the code using both options to decide which is best for your situation.
•
UM014418-0205
Modify or rebuild the run-time library. The C run-time library provides many
standardized C library routines as well as routines specifically tailored to work with
this compiler. Many of the standardized library routines are hand-coded in assembler
to improve performance, and some are written in C. If your application makes
extensive use of one of the C routines, you might want to recode that routine in
assembler. You can use the assembler source file (.src) generated by the compiler
(see “Listing Files Category” on page 109) as a starting point for your changes.
However, you must preserve the functionality of the library routine to ensure that
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
267
other library routines can call the modified routine. An error in a library routine can
cause unpredictable results.
Why is my code bigger when I select Optimize for Size than when I
select Optimize for Speed?
When your code is small and has two to three switch statements, select Optimize for
Speed (C tab, Optimizations category, page 103) on the Project Settings dialog box to generate smaller code.
How do I make my C program faster?
Use the following tips to make your programs run faster:
•
In the Project Settings dialog box (“Optimizations Category” on page 103), select
Maximize Speed from the Optimizations drop-down list box or place #pragma
optspeed in your code.
•
In the Project Settings dialog box (“Code Generation Category” on page 97), select
the Optimizes Calling Linkage check box.
•
Deselect the Alias Checking check box in the Project Settings dialog box (“Code
Generation Category” on page 97).
How do I create an interrupt handler in C?
Creating an interupt handler requires several steps. First, you must create an interrupt handler, and then you must tell the system which interrupt to associate with your handler.
1. To create an interrupt handler, you use the interrupt keyword, which is a storage
class that applies only to functions. This keyword causes the compiler to produce code
to preserve the current machine state at the beginning of the function and restore the
machine state on exit. To preserve the current state, the compiler generates code to
switch current register banks and pushes/pops registers.
2. Add the following startup file to the project:
ZILOGINSTALL\ZDSII_product_version\src\rtl\common\startup.asm
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
– version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
3. In startup.asm, change the BARE_SYSTEM setting:
BARE_SYSTEM EQU
UM014418-0205
1
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
268
The startup.asm file sets the I register and initializes the vector table by calling
_init_default_vectors.
4. Call _set_vector in user routines to set a particular interrupt vector. The
_set_vector routine enables the interrupts only if the interrupts were enabled
before entering the _set_vector routine. The _set_vector routine takes two
arguments. The first argument is an integer defining the interrupt, and the second
argument is the name of the associated interrupt handler. The function is used to attach
a C function, which is the interrupt handler, to an interrupt vector. _set_vector can
be placed within any function of your program where the interrupt handler function is
in scope. However, for clarity, it is best to place all the _set_vector calls in main.
For example:
#include <ez80.h>
extern void my_zero_timer(); /* declared as interupt */
extern void my_one_timer(); /* declared as interrupt */
int main() {
_di(); /* disable interrupts */
_set_vector(TMR0, my_zero_timer);
_set_vector(TMR1, my_one_timer);
_ei(); /* enable interrupts */
/* Body of application */
}
If you are developing an application for a bare board, you might need to capture all of
the interrupt vectors. The _init_default_vectors function takes no arguments
and needs to be called at the beginning of main. This function sets up all of the entries
in the vector table to point to a single interrupt handler. This routine must be called
while interrupts are disabled.
Can interrupt handlers take arguments?
No. Because an interrupt handler is not called from another function, but vectored to by
the hardware, it is not possible to pass arguments to it. Interrupt routines can, however,
access global variables or static variables. The compiler issues a warning if it detects an
interrupt routine with arguments.
How do I use interrupts in my program?
Note: For information about nonmaskable interrupts (NMIs), see the “Interrupts” chapter
of the eZ80 CPU User Manual (UM0077).
The eZ80Acclaim! family has a number of options for handling interrupts.
If you are using the default boot module, use the following procedure to enable the first
interrupt:
1. Call init_default_vectors() once
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
269
2. Call set_vector() with the appropriate parameters.
3. Configure and enable the peripherals interrupt.
For each additional interrupt, use steps 2 and 3 only.
Interrupts on the eZ80Acclaim! Devices
The eZ80F92/F93 operate like the eZ80190 in turns of having on chip SRAM available. If
however you are only targeting to have your code run within the on chip flash memory
then you might want to just keep you ISR routines within the first 64K bytes and point the
default vector addresses right to the ISR routines.
The eZ80Acclaim! eZ80F91 devices, however, have a new feature that has been added to
the interrupt controller to help out with interrupts. The default interrupt vectors have been
changed from two byte addresses to four bytes. This allows you to point the default ISR
vector right to you ISR routine. Below is some simple ISR setup code for the eZ80F91
device.
;**********************************
; Program entry point
;**********************************
.org %00
di
jp.lil_c_int0
; Jump around the ISR vectors.
;----------------------------------------------------------; ISR Vectors
;
Note the ‘DL’ define - This gives us two words or 4 bytes.
The upper byte is loaded with 00
We only need 24 bits.
.org %40
dl
%000000
;
dl
%000000
;
dl
%000000
;
dl
%000000
;
dl
%000000
;
dl
_isr_timer0;PRT0_ISR
dl
_isr_timer1;PRT1_ISR
dl
%000000
;
dl
%000000
;
dl
%000000
;
dl
%000000
;
dl
%000000
;
dl
_isr_uart0;UART0_ISR
dl
_isr_uart1;UART1_ISR
dl
%000000
;
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
270
** add all interrupt vectors that you are going to use.
;----------------------------------------------------------------------; Initialize Stack pointer
externTOSPS
externTOSPL
_c_int0:
ld.sis sp,TOSPS; Setup SPS
ld.lil sp,TOSPL; Setup SPL
;***********************************************************************
ld a, 00h
; Disable on-chip SRAM
out (RAM_CTL0), a;
; depends on what you want to do with the
; on-chip SRAM.
**** do other chip init here.
**** final jump to main
call
_main
; main()
void main(void)
{
init_com1();
init_timer1();
// Init com port - enable com1 ISR
// Init 100ms Timer - enable timer 1 ISR
_ei();
// Turn on the master interrupt system.
do
{
Your code goes here....
}while(1);
/****************************************************************
* This will initialize timer1 to interrupt every 10 ms
*
* 16 bit time constant is not big enough for 100 ms interrupts,
* so we will use additional intermediate counter to count
* every 10 ticks.
*/
void init_timer1(void)
{
ticks1 = 0x00;
intermediate_ticks1 = 0x00;
TMR_CTL1 = 0x00;
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
271
TMR_RRL1
TMR_RRH1
TMR_CTL1
TMR_CTL1
TMR_IER1
= 0xFF;
= 0x1F;
= 0x0e;
|= 0x01;
= 0x01;
//setup timer to interrupt every 10ms
//timer0 = multipass, /16, interrupt enable
//enable timer
// Enables timer 1 interrupt
}
void init_com1(void)
{
PC_ALT1 &= 0xf0;
PC_ALT2 |= 0x0F;
//PD0 = uart0_tx, PD1 = uart0_rx
UART_LCTL1=0x80;
BRG_DLRL1=0x45;
BRG_DLRH1=0x01;
UART_LCTL1=0x00;
//select dlab to access baud rate generators
// 9600
UART_FCTL1=0xc7;
UART_LCTL1=0x1B;
UART_MCTL1=0x20;
UART_IER1=0x05;
//clear tx fifo, clear rx fifo, fifo enable
//8-N-1
//disable modem flow control
//rx int enable, master int enable was 1
//disable dlab
}
#pragma interrupt
void isr_timer1(void)
{
unsigned char temp;
unsigned int delay;
temp = TMR_CTL1;//read to clear pending int
temp = TMR_IIR1;
intermediate_ticks1++;
if(intermediate_ticks1 >= 10)
{
intermediate_ticks1 = 0;
ticks1++;
}
}
/****************************************************************
* All this ISR should do is put the data into our internal fifos
*
*/
#pragma interrupt
void isr_uart1(void)
{
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
272
short temp;
temp = UART_LSR1;
if ( temp & 0x04 )
{
mdb_buff[byte_pos] = UART_RBR1;
byte_pos++;
done = 1;
}
if ( temp & 0x01)
{
mdb_buff[byte_pos] = UART_RBR1;
byte_pos++;
}
while( UART_LSR1 & 0x20) {//THRE int
if( ! fifo_empty(uart1tx->fifo) ) {// and we still have stuff to send ...
UART_THR1=fifo_get(uart1tx->fifo);// send it.
} else {
// otherwise ...
UART_IER1&=0xfd; // disable tx interrupts
break;
}
}
}
}
Summary
Most of ZiLOG’s tools have a built-in macro function to help you set up interrupts. You
would define a function as a interrupt routine using the #pragma interrupt keyword
and using set_vector(ISR,Name of ISR function), the tool would make sure to
org the correct jump address at the default ISR table. This is not as easy on the eZ80 family as we have a number of other thing to set up, like the I register, the long and short jump
tables, and so on. Because the eZ80F92 and eZ80F93 only have two byte addresses for the
default interrupt vectors, you need to set up other jump tables to bridge the gap into the
24-bit world. The other thing to keep in mind is the “I” register that controls the upper 8
bits of this default interrupt vector allowing you to move the overall interrupt jump table
anywhere in the 64K range.
What registers are preserved by an interrupt handler written in C?
The interrupt keyword, a storage class that applies only to functions, signifies
that a function is to be an interrupt handler. An interrupt function executes an EXX
instruction that preserves all the current registers upon entry to the function and an EXX
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
273
instruction to restore the registers at function exit. Remember that an interrupt function
can have no arguments and must return void.
What is a register variable?
Using the register storage class on a variable tells the compiler that this variable needs
to be allocated to a hardware register (if possible). The compiler might determine that no
register is available in which case the register storage class is ignored. Generally, register variables are variables that are used and modified frequently in a routine or a loop so
that keeping the variable in high-speed storage (that is, registers) decreases execution
speed. Only 8-, 16-, and 24-bit variables can be assigned to this storage class because the
eZ80Acclaim! does not have 32-bit registers. A register variable cannot be an array or
struct.
How do I locate a variable at a specific location in memory?
The eZ80Acclaim! C-Compiler does not extend the ANSI Standard for C to directly allow
variables to be placed at specific locations. However, the eZ80Acclaim! C-Compiler uses
the advanced macro-processing capabilities of ANSI C to support the features required to
control variable placement for embedded development.
To access a specific location in memory, declare a macro that expands into a pointer reference to the appropriate memory locations as shown in the following example:
#define b_x *((char *)0x20)
#define b_y *((int *)0x120)
#define b_array ((unsigned char * )0x30)
char c;
int i;
void main(void)
{
b_x = 10;
c = b_x;
b_y = 0x1234;
i = b_y;
c = b_array[c];
}
The various Special Function Registers are defined and accessed in a similar manner.
Note: When using this method, check the address ranges on the Project Settings dialog box
(“Address Spaces Category” on page 127) so that your program does not inadvertently
access data in areas already allocated.
Another method of allocating and accessing variables at a specified location requires a little assembly programming. The idea is to allocate segments in an assembly module that is
located using the ORG directive. Labels are placed at the appropriate location and are
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
274
made public using the XDEF directive. When this module is linked with the rest of your
program, the variable is located at the proper position in memory.
Assembly File
xdef _my_data
define_my_seg,space=ram,org=80h
segment my_seg
_my_data:
ds 20; 20 bytes at 80h
end
C File
extern unsigned char my_data[20];
void foo(void)
{
unsigned char I;
for (i=0;i<sizeof(my_data);++i)
my_data[i] = 0xff;
}
Note: The C file refers to the variable as my_data while the assembly uses _my_data. These
names are different because the compiler prefixes all global variable names with an
underscore (_). Failing to perform these modifications results in undefined symbol errors
from the linker.
How do I embed assembly into my C code?
There are two ways to embed assembly into your C code. The first method is to use the
asm pragma. For example:
#pragma asm "INCLUDE \"MYINC.INC\""
The contents of the string is inserted into the assembly file generated by the compiler. You
can place multiple lines of assembly in a #pragma asm by separating them with a newline (\n). For example:
#pragma asm "INCLUDE \"MYINC.INC\"\n" \
"INCLUDE \"YOURINC.INC\""
This method can be used to place assembly code anywhere within your program. The second method for inserting assembler code uses the asm statement, which can only be used
within the body of a function. For example:
void test(void)
{
asm("LD
}
UM014418-0205
A,#0");
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
275
The compiler ignores embedded assembly. Therefore, embedding assembly might cause
compiler optimizations to be incorrect. Before inserting assembly into your C code, look
first at the code generated by the compiler (it resides in the .src file) to make sure that the
embedded code functions correctly.
Is there a predefined compiler macro I can use for eZ80Acclaim!-specific code?
Yes. When you select the product family member in the CPU drop-down list box (on the
General tab of the Project Settings dialog box; see page 94), a predefined constant is displayed in the Preprocessor Definitions field (in the Preprocessor category in the C tab of
the Project Settings dialog box; see page 111). This constant is the name of the product
family member prefixed with an underscore. For example, selecting EZ80190 creates the
constant _EZ80190. You can also add any predefined name to the field. Further, there is a
file named ez80cc.con in the following directory:
ZILOGINSTALL\ZDSII_product_version\bin
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!,
eZ80Acclaim!, Crimzon, or Z8GP.
•
version is the ZDS II version number. For example, version might be 4.8.0 or
4.9.0.
This ordinary text file contains the default command line option setting for the
eZ80Acclaim! developer’s environment. To add a name that will be available to your code
at all times, use the -define option. For example:
eZ80cc.con
-define:__XYZ__=1
-define:data=RAM
test.c
data x = __XYZ__;
void test(void)
(
++xx;
}
Note: This option is an effective way of setting up the eZ80Acclaim! C-Compiler to compile
code written for another compiler. Modifications to the eZ80cc.con file take effect the
next time you open the Developer Environment after making the modifications.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
276
Why do floating-point operations give incorrect results?
The most common reason for floating-point operations giving incorrect results is that the
Use Floating Point Library check box on the Project Settings dialog box (“C (Compiler)
Tab” on page 95) is not checked. Because relatively few embedded microcontroller applications require the use of floating point, eZ80Acclaim! developer’s environment uses a
version of the run-time library that features all floating-point routines stubbed out, which
saves code space. If the Use Floating Point Library check box is checked, the floatingpoint routines are linked into your program as necessary and give the correct results.
WARNING AND ERROR MESSAGES
This section covers the following:
•
•
•
“Preprocessor Warning and Error Messages” on page 276
“Front-End Warning and Error Messages” on page 279
“Code Generator Warning and Error Messages” on page 288
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 <name>.
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 <name>.
An attempt was made to call a macro, but too few or too many arguments were given.
005 Unbalanced parentheses in macro call.
An attempt was made to call a macro with a parenthesis embedded in the argument list
that did not match up.
006 Cannot redefine <name> keyword.
An attempt was made to redefine a keyword as a macro.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
277
007 Illegal directive.
The syntax of a preprocessor directive is incorrect.
008 Illegal "#if" directive syntax.
The syntax of a #if preprocessor directive is incorrect.
009 Bad preprocessor file. Aborted.
An unrecognizable source file was given to the compiler.
010 Illegal macro call syntax.
An attempt was made to call a macro that does not conform to the syntax rules of the
language.
011 Integer constant too large.
An integer constant that has a binary value too large to be stored in 32 bits was
encountered.
012 Identifier <name> is undefined
The syntax of the identifier is incorrect.
013 Illegal #include argument.
The argument to a #include directive must be of the form "pathname" or <filename>.
014 Macro "<name>" 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 constant was encountered with a character greater than the radix of the
constant.
020 More than four characters in string constant.
A string constant was encountered having more than four ASCII characters.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
278
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.
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 <linenum> directive, <linenum> 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 <name>.
The macro name does not have a valid identifier syntax.
031 Extra "#endif" found.
#endif directive without a corresponding #if 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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
279
036 Unsupported CPU "name" in pragma.
An unknown CPU encountered.
037 Unsupported or poorly formed pragma.
An unknown #pragma directive encountered.
Front-End Warning and Error Messages
100 Syntax error.
A syntactically incorrect statement, declaration, or expression was encountered.
101 Function "<name>" 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 "<name>".
A function prototype or function declaration was encountered that has a different
result from a previous declaration.
105 Argument type mismatch for argument <name>.
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 "<name>" is not a variable or enumeration constant name.
In a declaration, a reference to an identifier was made that was not a variable name or
an enumeration constant name.
109 Cannot return a value from a function returning "void".
An attempt was made to use a function defined as returning void in an expression.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
280
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.
118 Escape sequence ASCII code too large to fit in char
The binary value of an escape sequence requires more than 8 bits of storage.
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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
281
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 "<name>" already declared within current scope.
An attempt was made to declare two objects of the same name in the same scope.
126 Identifier "<name>" not in function argument list, ignored.
An attempt was made to declare an argument that is not in the list of arguments when
using the old style argument declaration syntax.
127 Name of formal parameter not given.
The type of a formal parameter was given in the new style of argument declarations
without giving an identifier name.
128 Identifier "<name>" 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 "<name>" is already declared.
An attempt was made to define two labels of the same name in the same scope.
131 Label "<name> 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 <name> already declared.
An attempt was made to declare two cases with the same value.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
282
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 a type pointer to function.
139 Expression to left of "." or "->" 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 "<name>" is not a member of <name> structure.
An attempt was made to reference a member of a structure that does not belong to the
structure.
141 Object cannot be subscripted.
An attempt was made to use an expression as the address of an array or a pointer that
was not an array or pointer.
142 Array subscript must be of integral type.
An attempt was made to subscript an array with a non integral expression.
143 Cannot dereference a pointer to "void".
An attempt was made to dereference a pointer to void.
144 Cannot compare a pointer to a non-pointer.
An attempt was made to compare a pointer to a non-pointer.
145 Pointers to different types may not be compared.
An attempt was made to compare pointers to different types.
146 Pointers may not be added.
It is not legal to add two pointers.
147 A pointer and a non-integral may not be subtracted.
It is not legal to subtract a non-integral expression from a pointer.
148 Pointers to different types may not be subtracted.
It is not legal to subtract two pointers of different types.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
283
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 "<name>" must be arithmetic type.
An expression was encountered whose type was not arithmetic where only arithmetic
types are allowed.
154 "<name>" must be integral type.
An expression was encountered whose type was not integral where only integral types
are allowed.
155 "<name>" must be arithmetic or pointer type.
An expression was encountered whose type was not pointer or arithmetic where only
pointer and arithmetic types are allowed.
156 Expression must be an lvalue.
An expression was encountered that is not an lvalue where only an lvalue is allowed.
157 Cannot assign to an object of constant type.
An attempt was made to assign a value to an object defined as having constant type.
158 Cannot subtract a pointer from an arithmetic expression.
An attempt was made to subtract a pointer from an arithmetic expression.
159 An array is not a legal lvalue.
Cannot assign an array to an array.
160 Cannot take address of a bit field.
An attempt was made to take the address of a bit field.
161 Cannot take address of variable with "register" class.
An attempt was made to take the address of a variable with "register" class.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
284
162 Conditional expression operands are not compatible.
One operand of a conditional expression cannot be promoted to the type of the other
operand.
163 Casting a non-pointer to a pointer.
An attempt was made to promote a non-pointer to a pointer.
164 Type name of cast must be scalar type.
An attempt was made to cast an expression to a non-scalar type.
165 Operand to cast must be scalar type.
An attempt was made to cast an expression whose type was not scalar.
166 Expression is not a structure or union.
An expression was encountered whose type was not structure or union where only a
structure or union is allowed.
167 Expression is not a pointer to a structure or union.
An attempt was made to dereference a pointer with the arrow operator, and the
expression’s type was not pointer to a structure or union.
168 Cannot take size of void, function, or bit field types.
An attempt was made to take the size of an expression whose type is void, function, or
bit field.
169 Actual parameter has no corresponding formal parameter.
An attempt was made to call a function whose formal parameter list has fewer
elements than the number of arguments in the call.
170 Formal parameter has no corresponding actual parameter.
An attempt was made to call a function whose formal parameter list has more
elements than the number of arguments in the call.
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 "<name>" 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 "<name>" is not a structure tag.
The tag of a declaration of a structure object does not have type structure.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
285
174 Identifier "<name>" is not a union tag.
The tag of a declaration of a union object does not have type union.
175 Structure or union tag "<name>" is not defined.
The tag of a declaration of a structure or union object is not defined.
176 Only one storage class may be given in a declaration.
An attempt was made to give more than one storage class in a declaration.
177 Type specifier cannot have both "unsigned" and "signed".
An attempt was made to give both unsigned and signed type specifiers in a
declaration.
178 "unsigned" and "signed" may be used in conjunction only with "int", "long" or "char".
An attempt was made to use signed or unsigned in conjunction with a type specifier
other than int, long, or char.
179 "long" may be used in conjunction only with "int" or "double".
An attempt was made to use long in conjunction with a type specifier other than 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.
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 "<name>" has too many initializers.
An attempt was made to initialize an array with more elements than the array contains.
184 Structure "<name>" has too many initializers.
An attempt was made to initialize a structure with more elements than the structure
has members.
185 Dimension size may not be omitted.
An attempt was made to omit the dimension of an array which is not the rightmost
dimension.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
286
186 First dimension of "<name>" 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 "<name>" 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 "<name>" detected.
An attempt was made to use a variable without any previous definition or declaration.
194 Recursive structure declaration.
A structure member can not be of same type as the structure itself.
195 Initializer is not assignment compatible.
The initializer type does not match with the variable being initialized.
196 Empty parameter list is an obsolescent feature.
Empty parameter lists are not allowed.
197 No function prototype "<name>" in scope.
The function <name> is called without any previous definition or declaration.
198 "old style" formal parameter declarations are obsolescent.
Change the parameter declarations.
199 Data objects cannot have "io" storage class.
Change the storage class.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
287
200 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();
201 Can't preprocess format to (s)printf
This message is generated when the format parameter to printf or sprintf is not a
string literal and the inline generation of printf calls is requested. For example, the
following code causes this warning:
static char msg1 = "x = %4d";
char buff[sizeof(msg1)+4];
sprintf(buff,msg1,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 “Code Generation Category”
on page 97) so that all calls to printf and sprintf are handled by the real
printf or sprintf functions.
– Recode to pass a string literal. For example, the code in the example can be
revised as follows:
define MSG1 "x = %4d"
char buff[sizeof(MSG1)+4];
sprintf(buff,MSG1,x);
// OK
–
Keep the Generate Printfs Inline check box selected and ignore the warning. This
loses the primary goal of the option but results in the faster execution of the calls
to printf or sprintf that can be processed at compile time, a secondary goal of
the option.
202 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).
203 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");
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
288
204 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.
205 Missing declaration of (s)printf helper function, variable, or field
This warning is generated when the compiler has not seen the prototypes for the
printf or sprintf helper functions it generates calls to. This occurs if the standard
include file stdio.h has not been included or if stdio.h from a different release of
ZDS II has been included.
206 Can't preprocess calls to vprintf or vsprintf
This message is generated when the code contains calls to vprintf or vsprintf and
the inline generation of printf calls is requested. The reason for this warning and the
solutions are similar to the ones for message 201: Can’t preprocess format to (s)printf.
302 Unrecognized/invalid type specifier.
The type or syntax is incorrect.
Code Generator Warning and Error Messages
303 Case value <number> 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.
308 Excessive Registers required at line <num> of function <func>.
Excessive Page 0 registers are required at line number <num>. 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 <name> cannot have arguments.
A function declared as an interrupt function cannot have function arguments.
310 Index out of range, truncating index of <num> 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.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
289
312 Aggregate Copy out of range, truncating copy size of <num> 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 8 bits.
The compiler only accepts bitfield lengths of 8 bits or less.
UM014418-0205
4 Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
290
5
Using the Macro Assembler
You use the Macro Assembler to translate eZ80Acclaim! assembly language files with the
.asm extension into relocatable object modules with the .obj extension. After your relocatable object modules are complete, you convert them into an executable program using
the linker/locator. The Macro Assembler can be configured using the Assembler tab of the
Project Settings dialog box (see “Assembler Tab” on page 112).
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 “Command Processor Quick Tour” on page 31.
The following topics are covered in this chapter:
•
•
•
•
•
•
•
•
•
•
•
•
•
“Address Spaces and Segments” on page 291
“Output Files” on page 294
“Source Language Structure” on page 295
“Expressions” on page 298
“Directives” on page 301
“Conditional Assembly” on page 313
“Macros” on page 315
“Labels” on page 319
“Addressing Modes” on page 320
“Source Language Syntax” on page 322
“Compatibility Issues” on page 325
“Troubleshooting the Assembler” on page 328
“Warning and Error Messages” on page 328
Note: For more information about eZ80Acclaim! CPU instructions, see the “CPU Instruction
Set” section in the eZ80 CPU User Manual (UM0077).
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
291
ADDRESS SPACES AND SEGMENTS
You access the memory regions of the eZ80 family microcontroller by using segment
directives. A segment is a contiguous set of memory locations. All segments are attached
to exactly one memory space. The eZ80Acclaim! assembler has predefined spaces
(described in “Address Spaces”) and predefined segments (described in “Segments” on
page 292).
Allocating Processor Memory
All memory locations, whether data or code, must be defined within a segment. There are
two types of segments:
•
Absolute segments
An absolute segment is any segment with a fixed origin. The origin of a segment can
be defined with the ORG directive. All data and code in an absolute segment is located
at the specified physical memory address.
•
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 eZ80Acclaim! microprocessor are represented by the address
spaces listed in Table 19.
Table 19. eZ80Acclaim! Address Spaces
Lowest and
Highest
Addresses Size
Maximum
That Can Be
Minimal
Addressable Retrieved at
One Time
Unit
Space ID
Display
Prefix
ROM
C
Standard memory address space. 00000000– 16 MB
The ROM memory address space 00FFFFFF
can contain both program code
and data. If no address space is
associated with a segment, this is
the default space.
8 bits
3 maus
(24 bits)
RAM
D
Random access memory address XXE000–
space. 8 KB x 8 data RAM for
XXFFFF
general-purpose use and
1 KB x 8 static RAM for use with
the Multiply-Accumulator unit.
8 bits
3 maus
(24 bits)
UM014418-0205
Description
8 KB
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
292
Table 19. eZ80Acclaim! Address Spaces (Continued)
Lowest and
Highest
Addresses Size
Maximum
That Can Be
Minimal
Addressable Retrieved at
One Time
Unit
Space ID
Display
Prefix
Description
INTIO
I
On-chip I/O address space.
00000000– 256 bytes 8 bits
000000FF
1 mau
(8 bits)
EXTIO
E
External I/O address space.
00000000– 64 KB
0000FFFF
2 maus
(16 bits)
6 bits
Note: The lowest and highest addresses are the lowest and highest possible addresses; the CCompiler uses the values in Table 19 as a default. However, the hardware might not
physically have all of the possible addresses, so you can use ZDS II to set a different range.
Code and data is 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. A segment is associated with an address space.
Predefined Segments
For convenience, the segments listed in Table 20 are predefined by the assembler. Each
segment gets assigned to one of the address spaces in Table 19. If no address space is associated with a segment, ROM is the default space.
Table 20. Predefined Segments
Segment Name
Address Space
Alignment
Contents
__VECTORS
ROM
Align on any byte boundary
Constant data
STRSECT
RAM
Align on any byte boundary
Initialized strings
TEXT
ROM
Align on any byte boundary
Constant data
BSS
RAM
Align on any byte boundary
Uninitialized data
DATA
RAM
Align on any byte boundary
Initialized data
CODE
ROM
Align on any byte boundary
Code
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
293
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 directive, and MYSEG remains the current segment until a new SEGMENT directive appears.
MYSEG can be used as a segment name in the linker command file.
You can define a new segment in RAM using the following directives:
DEFINE MYDATA,SPACE=EDATA
SEGMENT MYDATA
or
DEFINE MYDATA,SPACE=RDATA
SEGMENT MYDATA
The DEFINE directive creates a new segment and attaches it to a space. For more information about using the DEFINE directive, see “DEFINE” on page 306. The SEGMENT directive 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 311.
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.
Assigning Memory at Link Time
At link time, the linker groups those segments of code and data that have the same name
and places the resulting segment in the address space to which it is attached. However, the
linker handles relocatable segments and absolute segments differently:
•
Relocatable segments
If a segment is relocatable, the linker decides where in the address space to place the
segment.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
294
•
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 341.
OUTPUT FILES
The assembler creates the following files and names them the name of the source file but
with a different extension:
•
<source>.lst contains a readable version of the source and object code generated by
the assembler. The assembler creates <source>.lst unless you deselect the Generate
Listing File (.lst) check box in the Assembler tab of the Project Settings dialog box.
See “Generate Listing File (.lst)” on page 113.
•
<source>.obj is an object file in relocatable OMF695 format. The assembler creates
<source>.obj unless you deselect the Generate Object check box in the Assembler
tab of the Project Settings dialog box. See “Generate Object” on page 113.
Caution: Do not use source input files with .lst or .obj extensions. The assembler does not assemble files with these extensions, and therefore the data contained in the files is lost.
Source Listing (.lst) Format
The listing file name is the same as the source file name with a .lst file extension.
Assembly directives allow you to tailor the content and amount of output from the assembler.
Each page of the listing file (.lst) contains the following:
•
•
•
Heading with the assembler version number
Source input file name
Date and time of assembly
Source lines in the listing file are preceded by the following:
•
•
•
•
•
UM014418-0205
Include level
Plus sign (+) if the source line contains a macro
Line number
Location of the object code created
Object code
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
295
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:
•
•
•
•
•
•
NEWPAGE
TITLE
NOLIST
LIST
MACLIST ON/OFF
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, use the -relist option for the assembler. For example:
ez80asm mfile.src -relist:afile.map
This example uses the information in the .src file (generated by the compiler when the
-keepasm option is used or when the Generate Assembly Source (.src) check box is
selected [see “Listing Files Category” on page 109]) and the .map file to change all of the
relative addresses in the assembly listing into absolute addresses.
Object Code (.obj) File
The object code output file name is the same as the source file name with an .obj extension. This file contains the relocatable object code in OMF695 format and is ready to be
processed by the linker and librarian.
SOURCE LANGUAGE STRUCTURE
This section describes the form of an assembly source file.
General Structure
A line consists in an assembly source file is either a source line or a comment line. You
should ignore blank lines. Each line of input consists of ASCII characters terminated 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 concatenated onto the end of the line with the backslash, as exemplified in the C programming
language. Place a space or any other character after the backslash, and your code will be
assembled.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
296
Source Line
A source line is composed of an optional label followed by an instruction or a directive. A
source line can 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
If included, the label field must be the first item in a source line. The first character of a
label can be a letter, an underscore _ , a dollar sign ($), a question mark (?), a period (.), or
pound sign (#). Following characters can include letters, digits, underscores, dollar signs
($), question marks (?), periods (.), or pound signs (#). 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. See “Labels” on page 319 for more information.
Instruction
An instruction contains one valid assembler instruction that consists of a mnemonic and its
arguments. Use commas to separate the operands. Use a semicolon or carriage return to
terminate the instruction. For more information about eZ80 CPU instructions, see the
“CPU Instruction Set” section in the eZ80 CPU User Manual (UM0077).
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 operands. See “Directives” on page 301 for more information.
Case Sensitivity
In the default mode, the assembler treats all symbols as case sensitive. Select the Ignore
Case check box of the Assembler tab in the Project Settings dialog box to invoke the
assembler and ignore the case of user-defined identifiers (see “Ignore Case” on page 113).
Assembler reserved words are not case sensitive.
Assembler Rules
Reserved Words
The following list contains reserved words the assembler uses. You cannot use these
words as symbol names or variable names. Also, reserved words are not case sensitive:
ADC
C
C0
C1
C2
C3
DMA
EQ
F
FLAGS
GE
GT
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
297
I2C
IMR
IPR
LE
LT
MI
NC
NE
NOV
NZ
OV
P0
P01M
P0AD
P1
P1AD
P2
P2AD
P2M
P3
P3AD
P3M
P4AD
P5AD
P6AD
P7AD
PL
PRE0
PRE1
r0
r10
r11
r12
r13
r14
r15
r2
r3
r4
r5
r6
r7
r8
r9
RESET
RP
rr0
rr10
rr12
rr14
rr2
rr4
rr6
rr8
SIO
SPH
SPI
T0
T1
TIMER0
TIMER1
TIMER2
TIMER3
TMR
TRAP
UART0RX
UART0TX
UART1RX
UART1TX
UGE
UGT
ULE
ULT
WDT
Z
Note: Additionally, do not use the instruction mnemonics or assembler directives as symbol or
variable names.
Assembler Numeric Representation
Numbers are represented internally as signed 32-bit integers. Floating-point numbers are
32-bit IEEE standard single-precision values. The assembler detects an expression operand that is out of range for the intended field and generates appropriate error messages.
Character Strings
Character strings consist of printable 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 insert null character (0's) at the end of a text string automatically
unless a 0 is inserted, and a character string cannot be used as an operand. For example:
DB
DB
DB
DB
UM014418-0205
"STRING" ; a string
'STRING',0 ; C printable string
"STRING\"S" ; embedded quote
'a','b','c' ; character constants
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
298
EXPRESSIONS
In most cases, where a single integer or float value can be used as an operand, an expression 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
<<
Left Shift
>>
Arithmetic Right Shift
**
Exponentiation
*
Multiplication
/
Division
%
Modulus
+
Addition
-
Subtraction
Note: You must put spaces before and after the modulus operator to separate it from the rest of
the expression.
Relational Operators
For use only in conditional assembly expressions.
==
Equal
!=
Not Equal
>
Greater Than
<
Less Than
>=
Greater Than or Equal
<=
Less Than or Equal
Boolean Operators
&
Bitwise AND
|
Bitwise inclusive OR
^
Bitwise exclusive XOR
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
299
~
Complement
!
Boolean NOT
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
Decimal Numbers
Decimal numbers are signed 32-bit integers consisting of the characters 0–9 inclusive
between -2147483648 and 2147483647. An underscore (_) can be used to separate digits for readability; the assembler ignores it. Positive numbers are indicated by the absence
of a sign. Negative numbers are indicated by a minus sign (-) preceding the number. For
example:
1234 ; decimal
-123_456 ; negative decimal
12E-45 ; decimal float
-123.456 ; decimal float
123.45E6 ; decimal float
Hexadecimal Numbers
Hexadecimal numbers are signed 32-bit integers ending with the h 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. Negative numbers are indicated by a minus sign (-) preceding the number. For example:
ABCDEFFFH ; hexadecimal
%ABCDEFFF ; hexadecimal
-0FFFFh ; negative hexadecimal
Binary Numbers
Binary numbers are signed 32-bit integers ending with the character b or B and consisting
of the characters 0 and 1. A binary number can have 32 characters. Positive numbers are
indicated by the absence of a sign. Negative numbers are indicated by a minus sign (-)
preceding the number. For example:
-0101b ; negative binary number
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
300
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. For example:
1234o ; octal number
-1234o ; negative octal number
Character Constants
A single printable ASCII character enclosed by single quotes (') can be used to represent
an ASCII value. This value can be used as an operand value. For example:
'A' ; ASCII code for "A"
'3' ; ASCII code for "3"
Operator Precedence
Table 21 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 21. Operator Precedence
Level 1
()
Level 2
~
unary- !
high low
Level 3
**
*
/
%
Level 4
+
-
&
|
^
>>
Level 5
<
>
<=
>=
==
!=
<<
Note: Shift Left (<<) 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<<2 | 1<<1
The constant expression in the preceding instruction evaluates to 2A H.
If you want to perform the Shift Left operations before the OR operation, use
parentheses as follows:
ld a, #(1<<2)|(1<<2)|(1<<1)
The modified constant expression evaluates to 6 H.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
301
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 supported assembler directives. For a list of compatible directives, see Table 23,
“eZ80Acclaim! Directive Compatibility,” on page 325.
ALIGN
Forces the object following to be aligned on a mau boundary that is a multiple of <value>.
Synonym
.align
Syntax
<align_directive> = > 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 assembler 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.
Syntax
.COMMENT delimiter [ text ] delimiter
Example
.COMMENT $
This text is a comment, delimited by a dollar sign, and spanning multiple source lines. The
dollar sign ($) is a deliminator that marks the line as the end of the comment block.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
302
CPU
Defines to the assembler which member of the eZ80 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.
The CPU directive can use the following predefined symbols:
•
•
•
eZ80F93
eZ80F92
eZ80F91
When eZ80F91 is selected, the following preprocessors are automatically defined:
_EZ80F91=1
_EZ80F92=0
These preprocessors can be used for conditional assembly. For example:
.if
...
.endif
_EZ80F91
When eZ80F92 is selected, the following preprocessors are automatically defined:
_EZ80F91=0
_EZ80F92=1
These preprocessors can be used for conditional assembly. For example:
.if
...
.endif
_EZ80F92
If you use a predefined symbol in your code, the symbol is already defined. For example
IFDEF EZ80190
Instead, use the following code:
_EZ80190 EQU 1
IFDEF _EZ80190
Note: The CPU directive is used to determine the physical location of the interrupt vectors.
Syntax
<cpu_definition> = > CPU = <cpu_name>
Example
CPU = EZ80L92
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
303
Data Directives
Data directives allow you to reserve space for specified types of data.
Syntax
<data directive> = > <type> <value>
<type> => DB
=> DD
=> DF
=> DL
=> DW
<value_list> => <value>
=> <value_list>,<value>
<value> => <expression>|<string_const>
BFRACT and UBFRACT Declaration Type
Syntax
BFRACT
signed fractional (8 bits)
UBFRACT
unsigned fractional (8 bits)
Examples
BFRACT [3]0.1, [2]0.2 ;
;
;
;
UBFRACT [50]0.1,[50]0.2
Reserve space for five 8 bit
signed fractional numbers.
Initialize first 3 with 0.1,
last 2 with a 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.
FRACT and UFRACT Declaration Type
Syntax
FRACT
signed fractional (8 bits)
UFRACT
unsigned fractional (8 bits)
Example
FRACT [3]0.1, [2]0.2 ;
;
;
;
UM014418-0205
Reserve space for five 16 bit
signed fractional numbers.
Initialize first 3 with 0.1,
last 2 with a 0.2.
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
304
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
bytes data (8 bits) [, <init_value>]
Example
BLKB 16 ; Allocate 16 uninitialized bytes.
BLKB 16, -1 ; Allocate 16 bytes and initialize them to -1.
BLKL Declaration Type
Syntax
BLKL
bytes data (32 bits) [, <init_value>]
Example
BLKL 16 ; Allocate 16 uninitialized longs.
BLKL 16, -1 ; Allocate 16 longs and initialize them to -1.
BLKP Declaration Type
Syntax
BLKP
bytes data (32 bits) [, <init_value>]
Example
BLKP 16 ; Allocate 16 uninitialized longs.
BLKP 16, -1 ; Allocate 16 longs and initialize them to -1.
BLKW Declaration Type
Syntax
BLKW
bytes data (16 bits) [, <init_value>]
Example
BLKW 16 ; Allocate 16 uninitialized words.
BLKW 16, -1 ; Allocate 16 words and initialize them to -1.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
305
DB Declaration Type
Synonyms
.byte, .ascii, DEFB, FCB, STRING, .STRING, byte
Syntax
DB
byte data (8 bits)
Example
DB "Hello World" ; Reserve and initialize 11 bytes.
DB "Hello" ; Reserve 12 bytes. Initialize 6.
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.
DD Declaration Type
Synonym
.double
Syntax
DD
double signed fractional (32 bits)
Example
DD 0.1,0.2 ; Reserve space for 2 double word signed fractional
; numbers. Initialize the first with a 0.1 and
; the last with a 0.2.
DD 0.5 ; Reserve space for 1 double word signed fractional
; number and initialize it to 0.5.
DF Declaration Type
Synonym
.float
Syntax
DF
word signed fractional (16 bits)
Example
DF 0.1,0.2 ; Reserve space for 2 word signed
; fractional numbers. Initialize
; first with a 0.1 and last with a
UM014418-0205
0.2.
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
306
DF .5 ; Reserve space for 1 word signed
; fractional number and initialize it to 0.5.
DL Declaration Type
Synonyms
.long, long
Syntax
DL long (32 bits)
Example
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)
Example
DW "Hello World" ; Reserve and initialize 11 words.
DW "Hello" ; Reserve 12 words, initialize 6.
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 %1234.
Note: There is no trailing null for the DW declaration type. Each letter gets 16 bits with the upper
8 bits zero.
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 “Segments” on page 292.
Synonym
.define
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
307
Syntax
<segment_definition> =>
DEFINE<ident>[<space_clause>][align_clause>][<org_clause>]
Example
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 %FFF8.
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 is a multiple of the MAU defined for
the space identifier. The multiple must be a power of two (1, 2, 4, 8, and so on).
Syntax
<align_clause> => ,ALIGN = <int_const>
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> => ,ORG = <int_const>
Example
DEFINE near_data
; Uses the defaults of NEAR_ROM, word alignment and relocatable.
DEFINE far_data,SPACE = FAR_RAM,ALIGN = 2
; Aligns on a half-word boundary, relocatable.
DEFINE near_code,ORG = %FFF8
; Uses NEAR_ROM, word alignment, and absolute starting
; address at memory location %FFF8.
SPACE Clause
A SPACE clause defines the address space in which the segment resides. The linker groups
together segments with the same space identification. See Table 19, “eZ80Acclaim!
Address Spaces,” on page 291 for available spaces.
Syntax
<space_clause> => ,SPACE = <indent>
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
308
DS
Defines storage locations that do not need to be initialized.
Synonym
.block
Syntax
<define_storage> => DS <value>
Example
NAME DS 10 ; Reserve 10 bytes of storage.
END
Informs the assembler of the end of the source input file. If the operand field is present, it
defines the start address of the program. During the linking process, only one module can
have a start address; otherwise, an error results. The END directive is 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> => END[<expression>]
Example
END start ; Use the value of start as the program start address.
EQU
Assigns symbolic names to numeric or string values. Any name used to define an equate
must not have been previously defined. Other equates and label symbols are allowed in the
expression, provided they are previously defined. Labels are not allowed in the expression.
Caution: You cannot export EQU using the XDEF directive or import using the XREF directive.
Synonyms
.equ, .EQU, EQUAL
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
309
Syntax
<label> EQU <expression>
Example
pi EQU 3.141 ; set to the value of pi
area EQU pi*7*7 ; area of a circle
reg EQU rr4 ; symbolic name of a register
INCLUDE
Allows the insertion of source code from another file into the current source file during
assembly. The included file is assembled into the current source file immediately after the
directive. When the EOF (End of File) of the included file is reached, the assembly
resumes on the line 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 (.lst) file unless a NOLIST directive is active.
Synonyms
.include, .copy
Syntax
<include_directive> => INCLUDE[<string_const>]
Example
INCLUDE "calc.h" ; include calc header file
INCLUDE "\test\calc.h" ; contains a path name
INCLUDE calc.h ; 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, .LIST
Syntax
<list_directive> => LIST
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
310
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> => NEWPAGE
Example
NEWPAGE
NOLIST
Turns off the generation of the listing file. This mode remains in effect until a LIST directive is encountered. No operand is allowed.
Synonym
.NOLIST
Syntax
<nolist_directive> => NOLIST
Example
LIST
NOLIST
ORG
Resets the assembler's internal program counter to the integer constant following the ORG
and causes absolute code/data to be generated.
The ORG directive must be followed by an integer constant.
Synonyms
ORIGIN, .org
Syntax
<org_directive> => ORG <int_const>
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
311
Example
ORG %1000 ; generate absolute code at %1000
ORG LOOP ; ERROR, use an integer constant
Note: If the ORG directive is used within a relocatable segment, that segment becomes an absolute
segment, with 0 as the base physical address of the segment. It is recommended that
segments requiring the use of an ORG be declared as absolute segments.
SEGMENT
Specifies entry into a previously defined segment.
The SEGMENT directive must be followed by the segment identifier. The default segment is
used until the assembler encounters a SEGMENT directive. The internal assembler program
counter is reset to the previous program counter of the segment when a SEGMENT directive
is encountered. See Table 20, “Predefined Segments,” on page 292 for the names of predefined segments.
Synonyms
.section, SECTION
Syntax
<segment_directive> => SEGMENT <ident>
Example
SEGMENT code ; predefined segment
DEFINE data ; user-defined
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> => TITLE <string_const>
Example
TITLE "My Title"
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
312
VECTOR
Initializes an interrupt or reset vector to a program address. <vector name> specifies
which vector is being specified. <vector name> must be one of the following:
•
•
•
•
•
•
•
IRQ0
IRQ1
IRQ2
IRQ3
IRQ4
IRQ5
RESET
If RESET is used, the assembler inserts a JP instruction to <expression> at the proper reset
address. <expression> is the address, usually a label, of the program code to handle the
interrupt or reset.
Note: If no reset vector is defined within the program, the linker generates a warning messages.
The CPU directive is used to determine the physical location of the interrupt vectors.
Syntax
<vector_directive> => VECTOR <vector name> = <expression>
Example
VECTOR IRQ0 = irq0_handler
VECTOR IRQ1 = irq1_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
<xdef_directive> => XDEF <ident list>
Example
XDEF label
XDEF label1,label2,label3
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
313
XREF
Specifies that a list of labels in the operand field are defined in another module. The reference is resolved by the linker. The labels must not be defined in the current module.
Synonyms
.extern, EXTERN, EXTERNAL, .ref
Syntax
<xref_directive> => XREF <ident list>
Example
XREF label
XREF label1,label2,label3
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:
•
•
•
•
IF
IFDEF
IFSAME
IFMA
Any symbol used in a conditional directive must be previously defined by an EQU or VAR
directive. Relational operators can be used in the expression. Relational expressions evaluate to 1 if true and evaluate to 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.
Note: Conditional assembly can be nested.
Conditional Assembly Directives
IF
Evaluates a Boolean expression. If the expression evaluates to 0, the result is false; otherwise, the result is true.
Synonyms
.if, .IF, IFN, IFNZ, COND, IFTRUE, IFNFALSE, .$IF, .$if
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
314
Syntax
IF [<cond_expression> <code_body>]
[ELIF <cond_expression> <code_body>]
[ELSE <code_body>]
ENDIF
Example
IF XYZ ; process code body if XYZ is not 0
.
.
.
<Code Body>
.
.
ENDIF
IF XYZ !=3 ; code body 1 if XYZ is not 3
.
.
.
<Code Body 1>
.
.
.
x ; XYZ=3 and ABC is not 0,
ELSE ; otherwise code body 3
.
.
.
<Code Body 3>
.
.
.
ENDIF
IFDEF
Checks for label definition. Only a single label can be used with this conditional. If the
label is defined, the result is true; otherwise, the result if false.
Syntax
IFDEF <label>
<code_body>
[ELSE
<code_body>]
ENDIF
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
315
Example
IFDEF XYZ
.
.
.
<Code Body>
.
.
.
ENDIF
; process code body if XYZ is
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 <string_const> , <string_const>
<code_body>
[ELSE
<code_body>]
ENDIF
IFMA
Used only within a macro, this directive checks to determine if a macro argument has been
defined. If the argument is defined, the result is true. Otherwise, the result is false. If
<arg_number> is 0, the result is TRUE if no arguments were provided; otherwise, the
result is FALSE.
Syntax
IFMA <arg_number>
<code_body>
[ELSE
<code_body>]
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 expanded. The following sections
describe how to define and invoke macros.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
316
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 arguments that are substituted with actual arguments when the macro is expanded. The arguments can be optionally prefixed with the substitution character (\) in the macro body.
During the invocation of the macro, a token substitution is performed, replacing the formal
arguments (including the substitution character, if present) with the actual arguments.
Syntax
<macroname>[:]MACRO[<arg>(,<arg>)...]
<macro_body>
ENDMAC[RO]<macroname>
Example
store: MACRO reg1,reg2,reg3
ADD reg1,reg2
MOV reg3,reg1
ENDMAC store
Concatenation
To facilitate unambiguous symbol substitution during macro expansion, the concatenation
character (&) can be suffixed to symbol names. The concatenation character is a syntactic
device for delimiting symbol names that are points of substitution and is devoid of semantic content. The concatenation character, therefore, is discarded by the assembler, when
the character has delimited a symbol name. For example:
val_part1 equ 55h
val_part2 equ 33h
The assembly is:
value
macro par1, par2
DB par1&_&par2
macend
value val,part1
value val,part2
The generated list file is:
000000 55
000001 33
UM014418-0205
A
A+
A+
A
A+
A+
9
9
9
10
10
10
value val,part1
DB val_part1
macend
value val,part2
DB val_part2
macend
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
317
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
<macroname>[<arg>[(,<arg>)]...]
Example
store R1,R2,R3
This macro invocation causes registers R1 and R2 to be added and the result stored in register R3.
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 invocation number.
Syntax
$$ <label>
Example
LJMP: MACRO cc,label
JR cc,$$lab
JP label
$$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 if
an argument was supplied with the invocation.
Example
MISSING_ARG: MACRO ARG0,ARG1,ARG2
IFMA 1
LD ARG0,ARG1
ELSE
LD ARG0,ARG2
ENDIF
ENDMACRO MISSING_ARG
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
318
Invocation
MISSING_ARG R1, ,@R2 ; missing second arg
Result
MOV R1,@R2
Note: IFMA refers to argument numbers that are zero based (that is, the first argument is
numbered zero).
Exiting a Macro
The MACEXIT directive is used to immediately exit a macro. No further processing is performed. 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 terminate the macro.
Example
RECURS_MAC: MACRO ARG1,ARG2
IFMA 0
MACEXIT
ELSE
RECURS_MAC ARG2
DB ARG1
ENDIF
ENDMACRO RECURS_MAC
Delimiting Macro Arguments
Macro arguments can be delimited by using the current macro delimiter characters defined
using the MACDELIM directive. The delimiters can be used 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
BRA: MACRO ARG1
JP ARG1
ENDMAC LJMP
Invocation
BRA {dummy,X}
Result
JP dummy,X
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
319
LABELS
Labels are considered symbolic representations of memory locations and can be used to
reference that memory location within an expression. See “Source Language Structure” on
page 295 for the form of a legal label.
The following sections describe labels.
Local Labels
Any label beginning with a dollar sign ($) or ending with a question mark (?) is considered to be a local label. The scope of a local label ends when a SCOPE directive is encountered, thus allowing the label name to be reused. A local label cannot be imported or
exported.
Example
$LOOP:
LAB?:
$LOOP:
LAB?:
JP $LOOP
JP LAB?
SCOPE
JP $LOOP
JP LAB?
;
;
;
;
;
Infinite branch to $LOOP
Infinite branch to LAB?
New local label scope
Reuse $LOOP
Reuse LAB?
Importing and Exporting Labels
Labels can be imported from other modules using the EXTERN or XREF directive. A space
can be provided in the directive to indicate the label's location. Otherwise, the space of the
current segment is used as the location of the label.
Labels can be exported to other modules by use of the PUBLIC or XDEF directive.
Label Spaces
The assembler makes use of a label's space when checking the validity of instruction operands. Certain instruction operands require that a label be located in a specific space, since
that instruction can only operate on data located in that space. A label is assigned to a
space by one of the following methods:
•
•
•
The space of the segment in which the label is defined.
The space provided in the EXTERN or XREF directive.
If no space 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 forward referenced labels. Thus, when a label is not located in the proper space is used as an
operand, the assembler flags a warning.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
320
Example
SEGMENT data_default
EXTERN label1:ROM ; Label1 is located in ROM
EXTERN label2 ; Label2 is located in DATA space
LOAD label2 ; Valid use of page0 label
LOAD label1 ; Generates assembler warning, cannot load from ROM
ADDRESSING MODES
This section discusses the addressing modes supported by the eZ80Acclaim! Macro
Assembler.
Table 22. eZ80Acclaim! Addressing Modes
Addressing Modes
Symbolic Name
8-Bit Register Mode
A
Notes
B
C
D
E
H
L
16/24-Bit Register Mode
BC
DE
HL
IX
IY
Indirect Register Mode
(BC)
(DE)
(HL)
(IX)
(IY)
Indirect Register Mode Plus Offset
16/24-Bit Direct Addressing Mode
PC Relative Addressing Mode
UM014418-0205
(IX+dd)
dd must be in the range of –128<dd<127.
(IY+dd)
dd must be in the range of –128<dd<127.
xxxxH or xxxxxxH For 24-bit values, ADL must equal 1.
PC
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
321
Table 22. eZ80Acclaim! Addressing Modes (Continued)
Addressing Modes
Symbolic Name
Single-Bit Flags
ADL
Notes
Not directly accessible but can be changed by suffixed
JP and CALL instructions.
IEF1
IEF2
MADL
F
Register Pair Addressing Mode
Only used as part of the AF or AF’ register pair. The F
register contains the six status bits used by the
eZ80Acclaim!.
AF
Only used with PUSH and POP instructions
AF’
Only used in EX AF,AF’ instruction
8-Bit Control Registers
I
IXH
IXL
IYH
IYL
MBASE
Only used in LD A,MB instruction where MB stands for
MBASE
R
SP
The ADL mode indicates whether SPS or SPL is
actually used.
Representing Immediate Value
The following are examples of instructions of the ld r, n type:
1. ld a, 1*2
2. ld a, #1*2
3. ld a, #(1*2)
The eZ80Acclaim! assembler accepts an optional prefix character # for the immediate
addressing mode as given in (1) and (2).
For the third case, the prefix character # is mandatory because it conflicts with the indirect
addressing mode. For example:
ld a, (1*2)
;3A0200
ld a, #(1*2) ;3E02
UM014418-0205
Assembled as ld a, (Mmn)
Assembled as ld a, n
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
322
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>
=>
=>
=>
=>
=>
<if_statement>
[<Label_field>]<instruction_field><EOL>
[<Label_field>]<directive_field><EOL>
<Label_field><EOL>
<EOL>
<if_statement>
=>
=>
=>
<if_section>
[<else_statement>]
ENDIF
<if_section>
=>
<if_conditional>
<code-body>
<if_conditional>
=>
IF<cond_expression>|
IFDEF<ident>|
IFSAME<string_const>,<string_const>|
IFMA<int_const>
<else_statement>
=>
ELSE <code_body>|
ELIF<cond_expression>
<code_body>
[<else_statement>]
<cond_expression>
=>
<expression>|
<expression><relop><expression>
<relop>
=>
== | < | > | <= | => | !=
<code_body>
=>
<source_line>@
<label_field>
=>
<ident>:
<instruction_field>
=>
<mnemonic>[<operand>]@
<directive_field>
=>
<directive>
<mnemonic>
=>
valid instruction mnemonic
<operand>
=>
=>
<addressing_mode>
<expression>
<addressing_mode>
=>
valid instruction addressing mode
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
323
<directive>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
ALIGN<int_const>
<array_definition>
CONDLIST(ON|OFF)
END[<expression>]
<ident>EQU<expression>
ERROR<string_const>
EXIT<string_const>
.FCALL<ident>
FILE<string_const>
.FRAME<ident>,<ident>,<space>
GLOBALS (ON|OFF)
INCLUDE<string_const>
LIST (ON|OFF)
<macro_def>
<macro_invoc>
MACDELIM<char_const>
MACLIST (ON|OFF)
NEWPAGE
NOLIST
ORG<int_const>
PL<int_const>
PW<int_const>
<public_definition>
<scalar_definition>
SCOPE
<segment_definition>
SEGMENT<ident>
SUBTITLE<string_const>
SYNTAX=<target_microprocessor>
TITLE<string_const>
<ident>VAR<expression>
WARNING<string_const>
<array_definition>
=>
=>
<type>'['<elements>']'
[<initvalue>(,<initvalue>)@]
<type>
=>
=>
=>
DB
DL
DW
<elements>
=>
[<int_const>]
<initvalue>
=>
['['<instances>']']<value>
<instances>
=>
<int_const>
<value>
=>
<expression>|<string_const>
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
324
<expression>
=>
=>
=>
=>
=>
=>
=>
=>
=>
'('<expression>')'
<expression><binary_op><expression>
<unary_op><expression>
<int_const>
<float_const>
<label>
HIGH<expression>
LOW<expression>
OFFSET<expression>
<binary_op>
=>
=>
=>
=>
=>
=>
=>
=>
=>
+
*
/
>>
<<
&
|
^
<i>
=>
=>
=>
~
!
<int_const>
=>
=>
=>
=>
digit(digit|'_')@
hexdigit(hexdigit|'_')@H
bindigit(bindigit|'_')@B
<char_const>
<char_const>
=>
'any'
<float_const>
=>
<decfloat>
<decfloat>
=>
<float_frac>|<float_power>
<float_frac>
=>
<float_const>[<exp_part>]
<frac_const>
=>
digit|'_') . (digit|'_')@
<exp_part>
=>
E['+'|-]digit+
<float_power>
=>
digit(digit|'_')@<exp_part>
<label>
=>
<ident>
<string_const>
=>
"('\"'|any)@"
<ident>
=>
(letter|'_')(letter|'_'|digit|'.')@
<ident_list>
=>
<ident>(,<ident>)@
<macro_def>
=>
<ident>MACRO[<arg>(<arg>)]
<code_body>
ENDMAC[RO]<macname>
<macro_invoc>
=>
<macname>[<arg>](,<arg>)]
<arg>
=>
macro argument
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
325
<public_definition>
=>
PUBLIC<ident list>
EXTERN<ident list>
<scalar_definition>
=>
<type>[<value>]
<segment_definition>
=>
DEFINE<ident>[<space_clause>]
[<align_clause>][<org_clause>]
<space_clause>
=>
,SPACE=<space>
<align_clause>
=>
,ALIGN=<int_const>
<org_clause>
=>
,ORG=<int_const>
<space>
=>
(RDATA|XDATA|ROM)
COMPATIBILITY ISSUES
Table 23 shows the equivalences between eZ80Acclaim! directives and those of other
assemblers that are also supported by the eZ80Acclaim! assembler. ZMASM directives
that are compatible with eZ80Acclaim! directives are also listed. The eZ80Acclaim!
assembler directives in the left column are the preferred directives, but the assembler also
accepts any of the directives in the right column.
Table 23. eZ80Acclaim! Directive Compatibility
eZ80Acclaim!
Assembler
Compatible With
ALIGN
.align
ASCII
.ascii
ASCIZ
.asciz
ASECT
.ASECT
ASG
.ASG
ASSUME
.ASSUME
BES
.bes
BREAK
.$BREAK,.$break
BSS
.bss
CHIP
chip, .cpu
CONTINUE
.$CONTINUE, .$continue
DATA
.data
DB
.byte, .ascii, DEFB, FCB, STRING, .STRING, byte
DD
.double
DEFINE
.define
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
326
Table 23. eZ80Acclaim! Directive Compatibility (Continued)
eZ80Acclaim!
Assembler
Compatible With
DF
.float
DL
.long, long
DR
<none>
DS
.block
DW
.word, word, .int
DW24
.word24, .trio, .DW24
ELIF
.ELIF, .ELSEIF, ELSEIF, .$ELSEIF, .$elseif
ELSE
.ELSE, .$ELSE, .$else
END
.end
ENDIF
.endif, .ENDIF, ENDC, .$ENDIF, .$endif
ENDMAC
.endm, ENDMACRO, .ENDMACRO, .ENDMAC, ENDM, .ENDM, MACEND,
.MACEND
ENDSTRUCT
.ENDSTRUCT
ERROR
.emsg
EQU
.equ, .EQU, EQUAL
EVAL
.EVAL
FCALL
.FCALL
FILE
.file
FRAME
.FRAME
GREG
GREGISTER
IF
.if, .IF, IFN, IFNZ, COND, IFTRUE, IFNFALSE, .$IF, .$if
INCLUDE
.include, .copy
LIST
.list <on> or <off>, .LIST
MACCNTR
<none>
MACEXIT
<none>
MACLIST
<none>
MACNOTE
.mmsg
MACRO
.macro, .MACRO
MLIST
<none>
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
327
Table 23. eZ80Acclaim! Directive Compatibility (Continued)
eZ80Acclaim!
Assembler
Compatible With
MNOLIST
<none>
NEWBLOCK
.NEWBLOCK
NEWPAGE
.page [<len>] [<width>], PAGE
NIF
IFZ, IFE, IFFALSE, IFNTRUE
NOLIST
.NOLIST
NOSAME
IFDIFF, IFNSAME
ORG
.org, ORIGIN
PAGELENGTH
PL
PAGEWIDTH
PW
PE
V
P0
NV
POPSEG
<none>
PRINT
<none>
PT
<none>
PUSHSEG
<none>
REPEAT
.$REPEAT, .$repeat
SAME
IFNDIFF, IFSAME
SBLOCK
.SBLOCK
SCOPE
<none>
SEGMENT
.section, SECTION
STRUCT
.STRUCT
TAG
.TAG
TEXT
.text
TITLE
.title
UNTIL
.$UNTIL, .until
VAR
.VAR, SET, .SET
VECTOR
<none>
WARNING
.wmsg, MESSAGE
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
328
Table 23. eZ80Acclaim! Directive Compatibility (Continued)
eZ80Acclaim!
Assembler
Compatible With
WEND
.$WEND, .$wend
WHILE
.$WHILE, .$while
XDEF
.global, GLOBAL, .GLOBAL, .public, .def, public
XREF
EXTERN, EXTERNAL, .extern, .ref
ZIGNORE
<none>
ZSECT
.sect
ZUSECT
.USECT
TROUBLESHOOTING THE ASSEMBLER
There are several instructions that you must be careful about when you use them. For
example, you can run into problems with instructions that have implicit registers (such as
DJNZ, LDI, LDIR, LDD, LDDR, and CPI CPIR).
Arithmetic instructions on register pairs (like DEC BC) do not set the condition codes;
however, single-register instructions (like DEC B or DEC C) do set the condition codes.
Be careful with handling register pairs in ADL mode since the highest-order byte is not
directly accessible.
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.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
329
404 Illegal EQU.
The name used to define an equate has been previously defined or equates and label
symbols in an equate expression have not been previously defined.
405 Label not defined.
The label has not been defined, either by an XREF or a label definition.
406 Illegal use of XREF's symbol.
XDEF defines a list of labels in the current module as an external symbol that are to be
made publicly visible to other modules at link time; XREF specifies that a list of
labels in the operand field are defined in another module.
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 for the .elif directive.
410 Illegal .else directive.
There is no matching .if for the .else directive.
411 Illegal .endif directive.
There is no matching .if for the .endif directive.
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.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
330
417 Unterminated quoted string.
You must terminate a string with a double quote.
418 Illegal symbol name.
There are illegal characters in a symbol name.
419 Unrecognized token.
The assembler has encountered illegal/unknown character(s).
420 Constant expression overflow.
A constant expression exceeded the range of –2147483648 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.
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.
431 Recursive macro call.
Macro calls cannot be recursive.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
331
432 Recursive include file.
Include directives cannot be recursive.
433 ORG to bad address.
The ORG clause specifies an invalid address for the segment.
434 Symbol name too long.
The maximum symbol length (33 characters) has been exceeded.
435 Operand out-of-range error.
The assembler detects an expression operand that is out of range for the intended field
and generates appropriate error messages.
436 Relative branch to XREF label.
Do not use the JP instruction with XREF.
437 Invalid array index.
A negative number or zero has been used for an array instance index. You must use
positive numbers.
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 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, or RESET
442 Missing delay slot instruction.
Add a delay slot instruction such as BRANCH or LD.
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 .$wend directive.
447 Missing .$repeat at EOF.
There is no matching .$repeat for the .$while directive.
448 Segment stack overflow.
Do not allocate returned structures on the stack.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
332
450 Floating point precision error.
The floating-point value cannot be represented to the precision given. The value 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.
476 User warning.
General-purpose warning.
480 Relist map file error.
A map file will not be generated.
481 Relist file not found error.
The map file cannot be found in the specified path, or, if no path is specified, the map
file cannot be located in the current directory.
482 Relist symbol not found.
Any symbol used in a conditional directive must be previously defined by an EQU or
VAR directive.
483 Relist aborted.
A map file will not be generated.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
333
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.
UM014418-0205
5 Using the Macro Assembler
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
334
6
Using the Linker/Locator
The eZ80Acclaim! developer’s environment linker/locator creates a single executable file
from a set of object modules and object libraries. It acts as a linker by linking together
object modules and resolving external references to public symbols. It also acts as a locator because it allows you to specify where code and data is stored in the target processor at
run time.
This chapter describes the following:
•
•
•
•
•
•
“Linker Interactions with the Compiler and Assembler” on page 335
“Linker Configurations” on page 339
“Linker Commands” on page 341
“Linker Expressions” on page 358
“Troubleshooting the Linker” on page 365
“Warning and Error Messages” on page 369
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 “Command Processor Quick Tour” on page 31.
The following six major types of objects are manipulated during the linking process:
•
Modules
Modules are created by assembling a file with the assembler or compiling a file with
the compiler.
•
Libraries
Object libraries are collections of object modules created by the Librarian. Segments,
address spaces, groups, and copy segments are defined in the following sections.
•
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 292 for more information about using predefined segments, defining new
segments, and attaching code and data to segments.
The memory range for the default segments depend on the particular eZ80Acclaim!
family member. The segments are described in “Address Spaces Category” on
page 127. For example, for the EZ80190, the default segments are ROM (memory
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
335
range 0–4FFFFF), RAM (memory range 500000–FFFFFF), EXTIO (memory range
0–FFFF), and INTIO (memory range 0–FF). The ROM and RAM make up the
MEMORY GROUP (see “HEADING” on page 347).
•
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 would have two physical blocks—each with its own set
of addresses. If there were read-only parts of each physical block, there might be
CODE and ROM to name the program store and DROM and DATA to name the data
store. Logical address spaces are often used to divide a large contiguous block of
memory in order to separate data and code on a RAM-based system. In this case, the
address spaces partition the physical memory into two logical address spaces. For
more information about address spaces, see “Address Spaces” on page 291.
•
Groups
Groups are collections of logical address spaces. They are typically used to
conveniently handle a set of address spaces.
•
Copy segments
Copy segments are segments of initialized data that are re-assigned to another address
space (the copy segment) by the linker. A startup routine typically moves data from
the copy segment into the original address space to initialize data before invoking a
program.
Note: 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. For more information, see
“BASE OF Versus LOWADDR OF” on page 360.
LINKER INTERACTIONS WITH THE COMPILER AND ASSEMBLER
The ZiLOG linker enables developers to control how source code is loaded into a target
processor. This section provides an overview of what the linker does and how it interacts
with the ZDS II compiler and assembler and with target hardware. For details of linker
command syntax, see “Linker Commands” on page 341.
The ZDS II compiler and assembler use a hierarchical processor model containing spaces
and segments. Each space has a range associated with it that identifies valid addresses for
that space. For example, Space A might be associated with the addresses from 100h to
7FFFh.
Each object file, called a module, contains several segments. See Figure 102 and
Figure 103. The linker performs two main functions:
• It resolves all external references in each module.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
336
• It assigns (or locates) physical hardware memory addresses into which each segment will
be loaded.
Figure 102. Linker Segments
Figure 103. Modules and Segments
Because the linker both links names and locates modules, it is referred to as a linker/locator. The locator part of the Linker assigns segments to spaces. In Figure 103, three modules are shown (one.obj, two.obj, and three.obj), each module containing a
combination of U, V, W, X, Y, and Z segments.
The linker has no information about the source of the object (*.obj) modules but processes a sequence of modules (in alphabetical order, by default), resolving references
between the modules and then loading the segments into the appropriate address spaces.
The resolution and loading occurs after the linker has read in the linker command file.
This file, containing commands that control linker actions such as the assignment of segments to spaces, is automatically generated by ZDS II when a project is built for the first
time. You can then edit the linker command file to change linker behavior if needed. The
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
337
linker command file gives a description of how to link the modules, providing a non-procedural description of the linking process.
Address Spaces
Every byte generated by the compiler gets assigned to an address space by the linker.
Address spaces represent physical or logical architecture divisions. Each space has physical or logical attributes that characterize it. A space might, for example, use special
addressing modes or have alignment restrictions.
Spaces can also indicate separate physical memories. Within each space, segments can be
defined that can affect instruction speed or availability.
The ZDS II compiler and assembler predefine four address spaces:
•
•
•
•
ROM (read-only space)
RAM (random-access/writable space)
EXTIO (16-bit addressable space for I/O)
INTIO (8-bit addressable space for I/O)
These spaces contain the logical components of an application. The linker command file
specifies how these logical spaces are mapped to the physical addresses on the target
board. For more information about address spaces, see “Address Spaces” on page 337.
Segments
The ZDS II compiler and assembler define the following six segments:
•
•
__VECTORS (segment type is CODE; address space is ROM)
CODE (segment type is CODE; address space is ROM)
This is the default segment for assembler code.
•
•
•
•
BSS (segment type is Segment type: Uninitialized Data; address space is RAM)
DATA (segment type is Initialized Data; address space is RAM)
STRSECT (segment type is String Initialization; address space is RAM by default)
TEXT (segment type is Constant Data; address space is RAM by default)
The default relationships of these segments to the four address spaces are shown in
Figure 104.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
338
Figure 104. Segment and Space Relationships
Note: The standard vector reset/initialization files (vectors16.asm or vectors32.asm)
define their own segment for the vectors instead of using __VECTORS.
The address spaces listed in “Address Spaces” on page 337 are those used for the run-time
addresses of the segments. Some segments can be copied from one space to another,
depending on the memory configuration (described in “Linker Configurations” on
page 339). For example, in a typical configuration, the DATA segment is placed in ROM
at load time and then copied to RAM on application reset; it is the copy in RAM that is
actually used when the program runs, but the ROM version is necessary so that the program can be re-initialized at reset.
The address spaces listed in “Address Spaces” on page 337 define the logical spaces to
which the segments are assigned. The relationship between the logical RAM/ROM spaces
and physical RAM or ROM memory depends on your system configuration and might be
more complicated. For more information, see “Link Configuration” on page 117.
You have complete control over the order in which these segments are loaded into the
RAM address space. For information about changing the link order, see “How do I control
the link order?” on page 365?.
You can define additional CODE segments in C by marking the One Code Segment Per
Module check box on the C tab (Code Generation category) of the Project Settings dialog
box (see “Code Generation Category” on page 97). For the myfile.c module, the code
segment is given the name myfile_TEXT (“text” refers to code, unlike the TEXT segment that contains constant data). All of the procedures in the myfile_TEXT module are
assigned to that same segment, and the segment is assigned to ROM space. All of the
uninitialized data, initialized data, and string initialization remain assigned to BSS, DATA,
and STRSECT, respectively.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
339
In addition to these segments, the linker must also determine the location of the following
components:
•
•
•
•
the C stack
the C heap for malloc/free
the code that sets up the run-time environment
the vector table
“Components for All Linker Configurations” on page 340 describes how to set these locations.
LINKER CONFIGURATIONS
The Select Link Configuration dialog box (see “Link Configuration” on page 117) allows
you to set up linker parameters related to the memory map. You can also select the linker
configuration when you create a new project.
In the Select Link Configuration dialog box, you can select one of the four configurations
shown in Figure 105. These diagrams schematically represent the most common physical
memory configurations. For example, some boards only have physical RAM on them (All
RAM), while some have both ROM and RAM (Standard). (The EXTIO and INTIO spaces
are not shown in these diagrams. Those spaces are logically distinct from the ROM and
RAM spaces and are accessed only by special instructions used for that purpose.)
Figure 105. Linker Configurations
Figure 105 does not show the addresses for the beginning and end of physical ROM and
RAM. You can enter the address information on the Linker tab (see “Address Spaces Category” on page 127). The linker configuration and Linker tab information represent the
hardware memory map.
ZDS II uses the linker configuration and the information from the Address Spaces category of the Linker tab to generate a linker command file. The linker command file
describes how segments are allocated to spaces and how the address spaces are mapped to
real hardware. If the project file is named myproj.zdsproj, the linker command file is
named myproj.linkcmd and is placed in the same directory as the project file (although
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
340
it is ordinarily created as a “hidden” file). Windows uses a “shortcut” icon to represent this
file.
As an example of what the linker command file does, suppose your hardware only has
RAM (the All RAM configuration). The linker therefore must map logical ROM space to
some part of physical RAM. In a 64K RAM configuration, you might specify a RAM
space of 0000h–FFFFh. The linker command file contains commands generated by
ZDS II that group the ROM and RAM spaces together.
In most embedded applications, the logical ROM space resides in physical (hardware)
ROM, and the logical RAM space resides in physical RAM. For this (Standard) configuration, the ROM and RAM memory spaces map directly to the corresponding ROM and
RAM hardware addresses. For example, in an architecture with a 24-bit addressing range,
you might have RAM at C00000h–FFFFFFh and ROM at 0h–00FFFFh.
In the Copy to RAM configuration, the hardware has both ROM and RAM. However, performance or operational considerations require that the code and data in physical ROM be
copied to a physical RAM address upon startup (to accommodate, for example, initialized
data that needs to be re-initialized when the board is reset). The Copy to RAM configuration causes the startup code to copy some part of the ROM to a location in RAM.
Components for All Linker Configurations
In a standalone application, components usually managed by an operating system must be
set up and managed as part of the C runtime. In particular, an embedded C application
need the following components:
•
•
•
•
Stack
Heap
Other segments
Startup
The location of the stack and heap depend on the size of the application and the amount of
physical RAM available. Generally, the heap starts at the first address past the end of the
program and grows towards higher-numbered addresses. The stack generally starts at the
highest possible address in physical RAM and grows towards lower numbered addresses.
The linker provides expressions that simplify placing the stack and heap at appropriate
addresses. For example, the linker TOP OF CODE command represents the address of the
last byte allocated in the Code segment. The following expression can be used to set the
lowest address of the heap:
define __heaptop = top of CODE + 1
Similarly, the linker HIGHADDR OF RAM command represents the highest numbered physical address in the RAM space. Setting the starting address for the stack can be done with
the following:
define __stack = HIGHADDR of RAM
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
341
Both of these linker commands define locations that are used by the startup module to initialize the C runtime for an application. In configurations where code or data is copied, the
linker commands for setting up the stack and heap may be more complicated. When a configuration has been selected, ZDS II automatically generates the appropriate DEFINEs
and linker expressions. In addition to the stack and heap, the startup routines handle all of
the copying for special segments and setting up the initial vector table.
LINKER COMMANDS
The linker is automatically invoked when you click the Build button or Rebuild All button
on the Build toolbar for your project. The linker executes commands and directives found
in a linker command file. A linker command file is generated automatically by the
eZ80Acclaim! developer’s environment if you select the Create New button in the Project
Settings dialog box (see page 125). Selecting the Create New button also allows you to
modify how the linker links/loads your application by changing the options and commands in a scripting file.
Caution: If you select the Included in Project button or the Custom button and use the startup
source or object provided with the tools (init_params_f91.asm, which includes
sysclk.asm or corresponding .obj files), building the project results in linker errors
and warnings. Follow these steps to add the correct linker directives to initialize variables
in your project:
1. Open your project.
2. From the Project menu, select Settings.
3. In the Input category of the Linker tab, select the Standard button and click OK.
4. Click Yes to the warning message: "The project settings have changed
since the last build. Would you like to rebuild the affected
files?"
The linker command file is generated even if the build is not successful.
5. Open the generated linker command file (project_name.linkcmd) and copy
everything from ORDER .RESET,.IVECTS,.STARTUP,CODE,DATA to the fifth
blank line or before this line:
"C:\Program Files\ZiLOG\ZDSII_eZ80Acclaim!_x.x.x\samples\StarterProject\starter"= \
6. Paste the directives into the Additional Linker Directives dialog box (page 122).
7. Click OK to return to the Project Settings dialog box.
8. Click OK to save your settings.
9. Click Yes to the warning message: "The project settings have changed
since the last build. Would you like to rebuild the affected
files?"
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
342
10. Reset your project settings and rebuild your project.
This section describes the commands of a linker command file:
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
“<outputfile>=<module list>” on page 343
“CHANGE” on page 343
“COLOR” on page 344
“COPY” on page 344
“DEBUG” on page 345
“DEFINE” on page 346
“FORMAT” on page 346
“GROUP” on page 346
“HEADING” on page 347
“LOCATE” on page 347
“MAP” on page 347
“MAXHEXLEN” on page 353
“MAXLENGTH” on page 353
“NOCOLOR” on page 353
“NODEBUG” on page 354
“NOMAP” on page 354
“NOWARN” on page 354
“ORDER” on page 354
“SPLITTABLE” on page 356
“SEARCHPATH” on page 355
“SORT” on page 356
“SPLITTABLE” on page 356
“UNRESOLVED IS FATAL” on page 357
“WARN” on page 357
“WARNING IS FATAL” on page 358
“WARNOVERLAP” on page 358
Notes: Only the <outputfile>=<module list> and the FORMAT commands are required. All
commands and operators are not case sensitive.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
343
<outputfile>=<module list>
This command defines the executable file, object modules, and libraries involved in the
linking process. The default extension is .lod as specified by the FORMAT option (see
page 346).
<module list> is a list of object module or library path names to be linked together to create the output file.
Example
c:\ZDSII_eZ80Acclaim!_4.4.0\sample=c:\ZDSII_eZ80Acclaim!_4.4.0\rtl\start.obj,adjust.obj, \
c:\ZDSII_eZ80Acclaim!_4.4.0\rtl\helpers.lib
Note: In the preceding example, the \ (backslash) at the end of the first line allows the <module
list> to extend over several lines.
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 segment to another address space.
Syntax
CHANGE <name> = <newname>
<name> can be a group, address space, or segment.
<newname> is the new name to be used in renaming a group, address space, or segment;
the name of the group where an address space is to be moved; or the name of the address
space where a segment is to be moved.
Examples
Note: See also the examples for the COPY command (page 344).
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, codeseg) to a different address space (for example,
RAM), use the following command:
CHANGE codeseg=RAM
To not allocate a segment (for example, dataseg), use the following command:
CHANGE dataseg=NULL
Note: The linker recognizes the special space NULL. NULL is not one of the spaces that an object
file or library contains in it. If a segment is copied to NULL as a command to the linker, the
segment is deleted from the linking process. This can be useful if you need to link only part
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
344
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.
COLOR
The COLOR command causes the linker to calculate memory overlays for segments
through graph coloring. The default setting is -COLOR. -NOCOLOR suppresses graph
coloring.
You can use the COLOR command to organize your overlays by building a tree representing
the sequence of overlays (for example, segment A is replaced by overlays C and D) and
then using a compiler technique called graph coloring to determine how to group the segments.
Syntax
[-]COLOR
COPY
The COPY command is used to make a copy of a segment into a specified address space.
This is most often used to make a copy of initialized RAM in ROM so that it can be initialized at run time.
Syntax
COPY <segment> <name>[at<expression>]
<segment> can only be a segment.
<name> can only be an address space.
Examples
To make a copy of a code segment in ROM, use the following procedure:
1. In the assembly code, define a code segment (for example, codeseg) to be a segment
located in RAM. This is the run-time location of codeseg.
2. Use the following linker command:
COPY codeseg ROM
The linker places the actual contents associated with codeseg in ROM (the load time
location) and associates RAM (the run-time location) addressed with labels in
codeseg.
Note: You need to copy the codeseg contents from ROM to RAM at run time as part of the
startup routine. You can use the COPY BASE OF and COPY TOP OF linker expressions to
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 codeseg.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
345
To copy segments to RAM, use the following procedure:
1. In the assembly code, define the segments (for example, strseg, text, and
codeseg) to be segments located in RAM. This is the run-time location of the
segments.
2. Use the following linker commands:
CHANGE strseg=codeseg
CHANGE text=codeseg
COPY codeseg RAM
The linker renames strseg and text as codeseg and performs linking as described
in the previous example. You need to write only one loop to perform the copy from
ROM to RAM at run time, instead of three (one loop each for strseg, text, and
codeseg).
To allocate a string segment in ROM but not generate the initialization:
1. In the assembly code, define the string segment (for example, strsect) to be a
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.
Notes: The linker recognizes the special space NULL. NULL is not one of the spaces that an object
file or library contains in it. If a segment is copied to NULL as a 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.
Refer to “Linker Expressions” on page 358 for the format to write an expression.
DEBUG
The DEBUG command causes the linker to generate debug information for the debugger.
This option is applicable only if the executable file is IEEE 695.
Syntax
-DEBUG
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
346
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> = <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 358 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
SREC
.srec
IEEE 695 format
OMF695
.lod
Intel 16-bit Hex
INTEL
.hex
INTEL32
.hex
Motorola S-records
Intel 32-bit
The default setting is IEEE 695.
Syntax
[-]FORMAT=<type>
Example
FORMAT = SREC
GROUP
The GROUP command provides a method of collecting multiple address spaces into a
single manageable entity.
Syntax
GROUP <groupname> = <name>[,<name>]
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
347
<groupname> can only be a group.
<name> can only be an address space.
HEADING
The HEADING command enables or disables the form feed (\f) 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 <name> AT <expression>
<name> 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 358 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.
In the link map file, the C prefix indicates Code, and the D prefix indicates Data.
Syntax
-MAP = [<mapfile>]
mapfile has the same name as the executable file with the .map extension unless an
optional <mapfile> is specified.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
348
Example
MAP = myfile.map
Link Map File
A sample map file is shown in this section. The map file is partitioned into labeled sections. Comments have been added to briefly describe each labeled section.
Zilog Linkage Editor.
LINK MAP:
Date:
Version 1.00
16-Feb-96
11:57:30
Page:
1
;summarizes the link, specifies the link
;date, the target microcontroller, and the names
;and types of the linked files.
Fri Feb 16 11:57:30 1996
Processor: Z89C00
Files:
[Object ] c00.o
COMMAND LIST:
;lists the command and options that are in effect.
;Options from the linker command line, as well as
;commands and options read from linker command files
;appear in this section of the link map.
-oc00 -mc00 c00.o
_Zilog Linkage Editor.
Version 1.00
SPACE ALLOCATION:
Space
-------------------------------ROM
RAM0
RAM1
CONTROL SECTIONS WITHIN SPACE:
ROM
-------------------------------$Vector
abscs
atext
UM014418-0205
16-Feb-96
11:57:30
Page:
2
;specifies the address space allocation.
Base
-------00000000
00000000
00000100
Top
Span
-------- -------00000FFF
1000h
00000011
12h
00000119
1Ah
;enumerates the control sections allocated
;within each address space.
Type
----------absolute
absolute
relocatable
Base
-------00000FFC
00000800
00000000
Top
-------00000FFF
0000082C
0000005B
Span
---4h
2Dh
5Ch
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
349
code
text
relocatable 0000005C 0000073F
relocatable 00000740 000007A7
6E4h
68h
RAM0
-------------------------------absb0
b0ram
bank0_bss
Type
----------absolute
relocatable
relocatable
Base
-------00000082
00000000
00000001
Top
-------00000081
00000000
00000011
Span
---0h
1h
11h
RAM1
-------------------------------absb1
b1ram
Type
----------absolute
relocatable
Base
-------00000181
00000100
Top
-------00000180
00000119
Span
---0h
1Ah
_Zilog Linkage Editor.
Version 1.00
CONTROL SECTIONS WITHIN MODULES:
16-Feb-96
11:57:30
Page: 3
;enumerates the control sections from each
;input object module.
Module: c00.s (File: c00.o) Fri Feb 16 11:57:15 1996
Control
Control
Control
Control
Control
Control
Control
Control
Control
Control
Name
Base
Top
-------------------------------- -------- ------section: $Vector
00000FFC
section: abscs
00000800
section: atext
00000000
section: code
0000005C
section: text
00000740
section: absb0
00000082
section: b0ram
00000000
section: bank0_bss
00000001
section: absb1
00000181
section: b1ram
00000100
_Zilog Linkage Editor.
Version 1.00
EXTERNAL DEFINITIONS BY ADDRESS:
16-Feb-96
Size
----00000FFF
0000082C
0000005B
0000073F
000007A7
00000082
00000000
00000011
00000181
00000119
11:57:30
Page:
4
45
92
1764
104
0
1
17
0
26
4
;lists the global symbols,
;sorted by address.
Symbol
Address Module
Control Section
-------------------------------- -------- ----------- --------------.textlab
00000001 c00.s
atext
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
350
begin
codelab
firloop
p0label
abslabel
addlabel
andlabel
calllabel
cplabel
declabel
inclabel
jplabel
ldlabel
mldlabel
mpyalabel
mpyslabel
neglabel
orlabel
poplabel
pushlabel
rllabel
rrlabel
slllabel
sralabel
sublabel
label1
label2
textlab
here
abslab
bs0lab1
bs0label
ab0lab0
bs1lab1
bs1lab0
bs1label
ab1lab0
00000069
0000006A
0000006A
0000006F
00000070
00000083
000000E1
00000117
000001C4
000001FA
0000020D
00000220
000002D2
000004C4
000004ED
00000515
0000053D
00000551
0000057B
000005EE
00000687
0000069A
000006AF
000006C3
000006D6
0000072E
00000738
0000075C
0000075E
00001009
00000000
00000011
00000103
00000100
00000109
00000119
00000301
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
text
text
abscs
b0ram
bank0_bss
absb0
b1ram
b1ram
b1ram
absb1
38 External symbols.
_Zilog Linkage Editor.
Version 1.00
16-Feb-96
EXTERNAL DEFINITIONS BY NAME:
Symbol
UM014418-0205
Address
11:57:30
Page:
5
;lists the global symbols,
;sorted by symbol name.
Module
Control Section
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
351
-------------------------------.textlab
ab0lab0
ab1lab0
abslab
abslabel
addlabel
andlabel
begin
bs0lab1
bs0label
bs1lab0
bs1lab1
bs1label
calllabel
codelab
cplabel
declabel
firloop
here
inclabel
jplabel
label1
label2
ldlabel
mldlabel
mpyalabel
mpyslabel
neglabel
orlabel
p0label
poplabel
pushlabel
rllabel
rrlabel
slllabel
sralabel
sublabel
textlab
------00000001
00000103
00000301
00001009
00000070
00000083
000000E1
00000069
00000000
00000011
00000109
00000100
00000119
00000117
0000006A
000001C4
000001FA
0000006A
0000075E
0000020D
00000220
0000072E
00000738
000002D2
000004C4
000004ED
00000515
0000053D
00000551
0000006F
0000057B
000005EE
00000687
0000069A
000006AF
000006C3
000006D6
0000075C
------c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
--------------atext
absb0
absb1
abscs
code
code
code
code
b0ram
bank0_bss
b1ram
b1ram
b1ram
code
code
code
code
code
text
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
code
text
38 External symbols.
_Zilog Linkage Editor.
SYMBOL CROSS REFERENCE:
UM014418-0205
Version 1.00
16-Feb-96
11:57:30
Page:
6
;lists a cross reference concordance of
;global symbols.
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
352
Symbol
-------------------------------.textlab
ab0lab0
ab1lab0
abslab
abslabel
addlabel
andlabel
begin
bs0lab1
bs0label
bs1lab0
bs1lab1
bs1label
calllabel
codelab
cplabel
declabel
firloop
here
inclabel
jplabel
label1
label2
ldlabel
mldlabel
mpyalabel
mpyslabel
neglabel
orlabel
p0label
poplabel
pushlabel
rllabel
rrlabel
slllabel
sralabel
sublabel
textlab
ENTRY POINT:
Module
----------c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
c00.s
Use
---------Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
Definition
;specifies the program entry point.
0069 Set from module 'c00.s'.
END OF LINK MAP:
UM014418-0205
;summarizes the status of the link. The
;number of error and warning messages are
;recorded in this section.
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
353
0 Warnings
0 Errors
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 < IS | = >
< 16 | 32 | 64 | 128 | 255 >
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 <name> <expression>
<name> can be a group, address space, or segment.
<expression> is the maximum size.
Example
MAXLENGTH CODE $FF
Note: Refer to “Linker Expressions” on page 358 for the format to write an expression.
NOCOLOR
The NOCOLOR command suppresses graph coloring for memory overlays. The default
setting is COLOR.
Syntax
[-]NOCOLOR
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
354
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 <name>[,<name-list>]
<name> can be a group, address space, or segment. <name-list> is a comma-separated list
of other groups, address spaces, or segments. However, a RANGE is established only for an
address space.
Example
ORDER DATA,TEXT
In this example, all address spaces associated with DATA are located before (that is, at
lower addresses than) address spaces associated with TEXT.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
355
RANGE
The RANGE command sets the lower and upper bounds of a group, address space, or segment. If an address falls outside of the specified RANGE, the system displays a message.
Note: You must use white space to separate the colon from the RANGE command operands.
Syntax
RANGE <name><expression> : <expression>[,<expression> : <expression>...]
<name> can be a group, address space, or segment. The first <expression> marks the
lower boundary for a specified address RANGE. The second <expression> marks the upper
boundary for a specified address RANGE.
Example
RANGE CODE $100 : $1FF,$300 : $3FF
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 358 for the format to write an expression.
SEARCHPATH
The SEARCHPATH command establishes an additional search path to be specified in locating files. The search order is as follows.
1. Current directory
2. Environment path
3. Search path
Syntax
SEARCHPATH ="<path>"
Example
SEARCHPATH="C:\ZDSII_eZ80Acclaim!_4.4.0\rtl"
Notes: The environment path is set by the DOS command: SET eZ80Acclaim=<path>.
This command is placed in the AUTOEXEC.BAT file when you install
eZ80Acclaim! developer’s environment.
SEQUENCE
The SEQUENCE command forces the linker to allocate a group, address space, or segment
in the order specified.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
356
Syntax
SEQUENCE <name>(,<name>)@
<name> is either a group, address space, or segment.
Example
SEQUENCE code,xdata
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 is 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.
ADDRESS indicates sorting by symbol address.
Examples
The following examples show how to sort the symbol listing by the address in ascending
order:
SORT ADDRESS ASCENDING
or
-SORT ADDRESS = UP
SPLITTABLE
The SPLITTABLE command allows (but does not force) the linker to split a segment into
noncontiguous pieces to fit into available memory slots. Splitting segments can be helpful
in reducing the overall memory requirements of the project. However, problems can arise
if a noncontiguous segment is copied from one space to another using the COPY command.
The linker issues a warning if it is asked to COPY any noncontiguous segment.
If SPLITTABLE is not specified for a given segment, the linker allocates the entire segment contiguously.
The SPLITTABLE command takes precedence over the ORDER and SEQUENCE commands.
By default, ZDS II segments are nonsplittable, which, as noted in the ZDS II readme.txt
file, can cause the hex file size to grow considerably when there are discontinuities in the
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
357
memory map. As an example, the default SSL project has a 220 KB code segment but
because of the project's ordering of segments, this segment needs to be moved above a discontinuity in the memory map, leaving a 150 KB gap in internal Flash.
When the code segment is made splittable, the size of this gap can be made dramatically
smaller. However, if there are multiple discontinuities in the memory map (for example, in
ZTP SSL project for F92), it might be necessary to make multiple segments splittable to
minimize the gaps between segments. When this is done, 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 of the system so there is only one discontinuity and only one
splittable segment in which case the ORDER command is followed
•
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 DATA, TEXT
UNRESOLVED IS FATAL
The UNRESOLVED IS FATAL command causes the linker to treat “undefined external
symbol” warnings as fatal errors. The linker quits generating output files immediately if
the linker cannot resolve any undefined symbol. By default, the linker proceeds with generating output files if there are any undefined symbols.
Syntax
[-] < UNRESOLVED > < IS | = > <FATAL>
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 warning messages on the screen and in the map file.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
358
Syntax
[-]WARN = [<warn filename>]
Example
-WARN=warnfile.txt
WARNING IS FATAL
The WARNING IS FATAL command causes the linker to treat all warning messages as
fatal errors. The linker does not generate output file(s) if there are any warnings while
linking. By default, the linker proceeds with generating output files even if there are warnings.
Syntax
[-]< WARNING | WARN> < IS | = > <FATAL>
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 overlapped.
Syntax
-[NO]warnoverlap
LINKER EXPRESSIONS
This section describes the operators and operands that form legal linker expressions:
•
•
•
•
•
•
•
UM014418-0205
“+ (Add)” on page 359
“& (And)” on page 360
“BASE OF” on page 360
“COPY BASE” on page 361
“COPY TOP” on page 361
“/ (Divide)” on page 361
“FREEMEM” on page 361
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
359
•
•
•
•
•
•
•
•
•
•
•
•
•
“HIGHADDR” on page 362
“LENGTH” on page 362
“LOWADDR” on page 362
“* (Multiply)” on page 363
“Decimal Numeric Values” on page 363
“Hexadecimal Numeric Values” on page 363
“| (Or)” on page 364
“<< (Shift Left)” on page 364
“>> (Shift Right)” on page 364
“- (Subtract)” on page 364
“TOP OF” on page 364
“^ (Bitwise Exclusive Or)” on page 365
“~ (Not)” on page 365
The following note applies to many of the <expression> commands discussed in this section:
Note: To use BASE, TOP, COPY BASE, COPY TOP, LOWADDR, HIGHADDR, LENGTH, and
FREEMEM <expression> 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
/* A correct use of segments */
SEQUENCE seg2, seg1
/* Calculate seg2 before seg1 */
LOCATE seg1 AT TOP OF seg2 + 1
/* An incorrect use of segments */
/* cannot use expression of seg1 to locate seg1! */
LOCATE seg1 AT (TOP OF seg2 - LENGTH OF seg1)
+ (Add)
The + (Add) operator is used to perform addition of two expressions.
Syntax
<expression> + <expression>
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
360
& (And)
The & (And) operator is used to perform a bitwise & of two expressions.
Syntax
<expression> & <expression>
BASE OF
The BASE OF operator provides the lowest used address of a group, address space, or segment, excluding any segment copies when <name> is a segment. The value of BASE OF
is treated as an expression value.
Syntax
BASE OF <name>
<name> 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 <name> gives the lowest allocated
address in the space; LOWADDR OF <name> gives the lowest physical address in the
space.
For example:
RANGE
RANGE
RANGE
RANGE
RANGE
RANGE
/* RAM
LOCATE
LOCATE
LOCATE
DEFINE
DEFINE
EXTIO $0 : $FFFF
INTIO $0 : $FF
ROM $0 : $1FFFF
RAM $5000 : $1FFFF
s_checksum $0 : $FFFF
s_nvrblock $5000 : $1FFFF
allocation */
s_uninit_data at $5000
BSS at (TOP OF s_uninit_data)+1
s_nvrblock at $FE00
__low_data = BASE OF s_uninit_data
__copy_code_to_ram = 0
Using
LOCATE s_uninit_data at $5000
or
LOCATE s_uninit_data at LOWADDR OF RAM
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
361
gives the same address (the lowest possible address) when RANGE RAM $5000:$1FFFF.
If
LOCATE s_uninit_data at $5000
is changed to
LOCATE s_uninit_data at BASE OF RAM
the lowest used address is $FE00 (because LOCATE s_nvrblock at $FE00 and
s_nvrblock is in RAM).
COPY BASE
The COPY BASE operator provides the lowest used address of a copy segment, group, or
address space. The value of COPY BASE is treated as an expression value.
Syntax
COPY BASE OF <name>
<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 <name>
<name> 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 <name>
<name> can be a group, address space, or segment.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
362
HIGHADDR
The HIGHADDR operator provides the highest possible address of a group, address
space, or segment. The value of HIGHADDR is treated as an expression value.
Syntax
HIGHADDR OF <name>
<name> 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 <name>
<name> 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 <name>
<name> 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 <name> gives the lowest allocated
address in the space; LOWADDR OF <name> gives the lowest physical address in the
space.
For example:
RANGE
RANGE
RANGE
RANGE
RANGE
RANGE
UM014418-0205
EXTIO $0 : $FFFF
INTIO $0 : $FF
ROM $0 : $1FFFF
RAM $5000 : $1FFFF
s_checksum $0 : $FFFF
s_nvrblock $5000 : $1FFFF
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
363
/* RAM
LOCATE
LOCATE
LOCATE
DEFINE
DEFINE
allocation */
s_uninit_data at $5000
BSS at (TOP OF s_uninit_data)+1
s_nvrblock at $FE00
__low_data = BASE OF s_uninit_data
__copy_code_to_ram = 0
Using
LOCATE s_uninit_data at $5000
or
LOCATE s_uninit_data at LOWADDR OF RAM
gives the same address (the lowest possible address) when RANGE RAM $5000:$1FFFF.
If
LOCATE s_uninit_data at $5000
is changed to
LOCATE s_uninit_data at BASE OF RAM
the lowest used address is $FE00 (because LOCATE s_nvrblock at $FE00 and
s_nvrblock is in RAM).
* (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>
Hexadecimal Numeric Values
Hexadecimal numeric constant values can be used as an expression or part of an expression. Hex digits are collections of numeric digits from 0 to 9 or A to F.
Syntax
<hexdigits>
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
364
| (Or)
The | (Or) operator is used to perform a bitwise inclusive | (Or) of two expressions.
Syntax
<expression> | <expression>
<< (Shift Left)
The << (Shift Left) operator is used to perform a left shift. The first expression to the left
of << is the value to be shifted. The second expression is the number of bits to the left the
value is to be shifted.
Syntax
<expression> << <expression>
>> (Shift Right)
The >> (Shift Right) operator is used to perform a right shift. The first expression to the
left of >> is the value to be shifted. The second expression is the number of bits to the right
the value is to be shifted.
Syntax
<expression> >> <expression>
- (Subtract)
The - (Subtract) operator is used to subtract one expression from another.
Syntax
<expression> - <expression>
TOP OF
The TOP OF operator provides the highest allocated address of a group, address space, or
segment, excluding any segment copies when <name> is a segment. The value of TOP OF
is treated as an expression value.
Syntax
TOP OF <name>
<name> 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,
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
365
LOCATE segment2 at TOP OF segment1
starts segment2 at the address of the last used location of segment1. To avoid both segments sharing one memory location, use the following syntax:
LOCATE segment2 at (TOP OF segment1) + 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>
TROUBLESHOOTING THE LINKER
Review these questions to learn more about common situations you might encounter when
using the linker:
•
•
•
•
•
•
•
“How do I control the link order?” on page 365
“How do I speed up the linker?”
“How do I generate debug information without generating code?”
“How can I debug code already burned in ROM?”
“How much memory is my program using?”
“How do I create a hex file?” on page 369
“How do I determine the size of my actual hex code?” on page 369
How do I control the link order?
The Linker processes the files in a project in alphabetical order, but you can control the
order and location of each segment in a compiled/assembled module. To provide a finer
level of control, you need to do the following:
1. Put each piece of code you want to control in a separate segment.
a. From the Project menu, select Settings.
b. On the C (Compiler) tab of the Project Settings dialog box, select the Code
Generation category.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
366
c. Select the One Code Segment per Module check box.
For each file, you get one segment. All of the procedures in the file belong to the
same segment. The compiler names the segment <filename>_TEXT; for example,
the file myproc.c generates the myproc_TEXT segment. The compiler does not
change the segments associated with variables.
d. In assembly, add the following lines to define a new segment:
DEFINE <segment_name>,space=<space_name>
SEGMENT <segment_name>
For example,
DEFINE MY_NEW_SEG,SPACE=ROM
SEGMENT MY_NEW_SEG
defines MY_NEW_SEG as a segment. MY_NEW_SEG remains the current segment
until the end of the file or another SEGMENT command. You define a segment
once, and then you can always make it the current segment with the SEGMENT
directive.
2. Add directives to control the location of each segment.
a. From the Project menu, select Settings.
b. On the Linker tab of the Project Settings dialog box, select the Input category.
c. Select the Create New button.
d. Click Add Directives to display the Additional Linker Directives dialog box.
e. In the Additional Linker Directives dialog box, add directives to control the
location of each segment.
You can also the LOCATE directive to place entry points and named variables. For example:
LOCATE myfile_TEXT at $3000
How do I speed up the linker?
Use the following tips to lower linker execution times:
•
If you do not need a link map file, deselect the Generate Map File check box in the
Project Settings dialog box (Linker tab, General category). See “Generate Map File”
on page 117.
•
Make sure that all DOS windows are minimized.
How do I generate debug information without generating code?
Use the COPY or CHANGE command in the linker to copy or change a segment to the
predefined NULL space. If you copy the segment to the NULL space, the region is still
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
367
allocated but no data is written for it. If you change the segment to the NULL space, the
region is not allocated at all.
The following examples are of commands in the linker command file:
COPY
CHANGE
myseg
NULL
myseg = NULL
How can I debug code already burned in ROM?
This solution has two parts:
•
•
“Part 1: Create and Burn the Hex File with Debug Information” on page 367.
“Part 2: Create a Build Configuration that Mimics the Original for Debugging” on
page 368
Part 1 produces code that can be debugged and places it on the target, and Part 2 is necessary to get the IDE in sync with the code on the target. Both parts are necessary to make
this solution work.
Note: Part 2 essentially produces a build configuration within the original project that allows the
IDE to connect to the target for debugging. The new build configuration contains virtually
the same project settings, except the executable format, as the project you used for creating
your hex file.
Part 1: Create and Burn the Hex File with Debug Information
1. From the File menu, select Open Project to open the project that was used to create
the original hex file with ZDS II.
2. Select the build configuration used to create the original hex file from the Select
Active Configuration drop-down list box in the Build toolbar.
3. Select Settings from the Project menu.
The Project Settings dialog box is displayed.
4. Select the C (Compiler) tab.
5. In the General category, select Generate Debug Info from the Debug Information
drop-down list box.
6. On the Assembler tab, select the Debug Information check box.
7. On the Linker tab, select the Generate Debug Info check box in the General category.
8. Click OK to close the Project Settings dialog box.
9. From the Build menu, select Rebuild All to build the project.
10. Burn the newly generated hex file in the target.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
368
Part 2: Create a Build Configuration that Mimics the Original for Debugging
1. Select Manage Configurations from the Build menu.
The Manage Configurations dialog box is displayed.
2. Click Add.
The Add Project Configuration dialog box is displayed.
3. In the Configuration Name field, enter a new configuration name (for example, Debug
– Flash).
4. Verify that the Target is eZ80.
5. In the Copy Settings From drop-down list box, select the build configuration used to
create the original hex file.
6. Click OK to close the Add Project Configuration dialog box.
7. Click Close to close the Manage Configurations dialog box.
8. Select the new build configuration (for example, Debug – Flash) from the Select
Active Configuration drop-down list box in the Build toolbar.
9. Select Settings from the Project menu.
The Project Settings dialog box is displayed.
10. In the C (Compiler) tab, make sure that Generate Debug Info is selected from the
Debug Information drop-down list box in the General category.
11. Make sure that the Debug Information check boxes are selected in the Assembler and
Linker tabs.
12. Select the Linker tab.
13. In the Output category, select IEEE 695 in the Executable Formats area.
14. In the Debugger tab, select the appropriate target and click Configure.
The Configure Target dialog box is displayed.
15. Verify that the initialization parameters mimic the hardware parameters used by the
original project.
16. Enter 0 in the Program Counter (hex) field.
17. Click OK to close the Configure Target dialog box.
18. Click OK to close the Project Settings dialog box.
19. From the Build menu, select Rebuild All to build the project.
20. From the Build menu, select Debug and then Connect to Target to connect to the
target.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
369
Caution: Do not establish a target connection using the Reset or Go commands/buttons and do not
invoke the Download Code command/button. Doing so might corrupt the ROM/Flash
device. The Reset and Go commands/buttons can be used in all other cases.
21. Continue debugging as usual.
Note: For the solution given here, it is assumed that the source and project files are available to
recreate the hex image with ZDS II and that the target can be reprogrammed. If the source
and project files are not available to recreate the hex image with ZDS II or the target cannot
be reprogrammed, a new project can be created for debugging at the disassembly level. In
that case, create a new project for the target that contains a blank source file.
How much memory is my program using?
Unless the Generate Map File check box is unchecked in the Project Settings dialog box
(Linker tab, General category), the linker creates a link map file each time it is run. The
link map file name is the same as your executable file with the .map extension and resides
in the same directory as your project file. The link map has a wealth of information about
the memory requirements of your program. Views of memory usage from the space, segment, and module perspective are given as are the names and locations of all public symbols. See “Generate Map File” on page 117 and “MAP” on page 347.
How do I create a hex file?
Select Intel Hex Records from the Executable Formats area in the Project Settings dialog
box (Linker tab, “Output Category” on page 128).
How do I determine the size of my actual hex code?
Refer to the map file. Unless the Generate Map File check box is unchecked in the Project
Settings dialog box (Linker tab, “General Category” on page 116), the linker creates a link
map file each time it is run. The link map file name is the same as your executable file
with the .map extension and resides in the same directory as your project file.
WARNING AND ERROR MESSAGES
This section covers warning and error messages for the linker/locator.
700 Absolute segment "<name>" is not on a MAU boundary.
The named segment is not aligned on a Minimum Addressable Unit boundary.
Padding or a correctly aligned absolute location must be supplied.
701 <address range error message>.
A group, section, or address space is larger than is specified maximum length.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
370
704 Locate of a type is invalid. Type "<typename>".
It is not permitted to specify an absolute location for a type.
708 "<name>" 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 "<space1> <space2>" is not allowed.
When merging two or more address spaces, at most one of them can be located
absolutely.
711 Merging two located groups "<group1> <group2>".
When merging two or more groups, at most one can be located absolutely.
712 Space "<space>" is not located on a segment base.
The address space is not aligned with a segment boundary.
713 Space "<space>" is not defined.
The named address space is not defined.
714 Multiple locates for "<name>" have been specified.
Multiple absolute locations have been specified for the named group, section, or
address space.
715 Module "<name>" 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.
718 "<segment>" is not in the specified range.
The named segment is not within the allowed address range.
719 "<segment>" is an absolute or located segment. Relocation was ignored.
An attempt was made to relocate an absolutely located segment.
720 "<name> calls <name>" graph node which is not defined.
This message provides detailed information on how an undefined function name is
called.
721 Help file "<name>" not found.
The named help file could not be found. You may need to reinstall the development
system software.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
371
723 "<name>" has not been ordered.
The named group, section, or address space does not have an order assigned to it.
724 Symbol <name> (<file>) is not defined.
The named symbol is referenced in the given file, but not defined. Only the name of
the file containing the first reference is listed within the parentheses; it can also be
referenced in other files.
726 Expression structure could not be stored. Out of memory.
Memory to store an expression structure could not be allocated.
727 Group structure could not be stored. Out of memory.
Memory to store a group structure could not be allocated.
730 Range structure could not be stored. Out of memory.
Memory to store a range structure could not be allocated.
731 File "<file>" is not found.
The named input file or a library file name or the structure containing a library file
name was not found.
732 Error encountered opening file "<file>".
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 "<segment>" is not defined.
The referenced segment name has not been defined.
739 Invalid space "<space>" is defined.
The named address space is not valid. It must be either a group or an address space.
740 Space "<space>" is not defined.
The referenced space name is not defined.
742 <error message>
A general-purpose error message.
743 Vector "<vector>" not defined.
The named interrupt vector could not be found in the symbol table.
745 Configuration bits mismatch in file <file>.
The mode bit in the current input file differs from previous input files.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
372
746 Symbol <name> not attached to a valid segment.
The named symbol is not assigned to a valid segment.
747 <message>
General-purpose error message for reporting out-of-range errors. An address does not
fit within the valid range.
748 <message>
General-purpose error message for OMF695 to OMF251 conversion. The requested
translation could not proceed.
749 Could not allocate global register.
A global register was requested, but no register of the desired size remains available.
751 Error opening output file "<outfile>".
The named load module file could not be opened.
753 Segment '<segment>' 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.
UM014418-0205
6 Using the Linker/Locator
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
373
A ANSI C Language
This appendix describes the ANSI C language supported by the eZ80Acclaim! developer’s environment ANSI C-Compiler. The following topics are covered:
•
•
•
•
•
•
•
•
•
•
UM014418-0205
“Conventions” on page 374
“Character Sets” on page 374
“Tokens” on page 375
“Comments” on page 388
“Conversions” on page 389
“Sequence Points” on page 393
“Expressions” on page 393
“Declarations” on page 412
“Statements” on page 429
“External Definitions” on page 436
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
374
CONVENTIONS
A colon (:) following a nonterminal introduces its definition.
Alternative definitions are listed on separate lines, except when prefaced by the words
“one of.”
An optional symbol is indicated by the subscript opt so that { expression opt } indicates
an optional expression enclosed in braces.
CHARACTER SETS
The compiler supports two character sets: the ASCII character set and trigraphs used to
generate ASCII characters that some terminals do not support.
In a character constant or string literal, characters in the execution set are represented by
corresponding characters in the source character set or by escape sequences consisting of
the backslash (\) followed by one or more characters. A representation with all bits set to
0, called the null character, exists in the execution character set, and is used to terminate
string literals.
The characters in Table 24 are in the source and execution character sets.
Table 24. Character Sets
Description
Characters
The 52 uppercase and lowercase letters of the English alphabet. a b c d e f g h i j k l m n o p q r s t u v w
x y z A B C D E F G H I J K L M NO P
Q R S T U V W X Y Z
The 10 decimal digits.
0 1 2 3 4 5 6 7 8 9
29 graphic characters.
! ‘‘ # % & ' ( ) * + , - . / :
; <<= >> ? [ \ ] ^ _ { | } ~
The space character, and control characters representing
horizontal tab, vertical tab, and form feed.
In source files, a standard character sequence indicates the end of each line of text. This
standard treats such an end-of-line indicator as if it were a single new-line character. In the
execution character set, a control character represents the new line.
If the compiler encounters any other characters in a source file (except in a preprocessing
token, a character constant, a string literal, or a comment), the behavior is undefined.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
375
All occurrences in a source file of the following sequences of three characters (called trigraph sequences) are replaced with the corresponding single character.
Table 25. Trigraph Sequences
Trigraph Sequence
Character
??=
#
??(
[
??/
\
??)
]
??’
^
??<<
{
??!
|
??>>
}
??-
~
No other trigraph sequences exist. The compiler does not change ? characters that do not
begin one of the listed trigraphs. For example:
printf("What???/n");
is converted to
printf("What?\n");
after replacement of the trigraph sequence ??/.
TOKENS
A token is the minimal lexical element of the language and can consist of any keyword,
identifier, or constant separated by white space from any otherwise adjacent keyword,
identifier, or constant. Tokens fall into the following categories:
•
•
•
•
•
•
UM014418-0205
keywords (described on page 376)
identifiers (described on page 377)
constants (described on page 382)
string literals (described on page 386)
operators (described on page 387)
punctuators (described on page 388)
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
376
Syntax
token:
keyword
identifier
constant
string-literal
operator
punctuator
The compiler ignores white space, such as space characters, horizontal tabs, new-line
characters, vertical tabs, form feeds, and comments (described later), except as it separates
tokens.
When parsing an input string, the compiler considers the next token to be the longest
sequence of characters that can constitute a token.
Note: An identifier or a constant constitutes a single token. White space must not appear between
the characters that constitute the tokens in the syntax descriptions in this section.
Keywords
The following tokens, constructed of lower-case letters, are reserved for use as keywords
and must not be used otherwise.
keyword: one of
__EXTIO
__INTIO
__near
__P
__R
__rom
asm
at
auto (see page 413)
bit*
break (see page 435)
case (see page 432)
char (see page 414)
const (see page 414)
continue (see page 434)
default (see page 432)
do (see page 433)
double (see page 381)
else (see page 432)
enum (see page 419)
extern (see page 413)
far*
float (see page 381)
for (see page 433)
fract* (see page 414)
goto (see page 434)
if (see page 432)
int (see page 414)
interrupt* (see page 268)
intrinsic
long (see page 414)
near*
nonreentrant
reentrant*
register (see page 413)
return (see page 435)
rom
short (see page 414)
signed (see page 380)
sizeof (see page 401)
static (see page 413)
struct (see page 416)
switch (see page 432)
typedef (see page 425)
union (see page 416)
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
377
unsigned (see page 414)
void (see page 414)
volatile (see page 414)
while (see page 433)
* Language extension for embedded application.
Identifiers
An identifier is a sequence of nondigit characters (including the underscore _ and the
lowercase and uppercase letters) and digits. The first character must not be a digit.
Syntax
identifier:
nondigit
identifier nondigit
identifier digit
nondigit: one of
abcdefghijklm
nopqrstuvwxyz
ABCDEFGHIJKLM
NOPQRSTUVWXYZ
digit: one of
0123456789
Constraints
An identifier must not consist of the same sequence of characters as a keyword. No
specific limit exists on the maximum length of an identifier.
Semantics
An identifier denotes one of the following:
– function
– object
– tag or a member of a structure, union, or enumeration
– typedef name
– label name
– macro name
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
378
Macro names are not considered further here, because the compiler replaces macro
names with their corresponding token sequences before the semantic phase of
program translation.
Scopes of Identifiers
An identifier is visible (that is, can be used) only within a region of program text called its
scope. Four kinds of scopes exist.
•
•
•
•
function
file
block
function prototype
A function prototype is a declaration of a function that declares the types of its parameters.
A label name is the only kind of identifier that has function scope. It can be used (in a
goto statement) anywhere in the function in which it appears and is declared implicitly by
its syntactic appearance (followed by a colon and a statement). Label names must be
unique within a function.
The compiler determines the scope of all other identifiers by the placement of their declarations.
•
If the declaration appears outside any block, the identifier has file scope, which
extends from the completion of its declarator to the end of the source file, including all
source files included by preprocessing directives.
•
If the declaration appears within a block or in the list of parameter identifiers in a
function definition, the identifier has block scope, which extends from the completion
of the declarator to the } that closes the associated block.
•
If an outer declaration of a lexically identical identifier exists, the compiler “hides” the
identifier until it encounters the } that closes the block.
•
If the declaration appears within the list of parameters in a function prototype, the
identifier has function prototype scope, which extends from the completion of the
declaration of the parameter to the end of the function declarator.
Linkages of Identifiers
Two lexically identical identifiers declared in different scopes can refer to the same function or object through a process called linkage. Three kinds of linkage exist: external,
internal, and none.
External Linkage
In the set of source files and libraries that constitute an entire program, every instance
of a particular identifier with external linkage denotes the same function or object. If the
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
379
declarations in two source files or in disjoint scopes within one source file differ, the
behavior is undefined.
If its first lexical declaration with file scope in the source does not contain the keyword
static, an identifier of a function or object declared with file scope has external linkage.
If the declaration of a function or object contains the keyword extern, the identifier has
the same linkage as any previous declaration of the identifier with file scope. If no previous declaration exists, the identifier has external linkage.
If an identifier declared with external linkage is used in an expression, the entire program
must hold exactly one external definition for the identifier (a declaration that has external
linkage and for which storage is allocated). If an identifier declared with external linkage
is not used in an expression, the identifier needs no external definition.
Internal Linkage
Within one source file, each instance of an identifier with internal linkage denotes the
same function or object.
If its first lexical declaration with file scope in the source contains the keyword static, an
identifier of a function or object declared with file scope has internal linkage.
No Linkage
Identifiers with no linkage denote unique entities.
An identifier that declares anything other than a function or an object has no linkage. An
identifier declared as a function parameter has no linkage.
Except for a declaration of a function, an identifier declared within a block without the
keyword extern must have only one declaration in the same scope. Such an identifier has
no linkage.
Name Spaces of Identifiers
If more than one declaration of a particular identifier is visible at any point in a source file,
the syntactic context might clarify uses that refer to different entities. Because of these
cases, separate name spaces exist for various categories of identifiers.
•
•
The label names (clarified by the syntax of the label declaration and use).
•
The members of structures or unions. Each structure or union has a separate name
space for its member, clarified by the type of the expression used to access the
member through the . or -> operator.
•
All other identifiers, called ordinary identifiers (declared in ordinary declarators or as
enumeration constants).
UM014418-0205
The tags of structures, unions, and enumerations. Although they are clarified by the
preceding struct, union, or enum keyword, tags share the same name space.
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
380
Storage Durations of Objects
An object has storage duration that determines its lifetime. There are two storage durations:
•
•
static
automatic
An object declared with static storage duration is created and initialized only once, theoretically when the program begins execution. It exists and retains its value, unless explicitly modified, throughout the execution of the entire program.
A new instance of an object declared with automatic storage duration is created on each
normal entry into the block in which it is declared or on a jump to a label in the block or in
an enclosed block. If an initialization is specified, it is performed on each normal entry,
but not if the block ends in any of the following three ways:
•
•
•
reaching the terminating }
jumping to an enclosing block
executing a break or return statement
Types
An identifier's type determines its permitted use. If the identifier designates an object, the
type is characterized by the set of values that such an object might contain. The meaning
of the value of an object is determined by the types of the identifiers in an expression used
to access it.
Characters, integers, and floating-point numbers are collectively called the basic types.
An object declared as a character (char) is large enough to store any member of the
required source character set. If such a character is stored in a char object, its value is
non-negative.
Signed Integer Types
Signed integers fall into the following four types:
•
•
•
•
signed char
short int
int
long int
A signed char occupies the same amount of storage as a “plain” char. The natural size
of a “plain” int is suggested by the architecture of the execution environment: the size
must be large enough to contain any value in the range INT_MIN to INT_MAX as defined
in the <limits.h> header). The other types are provided to meet special needs.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
381
The set of values of each signed integral type is a subset of the values of the next type in
the list. Even if the implementation defines two or more types of integers to have the same
set of values, they are nevertheless different types.
For signed char, short int, and each type of int, a corresponding unsigned integer type exists, declared with the keyword unsigned, that uses the same amount of storage, including sign information. The set of non-negative values of a signed type is a
subset of its corresponding unsigned type. A computation involving unsigned objects
can never overflow, because a result that does not fit in an object of that size is reduced by
modulo of the largest unsigned number that can be represented plus one.
Enumerated Types
The enumerated types are enumeration and void. An enumeration comprises a set of
named integer constant values. The void type specifies an empty set of values; no object
can have type void.
Any number of derived types can be constructed from the following basic and enumerated
types:
•
•
arrays comprising a contiguously allocated set of members of any one type of object
structures comprising a sequentially allocated set of named members of various types
of objects
•
•
unions comprising an overlapping set of named members of various types of objects
•
pointers to functions, to objects of any type, and to void
functions that accept arguments of various types and return a value of any one type of
object except an array
You can apply these methods of constructing derived types recursively.
Integral Types
Types char and int (of all sizes), both signed and unsigned, and enumerations are
collectively called integral types. The values of integral types must be interpreted in a pure
binary numeration system.
Floating Types
Types float, double, and long double are collectively called floating types. The
representations of floating types are unspecified.
Miscellaneous Types
Integral and floating types are collectively called arithmetic types. Arithmetic types and
pointers are collectively called scalar types. Arrays and structures are collectively called
aggregate types.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
382
The type of a function comprises the type of the value returned, the number and types of
the parameters (if specified), and whether a variable number of arguments is permitted.
Constants
Syntax
constant:
floating-constant
integer-constant
enumeration-constant
character-constant
floating-constant:
fractional-constant exponent-part opt floating-suffix opt
digit-sequence exponent-part floating-suffix opt
fractional-constant:
digit-sequence opt . digit-sequence
digit-sequence .
exponent-part:
e sign opt
digit-sequence
E sign opt
digit-sequence
sign: one of
+digit-sequence:
digit
digit-sequence digit
floating-suffix: one of
flFL
Constraint
The value of a constant must be representable in the storage appropriate for its type in the
execution environment.
Semantics
Each constant has a type, determined by its form and value.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
383
Integer Constants
An integer constant begins with a digit, but has no decimal point or exponent part. It might
have a prefix that specifies its base and a suffix that specifies its type.
Syntax
integer-constant:
decimal-constant integer-suffix opt
octal-constant integer-suffix opt
hexadecimal-constant integer-suffix opt
decimal-constant:
nonzero-digit
decimal-constant digit
octal-constant:
0
octal-constant octal-digit
hexadecimal-constant:
0x hexadecimal-digit
0X hexadecimal-digit
hexadecimal-constant hexadecimal-digit
nonzero-digit: one of
123456789
octal-digit: one of
01234567
hexadecimal-digit: one of
0123456789
abcdef
ABCDEF
integer-suffix:
unsigned-suffix long-suffix opt
long-suffix unsigned-suffix opt
unsigned-suffix: one of
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
384
u U
long-suffix: one of
l L
Semantics
The lexically first digit is the most significant.
The type of an integer constant is the first of the corresponding list in which its values can
be represented:
•
•
Unsuffixed decimal: int, long int, unsigned long int
Unsuffixed octal or hexadecimal: INT, unsigned int, long int, unsigned
long int
•
•
•
Suffixed by the letter u or U: unsigned int, unsigned long int
Suffixed by the letter l or L: long int, unsigned long int
Suffixed by both the letters u or U and l or L: unsigned long int
Enumeration Constants
Syntax
enumeration-constant:
identifier
Semantics
An identifier declared as an enumeration constant has type int.
Character Constants
A character constant is a sequence of one or more characters enclosed in single quotes, as
in 'x' or 'ab'. A wide character constant is the same, except prefixed by the letter L. With a
few exceptions detailed later, the characters are any characters in the source character set.
The single quote (’), the double quote ("), the question mark (?), the backslash (\), and
arbitrary integral values are representable according to the following table of escape
sequences:
Character
Escape Sequence
single-quote (')
\'
double-quote (")
\"
question-mark (?)
\?
backslash (\)
\\
octal integer
\o \oo \ooo
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
385
Character
Escape Sequence
hexadecimal integer
\xh \xhh \xhhh
alert
\a
backspace
\b
form feed
\f
new line
\n
carriage return
\r
horizontal tab
\t
vertical tab
\v
The double quote (") and question mark (?) are representable by themselves or by the
escape sequences \" and (\?) respectively, but the single quote (') must be represented by
the escape sequence (\'). The octal digits that follow the backslash in the escape sequences
\o, \oo, and \ooo are taken to be part of the construction of a single character. The numerical value of the octal integer so formed specifies the value of the character.
The hexadecimal digits that follow the backslash and the letter x in the escape sequences
\xh, \xhh, and \xhhh are taken to be part of the construction of a single character. The
numerical value of the hexadecimal integer so formed specifies the value of the character.
\a (alert) produces an audible or visible alert. The active position is not changed.
\b (backspace) moves the active position to the position of the previous character. If the
active position is at the initial position of a line, the behavior is unspecified.
\f (form feed) moves the active position to the initial position at the start of the next logi-
cal page.
\n (new line) moves the active position to the initial position of the next line.
\r (carriage return) moves the active position to the initial position of the current line.
\t (horizontal tab) moves the active position to the next horizontal tabulation position on
the current line. If the active position is at or past the last defined horizontal tabulation
position, the behavior is unspecified.
\v (vertical tab) moves the active position to the initial position of the next vertical tabula-
tion position. If the active position is at or past the defined vertical tabulation position, the
behavior is unspecified.
If an escape sequence other than one of these is encountered, the behavior is undetermined.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
386
Syntax
character-constant:
L opt 'c-char-sequence'
c-char-sequence:
c-char
c-char-sequence c-char
c-char:
any character in the source character set except
the single-quote ('), backslash (\), or new-line character
escape-sequence
escape-sequence: one of
\'
\"
\?
\o
\oo
\ooo
\xh
\xhh
\xhhh
\a
\b
\f
\\
\n
\r
\t
\v
Semantics
A character constant has type int. The value of a character constant containing a character
that maps into a character in the execution character set, is the numerical value of the representation of the mapped character interpreted as an integer. The value of a character constant containing more than one character, or containing a character or escape sequence not
represented in the execution character set, is flagged as an error.
A wide character constant has type wchar_t, an integral type defined in <stddef.h>. The
value of a wide character constant containing a single multibyte character that maps into a
member of the extended execution character set, is the wide character (code) corresponding to that multibyte character.
Example
The construction \0 represents the null character.
String Literals
A string literal is a sequence of zero or more characters enclosed in double-quotes, as in
"xyz".
The same considerations apply to each element to a sequence in a character string literal or
a wide string literal as if it were an integer character constant or a wide character constant,
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
387
except that the single-quote (') is representable by itself or by the escape sequence (\'), but
the double-quote (") must be represented by the escape sequence \"; in addition, you can
use the same escape sequences as described for character constants.
Syntax
string-literal:
L opt "s-char-sequence opt "
s-char-sequence:
s-char
s-char-sequence s-char
s-char:
any member of the source character set except
the double-quote ("), backslash (\), or new-line character
escape-sequence
Semantics
A string literal is a character array with static storage duration. The compiler initializes the
literal with the given characters; it concatenates string literals that are adjacent tokens into
a single string literal, then appends a null character.
A character string literal is a character array that the compiler initializes with the individual bytes of the multibyte character sequence.
A wide string literal is an array of type wchar_t. The compiler initializes this literal with
the sequence of wide characters corresponding to the multibyte character sequence.
Identical string literals need not be distinct. If the program attempts to modify a string literal, the behavior is undefined.
Operators
Syntax
operator: one of
[ ] ( ) . ->>
++ -- & * + - ~ ! sizeof
/ % << >> < > <= >= == != ^ | & &||
? :
= *= /= %= += -= <<= >>= &= ^= |=
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
388
, # ##
Constraints
The operators [ ], ( ), and ? : must occur in pairs, possibly separated by expressions. The
operators # and ## can occur in macro-defining preprocessor directives only.
Semantics
An operator performs an operation that yields an evaluation, or a value. An operand is an
entity on which an operator acts.
Punctuators
Syntax
punctuator: one of
[ ]
( )
{ }
*
,
:
=
;
...
#
Constraints
The punctuators [ ], ( ), and { } must occur in pairs, possibly separated by expressions,
declarations, or statements. The punctuator # can occur in preprocessor directives only.
Semantics
A punctuator is a symbol that has independent syntactic significance but does not specify
an operation to be performed that yields a value. Depending on context, the same symbol
can also represent an operator or part of an operator.
COMMENTS
The characters /* introduce a comment except in the following cases:
•
•
•
•
•
within a character constant
within a string literal
within the quoted argument to a #include or #line preprocessing directive
within the arguments to a #error or #pragma preprocessing directive
within a comment
The compiler examines contents of a comment only to find the characters */ that terminate it. The new style of comment is also supported. These comments begin with // and
are terminated by a new line.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
389
CONVERSIONS
Several operators can convert operand values from one type to another. This section specifies the result required from such an implicit conversion. The following conversions are
discussed:
•
•
•
•
•
•
•
•
“Characters and Integers”
“Signed and Unsigned Integers”
“Floating and Integral” on page 390
“Usual Arithmetic Conversions” on page 390
“Lvalues and Function Designators” on page 390
“Void” on page 391
“Pointers” on page 391
“const and volatile” on page 392
Conversion of an operand to the same type causes no change.
Arithmetic Types
Characters and Integers
A char, a short int, or an int bit-field, or their signed or unsigned varieties, can be
used in an expression wherever an int or unsigned int can be used. In all cases the
value is converted to an int if an int can represent all values of the original type; otherwise, it is converted to an unsigned int. These are called the integral promotions.
The integral promotions preserve the value, including its sign. As discussed earlier,
“plain” char is treated as signed.
When an integer is demoted to a shorter unsigned integer or unsigned int bit-field or
unsigned char, the result is the remainder modulo the largest unsigned number that can
be represented plus one. When an integer is demoted to a shorter signed integer or int
bit-field or signed char, the least significant bits of the integer are used.
Signed and Unsigned Integers
The following types are equivalent:
signed int = int
signed short int = short int
signed long int = long int
When an unsigned integer is promoted to a longer integer, its value is unchanged.
When a positive signed integer is converted to an unsigned integer of equal or greater
length, its value is unchanged. Otherwise, if the unsigned integer is longer, the signed
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
390
integer is first promoted to a signed integer of the same length as the unsigned integer,
then converted to unsigned by adding to it the largest number that can be represented in
the unsigned integer plus one.
Floating and Integral
When a value of floating type is converted to integral type, the fractional part is discarded.
If the value of the integral part cannot be represented in the space provided, the behavior is
undefined.
When a value of integral type is converted to floating type, some loss of precision occurs
if the destination lacks sufficient precision.
Usual Arithmetic Conversions
Many binary operators that expect operands of arithmetic type cause conversions and
yield result types in a similar way. The purpose is to yield a common type, which is also
the type of the result.
This pattern is called the usual arithmetic conversions.
•
First, if either operand has type unsigned long int, the other operand is converted
to unsigned long int.
•
Otherwise, if either operand has type long int, the other operand is converted to
long int.
•
Otherwise, the integral promotions are performed. Then, if either operand has type
unsigned int, the other operand is converted to unsigned int.
•
Otherwise, both operands have type int.
Operands can be converted to other types, provided neither range nor precision is lost; if
so, the type of the result is not change.
Other Operands
Lvalues and Function Designators
An lvalue is an expression (with an object type or an incomplete type other than void)
that identifies an object. The type of an object is determined by the lvalue used to identify the object.
A modifiable lvalue is an lvalue that does not have any of the following:
•
•
•
UM014418-0205
array type
an incomplete type
a const-qualified type
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
391
In addition, if it is a structure or union, the lvalue does not have any member (including,
recursively, any member of all contained structures or unions) with a const-qualified
type.
An lvalue that is not an array is converted to the value stored in the designated object and
is no longer an lvalue, except when it is the operand of any of the following:
•
•
•
•
•
the sizeof operator
the unary & operator
the ++ operator
the -- operator
the left operand of the . operator or an assignment operator
If the lvalue has qualified type, the value has the unqualified version of the type of the
lvalue; otherwise, the value has the type of the lvalue. If the lvalue has an incomplete type and does not have array type, the behavior is undefined.
If the lvalue is an array of a certain type, the compiler converts it to a pointer of that type
that points to the initial element of the array type and is not an lvalue. Exceptions occur
if the lvalue is one of the following:
•
•
•
the operand of the sizeof operator or the unary & operator
a character string literal that initializes an array of character type
a wide string literal that initializes an array with element type compatible with
wchar_t
A function designator is an expression that has function type. A function designator that
returns a type is converted to a pointer to a function returning that type, except when it is
the operand of the sizeof operator or the unary & operator.
Void
The (nonexistent) value of a void expression is not used in any way. Implicit or explicit
conversions must not be applied to such an expression.
Pointers
A pointer to void can be converted to a pointer to an object of any type. A pointer to an
object of any type can be converted to a pointer to void and back again; the result is equal
to the original pointer.
An integral constant expression with the value 0 or such an expression cast to type void *
is called a null pointer constant. If a null pointer constant is assigned to or compared for
equality to a pointer, the constant is converted to a pointer of that type. Such a pointer,
called a null pointer, does not point to any object or function.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
392
const and volatile
The properties associated with the const type specifier are meaningful only for expressions that are lvalues.
An expression that has a type declared with the const type specifier is not a modifiable
lvalue.
An expression that has a type not declared with the const type specifier acquires the
const attribute if converted to a type declared with the const type specifier.
An expression declared to be a pointer to a type without the const attribute can be
assigned to a pointer to a type with the const attribute. This pointer does not modify the
object.
Except by an explicit cast, an expression declared to be a pointer to a type with the const
attribute is not assigned to a pointer to a type without the const attribute. If you attempt
to modify an object that has a type declared with the const type specifier by means of an
lvalue that has a type not declared with the const type specifier, the behavior is undefined.
An object declared with the volatile type specifier can be modified in ways unknown to
the compiler or have other unknown side effects. Therefore, the compiler evaluates any
expression referring to such an object strictly according to the sequence rules of the
abstract machine. Furthermore, at every sequence point the value of the object in storage
agrees with that prescribed by the abstract machine, except as modified by the unknown
factors mentioned previously.
An expression declared to be a pointer to a type without the volatile attribute can be
assigned to a pointer to a type with the volatile attribute. In this case, the compiler
obeys the rules for volatile objects when the volatile pointer refers to the object.
Except by an explicit cast, an expression declared to be a pointer to a type with the
volatile attribute is not assigned to a pointer to a type without the const attribute. If
you attempt to modify an object declared to be a type with the const type specifier by
means of an lvalue that has a type not declared with the const type specifier, the behavior
is undefined.
If an aggregate object type is declared with the const or volatile type specifier, the
type of each member of the aggregate is implicitly declared with that specifier. For example:
An object declared
extern volatile const real_time_clock;
can be modified by hardware, but cannot be assigned to, incremented, or decremented.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
393
SEQUENCE POINTS
This section lists the sequence points as defined by the ANSI C standard. Sequence points
are points in the execution sequence at which all side effects of previous evaluations are
complete and no side effects of subsequent evaluations have taken place.
The following is the list of sequence points:
• The call to a function, after the arguments have been evaluated (See “Function Calls”
on page 396.)
• The logical AND operator && (See “Logical AND Operator (&&)” on page 408.)
• The logical OR operator || (See “Logical OR Operator (||)” on page 408.)
• The conditional operator? (See “Conditional Operator (?:)” on page 409.)
• The comma operator , (See “Comma Operator” on page 411.)
• Completion of the evaluation of a full expression:
– an initializer of an object that has automatic storage duration (See “Initialization”
on page 426.)
– the expression statement (See “Expression and Null Statements” on page 431.)
– the controlling expression of a selection statement such as if or switch (See
“Selection Statements” on page 432.)
– the controlling expression of an iteration statement such as while, do, or for
(See “Iteration Statements” on page 433.)
EXPRESSIONS
An expression is a sequence of operators and operands that specifies how to compute a
value, how to generate side effects, or both. There are primary expressions (see page 395)
and constant expressions (see page 411). Operators can include any of the following:
•
•
•
•
•
•
•
•
•
•
•
UM014418-0205
“Postfix Operators” on page 395
“Postfix Increment and Decrement Operators” on page 398
“Unary Operators” on page 399
“Prefix Increment and Decrement Operators” on page 399
“Address and Indirection Operators” on page 400
“Unary Arithmetic Operators” on page 400
“Sizeof Operator” on page 401
“Cast Operators” on page 402
“Multiplicative Operators” on page 402
“Additive Operators” on page 403
“Bitwise Shift Operators” on page 404
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
394
•
•
•
•
•
•
•
•
•
•
“Relational Operators” on page 405
“Equality Operator” on page 406
“Bitwise AND Operator (&)” on page 406
“Bitwise Exclusive OR Operator (^)” on page 407
“Bitwise Inclusive OR Operator (|)” on page 407
“Logical AND Operator (&&)” on page 408
“Logical OR Operator (||)” on page 408
“Conditional Operator (?:)” on page 409
“Assignment Operators” on page 409
“Comma Operator” on page 411
The order of evaluation is unspecified except for the following:
•
•
•
•
•
•
function-call operator ( ( ) )
unary plus operator ( + )
logical AND operator ( && )
logical OR operator ( || )
conditional operator ( ?: )
comma operator ( , )
The compiler can evaluate subexpressions in any order, even if the subexpressions produce side effects. The order in which side effects take place is unspecified.
An expression involving more than one occurrence of the same communitive and associative binary operator (*, +, &, ^, |) can be regrouped arbitrarily, even in the presence of
parentheses, provided that this regrouping does not change the types of the operands or of
the results. Two ways exist to force a particular grouping of operations:
•
•
by explicitly assigning the value of the expression to group to an object
by preceding the grouping parentheses with a unary plus operator
Some operators, such as the unary operator ~ and the binary or bitwise operators (<<, >>,
&, ^, and |), have operands with integral type.
If an exception occurs during the evaluation of an expression (that is, if the result is not
mathematically defined or not representable), the behavior is undefined.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
395
Primary Expressions
Syntax
primary-expression:
identifier
constant
string-literal
( expression )
Semantics
An identifier is a primary expression if it is an lvalue declared as designating an object or
a function locator designating a function.
A constant is a primary expression. Its type depends on its form, as detailed in “Constants”
on page 382.
A string literal is a primary expression. It is an lvalue of an array of char, as detailed in
“String Literals” on page 386.
A parenthesized expression is a primary expression. Its type and value are identical to
those of the unadorned expression. It is an lvalue if the unadorned expression is an lvalue,
or a function locator if the unadorned expression is a function locator.
Postfix Operators
Syntax
postfix-expression:
primary-expression
postfix-expression [ expression ]
postfix-expression ( argument-expression-list opt )
postfix-expression . identifier
postfix-expression -> identifier
postfix-expression ++
postfix-expression -argument-expression-list:
assignment-expression
argument-expression-list , assignment-expression
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
396
Array Subscripting
Constraints
One of the expressions is a pointer to type. The other expression has integral type. The
result is of type.
Semantics
A postfix expression followed by an expression in square brackets [] is a subscripted designation of a member of an array object.
For instance, E1 is identical to (*(E1+(E2))). Because of the conversion rules that apply to
the binary + operator, if E1 is an array object and E2 is an integer, E1 [E2] designates the
E2-th member of E1 (counting from zero).
Successive subscript operators designate members of a multidimensional array object. If E
is an n-dimensional array with dimensions i x j x ... x k, then E (used as other than an
lvalue) is converted to a pointer to an (n-1)-dimensional array with dimensions j x ... x k. If
the unary * operator is applied to this pointer explicitly, or implicitly as a result of subscripting, the result is the pointed-to (n-1)-dimensional array, which itself is converted into
a pointer if used as other than lvalue. Therefore, arrays are stored in row-major order:
the last subscript varies fastest.
Example
Consider the array object defined by the declaration
int x[3] [5];
Here, x is a 3x5 array of ints; more precisely, x is an array of three member objects, each
of which is an array of five ints. In the expression x [i], which is equivalent to (*(x+(i))),
•
•
x is converted to a pointer to the initial array of five ints.
•
The compiler adds the results and applies indirection to yield an array of five ints.
i is adjusted according to the type of x, which conceptually entails multiplying i by the
size of the object to which the pointer points: an array of five int objects.
When used in the expression x[i][j], that in turn is converted to a pointer to the first of the
ints, so x[i][j] yields an int.
Function Calls
Constraints
A function does not return a value of an array or function.
If a function prototype declarator is in scope, the number of arguments shall agree with the
number of formal parameters. The types shall be such that each formal parameter can be
assigned the value of the corresponding argument.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
397
Semantics
A postfix expression followed by parentheses ( ) contains a possibly empty, comma-separated list of expressions. The list of expressions specifies the arguments to the function.
The postfix expression denotes the function called, and is declared as a pointer to a function returning type (which can be the result of converting a function locator). The result is
of type.
If no declaration is in scope for an identifier used as the first expression in a function call,
the identifier is implicitly declared exactly as if, in the innermost block containing the
function call, the declaration
extern int identifier( );
appeared. This function has external linkage and no information about its parameters, and
returns an int.
An argument can be any expression other than a void expression. In preparing for the call
to a function, each argument is evaluated, and each formal parameter is assigned the value
of the corresponding argument. An argument or a formal parameter that has an array or
function type is converted to a pointer.
If no function prototype declarator is in scope, the integral promotions are performed and
arguments that have type float are promoted to double. These are called the default argument conversions. If the number of arguments or their types after conversion do not agree
with those of the formal parameters, the behavior is undefined.
If a function prototype declarator is in scope, the arguments are compared with the formal
parameters and are converted accordingly. The ellipsis notation (,...) in a function prototype declarator stops argument type checking and conversion stop after the last declared
formal parameter. The default argument conversions are performed on unchecked arguments.
No other conversions are performed automatically. In particular, the number and types of
arguments are not compared with those of the formal parameters in a function definition
that does not include a function prototype declarator.
The order of evaluation of arguments and of subexpressions within arguments is unspecified, but the call itself is a sequence point before which all side effects are completed.
Recursive function calls are permitted, both directly and indirectly through any chain of
other functions.
Structure and Union Members
Constraints
The first operand of the . operator has a structure or union type, and the second operand
names a member of that type.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
398
The first operand of the -> operator is a pointer to a structure or union. The second operand names a member of the type pointed to.
Semantics
A postfix expression followed by a dot (.) and an identifier designates a member of a
structure or union entity. The value is that of the named member, and is an lvalue unless
the first expression is the value returned by a function call.
A postfix expression followed by an arrow -> and an identifier designates a member of a
structure or union object. The value is that of the named member of the object to which
the first expression points. This value is an lvalue.
With one exception, if a member of a union is inspected when the value of the object has
been assigned using a different member, the behavior is indeterminate. One special guarantee is made in order to simplify the use of unions; if a union contains several structures
that share a common initial sequence, and if the union object currently contains one of
these structures, you can inspect the common initial part of any of them.
Example
The following is a valid fragment:
union {
struct {
int type;
} n;
struct {
int type;
int intnode;
} ni;
struct {
int type;
long longnode;
} nf;
} u;
u.nf.type = 1;
u.nf.longnode = 3;
/*...*/
if (u.n.type == 1)
/*...*/
Postfix Increment and Decrement Operators
Constraints
The operand of the postfix increment or decrement operator has scalar type and is a modifiable lvalue.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
399
Semantics
The result of the postfix ++ operator is the value of the operand. After noting the result,
the compiler increments (adds 1 to) the value of the operand. See “Additive Operators” on
page 403 and “Compound Assignment” on page 411 for information on types and
conversions and the effects of operations on pointers. The side effect of updating the
stored value of the operand can be delayed until the next sequence point is reached.
The postfix -- operator is analogous to the postfix ++ operator, except that the compiler
decrements (subtracts 1 from) the value of the operand.
Unary Operators
Syntax
unary-expression:
postfix-expression
++ unary-expression
-- unary-expression
unary-operator cast-expression
sizeof unary-expression
sizeof ( type-name )
unary-operator: one of
&
*
+
-
~
!
Prefix Increment and Decrement Operators
Constraints
The operand of the prefix increment or decrement operator has scalar type and is a modifiable lvalue.
Semantics
The compiler increments the value of the operand of the prefix ++ operator and stores the
incremented value before using the value. The expression ++E is equivalent to (E+=1).
See “Additive Operators” on page 403 and “Compound Assignment” on page 411 for
information on types and conversions and the effects of operations on pointers.
The prefix -- operator is analogous to the prefix ++ operator, except that the compiler
decrements (subtracts 1 from) the value.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
400
Address and Indirection Operators
Constraints
The operand of the unary & operator is either a function locator or an lvalue that designates an object other than a bit-field of an object declared with the register storage-class
specifier.
The operand of the unary * operator has pointer type, other than pointer to void.
Semantics
The result of the unary & (address-of) operator is a pointer to the object designated by its
operand. If the operand has type, the result is a pointer to type.
The unary * operator denotes indirection. If the operand points to a function, the result is a
function locator; if it points to an object, the result is an lvalue designating the object. If
the operand is a pointer to type, the result is of that type. If an invalid value is assigned to
the pointer, the behavior of the unary * operator is undefined.
Unary Arithmetic Operators
Constraints
The operand of the unary + and unary - operator has arithmetic type. The operand of the
~ operator has integral type. The operand of the ! operator has scalar type.
Semantics
The result of the + operator is the value of its operand. The compiler performs integral
promotion on the operand, and the result has the promoted type. Except that it inhibits
regrouping of subexpressions of E with subexpressions outside of E, the expression +E is
equivalent to (0+E).
The result of the unary - operator is the negative of its operand. The integral promotion is
performed on the operand, and the result has the promoted type. The expression -E is
equivalent to (0-E).
The result of the ~ operator is the bit-wise complement of its operand. In other words, each
bit in the result is set if, and only if, the corresponding bit in the converted operand is not
set. The integral promotion is performed on the operand, and the result has the promoted
type.
The expression ~E is equivalent to (ULONG_MAX-E) if E has type unsigned long, or
to (UINT_MAX-E) if E has any other unsigned type. (The constants ULONG_MAX
and UINT_MAX are defined in the <limits.h> header.)
The result of the logical negation operator ! is 0 if the value of its operand is nonzero, or 1
if the value of its operand is 0. The result has type int. The expression !E is equivalent to
(0==E).
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
401
Sizeof Operator
Constraints
The sizeof operator can not be applied to an expression that has type function, bit-field,
or void, or to the parenthesized name of the type of such an expression.
Semantics
The sizeof operator yields the size (in bytes) of its operand, which can be an expression
or the parenthesized name of a type.
•
When applied to an operand that has type char, unsigned char, or signed char,
the result is 1.
•
When applied to an operand that has array type, the result is the total number of bytes
in the array.
•
When applied to an operand that has structure or union type, the result is the total
number of bytes in such an object considered as a member of an array, including
whatever internal and trailing padding might be needed to align each member in such
an array properly.
The size is determined from the type of the operand, which is not itself evaluated. The
result is an integer constant. The size of the result is determined by the code generator, and
its type (an unsigned integral type) is size_t. size_t is defined in the <stddef.h>
header.
Examples
A principal use of the sizeof operator is in communication with routines such as storage
allocators and I/O systems. A storage-allocation function might accept a size (in bytes) of
an object to allocate and return a pointer to void. For example:
extern void *alloc(size_t);
double *dp = alloc(sizeof *dp);
The alloc function ensures that its return value is aligned suitably for conversion to a
pointer to double.
Another use of the sizeof operator is to compute the number of members in an array:
sizeof (array) / sizeof (array[0])
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
402
Cast Operators
Syntax
cast-expression:
unary-expression
( type-name ) cast-expression
Constraints
If the type name specifies void type, the operand can be any expression other than a void
expression. Otherwise, the type name specifies scalar type and the operand has scalar type.
Semantics
Preceding an expression by a parenthesized type name converts the value of the expression to the named type. This construction is called a cast. A cast that specifies an implicit
conversion or no conversion has no effect on the type or value of an expression.
Conversions involving pointers (other than from a pointer to void or from a pointer to an
object) can be specified by an explicit cast.
•
A pointer can be converted to an integer. If the space provided is not long enough, the
behavior is undefined.
•
•
An arbitrary integer can be converted to a pointer.
•
A pointer to an object of one type can be converted to a pointer to an object of another
type. The resulting pointer might not be valid if it is improperly aligned for the type of
object pointed to. However, a pointer to an object of a given alignment can be
converted to a pointer to an object of a less strict alignment and back again; the result
compares equal to the original pointer. (An object that has type char has the least
strict alignment.)
A pointer to a function of one type can be converted to a pointer to a function of
another type and back again; the result compares equal to the original pointer. If a
converted pointer is used to call a function of other than the original type, the behavior
is undefined.
Multiplicative Operators
Syntax
multiplicative-expression:
cast-expression
multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
403
multiplicative-expression % cast-expression
Constraints
Each operand has arithmetic type. The operands of the % operator have integral type.
Semantics
The compiler performs the usual arithmetic conversions on the operands.
The result of the binary * operator is the product of the operands. The binary * operator is
communitive and associative, and expressions involving several multiplications at the
same level can be regrouped.
The result of the / operator is the quotient of the operands.
The result of the % (modulo) operator is the remainder from the division of the first operand by the second.
When integers are divided and the division is inexact, if both operands are positive the
result of the / operator is the largest integer less than the true quotient and the result of the
% operator is positive. If either operand is negative, the result of the / operator is the largest integer less than the true quotient.
Example
The expression (a/b)*b + a%b equals a (if b is not 0).
Additive Operators
Syntax
additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
Constraints
Both of the operands can have arithmetic type. Additional type possibilities for each operator involve pointer operands: one operand can be a pointer to an object and the other an
expression that has integral type. (Incrementing or decrementing is equivalent to adding or
subtracting 1.) You can subtract two pointers to objects that have the same type.
Semantics
If both operands have arithmetic type, the compiler performs the usual arithmetic conversions.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
404
The result of the binary + operator is the sum of the operands. The binary + operator is
communitive and associative, and expressions involving several additions at the same
level can be regrouped.
The result of the binary - operator is the difference of the operands.
When an expression that has integral type is added to or subtracted from a pointer, the
integral value is first multiplied by the size of the object pointed to. The result is a pointer
of the same type as the original pointer. If the original pointer points to a member of an
array object, and the array object is large enough, the result points to another member of
the same array object, approximately offset from the original member.
For instance, if P points to a member of an array object, the expression P+1 points to the
next member of the array object. If the result is used as the operand of a unary * operator,
the behavior is undefined unless both the pointer operand and the result points to a member of the same array object.
When two pointers to members of the same array object are subtracted, the difference is
divided by the size of a member. The result represents the difference of the subscripts of
the two array members. The type of the result is a signed integral type, ptrdiff_t, defined
in the <stddef.h> header. As with any other arithmetic overflow, if the result does not fit
in the space provided, the behavior is undefined.
If two pointers that do not point to members of the same array object are subtracted, the
behavior is undefined. However, if P points to the last member of the same array object,
the expression (P+1) P has the value 1, even though P+1 does not point to a member of the
same array object as P.
Example
The compiler can compute the expression a + (b + c) as (a + b) + c. This feature allows the compiler to sum a and b during program translation if they are constant
expressions. However, this regrouping might lead to overflow or loss of precision. One
way to force the grouping is to write the expression as a + + (b + c), where white
space is required between the first two plus signs.
Bitwise Shift Operators
Syntax
shift-expression:
additive-expression
shift-expression << additive-expression
shift-expression >> additive-expression
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
405
Constraints
Each of the operands has integral type.
Semantics
The compiler performs integral promotions on each of the operands. Then the right operand is converted to int; the type of the result is that of the promoted left operand. If the
value of the right operand is negative or is greater than or equal to the width in bits of the
promoted left operand, the behavior is undefined.
The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with
zeros. If E1 has an unsigned type, the value of the result is
(E1 * 2<B^>E2) - modulo(ULONG_MAX + 1)
if E1 has type unsigned long, or
(E1 * 2<B^>E2) - modulo(UINT_MAX + 1)
otherwise.
The constants ULONG_MAX and UINT_MAX are defined in the <limits.h> header.
The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has a signed type, an
arithmetic shift is performed. If E1 has an unsigned type, the right shift is logical; the
value of the result is the integral part of the quotient of E1 divided by (2 raised to the
power of E2).
Relational Operators
Syntax
relational-expression:
shift-expression
relational-expression < shift-expression
relational-expression > shift-expression
relational-expression <= shift-expression
relational-expression >= shift-expression
Constraints
Both of the operands can have arithmetic type, or both can be pointers to objects that have
the same type.
Semantics
If both of the operands have arithmetic type, the compiler performs the usual arithmetic
conversions.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
406
When two pointers are compared, the result depends on the relative locations in the
address space of the objects pointed to; pointers are compared as if they were unsigned
integers of the appropriate length. If the objects pointed to are not members of the same
aggregate object, the pointer expression P=1 is greater than P, even though P+1 does not
point to a member of the same array object as P.
Each of the operators < (less than), > (greater than), <= (less than or equal to), and >=
(greater than or equal to) yield 1 if the specified relation is true and 0 if it is false. The
result has type int.
Equality Operator
Syntax
equality-expression:
relational-expression
equality-expression == relational-expression
equality-expression != relational-expression
Constraints
Both of the operands can have arithmetic type, or both can be pointers that have the same
type. In addition, one can be an object pointer and the other a pointer to void, or one can
be a pointer and the other a null pointer constant.
Semantics
The == (equal to) and the != (not equal to) operators are analogous to the relational operators except for their precedence.
If two pointers to objects or functions compare equal, they point to the same object or
function, respectively. If one of the operands is a pointer to an object and the other has
type pointer to void, the object pointer is converted to that type.
Bitwise AND Operator (&)
Syntax
AND-expression:
equality-expression
AND-expression & equality-expression
Constraints
Each of the operands has integral type.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
407
Semantics
The compiler performs the usual arithmetic conversions on the operands.
The result of the binary & operator is the bitwise AND of the operands: each bit in the
result is set if, and only if, each of the corresponding bits in the converted operands is set.
The binary & operator is communitive and associative, and an expression involving several binary & operations at the same level can be regrouped.
Bitwise Exclusive OR Operator (^)
Syntax
exclusive-OR-expression:
AND-expression
exclusive-OR-expression ^AND-expression
Constraints
Each operand has integral type.
Semantics
The compiler performs the usual arithmetic conversions on the operands.
The result of the ^ operator is the bitwise exclusive OR of the operands: each bit in the
result is set if, and only if, exactly one of the corresponding bits in the converted operands
is set. The ^ operator is communitive and associative, and an expression involving several
^ operations at the same level can be regrouped.
Bitwise Inclusive OR Operator (|)
Syntax
inclusive-OR-expression:
exclusive-OR-expression
inclusive-OR-expression | exclusive-OR-expression
Constraints
Each operand has integral type.
Semantics
The compiler performs the usual arithmetic conversions on the operands.
The result of the | operator is the bitwise inclusive OR of the operands: each bit in the
result is set if, and only if, at least one of the corresponding bits in the converted operands
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
408
is set. The | operator is communitive and associative, and an expression involving several |
operations at the same level can be regrouped.
Logical AND Operator (&&)
Syntax
logical-AND-expression:
inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression
Constraints
Each operand has scalar type.
Semantics
The && operator yields 1 if both of its operands evaluate to nonzero, or 0 otherwise. The
result has type int.
Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation
and is a sequence point. If the value of the first operand is 0, the second operand is not
evaluated.
Logical OR Operator (||)
Syntax
logical-OR-expression:
logical-AND-expression
logical-OR-expression || logical-AND-expression
Constraints
Each operand has scalar type.
Semantics
The || operator yields 1 if either of its operands evaluates to nonzero, or 0 otherwise. The
result has type int.
Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation and is a
sequence point. If the value of the first operand is nonzero, the second operand is not evaluated.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
409
Conditional Operator (?:)
Syntax
conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
Constraints
The first operand has scalar type. The second and third operands can be any of the following:
•
•
•
•
•
Both arithmetic type
Both structure, union, or pointer type
Both void expressions
One object pointer and one pointer to void
One pointer and one null pointer constant
Semantics
The ?: operator is a sequence point. It evaluates the first operand. If its value is nonzero the
result is the value of the second operand. Otherwise, the result is the value of the third
operand. The types of the operands determine the result.
If both the second and third operands have arithmetic type, the usual arithmetic conversions are performed to bring them to a common type. The result has that type.
•
•
•
If both the operands have structure, union, or pointer type, the result has that type.
•
If one operand is a pointer and the other operand a null pointer constant, the result has
the type of the pointer.
If both the operands are void expressions, the result is a void expression.
If one of the operands is a pointer to void, the other operand is converted to that type
and the result has that type.
Assignment Operators
Syntax
assignment-expression:
conditional-expression
unary-expression assignment-operator assignment-expression
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
410
assignment-operator: one of
=
*=
/=
%=
+=
-=
<<=
>>=
&=
^=
|=
Constraints
An assignment operator has a modifiable lvalue as its left operand.
Semantics
An assignment operator stores a value in the object designated by the left operand. An
assignment expression has the type of the left operand and the value of the left operand
after the assignment, but is not an lvalue. The compiler stores the value of the assignment
expression before using the value.
The order of evaluation of the operands is unspecified.
Simple Assignment
Constraints
Both the operands have arithmetic type or the same structure, union, or pointer type. In
addition, if the left operand is a pointer, either operand can be a pointer to void, or the
right operand can be a null pointer constant.
Semantics
In the simple assignment with =, the value of the right operand is converted to the type of
the left operand and replaces the value of the object designated by the left operand.
If an object is assigned to another object that overlaps in storage with any part of the object
being assigned, the behavior is undefined.
Example
In the program fragment
int f(void) ;
char c ;
/*...*/
/*...*/ ((c = f()) == -1) /*...*/
the int value returned by the function can be truncated when stored in the char, and then
converted back to int width before the comparison. In an implementation in which “plain”
char behaves the same as unsigned char, the result of the conversion cannot be negative, so the operands of the comparison can never compare equal. Therefore, for full portability, you must declare the variable c as int.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
411
Compound Assignment
Constraints
Each operand has arithmetic type consistent with those allowed by the corresponding
binary operator; in addition, for += and -= only, the left operand can be a pointer, in which
case the right operand has integral type.
Semantics
A compound assignment of the form E1 op = E2 differs from the simple assignment
expression E1 = E1 op (E2) only in that the lvalue E1 is evaluated only once.
Comma Operator
Syntax
expression:
assignment-expression
expression , assignment-expression
Semantics
The comma operator is a sequence point. The compiler first evaluates the left operand of a
comma operator as a void expression. Then it evaluates the right operand; the result has
its type and value.
Example
As indicated by the syntax, in contexts where a comma is a punctuator (in lists of argument to functions and lists of initializers), the comma operator as described in this section
appears only in parentheses. Consider the following function call:
f(a, (t=3, t+2), c)
The function has three arguments, the second of which has the value 5.
Constant Expressions
Syntax
constant-expression:
conditional-expression
Constraints
The compiler does not evaluate these operators in any constant expression:
•
UM014418-0205
a function-call operator ( )
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
412
•
•
•
an increment or decrement operator (++ or --)
an assignment operator
a comma operator (,)
An integral constant expression involves only integer, enumeration, and character constants and casts to integral types. The compiler does not evaluate the following:
•
•
•
•
array-subscripting operators ([])
member-access operators (. and -)
the address-of (&) and indirection (*) unary operators
arbitrary casts for integral constant expressions
Further restrictions that apply to the integral constant expressions used in preprocessing
conditional-inclusion directives are discussed later.
For constant expressions in initializers, in addition to integral constant expressions, floating constants and arbitrary casts can be used. Lvalues of objects that have static storage
duration or function identifiers can also specify addresses, either explicitly with the unary
& operator or implicitly for unsubscribed array identifiers or function identifiers.
Semantics
An expression that evaluates to a constant is required in several contexts. To specify the
size of a bit-field member of a structure, the value of an enumeration constant, the size of
an array, or the value of a case constant, the expression is an integral constant expression.
More latitude is permitted for initializers. If the expression is evaluated in the translation
environment, the arithmetic precision and range are at least as great as if the expression
were being evaluated in the execution environment.
DECLARATIONS
This section describes the following:
•
•
•
•
•
•
•
•
UM014418-0205
“Storage-Class Specifiers” on page 413
“Type Specifiers” on page 414
“Structure and Union Specifiers” on page 416
“Enumeration Specifiers” on page 419
“Declarators” on page 420
“Type Names” on page 424
“Type Definitions and Type Equivalence” on page 425
“Initialization” on page 426
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
413
Syntax
declaration:
declaration-specifiers init-declarator-list opt ;
declaration-specifiers:
storage-class-specifier declaration-specifiersopt
type specifier declaration-specifiers opt
init-declarator-list:
init-declarator
init-declarator-list , init-declarator
init-declarator:
declarator
declarator = initializer
Constraints
A declaration declares at least a declarator, a tag, or the members of an enumeration.
Semantics
A declaration specifies the interpretation and attributes of a set of identifiers. A declaration that also causes storage to be reserved for an object or function named by an identifier
is a definition.
The declaration specifiers consist of a sequence of specifiers that indicate the scope, storage duration, and type of the entities that the declarators denote. The init-declarator-list is
a comma-separated sequence of declarators, each of which can have an initializer. The
declarators contain the identifiers (if any) being declared.
Storage-Class Specifiers
Syntax
storage-class specifier:
typedef
extern
static
auto
register
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
414
Constraints
You can declare one storage-class specifier at most.
Semantics
The typedef specifier is called a “storage-class specifier'' for syntactic convenience only.
See “Type Definitions and Type Equivalence” on page 425 for more information. The
meanings of the various scopes and storage durations are discussed in “Scopes of Identifiers” on page 378 and in “Storage Durations of Objects” on page 380.
A declaration with storage-class specifier extern indicates that, if the identifier declared
is referred to, then somewhere in the set of source files that constitutes the entire program,
an external object definition for the given identifier (a definition with file scope) exists. If
the declaration with storage-class specifier extern occurs outside a function, the identifier is declared with file scope and external linkage, and can itself serve as the required
definition as discussed later.
A declaration of an object with storage-class specifier static, auto, or register also serves as
a definition, as it causes an appropriate amount of storage to be reserved. The storage-class
specifier static specifies static storage duration; the storage-class specifiers auto and register specify automatic storage duration.
A declaration with storage-class specifier register is an auto declaration, with a suggestion
that the objects declared be stored in fast-access machine registers if possible. The types of
objects that are stored in such registers and the number of such declarations in each block
that are effective are described in “Operators” on page 387.
The following rules apply to a declaration without a storage-class specifier:
•
•
•
For a function, the meaning is the same as if the storage-class specifier were extern.
For an object declared inside a function or among its formal para-meters, the meaning
is the same as if the storage-class specifier were auto.
For an object declared outside a function, the declaration is an external object
definition.
Type Specifiers
Syntax
type-specifier:
char
short
int
long
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
415
signed
unsigned
const
volatile
void
fract
struct-or-union-specifier
enum-specifier
typedef-name
Note: Float and double are not defined in COMPASS/3XX. fract is a nonstandard language
extension.
Constraints
One of the keywords long or short can be specified in conjunction with int; the meaning is the same if the keyword int is not mentioned.
The keywords signed or unsigned can be specified alone (in which case the presence of
int is implied), or in conjunction with int or its short or long varieties, or with char.
The keyword long can be specified in conjunction with double.
The keywords const and volatile can be specified alone (in which case the presence
of int is implied), or in conjunction with other types of specifiers.
Only const and volatile can be specified in conjunction with a structure, union, or
enumeration specifier, or with a typedef name.
Otherwise, at most one type specifier can be given in a declaration.
Semantics
The characteristics of the const and volatile type modifiers are discussed in “Other
Operands” on page 390. Specifiers for structures, unions, and enumerations are discussed
in “Structure and Union Specifiers” on page 416. Declarations of typedef names are discussed in “Type Definitions and Type Equivalence” on page 425. The characteristics of
the other types are discussed in “Types” on page 380.
If no type specifiers exist in a declaration, the type is taken to be int.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
416
Structure and Union Specifiers
Syntax
struct-or-union-specifier:
struct-or-union identifier opt { struct-declaration-list }
struct-or-union identifier
struct-or-union:
struct
union
struct-declaration-list:
struct-declaration
struct-declaration-list struct-declaration
struct-declaration:
type-specifier-list struct-declarator-list ;
type-specifier-list:
type-specifier
type-specifier-list type-specifier
struct-declarator-list:
struct-declarator
struct-declarator-list , struct-declarator
struct-declarator:
declarator
declarator opt : constant-expression
Constraints
A structure or union does not contain an instance of itself, but can contain a pointer to an
instance of itself.
The constant expression that specifies the width of a bit-field has integral type and nonnegative value. The width of a bit-field does not declare more storage than an ordinary
object of the same type.
Semantics
As discussed in “Types” on page 380, a structure is a type consisting of an ordered
sequence of named members, and a union is a type consisting of an overlapping sequence
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
417
of named members. A union is similar to a structure whose members overlap and whose
size is sufficient to contain the largest of its members. At most one of the members can be
stored in a union object at any time.
Structure and union specifiers have the same form.
The presence of a struct-declaration-list in a struct-or-union-specifier declares a new type.
The struct-declaration-list is a sequence of declarations for the members of the structure
or union.
A member of a structure or union can have any previously declared type of an object,
except the type being declared. In addition, a member can be declared to consist of a specified number of bits, including a sign bit, if any. Such a member is called a bit-field; its
width is preceded by a colon.
A bit-field can have type int, unsigned int, or signed int. The compiler treats the
high-order bit position of a “plain” int bit-field as a sign bit.
The compiler can allocate any bit-field small enough to fit in an int. If enough space
remains, a bit-field that follows another bit-field is packed into adjacent bits of the same
int. If insufficient space remains, a bit-field that does not fit is put into the next int.The
order of allocation of bit-fields within an int is high-order to low-order.
A bit-field declaration with no declarator, but only a colon and a width, indicates an
unnamed bit-field. As a special case of this, a bit-field with a width of 0 indicates that no
further bit-field is to be packed into the unit in which the previous bit-field, if any, was
placed.
Each non-bit-field member of a structure or union object is aligned as described in “Type
Definitions and Type Equivalence” on page 425.
Within a structure object, the bit-field members and the units in which bit-fields reside
have addresses that increase in the order in which they are declared. A pointer to a structure object, suitably cast, points to its initial member or, if it is a bit-field, to the unit in
which it resides. There might therefore be unnamed holes within or at the end of a structure, but not at its beginning, nor more than necessary to achieve the appropriate alignment.
A pointer to a union object, suitably cast, points to each of its members, or if a member is
a bit-field, to the unit in which it resides.
Structure and Union Tags
A complete structure or union specifier of the form
struct-or-union identifier { struct-declaration-list }
declares the identifier to be the tag of the structure or union specified by the list. A subsequent declaration in the same scope can then use the tag, but the bracketed declaration list
is omitted.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
418
An incomplete structure or union specifier of the form
struct-or-union identifier
declares a tag that can be used only when the size of an object of the specified type is not
needed, as follows:
•
•
when a typedef name is declared to be a synonym for a structure or union
when a pointer to or a function returning a structure or union is being declared
The specification must be complete before such a function is called or defined. Another
declaration of the tag in the same scope (but not in an enclosed block, which can declare a
new type known only within that block) can give the complete specification. A vacuous
structure or union specifier of the form
struct-or-union identifier ;
supersedes any prior declaration in an enclosing scope.
Examples
This mechanism allows you to declare a self-referential structure, as in the following
example:
struct tnode {
char tword [20];
int count;
struct tnode *left;
struct tnode *right;
};
This code segment declares a structure that contains an array of 20 characters, an integer,
and two pointers to objects of the same type. Once this structure is declared, the following
declaration
struct tnode s, *sp;
defines s to be the object of the given type and sp to be a pointer to an object of the given
type. With these declarations,
•
•
•
sp-count refers to the count member of the object to which sp points
s.left refers to the left struct tnode pointer of s
s.right-tword[0] refers to the initial character of the tword member of the right
struct tnode pointed to from s
The following illustrates the use of prior declaration of a tag to declare a pair of mutuallyreferential structures:
struct s1 { struct s2 *s2p; /*...*/ }; /* D1 */
struct s2 { struct s1 *s1p; /*...*/ }; /* D2 */
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
419
These declarations specify a pair of structures that contain pointers to each other. If s2
were already declared as a tag in an enclosing scope, the declaration D1 refers to it, not to
the tag s2 declared in D2. To eliminate this context sensitivity, the vacuous declaration
struct s2;
can be inserted ahead of D1. This declares a new tag s2 in the inner scope; the declaration
D2 then completes the declaration of the new type.
Enumeration Specifiers
Syntax
enum-specifier:
enum identifier opt { enumerator-list }
enum identifier
enumerator-list:
enumerator
enumerator-list , enumerator
enumerator:
enumeration-constant
enumeration-constant = constant-expression
Semantics
The identifiers in an enumerator list are declared as constants of type int and can appear
wherever constants are permitted. If the first enumerator has no =, the values of the corresponding constants begin at 0 and increase by 1 in the order in which they are declared,
until an enumerator with = appears. An enumerator with = gives the associated enumeration constant the value indicated; subsequent enumeration constants with no = continue
the progression from the earlier ascribed value (and can duplicate other values in the same
enumeration).
The scope of an enumeration constant begins after its declaration and ends with the scope
of the enumeration of which it is a member. The identifiers of enumeration constants in the
same scope shall all be distinct from each other and from other identifiers declared in ordinary declarators.
The role of the identifier in the enum-specifier is analogous to that of the tag in a structor-union-specifier: it names a particular enumeration.
An object that has an enumeration type behaves like an int in an expression. The compiler can use the set of values in the enumeration to determine whether to allocate less
storage than an int.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
420
Example
enum hue { chartreuse, burgundy, claret=20, winedark };
/*...*/
enum hue col, *cp;
/*...*/
col = claret;
cp = &col;
/*...*/
/*...*/ (*cp != burgundy) /*...*/
makes hue the tag of an enumeration, and then declares col as an object that has that type
and cp as a pointer to an object that has that type. The enumerated values are in the set
{ 0, 1, 20, 21 }.
Declarators
Syntax
declarator:
pointer opt direct-declarator
direct-declarator:
identifier
( declarator )
direct-declarator [ constant-expression opt ]
direct-declarator (parameter-type-list )
direct-declarator ( identifier-list opt )
pointer:
* type-specifier-list opt
* type-specifier-list opt pointer
parameter-type-list:
parameter-list
parameter-list , ...
parameter-list:
parameter-declaration
parameter-list , parameter-declaration
parameter-declaration:
declaration-specifiers declarator
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
421
type-name
identifier-list:
identifier
identifier-list , identifier
Semantics
Each declarator declares one identifier, and asserts that when a construction of the same
form as the declarator appears in an expression, it yields an entity of the indicated scope,
storage duration, and type.
If an unadorned identifier appears as a declarator, it has the type indicated by the type
specifiers heading the declaration.
A declarator in parentheses is identical to the unadorned declarator, but the binding of
complex declarators can be altered by parentheses.
In the following subsections, consider a declaration
T D1
where T is a type specifier (such as int) and D1 is a declarator. Suppose this declaration
makes the identifier have type type-specifier T, where the type-specifier is empty if D1 is
just a plain identifier (so that the type of x in int x is just int).
Pointer Declarators
Constraints
Only const and volatile can appear in the list of type specifiers.
Semantics
If D1 has the form
* type-specifier-list opt D
the contained identifier is a type-specifier pointer to T. If the type specifier list includes
const, the identifier is a constant pointer. If the type specifier list includes volatile, the
identifier is a volatile pointer.
Examples
The following pair of declarations demonstrates the difference between a variable pointer
to a constant value and a constant pointer to a variable value:
const int *ptr_to_constant;
int *const constant_ptr;
The contents of the array pointed to by ptr_to_constant must not be modified, but
ptr_to_constant itself can be changed to point to another const int. Similarly, the
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
422
contents of the array pointed to by constant_ptr can be modified, but constant_ptr
itself always points to the same location.
The declaration of the constant pointer constant_ptr can be clarified by including a
definition for a pointer to int.
typedef int *int_ptr;
const int_ptr constant_ptr;
Array Declarators
Constraints
The constant expression that specifies the size of an array has integral type and value
greater than zero. It is present, except that the first size can be omitted when an array is
being declared as a formal parameter of a function, or when the array declaration has storage-class specifier extern and the definition that actually allocates storage is given elsewhere. It can also be omitted when the declarator is followed by initialization; in this case,
the size is determined by the number of initializers supplied.
Semantics
If D1 has the form
D [constant-expression opt ]
the contained identifier is an array of type-specifier with T elements. When several array
of specifications are adjacent, a multi-dimensional array is declared.
Two declarations of an array with file scope, one of which has a missing first constant
expression and the other of which has a specified size, are compatible; the size of the array
is known from the completion of the declarator that specifies the size to the end of the
source file.
Examples
long fa [11], *afp[17];
declares an array of long numbers and an array of pointers to long numbers.
There are distinctions between the following declarations:
extern int *x;
extern int y[];
The first declares x to be a pointer to int; the second declares y to be an array of int of
unspecified size, the storage for which is defined elsewhere.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
423
Function Declarators (Including Prototypes)
Constraints
All declarators of a particular function must agree in the type returned.
Semantics
If D1 has the form
D(parameter-type-list)
or
D(identifier-list opt )
the contained identifier is a type-specifier function returning T.
A parameter type list declares the types of, and optional identifiers for, the formal parameters of the function. If the list terminates with an ellipsis (, ...), no information about the
number of types of the parameters after the comma is supplied.
In a declaration that is a function definition, identifiers are present for every parameter.
The only storage-class specifier allowed is register, which suggests that the corresponding
parameter be stored in a machine register if possible. If the list is empty, the function has
no parameters.
In a declaration that is not a function, any identifier declared in the list has function prototype scope, which extends to the end of the declaration. The only storage-class specifier
allowed is register, which is ignored. The special case of void as the only item in the list
specifies that the function has no parameters.
The definition and every prototype of a function shall agree in the number and types of the
parameters and in the use of the ellipsis terminator. The parameter type checking includes
agreement on the number of dimensions of arrays and on the bounds for each dimension
except the first. Function declarators with empty lists can also appear.
An identifier list declares only the identifiers of the formal parameters of the function. If
the list is empty in a function declaration that is not part of a function definition, no information about the number or types of the parameters is supplied. If the list is empty in a
function declaration that is part of a function definition, the function has no parameters.
Examples
The following declaration
static int f(void), *fip(), (*pfi) ();
declares a function f with no parameters returning an int, a function fip with no parameter-type information returning a pointer to an int, and a pointer pfi to a function with
no parameter-type information returning an int. It is especially useful to compare the last
two.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
424
The binding of *fip( ) is *(fip( )), so that the declaration suggests, and the same
construction in an expression requires, the calling of a function fip, and then using indirection through the pointer result to yield an int. In the declarator (*pfi)( ), the extra
parentheses are necessary to indicate that indirection through a pointer to a function yields
a function locator, which is then used to call the function; it returns an int.
The identifiers of the functions f and fip are declared as having file scope (not program
scope) and internal linkage. The pointer pfi is declared as having file scope and internal
linkage if the declaration is outside of any function, block scope and no linkage if the declaration is inside a function.
Here are two more intricate examples.
int (*apfi[])(int *x, int *y);
declares an array apfi of pointers to functions returning int. Each of these functions has
two parameters that are pointers to int. The identifiers x and y are declared for descriptive purposes only and go out of scope at the end of the declaration apfi. The declaration
int (*fpfi(int (*)(long), int))(int, ...);
declares a function fpfi that returns a pointer to a function returning an int. The function fpfi has two parameters; a pointer to a function returning an int (with one parameter
of type long), and an int. The pointer returned by fpfi points to a function that has at
least one parameter, which has type int.
Type Names
Syntax
type-name:
type-specifier-list abstract-declarator opt
abstract-declarator:
pointer
pointer opt direct-abstract-declarator
direct-abstract-declarator:
( abstract-declarator )
direct-abstract-declarator opt [ constant-expression opt ]
direct-abstract-declarator opt ( parameter-type-list opt )
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
425
Semantics
You might need to specify a type in several situations. Examples include specifying the
following:
•
•
•
A type conversion with cast (See “Multiplicative Operators” on page 402.)
The type of the operand of the sizeof operator (See “Sizeof Operator” on page 401.)
The type of a formal parameter in a function declarator (See “Function Declarators
(Including Prototypes)” on page 423.)
You can specify a type with a type name, which is syntactically a declaration for an object
of that type that omits the identifier of the object.
Examples
Declaration
Type
int
int
int *
Pointer to int
int *[3]
Array of three pointers to int
int (*) [3]
Pointer to an array of three ints
int *( )
Function with no parameter type information
returning a pointer to int
int (*)(void)
Pointer to a function with no parameters
returning an int
int (*const [])(unsigned int, ...) Array of an unspecified number of constant
pointers to functions, each with one
parameter that has type unsigned int and
an unspecified number of other parameters,
returning an int.
Type Definitions and Type Equivalence
Syntax
typedef-name:
identifier
Semantics
With the scope of a declaration whose storage-class specifier is typedef, each identifier
declared becomes equivalent to a type specifier naming the type associated with the identifier as described in “Declarators” on page 420.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
426
A typedef declaration does not introduce a brand-new type, but a synonym for a type that
can be specified in another way. Two types are the same if they have the same ordered
set of type specifiers and abstract declarators, either directly or through typedefs. Two
structures or unions are different if they have no names or different names, taking tags and
typedef synonyms into account, even if their members are identical.
A typedef name shares the same name space as other identifiers declared in ordinary
declarators. It can be redeclared in an inner block, but the type cannot be omitted in the
inner declaration.
Examples
After
typedef int MILES, KLICKSP();
typedef struct { double re, im; } complex;
the following constructions
MILES distance;
extern KLICKSP *metricp;
complex x;
complex z, *zp;
are all valid declarations. The type of distance is int, that of metricp is “pointer to function
with no parameter-type information returning int,” and that of x and z is the specified
structure; zp is a pointer to such a structure. The object distance is considered to have
exactly the same type as any other int object.
After the declarations
typedef struct s1 { int x; } t1, *tp1;
typedef struct s2 { int x; } t2, *tp2;
type t1 and the type pointed to by tp1 are equivalent to each other and to the type struct s1,
but different from the types struct s2 and t2, the type pointed to by tp2, and type int.
Initialization
Syntax
initializer:
assignment-expression
{ initializer-list }
{ initializer-list , }
initializer-list:
initializer
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
427
initializer-list , initializer
Semantics
Any declaration that defines an object can include an initializer that specifies its initial
value. The initializers in a declaration list are evaluated in the order they appear in the
source file.
For a union object, the initializer initializes the member that appears first in the declaration list of the union type.
An object that has static storage duration can be initialized by constant expressions only. If
such an object is not initialized explicitly, it is initialized implicitly as if every member
that has arithmetic type were assigned 0 and every member that has pointer type were
assigned a null pointer constant.
Except as noted for aggregates, an object that has automatic storage duration can be
initialized by arbitrary expressions involving constants, previously declared identifiers,
function calls, and assignments. Such an object is not initialized implicitly; if the value is
used before one is assigned, the behavior is undefined.
If the declared object is a scalar, the initializer is a single expression, optionally in braces.
The initial value of the object is that of the expression; the same conversions as for assignment are performed.
Initialization of Aggregate Objects
If the declared object is a structure object that has automatic storage duration, the initializer can be a single expression that has the same type. The initial value of the object is that
of the expression.
If the declared object is an array of chars, the initializer can be a string literal. Successive
characters of the string literal (including the terminating null character if there is room or
if no size for the array is specified) initialize the members of the array.
Otherwise, the initializer is a brace-enclosed list of initializers for the members of the
aggregate, written in increasing subscript or member order. All expressions in such a list
are constant expressions.
If the aggregate contains members that are aggregates, these rules apply recursively to the
subaggregates. If the initializer of a subaggregate begins with a left brace, the succeeding
initializers initialize the members of the subaggregate. Otherwise, only enough initializers
from the list are taken to account for the members of the first subaggregate; any remaining
initializers are left to initialize the next member of the subaggregate of which the current
aggregate is a part.
No more initializers exist in a list than there are members of an aggregate. If fewer initializers exist in a list than there are members of an aggregate, the remainder of the aggregate
is initialized as if it had storage duration.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
428
Examples
The declaration
int x[] = { 1, 3, 5 };
defines and initializes x as a one-dimensional array object that has three members, since
no size was specified and three initializers exist.
int y[4]
{
{
{
};
[3] =
1, 3,
2, 4,
3, 5,
{
5 },
6 },
7 },
is a definition with a fully bracketed initialization: 1, 3, and 5 initialize the first row of the
array object y[0], namely y[0][0], y[0][2]. Likewise the next two lines initialize y[1] and
y[2]. The initializer ends early, so y[3] is initialized with zeros. The following code
achieves the same effect:
int y[4] [3] = {
1, 3, 5, 2, 4, 6, 3, 5, 7
};
The initializer for y[0] does not begin with a left brace, so three items from the list are
used. Likewise the next three are taken successively for y[1] and y[2]. Also,
int z[4] [3] = {
{ 1 }, { 2 }, { 3 }, { 4 }
};
initializes the first column of z as specified and initializes the rest with zeros.
struct { int a[3], b; } w[] = { { 1 }, 2 };
is a definition with a partly bracketed initialization, which is not recommended programming practice. It defines an array with two member structures: w[0] .a[0] is 1 and w[1]
.a[0] is 2. All the other elements are zero.
Finally, the declaration
char s[] = "abc", t[3] = "abc";
defines character array objects s and t whose members are initialized with string literals.
This declaration is identical to
char s[] = {‘a', ‘b', ‘c', ‘\0' },
t[] = { ‘a', ‘b', ‘c' };
The contents of the arrays are modifiable. However, the declaration
char *p = "abc";
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
429
defines a character pointer p that is initialized to point to a character array object whose
members are initialized with a string literal. If an attempt is made to use p to modify the
contents of the array, the behavior is undefined.
STATEMENTS
The following types of statements are described in this section:
•
•
•
•
•
•
“Labeled Statements” on page 430
“Compound Statement (or Block)” on page 430
“Expression and Null Statements” on page 431
“Selection Statements” on page 432
“Iteration Statements” on page 433
“Jump Statements” on page 434
Syntax
statement:
labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement
Semantics
A statement specifies an action to perform. Except as indicated, statements are executed in
sequence.
A full expression is an expression that is not part of another expression. Each of the following is a full expression:
•
•
•
•
an initializer of an object that has automatic storage duration
the expression in an expression statement
the controlling expression of an selection statement (if or switch)
the controlling expression of an iteration statement (while, do, or for)
Completion of the evaluation of a full expression is a sequence point.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
430
Labeled Statements
Syntax
labeled-statement:
identifier : statement
case constant-expression : statement
default : statement
Constraints
A named label can be used only as a target of a goto statement. A case or default label
can appear only in a switch statement. The constraints on such labels are discussed under
the switch statement.
Semantics
Any statement can be preceded by a prefix that declares an identifier as a label name.
Labels in themselves do not alter the flow of control, which continues unimpeded across
them.
Compound Statement (or Block)
Syntax
compound-statement:
{ declaration-list opt statement-list opt }
declaration-list:
declaration
declaration-list declaration
statement-list:
statement
statement-list statement
Constraints
An object declared extern inside a block is not initialized in the declaration as storage
since it is defined elsewhere.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
431
Semantics
A compound statement (also called a block) allows a set of statements to be grouped into
one syntactic unit, which can have its own set of declarations and initializers (as discussed
in “Storage Durations of Objects” on page 380.
Expression and Null Statements
Syntax
expression-statement:
expression opt ;
Semantics
An expression statement, consisting of an expression followed by a semicolon, is evaluated for its side effects, such as assignments and function calls.
A null statement, consisting of just a semicolon, has no expression and performs no operations.
Examples
If a function call is evaluated as an expression statement for its side effects only, the discarding of its value can be made explicit by converting the expression to a void expression with a cast:
int p(int);
/*...*/
(void) p(0);
In the program fragment
char *s;
/*...*/
while (*s++ != ‘\0')
;
a null statement supplies an empty loop body to the iteration statement.
A null statement can also carry a label just before the closing } of a compound statement.
while (loop1) {
/*...*/
while (loop2) {
/*...*/
if (want_out)
goto end_loop1;
/*...*/
}
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
432
/*...*/
end_loop1: ;
}
Selection Statements
Syntax
selection-statement:
if ( expression ) statement
if ( expression ) statement else statement
switch ( expression ) statement
Semantics
A selection statement selects among a set of statements depending on the value of a controlling expression.
If Statement
Constraints
The controlling expression of an if statement has scalar type.
Semantics
In both forms, the first substatement is executed if the expression evaluates to nonzero. In
the else form, the second substatement is executed if the expression evaluates to zero. If
the first substatement is reached through a label, the second substatement is not executed.
An else is associated with the lexically immediately preceding else-less if that is in the
same block (but not in the enclosed block).
Switch Statement
Constraints
The controlling expression of a switch statement and the constant expression of each
case label has integral type. No two of the case constants in the same switch statement
can have the same value after conversion. There can be at most one default label in a
switch statement (but any enclosed switch statement can also have a default label).
Semantics
A switch statement causes control to jump to, into, or past the statement that is the
switch body, depending on the value of a controlling expression and the values of any
case prefixes on or in the switch body. If there are nested switch statements within the
switch body, any default or case labels in them are ignored.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
433
The integral promotions are performed on the controlling expression. The constant expression in each case label is converted to the type of the promoted controlling expression. If
a converted value matches that of the promoted controlling expression, control jumps to
the statement following the matched case prefix. Otherwise, if there is a default label,
control jumps to the labeled statement. If no converted case constant matches and there is
no default label, none of the statements in the switch body are executed.
Iteration Statements
Syntax
iteration-statement:
while ( expression ) statement
do statement while ( expression ) ;
for ( expression opt ; expression opt ; expression opt ) statement
Constraints
The controlling expression of an iteration statement has scalar type.
Semantics
An iteration statement repeatedly executes a statement called the loop body until the controlling expression evaluates to zero.
While Statement
The evaluation of the controlling expression takes place before each execution of the loop
body.
Do Statement
The evaluation of the controlling expression takes place after each execution of the loop
body.
For Statement
Except for the behavior of a continue statement in the loop body, the statement
for (expression-1 ; expression-2 ; expression-3 ) statement
is equivalent to
expression-1 ;
while (expression-2) {
statement
expression-3 ;
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
434
}
Thus, expression-1 specifies initialization for the loop;
expression-2 specifies an evaluation made before each iteration, such that execution of the
loop continues until the expression evaluates to zero; and
expression-3 specifies an operation (such as incrementing) that is performed after each
iteration.
Both expression-1 and expression-3 can be omitted, or can have any type, or can be void
expressions. An omitted expression-2 is replaced by a nonzero constant.
Jump Statements
Syntax
jump-statement:
goto identifier ;
continue ;
break ;
return expression opt ;
Semantics
A jump statement causes an unconditional jump to another place.
Goto Statement
Constraints
The identifier in a goto statement names a label located somewhere in the current function.
Semantics
A goto statement causes an unconditional jump to the named label in the current function.
Continue Statement
Constraints
A continue statement can appear only in a loop body.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
435
Semantics
A continue statement causes a jump to the loop-continuation portion of the smallest
enclosing iteration statement; that is, to the end of the loop body. More precisely, in each
of the statements
while (/*...*/) { do {
/*...*/
/*...*/
continue;
continue;
/*...*/
/*...*/
contin: ;
contin: ;
}
} while (/*...*/);
for (/*...*/) {
/*...*/
continue;
/*...*/
contin: ;
}
unless the continue statement shown is in an enclosed iteration statement (in which case
it is interpreted within that statement), it is equivalent to goto contin:. (Following the
contin: is a null statement.)
Break Statement
Constraints
A break statement can appear only in a switch body or loop body.
Semantics
A break statement terminates execution of the smallest enclosing switch or iteration
statement.
Return Statement
Constraints
A return statement with an expression cannot appear in a function declared as returning
type void.
Semantics
A return statement terminates execution of the current function and returns control to its
caller. A function can have any number of return statements, with and without expressions.
If a return statement with an expression is executed, the value of the expression is
returned to the caller. If the expression has a type different from that of the function in
which it appears, it is converted as if it were assigned to an object of that type.
If a return statement without an expression is executed, and the value of the function call
is used by the caller, the behavior is undefined. Reaching the } that terminates a function is
equivalent to executing a return statement without an expression.
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
436
EXTERNAL DEFINITIONS
This section covers the following topics:
•
•
“Function Definitions” on page 436
“External Object Definitions” on page 439
Syntax
file:
external-definition
file external-definition
external-definition:
function-definition
declaration
Constraints
If present, the storage-class specifier in an external definition shall be extern (which is
the default and declares external linkage) or static (which declares internal linkage). As
with other declarations, if there are no type specifiers the type shall be taken to be int.
Semantics
The unit of program text is a file, which consists of a sequence of external definitions of
functions and objects (and other declarations, such as type declarations) described as
“external” because they appear outside of any function. The syntax of an external definition is the same as that of a declaration, except that the code for a function (the function
body) appears outside of any other function.
An external definition implicitly declares its identifier to have file scope and static storage
duration.
Function Definitions
Syntax
function-definition:
declaration-specifiers opt declarator function-body
function-body:
declaration-list opt compound-statement
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
437
Constraints
As specified only by the declarator portion of a function definition, the first identifier
(which is the name of the function) has type function.
If the declarator is a function prototype declarator, no declaration list can follow. If the
declarator is an identifier list, only the identifiers it names can be declared in the declaration list. An identifier declared as a typedef name shall not be redeclared as a formal
parameter. The only storage-class specifier allowed in the declaration of a formal parameter is register.
Semantics
The declarator in a function definition specifies the name of the function being defined
and lists the identifiers of its formal parameters. If the declarator has the form of a function
prototype declarator, the list also declares the types of all the formal parameters: such a
declarator also serves as a function prototype. If the declarator is an identifier list, the
types of the formal parameters can be declared in a following declaration list. Any formal
parameter whose type is not declared in the declaration list is assumed to have type int.
If a function that accepts a variable number of arguments is defined without the ellipsis
notation in its prototype, the behavior is undefined.
If any formal parameter is declared with a type that is affected by the default argument
conversions, the following applies.
•
If a function prototype is in scope when the function is defined, and a call is executed
for which no semantically equivalent function prototype is in scope, the behavior is
undefined.
•
If no function prototype is in scope when the function is defined, and a call is executed
for which a function prototype is in scope that declares other than the appropriate
widened types (according to the default argument conversions), the behavior is
undefined.
•
On entry to the function the value of the argument expression is converted to the type
of the formal parameter, as if by assignment to the formal parameter.
Because array expressions and function identifiers as arguments are always converted to
pointers before the call, a declaration of a formal parameter as an array of type always is
adjusted to a pointer to type, and a declaration of a formal parameter as a function returning type is always adjusted to a pointer to a function returning type.
Each formal parameter is treated as having automatic storage duration and is an lvalue.
The layout of the storage for formal parameters is unspecified.
Examples
extern int max (int a, int b)
{
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
438
return
a
>
b
?
a
:
b;
}
Here extern is the storage-class specifier and int is the type specifier (each of which can
be omitted as those are the defaults); max(int a, int b) is the function declarator; and
{ return
a
>
b
?
a
:
b; }
is the function body. The following equivalent definition uses the identifier-list form for
the parameter declarations:
extern int max(a, b)
int a, b;
{
return a > b
}
?
a
:
b;
Here int a, b; is the declaration list for the formal parameters, which can be omitted as
those are the defaults.
The reason for this constraint is so that the type in a function definition cannot be inherited
from a typedef:
typedef int F(void);
/* type F is "function of no arguments returning int" */
F f { /*...*/ }
/* WRONG: implies that f returns a function */
int f(void) { /*...*/ }
/* RIGHT: f has the same type as F */
int g() { /*...*/ }
/* RIGHT: g has the same type as F */
F *f(void) { /*...*/ }
/* f returns a pointer to a function */
F * ((f))(void) { /*...*/ }
/* same: parentheses irrelevant */
int (*fp)(void);
/* fp points to a function that has type F */
F *Fp;
/* Fp points to a function that has type F */
To pass one function to another, you might say
int f(void);
/*...*/
g(f);
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
439
f is declared explicitly in the calling function, as its appearance in the expression g(f)
was not followed by (. Then the definition of g might read
g(int (*funct)(void))
{
/*...*/ (*funct)() /*...*/
}
or, equivalently,
g(int func(void))
{
/*...*/ func() /*...*/
}
External Object Definitions
Constraints
One external definition must exist for each object declared with the storage-class specifier
extern that is referred to in any way.
Semantics
A declaration of an identifier of an object outside of any function that includes an initializer constitutes the definition of the object.
A declaration of an identifier of an object outside of any function without an initializer,
and without a storage-class specifier or with the storage-class specifier static, constitutes a
tentative definition. If a definition is encountered later in the source file, all tentative definitions are taken to be declarations of the same object. If no subsequent definition is
encountered, the first tentative definition is taken to be a definition with initializer equal to
0.
Examples
int i1 = 1; /* definition, external linkage */
static int i2 = 2; /* definition, internal linkage */
extern int i3 = 3; /* definition, external linkage */
int i4; /* tentative definition, external linkage */
static int i5; /* tentative definition, internal linkage */
int i1; /* valid tentative definition, refers to previous */
int i2; /* violates A.3.2.2, linkage disagreement */
int i3; /* valid tentative definition, refers to previous */
int i4; /* valid tentative definition, refers to previous */
int i5; /* violates A.3.2.2, linkage disagreements */
extern int i1; /* refers to previous, linkage is external */
extern int i2; /* refers to previous, linkage is internal */
extern int i3; /* refers to previous, linkage is external */
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
440
extern int i4; /* refers to previous, linkage is external */
extern int i5; /* refers to previous, linkage is internal */
UM014418-0205
A ANSI C Language
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
441
B ANSI C Preprocessing Directives
This appendix describes the ANSI C preprocessor commands supported by the
eZ80Acclaim! developer’s environment ANSI C-Compiler. The following topics are
covered:
•
•
•
•
•
•
•
•
“Conditional Inclusion” on page 443
“Source File Inclusion” on page 444
“Macro Replacement” on page 446
“Line Control” on page 451
“Error Directive” on page 451
“Pragma Directive” on page 451
“Null Directive” on page 452
“Predefined Macros” on page 452
A preprocessing directive consists of a sequence of preprocessing tokens that begins with
a # preprocessing token that is the first character in the source file (after any white space
containing no new-line characters) or that follows white space containing at least one newline character, and ended by the next new-line character.
SYNTAX
preprocessing-file:
group opt
group:
group-part
group group-part
group-part:
pp-tokens opt new-line
if-section
control-line
if-section:
if-group elif-group opt else- group opt endif-line
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
442
if-group:
# if
constant-expression new-line group opt
# ifdef
identifier new-line group opt
# ifndef
identifier new-line group opt
elif-groups:
elif-group
elif-groups elif-group
elif-group:
# elif
constant-expression new-line group opt
else-group:
# else
new-line group opt
endif-line:
# endif
new-line
control-line:
# include
pp-tokens new-line
# define
identifier replacement- list new-line
# define
identifier lparen identifier- list opt ) replacement-list new- line
# undef
identifier new-line
# line
pp-tokens new-line
# error
pp-tokens opt new-line
# pragma
pp-tokens opt new-line
#
new-line
lparen:
the left-parenthesis character without preceding white space
replacement-list:
pp-tokens opt
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
443
pp-tokens:
preprocessing-token
pp-tokens preprocessing-token
new-line:
the new-line character
CONSTRAINTS
The only white-space characters that can appear between preprocessing tokens within a
preprocessing directive are space and horizontal-tabs.
SEMANTICS
The implementation can process and skip sections of source files conditionally, include
other source files, and replace macros. These capabilities are called preprocessing,
because conceptually they occur before translation of the resulting translation unit.
The preprocessing tokens within a preprocessing directive are not subject to macro expansion unless otherwise stated.
CONDITIONAL INCLUSION
Constraints
Constant expressions are discussed in “Constant Expressions” on page 411. Additional
restrictions apply to a constant expression that controls conditional inclusion. The expression shall be an integral constant expression that shall not contain a sizeof operator, a cast,
or an enumeration constant. It can contain unary expressions of the form
defined identifier
or
defined ( identifier )
which evaluate to 1 if the identifier is currently defined as a macro name (that is, if it is
predefined or if it has been the subject of a #define preprocessing directive without an
intervening #undef directive). If not, the expression evaluates to 0.
Each preprocessing token that remains after all macro replacements have occurred is in the
lexical form of a token.
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
444
Semantics
Preprocessing directives of the forms
# if
constant-expression new-line group opt
# elif
constant-expression new-line group opt
check whether the controlling constant expression evaluates to nonzero.
Before evaluation, macro invocations in the list of preprocessing tokens that become the
controlling constant expression are replaced (except for those macro names modified by
defined), just as in normal text. The defined operator explicitly appears in the original
list of preprocessing tokens. After all replacements are finished, the resulting preprocessing tokens are converted into tokens. Then, before the controlling constant expression is
evaluated, all remaining identifiers are replaced with OL and each integer constant not
already suffixed with l or L is considered to be additionally suffixed with L. This includes
interpreting character constants, which might involve converting escape sequences into
characters.
Preprocessing directives of the forms
# ifdef
identifier new-line group opt
# ifndef
identifier new-line group opt
check whether the identifier is or is not currently defined as a macro name. Their conditions are equivalent to #if defined identifier and #if !defined identifier respectively.
Each directive's condition is checked in order. If it evaluates to false (zero), the group that
it controls is skipped. Directives are processed only through the name that determines the
directive in order to keep track of the level of nested conditionals; the rest of the directives'
preprocessing tokens are ignored, as are the other preprocessing tokens in the group. Only
the first group whose control condition evaluates to true (nonzero) is processed. If none of
the conditions evaluates to true, and there is a #else directive, the group controlled by the
#else is processed; lacking a #else directive, all the groups until the #endif are
skipped.
SOURCE FILE INCLUSION
Constraints
A #include directive identifies a header or source file that the implementation can
process.
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
445
Semantics
A preprocessing directive of the form
# include <h-char-sequence> new- line
searches a sequence of places for a header identified uniquely by the specified character
sequence between the < and > delimiters, and causes the replacement of that directive by
the entire contents of the header.
A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the source file identified
by the specified character sequence between the " delimiters. The named source file is
searched for. If this search fails, the directive is reprocessed as if it read
# include <h-char-sequence> new- line
with the identical contained character sequence (including > characters, if any) from the
original directive.
A preprocessing directive of the form
# include pp-token new-line
(that does not match one of the two previous forms) is permitted. The preprocessing
tokens after include in the directive are processed just as in normal text. (Each identifier
currently defined as a macro name is replaced by its replacement list of preprocessing
tokens.) The directive resulting after all replacements matches one of the two previous
forms.
A #include preprocessing directive can appear in a source file that has been read
because of a #include directive in another file.
Examples
The most common uses of #include processing directives are as in the following:
#include <stdio.h>
#include "myprog.h"
This example illustrates a macro-replaced #include directive.
#if VERSION == 1
#define INCFILE ‘‘vers1.h''
#elif VERSION == 2
#define INCFILE ‘‘vers2.h'' /* and so on */
#else
‘‘versN.h'' #define INCFILE
#endif
#include INCFILE
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
446
MACRO REPLACEMENT
Constraint
Two replacement lists are identical if, and only if, the preprocessing tokens in both have
the same number, ordering, spelling, and white-space separation, where all white-space
separations are considered identical.
An identifier currently defined as a macro without use of lparen (an object-like macro)
can be redefined by another #define preprocessing directive provided, that the second
definition is an object-like macro definition and the two replacement lists are identical.
An identifier currently defined as a macro using lparen (a function-like macro) can be
redefined by another #define preprocessing directive provided, that the second definition is a function-like macro definition that has the same number and spelling of parameters, and the two replacement lists are identical.
The number of arguments in an invocation of a function-like macro agrees with the number of parameters in the macro definition, and a ) preprocessing token exists that terminates the invocation.
A parameter identifier in a function-like macro must be uniquely declared within its scope.
Semantics
The identifier immediately following the define is called the macro name. Any whitespace characters preceding or following the replacement list of preprocessing tokens is not
considered part of the replacement list for either form of macro.
If a # preprocessing token, followed by a name, occurs lexically at the point at which a
preprocessing directive can begin, the name is not subject to macro replacement.
A preprocessing directive of the form
# define identifier replacement-list new-line
defines a function-like macro that causes each subsequent instance of the macro name to
be replaced by the replacement list of preprocessing tokens that constitute the remainder
of the directive.
A preprocessing directive of the form
# define identifier lparen identifier-list opt ) replacement-list new-line
defines a function-like macro with arguments, similar syntactically to a function call. The
parameters are specified by the optional list of identifiers, whose scope extends from their
declaration in the identifier list until the new-line character that terminates the #define
preprocessing directive. Each subsequent instance of the function-like macro name followed by a ( as the next preprocessing token introduces the sequence of preprocessing
tokens that is replaced by the replacement list in the definition (an invocation of the
macro). The replaced sequence of preprocessing tokens is terminated by the matching )
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
447
preprocessing token, skipping intervening matched pairs of left and right parentheses
tokens.
Within the sequence of preprocessing tokens making up an invocation of a function-like
macro, new-line is considered a normal white-space character.
The sequence of preprocessing tokens bounded by the outermost matching parentheses
forms the list of arguments for the function-like macro. The individual arguments within
the list are separated by comma preprocessing tokens, but comma preprocessing tokens
bounded by nested parentheses do not separate arguments. If any argument consists of no
preprocessing tokens, the behavior is undefined. If there are sequences of preprocessing
tokens within the list of arguments that otherwise act as preprocessing directives, the
behavior is undefined.
Argument Substitution
After the arguments for the invocation of a function-like macro have been identified, argument substitution takes place. A parameter in the replacement list, unless preceded by a #
or ## preprocessing token or followed by a ## preprocessing token, is replaced by the corresponding argument after all macros have been expanded. Before being substituted, each
argument's preprocessing tokens are completely macro-replaced as if they formed the rest
of the source file. No other preprocessing tokens are available.
The # Operator
Constraints
Each # preprocessing token in the replacement list for a function-like macro must be followed by a parameter as the next preprocessing token in the replacement list.
Semantics
If, in the replacement list, a parameter is immediately preceded by a # preprocessing
token, both are replaced by a single character string literal preprocessing token that contains the spelling of the preprocessing token sequence for the corresponding argument.
Each occurrence of white space between the argument's preprocessing tokens becomes a
single space character in the character string literal. White space before the first preprocessing token and after the last preprocessing token comprising the argument is deleted.
Otherwise, the original spelling of each preprocessing token in the argument is retained in
the character string literal.
This process requires special handling for producing the spelling of string literals and
character constants: a \ character is inserted before each " and \ character of a character
constant or string literal (including the delimiting " characters). The order of evaluation of
# operators is unspecified.
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
448
The ## Operator
Constraints
A ## preprocessing token does not occur at the beginning or at the end of a replacement
list for either form of macro definition.
Semantics
If, in the replacement list, a parameter is immediately preceded or followed by a ## preprocessing token, the parameter is replaced by the corresponding argument's preprocessing token sequence.
For both object-like and function-like macro invocations, before the replacement list is
reexamined for more macro names to replace, each instance of a ## preprocessing token in
the replacement list (not from an argument) is deleted and the preceding preprocessing
token is concatenated with the following preprocessing token. If the result is not a valid
preprocessing token, the behavior is undefined. The resulting token is available for further
macro replacement. The order of evaluation of ## operators is unspecified.
Rescanning and Further Replacement
After all parameters in the replacement list have been substituted, the resulting preprocessing token sequence is rescanned with the rest of the source file's preprocessing tokens for
more macro names to replace.
If the name of the macro being replaced is found during this scan of the replacement list
(not including the rest of the source file's preprocessing tokens), it is not replaced. Further,
if any nested replacements encounter the name of the macro being replaced, it is not
replaced. These nonreplaced macro name preprocessing tokens are no longer available for
further replacement, even if they are later reexamined in contexts in which that macro
name preprocessing token is otherwise replaced.
The resulting completely macro-replaced preprocessing token sequence is not processed
as a preprocessing directive even if it resembles one.
Scope of Macro Definitions
A macro definition is effective until a #undef directive is read or the end of the file is
reached.
A preprocessing directive of the form
# undef identifier new-line
deletes the macro definition of the specified identifier. The #undef directive is ignored if
the specified identifier is not currently defined as a macro name.
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
449
Examples
The simplest use of this facility is to define a ''manifest constant,'' as in
#define TABSIZE 100
int table[TABSIZE];
The following defines a function-like macro whose value is the maximum of its arguments. Advantages include the following:
•
•
working for any compatible types of the arguments
generating in-line code without the overhead of function calling
Disadvantages include the following:
•
•
evaluating one argument a second time (including side effects)
generating more code than a function if invoked several times
#define max(a, b) ((a) > (b) ? (a) : (b))
The parentheses ensure that the arguments and the resulting expression are bound properly.
To illustrate the rules for redefinition and reexamination, the following sequence
#define x 3
#define f(a) f(x * (a))
#undef x
#define x 2
#define g f
#define z z[0]
#define h g(~
#define m(a) a(w)
#define w 0,1
#define t(a) a
f(y+1) + f(f(z)) % t(t(g) (0) +t) (1);
g(x+(3,4)-w) | h 5) & m
(f)^m(m) ;
results in
f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1) ;
f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1) ;
To illustrate the rules for creating character string literals and concatenating tokens, the
following sequence
#define str(s) # s
#define xstr(s) str(s)
#define debug(s, t) printf(''x'' # s ''= %d, x'' # t ''= %s'', x ## s, x ## t)
#define INCFILE(n) vers ## n /* from previous #include example */
#define glue(a, b) a ## b
define # xglue(a, b) glue(a, b)
#define HIGHLOW ''hello''
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
450
#define LOW LOW '', world''
debug(1, 2) ;
fputs(str(strncmp(''abc \ 0d'', ''abc'',
== 0) str(: @ \n), s) ;
#include xstr(INCFILE(2) .h)
glue(HIGH, LOW) ;
xglue(HIGH, LOW)
'\ 4') /* this goes away */
results in the following code
printf(''x'' ''1'' ''= %d, x'' ''2'' ''= %s'', x1, x2) ;
fputs(''strncmp(<N>\''abc \ \0d \'', \''abc \'', '\ \4') == 0'' '': @\n'', s) ;
#include ''vers2.h'' (after macro replacement, before file access)
''hello'';
''hello'' '', world''
or, after concatenation of the character string literals,
printf(''x1= %d, x2= %s'', x1, x2) ;
fputs(''strncmp(\''abc\ \0d \'', \''abc\'', '\ \4') == 0: @\n'', s) ;
#include ''vers2.h'' (after macro replacement, before file access)
''hello'';
''hello, world''
Space around the # and ## tokens in the macro definition is optional.
And finally, to demonstrate the redefinition rules, the following sequence is valid:
#define OBJ_LIKE (1-1)
#define OBJ_LIKE /* white space */ (1-1) /* other */
#define FTN_LIKE(a) ( a )
#define FTN_LIKE( a ) (
/* note the white space */ \
a /* other items on this line
*/ )
However, the following redefinitions are invalid:
#define
#define
#define
#define
UM014418-0205
OBJ_LIKE (0) /* different token sequence */
OBJ_LIKE (1 - 1) /* different white space */
FTN_LIKE(b) ( a ) /* different parameter usage */
FTN_LIKE(b) ( b ) /* different parameter spelling */
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
451
LINE CONTROL
Constraints
The string literal, if present, is a character string literal.
Semantics
Lines of code, comment lines, and blank lines are numbered sequentially, starting with 1 at
the first line of the file.
A preprocessing directive of the form
# line
digit-sequence new-line
causes the compiler to behave as if the following sequence of source lines begins with a
source line that has a line number as specified by the digit sequence (interpreted as a decimal integer).
A preprocessing directive of the form
# line
digit-sequence string-literal new- line
sets the line number similarly and changes the presumed name of the source file to be the
characters contained within the character string literal.
A preprocessing directive of the form
# line
pp-tokens new-line
is permitted if it does not match one of the two previous forms. The preprocessing tokens
after # line on the directive are processed just as in normal text (each identifier currently
defined as a macro name is replaced by its replacement list of preprocessing tokens). After
the compiler makes all replacements, the directive that results matches one of the two previous forms and is then processed as appropriate.
ERROR DIRECTIVE
A #error preprocessing directive causes the compiler to produce a diagnostic message
that includes the specified sequence of tokens.
PRAGMA DIRECTIVE
The compiler ignores #pragma preprocessing directives.
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
452
NULL DIRECTIVE
If there is no token between the # and the next new-line character, the directive has no
effect.
PREDEFINED MACROS
The compiler defines the following macros.
__ACCLAIM__
This macro is defined and set to 1 for the eZ80 compiler and is otherwise
undefined.
__DATE__
This macro, required by the ANSI standard, 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 the dd is a space character if the value is less than 10.
__EZ80__
This macro is defined and set to 1 for the eZ80 compiler and is otherwise
undefined.
__FILE__
This macro, required by the ANSI standard, expands to the current source file
(a string literal).
__FPLIB__
This macro is defined on all ZiLOG compilers and indicates whether the
floating-point library is available.
__LINE__
This macro, required by the ANSI standard, expands to the current line number
of the current file (a decimal constant).
__MODEL__
This macro is defined on all ZiLOG compilers and indicates the memory
model used by the compiler as follows:
0
1
2
3
4
5
Small Model
Compact Model
Medium Model
Large Model
Tiny Model
Huge Model
__STDC__
This macro, required by the ANSI standard, is defined as the decimal constant
1 and indicates conformance with ANSI C.
__TIME__
This macro, required by the ANSI standard, expands to the time of day in the
format “hh:mm:ss” (a character string literal) as in the time generated by the
asctime function.
__ZDATE__
This macro is defined on all ZiLOG compilers released after April 1, 2004. The
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__
would be 20060531. This macro gives a means to test for a particular ZiLOG
release or to test that the compiler is released after a new feature has been
added.
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
453
__ZILOG__
This macro is defined and set to 1 on all ZiLOG compilers to indicate that the
compiler is provided by ZiLOG rather than some other vendor.
The values of the predefined macros (except for __LINE__ and __FILE__) remain constant throughout the translation unit.
None of these macro names, nor the identifier defined, can be the subject of a #define
or a #undef preprocessing directive. All predefined macro names must begin with two
underscores and end with two underscores.
Examples
The following program illustrates the use of these predefined macros:
void main()
{
#ifdef __ZILOG__
printf("I love ZiLOG!\n");
#endif
#ifdef __EZ80__
printf("The eZ80 is the best embedded processor ever!\n");
#endif
#ifdef __ACCLAIM__
printf("It is also known as the Acclaim!\n");
#endif
UM014418-0205
B ANSI C Preprocessing Directives
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
454
C Shortcut Keys
This appendix lists the following shortcut keys for the eZ80Acclaim! developer’s environment:
•
•
•
•
“File Menu Shortcuts” on page 454
“Edit Menu Shortcuts” on page 454
“Project Menu Shortcuts” on page 455
“Build Menu Shortcuts” on page 455
FILE MENU SHORTCUTS
These are the shortcuts for the options on the File menu.
Option
Shortcut
Description
New File
Ctrl+N
To create a new file in the Edit window.
Open File
Ctrl+O
To display the Open dialog box for you to find the appropriate file.
Save
Ctrl+S
To save the file.
Save All
Ctrl+L
To save all files in the project.
Print
Ctrl+P
To print a file.
EDIT MENU SHORTCUTS
These are the shortcuts for the options on the Edit menu.
Option
Shortcut
Description
Undo
Ctrl+Z
To undo the last 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 it on the clipboard.
Copy
Ctrl+C
To copy selected text from a file and put it on the clipboard.
Paste
Ctrl+V
To paste the current contents of the clipboard into a file.
Delete
Ctrl+D
To remove a file from the current project.
Go to Line Ctrl+G
To jump to a specified line in the current file.
Find
Ctrl+F
F3
To find a specific value in the designated file.
To repeat the previous search.
Replace
Ctrl+H
To replace a specific value to the designated file.
UM014418-0205
C Shortcut Keys
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
455
PROJECT MENU SHORTCUTS
There is one shortcut for the options on the Project menu.
Option
Shortcut
Description
Settings
Alt+F7
To display the Project Settings dialog box.
BUILD MENU SHORTCUTS
These are the shortcuts for the options on the Build menu.
Option
Shortcut
Description
Build
F7
To build your file and/or project.
Stop Build Ctrl+Break To stop the build of your file and/or project.
These are the shortcuts for the selections on the Debug option (from the Build menu).
Option
Shortcut
Reset
Ctrl+Shift+F5 To reset the debugger.
Stop Debugging
Shift+F5
To stop debugging of your program.
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
returns to execute the next statement in the the caller
function.
Set Next Instruction
Shift+F10
To set the next instruction at the current line.
UM014418-0205
Description
C Shortcut Keys
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
456
Glossary
A
ABS. Absolute Value.
A/D. Analog-to-Digital—the conversion of an analog signal, such as a waveform, to a digital signal,
represented by binary data. See ADC.
ADC. Analog-to-Digital Converter—a circuit that converts an analog signal to a digital bit stream.
See A/D.
address space. The physical or logical area of the target system’s memory map. The memory map could be
physically partitioned into ROM to store code, and RAM for data. The memory can also be divided
logically to form separate areas for code and data storage.
ALU. See Arithmetic Logical Unit.
American National Standards Institute (ANSI). The U.S. standards organization that establishes procedures
for the development and coordination of voluntary American National Standards.
analog. From the word analogous, meaning similar to. The signal being transmitted can be represented in
a way similar to the original signal. For example, a telephone signal can be seen on an oscilloscope as a
sine wave similar to the voice signal being carried through the phone line.
analog signal. A signal that exhibits a continuous nature rather than a pulsed or discrete nature.
AND. A bitwise AND instruction.
ANSI. American National Standards Institute.
application program interface (API). A formalized set of software calls and routines that can be referenced
by an application program to access supporting network services.
architecture. Of a computer, the physical configuration, logical structure, formats, protocols, and
operational sequences for processing data, controlling the configuration, and controlling the operations.
Computer architecture may also include word lengths, instruction codes, and the interrelationships among
the main parts of a computer or group of computers.
Arithmetic Logical Unit (ALU). the element that can perform the basic data manipulations in the central
processor. Usually, the ALU can add, subtract, complement, negate, rotate, AND, and OR.
array. 1. An arrangement of elements in one or more dimensions. 2. In a programming language, an
aggregate that consists of data objects with identical attributes, each of which may be uniquely referenced
by subscription.
ASCII. Acronym for American Standard Code for Information Interchange. The standard code used for
information interchange among data processing systems, data communications systems, and associated
equipment in the United States.
ASM. Assembler File.
assembly. 1. The manufacturing process that converts circuits in wafer form into finished packaged parts.
2. A short term for assembly language.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
457
B
baud. A unit of measure of transmission capacity. The speed at which a modem can transmit data. The
number of events or signal changes that occur in one second. Because one event can encode more than one
bit in high-speed digital communications, baud rate and bits per second are not always synonymous,
especially at speeds above 2400 bps.
baud rate. A unit of measure of the number of state changes (from 0 to 1 or 1 to 0) per second on an
asynchronous communications channel.
binary (b). A number system based on 2. A binary digit is a bit.
bit. binary digit—a digit of a binary system. It contains only two possible values: 0 or 1.
block diagram. A diagram of a system, a computer, or a device in which the principal parts are represented
by suitably annotated geometrical figures to show both the basic functions of the parts and their functional
relationships.
buffer. 1. In hardware, a device that restores logic drive signal levels to drive a bus or a large number of
inputs. In software, any memory structure allocated to the temporary storage of data. 2. A routine or
storage medium used to compensate for a difference in rate of flow of data, or time of occurrence of events,
when transferring data from one device to another.
bus. In electronics, a parallel interconnection of the internal units of a system that enables data transfer and
control information. One or more conductors or optical fibers that serve as a common connection for a
group of related devices.
byte (B). A sequence of adjacent bits (usually 8) considered as a unit. A collection of four sequential bits of
memory. Two sequential bytes (8 bits) comprise one word.
C
CALL. This command invokes a subroutine.
CCF. Clear Carry Flag.
character set. A finite set of different characters that is complete for a given purpose. A character set
might include punctuation marks or other symbols.
CIEF. Clear IE Flag.
clock. A specific cycle designed to time events, used to synchronize events in a system.
CLR. Clear.
CMOS. Complementary Metal Oxide Semiconductor. A type of integrated circuit used in processors and
for memory.
compile. 1. To translate a computer program expressed in a high-level language into a program expressed
in a lower level language, such as an intermediate language, assembly language, or a machine language.
2. To prepare a machine language program from a computer program written in another programming
language by making use of the overall logic structure of the program or by generating more than one
computer instruction for each symbolic statement as well as performing the function of an assembler.
compiler. A computer program for compiling.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
458
COPF. Clear Overflow Protection Flag.
CPU. Abbreviation for Central Processing Unit. 1. The portion of a computer that includes circuits
controlling the interpretation and execution of instructions. 2. The portion of a computer that executes
programmed instructions, performs arithmetic and logical operations on data, and controls input/output
functions.
D
debug. To detect, trace, and eliminate mistakes.
DI. Disable interrupt.
E
EI. Enable interrupt.
emulation. The process of duplicating the characteristics of one product or part using another medium. For
example, an In-Circuit Emulator (ICE) module duplicates the behavior of the chip it emulates, in the circuit
being tested.
emulator. An emulation device.
EOF. End of file—when all records in a file are processed, the computer encounters an end-of-file
condition.
EPROM. Erasable Programmable Read-Only Memory. An EPROM can be erased by exposure to
ultraviolet light.
EQ. A Boolean operator meaning Equal to.
escape sequence. A special escape command is entered as three plus symbols (+++). placing the modem in
command mode, and interrupting user data transmission. However, the escape sequence does not terminate
the data connection. Command mode allows the entering of commands while the connection is maintained.
F
F. Falling Edge.
Fast Fourier Transform. An algorithm for computing the Fourier transform of a set of discrete data values.
Given a finite set of data points—for example, a periodic sampling taken from a real-world signal—the
FFT expresses the data in terms of its component frequencies. It also solves the essentially identical
inverse problem of reconstructing a signal from the frequency data.
FFT. See Fast Fourier Transform.
filter. A process for removing information content, such as high or low frequencies.
flag. In data transmission or processing, an indicator, such as a signal, symbol, character, or digit, used for
identification. A flag may be a byte, word, mark, group mark, or letter that signals the occurrence of some
condition or event, such as the end of a word, block, or message.
frequency. For a periodic function, the number of cycles or events per unit time.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
459
G
graphical user interface (GUI). 1. A graphics-based user interface that enables users to select files,
programs or commands by pointing to pictorial representations (icons) on the screen, rather than by typing
long, complex commands from a command prompt. 2. The windows and incorporated text displayed on a
computer screen.
groups. Collections of logical address spaces typically used for convenience of locating a set of address
spaces.
GUI. See graphical user interface.
H
h. See hexadecimal.
hardware. The boards, wires, and devices that comprise the physical components of a system.
Hertz. Abbreviated Hz. A measurement of frequency in cycles per second. A hertz is one cycle per second.
A kilohertz (KHz) is one thousand cycles per second. A megahertz (MHz) is one million cycles per second.
A gigahertz (GHz) is a billion cycles per second.
hexadecimal. A base-16 number system. Hex values are often substituted for harder-to-read binary
numbers.
I
ICE. In-Circuit Emulator. A ZiLOG product that supports the application design process.
icon. A small screen image representing a specific element like a document, embedded and linked objects,
or a collection of programs gathered together in a group.
ID. Identifier.
IE. Interrupt Enable.
initialize. To establish start-up parameters, typically involving clearing all of some part of the device’s
memory space.
instruction. Command.
interface (I/F). 1. In a system, a shared boundary, i.e., the boundary between two subsystems or two
devices. 2. A shared boundary between two functional units, defined by specific attributes, such as
functional characteristics, common physical interconnection characteristics, and signal characteristics. 3. A
point of communication between two or more processes, persons, or other physical entities.
interleaving. The transmission of pulses from two or more digital sources in time-division sequence over a
single path.
interrupt. A suspension of a process, such as the execution of a computer program, caused by an event
external to that process, and performed in such a way that the process can be resumed. The three types of
interrupts include: internal hardware, external hardware, and software.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
460
I/O. Input/Output. In computers, the part of the system that deals with interfacing to external devices for
input or output, such as keyboards or printers.
IPR. Interrupt Priority Register.
J
JP. Jump.
K
K. Thousands. May indicate 1000 or 1024 to differentiate between decimal and binary values.
Abbreviation for the Latin root kilo.
kHz. See kilohertz.
kilohertz (kHz). A unit of frequency denoting one thousand (103) Hz.
L
LD. Load.
library. A file that contains a collection of object modules that were created by an assembler or directly by
a C compiler.
LSB. Least significant bit.
M
MAC. An acronym for Media Access Control, the method a computer uses to transmit or receive data
across a LAN.
Megahertz (MHz). A unit of frequency denoting one million (106) Hz.
memory. 1. All of the addressable storage space in a processing unit and other internal memory that is used
to execute instructions. 2. The volatile, main storage in computers.
MHz. See Megahertz; also Hertz.
MI. Minus.
MLD. Multiply and Load.
MPYA. Multiply and Add.
MPYS. Multiply and Subtract.
MSB. Most significant bit.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
461
N
n. Number. This letter is used as place holder notation.
NC. No Connection.
NE. Not Equal.
NEG. Negate.
NMI. Nonmaskable interrupt.
NOP. An acronym for No Operation, an instruction whose sole function is to increment the program
counter, but that does not affect any changes to registers or memory.
O
Op Code. Operation Code, a quantity that is altered by a microprocessor’s instruction. Also abbreviated
OPC.
OR. Bitwise OR.
OV. Overflow.
P
PC. Program counter.
pipeline. The act of initiating a bus cycle while another bus cycle is in progress. Thus, the bus can have
multiple bus cycles pending at a time.
POP. Retrieve a value from the stack.
port. The point at which a communications circuit terminates at a network, serial, or parallel interface card.
power. The rate of transfer or absorption of energy per unit time in a system.
push. To store a value in the stack.
R
RAM. Random-access memory. A memory that can be written to or read at random. The device is usually
volatile, which means the data is lost without power.
random-access memory (RAM). A read/write, nonsequential-access memory used for the storage of
instructions and data.
read-only memory (ROM). A type of memory in which data, under normal conditions, can only be read.
Nonvolatile computer memory that contains instructions that do not require change, such as permanent
parts of an operating system. A computer can read instructions from ROM, but cannot store new data in
ROM. Also called nonerasable storage.
register. A device, accessible to one or more input circuits, that accepts and stores data. A register is most
often used only as a device for temporary storage of data.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
462
ROM. See read-only memory.
RR. Rotate Right.
S
SCF. Set C Flag.
SL. Shift Left.
SLL. Shift Left Logical.
SP. Stack Pointer.
SR. Shift Right.
SRA. Shift Right Arithmetic.
Static. Characteristic of random-access memory that enables it to operate without clocking signals.
SUB. Subtract.
T
tristate. A form of transistor-to-transistor logic in which output stages, or input and output stages, can
assume three states. Two are normal low-impedance 1 and 0 states; the third is a high-impedance state that
allows many tristate devices to time-share bus lines. This industry term is not trademarked, and is available
for ZiLOG use. Do not use 3-state or three-state.
U
ULT. Unsigned Less Than.
W
wait state. A clock cycle during which no instructions are executed because the processor is waiting for
data from memory.
word. Amount of data a processor can hold in its registers and process at one time.
write. To make a permanent or transient recording of data in a storage device or on a data medium.
X
X. 1. Indexed Address. 2. An undefined or indeterminate variable.
XOR. Bitwise exclusive OR.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
463
Z
Z. 1. Zero. 2. Zero Flag.
ZDS. ZiLOG Developer Studio. ZiLOG’s program development environment for Microsoft Windows.
UM014418-0205
Glossary
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
464
Index
Symbols
- (subtract) 364
"#" must be followed by an argument name 278
"##" cannot be first or last token in replacement
string 278
"else" not within #if and #endif directives 278
# (prefix character) 321
# Bytes drop-down list box 153
#define preprocessing directive 446
#elif preprocessing directive 444
#else preprocessing directive 444
#endif preprocessing directive 444
#error preprocessing directive 451
#if !defined preprocessing directive 444
#if defined preprocessing directive 444
#if preprocessing directive 444
#ifdef preprocessing directive 444
#ifndef preprocessing directive 444
#include 110, 111, 112, 196, 444
#pragma alias 98, 256
#pragma cpu 256
#pragma globalcopy 256
#pragma globalcse 257
#pragma globaldeadvar 257
#pragma globalfold 257
#pragma intrinsics 257
#pragma jumpopt 257
#pragma localcopy 258
#pragma localcse 258
#pragma localfold 258
#pragma localopt 258
#pragma noalias 98, 256
#pragma nobss 257
#pragma noglobalcopy 256
#pragma noglobalcse 257
#pragma noglobaldeadvar 257
#pragma noglobalfold 257
UM014418-0205
#pragma nointrinsics 257
#pragma nojumpopt 257
#pragma nolocalcopy 258
#pragma nolocalcse 258
#pragma nolocalfold 258
#pragma nolocalopt 258
#pragma noopt 258
#pragma nooptlink 258
#pragma nopeephole 259
#pragma nopromote 101, 259
#pragma nosdiopt 259
#pragma nostkck 259
#pragma nostrict 259
#pragma optlink 258
#pragma optsize 258, 266
#pragma optspeed 259
#pragma peephole 259
#pragma promote 101, 259
#pragma sdiopt 259
#pragma stkck 259
#pragma strict 259
#pragma, using 256, 260, 274
#undef 448
$$ 317
& (and) 360
* (multiply) 363
+ (add) 359
.class file extension 92
.COMMENT directive 301
.gif file extension 92
.hex file extension xxviii, 6, 129
.htm file extension 92
.html file extension 92
.jar file extension 92
.jpeg file extension 92
.jpg file extension 92
.linkcmd file extension 43
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
465
.lod file extension 343
.map file extension xxix, 117, 347, 369
.srec file extension xxx, 6, 129
.wav file extension 92
/ (divide) 361
<< (shift left) 364
<assert.h> header 199
<ctype.h> header 199
<errno.h> header 198
<eZ80.h> header 210
<float.h> header 201
<limits.h> header 200
<math.h> header 203
<outputfile>=<module list> command 343
<setjmp.h> header 204
<stdarg.h> header 205
<stddef.h> header 198
<stdio.h> header 206
<stdlib.h> header 206
<string.h> header 208
>> (shift right) 364
?, script file command
for expressions 38
for variables 39
\a 385
\b 385
\f 385
\n 385
\r 385
\t 385
\v 385
^ (bitwise exclusive or) 365
_ (underscore) 195, 196, 262
__ACCLAIM__ 452
__DATE__ 452
__EZ80__ 452
__FILE__ 452
__FPLIB__ 452
__LINE__ 452
__MODEL__ 452
__STDC__ 452
UM014418-0205
__TIME__ 452
__VECTORS segment 292
__ZDATE__ 452
__ZILOG__ 453
_init_default_vectors 268
_set_vector 268
| (or) 364
~ (not) 365
A
\a 385
abs function 210
Absolute segments 293, 294, 307
definition 291, 334
locating 347
Absolute value, computing 210, 218, 224
__ACCLAIM__ 452
acos function 211
Activate Breakpoints check box 161
Add button 138
Add Directives button 125, 366
add file, script file command 36
Add Files to Project dialog box 92
Add Project Configuration dialog box 147
Adding breakpoints 180
Adding files to a project 11, 92
Adding web files to a project 92
Additional Linker Directives dialog box 125
Additive operators 403
Address Hex field 153
Address operator 400
Address spaces
allocation order 355
definition 335
grouping 346
linking sequence 354
locating 347
moving 343
predefined 291
renaming 343
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
466
setting maximum size 353
setting ranges 355
Addresses
finding 171
viewing 171
Addressing modes in assembly 320
prefix character 321
Aggregate objects, initialization 427
Aggregate types 381
Alias Checking check box 98
Alias checking, enabling 256
Alias, defined 256
ALIGN clause 307
ALIGN directive 301
Aligning data 264
All RAM configuration 81, 118
Allocating space 227
ANSI C language, described 373
ANSI C preprocessor commands 441
ANSI C-Compiler 190
command line options 57
configuring 5
configuring optimizer 103
description 5
error messages 276
running from the command line 54
sequence points 393
setup 95
supported preprocessor commands 441
warning messages 276
ANSI Promotions check box 98
ANSI standards, sensitivity to 101
arc cosine, computing 211
arc sine, computing 211
arc tangent, computing 212, 213
Argument
passing 195, 263
substitution 447
Arithmetic conversions 390
Arithmetic operators in assembly 298
Arithmetic types 381, 389
UM014418-0205
Arithmetic, basic fractional 193
Array declarators 422
Array function 215
Arrays
definition 381
subscripting 396
Arrow (->), using 398
ASCII values, viewing 177
ASCIZ values, viewing 178
asctime function 452
asin function 211
.asm file extension xxviii, 6
asm statement 260
Assembler
adding null characters 297
addressing modes 320
arithmetic operators 298
binary numbers 299
Boolean operators 298
case sensitivity 113, 296
character constants 300
character strings 297
command line options 55
configuring 6
decimal numbers 299
description 5
directive compatibility 325
directives 301
error messages 328
expressions 298
floating-point numbers 297
generating listing file (.lst) 294
generating object file 294
hexadecimal numbers 299
numeric representation 297
octal numbers 300
operator precedence 300
options 42
relational operators 298
reserved words 296
running from the command line 55
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
467
setup 112
syntax 322
using 290
warning messages 328
Assembler tab, Project Settings dialog box 112
Assembly language
adding null characters 297
addressing modes 320
arithmetic operators 298
backslash 295
binary numbers 299
blank lines 295
Boolean operators 298
calling from C 262
case sensitivity 296
character constants 300
character strings 297
comments 296
decimal numbers 299
directive compatibility 325
directives 296, 301
embedding in C 260, 274
expressions 298
floating-point numbers 297
hexadecimal numbers 299
instructions 296
labels 296, 319
line continuation 295
line definition 295
line length 295
macro expansion 113
numeric representation 297
octal numbers 300
operator precedence 300
prefix character 321
relational operators 298
reserved words 296
routine names 262
source line 296
structure 295
syntax 322
UM014418-0205
translating 5
<assert.h> header 199
asset function 212
Assigned function names 262
Assignment operators 409
compound 411
simple 410
Associated File Types field 162
atan function 212
atan2 function 213
atof function 213
atoi function 213
atol function 214
Automatic storage duration, defined 380
Automatically Reload Externally Modified
Files check box 156
B
\b 385
Backslash, used in assembly 295
BASE OF 344
BASE OF operator 360
Basic fractional arithmetic 193
batch, script file command 31, 36
Baud Rate list box 23, 132
Baud rate, choosing 23, 132
Beginning a project 8
BFRACT directive 303
Binary numbers in assembly 299
Binary operator 403
bit-field 417
Bitwise AND operator (&) 406
Bitwise exclusive OR operator (^) 407
Bitwise inclusive OR operator (|) 407
Bitwise logical operations 193
Bitwise shift operators 404
BLKB directive 304
BLKL directive 304
BLKP directive 304
BLKW directive 304
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
468
Block 431
Blue dots 17, 68, 70, 166, 180, 181
Bookmarks 74
Boolean operators in assembly 298
Boot module
customizing 124
default 122
Boot Module area 122
bp, script file command 36
Branch Optimizations check box 106
Branch optimizations, definition 106
Break button 70, 167
break statement 435
Breakpoints 181
adding 19, 180
deleting 183
disabling 183
enabling 182
finding 182
inserting 19
jumping to 182
making active 182
making inactive 183
moving to 182
placing 19
removing 183
setting 19
viewing 181
Breakpoints dialog box 90, 181, 182
bsearch function 214
BSS segment 292
Build button 67
Build menu 141
Build 142
Compile 142
Debug 142
Break 144
Connect to Target 143
Download Code 143
Go 143
Reset 143
UM014418-0205
Run to Cursor 143
Set Next Instruction 144
shortcuts 455
Step Into 144
Step Out 144
Step Over 144
Stop Debugging 143
Manage Configurations 146
Rebuild All 142
Set Active Configuration 144
shortcuts 455
Stop Build 142
Update All Dependencies 142
Build Output window 75, 76
Build toolbar 67
build, script file command 37
Building a project 15, 142
from the command line 54
Burn and Verify button 152
C
C
additive operators 403
arithmetic types 389
assignment operators 409
bitwise shift operators 404
calling assembly from 262
cast operators 402
character constants 384
character sets 374
comments 388
constant expressions 411
constants 382
conventions 374
conversions 389
converting web files to 92
declarations 412
declarators 420
embedding assembly in 260
enumeration constants 384
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
469
equality operator 406
expressions 393
external definitions 436
external object definitions 439
function calls 396
function definitions 436
identifiers 377
initialization 122
integer constants 383
keywords 376
language, described 373
lexical elements 375
macro expansion 110
making programs faster 267
making programs smaller 266
multiplicative operators 402
operators 387
postfix operators 395
preprocessor commands 441
primary expressions 395
punctuators 388
relational operators 405
statements 429
string literals 386
trigraph sequences 375
troubleshooting 264
type definitions 425
type equivalence 425
type names 424
type specifiers 414
unary operators 399
variables in embedded assembly 260
with embedded assembly 274
writing programs 190
.c file extension xxviii, 5
C tab, Project Settings dialog box 95
Call Stack window 178
Call Stack Window button 71
Calling assembly from C 262
Calling conventions 262
calloc function 215
UM014418-0205
cancel all, script file command 37
cancel bp, script file command 37
Cannot initialize object with "extern" storage
class 286
Cascade the files 163
Case Sensitive check box 159
Case sensitivity
in assembler 113, 296
in linker 117
C-Compiler
command line options 57
configuring 5
configuring optimizer 103
description 5
error messages 276
running from the command line 54
sensitivity to ANSI standards 101
setup 95
supported preprocessor commands 441
warning messages 276
cd, script file command 37
ceil function 215
CHANGE command 343, 366
Changing object size 235
char *gets 206
char *strcat 209
char *strchr 209
char *strcpy 209
char *strncat 209
char *strncpy 209
char *strpbrk 209
char *strrchr 209
char *strstr 209
char *strtok 209
CHAR_BIT 200
CHAR_MAX 200
CHAR_MIN 200
Character case mapping functions 200
Character constants
in assembly 300
in C 384
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
470
Character sets, used by compiler 374
Character string literal, definition 387
Character strings, in assembly 297
Character testing functions 200
Character-handling functions 199
.class file extension 92
Clear button 157
Clock Speed (MHz) field 30, 135
Clock window 170
Clock Window button 71
Close Dialog When Flash Complete check box
152
Code line indicators 166
CODE segment 292
COLOR command 344
Colors, selecting 159
Comma operator 411
Command field 69
Command line
building a project from 54
examples 41
running the assembler from 55
running the compiler from 54, 57
running the librarian from 62
running the linker from 55, 62
running ZDS II from 54
Command Output window 77, 78
Command Processor
description 6
quick tour 31
running the Flash Loader from 51
Command Processor toolbar 68
Command script file
commands 32
example 31
writing 31
Commands
linker 341
linker command file 342
running 31
Commands tab 155
UM014418-0205
Commands to Keep field 157
Comment 388
/* 388
// 388
in assembly language 296
Comment characters, defining 159
.COMMENT directive 301
Common initial sequence 398
Common subexpressions
global 106
local 105
Common Subexpressions check box 105, 106
Communication button 131
Comparing characters 228, 245
Comparing strings 243
Comparison functions 209
Compatibility of assembly directives 325
Compile/Assemble File button 67
Compiler 190
character sets supported 374
command line options 57
configuring 5
configuring optimizer 103
description 5
determining identifier scope 378
error messages 276
generating temporary variables 265
lower execution times 265
naming conventions 194
options 42
predefined macros 275
preprocessor commands 441
running from the command line 54
sensitivity to ANSI standards 101
setting options 256
setup 95
speeding up 265
troubleshooting 264
warning messages 276
Compiling a project 142
Compound statements 430
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
471
Concatenating strings 242, 245
Concatenation functions 209
Concatention character 316
Conditional assembly 313
Conditional assembly directives 313
IF 313
IFDEF 314
IFMA 315, 317
IFSAME 315
Conditional inclusion 443
Conditional operator (?:) 409
Configurations
copying 146
linker 339
setting 144
Configure New Project dialog box 10, 11, 81
Configure Target dialog box 136
Connect to Target button 67
const 194, 392, 415
Const Variable Placement area 98
Constant
definition 395
in C 382
UINT_MAX 400, 405
ULONG_MAX 400, 405
Constant expressions 411
Constant folding
global 107
local 105
Constant Folding check box 105, 107
continue statement 434
Conventions used for C language 374
Conventions used in manual xxvi
Conversion characters for scanf 238
Conversions 389
arithmetic 390
default argument 397
with pointers 402
Converting letter case 251, 252
Converting strings 248, 250
Converting web files to C 92
UM014418-0205
Copy a Target Wizard dialog box 140
COPY BASE OF command 344
COPY BASE operator 361
Copy button 66, 139
COPY command 344, 366
Copy Configuration Settings dialog box 148
Copy propagation
global 107
local 105
Copy Propagation check box 105, 107
Copy segments 335
Copy to RAM configuration 82, 120
COPY TOP OF command 344
COPY TOP operator 361
Copying characters 229, 246
Copying functions 208
Copying strings 243
Copying values 229
cos function 216
cosh function 216
cosine, calculating 216
CPU directive 302
CPU list box 94
CPU selection 20, 29, 94
CpuflashDevice.xml file 151
Create New button 125, 366
Create New Target Wizard dialog box 139
Creating a project 8
adding linker directives 124, 341
initializing variables 124, 341
<ctype.h> header 199
Custom button 124, 126
caution 124, 341
Custom configuration 82, 121
Custom field 124, 126, 341
Custom Linker Command File dialog box 126
Customer service xxvii
Customer support xxvii
Customize dialog box 154
Commands tab 155, 156
Toolbars tab 154
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
472
Cut button 66
D
Data alignment 264
Data directives in assembly 303
DATA segment 292
__DATE__ 452
DB directive 305
DBL_DIG 201
DBL_MANT_DIG 201
DBL_MAX 201
DBL_MAX_10_EXP 201
DBL_MAX_EXP 201
DBL_MIN 201
DBL_MIN_10_EXP 201
DBL_MIN_EXP 201
DD directive 305
Deallocating space 219
DEBUG command 345
Debug configuration 144
Debug Information check box 113
Debug Information list box
Code Generation category 98
General category 96
Debug information, generating 345, 354, 366
Debug mode
description 7
invoking 7, 143
quick tour 16
RUN 18, 165
selecting 130
setting up 17
STEP 18, 165
STOP 18, 165
switching to 164
Debug Output window 76, 166
Debug toolbar 69, 166
Debug windows 91
Debug Windows toolbar 71, 169
UM014418-0205
Debugger
description 7, 130, 164
invoking 7, 143
options 46
quick tour 16
setting up 17
status bar 18, 165
Debugger script file
commands 32
example 31
writing 31
Debugger tab
Options dialog box 160
Project Settings dialog box 130
Debugging code 367
with Flash-based target 189
with Instruction Set Simulator 185
with RAM-based target 186
with ROM-based target 189
Dec button 153
Decimal numbers in assembly 299
Decimal numeric values 363
Decimal values, viewing 177
Declaration 412
Declarator 420
array 422
function 423
pointer 421
Default argument conversions 397
Default button 122
Default integral promotions 192
Default promotions on fract variables 191
DEFINE 293, 306, 307, 346
-define option 275
#define preprocessing directive 446
Defines field 114
Definitions
external 436
external object 439
function 436
tentative 439
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
473
Delete button 66, 140
Deleting files from a project 12, 79
Developer’s environment tutorial 7
DF directive 305
Diagnostics function 212
Directives
# line 451
#define 446
#elif 444
#else 444
#endif 444
#error 451
#if 444
#if !defined 444
#if defined 444
#ifdef 444
#ifndef 444
#include 444
#pragma 451
#undef 448
.COMMENT 301
ALIGN 301
BFRACT 303
BLKB 304
BLKL 304
BLKP 304
BLKW 304
compatibility 325
CPU 302
data 303
DB 305
DD 305
DEFINE 293, 306, 307
definition 301
DF 305
DL 306
DS 308
DW 306
END 308
ENDMACRO 316
EQU 308
UM014418-0205
EXTERN 319
FRACT 303
IF 313
IFDEF 314
IFMA 315
IFSAME 315
in assembly 296, 301
INCLUDE 309
LIST 309
MACDELIM 318
MACEXIT 318
MACRO 316
NEWPAGE 310
NOLIST 310
null 452
ORG 310
preprocessing 441
syntax 441
SCOPE 319
SEGMENT 293, 311
TITLE 311
UBFRACT 303
UFRACT 303
VECTOR 312
XDEF 312
XREF 313, 319
Disable All Breakpoints button 70, 168
Disable All button 90, 183
Disable Breakpoint command 183
Disassemble the code 19
Disassembly window 19, 179
Disassembly Window button 71
Display Errors/Warnings Only check box 114
Display Warnings check box 114
div function 217
div_t 206
div_t div 208
Division by zero encountered 278
DL directive 306
Do Not Erase Info Page 152
do statement 433
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
474
double acos 203
double asin 203
double atan 203
double atan2 203
double atof 207
double cos 203
double cosh 204
double exp 204
double fabs 204
double floor 204
double fmod 204
double frexp 204
double ldexp 204
double log 204
double log10 204
double modf 204
double pow 204
double sin 203
double sinh 204
double sqrt 204
double strtod 207
double tan 203
double tanh 204
Download Code button 67, 69, 166
Driver
definition 17
selecting 7, 17
DS directive 308
DW directive 306
E
Edit Breakpoints command 181
Edit menu 86
Breakpoints 89
Copy 86
Cut 86
Delete 87
Find 87
Find in Files 88
Go to Line 87
UM014418-0205
Paste 87
Redo 86
Replace 89
shortcuts 454
Undo 86
Edit toolbar 66
Edit window 73
code line indicators 166
Editor tab, Options dialog box 157
EDOM 198, 203, 206
#elif preprocessing directive 444
#else preprocessing directive 444
Embedding assembly in C 260
Emulators
quick tour 20
supported xxvii
Enable All button 90, 182
Enable Breakpoint command 183
Enable check box 153
Enable/Disable Breakpoint button 68, 70, 168
END directive 308
End of file encountered before end of macro
call 278
#endif preprocessing directive 444
ENDMACRO directive 316
End-of-file found before #endif directive 278
Enumerated types 381
Enumeration constants in C 384
Enumeration specifiers 419
EQU directive 308
Equality operator 406
ERANGE 198, 203, 206
ERASE button 152
Erase Flash Before Burning check box 152
errno macro 198, 199
<errno.h> header 198
ERROR (000) 276
ERROR (001) 276
ERROR (002) 276
ERROR (003) 276
ERROR (004) 276
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
475
ERROR (005) 276
ERROR (006) 276
ERROR (007) 277
ERROR (008) 277
ERROR (009) 277
ERROR (010) 277
ERROR (011) 277
ERROR (012) 277
ERROR (013) 277
ERROR (014) 277
ERROR (015) 277
ERROR (016) 277
ERROR (017) 277
ERROR (018) 277
ERROR (019) 277
ERROR (020) 277
ERROR (021) 278
ERROR (022) 278
ERROR (023) 278
ERROR (024) 278
ERROR (025) 278
ERROR (026) 278
ERROR (027) 278
ERROR (028) 278
ERROR (029) 278
ERROR (030) 278
ERROR (031) 278
ERROR (032) 278
ERROR (033) 278
ERROR (034) 278
ERROR (035) 278
ERROR (036) 279
ERROR (037) 279
ERROR (100) 279
ERROR (101) 279
ERROR (102) 279
ERROR (103) 279
ERROR (104) 279
ERROR (105) 279
ERROR (106) 279
ERROR (107) 279
UM014418-0205
ERROR (108) 279
ERROR (109) 279
ERROR (110) 280
ERROR (111) 280
ERROR (112) 280
ERROR (113) 280
ERROR (114) 280
ERROR (115) 280
ERROR (116) 280
ERROR (117) 280
ERROR (118) 280
ERROR (119) 280
ERROR (120) 280
ERROR (121) 280
ERROR (122) 280
ERROR (123) 281
ERROR (124) 281
ERROR (125) 281
ERROR (126) 281
ERROR (127) 281
ERROR (128) 281
ERROR (129) 281
ERROR (130) 281
ERROR (131) 281
ERROR (132) 281
ERROR (133) 281
ERROR (134) 281
ERROR (135) 281
ERROR (136) 281
ERROR (137) 282
ERROR (138) 282
ERROR (139) 282
ERROR (140) 282
ERROR (141) 282
ERROR (142) 282
ERROR (143) 282
ERROR (144) 282
ERROR (145) 282
ERROR (146) 282
ERROR (147) 282
ERROR (148) 282
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
476
ERROR (149) 283
ERROR (150) 283
ERROR (151) 283
ERROR (152) 283
ERROR (153) 283
ERROR (154) 283
ERROR (155) 283
ERROR (156) 283
ERROR (157) 283
ERROR (158) 283
ERROR (159) 283
ERROR (160) 283
ERROR (161) 283
ERROR (162) 284
ERROR (163) 284
ERROR (164) 284
ERROR (165) 284
ERROR (166) 284
ERROR (167) 284
ERROR (168) 284
ERROR (169) 284
ERROR (170) 284
ERROR (171) 284
ERROR (172) 284
ERROR (173) 284
ERROR (174) 285
ERROR (175) 285
ERROR (176) 285
ERROR (177) 285
ERROR (178) 285
ERROR (179) 285
ERROR (180) 285
ERROR (181) 285
ERROR (182) 285
ERROR (183) 285
ERROR (184) 285
ERROR (185) 285
ERROR (186) 286
ERROR (187) 286
ERROR (188) 286
ERROR (189) 286
UM014418-0205
ERROR (190) 286
ERROR (191) 286
ERROR (192) 286
ERROR (193) 286
ERROR (194) 286
ERROR (195) 286
ERROR (196) 286
ERROR (197) 286
ERROR (198) 286
ERROR (199) 286
ERROR (200) 287
ERROR (201) 287, 288
ERROR (202) 288
ERROR (303) 288
ERROR (308) 288
ERROR (309) 288
ERROR (310) 288
ERROR (312) 289
ERROR (313) 289
ERROR (400) 328
ERROR (401) 328
ERROR (402) 328
ERROR (403) 328
ERROR (404) 329
ERROR (405) 329
ERROR (406) 329
ERROR (407) 329
ERROR (408) 329
ERROR (409) 329
ERROR (410) 329
ERROR (411) 329
ERROR (412) 329
ERROR (413) 329
ERROR (414) 329
ERROR (415) 329
ERROR (416) 329
ERROR (417) 330
ERROR (418) 330
ERROR (419) 330
ERROR (420) 330
ERROR (421) 330
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
477
ERROR (422) 330
ERROR (423) 330
ERROR (424) 330
ERROR (425) 330
ERROR (426) 330
ERROR (427) 330
ERROR (428) 330
ERROR (429) 330
ERROR (430) 330
ERROR (431) 330
ERROR (432) 331
ERROR (433) 331
ERROR (434) 331
ERROR (435) 331
ERROR (436) 331
ERROR (437) 331
ERROR (438) 331
ERROR (439) 331
ERROR (442) 331
ERROR (444) 331
ERROR (445) 331
ERROR (446) 331
ERROR (447) 331
ERROR (448) 331
ERROR (450) 332
ERROR (451) 332
ERROR (452) 332
ERROR (453) 332
ERROR (461) 332
ERROR (462) 332
ERROR (464) 332
ERROR (470) 332
ERROR (475) 332
ERROR (476) 332
ERROR (480) 332
ERROR (481) 332
ERROR (482) 332
ERROR (483) 332
ERROR (490) 333
ERROR (499) 333
ERROR (700) 369
UM014418-0205
ERROR (701) 369
ERROR (704) 370
ERROR (708) 370
ERROR (710) 370
ERROR (711) 370
ERROR (712) 370
ERROR (713) 370
ERROR (714) 370
ERROR (715) 370
ERROR (717) 370
ERROR (718) 370
ERROR (719) 370
ERROR (720) 370
ERROR (721) 370
ERROR (723) 371
ERROR (724) 371
ERROR (726) 371
ERROR (727) 371
ERROR (730) 371
ERROR (731) 371
ERROR (732) 371
ERROR (736) 371
ERROR (738) 371
ERROR (739) 371
ERROR (740) 371
ERROR (742) 371
ERROR (743) 371
ERROR (745) 371
ERROR (746) 372
ERROR (747) 372
ERROR (748) 372
ERROR (749) 372
ERROR (751) 372
ERROR (753) 372
Error conditions 198, 203
Error directive 451
Error messages
ANSI C-Compiler 276
assembler 328
linker/locator 369
#error preprocessing directive 451
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
478
Escape sequences 384, 385
Ethernet check box 141
Ethernet target, setting up 131
Ethernet, setting up 20
Executable Formats area 129
Executable formats, for Linker 129
exit, script file command 39
exp function 217
Expand Macros check box 113
Expand Macros on Error check box 110
Exponential functions 204, 217
Exporting project as make file 141
from the command line 54
Expression statement 431
Expressions
arithmetic operators 298
binary numbers 299
Boolean operators 298
character constants 300
decimal numbers 299
definition 393
hexadecimal numbers 299
HIGH operator 299
in assembly 298
linker 358
LOW operator 299
octal numbers 300
operator precedence 300
order of evaluation 394
parenthesized 395
primary 395
relational operators 298
Extensions, language 194
EXTERN directive 319
External definitions 436
External Flash check box 151
External linkage of identifiers 378
External object definitions 439
External references, resolving 346
EXTIO 292
Extra "#endif" found 278
UM014418-0205
EXX instruction 272
__EZ80__ 452
eZ80 Simulator, setting up 30
<eZ80.h> header 210
eZ80F91, using 149
eZ80F92, using 149
eZ80F93, using 149
F
\f 385
fabs function 218
Fast Burn button 152
__FILE__ 452
File
adding 11, 92
deleting from a project 12
opening 12
reading 12
viewing 12
File extensions xxviii
.asm xxviii, 6
.c xxviii, 5
.class 92
.gif 92
.hex xxviii, 6, 129
.htm 92
.html 92
.jar 92
.jpeg 92
.jpg 92
.lib xxviii
.libcmd xxviii
.linkcmd xxviii
.lis xxviii, 109
.lnk xxix
.lod xxix, 6, 129, 343
.lst xxix, 110, 294
.mak xxix
.map xxix, 117, 347, 369
.obj xxx, 5, 6, 294, 295
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
479
.pro xxx
.s xxx
.src xxx
.srec xxx, 6, 129
.wav 92
.wsp xxx, 83
.zdsproj xxx, 8
File Groups field 162
File menu 78
Close File 79
Close Project 83
Exit 86
New File 79
New Project 80
Open File 79
Open Project 82
Print 84
Print Preview 84
Print Setup 85
Recent Files 85
Recent Projects 86
Save 83
Save All 84
Save As 83
Save Project 83
shortcuts 454
File Offset field 152
File toolbar 65
File Type drop-down list box 158
File types xxviii
File Types tab, Options dialog box 161
Fill Memory dialog box 173
Find dialog box 87
Find field 66
Find in Files 2 Output window 77
Find in Files button 66
Find in Files dialog box 88
Find in Files Output window 76
Finding characters 243, 247
Finding strings 246, 247
Fixed-point representations, fractional 191
UM014418-0205
Flag characters for printf 232
Flash Base field 151
Flash Configuration area 151
Flash Loader
running from the Command Processor 51
using the GUI 149
Flash Loader Processor dialog box 150
Flash Options area 150
Flash-based target 187
configuring 187
debugging with 189
FlashDevice.xml file 151
<float.h> header 201
Floating types 381
converting to integral 390
Floating-point operations, incorrect results 276
floor function 218
FLT_DIG 201
FLT_MANT_DIG 201
FLT_MAX 202
FLT_MAX_10_EXP 202
FLT_MAX_EXP 202
FLT_MIN 202
FLT_MIN_10_EXP 202
FLT_MIN_EXP 202
FLT_RADIX 202
FLT_ROUND 202
fmod function 218
Font dialog box 160
for statement 433
FORMAT command 346
__FPLIB__ 452
fract 194
assigning values 191
default promotions 191
passing arguments 193
FRACT directive 303
Fractional arithmetic, scaled 193
Fractional expressions 192
Fractional fixed-point representations 191
Fractional numbers 194
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
480
signed 191
Fractional values 192
free function 219
FREEMEM operator 361
frexp function 219
Full expression, types 429
Function calls 396
Function declarators 423
Function definitions 436
Function designator, definition 391
Function names, assigned 195, 262
Function prototype, definition 378
Functions
abs 210
acos 211
asctime 452
asin 211
assert 212
assigned names 195
atan 212
atan2 213
atof 213
atoi 213
atol 214
bsearch 214
calloc 215
ceil 215
cos 216
cosh 216
definition 381
detailed descriptions of 210
div 217
exp 217
fabs 218
floor 218
fmod 218
free 219
frexp 219
getchar 220
gets 220
isalnum 221
UM014418-0205
isalpha 221
iscntrl 221
isdigit 222
isgraph 222
islower 222
isprint 223
ispunct 223
isspace 223
isupper 224
isxdigit 224
labs 224
ldexp 225
ldiv 225
log 226
log10 226
longjmp 226
malloc 227
memchr 228
memcmp 228
memcpy 229
memmove 229
memset 229
modf 230
pow 230
printf 231
putchar 234
puts 234
qsort 234
rand 235
realloc 235
scanf 236
setjmp 239
sin 240
sinh 240
sprintf 240
sqrt 241
srand 241
sscanf 242
strcat 242
strchr 243
strcmp 243
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
481
strcpy 243
strcspn 244
strlen 244
strncat 245
strncmp 245
strncpy 246
strpbrk 246
strrchr 247
strspn 247
strstr 247
strtod 248
strtok 249
strtol 250
tan 251
tanh 251
tolower 251
toupper 252
using 196
va_arg 252
va_end 253
va_start 254
vprintf 255
vsprintf 255
G
General tab
Options dialog box 156, 157
Project Settings dialog box 13, 93, 94, 146
Generate Assembly Source (.src) check box
110
Generate Compiler Listing File (.lis) check box
109
Generate Debug Information check box 117
Generate Listing File (.lst) check box
Assembler tab 113
C tab 110
Generate Map File check box 117
Generate Object check box 113
Generate Printfs Inline check box 102
Generate Warnings check box 117
UM014418-0205
getchar function 220
gets function 220
.gif file extension 92
Global optimizations
definition 103
setup 106
Go button 68, 70, 167
Go to Code button 90, 182
Go to Line Number dialog box 87
go, script file command 39
goto statement 434
GROUP command 346
Groups
allocation order 355
definition 335
linking sequence 354
locating 347
renaming 343
setting maximum size 353
setting ranges 355
H
Header files
nonstandard 197
reserved words 196
standard 197
using 198
Headers
location 197
HEADING command 347
Help menu 163
About 163
Help Topics 163
Online Registration 163
Hex button 153
Hex code, size of 369
Hex file
creating 369
size of 369
.hex file extension xxviii, 6, 129
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
482
Hexadecimal Display check box 161
Hexadecimal numbers in assembly 299
Hexadecimal values
in linker expressions 363
viewing 177
HIGH operator 299
HIGHADDR operator 362
.htm file extension 92
.html file extension 92
HUGE_VAL macro 203, 206
Hyperbolic cosine, computing 216
Hyperbolic functions 204
Hyperbolic sine, computing 240
Hyperbolic tangent, calculating 251
I
Identifiers
C language 377
definition 377, 395
external linkage 378
internal linkage 379
linkages 378
name spaces 379
no linkage 379
scope 378
types 380
IEEE 695 format 6, 129, 346
IEF1 bit flag 321
IEF2 321
#if !defined preprocessing directive 444
#if defined preprocessing directive 444
IF directive 313
#if preprocessing directive 444
if statement 105, 432
IFDEF directive 314
#ifdef preprocessing directive 444
IFMA directive 315, 317
#ifndef preprocessing directive 444
IFSAME directive 315
UM014418-0205
Ignore Case check box
Assembler tab 113
Linker tab 117
Illegal "#line" directive syntax 278
Illegal constant expression 278
Illegal macro name 278
INCLUDE directive 309
#include directive 110, 196, 444
Include Path field 114
Include Serial in Burn check box 153
Included in Project button 122
caution 124, 341
Increment Dec (+/-) field 153
Indirection operator 400
_init_default_vectors 268
Initialization 426
of aggregate objects 427
Initializer is not assignment compatible 286
Insert Breakpoint command 181
Insert Spaces button 158
Insert/Remove Breakpoint button 68, 70, 168,
180
Inserting breakpoints 180
Installation 3
Instruction Set Simulator
configuring 184
debugging with 185
description 7, 184
quick tour 29
setting up 30
Instructions in assembly 296
int abs 208
int atoi 207
int getchar 206
int isalnum 200
int isalpha 200
int iscntrl 200
int isdigit 200
int isgraph 200
int islower 200
int isprint 200
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
483
int ispunct 200
int isspace 200
int isupper 200
int isxdigit 200
int keyword 415
int memcmp function 209
int printf 206
int putchar 206
int puts 206
int rand 207
int scanf 206
int setjmp 205
int sprintf 206
int sscanf 206
int strcmp 209
int strncmp 209
int tolower 200
int toupper 200
int vsprintf 206
INT_MAX 200
Integer constants in C 383
Integers
signed 389
unsigned 389
Integral constant expression 412
Integral promotion
default 192
definition 389
Integral types 381
Intel 16-bit Hex 346
Intel 32-bit 346
Intel Hex Records format 6, 346
Intel Hex16 - Records check box 129
Intel Hex16 format 129
Intel Hex32 - Records check box 129
Intel Hex32 format 129
Interleave Source and Assembly check box 110
Internal Flash check box 151
Internal linkage of identifiers 379
Interrupt handler
arguments 268
UM014418-0205
creating in C 267
preserved registers 272
interrupt keyword 267, 272
Interrupts, using 268
INTIO 292
Intrinsic functions 257
Intrinsics, definition 102
IP Address field 20, 131
isalnum function 221
isalpha function 221
iscntrl function 221
isdigit function 222
isgraph function 222
islower function 222
isprint function 223
ispunct function 223
isspace function 223
isupper function 224
isxdigit function 224
Iteration statements 433
J
.jar file extension 92
jmp_buf 204
.jpeg file extension 92
.jpg file extension 92
Jump Optimization check box 113
Jump statements 434
K
Keep Tabs button 158
-keepasm 295
Keywords 194
ANSI C language 376
const 194
interrupt 267, 272
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
484
L
Labeled statements 430
Labels
assigning to a space 319
exporting 319
importing 319
in assembly language 296, 319
local ($) 319
local (?) 319
location checks 319
name 378
labs function 224
Language extensions 194
Largest integer, computing 218
LDBL_DIG 202
LDBL_MANT_DIG 202
LDBL_MAX 202
LDBL_MAX_10_EXP 202
LDBL_MAX_EXP 202
LDBL_MIN 202
LDBL_MIN_10_EXP 202
LDBL_MIN_EXP 202
ldexp function 225
ldiv function 225
ldiv_t 206
ldiv_t ldiv 208
LENGTH operator 362
Lexical elements of C 375
.lib file extension xxviii
.libcmd file extension xxviii
Librarian
command line options 62
options 46
Libraries
defining 343
functions 210
object 334
Library file, creating xxviii
Library functions
detailed descriptions of 210
using 196
UM014418-0205
<limits.h> header 200
__LINE__ 452
Line continuation in assembly 295
Line control 451
Line number 451
Link Configuration button 117
Link map file
contents 347
creating 347, 354
generating xxix, 117
.linkcmd file extension xxviii, 43
Linker
case sensitivity 117
command line options 62
commands 341
configuring 6, 339
controlling the link order 365
creating link map file 347, 354
creating linking sequence 354
debugging code 367
defining holes in memory 128
description 6
detailed description 334
error messages 369
expressions 358
file format 346
generating debug information 345, 354,
366
generating warnings 357
interactions with assembler 335
interactions with compiler 335
memory used 369
objects manipulated during linking 334
options 46
reducing execution times 366
running from the command line 55
search order 355
speeding up 366
suppressing warnings 354
troubleshooting 365
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
485
using directives to initialize variables 124,
341
warning messages 124, 341, 369
Linker command file 341
commands 342
creating 6
customizing 126
Linker Command File area 125
Linker commands
<outputfile>=<module list> 343
BASE OF 344
CHANGE 343
COLOR 344
COPY 344
COPY BASE OF 344
COPY TOP OF 344
DEBUG 345
DEFINE 346
FORMAT 346
GROUP 346
HEADING 347
LOCATE 347
MAP 347
MAXHEXLEN 353
MAXLENGTH 353
NOCOLOR 344, 353
NODEBUG 354
NOMAP 347, 354
NOWARN 354
ORDER 354
RANGE 355
SEARCHPATH 355
SEQUENCE 355
SORT 356
SPLITTABLE 356
TOP OF 344
UNRESOLVED IS FATAL 357
WARN 357
WARNING IS FATAL 358
WARNOVERLAP 358
UM014418-0205
Linker directives
adding to new project 124, 341
using to initialize variables 124, 341
Linker expressions
- (subtract) 364
& (and) 360
* (multiply) 363
+ (add) 359
/ (divide) 361
<< (shift left) 364
>> (shift right) 364
^ (bitwise exclusive or) 365
| (or) 364
~ (not) 365
BASE OF 360
COPY BASE 361
COPY TOP 361
decimal numeric values 363
FREEMEM 361
hexadecimal numeric values 363
HIGHADDR 362
LENGTH 362
LOWADDR 362
TOP OF 364
Linker tab 116
Linker/locator error messages 369
Linker/locator warning messages 369
Linking sequence, creating 354
.lis file extension xxviii, 109
.lst file extension 110
list bp, script file command 40
LIST directive 309
List Include Files in .lis check box 110
Listing file
assembly 110, 113, 294
compiler xxviii, 109
.lnk file extension xxix
Load Debug Information (Current Project)
check box 161
Load from File dialog box 175
Load Last Project on Startup check box 156
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
486
Load Memory Files check box 30, 135
Local labels in assembly 319
Local macro label 317
Local optimizations
definition 103
setup 104
Locals window 178
Locals Window button 71
LOCATE command 347
Locator
configuring 6
description 6
detailed description 334
error messages 369
warning messages 369
.lod file extension xxix, 6, 129, 343
log function 226
log, script file command 40
log10 function 226
Logarithm, computing 226
Logarithmic functions 204
Logical AND operator (&&) 408
Logical OR operator (||) 408
long int atol 207
long int labs 208
long int strtol 207
long keyword 415
LONG_MAX 200
LONG_MIN 200
longjmp function 226
Loop body, definition 433
Loop Optimizations check box 106
Loop optimizations, definition 106
LOW operator 299
LOWADDR operator 362
.lst file extension xxix, 294
Lvalue 390
UM014418-0205
M
MACDELIM directive 318
MACEXIT directive 318
Macro Assembler
adding null characters 297
addressing modes 320
arithmetic operators 298
binary numbers 299
Boolean operators 298
case sensitivity 113, 296
character constants 300
character strings 297
command line options 55
configuring 6
decimal numbers 299
description 5
directive compatibility 325
directives 301
error messages 328
expressions 298
floating-point numbers 297
generating listing file (.lst) 294
generating object file 294
hexadecimal numbers 299
numeric representation 297
octal numbers 300
operator precedence 300
relational operators 298
reserved words 296
running from the command line 55
setup 112
syntax 322
using 290
warning messages 328
MACRO directive 316
Macros 315
__ACCLAIM__ 452
__DATE__ 452
__EZ80__ 452
__FILE__ 452
__FPLIB__ 452
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
487
__LINE__ 452
__MODEL__ 452
__STDC__ 452
__TIME__ 452
__ZDATE__ 452
__ZILOG__ 453
concatenation character 316
defining 316, 388
delimiter characters 318
delimiting arguments 318
exiting 318
expanding 110, 113
invocation 317
labels 317
name 446
optional arguments 317
predefined 275, 452
replacement 446
scope of definition 448
using 453
MADL bit flag 321
_main has not been defined 127
.mak file extension xxix
Make file, exporting 141
make, script file command 40
malloc function 227
Manage Configurations dialog box 146, 147,
148
Manifest constant, defining 449
MAP command 347
.map file extension xxix, 117, 347, 369
Map file, generating 117
<math.h> header 203
Mathematical functions 203
Mathematical macros 203
Max Errors field 97
MAXHEXLEN command 353
MAXLENGTH command 353
MB_CUR_MAX macro 207
memchr function 228
memcmp function 228
UM014418-0205
memcpy function 229
memmove function 229
Memory
accessing 291
amount used by program 369
defining holes 128
defining locations 291
filling 172
loading to file 174
saving to file 173
Memory management functions 207
Memory range
syntax 128
Memory window 171
changing values 171
filling memory 172
finding addresses 171
loading to file 174
saving to file 173
viewing addresses 171
Memory Window button 71
memset function 229
Menus
Build 141
Edit 86
File 78
Help 163
Project 92
right click 72, 73, 75, 76, 77, 176, 177, 178,
179, 180
shortcuts 454
Tools 149
View 90
Windows 162
Messages Output window 77
Minimum requirements for ZDS II 2
__MODEL__ 452
modf function 230
Modifiable lvalue 390
Modules
defining 343
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
488
definition 334
Motorola S - Records check box 129
Motorola S-Records 346
Motorola S-Records format 6, 129
Moving characters 229
Multiplicative operators 402
N
\n 385
Naming conventions, compiler 194
NDEBUG macro 199
Nearest integer functions 204
New button 65
New project
adding files 11, 92
adding linker directives 124, 341
building 15
configuring 12
creating 8, 80
debugging 16
deleting files 12, 79
initialize variables 124, 341
saving 16
setting up 12
New Project dialog box 9, 80
new project, script file command 40
New segments, creating 293
New toolbar 154
New Toolbar dialog box 155
NEWPAGE directive 310
NMI 268
No function prototype <name> in scope 286
NOCOLOR command 344, 353
NODEBUG command 354
NOLIST directive 310
NOMAP command 347, 354
Nonmaskable interrupt 268
NOWARN command 354
Null character (0) 374, 386
Null directive 452
UM014418-0205
NULL macro 199, 207, 208
Null pointer 391
Null pointer constant, definition 391
NULL, using 343, 345
NULL-terminated ASCII, viewing 178
Numbers
binary 299
decimal 299
hexadecimal 299
octal 300
O
.obj file extension xxx, 5, 6, 294, 295
Object code file 295
Object formats
for Linker 129
IEEE 695 6, 129
Intel Hex Records 6
Intel Hex16 129
Intel Hex32 129
Motorola S-Records 6, 129
OMF695 294, 295
Object libraries 334
Object Size group 108
Object sizes 108
Object/Library Modules field
General category 117
Input category 122
Objects, storage duration 380
Octal numbers in assembly 300
offsetof macro 199
OMF695 format 294, 295
One Code Segment per Module check box 102
Open button 65
Open dialog box 79
Open Project dialog box 82
open project, script file command 41
Operator precedence in assembly 300
Operators
- (subtract) 364
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
489
# 388, 447
## 388, 448
& (and) 360
* (multiply) 363
+ (add) 359
/ (divide) 361
<< (shift left) 364
>> (shift right) 364
[ ] 388
^ (bitwise exclusive or) 365
| (or) 364
~ (not) 365
additive 403
difference (binary -) 404
sum (binary +) 404
address of (unary &) 400
arithmetic 298
assignment 409, 410
compound (+=) 411
compound (-=) 411
simple (=) 410
BASE OF 360
bitwise AND (&) 406, 407
bitwise exclusive OR (^) 407
bitwise inclusive OR (|) 407
bitwise shift 404
Boolean 298
cast 402
comma (,) 411
conditional (?:) 388, 409
COPY BASE 361
COPY TOP 361
equality 406
equal to (==) 406
not equal to (!=) 406
FREEMEM 361
function call ( ( ) ) 388
HIGH 299
HIGHADDR 362
indirection (unary *) 400, 404
LENGTH 362
UM014418-0205
list of 387
logical AND (&&) 408
logical OR (||) 408
LOW 299
LOWADDR 362
multiplicative 402
binary (*) 403
modulo (%) 403
quotient (/) 403
postfix 395
postfix decrement (--) 399
postfix increment (++) 399
precedence 300
prefix decrement (--) 399
prefix increment (++) 399
relational 298, 405
greater than (>) 406
greater than or equal to (>=) 406
less than (<) 406
less than or equal to (<=) 406
sizeof 401
TOP OF 364
unary 399
unary arithmetic
- 400
! 400
+ 400
~ 400
Optimizations list box
General category 96
Optimizations category 104, 106
Optimize For buttons 105, 107, 267
Optimizer
configuring 5, 96, 103
global optimizations 106
local optimizations 104
setup 96
option, script file command 41
Options 41
assembler 42
compiler 42
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
490
debugger 46
general 47
librarian 46
linker 46
Options dialog box 156
Debugger tab 160, 161
Editor tab 157, 158
File Types tab 161, 162
General tab 156, 157
ORDER command 354, 359
ORG clause 307
ORG directive 310
Output File field 129
Output File Name field 116
Output Files Directory field 94
Output Window button 66
P
Page Length field 114
Page Width field 114
Parenthesized expression, definition 395
Paste button 66
PC, definition 166
Peephole Optimizations check box 105
Peephole optimizations, definition 105
Perform Re-List check box 117
Placing breakpoints 180
Pointer declarators 421
Pointers 391
Port list box 23, 133
Ports area 115
Ports, choosing 23, 133
Postfix (--) operator 399
Postfix (++) operator 399
Postfix decrement operator 398
Postfix increment operator 398
Postfix operators 395
pow function 230
Power functions 204
#pragma alias 256
UM014418-0205
#pragma bss 257
#pragma cpu 256
#pragma globalcopy 256
#pragma globalcse 257
#pragma globaldeadvar 257
#pragma globalfold 257
#pragma intrinsics 257
#pragma jumpopt 257
#pragma localcopy 258
#pragma localcse 258
#pragma localfold 258
#pragma localopt 258
#pragma noalias 256
#pragma noglobalcopy 256
#pragma noglobalcse 257
#pragma noglobaldeadvar 257
#pragma noglobalfold 257
#pragma nointrinsics 257
#pragma nojumpopt 257
#pragma nolocalcopy 258
#pragma nolocalcse 258
#pragma nolocalfold 258
#pragma nolocalopt 258
#pragma noopt 258
#pragma nooptlink 258
#pragma nopeephole 259
#pragma nopromote 259
#pragma nosdiopt 259
#pragma nostkck 259
#pragma nostrict 259
#pragma optlink 258
#pragma optsize 258
#pragma optspeed 259
#pragma peephole 259
#pragma preprocessing directive 451
#pragma promote 259
#pragma sdiopt 259
#pragma stkck 259
#pragma strict 259
#pragma, using 256, 260, 274, 451
Predefined address spaces 291
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
491
Predefined macros 275, 452
Prefix character 321
Prefix decrement operators 399
Prefix increment operators 399
Preprocessing
argument substitution 447
conditional inclusion 443
definition 443
directives 441
# line 451
#define 446
#elif 444
#else 444
#endif 444
#error 451
#if 444
#if !defined 444
#if defined 444
#ifdef 444
#ifndef 444
#include 444
#pragma, using 451
#undef 448
syntax 441
error directive 451
line control 451
macro replacement 446
null directive 452
pragma directive 451
predefined macros 452
redefinition 449
reexamination 449
replacement 448
rescanning 448
source file inclusion 444
tokens
# 447
## 448
( 446
) 446, 447
Preprocessor commands 441
UM014418-0205
Preprocessor Definitions field 111
Primary expressions 395
Print button 66
Print Preview window 85
print, script file command 47
printf function 231
.pro file extension xxx
Program, sample 8
Programmable reload timer peripheral simulation 184
Programmer’s editor 5
Project
adding files 11, 92
adding web files 92
building 15, 142
compiling 142
configuring 12, 144
copying configurations 146
creating 8, 80
debugging 16
deleting files 12, 79
exporting as make file 141
saving 16
setting up 12
Project file, creating 8
Project menu 92
Add Files 92
Export Makefile 141
Remove Selected File(s) 93
Settings 93
shortcuts 455
Project Settings dialog box 93
Assembler tab 112, 130
C tab 95
Code Generation category 97
Data Types category 107, 108
General category 14, 96
Listing Files category 109
Optimizations category 103, 104
Preprocessor category 111
Debugger tab 15, 130
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
492
General tab 13, 93, 94, 146
Linker tab 116
Address Spaces category 127
General category 116
Input category 122
Output category 128, 129
ZSL tab 115
Project Workspace window 72
Prototypes 423
Pseudorandom sequence generation 207, 241
ptrdiff_t 198
Public symbols, creating 346
Punctuator 388
( ) 388
[ ] 388
{ } 388
definition 388
putchar function 234
puts function 234
pwd, script file command 48
Q
qsort function 234
Quick tour
Command Processor 31
debugger 16
developer’s environment 7
emulator 20
Instruction Set Simulator 29
ZDS II 7
quit, script file command 48
Quotient, computing 217, 225
R
\r 385
RAM 291
RAM-based target
configuring 185
debugging with 186
UM014418-0205
description 185
rand function 235
RAND_MAX macro 207
RANGE command 355
Range error, generating 128
Reading input 236
Readme.txt, location of xxvi
realloc function 235
Rebuild All button 67
rebuild, script file command 48
Recursive structure declaration 286
Red octagon 166, 181
Redefinition 449
Reexamination 449
Register variable 273
Registers
changing values 169
using 195, 262
variable 273
Registers window 169
Registers Window button 71
Relational operators 405
in assembly 298
Release configuration 144
-relist 295
Relist target 117
Relocatable object module 5, 6
Relocatable segments 291, 293, 334
Remainder, computing 218
remdouble ceil 204
Remove All Breakpoints button 68, 71, 168
Remove All button 90, 183
Remove Breakpoint command 183
Remove button 90, 183
Replace dialog box 89
Replacement 448
Requirements for ZDS II 2
Rescanning 448
Reserved words
ANSI C language 376
in assembly 296
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
493
in headers 196
Reset button 68, 69, 167
Reset to Symbol ’main’ (Where Applicable)
check box 160
reset, script file command 48
return statement 435
Revision history iii
Right-click menus
Build Output window 75
Call Stack window 179
Command Output window 77
Debug Output window 76
Disassembly window 180
Find in Files 2 Output window 77
Find in Files Output window 76
in Edit window 73, 75
in Project Workspace window 72
Locals window 178
Messages Output window 77
Watch window 176, 177
ROM 291
ROM-based target 187
configuring 187
debugging with 189
Run Command button 68
Run to Cursor button 70, 167
Run-time library
formatting 196
functions 210
using 127, 196
using functions 196
S
.s file extension xxx
.src file extension xxx
Sample files 8
Sample program 8
Save All button 66
Save As dialog box 83, 141
Save button 65
UM014418-0205
Save Files Before Build check box 156
Save Project Before Start of Debug Session
check box 160
Save to File dialog box 174
Save/Restore Project Workspace check box
157
Saving a project 16
Scalar types 381
Scaled fractional arithmetic 193
scanf function 236
SCHAR_MAX 201
SCHAR_MIN 201
Scope
definition 378
of macro definitions 448
types of 378
SCOPE directive 319
Script file
commands 32
definition 31
example 31
writing 31
Search functions 209, 214
SEARCHPATH command 355
SEGMENT directive 293, 311
Segments 291
absolute 291, 293, 294, 307, 334
address space 307
alignment 293, 307
allocation order 355
attaching code 293
attaching data 293
copy 335
copying 344
creating 293
defining 293, 306
description 292, 334
graph coloring 344, 353
linking sequence 354
locating 307, 347
moving 343
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
494
new 293
origin 293
relocatable 291, 293, 334
renaming 343
setting maximum size 353
setting ranges 355
splitting 356
types 291
user defined 293
Select Active Configuration list box 67, 145
Select Configuration dialog box 145
Select Link Configuration dialog box 118, 339
Select Target area 131
Selection statements 432
SEQUENCE command 355, 359
Sequence points, list 393
Serial check box 140
Serial driver, setting up 23
Serial Number list box 26, 134
Serial number, choosing 26, 134
Serial SmartCable 23
Serial SmartCable requirements 3
Serial target, setting up 132
Serial Value field 153
set config, script file command 48
Set Next Instruction button 70, 168
_set_vector 268
setjmp function 239
<setjmp.h> header 204
Setting breakpoints 180
Setup button 135
Setup Serial Communication dialog box 132
Setup Simulator dialog box 30, 135
Setup TcpIP Communication dialog box 131
Setup USB Communication dialog box 134
Shortcut keys 454
Show DataTips Pop-Up Information check box
160
Show Tabs check box 158
Show the Full Path in the Document Window’s
Title Bar check box 157
UM014418-0205
SHRT_MAX 201
SHRT_MIN 201
Signed fractional arithmetic 193
Signed fractional numbers, support 191
Signed fractional variable 191
Signed integer types 380
Signed integers 389
signed keyword 415
Simulator
description 7
quick tour 29
selecting 7
setting up 30
Simulator Throttle 30, 135
recommended setting 30, 135
sin function 240
Sine, computing 240
sinh function 240
size_t 199, 206, 208
size_t strcspn 209
size_t strlen 210
size_t strspn 209
Sizeof operator 401
Smallest integer, computing 215
SmartCable
serial 23
USB 26
Software installation 3
SORT command 356
Sorting arrays 234
Sorting integers 235
Source file inclusion 444
Source line
contents 296
definition 296
labels 296, 319
SPACE clause 307
Span-Dependent Instructions check box 106
Span-dependent instructions, definition 106
Special Function Registers window 170
Special Function Registers Window button 71
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
495
Special function registers, changing values 170
Specifiers, storage class 413
SPLITTABLE command 356
sprintf function 240
sqrt function 241
Square root, calculating 241
srand function 241
.srec file extension xxx, 6, 129
sscanf function 242
Standard configuration 81, 119
Standard field 111
Starting a project 8
Statements 429
block 430
break 435
compound 430
continue 434
defined 429
do 433
expression 431
for 433
goto 434
if 432
iteration 433
jump 434
labeled 430
null 431
return 435
selection 432
switch 432
while 433
Static library, creating 80
Static storage duration, defined 380
Status bar 18, 165
<stdarg.h> header 205
__STDC__ 452
<stddef.h> header 198
<stdio.h> header 206
<stdlib.h> header 206
Step Into button 70, 167
Step Out button 70, 168
UM014418-0205
Step Over button 70, 167
step, script file command 49
stepin, script file command 49
stepout, script file command 49
Stop Build button 67
Stop Command button 69
Stop Debugging button 69, 167
stop, script file command 49
Storage duration for objects 380
Storage-class specifiers 413
strcat function 242
strchr function 243
strcmp function 243
strcpy function 243
strcspn function 244
Strict ANSI Conformance check box 101
String comparison 243
String conversion functions 207, 213, 214, 248,
250
String literal 449, 451
character 387
definition 387, 395
in C 386
wide 387
<string.h> header 208
String-handling functions 208
strlen function 244
strncat function 245
strncmp function 245
strncpy function 246
strpbrk function 246
strrchr function 247
STRSECT segment 292
strspn function 247
strstr function 247
strtod function 248
strtok function 249
strtol function 250
Structure identifier 417
Structure type 397
Structure, definition 381
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
496
Subscripting arrays 396
Supported emulators xxvii
Supported ZiLOG parts xxvii
switch statement 432
Symbol Cross-Reference check box 117
Symbols window 179
Symbols Window button 71
Symbols, predefined 302
Symbols, public 346
Syntax Coloring dialog box 159
System requirements for ZDS II 2
T
\t 385
Tab Size field 158
Tag, to identify structure or union 417
tan function 251
Tangent, calculating 251
tanh function 251
Target
configuring 184
selecting 130
Target Communication list box 139, 140
TCP Port field 20, 131
Technical service xxvii
Technical support xxvii
Tentative definition 439
TEXT segment 292
Tile the files 163
__TIME__ 452
TITLE directive 311
Tokens
categories 375
definition 375
tolower function 251
Toolbars
Build 67
Command Processor 68
creating 154
Debug 69, 166
UM014418-0205
Debug Windows 71, 169
Edit 66
File 65
Toolbars tab 154
Tools menu 149
Customize 154
Flash Loader 149
Options 156
TOP OF command 344
TOP OF operator 364
toupper function 252
Trigonometric functions 203
Trigraph sequences 375
Troubleshooting
C programs 264
compiler 264
linker 365
Tutorials
Command Processor 31
debugger 16
developer’s environment 7
emulator 20
Instruction Set Simulator 29
ZDS II 7
Type list box 104, 106
Type specifiers 414
type va_arg 205
Typedef 425
Types
arithmetic 390
char 389
const 392
definitions 425
equivalence 425
int 389
names 424
null pointer 391
short int 389
structure 397
union 397
void 391
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
497
volatile 392
when to specify 425
U
Uarts area 115
UBFRACT directive 303
UCHAR_MAX 201
UFRACT directive 303
UINT_MAX 201, 400, 405
ULONG_MAX 201, 400, 405
Unary arithmetic operators 400
Unary operators 399
#undef 448
Underscore 195, 196
Union identifier 417
Union type 397
Union, definition 381
Units drop-down list box 151
UNRESOLVED IS FATAL command 357
unsigned integers 389
unsigned keyword 415
Unsupported or poorly formed pragma 279
USB check box 140
USB SmartCable requirements 3
USB SmartCable, setting up 26
USB target, setting up 133
Use Alternate ZDI Clock Frequency check box
21, 24, 26, 131
Use C Runtime Library check box 127
Use Existing button 126
Use Existing field 126
Use Floating Point Library check box 97
Use Intrinsics check box 102
Use Syntax Coloring check box 159
Use ZiLOG Standard Library check box 115
User field 112
User-defined segments 293
USHRT_MAX 201
UM014418-0205
V
\v 385
va_arg function 252
va_end function 253
va_list 205
va_start function 254
Values, return 195, 263
Variables
assigned names 194
register 273
specific location 273
temporary 265
VECTOR directive 312
Verify button 152
View menu 90
Debug Windows 91
Output 91
Status Bar 91
Workspace 91
void *bsearch 208
void *calloc 207
void *malloc 207
void *memchr 209
void *memcpy 208
void *memmove 208
void *memset 210
void *realloc 207
void assert 199
void expression 391
void free 207
void longjmp 205
void qsort 208
void srand 207
void va_end 205
void va_start 205
volatile keyword 415
volatile type 392
vprintf function 255
vsprintf function 255
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
498
W
wait bp, script file command 51
wait, script file command 51
WARN command 357
WARNING (000) 276
WARNING (001) 276
WARNING (002) 276
WARNING (004) 276
WARNING (005) 276
WARNING (006) 276
WARNING (007) 277
WARNING (008) 277
WARNING (009) 277
WARNING (010) 277
WARNING (011) 277
WARNING (012) 277
WARNING (013) 277
WARNING (014) 277
WARNING (015) 277
WARNING (016) 277
WARNING (017) 277
WARNING (018) 277
WARNING (019) 277
WARNING (020) 277
WARNING (021) 278
WARNING (022) 278
WARNING (023) 278
WARNING (024) 278
WARNING (025) 278
WARNING (026) 278
WARNING (027) 278
WARNING (028) 278
WARNING (029) 278
WARNING (030) 278
WARNING (031) 278
WARNING (032) 278
WARNING (033) 278
WARNING (034) 278
WARNING (035) 278
WARNING (036) 279
WARNING (037) 279
UM014418-0205
WARNING (100) 279
WARNING (101) 279
WARNING (102) 279
WARNING (103) 279
WARNING (104) 279
WARNING (105) 279
WARNING (106) 279
WARNING (107) 279
WARNING (108) 279
WARNING (109) 279
WARNING (110) 280
WARNING (111) 280
WARNING (112) 280
WARNING (113) 280
WARNING (114) 280
WARNING (115) 280
WARNING (116) 280
WARNING (117) 280
WARNING (118) 280
WARNING (119) 280
WARNING (120) 280
WARNING (121) 280
WARNING (122) 280
WARNING (123) 281
WARNING (124) 281
WARNING (125) 281
WARNING (126) 281
WARNING (127) 281
WARNING (128) 281
WARNING (129) 281
WARNING (130) 281
WARNING (131) 281
WARNING (132) 281
WARNING (133) 281
WARNING (134) 281
WARNING (135) 281
WARNING (136) 281
WARNING (137) 282
WARNING (138) 282
WARNING (139) 282
WARNING (140) 282
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
499
WARNING (141) 282
WARNING (142) 282
WARNING (143) 282
WARNING (144) 282
WARNING (145) 282
WARNING (146) 282
WARNING (147) 282
WARNING (148) 282
WARNING (149) 283
WARNING (150) 283
WARNING (151 283
WARNING (152) 283
WARNING (153) 283
WARNING (154) 283
WARNING (155) 283
WARNING (156) 283
WARNING (157) 283
WARNING (158) 283
WARNING (159) 283
WARNING (160) 283
WARNING (161) 283
WARNING (162) 284
WARNING (163) 284
WARNING (164) 284
WARNING (165) 284
WARNING (166) 284
WARNING (167) 284
WARNING (168) 284
WARNING (169) 284
WARNING (170) 284
WARNING (171) 284
WARNING (172) 284
WARNING (173) 284
WARNING (174) 285
WARNING (175) 285
WARNING (176) 285
WARNING (177) 285
WARNING (178) 285
WARNING (179) 285
WARNING (180) 285
WARNING (181) 285
UM014418-0205
WARNING (182) 285
WARNING (183) 285
WARNING (184) 285
WARNING (185) 285
WARNING (186) 286
WARNING (187) 286
WARNING (188) 286
WARNING (189) 286
WARNING (190) 286
WARNING (191) 286
WARNING (192) 286
WARNING (193) 286
WARNING (194) 286
WARNING (195) 286
WARNING (196) 286
WARNING (197) 286
WARNING (198) 286
WARNING (199) 286
WARNING (200) 287
WARNING (201 287, 288
WARNING (202) 288
WARNING (303) 288
WARNING (308) 288
WARNING (309) 288
WARNING (310) 288
WARNING (312) 289
WARNING (400) 328
WARNING (401) 328
WARNING (402) 328
WARNING (403) 328
WARNING (404) 329
WARNING (405) 329
WARNING (406) 329
WARNING (407) 329
WARNING (408) 329
WARNING (409) 329
WARNING (410) 329
WARNING (411) 329
WARNING (412) 329
WARNING (413) 329
WARNING (414) 329
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
500
WARNING (415) 329
WARNING (416) 329
WARNING (417) 330
WARNING (418) 330
WARNING (419) 330
WARNING (420) 330
WARNING (421) 330
WARNING (422) 330
WARNING (423) 330
WARNING (424) 330
WARNING (425) 330
WARNING (426) 330
WARNING (427) 330
WARNING (428) 330
WARNING (429) 330
WARNING (430) 330
WARNING (431) 330
WARNING (432) 331
WARNING (433) 331
WARNING (434) 331
WARNING (435) 331
WARNING (436) 331
WARNING (437) 331
WARNING (438) 331
WARNING (439) 331
WARNING (442) 331
WARNING (444) 331
WARNING (445) 331
WARNING (446) 331
WARNING (447) 331
WARNING (448) 331
WARNING (450) 332
WARNING (451) 332
WARNING (452) 332
WARNING (453) 332
WARNING (461) 332
WARNING (462) 332
WARNING (464) 332
WARNING (470) 332
WARNING (475) 332
WARNING (476) 332
UM014418-0205
WARNING (480) 332
WARNING (481) 332
WARNING (482) 332
WARNING (483) 332
WARNING (490) 333
WARNING (499) 333
WARNING (700) 369
WARNING (701) 369
WARNING (704) 370
WARNING (708) 370
WARNING (710) 370
WARNING (711) 370
WARNING (712) 370
WARNING (713) 370
WARNING (714) 370
WARNING (715) 370
WARNING (717) 370
WARNING (718) 370
WARNING (719) 370
WARNING (720) 370
WARNING (721) 370
WARNING (723) 371
WARNING (724) 127, 371
WARNING (726) 371
WARNING (727) 371
WARNING (730) 371
WARNING (731) 371
WARNING (732) 371
WARNING (736) 371
WARNING (738) 371
WARNING (739) 371
WARNING (740) 371
WARNING (742) 371
WARNING (743) 371
WARNING (745) 371
WARNING (746) 372
WARNING (747) 372
WARNING (748) 372
WARNING (749) 372
WARNING (751) 372
WARNING (753) 372
Index
ZiLOG Developer Studio II
eZ80Acclaim!TM User Manual
501
WARNING IS FATAL command 358
Warning messages
ANSI C-Compiler 276
assembler 328
generating 357
linker/locator 369
suppressing 354
WARNOVERLAP command 358
Watch Compilation Process list box 96
Watch window 176
adding new variables 176
changing values 177
removing expressions 177
viewing ASCII values 177
viewing ASCIZ values 178
viewing decimal values 177
viewing hexadecimal values 177
viewing NULL-terminated ASCII 178
Watch Window button 71
.wav file extension 92
wchar_t 199, 206
Web Files folder, contents of 92
Web files-to-C conversion 92
while statement 433
White octagon 166
White space, definition 376
Wide string literal, definition 387
Windows menu 162
Arrange Icons 163
Cascade 163
Close 163
Close All 163
New Window 163
Tile 163
Workspace Window button 66
Write Memory Files check box 30, 135
Writing characters 234
Writing output 231, 240
Writing strings 234
.wsp file extension xxx, 83
UM014418-0205
X
XDEF directive 312
XREF directive 313, 319
Y
Yellow arrow 166
Yellow arrow on red octagon 166
Z
__ZDATE__ 452
ZDS
definition xxvii
latest released version xxvii
ZDS II
installation 3
quick tour 7
running from the command line 54
system requirements 2
.zdsproj file extension xxx, 8
__ZILOG__ 453
ZiLOG parts, supported xxvii
ZiLOG Standard Library 115
ZiLOG web site URL xxvii
ZMASM compatibility 325
ZPAK II requirements 3
ZSL tab, Project Settings dialog box 115
ZSL, definition 115
zsldevinit.asm file 11
Index
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement