An Introduction to Machine Language
When a programmer, writes code, they do it in a high level language, such as C, C++, Java etc. That high level code is run through the compiler, to generate a kind of code known as machine code. Some times the compiler converts the high level language, to a mnemonic language, which is also know as assembly language. And then this mnemonic code is translated to machine code, by the use of an assembler. But modern compilers convert the high level language directly to machine code. The assembly code, which is sometimes generated by the compiler, is in hexadecimals, is then run through an assembler. The assembler converts the hexadecimal strings, to binary numbers, which is the machine language code.
The code that is
generated as machine language, is composed
of 16 bit strings of binary numbers, called instructions. They could be
up to 32
bit and 64 bit strings of binary numbers. The first part of those
strings are
called Opcode, and the second part is called the Operand. In assembly
or
mnemonic language we have Opcodes as LOAD, STORE, JUMP, HALT, etc.
In machine language, we have the binary
equivalents of the above Opcodes. The Operands are either data, or
memory
addresses.
Advertisement.
|
|
The number strings or
instructions, represent the equivalent of
the high level
language code or program. So if the above programmer, did the code in
machine
language, these would be the list of binary number strings. But these
binary
number strings list would be very large, as compared to the high level
language
code, and would be very tedious and difficult to code. These binary
number
strings would be executed in the computer's Central Processing Unit, or
the
CPU. The CPU processes millions of
instructions per second, so it would be done very fast.
In hardware terms, the
CPU consists of a chip, known as the
Microprocessor. The Microprocessor consists of the Arithmetic Logic
Unit (ALU),
the Control Unit (CU) and registers to store and use data locally for
speedy
operation. The basic computer motherboard consists of the
Microprocessor, the
RAM memory, the ROM memory, and the serial buses to carry the data, to
and
from. The microprocessor, processes the instructions. The
microprocessor
instruction set consists of opcodes like LOAD, STORE, JUMP, ADD, XOR,
PUSH,
POP, OR, and many more. These are
mnemonic codes. They are different for different microprocessor chips.
Like a
chip by AMD would have different mnemonic codes, as compared to a chip
by
Intel. The machine language codes generated would be in a binary string
form.
The reason we have
machine language, at the lowest level, is
because, it can be converted into electronic signals. In electronic
terms and
in terms of voltage, the low voltage represents a 0 and the high
voltage
represents a 1. So binary strings can be represented by arrays of
electronic
signals of low and high voltage. Information can
be represented as arrays of binary strings
and stored in electronic form. For
example, the binary string 00010001 can be easily stored in an
electronic
array. The 0s would correspond to low voltages, and the 1s would
correspond to high
voltage. Information can also be processed, using binary strings in
electronic
form. Each of the binary digit would represent a Bit, in computer
terminology.
Eight of the bits would form what is called a Byte.
The converted machine
code is loaded onto the memory, by the
loader. The microprocessor then, FETCHES the next instruction from the
memory, and
proceeds to DECODE it, and then EXECUTES
it. If it is an arithmetic or computation instruction, it uses the ALU
to
process it, otherwise it uses the CU to process it. The program is thus
executed.
Advertisement.
|
|