<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2008 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>3.4.2 Z80/Z180 Storage Class Language Extensions</TITLE> <META NAME="description" CONTENT="3.4.2 Z80/Z180 Storage Class Language Extensions"> <META NAME="keywords" CONTENT="sdccman"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="sdccman.css"> <LINK REL="next" HREF="node61.html"> <LINK REL="previous" HREF="node59.html"> <LINK REL="up" HREF="node58.html"> <LINK REL="next" HREF="node61.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html1582" HREF="node61.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1576" HREF="node58.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1570" HREF="node59.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1578" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1580" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1583" HREF="node61.html">3.4.3 HC08 Storage Class</A> <B> Up:</B> <A NAME="tex2html1577" HREF="node58.html">3.4 Storage Class Language</A> <B> Previous:</B> <A NAME="tex2html1571" HREF="node59.html">3.4.1 MCS51/DS390 Storage Class</A> <B> <A NAME="tex2html1579" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html1581" HREF="node191.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <!--Table of Child-Links--> <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A> <UL> <LI><A NAME="tex2html1584" HREF="node60.html#SECTION00442100000000000000">3.4.2.1 sfr (in/out to 8-bit addresses)</A> <LI><A NAME="tex2html1585" HREF="node60.html#SECTION00442200000000000000">3.4.2.2 banked sfr (in/out to 16-bit addresses)</A> <LI><A NAME="tex2html1586" HREF="node60.html#SECTION00442300000000000000">3.4.2.3 sfr (in0/out0 to 8 bit addresses on Z180/HD64180)</A> </UL> <!--End of Table of Child-Links--> <HR> <H2><A NAME="SECTION00442000000000000000"></A><A NAME="1479"></A> <BR> 3.4.2 Z80/Z180 Storage Class Language Extensions </H2> <P> <H3><A NAME="SECTION00442100000000000000"></A><A NAME="1480"></A><A NAME="1481"></A> <BR> 3.4.2.1 sfr (in/out to 8-bit addresses) </H3> <P> The Z80<A NAME="1482"></A> family has separate address spaces for memory and <I>i</I>nput/<I>o</I>utput memory. I/O memory<A NAME="1485"></A><A NAME="1486"></A><A NAME="1487"></A> is accessed with special instructions, e.g.: <BLOCKQUOTE> <TT>__sfr __at 0x78 IoPort; /* define a var in I/O space at 78h called IoPort */ </TT> </BLOCKQUOTE> Writing 0x01 to this variable generates the assembly code: <BLOCKQUOTE> <TT>3E 01 ld a,#0x01</TT> <BR><TT>D3 78 out (_IoPort),a </TT> </BLOCKQUOTE> <P> <H3><A NAME="SECTION00442200000000000000"></A><A NAME="1496"></A><A NAME="1497"></A> <BR> 3.4.2.2 banked sfr (in/out to 16-bit addresses) </H3> <P> The keyword <I>banked</I> is used to support 16 bit addresses in I/O memory e.g.: <BLOCKQUOTE> <TT>__sfr __banked __at<A NAME="1500"></A><A NAME="1501"></A> 0x123 IoPort; </TT> </BLOCKQUOTE> Writing 0x01 to this variable generates the assembly code: <BLOCKQUOTE> <TT>01 23 01 ld bc,#_IoPort</TT> <BR><TT>3E 01 ld a,#0x01 </TT> <BR><TT>ED 79 out (c),a </TT> </BLOCKQUOTE> <P> <H3><A NAME="SECTION00442300000000000000"></A><A NAME="1508"></A><A NAME="1509"></A><A NAME="1510"></A><A NAME="1511"></A> <BR> 3.4.2.3 sfr (in0/out0 to 8 bit addresses on Z180/HD64180) </H3> <P> The compiler option --portmode<A NAME="1512"></A>=180 (80) and a compiler #pragma portmode<A NAME="1513"></A> z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructions <TT>in0/out0</TT> instead of <TT>in/out</TT>. If you include the file z180.h this will be set automatically. <P><P> <BR> <P> <HR> <!--Navigation Panel--> <A NAME="tex2html1582" HREF="node61.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1576" HREF="node58.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1570" HREF="node59.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1578" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1580" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1583" HREF="node61.html">3.4.3 HC08 Storage Class</A> <B> Up:</B> <A NAME="tex2html1577" HREF="node58.html">3.4 Storage Class Language</A> <B> Previous:</B> <A NAME="tex2html1571" HREF="node59.html">3.4.1 MCS51/DS390 Storage Class</A> <B> <A NAME="tex2html1579" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html1581" HREF="node191.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> 2011-03-20 </ADDRESS> </BODY> </HTML>