Search found 42 matches

by blargg
Tue Feb 26, 2008 9:15 am
Forum: Programming
Topic: Disassembler-friendly constant parameter to routine
Replies: 9
Views: 7029

I'm just saying, "yes," it is possible to automate the testing and verification of hardware against a software model.
That's exactly what I'm doing already. User runs automated test. User's simulator fails the test with the result "Reading from $2002 should suppress NMI if read just when it's set ...
by blargg
Mon Feb 25, 2008 4:01 am
Forum: Programming
Topic: Interrupt Handler
Replies: 13
Views: 8490

DonnaD, your fix would back the PC back up to point to the BRK again, since it subtracts 2 from it. BRK only skips one extra byte, so if you wanted to continue execution just after the BRK opcode, you'd only subtract 1. Even if it were properly subtracting 1, it's still changing the stack pointer ...
by blargg
Mon Feb 25, 2008 1:41 am
Forum: Programming
Topic: Disassembler-friendly constant parameter to routine
Replies: 9
Views: 7029

This is why I always choose to rely upon automated testing, instead of manual testing, and in particular using test-driven development practices. Manual testing is laborious, error-prone, and a gigantic time-sink in terms of productivity.
Maybe I was unclear. OK, we have a piece of hardware that ...
by blargg
Mon Feb 25, 2008 1:37 am
Forum: Programming
Topic: Interrupt Handler
Replies: 13
Views: 8490

You are aware that BRK skips the byte after the BRK opcode, right? So this prints 1, not 2 as you might expect:

LDX #0
BRK
INX ; This is skipped
INX
JSR PRINT_X ; Prints 1
...

IRQ:
RTI
by blargg
Sun Feb 24, 2008 5:08 am
Forum: Programming
Topic: Disassembler-friendly constant parameter to routine
Replies: 9
Views: 7029

Disassembler-friendly constant parameter to routine

I write lots of test programs that are run on hardware and emulators to be sure they both have the same behavior. People often step through them with a debugger in emulators, so I'd like them to be relatively easy to disassemble. I have a few routines that take constant parameters and preserve all ...
by blargg
Sat Jan 26, 2008 4:42 pm
Forum: Programming
Topic: Warning of LDA const instead of LDA #const
Replies: 34
Views: 25300

My only aim was to catch the error with minimal changes to source, and preferably in a way that doesn't yield one's source incompatible with the standard ca65. I've succeeded in all these respects and have a simple, practical approach, so doubt I'll do much more work on it. Out of curiosity, has ...
by blargg
Tue Jan 22, 2008 6:20 am
Forum: Programming
Topic: Warning of LDA const instead of LDA #const
Replies: 34
Views: 25300

Let's see...if you're just marking EQUs whose value is address < 256, to distinguish them from EQU constants < 256, there are at worst only 256 zp address. Some addresses are be defined in terms of others (e.g. PTRH = PTRL+1; that was a really bad example in my previous post).
This is assuming you ...
by blargg
Sat Jan 19, 2008 10:58 pm
Forum: Programming
Topic: Warning of LDA const instead of LDA #const
Replies: 34
Views: 25300

Having to state that this label is an address, and that label is an address, and this other label is an address, and that other label is an address, and so on seems kinda tedious to me.
I must have utterly failed in my presentation, because for the most part it's automatic. With the second patch ...
by blargg
Sat Jan 19, 2008 8:50 pm
Forum: Programming
Topic: Warning of LDA const instead of LDA #const
Replies: 34
Views: 25300

The main reason to avoid new syntax, at least right now, is that code will continue to work on the standard ca65 at the very least, with the patched ca65 serving as an optional lint-like assembler.

Not to be picky, but isn't it difficult to be sure that one has never made this error in all 65xx ...
by blargg
Sat Jan 19, 2008 7:12 am
Forum: Programming
Topic: Warning of LDA const instead of LDA #const
Replies: 34
Views: 25300

Make this an option that you can turn off
Currently it's --addr-type to turn it on, off by default.

Add an operator to the equate expression for when we explicitly want an address.
Spelled ADDR+ (or +ADDR if you like a suffix). Introducing new syntax makes one's source dependent on the new ...
by blargg
Sat Jan 19, 2008 1:52 am
Forum: Programming
Topic: Warning of LDA const instead of LDA #const
Replies: 34
Views: 25300

Warning of LDA const instead of LDA #const

65xx assemblers differentiate between immediate and address operands by the # character, rather than the instruction's mnemonic:
lda #10 ; A = the number 10
lda 10 ; A = byte at address 10
Since # is not required in other common computer languages or general writing, it is easy to forget. The ...
by blargg
Fri Jan 18, 2008 5:35 am
Forum: Programming
Topic: Register size-independent 65816 code
Replies: 2
Views: 3294

Register size-independent 65816 code

On the Wiki it is suggested to make code register size-independent by avoiding immediate values and instead referencing them by address. This way if the register is 8 bits, it uses the first byte only, without changing the interpretation of the instructions.
and #$0F ; no, requires that size of ...
by blargg
Sat Jan 12, 2008 10:36 pm
Forum: Programming
Topic: Delay N clocks
Replies: 3
Views: 4589

Delay N clocks

Most of my assembly coding is part of reverse-engineering video game consoles, and a common need is to delay N clocks, where N is a constant or run-time value. I figured I'd share the 6502 routines I use, since I found them fun to write. This is the key routine:
; Delays A+20 clocks (excluding JSR ...
by blargg
Thu Sep 27, 2007 4:01 am
Forum: General Discussions
Topic: 65x02 variants
Replies: 15
Views: 15644

Re: 65x02 variants

Branch instructions that cross a page boundary don't have a penalty cycle.
I may be wrong, but isn't it instead that you don't save a cycle for branches within the same page? That branch takes either 2 clocks (not taken) or 4 clocks (taken)? Perhaps an advantage in simplifying cycle counting, but ...
by blargg
Thu Jul 19, 2007 6:24 pm
Forum: Programming
Topic: Writing an assembler
Replies: 17
Views: 13036

Here's a pet feature that I'd like to see in a 65xx assembler: typed constants, specifically addresses and numeric constants. These allow an assembler to emit a warning when a numeric constant is used without a # sign, avoiding the obscure error of accidentally using a numeric constant as an address ...