Page 1 of 1

Dragon 32 system/user stack...

Posted: Wed Oct 16, 2013 12:46 pm
by jedie
I question me, where is the initial address of system and user stack?

In Inside the Dragon i found this:
21:22 - Stack base address
With my HexViewer i saw the value $7f36, think this is right.


In the XRoar trace output i see this following for the System Stack:

* 03d7 - comes from b39b| 10ce03d7 LDS #$03d7
* 03d5 - because of a subroutine jump: b3c3| bdba77 JSR $ba77
* 03d7 - return: ba85| 39 RTS
* 7f36 - set initial value with:

Code: Select all

b3e3| 9f21        STX     <$21
b3e5| 1f14        TFR     X,S

OK, but what is the initial address for the user stack?
From XRoar trace:

The first value is 008f set with bb8b| ce008f LDU #$008f
The address would be increase step-by-step with STA ,U+ to 009c
Then it set to 0148 with bb92| ce0148 LDU #$0148
then U+=1 until 0151
b3ed| ce009d LDU #$009d
U+=1 until 00ab
b3f5| ce010c LDU #$010c
U+=1 until 012a - this value stays a few ops...

than set to 8b8d
b41d| ce8b8d LDU #$8b8d
this stays a while then set to b4b3 with 8c83| de62 LDU <$62
stays a while then set to 82ec with 8c83| de62 LDU <$62

and 82ec seems to be the "final" value...

$62 is documented in Inside the Dragon with:
62-67 - Miscellaneous use
and on http://dragon32.info/info/memmap.html with:
$0062 Sign comparison
$0062-0067 Misc use
So 62 is a temporary storage?

Anyone knows how the user stack address is calculated?

Re: Dragon 32 system/user stack...

Posted: Wed Oct 16, 2013 1:13 pm
by sixxie
I don't think U is used as anything other than a convenient register by BASIC. Its value outside of any specific routine is probably irrelevant.

Re: Dragon 32 system/user stack...

Posted: Wed Oct 16, 2013 4:48 pm
by retrocanada76
The CLEAR X,Y command sets the string storage (X) and the basic hi-mem (Y). So, before the string storage comes the stack. But it's not X - Y for the stack, there is the basic working area after the stack for string pointers and lengths.

Re: Dragon 32 system/user stack...

Posted: Thu Oct 17, 2013 5:00 pm
by jedie
A other question to the stacks...

What is if PULL more often called than PUSH before?
Just return the values "outside" the stack?

Re: Dragon 32 system/user stack...

Posted: Thu Oct 17, 2013 8:18 pm
by tormod
Yes, there is no security net. PULL will just increase the stack pointer, it does not track where the stack once "started". As you already know you can set the stack pointer as you like, and that will be your stack "start" or base. For the CPU it does not mean anything.

Re: Dragon 32 system/user stack...

Posted: Mon Oct 21, 2013 12:15 am
by JeeK
jedie wrote:A other question to the stacks...

What is if PULL more often called than PUSH before?
Just return the values "outside" the stack?
Just another thought on this: compare PULS X with LDX ,S++ They are nearly equal, except for condition code handling and PULS X saves 1 cycle (2 cycles in case register Y is used). PUL/PSH is a fast method and common optimization for word based block operations ... (just an additional example, which shows that "inside/outside stack" has no meaning at all).

Re: Dragon 32 system/user stack...

Posted: Mon Oct 21, 2013 12:17 pm
by jedie
You are right. Thanks for the tip!