Jump to content
IGNORED

DASM question


e1will

Recommended Posts

Is there any difference in DASM between these two lines in an .asm file?

 

LEFT_BORDER = 9
LEFT_BORDER = #9

I'm not sure about DASM, but these would be treated differently in other assemblers I know of. It's not good programming practice to include the "#" in the definition though, because it will be harder to tell immediate and absolute/ZP instructions apart in the code, and that may result in bugs that will take you a long time to find.

Link to comment
Share on other sites

Is there any difference in DASM between these two lines in an .asm file?

 

LEFT_BORDER = 9
LEFT_BORDER = #9

Or is the # ignored?

 

--Will

I'm not sure if the context might make a difference, or perhaps the version of DASM, but when I tried it they were interpreted identically. So that means even if you use the pound sign in the equate, you'd still need to use a pound in an instruction if you want it to use the immediate mode:

 

LEFT_BORDER_1 = $9
LEFT_BORDER_2 = #9
  LDA LEFT_BORDER_1 ; this is equivalent to LDA $09 (zero page addressing)
  LDA LEFT_BORDER_2 ; this is also equivalent to LDA $09 (zero page addressing)
  LDA #LEFT_BORDER_1 ; this is equivalent to LDA #9 (immediate addressing)
  LDA #LEFT_BORDER_2 ; this is also equivalent to LDA #9 (immediate addressing)

Michael

Link to comment
Share on other sites

The "#" is usually part of the instruction syntax, meaning "use immediate mode". The "$" is part of the syntax of constant numbers.

 

I'm assuming that the "=" stores a numeric value in the symbol table, not a macro substitution string (such as #define in C), in which case you can't use "#" like that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...