Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

odd question


ghost's Avatar
0 0

I am not even sure how to put this but I will try. How does a computer know what the programming language is saying? What programmed the cpu to understand the program language it self? Does that make since? I understand we write programs but how the hell did the program get programed to understand the program. It is difficult to explain. I hope someone understands what I am asking and can explain.

I understand its based on 1's and 0's but how does it understand that….?

Like which came first the chicken or the egg?


ghost's Avatar
0 0

I'll try simplify some things for you, programming languages are converted to machine language for the computer to understand. The machine language is binary, the 1 has a different value to 0. 0 is off/false/no ect. and 1 is on/true/yes ect.. A small part of code can be compiled into a massive part of binary code, the command given to the machine requires processing, the processor processess the bits of machine code to explain to the systems components what is 1 and 0. I think I have confused myself, I'll shutup now.


ghost's Avatar
0 0

The programs you write are,of course,converted to binary code….

The 1's and 0's in binary code are high voltage and low voltage that are passed to the semiconductor circuits(gates).

(its not that simple,today's chips are Integrated circuits(with a lot of V's and L' as prefixes.))

The chips have the circuits printed on them(There are AND,NOT,etc gates in them)

Using such basic logic,one programs a computer,missile,phone,etc…

Of course,in large companies such low level twiddling is done only for research today,the actual circuit design on products is printed by machines.

Read up on semiconductors and chips to know more…I think basics is in grade 12 level(I don't know your grade syllabus) and the topic branches out from there

———————————ALSO——————————— Would people PLEASE stop using the chicken-egg problem??? The CHICKEN came first,the egg it emerged from was the egg of its predecessor in evolution(I don't know if u "believe" in it:D)


ghost's Avatar
0 0

That's a good question. People seem to be answering a different question from what I think you're asking. Fair enough the cpu is given a bunch of numbers but how does it know what to do with them?

All a CPU has is a bunch of "gates" (like someone described above). You can say use an AND and a XOR gate to add to binary numbers. A XOR will be one if and only if 1 bit is 1. Therefore it can be our lower bit. And then an AND will be out higher bit.

When an ADD x,y op code comes along another circuit reads it sees ADD (lets just say it's 0A) we give the cpu this as machine code. 0A0101 a circuit see's the 0A (it could just compared it to 1,0 if it fit's the correct order 00001010) now since we have 2bit for each value (we're adding 01+01) we need to set 4 pins on the cpu we set them LOW HIGH LOW HIGH these are connected to the ADD (described above for only 1 bit). This could then output to some LED's

If we also had pins for MUL and DIV and SUB we just made a very basic computer which is a calculator.

Making CPU's isn't only for rich companies. You can get an FPGA for about £30 which is effectively a reprogrammable computer. It has a bunch of "logic cell" which can be made to act as AND SUB whatever. These are programed in hardware description languages like verilog or just by schematics almost like building a circuit in a simulator. here's an example of verilog.

module adder(clk, a, b, h, l);
// a,b are input's form pins.
input a; 
input b; 
input clk; //the clock input 
// high and low bits for the output.
output h;
output l;

//posedge is the leading edge of the clock pulse
always @(posedge clk);
assign l<=a^b; //XOR a,b goes to low bit
assign h<=a&b; //AND a,b goes to high bit
endmodule

(This isn't actually how you'd do it. verilog provides an + operation :P) But I wrote that off the top of my head so it probably has a few mistakes, it should make sense anyways. This will be compiled then software will be used to design the circuit called "place and route" this file is transferred to the FPGA.

So a cpu doesn't understand it switch and buttons and highs and lows make stuff happen. Which is mind boggling after you consider what we do with it today.


stealth-'s Avatar
Ninja Extreme
0 0

To give a greater understanding of how the languages are turned into machine code, you could say they are "built on top of each other". The compiler, in C code, turns the code into a binary executable (1,0's). Python is interpreted by a C program, and the C program itself has been converted to binary. Really, all programing languages are is a method of functions and syntax designed to make programing less repetitive. They make it less repetitive by building on a lower level language to (for example) make one function in the new language do what might have taken 100 lines in the language it was built on. The higher level you go, the less code your supposed to have to write. Writing what might take one line in python could take a hundred in assembler.

If you were looking for a understanding on how things work at the hardware level, this podcast is actually not bad for teaching you the basics of stuff.

http://www.grc.com/securitynow.htm

It covers everything from RAM to hardware interrupts, and is a great thing to listen to while gaming or something. They're about an hour to a hour and a half each, but you can skip through most of the crap and cut that number down pretty fast.

You'll want numbers 233, 235, 237, 239, 241, and 247. The rest really aren't that interesting.

Hope I helped somewhere in there ;)


ghost's Avatar
0 0

The simple answer is that there are two parts, hardware and software. The more you code in one, the less you code in the other.

In my intro electronics we made a simple LED counter to count from 0-9, and connect all the wires by hand between 2 chips and the LED. That was pretty fun. You might like working out an electronics hobby kit like that one.


ghost's Avatar
0 0

Wolf hit the nail on the head. +rep


fashizzlepop's Avatar
Member
0 0

I agree. Good response Wolf. Also, good question.


ghost's Avatar
0 0

Thanks guys =D