Machine Code and Assembly Language
Machine Code and Assembly Language
to human language. The results are translated into machine code, which computers understand.
Assembly languages
Higher-level languages
Each generation is at a higher level of abstraction i.e.: The higher the generation, the lesser the programmer will be aware of the internal workings of the program in the hardware level.
A Brief Chronology
Early 1950s 1957 FORTRAN 1958 ALGOL 1960 LISP, COBOL 1962 APL, SIMULA 1964 BASIC, PL/I 1966 ISWIM 1970 Prolog 1972 C 1975 Pascal, Scheme 1978 CSP 1978 FP 1983 Smalltalk-80, Ada 1984 Standard ML 1986 C++, Eiffel 1988 CLOS, Oberon, Mathematica 1990 Haskell 1990s Perl, Python, Ruby, JavaScript 1995 Java 2000 C# order codes (primitive assemblers) the first high-level programming language the first modern, imperative language Interactive programming; business programming the birth of OOP (SIMULA) first modern functional language (a proposal) logic programming is born the systems programming language two teaching languages Concurrency matures Backus proposal OOP is reinvented FP becomes mainstream (?) OOP is reinvented (again) FP is reinvented Scripting languages become mainstream OOP is reinvented for the internet
the computer hardware can understand and execute directly. All other forms of computer language must be translated into machine code in order to be executed by the hardware. Machine code consists of many strings of binary digits that are easy for the computer to interpret, but tedious for human beings to interpret. Machine code is different for each type of computer.
A program in machine code for an Intel x86-based PC will not run
Assembly Language
Assembly language is a symbolic representation of machine
code, which allows programmers to write programs in machine code without having to deal with the long binary strings. For example, the machine code for an instruction that adds two numbers might be 01101110, but in assembly language, this can be represented by the symbol ADD. A simple assembler program translates this symbolic language directly into machine code. Because machine code is specific to each type of computer hardware, assembly languages are also specific to each type of computer. However, all machine languages and assembly languages look very similar, even though they are not interchangeable.
Assembly code
beings to understand. High-level programming languages must be translated into machine code for execution, and this process is called compilation. A program that carries out this translation is a compiler. High-level language may bear no resemblance at all to machine code. The compiler figures out how to generate machine language that does exactly what the high-level-language source program specifies. Languages like C++, Algol, COBOL, etc., are all compiled high-level languages. They usually work more or less the same across all computer types, which makes them much more portable than assembly language.
Example :
than 3GLs.
4GLs may use a text-based environment (like a 3GL) or may
in the programming community some programmers cannot agree that they even exist.
These high-level languages would use artificial
of the computer system. To enter data into memory, the address switches were toggled to the correct address, the data switches were toggled next, and finally the WRite switch was toggled. This wrote the binary value on the front panel data switches to the address specified. Once all the data and instruction were entered, the run switch was toggled to run the program.
of the processor.
Each instruction needed to be manually converted into bit
patterns by the programmer so the front panel switches could be set correctly.
This led to errors in translation as the programmer could
error prone.
larger memory, and the increase in memory size (due to better production techniques and lower cost), programs were written to perform some of this manual entry.
Small monitor programs became popular, which allowed
from mnemonics to instructions was still performed manually. To increase programmer productivity, the idea of writing a program to interpret another was a major breakthrough. This would be run by the computer, and translate the actual mnemonics into instructions. The benefits of such a program would be
reduced errors
faster translation times changes could be made easier and faster
instructions in mnemonic form, using an assembler to convert these mnemonics into actual processor instructions and associated data.
So basically assembly language is a translator from
Mnemonics
Assembler
task : the implementer chooses an appropriate language, develops the algorithm (a sequence of steps, which when
carried out in the order prescribed, achieve the desired result), implements this algorithm in the chosen language (coding), then tests and debugs the final result.
essential that a standardized format be followed. Most manufacturers provide assemblers, which are programs used to generate machine code instructions for the actual processor to execute.
language source program into a format which run on the processor. Each machine code instruction (the binary or hex value) is replaced by a mnemonic. A mnemonic is an abbreviation which represents the actual instruction.
Binary 01001111 00110110 01001101 Hex 4F 36 4D Mnemonic CLRA PSHA TSTA Clears the A accumulator Saves A acc on stack Tests A acc for 0
Mnemonics are used because they are more meaningful than hex or binary values reduce the chances of making an error are easier to remember than bit values Assemblers also accept certain characters as representing
$24 or 24h 24D 67 0101111B 377O 232Q LDAA #$34 LDAA 01,X
Assembly language statements are written one per line. A machine code program thus consists of a sequence of
assembly language statements, where each statement contains a mnemonic. Each line of an assembly language program is split into four fields, as shown below
LABEL OPCODE OPERAND COMMENTS
Label
The label field is optional. A label is an identifier (or text string symbol). Labels are used extensively in programs to reduce reliance upon
programmers remembering where data or code is located. A label can be used to refer to a memory location the value of a piece of data the address of a program, sub-routine, code portion etc. The maximum length of a label differs between assemblers. Some accept up to 32 characters long, others only four characters.
A label, when declared, is suffixed by a colon, and begins with a valid
character (A..Z).
Example
START: LDAA #24H
Here, the label START is equal to the address of the instruction LDAA
#24H.
associated with the label START, thus executing the instruction LDAA #24H immediately after the JMP instruction. When a label is referenced later on in the program, it is done so without the colon suffix.