Low-level programming language: Difference between revisions

Content deleted Content added
m Reverted edits by Barresmus123 (talk) to last version by Cedar101
Bima123 (talk | contribs)
m CUTE !
Tag: blanking
Line 1:
~BIMA O NOT BIMA
{{Unreferenced|date=December 2009}}
In [[computer science]], a '''low-level programming language''' is a [[programming language]] that provides little or no [[Abstraction (computer science)|abstraction]] from a computer's [[instruction set architecture]]. Generally this refers to either [[machine code]] or [[assembly language]]. The word "low" refers to the small or nonexistent amount of [[abstraction (computer science)|abstraction]] between the language and machine language; because of this, low-level languages are sometimes described as being "close to the hardware."
 
Low-level languages can be converted to machine code without using a compiler or interpreter, and the resulting code runs directly on the processor. A program written in a low-level language can be made to run very quickly, and with a very small memory footprint; an equivalent program in a high-level language will be more heavyweight. Low-level languages are simple, but are considered difficult to use, due to the numerous technical details which must be remembered.
 
By comparison, a [[high-level programming language]] isolates the execution semantics of a computer architecture from the specification of the program, which simplifies development.
 
Low-level programming languages are sometimes divided into two categories: ''first generation'', and ''second generation''.
 
==Machine code==
[[Machine code]] is the only language a microprocessor can process directly without a previous transformation. Currently, programmers almost never write programs directly in machine code, because it requires attention to numerous details which a high-level language would handle automatically, and also requires memorizing or looking up numerical codes for every instruction that is used. For this reason, [[second generation programming language]]s provide one abstraction level on top of the machine code.
 
Example: A function in 32-bit [[x86]] machine code to calculate the ''n''th [[Fibonacci number]]:
<pre>
8B542408 83FA0077 06B80000 0000C383
FA027706 B8010000 00C353BB 01000000
B9010000 008D0419 83FA0376 078BD98B
C84AEBF1 5BC3
</pre>
 
==Assembly==
[[Assembly language]] is not considered a programming language as it has no semantics and no specification, being only a mapping of human-readable symbols, including symbolic addresses, to [[opcode]]s, [[memory address|addresses]], numeric constants, [[string (computer science)|strings]] and so on. Typically, one machine instruction is represented as one line of assembly code. Assemblers produce [[object file]]s which may be [[linker (computing)|linked]] with other object files or [[loader (computing)|loaded]] on their own.
 
Most assemblers provide [[macro (computer science)|macros]].
 
Example: The same [[Fibonacci number]] calculator as above, but in x86 assembly language using [[MASM]] syntax:
<source lang="asm">
fib:
mov edx, [esp+8]
cmp edx, 0
ja @f
mov eax, 0
ret
@@:
cmp edx, 2
ja @f
mov eax, 1
ret
@@:
push ebx
mov ebx, 1
mov ecx, 1
@@:
lea eax, [ebx+ecx]
cmp edx, 3
jbe @f
mov ebx, ecx
mov ecx, eax
dec edx
jmp @b
@@:
pop ebx
ret
</source>
 
==Low-level programming in high-level languages==
Experiments with hardware support in high-level languages in the late 1960s led to such languages as [[IBM PL/S|PL/S]], [[BLISS]], [[BCPL]], and extended [[ALGOL]] for [[Burroughs large systems]] being used for low-level programming. [[Forth (programming language)|Forth]] also has applications as a systems language. However, the language that became pre-eminent in [[systems programming]] was [[C (programming language)|C]].
 
C is considered a [[third-generation programming language|third generation]] programming language, since it is [[structured programming|structured]] and abstracts from machine code (historically, no [[second generation programming language]] emerged that was particularly suitable for low-level programming). However, many programmers today might refer to C as low-level, as it lacks a large [[Run time system|runtime]]-system (no [[Garbage collection (computer science)|garbage collection]] etc.), basically supports only scalar operations, and provides direct memory addressing. It therefore readily blends with assembly language and the machine level of [[CPU]]s and [[microcontroller]]s. C's ability to abstract from the machine level means that the same code can be compiled for different hardware platforms; however, fine-grained control at the systems level is still possible providing that the target platform has certain broadly-defined features in place, such as a [[flat memory model]], and memory that is divided into [[byte]]s. C programmes may require a certain amount of 'tweaking', often implemented by [[conditional compilation]], for different target platforms. The process of adapting a systems programme for a different platform is known as [[porting]].
 
Example - a function that calculates the nth [[Fibonacci number]] in C
 
<source lang="c">
unsigned int fib(unsigned int n)
{
if (n <= 0)
return 0;
else if (n <= 2)
return 1;
else {
int a,b,c;
a = 1;
b = 1;
while (1) {
c = a + b;
if (n <= 3) return c;
a = b;
b = c;
n--;
}
}
}
</source>
 
==Relative meaning==
The terms ''high-level'' and ''low-level'' are inherently relative. Some decades ago, the [[C (programming language)|C language]], and similar languages, were most often considered "high-level". Many programmers today might refer to C as low-level.
 
Assembly language may itself be regarded as a higher level (but often still one-to-one if used without [[Macro (computer science)|macro]]s) representation of [[machine code]], as it supports concepts such as constants and (limited) expressions, sometimes even variables, procedures, and [[data structure]]s. [[Machine code]], in its turn, is inherently at a slightly higher level than the [[microcode]] or [[micro-operation]]s used internally in many processors.
 
==See also==
* [[High-level programming language]]s
* [[Very high-level programming language]]s
* [[Programming language generations]]
 
{{Programming language}}
{{X86 assembly topics}}
 
{{DEFAULTSORT:Low-Level Programming Language}}
[[Category:Programming language classification]]