Aidan: How does a computer’s hardware understand it’s base code in the first place?
So I am a computer programmer, and I’m planning on creating a mobile device by creating the hardware and building a custom circuit board for it.
I haven’t done too much research yet, but how does a computer’s hardware understand it’s base programming language in the first place?
How can a computer’s hardware read code and understand what it means?
Answers and Views:
Answer by JoelKatz
It doesn’t have to understand what it means any more than a ball has to understand the laws of physics in order to bounce. See the link below for more information on how microprocessors (the part of the computer that executes the base code) work.
High level code eventually gets converted into machine code which the CPU “understands”. The CPU interprets the code and generates (electrical) signals to handle various instructions dealing with registers, memory etc.Answer by Richard M
You obviously have a long way to go.
Anyway, there are various parts to any computer. The two you need to know about are the BIOS (Basic Input/Output System) and the CPU. You write your code and compile it for the CPU. The CPU uses little numbers that represent lots of exciting things – like commands to load registers, memory addresses, and stuff like that.
The BIOS is stored in a non-volatile memory chip and carries those instructions that allow the appliance to “boot” or start up correctly and be able to do real work.
The CPU is designed to do a couple of things when it is first powered on. The first is to clear all the registers and address pointers. The second thing is to look at a specific memory address where it can retrieve and action a command. So you put the BIOS stuff where the CPU is designed to look.
Simple, eh?Answer by Jim J
It’s hard to explain this to someone who’s had little experience with digital logic circuits. To fully understand this, you need to read up on logic gates, boolean algebra, CPU and bus architecture.
I’ll try to keep it simple. The base language of a computer is machine code. The part of the computer that actually “understands” and executes machine code is the CPU.
Machine codes consist of numbers: opcodes and arguments. For example “254” is a x86 instruction meaning “decrease by 1”.
The CPU itself consists of a complex network of logic gates (basic digital devices that combine and manipulate bits of data). When the CPU reads an opcode of 254, it sees it as a binary bit-pattern: 11111110. Each of those bits is sent down its own wire (bus) into a logic-gate network (instruction decoder) which is connected in such a way that an input of 254 would activate the “decrease by 1” mechanism; an input of, say, 14 would activate the “multiply by” mechanism, etc.
In short, the CPU is hardwired to respond to specific patterns of bits which we call machine code. If you ever take a digital circuit course, you will likely build a basic 4-bit CPU for your final project.
Leave a Reply