I was pondering the meaning of life, along with several computer and algorithmic concepts, like I often do, as many of you know, and I came upon a question that has been lulling around in my mind for quite some amount of time now.

I thought of which board I should post this in, but as it is not related to C++, Game Programming, or any specific operating system, I felt it best to post it here.

As you might have guess by now, it is about the Assembly language. Now, many of us could easily recognize assembly if we saw it, for example:

mov ah, 01
mov dl, 02
int 21
int 20

That is a very simple assembly program right there. Also, many of us know that Assembly code can be translate directly into binary code (or machine code if you are anal about the name, as I know some people on this message board seem to be). For example, the latter program translated into binary would be the following:

(Actually I am going to display the hex code first):

B4 01 B2 02 CD 21 CD 20

(Then the binary):

1011 0100 0000 0001 1011 0010 0000 0010 1100 1101 0010 0001 1100 1101 0010 0000

(if my binary conversion was incorrect, please correct me).
(if you have any questions about converting assembly code into binary code, you can find the definitions of all assembly commands, and how to compose their binary equivalents in any documentation for a good Assembly program, such as Microsoft MASM.).

But anyways, back to my question....(sorry for all the information leading up to it).

I was reading my reference material for ASM, and saw these terms. I have also seen these in a lot of assembly code I have seen around the net, etc.:

IF, ELSEIF, ELSE, ENDIF, FOR, WHILE, REPEAT, SUBSTR, STRUCT, etc. (i dont think i have to go on, you have probably all seen them).

I don't understand how they all fit into the assembly language. Some of them, I understand. For example, a struct is just a declaration of a data type (BASICALLY), and so I can see how that might translate directly into machine code.

However, there are others which I do not see have the ability to translate directly into machine code, for example, the FOR loop which was stated in my ASM reference.

With my knowledge, a for loop requires initializations, conditions, and incrementation of variables, all of which, to the best of my knowledge, cannot be translated directly into machine code.

In fact, I was once taught how to do loops in assembly, using the various jmp commands, etc., and I can see how easily how those translate into direct machine code, but I cannot see how a for loop would.

In my view, a for loop would have to be translate into assembly code, and THEN into machine code, correct?

So if my assumption is correct, then why on earth is it included as part of an Assembler? In my views, if you are going to code in assembler, you should code in pure, hard, down and dirty Assembly language that is directly above the machine code, like Assembly language was always meant to be. Since when did for loops become part of that? For loops are not the only thing that I have seen. Look at the SUBSTR function which was included in my assembly reference.

Since when did SUBSTR become part of assembly? To the best of my knowledge, parsing a string and extracting a sub-string from it takes much more than just a few lines of code, and therefore can in now way be translated into a single line of machine code such as the definition for Assembly code states.

Then why has it been integrated into Assemblers? These two high-level commands are not the only ones that I have seen bobbing around in Assembly code, but they are the first that have come to my head as I have been writing this post.

But my point is, I am looking as several so called .asm files assembled using assemblers, which contain obvious high level coding!

Leave high level code to such languages as C++, C, Basic, Java, etc. That is what they are meant for. They are middle and high level languages.

Assembly is a low level language that is meant to be right above meachine code, so I am having trouble accepting the fact that such high level coding is being implemented into assemblers, when such coding does not translate directly into machine code.




Assembly - The automatic translation of symbolic code into machine code.

Source: The American Heritage® Dictionary of the English Language, Fourth Edition
Copyright © 2000 by Houghton Mifflin Company.

Assembly Language - A symbolic representation of
the machine language of a specific processor. Assembly
language is converted to machine code by an assembler...each line of assembly code produces one machine instruction.

The Free On-line Dictionary of Computing, © 1993-2001 Denis Howe

David no like use of high level stuff in asm