Dragon 32 system/user stack...

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
jedie
Posts: 634
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Dragon 32 system/user stack...

Post 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?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
sixxie
Posts: 1161
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: Dragon 32 system/user stack...

Post 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.
retrocanada76
Posts: 45
Joined: Tue Jul 23, 2013 3:26 pm

Re: Dragon 32 system/user stack...

Post 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.
jedie
Posts: 634
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Dragon 32 system/user stack...

Post 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?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: Dragon 32 system/user stack...

Post 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.
User avatar
JeeK
Posts: 65
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: Dragon 32 system/user stack...

Post 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).
The dragon on my side: http://klasek.at/hc/dragon/
jedie
Posts: 634
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Dragon 32 system/user stack...

Post by jedie »

You are right. Thanks for the tip!
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Post Reply