SlideShare ist ein Scribd-Unternehmen logo
1 von 35
WELCOME TO COSC3025
What to expect:
 Microprocessor Architecture, interrupt,
interfacing …
 Assembly language Concept
Fundamentals
Data Transfer in Memory and Registers
How conditional and Loop Works
Assembly for MP programming
Assembly for OS programming (inline Assembly)
C compiler
Procedure, Macro, Array, String (???)
COURSE LOGISTICS
Course Material:
https://elearning.ju.edu.et/course/view.
php?id=262
Blog:
https://csassembly.weebly.com/
Telegram Group
https://t.me/joinchat/UaLxVm2SWZ7N1
I70
Others
WHAT IS A MICROPROCESSOR?
A circuit of transistors and other electrical
components on a chip that can process
programs, remember information, or
perform calculations.
The heart of every CPU
Requires programmed input
Advantages over a customized digital
circuit
Cost
Scalable
Single design – multiple
use
© Intel Corp.
DESIGN OBJECTIVES OF MP
Maximize Performance
 Speed of operation: How quickly an operation can be completed
 Throughput: No of operations completed in unit time, not necessarily
the same as speed, consider Servers.
Maximize Productivity
 Interface provided must be easy
Be one step ahead of market needs and two steps
ahead of competition
DRAMATIC PROGRESS OVER THE YEARS
© Intel 4004 Processor
 Introduced in 1971
 2300 Transistors
 108 KHz Clock
© Intel P4 Processor
 Introduced in 2000
 42,000,000 Transistors
 1.5 GHz Clock (Initial)
DESIGN CONSTRAINT
Power consumed
 Today’s processors consume a peak power of 100 W, which means a
peak current of nearly 80A.
Area
Cost
Backward compatibility
 Windows running on Intel P3 Processor should run on Intel P4 too.
Time taken to design the processor should not be
very large or else the competitor may get ahead
Other factors like security, scalability, reliability also
need to be considered in processor design
MARKET
Desktop
 Processor for desktop computers. Cost, backward compatibility are very
important. Eg: Intel Pentium, AMD Athlon
Servers
 Processor for applications requiring huge amount of computation, data
handling like web servers, database servers, scientific computation
servers. In general, multiple processors are used. Throughput is a very
important metric for servers in general. Eg: Google servers, vsnlproxy
Embedded
 For applications in electronic appliances, robots, cars, mobiles etc. Power
consumption, cost are very important metrics. Eg: Microcontrollers like
8051, PIC, specifically designed processors for cars, mobiles etc.
STRUCTURE
The processor is a computing unit which needs to
interact with memory for getting instructions as
well as data
Processor
Instruction
Memory
Data
Memory
Address
(PC)
Instruction
Address
(reg)
Data
(loads)
Data
(stores)
INTERNAL STRUCTURE OF THE PROCESSOR
Control Unit
 Fetches instructions from memory, Interprets them, Controls ALU
ALU
 Does all computations
Register File
 Stores variables
Data
Address
ALU
(Calculator)
Register File
Data
Control Unit
Instr
Control
Flags
PC
Data
Out
Data
In
Instr
In
Inst
Address
r1
r2
r3
r4
EVOLUTION OF MP
Intel Microprocessor History
Intel 8086, 80286
IA-32 processor family
P6 processor family
CISC and RISC
EARLY
•Intel 8080
–64K addressable RAM
–8-bit registers
–CP/M operating system
–S-100 BUS architecture
–8-inch floppy disks!
•Intel 8086/8088
–IBM-PC Used 8088
–1 MB addressable RAM
–16-bit registers
–16-bit data bus (8-bit for 8088)
–separate floating-point unit (8087)
THE IBM-AT
•Intel 80286
–16 MB addressable RAM
–Protected memory
–several times faster than 8086
–introduced IDE bus architecture
–80287 floating point unit
INTEL IA-32 FAMILY
•Intel386
–4 GB addressable RAM, 32-bit registers,
paging (virtual memory)
•Intel486
–instruction pipelining
•Pentium
–superscalar, 32-bit address bus, 64-bit
internal data path
64-BIT PROCESSORS
•Intel64
–64-bit linear address
–Intel: Pentium Extreme, Xeon, Celeron D,
PendiumD, Core 2, and Core i7
•IA-32e Mode
–Compatibility mode for legacy 16-and 32-bit
applications
–64-bit Mode uses 64-bit addresses and operands
INTEL PROCESSOR FAMILIES
Currently Used:
Pentium & Celeron –dual core
Core 2 Duo -2 processor cores
Core 2 Quad -4 processor cores
Core i7 –4 processor cores
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
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
COMPILER AND ASSEMBLER
DEMO
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
Instruction Address Machine Code Assembly Instruction
0005 B8 0001 MOV AX, 1
0008 B8 0002 MOV AX, 2
000B B8 0003 MOV AX, 3
000E B8 0004 MOV AX, 4
0011 BB 0001 MOV BX, 1
0014 B9 0001 MOV CX, 1
0017 BA 0001 MOV DX, 1
001A 8B C3 MOV AX, BX
001C 8B C1 MOV AX, CX
001E 8B C2 MOV AX, DX
0020 83 C0 01 ADD AX, 1
0023 83 C0 02 ADD AX, 2
0026 03 C3 ADD AX, BX
0028 03 C1 ADD AX, CX
002A 03 06 0000 ADD AX, i
002E 83 E8 01 SUB AX, 1
0031 2B C3 SUB AX, BX
0033 05 1234 ADD AX, 1234h
TRANSLATING LANGUAGES
English: D is assigned the sum of A times B plus 10.
High-Level Language: D = A * B + 10
Intel Assembly Language:
mov eax, A
mul B
add eax, 10
mov D, eax
Intel Machine Language:
A1 00404000
F7 25 00404004
83 C0 0A
A3 00404008
A statement in a high-level language is translated
typically into several machine-level instructions
ADVANTAGES OF HIGH-LEVEL LANGUAGES
Program development is faster
High-level statements: fewer instructions to code
Program maintenance is easier
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
VIRTUAL MACHINE CONCEPT
An effective way to explain how a computer’s hardware
and software are related is called the virtual machine
concept.
A computer can usually execute programs written in its
native machine language. Each instruction in this
language is simple enough to be executed using a
relatively small number of electronic circuits. For
simplicity, we will call this language L0.
Programmers would have a difficult time writing
programs in L0 because it is enormously detailed
and consists purely of numbers. If a new language,
L1 , could be constructed that was easier to use,
programs could be written in L1. There are two ways
to achieve this:
Interpretation:
As the L1 program is running, each of its
instructions could be decoded and executed
by a program written in language L0. The L1
program begins running immediately, but
each instruction has to be decoded before it
can execute.
Translation:
The entire L1 program could be converted into
an L0 program by an L0 program specifically
designed for this purpose. Then the resulting
L0 program could be executed directly on the
computer hardware.
Virtual Machines
Rather than using only languages, it is easier
to think in terms of a hypothetical computer,
or virtual machine , at each level. we can
define a virtual machine as a software
program that emulates the functions of some
other physical or virtual computer.
The virtual machine VM1 , can execute
commands written in language L1. The
virtual machine VM0 can execute commands
written in language L0.
Each virtual machine can be constructed of
either hardware or software.
WHY LEARN ASSEMBLY LANGUAGE?
Two main reasons:
 Accessibility to system hardware
 To use space and time efficiently
Some application of assembly languages
are:
Real time system. E.g Traffic control system
Embedded system. Where there is no
compiler. E.g Micro chips.
Operating system. Specially kernel part of
operating system. Where direct access of
hard ware is necessary.
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
 MASM (Macro Assembler from Microsoft)
LINKER AND LINK LIBRARIES
You need a linker program to produce
executable files
It combines your program's object file
created by the assembler with other
object files and link libraries, and
produces a single executable program
LINK32.EXE is the linker program
provided with the MASM distribution
for linking 32-bit programs
ASSEMBLE AND LINK PROCESS
Source
File
Source
File
Source
File
Assembler
Object
File
Assembler
Object
File
Assembler
Object
File
Linker
Executable
File
Link
Libraries
A project may consist of multiple source files
Assembler translates each source file separately into an object file
Linker links all object files together with link libraries
Locally:
 MASM
 NASM
 TASM
EMULATOR:
 Emu8086
 Online
Online:(NASM)
 Tutorial Point
Assembler
 JDOODLE
 My-Compiler
WHERE WE CAN WRITE ASSEMBLY
NUMBER SYSTEMS
Decimal
(D)
Binary (B) Hexadecimal
(H or X)
Zero 0 0 0
Nine 9 1001 9
Ten 10 1010 A
Eleven 11 1011 B
Twelve 12 1100 C
Thirteen 13 1101 D
Fourteen 14 1110 E
Fifteen (Largest 4 bit no.) 15 1111 F
Forty Two 42 0010 1010 2A
Largest 8 bit no. 255 1111 1111 FF
Largest 16 bit no. 65535 1111 1111 1111 1111 FF FF

Weitere ähnliche Inhalte

Ähnlich wie Assembly chapter One.pptx

Introduction To Computer and Java
Introduction To Computer and JavaIntroduction To Computer and Java
Introduction To Computer and Java
PRN USM
 

Ähnlich wie Assembly chapter One.pptx (20)

VTU University Micro Controllers-06ES42 lecturer Notes
VTU University Micro Controllers-06ES42 lecturer NotesVTU University Micro Controllers-06ES42 lecturer Notes
VTU University Micro Controllers-06ES42 lecturer Notes
 
Pre requisite of COA- for Micro controller Embedded systems
Pre requisite of COA- for Micro controller Embedded systemsPre requisite of COA- for Micro controller Embedded systems
Pre requisite of COA- for Micro controller Embedded systems
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Mp &mc programs
Mp &mc programsMp &mc programs
Mp &mc programs
 
Assembly language
Assembly languageAssembly language
Assembly language
 
An introduction to digital signal processors 1
An introduction to digital signal processors 1An introduction to digital signal processors 1
An introduction to digital signal processors 1
 
Introduction
IntroductionIntroduction
Introduction
 
Machine Level Language
Machine Level LanguageMachine Level Language
Machine Level Language
 
Embedded Systems
Embedded SystemsEmbedded Systems
Embedded Systems
 
1 Intro To Micro P
1 Intro To Micro P1 Intro To Micro P
1 Intro To Micro P
 
Introduction To Computer and Java
Introduction To Computer and JavaIntroduction To Computer and Java
Introduction To Computer and Java
 
C with lab
C with labC with lab
C with lab
 
Microprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.pptMicroprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.ppt
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
 
RISC Vs CISC, Harvard v/s Van Neumann
RISC Vs CISC, Harvard v/s Van NeumannRISC Vs CISC, Harvard v/s Van Neumann
RISC Vs CISC, Harvard v/s Van Neumann
 
Microprocessor fundamentals
Microprocessor fundamentalsMicroprocessor fundamentals
Microprocessor fundamentals
 
CISY 105 Chapter 1
CISY 105 Chapter 1CISY 105 Chapter 1
CISY 105 Chapter 1
 
Enee114 01
Enee114 01Enee114 01
Enee114 01
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Assembly chapter One.pptx

  • 1. WELCOME TO COSC3025 What to expect:  Microprocessor Architecture, interrupt, interfacing …  Assembly language Concept Fundamentals Data Transfer in Memory and Registers How conditional and Loop Works Assembly for MP programming Assembly for OS programming (inline Assembly) C compiler Procedure, Macro, Array, String (???)
  • 3.
  • 4. WHAT IS A MICROPROCESSOR? A circuit of transistors and other electrical components on a chip that can process programs, remember information, or perform calculations. The heart of every CPU Requires programmed input Advantages over a customized digital circuit Cost Scalable Single design – multiple use © Intel Corp.
  • 5. DESIGN OBJECTIVES OF MP Maximize Performance  Speed of operation: How quickly an operation can be completed  Throughput: No of operations completed in unit time, not necessarily the same as speed, consider Servers. Maximize Productivity  Interface provided must be easy Be one step ahead of market needs and two steps ahead of competition
  • 6. DRAMATIC PROGRESS OVER THE YEARS © Intel 4004 Processor  Introduced in 1971  2300 Transistors  108 KHz Clock © Intel P4 Processor  Introduced in 2000  42,000,000 Transistors  1.5 GHz Clock (Initial)
  • 7. DESIGN CONSTRAINT Power consumed  Today’s processors consume a peak power of 100 W, which means a peak current of nearly 80A. Area Cost Backward compatibility  Windows running on Intel P3 Processor should run on Intel P4 too. Time taken to design the processor should not be very large or else the competitor may get ahead Other factors like security, scalability, reliability also need to be considered in processor design
  • 8. MARKET Desktop  Processor for desktop computers. Cost, backward compatibility are very important. Eg: Intel Pentium, AMD Athlon Servers  Processor for applications requiring huge amount of computation, data handling like web servers, database servers, scientific computation servers. In general, multiple processors are used. Throughput is a very important metric for servers in general. Eg: Google servers, vsnlproxy Embedded  For applications in electronic appliances, robots, cars, mobiles etc. Power consumption, cost are very important metrics. Eg: Microcontrollers like 8051, PIC, specifically designed processors for cars, mobiles etc.
  • 9. STRUCTURE The processor is a computing unit which needs to interact with memory for getting instructions as well as data Processor Instruction Memory Data Memory Address (PC) Instruction Address (reg) Data (loads) Data (stores)
  • 10. INTERNAL STRUCTURE OF THE PROCESSOR Control Unit  Fetches instructions from memory, Interprets them, Controls ALU ALU  Does all computations Register File  Stores variables Data Address ALU (Calculator) Register File Data Control Unit Instr Control Flags PC Data Out Data In Instr In Inst Address r1 r2 r3 r4
  • 11. EVOLUTION OF MP Intel Microprocessor History Intel 8086, 80286 IA-32 processor family P6 processor family CISC and RISC
  • 12. EARLY •Intel 8080 –64K addressable RAM –8-bit registers –CP/M operating system –S-100 BUS architecture –8-inch floppy disks! •Intel 8086/8088 –IBM-PC Used 8088 –1 MB addressable RAM –16-bit registers –16-bit data bus (8-bit for 8088) –separate floating-point unit (8087)
  • 13. THE IBM-AT •Intel 80286 –16 MB addressable RAM –Protected memory –several times faster than 8086 –introduced IDE bus architecture –80287 floating point unit
  • 14. INTEL IA-32 FAMILY •Intel386 –4 GB addressable RAM, 32-bit registers, paging (virtual memory) •Intel486 –instruction pipelining •Pentium –superscalar, 32-bit address bus, 64-bit internal data path
  • 15. 64-BIT PROCESSORS •Intel64 –64-bit linear address –Intel: Pentium Extreme, Xeon, Celeron D, PendiumD, Core 2, and Core i7 •IA-32e Mode –Compatibility mode for legacy 16-and 32-bit applications –64-bit Mode uses 64-bit addresses and operands
  • 16. INTEL PROCESSOR FAMILIES Currently Used: Pentium & Celeron –dual core Core 2 Duo -2 processor cores Core 2 Quad -4 processor cores Core i7 –4 processor cores
  • 17. A HIERARCHY OF LANGUAGES
  • 18. ASSEMBLY AND MACHINE LANGUAGE Machine language Native to a processor: executed directly by hardware Instructions consist of binary code: 1s and 0s Assembly language 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
  • 20. DEMO
  • 21. 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.
  • 22. 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.
  • 23. ASSEMBLY VS. MACHINE CODE Instruction Address Machine Code Assembly Instruction 0005 B8 0001 MOV AX, 1 0008 B8 0002 MOV AX, 2 000B B8 0003 MOV AX, 3 000E B8 0004 MOV AX, 4 0011 BB 0001 MOV BX, 1 0014 B9 0001 MOV CX, 1 0017 BA 0001 MOV DX, 1 001A 8B C3 MOV AX, BX 001C 8B C1 MOV AX, CX 001E 8B C2 MOV AX, DX 0020 83 C0 01 ADD AX, 1 0023 83 C0 02 ADD AX, 2 0026 03 C3 ADD AX, BX 0028 03 C1 ADD AX, CX 002A 03 06 0000 ADD AX, i 002E 83 E8 01 SUB AX, 1 0031 2B C3 SUB AX, BX 0033 05 1234 ADD AX, 1234h
  • 24. TRANSLATING LANGUAGES English: D is assigned the sum of A times B plus 10. High-Level Language: D = A * B + 10 Intel Assembly Language: mov eax, A mul B add eax, 10 mov D, eax Intel Machine Language: A1 00404000 F7 25 00404004 83 C0 0A A3 00404008 A statement in a high-level language is translated typically into several machine-level instructions
  • 25. ADVANTAGES OF HIGH-LEVEL LANGUAGES Program development is faster High-level statements: fewer instructions to code Program maintenance is easier 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
  • 26. VIRTUAL MACHINE CONCEPT An effective way to explain how a computer’s hardware and software are related is called the virtual machine concept. A computer can usually execute programs written in its native machine language. Each instruction in this language is simple enough to be executed using a relatively small number of electronic circuits. For simplicity, we will call this language L0. Programmers would have a difficult time writing programs in L0 because it is enormously detailed and consists purely of numbers. If a new language, L1 , could be constructed that was easier to use, programs could be written in L1. There are two ways to achieve this:
  • 27. Interpretation: As the L1 program is running, each of its instructions could be decoded and executed by a program written in language L0. The L1 program begins running immediately, but each instruction has to be decoded before it can execute. Translation: The entire L1 program could be converted into an L0 program by an L0 program specifically designed for this purpose. Then the resulting L0 program could be executed directly on the computer hardware.
  • 28. Virtual Machines Rather than using only languages, it is easier to think in terms of a hypothetical computer, or virtual machine , at each level. we can define a virtual machine as a software program that emulates the functions of some other physical or virtual computer. The virtual machine VM1 , can execute commands written in language L1. The virtual machine VM0 can execute commands written in language L0. Each virtual machine can be constructed of either hardware or software.
  • 29.
  • 30. WHY LEARN ASSEMBLY LANGUAGE? Two main reasons:  Accessibility to system hardware  To use space and time efficiently Some application of assembly languages are: Real time system. E.g Traffic control system Embedded system. Where there is no compiler. E.g Micro chips. Operating system. Specially kernel part of operating system. Where direct access of hard ware is necessary.
  • 31. 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  MASM (Macro Assembler from Microsoft)
  • 32. LINKER AND LINK LIBRARIES You need a linker program to produce executable files It combines your program's object file created by the assembler with other object files and link libraries, and produces a single executable program LINK32.EXE is the linker program provided with the MASM distribution for linking 32-bit programs
  • 33. ASSEMBLE AND LINK PROCESS Source File Source File Source File Assembler Object File Assembler Object File Assembler Object File Linker Executable File Link Libraries A project may consist of multiple source files Assembler translates each source file separately into an object file Linker links all object files together with link libraries
  • 34. Locally:  MASM  NASM  TASM EMULATOR:  Emu8086  Online Online:(NASM)  Tutorial Point Assembler  JDOODLE  My-Compiler WHERE WE CAN WRITE ASSEMBLY
  • 35. NUMBER SYSTEMS Decimal (D) Binary (B) Hexadecimal (H or X) Zero 0 0 0 Nine 9 1001 9 Ten 10 1010 A Eleven 11 1011 B Twelve 12 1100 C Thirteen 13 1101 D Fourteen 14 1110 E Fifteen (Largest 4 bit no.) 15 1111 F Forty Two 42 0010 1010 2A Largest 8 bit no. 255 1111 1111 FF Largest 16 bit no. 65535 1111 1111 1111 1111 FF FF