It is currently Fri Oct 19, 2018 10:29 am

All times are UTC - 7 hours

Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Sep 20, 2018 12:26 pm 
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3638
Location: Mountain View, CA
sdm wrote:
ok, everything seems to work, the problem was a small trifle - before LDA% 00000110, there was no "#" character (of course, nesasm3 did not display an error and I missed the problem).

Just a comment in passing, and isn't intended to disparage or chastise you! It's more about "assembler education":

If the code was lda %00000110, then that's 100% valid code; the assembler not showing an error is correct behaviour. What you did there is essentially the same as writing lda 6 or lda $06 (load accumulator from zero page location 6). Just because you chose to use base 2 (binary) instead of base 10 (decimal) or base 16 (hexadecimal) doesn't change things in the least. There's no 100% correct way for the assembler to detect this situation as an error vs. something the user actually wanted to do; you can't assume that using base 2 as an operand isn't what the user wanted to do, and I have seen plenty of code on the Apple II where people have used base 10 addresses as operands, as "bizarre" as that might seem, but it's perfectly OK.

Iplementing a feature in the assembler (defaulting to disabled) that would allow you to tell it "only expect labels/equates, or base 16 numbers, as operands for non-immediate addressing modes" might sound like a good idea, right? When enabled, lda %00000110, lda 6, or MYVAL = %00000110 / lda MYVAL would cause an error to be thrown, while lda $06 or MYVAL = $06 / lda MYVAL would be OK. This would be annoying to implement in the assembler, however, because it would then have to track what base a particular line of code used, and there's no way to sanely deal with, say, lda $06+%10000000 (e.g. lda $86) or MYVAL = $06 + 128 / lda MYVAL. In other words, there would be tons of edge-case situations that would cause the assembler to potentially throw an error when the user didn't want it, plus adding complexity. Starting to see why nobody tries to implement this kind of thing? :-)

Like with any programming language, a single character/byte mistake can cause lots of pain. Pain that can cost you hours of time debugging/reverse-engineering. It's not unique to 6502 assembly at all. There isn't a 100% infallible way to relieve this problem in the computing world, sorry to say.

PostPosted: Mon Oct 01, 2018 2:56 am 

Joined: Tue Apr 11, 2006 4:08 am
Posts: 276
Location: Poland
How many cpu cycles does the switching of mmc3 bank take? it's about 0 8000-9fff bank changed into another one:

   LDA #%00000110   ;6 / 8000-9fff
   STA $8000
   LDA #2      ;switch to mmc3 bank 2
   STA $8001

PostPosted: Mon Oct 01, 2018 7:01 am 

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20671
Location: NE Indiana, USA (NTSC)
That's 12 cycles: load immediate is 2, and store absolute is 4. The new bank is visible as soon as the STA instruction's memory access cycle completes, which is before the next instruction gets fetched.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours

Who is online

Users browsing this forum: RatcheT2497 and 7 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