| |
Trap
Registered: Jul 2010 Posts: 222 |
Best practice IRQ recovery
Hi,
Here's a little newbie question. Sorry, I'm still learning this shit and it's really complicated :(
I have kernel off ($01=$35) and I am running IRQ's using the normal $fffe/$ffff vectors.
I want to exit from this and call a prepacked piece of code (in this case something packed with TinyCrunch).
I tried restoring the IRQ vectors and jump to the packer. However, it just hangs. I tried some other things but all gave the same result. The only thing that worked was when I did this:
sei
lda #$36
sta $01
jsr $ff81
jmp unpacker
The problem of course is that it resets the VIC which isn't really great for my situation.
So, my question:
What is the correct/proper way to exit from a part and go to the next? preferably not using kernal routines :|
Thank you.
Trap |
|
... 78 posts hidden. Click here to view all posts.... |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1378 |
If you disable CIA and VIC interrupts *without* a preceding SEI you don't even need to acknowledge any pending ones - the existing handler will deal with that.
tinycrunch's self extracting mode only wraps the decrunch in SEI/CLI because too many people were having issues with nucrunch's default of just turning off CIA while trying to crunch things that needed the kernal interrupt to still be in place when they started up :-/ |
| |
chatGPZ
Registered: Dec 2001 Posts: 11111 |
someone gotta write this "SEI considered harmful" rant already :) |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1378 |
Quote: someone gotta write this "SEI considered harmful" rant already :)
Well I think it's already been flogged to death over at
TIL: The instruction after SEI can be executed before a pending IRQ is handled and to a lesser extent in C-64 coding cargo cults but it's always been as an offshoot from a broader discussion, so far as I can find. |
| |
Martin Piper
Registered: Nov 2007 Posts: 634 |
Tried single stepping using the debugger in Vice?
It will probably show where various IRQs happen after the CLI.
Create, or reuse, consistent IRQ disable and ACK code: https://github.com/martinpiper/C64Public/blob/master/stdlib/std..
I generally always use this to initialise to a known state: https://github.com/martinpiper/C64Public/blob/master/stdlib/Ini.. |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
"lda #$7f
sta CIA1InterruptControl
sta CIA2InterruptControl"
I will stick to dc0d dd0d :D letsnamealltheregisters_so_itseasyertocode NOT. |
| |
Martin Piper
Registered: Nov 2007 Posts: 634 |
It's easier for me to name registers and sometimes their bitfields. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11111 |
Is this "how to make trivial code unreadable 101"? /o\ |
| |
Krill
Registered: Apr 2002 Posts: 2839 |
Oh come on, the registers have names already in the datasheet.
And not everybody spent years writing and analysing code with a memory monitor before using a proper assembler. =)
I'd stick to concise symbols like "CIA1_ICR", though.
And yes, using symbols instead of raw addresses and bitfields can make code more readable, especially with rarely used registers. |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
Quote: Oh come on, the registers have names already in the datasheet.
And not everybody spent years writing and analysing code with a memory monitor before using a proper assembler. =)
I'd stick to concise symbols like "CIA1_ICR", though.
And yes, using symbols instead of raw addresses and bitfields can make code more readable, especially with rarely used registers.
I'm sorry, for me lda $#7f sta $dc0d is more readable than lda #CIAdisableallinterrupts sta Cia2interruptcontrolregister. anyone who didnt spent years using these registers by hex values raise their hands. nobody? good :)
and btw if you code like this, and then you see your code in monitor, you will have no clue what part of your code you see. same goes for source code thats programmed as a script. |
| |
TWW
Registered: Jul 2009 Posts: 541 |
Best of both worlds :)
// Disable all CIA interrupts
lda #$7f
sta $dc0d
sta $dd0d
// Acknowlege any pending CIA iterrupts
lda $dc0d
lda $dd0d
|
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - Next |