Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You're asking the question the wrong way around. Text doesn't get converted to 1's and 0's or turned into voltages. The 1's and 0's and voltages are the first principles. Code is emergent behavior.

When you strike a key on your keyboard, what happens? A few circuit lines on the keyboard switch matrix that are normally open become closed circuits. These circuits are inputs to a keyboard decoder chip such as a 74C922. It interprets voltage levels on these lines as 1's or 0's and produces what we call a scan code. This scan code is output serially to the PC over the keyboard connection by sending voltage levels that switch between 1 and 0 over time.

The PC contains a chip (a collection of transistors wired together) that we call a keyboard controller. It sequentially switches a number of transistors to read the incoming scan code bit by bit and store each bit in a flip-flop. We call this collection of flip-flops a register. The keyboard controller also drives voltages representing 1's and 0's onto some circuit lines that are wired into the CPU. We call this an interrupt. More transistors within the CPU will detect that interrupt signal and copy a pattern of 1's and 0's into a particular collection of flip-flops, which we call the program counter register. We now have the concept of an interrupt handler.

The CPU's transistors now drive the 1's and 0's in the program counter register (flip-flops) onto a group of circuit lines. We call that collection the memory address bus, and the pattern an address. The memory is itself a giant collection of flip-flops, a few (8 or 32 or whatever) of which are wired to respond to this pattern on the address bus and drive their contents onto another group of circuit lines that we call the data bus. These contents we call an opcode, and the pattern of this opcode we might call a port-read instruction. Inside the CPU, a particular group of transistors activates to execute this opcode, with the result of copying the contents of a particular port (the flip-flops in the keyboard controller) into a register within the CPU (more flip-flops.) Then the next opcode activates another group of transistors to copy the register flip-flops onto the memory bus, where the 1's and 0's latch into some more memory flip-flops. (There's more to interrupt handling than this of course, but that's the bare essentials.)

Do that many times and you might eventually have a sequence of memory flip-flops with a pattern of 1's and 0's representing a string such as PRINT "HELLO WORLD". But it's not that this text was converted into 1's and 0's. The 1's and 0's are the first principles. It's flip-flops and electric signals all the way down.

"Text" or "code" or "software" are merely abstractions we use to describe emergent behavior arising from groups of transistors shuffling around these 1's and 0's.



IMHO this is the most accessible and sensible ("makes most sense to me") answer so far. Thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: