1.

Solve : How does a language talk to hardware??

Answer»

Ok so I'm very very confused how a piece of hardware can understand code. I read somewhere it has to do with voltages but how exactly does the piece of hardware KNOW what an instruction in software means? I know drivers is the bridge between software and hardware but a driver is still software :S.

For example, in C++ we have pointers and they can point to some address in memory.. Can we have a pointer that points to some hardware address and then write to that address and it would affect the hardware? Or does hardware not have addresses?

I guess what I'm really asking is how does the OS or BIOS know where a piece of hardware is and how to talk to it?Short answer. When the PC starts, the BIOS examines the usual places to locate a any hardware device and stores information in a set of pointers. The source coed for the original IBM PC is available, if you want to read it.
Long answer. Study all the engineering books son the original IBM PC  design.
Start Here:
https://en.wikipedia.org/wiki/IBM_Personal_Computer
Quote

The IBM Personal Computer, commonly known as the IBM PC, is the original version of the IBM PC compatible hardware platform. It is IBM model number 5150 and was introduced on August 12, 1981. It was CREATED by a team of engineers and designers under the direction of Philip Don Estridge of the IBM Entry Systems DIVISION in Boca Raton, Florida.
The generic term "personal computer" ("PC") was in use years before 1981, applied as early as 1972 to the Xerox PARC's Alto, but the term "PC" came to mean more specifically a desktop microcomputer compatible with IBM's Personal Computer branded products. The machine was based on open architecture,[1][2] and third-party suppliers sprang up to provide peripheral devices, expansion cards, and software. IBM had a substantial influence on the personal computer market in standardizing a platform for personal computers, and "IBM compatible" became an important criterion for sales growth. Only the Apple Macintosh family kept a significant share of the microcomputer market after the 1980s without compatibility to the IBM personal computer.
...
Look at thee reference at  the bottom.   
The CPU can run machine code instructions for it's architecture. They don't "understand" it per se. Their design is such that they will perform specific functions given particular inputs. Instructions can specify a memory address and the CPU will read/write from that memory address using it's Address bus, for example; Opcodes indicate what operation to take (and things like ModR/M bytes specify memory or register processing.)

>For example, in C++ we have pointers and they can point to some address in memory

This isn't directly true, because it depends on the current operating Mode. For example, on any modern Operating System, Memory pointers in an application aren't pointing at physical memory, they are pointing at Virtual Memory. The CPU is able to effectively move memory pages around in physical memory and the virtual memory addresses remain the same. This was a feature added in x86 processors with the 386 known as "Memory protection". It is only at the lower level software- drivers, for example- where it is possible to directly access memory addresses. (or, if the program is running on say Real-Mode MS-DOS).

It is typically driver software which performs the interfacing with a hardware device. It knows all the quirks and how to access it, it just needs to be told where it is- which is where some added features like Plug & Play come in where the driver can determine the locations of a hardware device. The driver adheres to whatever requirements of the OS and is able to expose capabilities through that OS. for example, a MS-DOS Driver for say a parallel port Bernoulli drive is able to allow access to the device via a DOS Drive letter.

At the driver level software can directly access hardware via memory. Hardware devices have an I/O Address range; often the device effectively maps it's own memory into that area of memory and it watches for changes. Usually, when interacting with hardware via I/O addresses you basically toggle a bit once you are finished writing to indicate there is some new operation, and the device will read the data and start the operation and then reset the flag. Other times, the device itself can trigger an interrupt routine. (This is a feature of the CPU).

Remember that a CPU is integrated CIRCUITRY. For a good example, the MOS 6502 was "disintegrated" into the "MOnSter 6502", this basically expands the CPU and it's components into discrete, separate logic and adds LEDs that allow one to observe the inner workings of the CPU. (It also has a greatly reduced clock speed of 50kHz due to the larger size)Years ago I did some 6502  programming at the LOWEST level.It was ra floppy disk alignment program. Ran on the Apple ][ computer.

But now the new low-cost way to study low level hardware is with a Super Kit from Walmart. This is built on  the Arduino UNO system.
Here is  link:

Super Starter Kit Programming Language Electronics

This is a great value and will give you hands on learning.
Image is below.



Discussion

No Comment Found