Steril707 Posted August 30, 2007 Share Posted August 30, 2007 I am into heavy kernal tweaking at the moment, and i am in the situation now that i need to waste a single cycle for my asymmetric mirrored Kernal. I want to insert typical 7 cycle load store combi like lda blop,x ;4 sta COLUPF1 ;3 into a space that needs 8 cycle to get burnt, so my PF2 gets loadad at the correct cycle later on. That means, I need kind of a 8 cycle lda/sta instead of the example typical 7 cycle one... Is there any trick to do that? I encounter these kind of situations a lot while tweaking kernals, would be a big help for me to know a solution to this. Quote Link to comment Share on other sites More sharing options...
+batari Posted August 30, 2007 Share Posted August 30, 2007 I am into heavy kernal tweaking at the moment, and i am in the situation now that i need to waste a single cycle for my asymmetric mirrored Kernal. I want to insert typical 7 cycle load store combi like lda blop,x ;4 sta COLUPF1 ;3 into a space that needs 8 cycle to get burnt, so my PF2 gets loadad at the correct cycle later on. That means, I need kind of a 8 cycle lda/sta instead of the example typical 7 cycle one... Is there any trick to do that? I encounter these kind of situations a lot while tweaking kernals, would be a big help for me to know a solution to this. sta.w COLUPF1 = 4 cycles (why the 1 at the end?) Quote Link to comment Share on other sites More sharing options...
supercat Posted August 30, 2007 Share Posted August 30, 2007 That means, I need kind of a 8 cycle lda/sta instead of the example typical 7 cycle one... As noted, most 3-cycle instructions can be turned into 4-cycle instructions with the addition of a ".w" to the opcode. That will suffice for most of the places where it's necessary to add an extra cycle to your code. The one place where things really get tricky is when there's a need for a four-cycle jump or branch. Branches across page boundaries take four cycles, but it's seldom practical to place things deliberately to cause that. In some cases, especially if your code requires use of both the stack pointer and a byte of RAM as two temporary variables, you may be able to swap your use of the stack pointer and the temp ram byte so as to move instruction times a little so you either won't need a cycle or else can insert two. In other cases, especially with JMP's (as opposed to branches) you can insert before the JMP a copy of the code at the destination, and stick an extra cycle somewhere within that code. Of course, if 6502 programming were easy it wouldn't be so much fun. Quote Link to comment Share on other sites More sharing options...
Steril707 Posted August 30, 2007 Author Share Posted August 30, 2007 I am into heavy kernal tweaking at the moment, and i am in the situation now that i need to waste a single cycle for my asymmetric mirrored Kernal. I want to insert typical 7 cycle load store combi like lda blop,x ;4 sta COLUPF1 ;3 into a space that needs 8 cycle to get burnt, so my PF2 gets loadad at the correct cycle later on. That means, I need kind of a 8 cycle lda/sta instead of the example typical 7 cycle one... Is there any trick to do that? I encounter these kind of situations a lot while tweaking kernals, would be a big help for me to know a solution to this. sta.w COLUPF1 = 4 cycles (why the 1 at the end?) The 1 is just a typo... Thanks guys...You rock!!! Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted August 31, 2007 Share Posted August 31, 2007 Another alternative (when you don't even have the spare byte to waste) is to shuffle the instructions a bit...swapping a 2-cycle instruction before the critical spot with a 3-cycle instruction that follows it. It's true that this is only possible some of the time (regarding on how dependant the critical spot is on preceding instructions), but it's something to look at if coding is getting really tight. If a register at that point in the code is a known value, that would also work if it's value is greater than the address being stored to, without wasting a byte (e.g. STA COLUPF-X,X). Naturally, you'd need to work out COLUPF-X prior to assembly. Quote Link to comment Share on other sites More sharing options...
Hornpipe2 Posted September 22, 2007 Share Posted September 22, 2007 This has been super useful to me when figuring out how to waste N cycles: http://www.qotile.net/minidig/docs/2600_ad..._prog_guide.txt Just read the section on 'Wasting Cycles'. Beats the heck out of e.g. 17 NOP instructions just to burn 34 cycles. Quote Link to comment Share on other sites More sharing options...
supercat Posted September 22, 2007 Share Posted September 22, 2007 Just read the section on 'Wasting Cycles'. Beats the heck out of e.g. 17 NOP instructions just to burn 34 cycles. But be sure to take some of the suggestions with necessary amounts of NaCl. A few have typos, and some have obvious side-effects which could easily be mitigated (e.g. LDA trashes the accumulator; CMP does not, but does trash flags) while others have side-effects that make them dangerous (e.g. if the value of X is unknown, CMP ($80,x) will waste six cycles but could potentially crash any bank-switching scheme (some with much greater probability than others). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.