Marius Posted February 9, 2013 Share Posted February 9, 2013 I'm totally confused. I was testing some things and I really couldn't get the answer, why the things I wanted did not work out. So I made this little piece of code to test things out, and I was really SURPRISED. Read on please: (This is SynAssembler Syntax) 00010 .LI OFF 00020 TEMP0 .EQ $0600 00030 TEMP1 .EQ $0601 00060 .OR $4000 00070 LDA #$00 00080 LDX #$03 ; there were more TEMPS in my previous code 00090 LUS STA TEMP0,X 00100 DEX 00110 BPL LUS 00120 LDX #$10 00130 LDA #$00 00135 CLC 00140 LUS2 ADC $BFF0,X ; ok $BFF0 + $10 should be $C000 right? 00150 INX 00160 BNE LUS2 00170 STA TEMP0 00180 LDX #$00 00190 LDA #$00 00200 CLC 00210 LUS3 ADC $C000,X 00220 INX 00230 CPX #$F0 00240 BNE LUS3 00250 STA TEMP1 00260 RTS After running this: TEMP0 = $9B TEMP1 = $43 The use of the code is not interesting or part of the discussion. I simply do not understand why the result of TEMP0 = $9B and the result of TEMP1 = $43 while both should have been equal. Anyone? Thanks a lot PW Quote Link to comment Share on other sites More sharing options...
kenfused Posted February 9, 2013 Share Posted February 9, 2013 Is this being run on 400/800 or XL/XE? Quote Link to comment Share on other sites More sharing options...
Marius Posted February 9, 2013 Author Share Posted February 9, 2013 XL/XE Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted February 9, 2013 Share Posted February 9, 2013 CPX in line 230 will be constantly resetting the carry flag before the next addition, but this isn't the case in the first loop, since there's no comparison instruction present to reset the C flag after the addition. 1 Quote Link to comment Share on other sites More sharing options...
Marius Posted February 9, 2013 Author Share Posted February 9, 2013 Thanks FJC! Quote Link to comment Share on other sites More sharing options...
kenfused Posted February 9, 2013 Share Posted February 9, 2013 CPX in line 230 will be constantly resetting the carry flag before the next addition, but this isn't the case in the first loop, since there's no comparison instruction present to reset the C flag after the addition. Oh duh, I didn't catch that. 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.