Code: Select all
lda #10 ; A = the value 10
lda 10 ; A = byte at address 10My proposal is to prevent this error by adding a warning to assemblers for the second case above. To avoid the warning, the value must have some sort of "this is an address" prefix on it, or be defined symbolically in advance. For the moment I'll use the @ symbol, but any syntax could be used:
Code: Select all
lda 10 ; warning
lda @10 ; OK
addr = @10
lda addr ; OK
lda #addr ; OK, sets A to the value 10
not_addr = 10
lda not_addr ; warning
lda @not_addr ; OK
table: .byte 1,2,3,4
lda table ; OK* Assembler keeps track of the type of a value, either an address if prefixed with @, or a pure value if not
* Assembler warns on use of pure value not prefixed with a #
* Labels are addresses
* In an arithmetic expression, if any value is an address, the result of the expression is an address
I think the need to use @ would be minimal, only for the absolute addresses of hardware registers, which would be in a common include file anyway. Non-absolute addresses (i.e. variables and constants) would virtually all be labels, which the assembler would already treat as an address. If there's any complaining about this issue, it should be that the annoying # is required everywhere, when the most common case is a numeric constant, not an absolute address. Enabling this warning would involve the addition of a small number of @ symbols (unless you don't use symbolic constants).