Uploaded by Laraib Saeed

Computer Organization: Assembly Language Fundamentals

advertisement
COMPUTER ORGANIZATION
By
Javeria Amin
CONTACT INFORMATION
• Instructor:
Javeria Amin (Lecturer)
Department of Computer Sciences
University of Wah
• Office Hours:
08:00 am - 030:30 pm, at CS faculty Hall
2/18/2025
2
COURSE BOOK
• Recommended Text Books:
• Assembly Language for X86 Processors, 6th Edition by Kip R.
Irvine
• Reference Books:
• Computer Systems: A Programmer's Perspective by Randal E. Bryant and David
R. O'Hallaron, Prentice Hall - http://csapp.cs.cmu.edu/
• The Art of Assembly Language by Randy Hyde http://webster.cs.ucr.edu/AoA/Windows/PDFs/0_PDFIndexWin.html
• System Software: An Introduction to Systems Programming by Leland L. Beck Addison-Wesley
3
EVALUATION CRITERIA
S. No. Assessment Items
%age
1
Assignments
5
2
Quizzes / Class Participation
10
3
Group project and report
10
4
1st Sessional (after 4 weeks)
10
5
2nd Sessional (after 9 weeks)
15
6
Final examination (after 15 weeks)
50
Total
100
2/18/2025
4
GROUP PROJECT AND REPORT
• Total Weightage:
10 % of Total Marks
• Group Members:
Maximum 3 members (all members work on separate
module)
After 2nd Sessional Weekly progress Report
Project Demonstration along with detailed report of project
2/18/2025
5
COURSE OBJECTIVES
• It is expected that at the end of this course the student
will be able to:
• understand the principles and techniques of machine-level
programming.
• learn to use computers for real time data acquisition and control
of input-output devices.
• design and implement complex programs.
• learn the organization of a real microprocessor.
• learn the Interaction between Assembly Language Programs, the
Operating System and Other Application Programs
COURSE OUTCOMES
• At the end of the course, the student should be able to
• Explain how an instruction is executed
• Summarize how instructions are represented at both the machine level and in the context
of a symbolic assembler.
• Explain different instruction formats, such as addresses per instruction and variable
length vs. fixed length formats.
• Write assembly language program segments.
• Demonstrate how fundamental high-level programming constructs are implemented at
the machine language level.
• Explain the basic concepts of interrupts and I/O operations.
• Machine level representation of data
• Explain the pros and cons of using different formats to represent numerical data.
• Convert numerical data from one format to another.
• Describe the internal representation of characters, strings, records, and arrays.
• Memory system organization and architecture
• Identify various types of buses in a computer system.
• Functional organization
TODAY’S LECTURE
• Context of Assembly Language
• Software Hierarchy Levels
• What & Why Assembly Language
• Comparison of Assembly Language with High Level
Languages
• Assembly Language Applications
QUESTIONS TO ASK
• Why am I learning Assembly Language?
• What background should I have?
• What is an assembler?
• What hardware/software do I need?
• What do I get with this book?
• What will I learn?
9
WELCOME TO ASSEMBLY LANGUAGE
(CONT)
• How does assembly language (AL) relate to machine
language?
• How do C++ and Java relate to AL?
• Is AL portable?
• Why learn AL?
10
INTRODUCTION
Levels of Programming Languages
1) Machine Language
• Consists of individual instructions that will be executed by the CPU
one at a time
2) Assembly Language (Low Level Language)
• Designed for a specific family of processors (different processor
groups/family has different Assembly Language)
• Consists of symbolic instructions directly related to machine
language instructions one-for-one and are assembled into machine
language.
3) High Level Languages
• e.g. : C, C++ and Vbasic
• Designed to eliminate the technicalities of a particular computer.
• Statements compiled in a high level language typically generate
many low-level instructions.
ADVANTAGES OF ASSEMBLY
LANGUAGE
1.
2.
3.
4.
Shows how program interfaces with the processor,
and operating system.
Shows how data is represented and stored in
memory and on external devices.
Clarifies how processor accesses and executes
instructions and how instructions access and
process data.
Clarifies how a program accesses external devices.
REASONS FOR USING ASSEMBLY
LANGUAGE
1.
2.
3.
A program written in Assembly Language requires considerably
less memory and execution time than one written in a high –level
language.
Assembly Language gives a programmer the ability to perform
highly technical tasks that would be difficult, if not impossible in a
high-level language.
Resident programs (that reside in memory while other program
execute) and interrupt service routines (that handle input and
output) are almost always develop in Assembly Language.
A HIERARCHY OF LANGUAGES
ASSEMBLY AND MACHINE LANGUAGE
• 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
• Assemblers translate assembly to machine code
• Compilers translate high-level programs to machine code
• Either directly, or
• Indirectly via an assembler
COMPILER AND ASSEMBLER
INSTRUCTIONS AND MACHINE
LANGUAGE
• 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.
INSTRUCTION FIELDS
• 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.
ASSEMBLY VS. MACHINE CODE
TRANSLATING LANGUAGES
English: Display the sum of A times B plus C.
C++: cout << (A * B + C);
Assembly Language:
mov eax,A
mul B
add eax,C
call WriteInt
Intel Machine Language:
A1 00000000
F7 25 00000004
03 05 00000008
E8 00500000
20
MAPPING BETWEEN ASSEMBLY
LANGUAGE AND HLL
• 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
ADVANTAGES OF HIGH-LEVEL
LANGUAGES
• Program development is faster
• High-level statements: fewer instructions to code
• Program maintenance is easier
• For the same above reasons
• Programs are portable
• Contain few machine-dependent details
• Can be used with little or no modifications on different
machines
• Compiler translates to the target machine language
• However, Assembly language programs are not portable
ASSEMBLY VS. HIGH-LEVEL
LANGUAGES
Some representative types of applications:
SPECIFIC MACHINE LEVELS
(descriptions of individual levels
follow . . . )
24
HIGH-LEVEL LANGUAGE
• Level 4
• Application-oriented languages
• C++, Java, Pascal, Visual Basic . . .
• Programs compile into assembly language
(Level 3)
25
ASSEMBLY LANGUAGE
• Level 3
• Instruction that have a one-to-one correspondence
to machine language
• Programs are translated into Instruction Set
Architecture Level - machine language (Level 2)
26
INSTRUCTION SET ARCHITECTURE (ISA)
• Level 2
• Also known as conventional machine language
• Executed by Level 1 (Digital Logic)
27
DIGITAL LOGIC
• Level 1
• CPU, constructed from digital logic gates
• System bus
• Memory
• Implemented using bipolar transistors
28
Download