<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem"> <head><title>STORE</title> <link href="../../SkinSupport/MadCap.css" rel="stylesheet" /> <link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" /> <script src="../../SkinSupport/MadCapAll.js" type="text/javascript"> </script> </head> <body> <h1 class="code">STORE</h1> <div class="ImagePlusCaption"> <div class="Col2"> <p> <img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" /> <img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" /> <img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /> </p> </div> <p style="text-align: right;"><a href="../ExampleTopics/StoreEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STORE Examples</a> </p> <p> </p> </div> <p class="clear"> </p> <p> </p> <p class="PlainText">Syntax: <span class="keyword_in_text">STORE </span> <![CDATA[ ]]><i>ProgramSlot</i></p> <h2>Function</h2> <p class="PlainText">Designate a program slot for the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> instructions to operate upon. </p> <ul> <li value="1"><b><i>ProgramSlot</i></b> is a variable/constant/expression (BS2p and BS2px: 0 – 7, BS2pe: 0 - 15) that specifies the program slot<sup>†</sup>to use for <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> instructions.</li> </ul> <p><sup>†</sup> Note: On the BS2pe, slots 8 - 15 are only available for data (<span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span>); they cannot be used to run programs. </p> <h2>Quick Facts</h2> <table width="100%" cellpadding="4" cellspacing="0" border="1"> <tr> <td width="20%" align="center" bgcolor="#CFCFCF"> </td> <td width="40%" align="center" bgcolor="#CFCFCF">BS2p and BS2px</td> <td width="40%" align="center" bgcolor="#CFCFCF">BS2pe</td> </tr> <tr> <td align="center" bgcolor="#CFCFCF">Program Slot Range</td> <td align="center">0 - 7</td> <td align="center">0 - 15</td> </tr> <tr> <td align="center" bgcolor="#CFCFCF">Related Commands</td> <td colspan="2" align="center"><a href="READ.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">READ</a>, <a href="WRITE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">WRITE</a></td> </tr> </table> <h2>Explanation</h2> <p class="PlainText"><span class="keyword_in_text">STORE</span> tells the BS2p, BS2pe, or BS2px which program slot to use when a <span class="keyword_in_text">READ</span> or <span class="keyword_in_text">WRITE</span> instruction is executed. The <span class="keyword_in_text">STORE</span> command only affects the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> instructions.</p> <p class="PlainText">The <span class="keyword_in_text">STORE</span> command allows a program to access all EEPROM locations that exist on the BS2p, BS2pe, and BS2px, regardless of which program is running or which program slot is active. The <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands can only access locations 0 to 2047 within a single program slot. The <span class="keyword_in_text">STORE</span> command switches the program slot that the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands operate on. This short subroutine demonstrates the use of <span class="keyword_in_text">STORE</span>:</p><pre class="BScode" xml:space="preserve"> Move_Block: FOR idx = 0 TO (blockLen - 1) ' move blockLen bytes STORE srcSlot ' point to source slot READ srcAddr + idx, eeByte ' read source byte STORE tgtSlot ' point to target slot WRITE tgtAddr + idx, eeByte ' write byte to target slot NEXT RETURN </pre> <p class="PlainText">The default program slot that the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> instructions operate on is the currently running program. The <span class="keyword_in_text">STORE</span> command can be used to temporarily change this, to any program slot. The change will remain in effect until another <span class="keyword_in_text">STORE</span> command is issued, or until another program slot is executed. The current slot used by <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> (as set by <span class="keyword_in_text">STORE</span>) can be read from byte 127 of the Scratchpad RAM. Example:</p><pre class="BScode" xml:space="preserve"> #SELECT $STAMP #CASE BS2 pgmSlot = 0 ' everything in slot 0 rwSlot = 0 #CASE BS2E, BS2SX GET 63, pgmSlot ' read current slot rwSlot = pgmSlot ' READ/WRITE slot is same #CASE BS2P, BS2PE, BS2PX GET 127, pgmSlot ' get slot control byte rwSlot = rwSlot.HIGHNIB ' READ/WRITE in high nibble pgmSlot = pgmSlot.LOWNIB ' pgm slot in low nibble #ENDSELECT </pre> <div class="Col2"> <div class="MasterFoot"> <p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a> </p> </div> </div> <div class="Col2"> <div class="MasterFoot"> <p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p> <p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p> <p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span> </p> </div> </div> <script type="text/javascript">/* <![CDATA[ */ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-285614-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); /* ]]> */</script> <script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js"> </script> </body> </html>