News for hackers. Stuff that matters.
Re:Things Every Hacker Once Knew by bogomipz on Friday January 27, 2017 @09:17AM (#13499895)
>"It becomes immediately obvious why, eg, ^[ becomes escape. Or that the alphabet is just 40h + the ordinal position of the letter (or 60h for lower-case). Or that we shift between upper & lower-case with a single bit."

I am not following, can you explain why ^[ becomes escape. Or that the alphabet is just 40h + the ordinal position? Can you elaborate? I feel like I am missing the elegance you are pointing out.

Re:Things Every Hacker Once Knew by soneil on Friday January 27, 2017 @10:19AM (#13500251)
If you look at each byte as being 2 bits of 'group' and 5 bits of 'character';

    00 11011 is Escape
    10 11011 is [
So when we do ctrl+[ for escape (eg, in old ansi 'escape sequences', or in more recent discussions about the vim escape key on the 'touchbar' macbooks) - you're asking for the character 11011 ([) out of the control (00) set.

Any time you see \n represented as ^M, it's the same thing - 01101 (M) in the control (00) set is Carriage Return.

Likewise, when you realise that the relationship between upper-case and lower-case is just the same character from sets 10 & 11, it becomes obvious that you can, eg, translate upper case to lower case by just doing a bitwise or against 64 (0100000).

And 40h & 60h .. having a nice round number for the offset mostly just means you can 'read' ascii from binary by only paying attention to the last 5 bits. A is 1 (00001), Z is 26 (11010), leaving us something we can more comfortably manipulate in our heads.

I won't claim any of this is useful. But in the context of understanding why the ascii table looks the way it does, I do find four sets of 32 makes it much simpler in my head. I find it much easier to remember that A=65 (41h) and a=97 (61h) when I'm simply visualizing that A is the 1st character of the uppercase(40h) or lowercase(60h) set.

Re:Things Every Hacker Once Knew by amackera on Friday January 27, 2017 @10:35AM (#13500358)
This single comment has cleared up so much magic voodoo. I feel like everything fell into place a little more cleanly, and that the world makes a little bit more sense.

Thank you!

Re:Things Every Hacker Once Knew by ksrm on Friday January 27, 2017 @04:10PM (#13502685)
I can't believe I've only just realised where the Control key gets its name from. Thank you!
Re:Things Every Hacker Once Knew by FabHK on Friday January 27, 2017 @11:38AM (#13500754)
The article linked mentions that the ctrl key (back then?) just clears the top 3 bits of the octet.
Re:Things Every Hacker Once Knew by bogomipz on Friday January 27, 2017 @12:07PM (#13500982)
Awesome, yes this makes total sense. I'm glad I asked. Cheers.
Re:Things Every Hacker Once Knew by masklinn on Friday January 27, 2017 @09:30AM (#13499967)
Basically, that modifier keys are just flags/mask e.g. ESC is 00011011, [ is 01011011. CTRL just unsets the second MSB and shifts the column without changing the row.

Physically it might have been as simple as a press-open switch on the original hardware, each bit would be a circuit which the key would connect, the SHIFT and CONTROL keys would force specific circuits open or closed.

Re:Things Every Hacker Once Knew by sarabob on Friday January 27, 2017 @09:29AM (#13499959)
if you press a letter and control, it generates the control character in the left-hand column.

the letters in the third column are A = 1, B = 2 etc: 40h + the position in the alphabet.

Awesome to see ^@ as null and laying it out this way makes it easier to see ^L (form-feed, as the article says: control-L will clear your terminal screen), ^G (bell), ^D, ^C etc etc

Re:Things Every Hacker Once Knew by kps on Friday January 27, 2017 @10:27AM (#13500305)
This is so that control characters (and shifted characters — see https://en.wikipedia.org/wiki/Bit-paired_keyboard) could be generated electromechanically. Remember a teletype of the era (e.g. Model 33) has no processing power.
Re:Things Every Hacker Once Knew by olalonde on Friday January 27, 2017 @03:26PM (#13502336)
There's a longer explanation on Wikipedia: https://en.wikipedia.org/wiki/Caret_notation
Re:Things Every Hacker Once Knew by nerdponx on Friday January 27, 2017 @09:25AM (#13499938)
ESC is on the same row as [, just in another column. So Ctrl ends up being a modifier just like Shift, in that it changes column but not row.

The 40h offset is 2 columns' worth.