English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 26 May 2019, 15:33   #1
hop
Registered User
 
hop's Avatar
 
Join Date: Apr 2019
Location: UK
Posts: 239
Stack position and size

I know how to use the stack, but I've realised that I don't understand where the initial value of the stack pointer is set, and how to determine how much stack space is available.

If an executable is launched from the shell, how is the value of A7 at entry point calculated and how much stack space is available?

When code in a bootblock is executed, what is the value of A7 on entry and how much stack space is available? Does the Amiga OS perhaps set the Stack Pointer(s) during boot?

How are stack overflows typically detected in assembly code?

Can the amount of available stack space be queried?

Do demos/games typically set their own stack pointer(s), or run with the initial value?

Do Amiga executables contain the desired stack size?

Is this information documented anywhere?
hop is offline  
Old 26 May 2019, 15:40   #2
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,437
A few answers - though not all

Amiga OS normally allocates 4 KB of stack space for any task and IIRC this also goes for the bootblock.

The actual location of the stack is decided by the OS. I do not know the algorithm.

Amiga OS does set the stack pointer on boot. Note that each task has it's own stack.

Stack overflows are typically not detected in assembly code (unless you make something for this purpose yourself or use the OS and have something like Enforcer or a debugger running).

I sometimes set my own stack pointer, but not always. Depends on the situation.
roondar is offline  
Old 26 May 2019, 18:20   #3
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
Quote:
Originally Posted by hop View Post
If an executable is launched from the shell, how is the value of A7 at entry point calculated and how much stack space is available?
A7 is located at the end of an area allocated via AllocMem. Available space depends on stack setting on the shell. Type "stack" command (with no parameter) to query actual value.


Quote:
Originally Posted by hop View Post
How are stack overflows typically detected in assembly code?
You get alert or guru saying memory lists are corrupt.
But typical asm programs don't use much stack so an overflow is unlikely if u don't mix with c.


Quote:
Originally Posted by hop View Post
Can the amount of available stack space be queried?
Yes, min and max values are stored in your program's task structure.


Quote:
Originally Posted by hop View Post
Do demos/games typically set their own stack pointer(s), or run with the initial value?
Those in pure asm probably keep the initial value, unless they completely destroy the OS.


Quote:
Originally Posted by hop View Post
Do Amiga executables contain the desired stack size?
Nope - at least not until after 3.1.
meynaf is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Supervisor stack size? alpine9000 Coders. System 71 09 June 2019 01:36
Window position and size a600fan support.FS-UAE 1 18 February 2019 00:10
cli window size and position honx support.WinUAE 5 03 September 2016 23:48
Saving your Game Position Ravenhook support.Games 8 26 May 2010 22:34
Saving position ? Another World support.Games 1 28 April 2007 00:32

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:50.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12734 seconds with 12 queries