This repository has been archived on 2024-09-22. You can view files and clone it, but cannot push or open issues or pull requests.
pbi-ide/help/BasicStampHelp/Content/LanguageTopics/Commands/GET.htm

181 lines
9.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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>GET</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">GET</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
<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/GetPutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET / PUT Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">GET</span> <![CDATA[ ]]><i>Location</i>,<i><![CDATA[ ]]></i>{Word}<i> Variable
</i>{,<i><![CDATA[ ]]></i>{Word}<i> Variable ...</i>}</p>
<h2>Function</h2>
<p class="PlainText">Read value(s) from Scratchpad RAM, starting at <i>Location</i> and store in
<i>Variable(s)*</i>.
</p>
<ul>
<li value="1"><b><i>Location</i></b> is a variable/constant/expression (0 63 for Bs2e
and BS2sx, and 0 135 for BS2p, BS2pe, and BS2px) that specifies the Scratchpad
RAM location to read from.</li>
<li value="2"><b><i>Variable</i></b> is a variable (usually a byte; unless using the optional <i>Word</i> modifier) to store the
value into. </li>
</ul>
<p>*Note: The optional arguments require PBASIC 2.5.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="24%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2e and BS2sx</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Scratchpad RAM size and organization</td>
<td align="center">64 bytes (0 63). Organized as bytes only.</td>
<td align="center">136 bytes (0 135). Organized as bytes only.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">General purpose locations</td>
<td align="center">0 - 62</td>
<td align="center">0 126</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special use location</td>
<td align="center">Current program slot number in read-only location 63.</td>
<td align="center">Current program slot number in lowest nibble of read-only location 127. Current read/write slot number in highest nibble of location 127. </td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Additional locations</td>
<td align="center">None</td>
<td align="center">Locations 128 - 135 (read-only) hold state of polled input pins.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center"><a href="PUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PUT</a>
</td>
<td align="center"><a href="PUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PUT</a>, <a href="STORE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STORE</a></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">PBASIC 2.5 Syntax Options</td>
<td align="center" colspan="2">
<p colspan="2" align="center">Multiple sequential variables may be read from the Scratchpad RAM. </p>
<p colspan="2" align="center">The optional Word modifier may be specified to retrieve 16-bit values.</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">By default, the <span class="keyword_in_text">GET</span> command reads a byte-sized value from the specified
Scratchpad RAM location and stores it into variable. All values in all locations
can be retrieved from within any of the eight program slots.</p>
<p class="PlainText">Scratchpad RAM is useful for passing data to programs in other program
slots and for additional workspace. It is different than regular RAM in
that symbol names cannot be assigned directly to locations and each
location is always configured as a byte only. The following code will read
the value at location 25, store it in a variable called <i>temp</i> and display
it:</p>
<p class="PlainText">The following example illustrates this:</p><pre class="BScode" xml:space="preserve">
temp VAR Byte
Main:
GET 25, temp
DEBUG DEC temp
END
</pre>
<p class="PlainText">When using the $PBASIC 2.5 directive, multiple sequential variables may be read
from the Scratchpad RAM, starting at <i>Location</i>, and the Word modifier may
be specified for 16-bit values.</p>
<p>
<img src="../../graphics/bsesxppepx_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
' {$PBASIC 2.5}
value VAR Word
value2 VAR Word
addr VAR Word ' EEPROM address
test VAR Byte ' test byte read back
Main:
value = $11
value2 = $2003
PUT 0, value, Word value2 ' write value to SP location 0
' and value2 to SP locations 1 &amp; 2
value = $FF ' modify variables
value2 = $FFFF
GET 0, value, Word value2 ' retrieve from Scratchpad
DEBUG HEX2 ? value ' display
DEBUG HEX4 ? value2
END
</pre>
<p class="PlainText">The low nibble of location 63 (BS2e and BS2sx) and location 127 (BS2p,
BS2pe, and BS2px) is a special, read-only location that always contains the
number of the currently running program slot. On the BS2p, BS2pe, and BS2px,
the high nibble of location 127 also contains the current program slot that
will be used for the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands. See the
demo program for an example of use.</p>
<p>
<img src="../../graphics/bsppepx_inline.gif" border="0">
</img>
</p>
<p class="PlainText">On the BS2p and BS2pe, the state of polled input pins can be retrieved from
upper Scratchpad locations:</p>
<ul>
<li value="1">128 : MAINIO pins 0 - 7</li>
<li value="2">129 : MAINIO pins 8 - 15</li>
<li value="3">130 : AUXIO pins 0 - 7</li>
<li value="4">131 : AUXIO pins 8 - 15</li>
</ul>
<p class="PlainText">This information can be used to determine which input pin (or pins) has
triggered a polled event.</p>
<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 ©&#160;<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>