
Originally Posted by
BubbaJoe13
thanks for the link. ya, ill prolly invest in a chip for starting projects...but id like to know how the programming works (well really, i was one of those kids that got a present and played with it for 2 secs, before blasting it apart to see how it worked...so i guess i want to know how everything works..and since programming is at the base of all electronics and computing, that would be the most obvious way.no?). Thanks again for the link...looks that is a diamond for those who want to finish a project quickly
Indeed it is.
If you want to learn coding for microprocessors, then C or C++ is what you will be using.
I thought you just wanted coding for the PC to make games, or applications. Drivers and integrated code is all completely different. There you cant use what is easiest, you have to use what is fastest and smallest. For instance, you shouldnt use a string to classify things, because a string is an array of characters.
For instance in C#, if you wanted easy to read code you could say:
Code:
string thisThing = "Tree";
switch(thisThing)
{
case "Tree":
doTreeThing();
break;
case "Frog":
doFrogThing();
break;
default:
doUnknownThing();
break;
}
each character in the string takes up as much space as an integer. And when you are dealing with storage spaces such as Gigabytes in modern computers, or 512Mb of RAM, this is no problem. However, when you get a PIC with 64Kb of memory, each byte matters.
So instead you need:
Code:
/*
* 0 = Tree
* 1 = Frog
...
*/
int thisThing = 0;
switch(thisThing)
{
case 0:
doTreeThing();
break;
case 1:
doFrogThing();
break;
default:
doUnknownThing();
break;
}
takes up less space and is much faster, but it starts to get less human readable. The most basic you will probably go is assembly which is a nightmare to understand. I dont get it yet.
When you do a if(string == string), it has to compare every single character. It is as if you had n number of if statements where n is the length of the string. So if("tree" == "there") it is actually:
Code:
if(char1a == char1b) {
if(char2a == char2b) {
if(char3a == char3b) {
if(char4a == char4b) {
if(char5a == char5b) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
that is when it executes it. Instead of just 1 if statement for an integer. It doesnt actually work just like that above, but it does have that many more comparisons because a string is just an array.
So anyways, there are completely different styles of codes for microproccessor coding, and general computer coding.
Bookmarks