(1) Is there a coding standard for 8051 assembler regarding use of:
foo equ 80h ; some idata
foo: ds 1
As Drew says, the two statements have different purposes, and are not interchangeable.
I agree with both of you. However, I inherited code that uses EQU for variables. I dislike this and intend to have our subcontractor change it. In the meantime, I hope to find a document that mandates or, at least, highly recommends the use of DS over EQU. In such a document I had hoped to find other programming pearls, a la McConnell's "Code Complete", et al. Thanks, Doug
"I ... intend to have our subcontractor change it." In my entirely objective, unbiased, and impartial opinion, I'm sure you could find far better things for your subcontractor to do... ;-) (unless, of course, you were asking me to quote for this as a subcontractor...) "I hope to find a document that mandates or, at least, highly recommends the use of DS over EQU." But wasn't that the precisely point that both Drew and I were making: DS and EQU are entirely different beasts - each has its own place, and anything that blindly mandates (or recommends) one over the other must be inherently flawed!?
Sorry. I did not mean to imply one over the other in all cases. My intent was that for variables DS be used instead of EQU. I also agree that our sub has more important things to do with his time. Doug
ds a ds b ds c will automatically allocate separate spaces a equ 8 b equ 9 c equ 10 works as well BUT if these get mixed up it EXTREMELY likely that some day some 'small program change' will result in two variables in same slot a equ 8 b equ (a+1) c equ (b+1) does in some way remove the danger of the above. The one important thing here is to have ALL variables in the same place or you may end up with the stack in a place where you do not want it to be. Erik