News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: SNES Assembly: #$ vs # vs $  (Read 10390 times)

lowena

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
SNES Assembly: #$ vs # vs $
« on: July 04, 2013, 02:27:29 pm »
I know this is a very simple question, one that should be obvious, but I can't find any information on it anywhere... mostly because it is almost impossible to search for "#$" in a search engine. :banghead:

Could someone briefly explain to me what the difference between #$ and $ before numbers mean?

Thanks!

Lenophis

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 959
  • The return of the sombrero!
    • View Profile
    • Slick Productions
Re: SNES Assembly: #$ vs # vs $
« Reply #1 on: July 04, 2013, 02:47:16 pm »
LDA #$09

Here, the value of 9 gets loaded into the accumulator. This is called "Immediate."

LDA $09

Here, whatever is being held in $09 will be loaded into the accumulator. If this is NES, this is called loading from "Zero Page." If it's SNES, it's called loading from "Direct Page." Perhaps a better example:

LDA $0009

This is called "Absolute." If this is SNES, and DP was set to 0000 in the previous example, both of these would load from the same location. The DP load would be slightly faster, though.


https://ff6randomizer.codeplex.com/ - Randomize your FF6 experience!

Bregalad

  • Hero Member
  • *****
  • Posts: 2637
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #2 on: July 04, 2013, 02:55:54 pm »
The dollar $ sign simply means the value after it is given in hex. No dollar would mean it is in decimal.

i.e.

lda #$ff

is the same as

lda #255

I hope it helps.

lowena

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #3 on: July 04, 2013, 03:12:49 pm »
So then what does the pound sign indicate on its own? And in conjunction with the dollar sign?

Bregalad

  • Hero Member
  • *****
  • Posts: 2637
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #4 on: July 04, 2013, 03:31:20 pm »
The pound sign £ is never used in assembly language and is illegal, any use of it (outside of comment area) would probably generate an error.

Nowadays everyone use 0x..... to indicate hexadecimal notation and 0b..... for binary, but back then the $ sign was used for hex and the % sign for binary instead. This "old" notation has simply died, and the 0x became dominant.

Now if the 6502 syntax were adapted to today's standard we'd use

lda #0xff

but that looks a bit weird ;)

lowena

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #5 on: July 04, 2013, 03:32:16 pm »
By pound I mean #, smartass...

Bregalad

  • Hero Member
  • *****
  • Posts: 2637
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #6 on: July 04, 2013, 03:34:40 pm »
# is a sharp symbol, not a pound.

Lenophis already explained it's usage, it's for the addressing mode. Many different instruction sets uses this notation where # means "immediate value".

lowena

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #7 on: July 04, 2013, 03:41:44 pm »
Here, whatever is being held in $09 will be loaded into the accumulator. If this is NES, this is called loading from "Zero Page." If it's SNES, it's called loading from "Direct Page." Perhaps a better example:
Here it is said that $09 is an address (or maybe a pointer to an address).

The dollar $ sign simply means the value after it is given in hex. No dollar would mean it is in decimal.

I hope it helps.
And here you are saying that it means it's a hex number. So no, conflicting information does not help. Either one of you is wrong, or one is trolling me, and I'm more inclined to believe it's you, since in the nesdev forum someone PM'd me warning me about how rude you are.

And then there's this:
# is a sharp symbol, not a pound.
"Sharp" is used for music, not computing. In the computer world it's either "hash", "pound", or "number" signs.

Lenophis

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 959
  • The return of the sombrero!
    • View Profile
    • Slick Productions
Re: SNES Assembly: #$ vs # vs $
« Reply #8 on: July 04, 2013, 03:58:30 pm »
Both of us are correct.

LDA $09 is loading from a hexidecimal location in memory, either RAM or ROM. That will depend on the architecture and mapping. You could convert the hex to a regular decimal number, but it's generally not recommended.


https://ff6randomizer.codeplex.com/ - Randomize your FF6 experience!

Bregalad

  • Hero Member
  • *****
  • Posts: 2637
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #9 on: July 04, 2013, 04:14:02 pm »
Quote
"Sharp" is used for music, not computing. In the computer world it's either "hash", "pound", or "number" signs.
Really ? I wasn't aware of this. Since it's the same symbol than for music it would make the most sense to use the same name for it, isn't it ?

tryphon

  • Hero Member
  • *****
  • Posts: 722
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #10 on: July 04, 2013, 04:20:44 pm »
In fact, they are not exactly the same :

Quote from: wikipedia
The sharp symbol (♯) may be confused with the number (hash or pound) sign (#). Both signs have two sets of parallel double-lines. However, a correctly drawn sharp sign must have two slanted parallel lines which rise from left to right, to avoid being obscured by the staff lines. The number sign, in contrast, has two compulsory horizontal strokes in this place. In addition, while the sharp also always has two perfectly vertical lines, the number sign (#) may or may not contain perfectly vertical lines (according to typeface and writing style).

LostTemplar

  • Hero Member
  • *****
  • Posts: 906
    • View Profile
    • au-ro-ra.net
Re: SNES Assembly: #$ vs # vs $
« Reply #11 on: July 04, 2013, 04:34:24 pm »
To sum it up: $ means hex and # means value (as opposed to address). There's also % for binary.

255 = address 255
$ff = address 255
%111111111 = address 255
#255 = value 255
#$ff = value 255
#%11111111 = value 255

lowena

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #12 on: July 04, 2013, 04:35:57 pm »
To sum it up: $ means hex and # means value (as opposed to address).

255 = address 255
$ff = address 255
#255 = value 255
#$255 = value 255
Thank you! That's all I needed.

LostTemplar

  • Hero Member
  • *****
  • Posts: 906
    • View Profile
    • au-ro-ra.net
Re: SNES Assembly: #$ vs # vs $
« Reply #13 on: July 04, 2013, 04:37:23 pm »
Just to let you know, I updated my post. There's also % for binary.

puzzledude

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #14 on: July 12, 2013, 12:47:57 pm »
Could someone briefly explain to me what the difference between #$ and $ before numbers mean?

Let's learn by example

Part of the Asm for A link to the past
LDA $7EF353 ; load ram mirror slot
CMP #$02 ; compare to value 02 (have mirror is 02, no mirror is 00)
BNE $06 ; if not value 02, go to enable BG2

$ obviously refers to an Address in hex, LDA $7EF353 means load Ram address 7EF353 (this is a ram address for monitoring if you have a mirror item or not), but CMP #$02 means compare it to the Value 02 in hex. Then branch if not equal etc.

So this is just a basic difference between where to look and what is the actual value at that address.
« Last Edit: July 12, 2013, 01:46:50 pm by puzzledude »

BRPXQZME

  • Hero Member
  • *****
  • Posts: 4572
  • じー
    • View Profile
    • The BRPXQZME Network
Re: SNES Assembly: #$ vs # vs $
« Reply #15 on: July 12, 2013, 01:00:15 pm »
The $ does not refer to an address, but exists to inform the assembler that the number provided is in hexadecimal format (as has been said). The use of an address is implied in the instruction itself. When coding this, or constructing a readable disassembly, you would not use “LDA $location”, but rather “LDA location”.

Also, among American programmers, it is usually the best practice to call # a hash unless the context demands it be something else, like a sharp (e.g. music, or in the C# language which is a musical reference and codepoint abomination, or shebang [whose etymology is unclear]) or a pound (phone numbers mostly).
« Last Edit: July 12, 2013, 01:12:45 pm by BRPXQZME »
we are in a horrible and deadly danger

puzzledude

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #16 on: July 12, 2013, 01:37:08 pm »
You are correct, but I just had to simplify this in order to answer the question, so that it would be understood by the person who originally posted it. If $ only means a hex value (and it does mean that), what is then the difference between $ and #$. I would obviously had to rephrase the question in order to answer it.

As you can see above, the person who originally posted the question, actually couldn't believe the true meaning of $. Sure the $ means only a hex value, but this is not the essence. The goal is a difference between the address and the value.

BRPXQZME

  • Hero Member
  • *****
  • Posts: 4572
  • じー
    • View Profile
    • The BRPXQZME Network
Re: SNES Assembly: #$ vs # vs $
« Reply #17 on: July 12, 2013, 04:16:06 pm »
As I can see above, the OP had no trouble accepting the correct answer more than a week ago after seeing LostTemplar’s concise explanation. If you want a difference between the address and the value, that’s #, not $.
we are in a horrible and deadly danger

Disnesquick

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #18 on: July 22, 2013, 06:13:07 pm »
Why do all yinz carpetbaggers call the #/hash symbol a "pound"?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6892
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: SNES Assembly: #$ vs # vs $
« Reply #19 on: July 22, 2013, 07:10:53 pm »
Because that's what a # sign is called in the US (or at least what we used to call it on landline phones. Haven't heard anyone talk about it since.)
"My watch says 30 chickens" Google, 2018