go away spammer

Author Topic: Machine language?  (Read 2723 times)

0 Members and 1 Guest are viewing this topic.

Offline nckspecTopic starter

  • Jr. Member
  • **
  • Posts: 22
  • Helpful? 0
Machine language?
« on: March 29, 2008, 05:57:39 PM »
I was just wondering. can you compile any kind of code (c, basic, java: whatever works for microcontroller) and once it is turned into machine code it will work with any ic ( basic stamp, pic avr atmega8). Like can i use basic with avr atmega8?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Machine language?
« Reply #1 on: March 29, 2008, 09:14:51 PM »
Languages come in two versions: Compiled and Interpreted. Whats the difference?

A compiled language takes the stuff that you type in and generates the machine code for the target processor. The resultant machine code will not work on any other processor (since it has a different 'machine language'). However, by telling the compiler to generate code for a different target processor then it will do this for you. So: your source code be it C, Basic, Java etc doesn't need to change but you tell the compiler to generate the code for the correct target micro-controller. This code, say a hex file, is then tied in to the controller that you generated it for and so you need to re-compile your unchanged source code to generate new code for a different controller. Once you have compiled onto 'machine code' then your hardware does know, and doesn't care, what programming language you wrote it in.

An interpreted language doesn't generate any machine language at all !! Instead it saves your program in an intermediate format and requires your board to have a chip that understands this format. So for Java (and some BASICs) you have an on-board 'interpreter chip' that takes your program and works out how to make it run. Hence the 'BASIC Stamp' has a chip that knows how to make sense of your BASIC code. This is why, in the computer world, a Java program can be run on Windows, Mac, Unix etc - by having a copy of the relevant Java runtime for the target platform you are running on. Whereas a compiled program normally works stand alone without any other bits'n'pieces.


Slightly simplistic response - but hope it makes sense

So if you want to use BASIC with ATMega8 then you will need to find a BASIC compiler that compiles your BASIC source code into ATMega8 machine code. Don't know of one, off hand, and if you can find one then it may cost you. Most folk will advise you to use C with Atmel AVR processors since there are free tools for the Atmel processors like AVR Studio.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline nckspecTopic starter

  • Jr. Member
  • **
  • Posts: 22
  • Helpful? 0
Re: Machine language?
« Reply #2 on: March 30, 2008, 01:35:57 AM »
Thank you.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: Machine language?
« Reply #3 on: March 30, 2008, 01:46:46 AM »
There is Bascom-AVR from MCS Electronics. Bascom stands for Basic Compiler. It is especialy made for AVRs and works great with mega8 and mega168. They have a demo version that can program up to 4k of memory, but if you like it and feel that it suits your needs you can get a license for about a hundred bucks. Lots of samples and support on the forum.

Here is the link: http://www.mcselec.com/index.php?option=com_docman&task=cat_view&gid=99&Itemid=54

The demo version is the last link on the bottom of the page.
Check out the uBotino robot controller!

 


Get Your Ad Here

data_list