Assembly Language
Download
Report
Transcript Assembly Language
CEN 226: Computer Organization
&
Assembly Language :CSC 225
(Lec#1)
By
Dr. Syed Noman
Course organization
• Course is divided into two sections:
▫ Computer organization
▫ Assembly language programming
• Computer organization and assembly language
are interrelated.
▫ Program in assembly and get better
understanding of the machine
▫ Get familiarized with the machine to better
program in assembly language. To program in
assembly language requires knowledge of the
machine.
Text Book
4
Reference Book
Course Outline
•
•
•
•
•
•
•
•
•
Introduction to PC hardware.
von Neumann machine
8086 machine architecture
PC software requirements
Assembly language programmers requirements
Program logical and control
String operations
Arithmetic operations for processing binary data
Assembling linking and executing a program.
Marks Distribution
•
•
•
•
•
•
Lab : 20 Marks
Mid-1: 15 Marks
Mid-2: 15 Marks
Assignment: 6 marks
Quizzes: 2 Marks (best of 2 out of 3)
Attendance: 2 Marks (after 2 absents, 1 mark will be
deducted)
• Final: 40 Marks
Collection of Programs
• Learning Tip: object of the program must be
clearly defined.
• Program Codes are as follows:
▫
▫
▫
▫
EP#: Example program number
LT#: Lab Task number
QP#: Quiz program number
AP#: Assignment program#
Software Hierarchy Levels
Level
Description
Application Program
Software designed for a particular class of
applications
High-Level Language
(HLL)
Programs are compiled into either
assembly language or machine language.
E.g. C++, Pascal, Java, Visual Basic, etc.
Operating Systems
Contains procedures than can be called
from programs written in either high-level
language or assembly language. This
system may also contain an application
programming interface (API).
Assembly Language (ASM) Uses instruction mnemonics that have a
one-to-one correspondence with machine
language.
Machine Language (ML)
8
Numeric instructions and operands that can
be stored in memory and directly executed
by the computer processor.
What is Assembly Language?
• A low-level processorspecific programming
language, designed to match
the processor’s machine
instruction set
• each assembly language
instruction matches exactly
one machine language
instruction
• we study here Intel’s 80x86
(and Pentiums)
9
10
Why learn Assembly Language?
• To learn how high-level language code gets
translated into machine language
▫ i.e.: to learn the details hidden in HLL code
• To learn the computer’s hardware
▫ by direct access to memory, video controller,
sound card, keyboard…
• To speed up applications
▫ direct access to hardware (ex: writing directly to
I/O ports instead of doing a system call)
▫ good ASM code is faster and smaller: rewrite in
ASM the critical areas of code
Table: Comparison of Assembly
Language and High-Level Languages
Type of Applications
High-Level Language
Assembly Language
Business application
software for single
platform.
Formal structures
No formal structure.
make it easy to
organize and maintain.
Hardware device
driver.
Awkward coding
techniques required.
Hardware access is
straightforward and
simple.
Business application
for multiple platforms.
Portable.
Difficult to maintain.
Embedded systems
and computer games
requiring direct
hardware access.
Produces too much
executable code, and
may not run efficiently.
Ideal, because the
executable code is
small and runs quickly.
11
12
Machine Language
• An assembler is a program that converts ASM
code into machine language code:
▫ mov al,5 (Assembly Language)
▫ 1011000000000101 (Machine Language)
most significant byte is the opcode for “move into
register AL”
the least significant byte is for the operand “5”
• Directly programming in machine language
offers no advantage (over Assembly)...
13
Binary Numbers/Storage Size
• are used to store both code and data
• On Intel’s x86:
▫
▫
▫
▫
byte = 8 bits (smallest addressable unit)
word = 2 bytes
doubleword = 2 words
quadword = 2 doublewords
14
Data Representation
• Even if we know that a block of memory
contains data, to obtain its value we need to
choose an interpretation
• Ex: memory content “0100 0001” can either
represent:
▫ the number 2^{6} + 1 = 65
▫ or the ASCII code of character “A”
15
Data Representation
• Number Systems
▫ Binary/Octal/Decimal/Hexadecimal
▫ Converting between various number
systems
• Signed/Unsigned Interpretation
▫ Two’s Complement
• Addition/Subtraction
• Character Storage
16
Number
Systems
• A written number is meaningful only with respect to a base
• To tell the assembler which base we use:
▫ Hexadecimal 25 is written as 25h
▫ Octal 25 is written as 25o or 25q
▫ Binary 1010 is written as 1010b
▫ Decimal 1010 is written as 1010 or 1010d
• You are supposed to know how to convert from one base to
another.