scotws wrote:
I'm getting to the point with my 65816 assembler where I can start thinking about more than just the core functionality. I'd like to include some checks for obvious problems -- for instance, if you're coding the WDM instruction, you've probably done something wrong. Also, a XCE without a SEC or CLC before should generate a warning as well. Checking for JSR/RTS sequences (to be replaced by JMP) would be another easy optimization to suggest. Does anything else come to mind for the experienced 65816 programmers here? The amount of stuff I'll be able to include in this single-pass assembler will be limited, but somebody out there might be thinking about a two-pass version as we speak ...
I personally do not want an assembler doing my thinking for me. None of those checks would be of value to me, as the assembler can't possibly know what are my intentions. That sort of stuff is fine with a compiler, where some hand-holding may be useful (all compilers generate diagnostics about dubious things, as well as outright errors). However, one writes assembly language programs to (among other things) create the fastest and tightest possible code. Doing so frequently entails the use of "odd" programming techniques that an "error-correcting" assembler will misunderstand.
As for warning about WDM, Garth already pointed out that the instruction actually has some specialized usages. Also, WDM is benign: it's seen as a NOP and doesn't nothing other than step PC.
Similarly, as Garth noted, the JSR -- RTS sequence may be valid due to run-time branching. Also, as he noted, any subroutine that expects a stack frame prior to entry cannot be JuMPed into, as the wrong word will be pulled for a return address, causing a major malfunction.
My advice, FWIW, is to limit the assembler's error checking to syntactical and addressing matters of the type that would otherwise cause it to emit erroneous code, and assume that the programmer knows what he's doing.