It is currently Sun Aug 19, 2018 11:00 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 1451 posts ]  Go to page Previous  1 ... 44, 45, 46, 47, 48, 49, 50 ... 97  Next
Author Message
PostPosted: Fri Aug 24, 2012 3:04 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10714
Location: Rio de Janeiro - Brazil
Yes, this is correct. I like to think about it this way: the carry flag, in subtractions, is actually a value that can be borrowed if necessary. After the subtraction (CMP acts just like SEC + SBC, except it doesn't change A), if the carry is still set, a borrow wasn't necessary, so the value in A was large enough for you to subtract from it as much as you did (it's >= the value you subtracted). If the carry is clear, a borrow was necessary and the value in A wasn't large enough (it's < than the subtracted value).


Top
 Profile  
 
PostPosted: Fri Aug 24, 2012 3:14 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 908
Location: cypress, texas
tokumaru wrote:
Yes, this is correct. I like to think about it this way: the carry flag, in subtractions, is actually a value that can be borrowed if necessary. After the subtraction (CMP acts just like SEC + SBC, except it doesn't change A), if the carry is still set, a borrow wasn't necessary, so the value in A was large enough for you to subtract from it as much as you did (it's >= the value you subtracted). If the carry is clear, a borrow was necessary and the value in A wasn't large enough (it's < than the subtracted value).


Ah yes, I was correct in my guess!! Thank you so much tokumaru! :D :)

edited text


Top
 Profile  
 
PostPosted: Sat Sep 01, 2012 4:02 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 908
Location: cypress, texas
I have a loop in my code.

If I have to run one line of code only on the first time through my loop
Code:
lda t6+1


and then at all other times I'll need to run this line instead:
Code:
lda t6


How would be a good way to set that up... something simple maybe? :) And these lines of code will be in the middle of my large loop. I'm trying to use one of those temp variables Kasumi recommended me.


Top
 Profile  
 
PostPosted: Sat Sep 01, 2012 4:13 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1179
It sorta depends on how long the loop is/what registers you need.

I'd just do the obvious and double the loop code if it's shortish. (Yeah, I realize you said it was long)
Code:
lda t6+1
;loop stuff
looplabel:
lda t6
;loop stuff


If it's long, I might just store whatever is in t6 or t6+1 into a new temp variable or a register and then just always use the new temp variable or register.

Code:
ldy t6+1
looplabel:
tya
;loopstuff
ldy t6
;conditional on whether you loop to looplabel again


Or... alternatively, depending on your conditional not requiring the use of A:

Code:
lda t6+1
looplabel:
;loopstuff
lda t6
;conditional on whether you loop to looplabel again

Edit:
Or this:
Code:
lda t6+1
jmp skiploadt6
looplabel:
lda t6
skiploadt6:
;loop stuff
;conditional on whether you loop to looplabel

That one is probably best, because it doesn't add setup time to each loop after the first like the others. It just came to mind third.

Or I might do something totally different depending on the setup of the loop. But there's some ideas.

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Sat Sep 01, 2012 5:12 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 908
Location: cypress, texas
Kasumi wrote:
Edit:
Or this:
Code:
lda t6+1
jmp skiploadt6
looplabel:
lda t6
skiploadt6:
;loop stuff
;conditional on whether you loop to looplabel

That one is probably best, because it doesn't add setup time to each loop after the first like the others. It just came to mind third.
This one rocks!! (I just figured it out! :o) Thank you Kasumi!!! :D They are all good though, thanks very much! :D


...NESDEV's improvements wrote:
Code:
...
Code:
...etc.
AND GOODNESS!! THIS FORUM JUST KEEPS GETTING BETTER AND BETTER, THANKS YALL! :D Edit: It's kindof slow right now...but maybe that's because there's been lot of my time coding these days. :?


Top
 Profile  
 
PostPosted: Sat Sep 01, 2012 9:16 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 908
Location: cypress, texas
unregistered un - wrote:
Kasumi wrote:
Edit:
Or this:
Code:
lda t6+1
jmp skiploadt6
looplabel:
lda t6
skiploadt6:
;loop stuff
;conditional on whether you loop to looplabel

That one is probably best, because it doesn't add setup time to each loop after the first like the others. It just came to mind third.
This one rocks!! (I just figured it out! :o) Thank you Kasumi!!! :D They are all good though, thanks very much! :D
Kasumi wrote:
If it's long, I might just store whatever is in t6 or t6+1 into a new temp variable or a register and then just always use the new temp variable or register.

Ahhh, I see now... after rereading and understanding your dark orange text up there... now, now... thank you so much Kasumi!!! :D Brilliant! I'm a step closer now! I'm in for some more gettin' dirty coding, I think. :D


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2012 5:00 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 908
Location: cypress, texas
Code:
lda t6      ;pla ;<--------------------------------------
;on every 8th run do this instead:
lda t6+1


Is there a simple way to do this? I'm trying to make a simple solution.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Fri Sep 07, 2012 5:36 pm 
Online
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3111
Location: Tampere, Finland
unregistered wrote:
Code:
lda t6      ;pla ;<--------------------------------------
;on every 8th run do this instead:
lda t6+1


Is there a simple way to do this? I'm trying to make a simple solution.

Have a counter that counts upwards each run. Calculate counter AND 7, if result is zero, lda t6+1, otherwise lda t6. If counter starts at zero this will load t6+1 on the first run too. If you don't want that you can initialize the counter to a different value.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Fri Sep 07, 2012 5:38 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20420
Location: NE Indiana, USA (NTSC)
This should be close:
Code:
  ldx t6
  lda runCount
  and #$07
  bne :+
  ldx t6+1
:
  txa


Top
 Profile  
 
 Post subject: Re:
PostPosted: Fri Sep 07, 2012 8:24 pm 
Offline

Joined: Wed Jul 30, 2008 12:03 am
Posts: 34
Another one

Code:
 lda #$80
 sta counter

LOOP
 lda t6
 lsr counter
 bne SKIP
 ror counter
 lda t6+1
SKIP
 .
 .


I would point out that in Kasumi's code
Code:
lda t6+1
jmp skiploadt6
looplabel:
lda t6
skiploadt6:
;loop stuff
;conditional on whether you loop to looplabel


There's the possibility of using a branch instead of
a jmp if that seems desirable eg if you know
t6+1 will never be 0 you could bne
saves a byte, might cost you a cycle at a page boundary,
more relocatable

unregistered wrote:
Code:
lda t6      ;pla ;<--------------------------------------
;on every 8th run do this instead:
lda t6+1


Is there a simple way to do this? I'm trying to make a simple solution.


Top
 Profile  
 
 Post subject: Re: Re:
PostPosted: Sat Sep 08, 2012 3:14 am 
Online
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3111
Location: Tampere, Finland
bogax wrote:
There's the possibility of using a branch instead of
a jmp if that seems desirable eg if you know
t6+1 will never be 0 you could bne
saves a byte, might cost you a cycle at a page boundary,
more relocatable

Using branch also loses some maintainability (in case the code above changes so that the zero flags value isn't a constant anymore). I tend to avoid this optimization. It sure would be nice to be able to do runtime assertions... (I'm considering implementing something like that in NintendulatorDX).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Sep 08, 2012 6:28 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20420
Location: NE Indiana, USA (NTSC)
Emulator-side runtime assertions are implemented in FCEUX.


Top
 Profile  
 
PostPosted: Sat Sep 08, 2012 7:40 am 
Online
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3111
Location: Tampere, Finland
tepples wrote:
Emulator-side runtime assertions are implemented in FCEUX.

Not what I'm looking for. I don't want to specify the conditions manually and have to update them every time the addresses change. What I'm thinking about doing is a macro that outputs the assert expressions in a separate file (easily done with CC65). Something like this:
Code:
runTimeAssert "A == 0 && C"
runTimeAssert "current_bank == 0x12"

Et cetera.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Sep 08, 2012 9:12 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6600
Location: Canada
You could implement an assert macro that reads or writes to a specific address, executes a bad opcode, or something else that is not dependent on the program counter. This would let you keep the same "assert" breakpoint from build to build.

Alternatively, you could try to auto-generate the .dbg file FCEUX uses based on compile symbols. This would be better, since you could then have asserts without any extra code in the ROM.


Top
 Profile  
 
 Post subject: new question
PostPosted: Fri Sep 14, 2012 4:19 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 908
Location: cypress, texas
Code:
0002D                              attNextRowStart .dsb 1 ;thank you !!!! :D
0002E                              every8thRun .dsb 1  ;will stay at 0 until the 8th attribute table block, the start of a new row, is to b
0002F                               atttablerownums: .db $00, $20, $40,$60,$80,$a0,$c0,$e0
00037                              tA .dsb 2


There's the ^ code that shows the addresses.

Code:
00:C26D:E6 37     INC $0037 = #$05
00:C26F:A6 37     LDX $0037 = #$05
00:C271:B5 2F     LDA $2F,X @ $003D = #$00
00:C273:85 2D     STA $002D = #$00


WHY IS $002D AT #$00????????? :shock: :?

edit: Thank yall for helping with my last question. I'm tired, it is time to get away from this right now for me. Will elaborate my thanks soon, I promise. : )


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1451 posts ]  Go to page Previous  1 ... 44, 45, 46, 47, 48, 49, 50 ... 97  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group