The Assembly Language Level - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

The Assembly Language Level

Description:

We could live without assembly language and write programs directly in machine code, right? ... language is a language that maps each statement to a single ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 9
Provided by: anniegro
Category:

less

Transcript and Presenter's Notes

Title: The Assembly Language Level


1
The Assembly Language Level
  • CS227
  • Western Washington University

2
Why Assembly Language?
We could live without assembly language and write
programs directly in machine code, right? Thats
not really practical. Machine code is extremely
difficult for humans to understand and therefore
for humans to develop and maintain. Assembly
language instructions are easier to understand
and therefore develop. How does an assembly
language program become machine code? It is
translated, or assembled, into machine
code. Recall that the ISA instructions are
actually in binaryeven though we talked about
them using mnemonics.
3
What is Assembly Language?
Pure assembly language is a language that maps
each statement to a single machine
instruction. As previously stated, it is a lot
easier to program in mnemonics than in binary or
hexadecimal notation. The assembly language has
direct access to all the features and
instructions of the target machines. As a
result, assembly language programs can only run
on a specific target machinesthey are not
cross-platform.
4
Why Use Assembly Language?
Reduce code size Experienced assembly programmers
can write more compact assembly language code
than the code generated by high level compilers.
Certain embedded applications have very limited
amounts of memory, so size does matter. Write
faster code When the number of instructions is
smaller the code can usually execute
faster. Direct access to hardware
devices Embedded real time systems applications
often require direct hardware access.
5
Instruction Format
The format of an assembly instruction closely
mirrors the structure of a machine instruction.
A machine instruction typically begins with a
hexadecimal number representing an opcode and
then uses different bit permutations to denote
the type of operation. The instruction will also
expect a particular number of addresses to
represent the operands. The assembly instruction
typically has 4 parts the label field the
operation/opcode field the operands field the
comments field
6
Assembly Lang Features
Most assembly languages provide a way to reserve
space for datasimilar to declaring variables and
constants in a high level language. Some
examples include DW, DC, and .WORD
Pseudoinstructions or assembler directives are
another component of an assembly language
program. These are instructions that are
directed to the assembler. They will affect the
machine code generated by they will not be
translated directly into machine
code. Directives can be used to declare
variables, constants, segments, macros, and
procedures as well as supporting conditional
assembly.
7
Macros
Macros are used prevalently in assembly language
programs. They provide a means for associating a
name with a block of textsimilar to an alias. A
macro can be associated with a sequence of
instructions that perform a specific operation
such as swapping data. Macros can be used in
place of writing subroutines or procedures.
Why would you want to write a macro instead of
a procedure?
8
The Assembly Process
Most assemblers use a multi-pass process. This
means that the assembler makes multiple passes
through the assembly program. Why? One problem
that is solved is the forward reference
problemlabels that are referred to before they
have an address. Pass One This pass builds the a
symbol table using an Instruction Location
Counter(ILC). It may also build an opcode table
and a pseudoinstruction table. Pass Two This
pass actually generates the machine code.
Write a Comment
User Comments (0)
About PowerShow.com