Subject: Re: [stella] The newbie DASM #constant problem From: KirkIsrael@xxxxxxxxxxxxx Date: 10 Apr 2004 04:40:31 -0000 |
Synopsis: my preference would be a way of tagging every label as a "memory label" or a "constant label", any memory label with a # is a strong warning, every contant label OR NUMBER without a # is a strong warning. > We had a discussion a couple weeks ago about whether the assembler could > possibly notice and warn about the most common syntax error made by new > (and experienced) 2600 programmers - writing LDA 5 when you mean LDA #5. > As I was coding for the 2600 today, the solution hit me: have DASM throw a > warning for any read from a zeropage location between 0 and $7F that uses > a number rather than a constant reference. In common coding practice, we > never refer to any of the TIA registers numerically - we always use the > constant names like CXM1FB. > > LDA 5 ;warning, almost certainly a mistake! > LDA #5 ;good - never warn if the # is used > LDA CXM1FB ;good - a constant name is used > LDA $85 ;don't warn - RAM access, which is often done numerically > > Of course, there's the usual debate over whether something like this > should go into an ostensibly general-purpose assembler, but I think it's > worthwhile implementing as an option. I might even have a go myself once > DASM moves to open source. > > Anyone have any opinions? The trouble is this misses stuff like LDA CONST_SPEED_DELTA Which is the one that zapped me about half the time. I think an ideal solution would be some kind of (macroish?) way of tagging labels as either used for constant values or used as a memory location. Also, I don't think "LDA $85" is usually indicative of a good programming practice... I know I'm not the programmer with the most flair, (not in the "Office Space" sense of "flair" ;-) but I *never* do a LDA $85 and "mean it" -- that would always mean I screwed up, I *only* reference memory locations by labels, even when using tricky code that uses offsets and what not-- it still uses a label for the base memory location (and if need me, I could always define a " HEXEIGHTFIVE = $85" or something) But I think some syntax for specifying if a label should be for memory or for a constant value, and assuming every hard coded number is a constant value...that would be great. If it was a macro, even better. (I'm sure better programmers have a reason that they just need to use memory values by number, but I don't know what it is.) -- KirkIsrael@xxxxxxxxxxxxx http://kisrael.com "Rationality tied to moral decency is the most powerful joint instrument for good that our planet has ever known." --Michael Shermer ---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[stella] The newbie DASM #constant , Erik Mooney | Thread | [stella] My New Project - RRampage., Erik Mooney |
[stella] The newbie DASM #constant , Erik Mooney | Date | Re: [stella] got my homebrew idea!, KirkIsrael |
Month |