Download (DOCX, Unknown)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
MACHINE AND ASSEMBLY CODE
Machine Code
Machine code, also known as machine language, is the elemental language of computers, comprising a long
sequence of binary digital zeros and ones (bits).
Ultimately, the output of any programming language analysis and processing emerges in the form of machine
code. After you write a program, your source language statements are compiled or (in the case of assembler
language) put together into machine code that is stored as an executable file until someone tells the
computer's OS (operating system) to run it. In personal computer OSs, these files typically have the suffix
".exe."
Each processor has its own specific machine language, and it reads and handles a certain number of bits at a
time. Because it is designed to know how many bits (and which bits) tell it what operation to do, the processor
can look at the correct sequence of bits and perform the next operation. Then it reads the next instruction,
and so on. Each machine-code instruction causes the CPU (central processing unit) to perform a simple
operation such as an arithmetic calculation or storing data in RAM (random access memory). Execution of
machine code can be controlled by firmware or else carried out by means of the CPU's internal wiring.
Human programmers rarely, if ever, write or read in machine code because it is essentially impossible to
translate it from or into thoughts that the human mind can understand. Humans write in so-called high-level
languages that are far more comprehensible than machine code, and that require far fewer characters to
represent the task at hand.
Assembly Language
Intermediate-level programming language which is higher (is easier to use but runs slower) than machine
language and lower (is more difficult to use but runs faster) than a high-level language such as Basic, FORTRAN,
or Java. Programs written in assembly language are converted into machine language by specialized programs
called assemblers or compilers for their execution by the machine.
Assembly language is converted into executable machine code by a utility program referred to as an
assembler; the conversion process is referred to as assembly, or assembling the code.
Assembly language uses a mnemonic to represent each low-level machine instruction or operation. Typical
operations require one or more operands in order to form a complete instruction, and most assemblers can
therefore take labels, symbols and expressions as operands to represent addresses and other constants,
freeing the programmer from tedious manual calculations. Macro assemblers include a macroinstruction
facility so that (parameterized) assembly language text can be represented by a name, and that name can be
used to insert the expanded text into other code. Many assemblers offer additional mechanisms to facilitate
program development, to control the assembly process, and to aid debugging.
Op-code
Specifications and format of the opcodes are laid out in the instruction set architecture of the processor in
question, which may be a general CPU or a more specialized processing unit. Apart from the opcode itself, an
instruction normally also has one or more specifies for operands (i.e. data) on which the operation should act,
although some operations may have implicit operands, or none at all. There are instruction sets with nearly
uniform fields for opcode and operand specifies, as well as others (the x86 architecture for instance) with a
more complicated, variable-length structure.
Depending on architecture, the operands may be register values, values in the stack, other memory values, I/O
ports, etc., specified and accessed using more or less complex addressing modes. The types of operations
include arithmetic’s, data copying, logical operations, and program control, as well as special instructions.
Operand
Operand codes are the data side of the op code. They contain either numerical values or memory locations
ready for the cpu to access. A hash in operand code tells the cpu to use the numerical value of the piece of
code rather than the memory location. If there is no hash it will look for the data in that specified memory
location