AOA Forums AOA Forums AOA Forums Folding For Team 45 AOA Files Home Front Page Become an AOA Subscriber! UserCP Calendar Memberlist FAQ Search Forum Home


Go Back   AOA Forums > Software > Programming and Assembly Language

Programming and Assembly Language Please read this Topic's rules!!


Reply
 
LinkBack Thread Tools Rate Thread
  #1 (permalink)  
Old 4th January, 2003, 07:05 PM
cloasters's Avatar
Asst. BBS Administrator
 
Join Date: September 2001
Location: Location, Location
Posts: 21,956

Elucidation solicited, please.

First off, I'm a dummy in the software department. Can I ask a very basic question, please?

Do CPU's "translate" program wording so that it makes sense to the them? Or is it a given that modern CPU's handle every one of the many programming languages?

I'd guess that big iron RISC processors specialize in olde through modern programming languages that are 64-Bit?

And x86 CPU's are befuddled by say, Cobol. But are happy with before Basic through C#?

Thank you for taking the time and effort on my behalf!
__________________
When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 4th January, 2003, 10:31 PM
Member
 
Join Date: September 2001
Location: Kent UK
Posts: 969
Send a message via ICQ to Rackne Send a message via AIM to Rackne Send a message via Yahoo to Rackne

Assuming we're talking about high level languages like VB, Pascal, C++ etc, before programs can be run they have to be translated from source code (what the programmer writes) into object or machine code depending on what you want to call it.

This is done by a compiler or interpreter, which are language specific.

Compilers convert all the source code into object code at once and create a "standalone" program which will run independently of the interpreter. eg they might make a .exe file. This can be a time consuming process if you have a lot of code to compile so isn't ideal when developing as one tiny change in code requires all the code to be compiled again before it can be tested. For small programs this isn't much of an issue but when there's more than 1000 lines of code things begin to take a while. Compilers also hide the source code from the user whcih means people can't copy, steal or alter your program.

Interpreters are most commonly used during development as they convert one line of source code to object code at a time, execute it then get the next line of source code. Good during development cos they crash as soon as an error is found which makes modifying mistakes quicker than using a compiler as you don't have to reload and recompile the whole program every time you make a slight change. However interpreted code will always run slower than compiled code because translation is occuring as the program runs. Also, it exposes your source code.

I'm not going to go into all the steps of machine/object code generation unless asked.

As to the processor languages will run on, don't know specifics, not my area of expertise. Low level languages like assembly language are machine orientated (ie will only work for one type of chip) while high level langauages are in theory portable between different machines provided there is an appropriate compiler or interpreter available.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 6th January, 2003, 03:56 PM
cloasters's Avatar
Asst. BBS Administrator
 
Join Date: September 2001
Location: Location, Location
Posts: 21,956

Thank you very much for providing this information, Rackne!
May I ask another Q, please?

Where is a compiler located? Is it included with an OS?
__________________
When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 6th January, 2003, 04:09 PM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,914

I think (at least for Java) the compiler is a part of the Java SDK (Software Development Kit).

The compiler is a "program" by itself. We used a compiler called javac (for java compiler?!), I bet there are others out there though. But it came with the SDK.

In "dintprog" (Introduction to programming) I wrote the code in Emacs, compiled it with Javac and ran it with java...
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 6th January, 2003, 05:31 PM
Member
 
Join Date: September 2001
Location: Kent UK
Posts: 969
Send a message via ICQ to Rackne Send a message via AIM to Rackne Send a message via Yahoo to Rackne

Linux comes with some compilers included, Windows doesn't. Compilers tend to be available for download if they're free, or come with development environments like Visual Basic and other Microsoft offerings.

The standard Java compiler is indeed javac, which Sun distribute for free and which runs from the command line.

I write most of my code in gvim then compile it with whichever compiler necessary.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 6th January, 2003, 10:53 PM
Superman's Avatar
Systems Administrator
 
Join Date: September 2001
Location: WI
Posts: 4,406
Send a message via ICQ to Superman

vim rocks, emacs sucks, end of story

The GNU project offers compilers for many languages, including C, C++, Java, Fortron, and Ada (I think, hehe) via their gcc project. That's for Linux, BTW.
__________________
"And, most of all, remember this descendant of David who beat the hell out of death."
-from the book "Six Hours One Friday" by Max Lucado

"You have to go outside the sequence of engines, into the world of men, to find the real originator of the rocket. Is it not equally reasonable to look outside nature for the real Originator of the natural order?
-C.S. Lewis


Director of JavaScript section of the Allied Sites Support Team, web designer and programmer for DaOCPlace, and co-web designer and programmer for AOA Files

Avatar by Epox Tech



<>< I Believe-Do You?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 6th January, 2003, 10:55 PM
Member
 
Join Date: September 2001
Location: Kent UK
Posts: 969
Send a message via ICQ to Rackne Send a message via AIM to Rackne Send a message via Yahoo to Rackne

Never tried emacs but vim does indeed rock.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 7th January, 2003, 07:18 PM
cloasters's Avatar
Asst. BBS Administrator
 
Join Date: September 2001
Location: Location, Location
Posts: 21,956

Another "duuh" question if you have the time, please.

Does any processor handle "machine code" only? If so, do you write in programming language that is later "dumbed down" for computers? Or do you write in "machine code" that is then "translated" into instructions that fit the desired programming language?

Is it safe to assume that you write the program in a language that approaches English(with plenty of what are usually known as exclamation points, brackets, the other kinds of brackets, colons and lots of uppercase characters? If so, is this is what is "compiled" into machine code?

Sorry, I'm thick as a brick in this department!
__________________
When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 7th January, 2003, 07:48 PM
Chief Systems Administrator
 
Join Date: September 2001
Location: Europe
Posts: 13,075

A processor only understands machine code, and more specifically, only the machine code for that processor will work on it. (Not quite true for some mainframes though) Hence, a program written for a Mac won't run on a PC, not just because the OS is different, but also because the processor effectively speaks a different language.

Machine code is effectively just a bunch of numbers stored in some memory locations, that just happen to make sense to the CPU.

Generally, they're fairly simplistic instructions, along the lines of...

Move data from A to B
Add A to B
Subtract A from B
Multiply A by B
Divide A by B
Compare A and B
Go to another bit of program if A was larger/smaller/equal/zero/notzero than B
Do nothing (Better known as NOP for No Operation)

Unless, of course, you're Intel, in which case you do stuff like:

Move data from B to A
Add B to A
Subtract B from A
...
and so on

Now, the really magic thing here is that A and B can be memory (RAM), IO space (like memory, but for Peripherals), registers (temporary storage on the CPU) or any mix!

Do these simple steps often enough, and quick enough, and you can make it seem like things are really happening!

A compiler does the magic work of taking your program and converting it into these basic steps. Obviously one instruction in a high level language can take many instructions (possibly hundreds) at the machine level.

Writing much code in Assembly code can be a lot of work. Each instruction in Assembly code has a direct corresponding instruction in the machine code. Assembly is friendlier, as it uses mnemonics instead of numbers. For instance, an instruction to load the contents of memory location 1234 into temporary store A could be represented like

MOVE 1234,A

In machine language, it might look like

17 10 18 52

There's a direct one-to-one relationship between the two, no matter how hard that might seem. For obvious reasons, most sane people prefer a higher level language!


The other thing that can be done is interpretation. This is where a program takes your code, instruction at a time, and interprets its actions and carries them out. This is much slower, as your program is running on another program that is running on the processor. It's basically like an emulator for the language!

Áedán
__________________
Any views, thoughts and opinions are entirely my own. They don't necessarily represent those of my employer (BlackBerry).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 8th January, 2003, 04:34 PM
cloasters's Avatar
Asst. BBS Administrator
 
Join Date: September 2001
Location: Location, Location
Posts: 21,956

Thank you Aedan! I'm actually going to be able to understand this post after reading it a few more times.
__________________
When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 10th January, 2003, 02:44 AM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,914

Quote:
Originally posted by Superman
vim rocks, emacs sucks, end of story
Well, can you play TETRIS in vim? You can in emacs, hehe. Seriously, there are a lot of people who (when they get used to it) really love emacs... but it DOES take some getting used to.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 10th January, 2003, 09:53 PM
cloasters's Avatar
Asst. BBS Administrator
 
Join Date: September 2001
Location: Location, Location
Posts: 21,956

Quote:
Originally posted by Áedán
A processor only understands machine code, and more specifically, only the machine code for that processor will work on it. (Not quite true for some mainframes though)Áedán
(Please excuse my snippery. I did it for brevity. Hated to, your's is an exceptionally helpful post.)

May I ask another question, please? If processors only understand machine code written specifically for them, how do Via and AMD CPU's survive in a predominantly Intel world?

I'm sure this is an ignorant question, sorry.
__________________
When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 10th January, 2003, 10:09 PM
Chief Systems Administrator
 
Join Date: September 2001
Location: Europe
Posts: 13,075

Quote:
Originally posted by cloasters
May I ask another question, please? If processors only understand machine code written specifically for them, how do Via and AMD CPU's survive in a predominantly Intel world?
That's not a stupid question. It's because Via and AMD work hard at making their chips understand the same instructions as Intel's chips. Intel's architecture is known as IA32 (Intel Architecture 32). When I say IA32, I mean Intel compatible.

More recently, AMD and Intel's chips have diverged. Things like Intel's SSE and AMD's 3DNow! are actually sets of instructions on the CPU.

If code is running on an AMD IA32 CPU, it has to know which instructions it can run. Hence, it's possible to query an IA32 CPU and find how what sets of instructions it understands. That's what certain CPU info programs do!

Áedán
__________________
Any views, thoughts and opinions are entirely my own. They don't necessarily represent those of my employer (BlackBerry).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 11th January, 2003, 05:32 PM
cloasters's Avatar
Asst. BBS Administrator
 
Join Date: September 2001
Location: Location, Location
Posts: 21,956

Thank you very much, Aedan! I figured that there must be a "translator" section of the CPU's, which converted the "foreign" machine code into code that the CPU "understands."

It's better to not have to do this. This "translator" might require lots of dedicated memory in an "L0" cache!
__________________
When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 25th January, 2003, 01:44 PM
SiGmA_X's Avatar
Member
 
Join Date: April 2002
Location: Portland, OR
Posts: 1,529
Send a message via ICQ to SiGmA_X Send a message via AIM to SiGmA_X Send a message via MSN to SiGmA_X Send a message via Yahoo to SiGmA_X

No, both vim and emacs suck (I hate them.. So confusing! I kept deleting stuff I didn't want to!) and nano p0wnz them all
__________________
"In war, it is not the goal to die for your country, but rather to make the other bastard die for his!"
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:39 AM.


Copyright ©2001 - 2023, AOA Forums
Don't Click Here Don't Click Here Either

Search Engine Friendly URLs by vBSEO 3.3.0