$ vs. h for hex addresses
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
- jeffythedragonslayer
- Posts: 344
- Joined: Thu Dec 09, 2021 12:29 pm
$ vs. h for hex addresses
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?
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: $ vs. h for hex addresses
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.
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.
- jeffythedragonslayer
- Posts: 344
- Joined: Thu Dec 09, 2021 12:29 pm
Re: $ vs. h for hex addresses
Cool, I feel better about using h then! Never heard of @ for octal, that's cute.
Re: $ vs. h for hex addresses
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.
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!
-
- Posts: 611
- Joined: Mon Jan 23, 2006 7:47 am
- Location: Germany
- Contact:
Re: $ vs. h for hex addresses
C has 0b.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: $ vs. h for hex addresses
Wow, I didn't realize that was finally added in C++14.
Re: $ vs. h for hex addresses
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
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
- jeffythedragonslayer
- Posts: 344
- Joined: Thu Dec 09, 2021 12:29 pm
Re: $ vs. h for hex addresses
Fun fact: I heard on cppcast that in C++ source when you type a 0 it's an octal 0
Re: $ vs. h for hex addresses
Yeah I heard that too and read a long explanation of it that I forgot! Pretty crazy (the thing itself, not that I forgot)!
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.
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.
Agreed!
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: $ vs. h for hex addresses
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.
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.
-
- Posts: 611
- Joined: Mon Jan 23, 2006 7:47 am
- Location: Germany
- Contact:
Re: $ vs. h for hex addresses
For German @ is AltGr+Q, and the [ ] brackets are AltGr+8 and AltGr+9. It's almost enough to switch keyboards for programming...
Also, the x86 instruction set started with an octal design.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.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
- 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
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).
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: $ vs. h for hex addresses
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.
$ 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.
-
- Posts: 1510
- Joined: Thu May 19, 2005 11:30 am
Re: $ vs. h for hex addresses
Where? I have never seen that.the BIOS's Ports on IBM-PC are also usually spec'd in octal for some reason
-
- Posts: 611
- Joined: Mon Jan 23, 2006 7:47 am
- Location: Germany
- Contact:
Re: $ vs. h for hex addresses
Another link: https://retrocomputing.stackexchange.co ... -originate
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10