15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The History of Computer Programming 11<br />

In the old days, computers filled entire rooms and cost millions of dollars.<br />

Today, computers have shrunk so far in size that they’re essentially nothing<br />

more than a little silicon wafer, about the size of a potato chip. These silicon<br />

wafers are called the central processing unit (CPU), a microprocessor, or just<br />

a processor.<br />

A processor is essentially an entire computer. To tell the processor what to<br />

do, you have to give it instructions written in machine language — a language<br />

that the processor can understand.<br />

Book I<br />

Chapter 1<br />

Getting Started<br />

Programming a<br />

Computer<br />

To make faster computers, engineers smash two or more processors<br />

together and make them work as a team. So instead of having a single<br />

processor in your computer, the latest computers have two, four, six, or<br />

more processors working side by side.<br />

Talking to a processor in machine language<br />

To understand how machine language works, you have to understand how<br />

processors work. Basically, a processor consists of nothing more than millions<br />

of tiny switches that can turn on or off. By turning certain switches on<br />

or off, you can make the processor do something useful.<br />

Instead of physically turning switches on or off, machine language lets you<br />

turn a processor’s switches on or off by using two numbers: 1 (one) and 0<br />

(zero) where the number 1 can mean “turn a switch on” and the number 0<br />

can mean “turn a switch off.” So a typical machine language instruction<br />

might look like this:<br />

1011 0000 0110 0001<br />

If the preceding instruction doesn’t make any sense, don’t worry. The point<br />

is that machine language is a just way to tell a processor what to do.<br />

Using 1’s and 0’s is binary arithmetic. Because binary arithmetic can be so<br />

hard to read, programmers also represent binary numbers in hexadecimal.<br />

Where binary arithmetic uses only two numbers, hexadecimal uses sixteen<br />

numbers (0–9 and A–F). So the binary number 1011 0000 0110 0001 could be<br />

represented as the hexadecimal number: B061.<br />

Machine language is considered the native language of CPUs, but almost no<br />

one writes a program in machine language because it’s so tedious and confusing.<br />

Mistype a single 1 or 0 and you can accidentally give the wrong instruction<br />

to the CPU. Because writing instructions in machine language can be so<br />

difficult and error-prone, computer scientists have created a somewhat simpler<br />

language — assembly language.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!