Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
stack   Message List  
Reply | Forward Message #13822 of 15019 |
Re: [gbadev] stack

The stack system the ARM7 uses only require 4 opcodes, LDR, STR, LDM and STM,
which can also be used to load and store data from memory, which can get
confusing.

Basically if you're implementing a stack opcodes LDM and STM have two extra
conditions and a writeback function, which 'writes back' an incremented or
decremented address value to the register you are using to reference the stack.
The two extra conditions control 1. whether the stack pointer is incremented or
decremented, and 2. whether the stack pointer points to an 'empty' stack cell or
a 'full' stack cell. If the pointed cell is full, the stack pointer is
increased/decreased before data transfer, and if it is empy, vice versa.
With LDR and STR, you have to specify how much you want it
decreasing/increasing by subtracting/adding to the pointer and writing back the
value. as to when it writes back the value, that depends upon how the code is
phrased i.e STR R1, [R13 + 4]! as opposed to STR R1, [R13]! +4

As to whether the stack grows up or down, well it depends upon the compiler
and the opcodes it chooses to use. The extra memory at the top is reserved by
the BIOS for levels of supervision higher than the IRQ_SVC, though when they are
used I dont know, the header file only sets the value of the stacks to the value
the BIOS sets them to anyway. I do know that the highest word in IWRAM stores
the address for the software interrupt handler and so it wouldnt be a good idea
to use ascending stacks as it would overwrite this.

Hope this helps
----- Original Message -----
From: Jason Wilkins
To: gbadev@yahoogroups.com
Sent: Friday, March 21, 2003 5:13 PM
Subject: [gbadev] stack


How does the stack on the Gameboy Advance work?

Jeff's crt0.S sets the user and irq stack pointers high in IWRAM (160 and
92 bytes respectively). This implies to me that these stacks grow upwards
in memory. Giving the irq stack 92 bytes and the user stack 160 - 92 = 68
bytes.

This looks to odd to me, and knowing that stacks ussually grow downward in
memory towards the top of the heap then maybe they really grow downwards,
giving the irq stack 68 and the user stack all of iwram (or until it
corrupts any variables stored there).

If so, then what is the 92 bytes left free at the top? I seem to recall
there being a third stack on the ARM7TDMI, is this for bios calls?

I knew all of this once upon a time, but looking at everything again is
serving to confuse me, not clarify ^_^

Looking at the linkscript and crt0.S for devkitadvance again is making me
have a lot of "What the hell!" moments which one gets when they look at
cod ethey wrote years ago.





Fri Mar 21, 2003 8:41 pm

bw3043@...
Send Email Send Email

Forward
Message #13822 of 15019 |
Expand Messages Author Sort by Date

How does the stack on the Gameboy Advance work? Jeff's crt0.S sets the user and irq stack pointers high in IWRAM (160 and 92 bytes respectively). This implies...
Jason Wilkins
fenix@...
Send Email
Mar 21, 2003
5:36 pm

No, the stacks grow downwards. In systems where there is only one stack, that is ususally set to the high end of (a typically monolithic) memory area and the...
John Seghers
johnse98072
Offline Send Email
Mar 21, 2003
8:03 pm

The stack system the ARM7 uses only require 4 opcodes, LDR, STR, LDM and STM, which can also be used to load and store data from memory, which can get...
Benjamin White
bw3043@...
Send Email
Mar 21, 2003
9:10 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help