Square colon notation?

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

Square colon notation?

Post by jeffythedragonslayer »

In Figure 2-8-5 Plot Operations Assigned by CMODE of the Nintendo dev manual, we have:
Z is the source register for the COLOR instruction,
ROM buffer value for GETC instruction.

Z[7:4] is a symbol that shows the data in bit 7 through bit 4 of Z.
Is there a name for this notation? Square colon? Does anyone know where it originated?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Square colon notation?

Post by Dwedit »

You can see this notation used in hardware description languages to describe a range of bits.

It also looks similar to C's Bitfields.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Square colon notation?

Post by lidnariq »

At the very least that's how Verilog notates bitarrays and bitslices.

(VHDL uses "downto". CUPL uses ".." )
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Square colon notation?

Post by calima »

Probably from IBM, it's still used in their Power manuals, and they were pretty much the first computer maker.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Square colon notation?

Post by Oziphantom »

: is commonly used as to in maths. Most typically in odds. 1:7 is 1 to 7 but also ration 3:4 is 3 to 4
[] is used as an array index thus you have
[1:7] selects 1 to 7 of the array
hence your [7:4] selects 7 to 4 from the bit array.
Standard maths nomenclature.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: Square colon notation?

Post by jeffythedragonslayer »

I see... perhaps IBM bitslice notation or bracket-colon notation. The other popular one I'm familiar with on the SNES I call dollar-dot notation. Like if you want to access bit 1 of $1000 you have $1000.1

@Oziphantom
Most typically in odds?
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Square colon notation?

Post by Drag »

[x:y] is helpful when you want to say "this thing is wider than one single bit" in environments where everything is assumed to be just a single bit by default. In Verilog, multi-bit things seem to be called "vectors" and single-bit things are "scalars", which is funny because as a programmer, that makes 3 definitions for what "vector" could mean, depending on what I'm doing. :P
$xxxx.y is helpful in the opposite situation: when everything is assumed to be several bits wide, but you want to pick one bit out specifically.
A third notation, found on the wiki here, would be something like %..xxyyzz, for when your things are multiple bits by default, but you need to point out several different groups of bits, instead of just one single bit.

When describing ranges, the notation I'm used to is, square brackets for inclusive bounds, round brackets for exclusive bounds, and .. to indicate the range, so for example, [0..15] means "from 0 up to (and including) 15", and [0..1) means "from 0 up to but not including 1" (e.g., 0.999999 is included but 1.0 itself is not). I don't know what this notation is called, but I learned it in college, and I think Matlab uses it?
Last edited by Drag on Sat Dec 31, 2022 6:22 pm, edited 1 time in total.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Square colon notation?

Post by creaothceann »

Pascal uses .. for subrange types.
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: Square colon notation?

Post by rainwarrior »

Python has a similar (but not compatible) "slice" notation for arrays:

Code: Select all

a[3:6] // a elements 3,4,5
a[2:8:2] // a elements 2,4,6
a[5:2:-1] // a elements 5,4,3
a[-3:] // last 3 elements of a (python negative indexing counts back from the end of a list)
a[-3:-1] // 3rd and 2nd last elements of a
It's almost the same for counting up, except for being < rather than <= on the stop index. For counting down it needs a third parameter of -1. Of course, python doesn't have an array of bits either.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Square colon notation?

Post by Oziphantom »

jeffythedragonslayer wrote: Sat Dec 31, 2022 3:02 pm @Oziphantom
Most typically in odds?
I figure more people bet then do high level set maths. But that could just be because I live in Aus, and we have public holidays for horse races...
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Square colon notation?

Post by Pokun »

Isn't the colon in math just one of many symbols used as a division operator?

Besides in odds it is also commonly used in map scale notation, for example a 1:100000 notation on a map may mean that 1 cm on the map is 1 km in the real world. And yeah in ratios in general.

As for odds, it is usually thought of as being the number of unsuccessful cases divided by the number of successful cases u:s (this is for "odds against" which is normally implied, "odds in favour" means the dividend and the quotient are swapped s:u). But in reality the number is set by an oddsmaker to make sure the house always makes a profit in the end, so it is usually directly related to the payout instead of the actual probability, as the odds value is typically multiplied with the bet or something like that to calculate payout ("high odds" means a low chance of success and pays out more).

Although the colon is read as "to" (1:5 is read as "one to five") the mathematical meaning would be division if I understand things correctly.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Square colon notation?

Post by rainwarrior »

Pokun wrote: Sun Jan 01, 2023 1:45 pmAlthough the colon is read as "to" (1:5 is read as "one to five") the mathematical meaning would be division if I understand things correctly.
Most of the time that can be equally well expressed as a division/fraction, but : can compare more than just two things. 1:4 expresses only 1 pairing, but 1:4:9 expresses 3 pairings at once (4/1, 9/1, 9/4), and 1:4:9:16 expresses 6. When comparing two things the choice is a little bit arbitrary/style, but when comparing multiple things the ratio notation has this advantage.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: Square colon notation?

Post by jeffythedragonslayer »

rainwarrior wrote: Sun Jan 01, 2023 2:09 pm
Pokun wrote: Sun Jan 01, 2023 1:45 pmAlthough the colon is read as "to" (1:5 is read as "one to five") the mathematical meaning would be division if I understand things correctly.
Most of the time that can be equally well expressed as a division/fraction, but : can compare more than just two things. 1:4 expresses only 1 pairing, but 1:4:9 expresses 3 pairings at once (4/1, 9/1, 9/4), and 1:4:9:16 expresses 6. When comparing two things the choice is a little bit arbitrary/style, but when comparing multiple things the ratio notation has this advantage.
So when I say "I have a 2/1/3 snes" that's actually ternary division. :lol:
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Square colon notation?

Post by Pokun »

Heh, I think the division meaning is lost when arbitrarily comparing things and definitely doesn't apply when using a colon or slash as a generic conjunction symbol (usually meaning "and" or "or").
But colon is literally used for arithmetic division in situations such as scale, ratio or odds. It's similar to how math books nowadays (at least in Sweden) uses the middle dot sign (·) for multiplication but things like dimension notation in blueprints always uses the more traditional cryss* sign (×).


*Or whatever a 45 degrees rotated cross is called in English. I can't find this word in any dictionary but words like "×-mas" and "×-tal" indicates that it's pronounced [kriss] which is close to the Swedish word for it (kryss) so I'm guessing it should be "cryss".
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: Square colon notation?

Post by jeffythedragonslayer »

Pokun wrote: Mon Jan 02, 2023 11:47 am *Or whatever a 45 degrees rotated cross is called in English. I can't find this word in any dictionary but words like "×-mas" and "×-tal" indicates that it's pronounced [kriss] which is close to the Swedish word for it (kryss) so I'm guessing it should be "cryss".
It's called a multiplication sign in english, but I prefer cryss.
Post Reply