<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.mcselec.com/bavr/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=%24HWSTACK%2Fde</id>
		<title>$HWSTACK/de - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=%24HWSTACK%2Fde"/>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=$HWSTACK/de&amp;action=history"/>
		<updated>2026-04-17T14:45:12Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.6</generator>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=$HWSTACK/de&amp;diff=1938&amp;oldid=prev</id>
		<title>Admin: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=$HWSTACK/de&amp;diff=1938&amp;oldid=prev"/>
				<updated>2013-02-15T19:06:59Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:06, 15 February 2013&lt;/td&gt;
		&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=$HWSTACK/de&amp;diff=1937&amp;oldid=prev</id>
		<title>Admin at 19:47, 6 February 2013</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=$HWSTACK/de&amp;diff=1937&amp;oldid=prev"/>
				<updated>2013-02-06T19:47:48Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== (**COPIED FROM ENGLISH PAGE**) === &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
Sets the available space for the Hardware stack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Syntax&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;f_Syntax&amp;quot;&amp;gt;$HWSTACK&amp;lt;/span&amp;gt;&amp;amp;nbsp;= var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Remarks&amp;lt;/span&amp;gt; =&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0px; margin: 0px 0px 0px 4px;&amp;quot;&amp;gt;&lt;br /&gt;
{| width=&amp;quot;604&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot; border=&amp;quot;1&amp;quot; style=&amp;quot;border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;12%&amp;quot; style=&amp;quot;width: 69px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
Var&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;100%&amp;quot; style=&amp;quot;width: 526px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
A numeric decimal value.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While you can configure the HW Stack in Options, Compiler, Chip, it is good practice to put the value into your code. This way you do no need the cfg(configuration) file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The $HWSTACK directive overrides the value from the IDE Options.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is important that the $HWSTACK directive occurs in your main project file. It may not be included in an $include file as only the main file is parsed for $HWSTACK. $HWSTACK only accepts numeric values.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
The Hardware stack is room space in SRAM that is needed by your program. Each time you call a SUB or FUNCTION, or use GOSUB, the processor need to know at which address to return after returning from the call. Also for RETURN Address after Interrupt this is needed by the program. For this purpose, the processor saves this address on the hardware stack.&lt;br /&gt;
&lt;br /&gt;
When you use GOSUB label, the microprocessor pushes the return address on the hardware stack and will use 2 Bytes for that. When you use RETURN, the Hardware stack is popped back and the program can continue at the proper address. When you nest GOSUB, CALL or functions, you will use more stack space. Most statements use HW stack because a machine language routine is called.&lt;br /&gt;
&lt;br /&gt;
The Hardware Stack is growing top down. The Hardware Stack start at the highest available SRAM Address and therefore is located before Software Stack and/or Frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;See also&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[[$SWSTACK]]&amp;amp;nbsp;,&amp;amp;nbsp;[[$FRAMESIZE]],&amp;amp;nbsp;[[Memory usage|Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Example &amp;amp;nbsp;for using an Interrupt and examine Hardware Stack:&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
With the following example we just define and enable the Receive Interrupt of the UART and examine when clicking on Interrupt button within the Bascom-AVR Simulator Interrupts Tab how many Hardware Stack is needed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;source lang=&amp;quot;bascomavr&amp;quot;&amp;gt;&lt;br /&gt;
$regfile = &amp;quot;m328pdef.dat&amp;quot;&lt;br /&gt;
$crystal = 16000000&lt;br /&gt;
$hwstack = 48&lt;br /&gt;
$swstack = 32&lt;br /&gt;
$framesize = 32&lt;br /&gt;
 &lt;br /&gt;
$baud = 19200&lt;br /&gt;
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0&lt;br /&gt;
 &lt;br /&gt;
Dim Rs232 As Byte&lt;br /&gt;
 &lt;br /&gt;
'Enable Receive Interrupt for COM1&lt;br /&gt;
On Urxc Rxc_isr&lt;br /&gt;
Enable Urxc&lt;br /&gt;
Enable Interrupts&lt;br /&gt;
 &lt;br /&gt;
Do&lt;br /&gt;
!nop&lt;br /&gt;
Loop&lt;br /&gt;
 &lt;br /&gt;
End&lt;br /&gt;
 &lt;br /&gt;
Rxc_isr:&lt;br /&gt;
Rs232 = Inkey()&lt;br /&gt;
Print Rs232&lt;br /&gt;
Return&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;br/&amp;gt;Bascom-AVR Simulator output of the example above:&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;[[File:Hw stack.png|center|Hw stack.png]]&amp;lt;br/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
Picture&amp;amp;nbsp;: The Hardware Stack will be filled by clicking the Bascom-AVR Simulator Interrupt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this example we see (by counting the changed SRAM Bytes in Bascom Simulator Memory Window) that Software Stack is NOT needed but at least&amp;amp;nbsp;&amp;lt;span style=&amp;quot;font-weight: bold;&amp;quot;&amp;gt;39 Byte of Hardware Stack&amp;lt;/span&amp;gt;&amp;amp;nbsp;and the Frame with the 24 Byte conversion buffer because of PRINT.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Most of the 39 Bytes are the saved Registers when jumping in Interrupt Service Routine. These are SREG , R31 to R16 and R11 to R0 with exception of R6,R8 and R9.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
The following should be considered in any case (not only when using NOSAVE):&lt;br /&gt;
&lt;br /&gt;
Take care when using floating point math in the ISR because the Register R12 to R15 are not saved in the regular process of processor register backup. Using floating point math in ISR is not recommended anyway.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size: 12pt; font-family: 'Times New Roman';&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you try the same example with &amp;amp;nbsp;NOSAVE you will see the example will need less Hardware Stack but&amp;amp;nbsp;&amp;lt;span style=&amp;quot;font-weight: bold;&amp;quot;&amp;gt;you are responsible then to save all of the Registers&amp;lt;/span&amp;gt;&amp;amp;nbsp;with PUSH and POP in the Interrupt Service Routine that are needed or changed during the Interrupt Service Routine.&lt;br /&gt;
&lt;br /&gt;
The easier, and above all safer way is not using NOSAVE which is also the default way.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
By clicking on the Interrupts Button will fire an interrupt in Simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Hw stack sim.png|center|Hw stack sim.png]]&lt;br /&gt;
&lt;br /&gt;
{{Languages}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
[[Category:BASCOM Language Reference/de]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>