Objectives and Perspective of Assembly Language
Objectives and Perspective of Assembly Language
It means: z = x + y;
Machine language
Native to a processor: executed directly by hardware
Instructions consist of binary code: 1s and 0s
Assembly language
A programming language that uses symbolic names to represent
operations, registers and memory locations.
Slightly higher-level language
Readability of instructions is better than machine language
One-to-one correspondence with machine language instructions
Assemblers translate assembly to machine code
Compilers translate high-level programs to machine code
Either directly, or
Indirectly via an assembler
Software tools are needed for editing, assembling, linking,
and debugging assembly language programs
An assembler is a program that converts source-code
programs written in assembly language into object files in
machine language
Popular assemblers have emerged over the years for the
Intel family of processors. These include …
TASM (Turbo Assembler from Borland)
NASM (Netwide Assembler for both Windows and Linux), and
GNU assembler distributed by the free software foundation
In assembly language, mnemonics are used
to specify an opcode that represents a
complete and operational machine language
instruction. This is later translated by the
assembler to generate the object code. For
example, the mnemonic MOV is used in
assembly language for copying and moving
data between registers and memory
locations.
Each command of a program is called an instruction
(it instructs the computer what to do).
Computers only deal with binary data, hence the
instructions must be in binary format (0s and 1s) .
The set of all instructions (in binary form) makes up the
computer's machine language. This is also referred to as
the instruction set.
Machine language instructions usually are made up of
several fields. Each field specifies different information
for the computer. The major two fields are:
Opcode field which stands for operation code and it
specifies the particular operation that is to be performed.
Each operation has its unique opcode.
Operands fields which specify where to get the source
and destination operands for the operation specified by
the opcode.
The source/destination of operands can be a constant,
the memory or one of the general-purpose registers.
Built from two pieces
Add R1, R3, 3
Opcode Operands
What to do Where to
with the data get data and
(ALU put the
operation) results
Arithmetic, logical
◦ add, sub, mult
◦ and, or
◦ Cmp
Memory load/store
◦ ld, st
Control transfer
◦ jmp
◦ bne
Complex
◦ movs
Each operand taken from a particular
addressing mode:
Examples: