This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Coding standards: EQU vs DS

(1) Is there a coding standard for 8051 assembler regarding use of:

foo equ 80h   ; some idata

and

foo:  ds 1
?

(2) What is your opinion?

Parents
  • As Drew says, the two statements have different purposes, and are not interchangeable.

    foo equ 80h   ; some idata
    Simply associates the numerical value 80h with the symbol foo - the comment "some idata" is misleading as there is nothing whatsoever in this definition to show that foo has anything at all to do with IDATA!
    This foo is just a number - 80h - it could be used as a DATA address, an IDATA address, a literal constant, in fact anything where the value 80h is valid.
    foo:  ds 1
    This foo is quite different: it is a label for a specific byte location - whether that location is in IDATA, DATA, CODE, etc, depends upon the context

Reply
  • As Drew says, the two statements have different purposes, and are not interchangeable.

    foo equ 80h   ; some idata
    Simply associates the numerical value 80h with the symbol foo - the comment "some idata" is misleading as there is nothing whatsoever in this definition to show that foo has anything at all to do with IDATA!
    This foo is just a number - 80h - it could be used as a DATA address, an IDATA address, a literal constant, in fact anything where the value 80h is valid.
    foo:  ds 1
    This foo is quite different: it is a label for a specific byte location - whether that location is in IDATA, DATA, CODE, etc, depends upon the context

Children