You are not logged in -
nap
CSDb User Forums
Forums
>
C64 Coding
>
How to use the stack area?
2016-03-07
21:31
Trap
Registered: Jul 2010
Posts: 222
How to use the stack area?
Hi,
I'm having some problems here that I need your help with.
I need to put some graphics in the area of the stack, $0100-$01ff. I can easily store data up to $01f0, but when I go beyond that, my code crashes.
So, I'm guessing here ... any branch or jump will store the PC on the stack or what? So, in order to make this work I would have to eliminate all loops in my initialization code? Would a simple TSX and TXS in my interrupt fix the remaining problem?
Am I on the right path here or have I strayed off it? ;)
Cheers
Trap
2016-03-07
21:33
Trap
Registered: Jul 2010
Posts: 222
Ah ok. Found that only JSR, PLA, PLP, RTS, PHA, PHP and RTI use the stack.
So, branches are ok I guess.
2016-03-07
21:37
Hoogo
Registered: Jun 2002
Posts: 102
Quoting Trap
Would a simple TSX and TXS in my interrupt fix the remaining problem?
I guess your interrupt is also your problem. You can't prevent that 3 bytes are pushed to the stack, and more if you're using the usual interrupt handler.
If you do not want to mess the stack, you have to avoid pha, pla, php, plp, jsr, rts, rti, brk. Turn off IRQs, and lock NMIs too if you want protection from the restore key.
EDIT: At least make sure that no IRQ appears in areas where your graphic is shown. An own IRQ handler can pick flags and return address from the stack, repair the graphic bug and return to the main loop without RTI. But handling the flags could be tricky enough that you will easily find a way without interrupts.
2016-03-07
22:09
Trap
Registered: Jul 2010
Posts: 222
Thanks Hoogo.
I managed to fix it. I just moved the SP to a safe spot and replaced the RTS I had at the end of my init code with a jmp back to main code. Viola!
Happy coder :)
Refresh
Subscribe to this thread:
You need to be logged in to post in the forum.
Search the forum:
Search
All forums
C64 Coding
C64 Composing
C64 Pixeling
C64 Productions
CSDb Bug Reports
CSDb Discussions
CSDb Entries
CSDb Feedback
CSDb Info
CSDb moderators
CSDb Questions
CSDb V2 development
Messages to moderators
Requests
for
in
Writer & text
Text
Writer
All times are CET.
Search CSDb
All
Releases
Groups
Sceners
Events
BBS
SIDs
-------
Forum
Comments
Advanced
Users Online
Guests online: 119
Top Demos
1
Next Level
(9.8)
2
Mojo
(9.7)
3
Coma Light 13
(9.7)
4
Edge of Disgrace
(9.6)
5
Comaland 100%
(9.6)
6
No Bounds
(9.6)
7
Uncensored
(9.6)
8
Wonderland XIV
(9.6)
9
Bromance
(9.6)
10
Memento Mori
(9.6)
Top onefile Demos
1
It's More Fun to Com..
(9.7)
2
Party Elk 2
(9.7)
3
Cubic Dream
(9.6)
4
Copper Booze
(9.5)
5
TRSAC, Gabber & Pebe..
(9.5)
6
Rainbow Connection
(9.5)
7
Onscreen 5k
(9.5)
8
Wafer Demo
(9.5)
9
Dawnfall V1.1
(9.5)
10
Quadrants
(9.5)
Top Groups
1
Oxyron
(9.3)
2
Nostalgia
(9.3)
3
Booze Design
(9.3)
4
Censor Design
(9.3)
5
Crest
(9.3)
Top Musicians
1
Rob Hubbard
(9.7)
2
Jeroen Tel
(9.6)
3
Linus
(9.6)
4
Stinsen
(9.6)
5
Mutetus
(9.6)
Home
-
Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.055 sec.