$HWSTACK

Top  Previous  Next

Action

Sets the available space for the Hardware stack.

 

 

Syntax

$HWSTACK = var

 

 

Remarks

Var

A numeric decimal value.

 

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.

 

The $HWSTACK directive overrides the value from the IDE Options.

 

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.

 

The Hardware stack is room in RAM that is needed by your program. 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 HW 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.

 

 

See also

$SWSTACK , $FRAMESIZE

 

 

Example

'--------------------------------------------------------------------------------

'name                     : adc.bas

'copyright                : (c) 1995-2005, MCS Electronics

'purpose                  : demonstration of GETADC() function for 8535 or M163 micro

'micro                    : Mega163

'suited for demo          : yes

'commercial addon needed  : no

'use in simulator         : possible

' Getadc() will also work for other AVR chips that have an ADC converter

'--------------------------------------------------------------------------------

$regfile = "m163def.dat"                                   ' we use the M163

$crystal = 4000000

 

$hwstack = 32                                               ' default use 32 for the hardware stack

$swstack = 10                                               'default use 10 for the SW stack

$framesize = 40                                             'default use 40 for the frame space