Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Best practice IRQ recovery
2021-06-10 20:30
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....
 
2021-06-12 06:01
Martin Piper

Registered: Nov 2007
Posts: 631
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..
2021-06-12 08:50
Oswald

Registered: Apr 2002
Posts: 5017
"lda #$7f
sta CIA1InterruptControl
sta CIA2InterruptControl"

I will stick to dc0d dd0d :D letsnamealltheregisters_so_itseasyertocode NOT.
2021-06-12 11:47
Martin Piper

Registered: Nov 2007
Posts: 631
It's easier for me to name registers and sometimes their bitfields.
2021-06-12 13:06
chatGPZ

Registered: Dec 2001
Posts: 11100
Is this "how to make trivial code unreadable 101"? /o\
2021-06-12 13:26
Krill

Registered: Apr 2002
Posts: 2825
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.
2021-06-12 13:37
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.
2021-06-12 13:46
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
2021-06-12 13:48
Krill

Registered: Apr 2002
Posts: 2825
Quoting Oswald
anyone who didnt spent years using these registers by hex values raise their hands. nobody? good :)
Some people got into C-64 coding only recently.

Quote:
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.
VICEmon symbol files have been invented. \=D/

Quote:
same goes for source code thats programmed as a script.
Please elaborate.
2021-06-12 14:14
chatGPZ

Registered: Dec 2001
Posts: 11100
TWW: there are no pending interrupts after disabling them (or to be precise, they'd still trigger, before you can even ACK, the original handler will take care of them)
2021-06-12 15:09
TWW

Registered: Jul 2009
Posts: 541
GPZ: This is done inside a sei-cli raster IRQ setup to ensure no accidental CIA IRQ triggers after cli'ing which may have activated between the sei and the point you actually disable them.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Matt
Zamdee/Extend ^ Damo..
Viti/Hokuto Force
CA$H/TRiAD
C64_80er/TRT
rexbeng
Brix/Plush
Guests online: 71
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 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (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 Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.044 sec.