Transcript Lecture 1

COE 205 - 3
Computer Organization &
Assembly Language
Introduction
HLL vs. Assembly
Programming Languages
Programming Language

Computers only understand programs in their own machine
language.

It is extremely impractical to ask programmers to write their
programs in machine language.

So what is the solution to this dilemma?

The answer is in what are called programming languages

Programming language can be a High-level languages (HLL) or a
low level language (assembly)
COE 205
Term 042
Dr.Talal AlKharobi
2
High-Level Languages (HLL)

HLLs are programming languages that look like natural language text.

They make programming easier and more abstract, i.e. the programmer does
not need to come up with the detailed machine instructions

HLL programs are machine independent. They can be run on different
hardware platforms (i.e. different computers with different instruction sets)

To run a HLL program on a specific machine, it has to be translated to its
machine language

This is done through the use of a compiler: a program that translates a HLL
program to a machine language program of a specific platform

The Machine language program produced by the compiler is usually referred
to as the executable program

Hence by using the appropriate compiler we can execute HLL programs on
any platform
COE 205
Term 042
Dr.Talal AlKharobi
3
Mapping Between HLL and Machine Language

Translating HLL programs to machine language programs is not a
one-to-one mapping

A HLL instruction (usually called a statement) will be translated to
one or more machine language instructions

The number of mapped machine instructions depends on the
efficiency of the compiler in producing optimized machine
language programs from the HLL programs

Usually, machine language programs produced by compilers are
not efficient (i.e. they contain many unnecessary instructions that
increase processing and slow down execution).
COE 205
Term 042
Dr.Talal AlKharobi
4
Data Type in HLL vs Machine Language

High-Level Language supports many primitive data types such as
 integers & real numbers
 strings & characters
 Boolean

HLL allows the programmer to define new and complex data types
using the primitive data types

HLL compilers strictly enforce data typing, preventing the
programmer from making mistakes.

Machine Language just operate on binary numbers and dose not
enforce any data typing.
COE 205
Term 042
Dr.Talal AlKharobi
5
Assembly Language

The assembly language is a programming language that uses
symbolic names to represent operations, registers and memory
locations.

Programs are written in a natural language style.

Each assembly language instruction (or statement) would
correspond to a single machine language instruction.

This makes it easier for the programmer to produce efficient
machine language programs.
COE 205
Term 042
Dr.Talal AlKharobi
6
Why Learn Assembly Language?

Writing assembly programs gives the computer designer the needed
deep understanding of the instruction set and how to design one

To be able to write compilers for HLLs, we need to be expert with the
machine language. Assembly programming provide this experience

Sometimes very efficient machine codes are required to do some
specific functions and these can not be produced by HLL and
compilers. In this case assembly language has to be used

Sometimes we want to access specific memory addresses or I/O
ports. This is very difficult to do using HLLs. In these cases Assembly
language would be the better choice

Embeded-controllers that find numerous applications nowadays
usually contain special-purpose processors. Assembly programming
is usually the only practical way to program these processors.
COE 205
Term 042
Dr.Talal AlKharobi
7
Mapping Between Assembly Language and HLL
 The mapping between HLL
constructs and Assembly
language instructions is
many-to-many, as it was
between HLL and machine
language.
 The table shows some
examples of mapping
between some HLL
instructions and 8086
assembly language
instructions
Instruction
Class
HLL
Assembly
Language
Data
Movement
a=5
MOV a, 5
Arithmetic
b=a+5
MOV ax, a
ADD ax, 5
MOV b, ax
Control Flow
Goto LBL
JMP LBL
logical
B=B or C
MOV ax, C
Or B, ax
COE 205
Term 042
Dr.Talal AlKharobi
8
The Assembler & Linker

The program that translates from assembly language to machine language is
called an Assembler

It allows the programmer to specify the memory locations for his data and
programs and symbolically refer to them in his assembly code.

It will translate these symbolic addresses to actual (physical) addresses in
the produced machine code.

The linker is the program that is used to link together separately
assembled/compiled programs into a single executable code.

It allows the programmers to develop different parts of a large program
separately (some in HLL and others in Assembly depending on the best
choice for that part), test them separately and ‘freeze’ them for future use.

This produces modular programs and greatly enables the management of
large programming projects.
COE 205
Term 042
Dr.Talal AlKharobi
9
Debugger & Monitor
 Tools that allow the assembly programmers to:
 Display and alter the contents of memory and registers
while running their code,
 Perform disassembly of their machine code (show the
assembly language equivalent)
 Permit them to run their programs, stop (or halt) them,
run them step-by-step or insert break points
COE 205
Term 042
Dr.Talal AlKharobi
10