$ vs. h for hex addresses

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

$ vs. h for hex addresses

Post by jeffythedragonslayer »

Does anyone know the history of why most 65x hex addresses begin with $, but some like here (https://problemkaputt.de/fullsnes.htm) instead end in h? Is this a matter of different 65x dialects or do people just not like holding down the shift key?
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: $ vs. h for hex addresses

Post by rainwarrior »

It's not really 6502 specific, it's just two different conventions.

One convention is using suffixes (h for hexadecimal, o for octal, b for binary, etc.) to denote non-decimal numbers. The other convention is using $ prefix for hexadecimal specifically and maybe @ and % for octal and binary.

They're both common. I think the "h" suffix was favoured by Intel, so you see it in a lot of x86 stuff, but it gets used for any architecture.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: $ vs. h for hex addresses

Post by jeffythedragonslayer »

Cool, I feel better about using h then! Never heard of @ for octal, that's cute.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: $ vs. h for hex addresses

Post by Dwedit »

Meanwhile, in the C programming language and anything descended from that, the 0x prefix reigns supreme.

Gnu Assembler uses @ as the comment character, so seeing that made me do a little double take.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: $ vs. h for hex addresses

Post by creaothceann »

C has 0b.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: $ vs. h for hex addresses

Post by rainwarrior »

Wow, I didn't realize that was finally added in C++14.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: $ vs. h for hex addresses

Post by DRW »

The person who decided to prefix octal numbers simply with a 0 deserves a paddlin'.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: $ vs. h for hex addresses

Post by jeffythedragonslayer »

Fun fact: I heard on cppcast that in C++ source when you type a 0 it's an octal 0
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: $ vs. h for hex addresses

Post by Pokun »

Yeah I heard that too and read a long explanation of it that I forgot! Pretty crazy (the thing itself, not that I forgot)!

Dwedit wrote: Fri May 20, 2022 6:09 pm Gnu Assembler uses @ as the comment character, so seeing that made me do a little double take.
Ugh on Swedish keyboards the "@" requires to press AltGr+2. Using "Graphical symbols" for something as commonly used as comments sounds like a huge pain. The "$" is already bad enough requiring to use AltGr+4.

rainwarrior wrote: Sat May 21, 2022 1:41 am Wow, I didn't realize that was finally added in C++14.
Right! I find it almost outraging that an old and heavily used language like C++ did not have a standard way of expressing one of the most important and useful number bases in programming until recently, yet it had the much less useful octal base since way back. Compilers have supposedly supported 0b for a long time before it was finally made standard though.

DRW wrote: Sat May 21, 2022 1:48 am The person who decided to prefix octal numbers simply with a 0 deserves a paddlin'.
Agreed!
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: $ vs. h for hex addresses

Post by rainwarrior »

Octal was more popular in the 1970s. It often makes me think of the switches on the front of the Altair 8800, which had octal grouping, despite being an 8-bit CPU. A lot of the early IBM mainframes had more natural 3-bit groupings in their design. By the 1980s, 8-bit groupings had become standard, I guess.

Mostly octal seems to hang on for code dealing with unix file permissions. I dunno, I'd definitely be for elimination of 0 prefix by default, but I'm sure they've had the backward compatibility argument in the C standards discussions over and over on this one. (Meanwhile python seems almost eager to burn a few bridges every now and then...)

After reading a bit more it seems that $ @ % prefixes were popularized by Motorola's early assemblers.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: $ vs. h for hex addresses

Post by creaothceann »

Pokun wrote: Sun May 22, 2022 4:11 pm Ugh on Swedish keyboards the "@" requires to press AltGr+2. Using "Graphical symbols" for something as commonly used as comments sounds like a huge pain. The "$" is already bad enough requiring to use AltGr+4.
For German @ is AltGr+Q, and the [ ] brackets are AltGr+8 and AltGr+9. :? It's almost enough to switch keyboards for programming...
rainwarrior wrote: Sun May 22, 2022 5:02 pm Octal was more popular in the 1970s. It often makes me think of the switches on the front of the Altair 8800, which had octal grouping, despite being an 8-bit CPU. A lot of the early IBM mainframes had more natural 3-bit groupings in their design. By the 1980s, 8-bit groupings had become standard, I guess.
Also, the x86 instruction set started with an octal design.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
User avatar
TmEE
Posts: 960
Joined: Wed Feb 13, 2008 9:10 am
Location: Norway (50 and 60Hz compatible :P)
Contact:

Re: $ vs. h for hex addresses

Post by TmEE »

All these cars being under AltGr on Estonian (and Swedish+Finnish) layout are why I switched to US-International layout early on (and later when I switched to Dvorak I created Dvorak-International layout where all accent chars are in same place as US-int layout).
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: $ vs. h for hex addresses

Post by Oziphantom »

the BIOS's Ports on IBM-PC are also usually spec'd in octal for some reason, so if you look at a QBASIC code you will see a lot of it. Also CHMOD uses octal.

$ is a Motorolla thing.

I think it all comes down to the keyboard the original implementation was written on, the issue with $ is not all keyboards had $s. For example in England who needs $ you want £, and if you are in Germany you want DM and for Italy you want ₤
Keyboard issues are why we have <: = [ and ??= as way to type # and ??/ for \ see also Linux Filesystem.

It annoys me how ARM and MIPS use $ for register, really throws me in the assembly seeing LDR $1,$2

Prefix makes parsers easier as you don't need to store the whole number and then convert you know what your type is before. Thus doing $vv or 0xvv is faster than vvh which would have made a difference back in the day.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: $ vs. h for hex addresses

Post by NewRisingSun »

the BIOS's Ports on IBM-PC are also usually spec'd in octal for some reason
Where? I have never seen that.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: $ vs. h for hex addresses

Post by creaothceann »

My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Post Reply