SlideShare a Scribd company logo
1 of 22
PROGRAMMING
CONCEPTS-IV
CHAPTER 5
 We all know that the processor we use is connected to
the I/O as well as the memory
 So far, we have only discussed with data being read from
and written to memory
 Even though we have used the I/O devices like the
keyboard and monitor, but for these we used DOS
interrupts, which are functions already written
 Lets try for interacting the I/O directly using the
instructions of 8086
 In practice, I/O devices are not connected directly to the
processor but are connected through interfacing chips
which provides control signals for the processor to
communicate with the peripheral.
INTRODUCTION
INPUT/ OUTPUT PROGRAMMING
 There are many I/O devices connected to the processor,
using which data is taken in (input device) or data is given
out (output device)
 For I/O processing, there appears the concept of a ‘Port’,
which means a register or storage area for data, from/to
which the data is transferred to the processor
 An I/O device is frequently referred to as a ‘port’ with an
associated address.
 Any I/O device has a unique address, known as ‘port
address’ or simply mentioned as ‘port.
I/O ports with address bus and data bus and the read and write control
signals
 Figure shows an input and output device connected tot
he processor through the address and data bus & a
control pin.
 When its address is placed on the address bus and the
WR signal is activated, data from the processor is written
to the output port
 Similarly, data from the input port is read into the
processor when the input port is addressed and the RD
signal is activated
 There are two schemes for connecting an I/O device to the
processor
 Memory Mapped I/O :
 In this scheme, the I/O device has the same address
space and addressing scheme as memory.
 For example, given the instruction MOV AL, [3456H], the
address 3456H may be a memory location or the address
of an I/O device.
 So I/O addressing does not need any special instructions.
 Peripheral or Isolated I/O:
 Also referred to as ‘I/O mapped I/O’ .
 Here, there are special instructions catering to input and
output devices
 The address space is disjoint and separate from the
memory address space. (Detail in Chapter 7)
I/O INSTRUCTIONS
 8086 has two instructions to communicate:
 IN :
 usage: IN accumulator, port
 This is the case when data is taken from the I/O device
 It implies the device is an input device
 using this instruction, an I/O read machine cycle is initiated
and the data in the input device is transferred to the
accumulator of the processor
 OUT :
 usage: OUT port, accumulator
 here the data is given to an output device from the
accumulator with the initiation of an I/O write machine cycle
THINGS TO REMEMBER
 In both cases, ‘port’ implies the port address, i.e the
address of the I/O device
 The source has always to be the ‘Accumulator’
 Means the AL register if an 8-bit data is being transferred
of AX register if a 16-bit register is used
 No other register may be used
 I/O addresses are limited to a maximum bit size of 16 bits.
 Hence, there can be a maximum of 2 ports
 Thus, there can be 2 input and 2 output ports, as the
instruction used for input and output is different.
16
16 16
TWO FORMATS FOR I/O INSTRUCTIONS
 1. Fixed Port Addressing :
 This is used only when the address of an I/O device is 8
bits wide
 Here the address of the port is directly mentioned in the
instruction.
 Note that data can be 8 bits or 16 bits, depending on
the data bus width of the I/O device.
 Example:
IN AL, 45H ;move 8-bit data into AL from an input
port with address 45H
IN AX, 12H ;
OUT 34H, AL ; move 8-bit data from AL to an output
port with address 34H
OUT 0FCH, AX ;
 2. Variable Port Addressing:
 This is used when the addressed port has a 16-bit
address.
 Here, the port address is to be loaded into DX and then
only the I/O instruction can be used.
 Only the DX register can be used for this.
 Examples
 Mov DX, 9876H ; load the address of the port in DX
IN AL, DX ; move 8-bit data into AL from an input port
whose address is in DX
 Mov DX, 0FC6H
OUT DX, AX
Consider an Example:
An 8086 is connected to two ports with 8-bit addresses.
The address of the input port is 67H and the address of
the output port is FEH. The input port sends a 16-bit data
to the processor. Only the lower 12 bits are to be
transferred to the output port. Write the relevant program
lines for this.
SOLUTION
IN AX, 67H
AND AX, 0FFFH
OUT 0FEH, AX
MODULAR PROGRAMMING
 Suppose to handle large programming problem
 Its better to think of breaking it up into modules
 then testing the individual modules separately
 later they can be integrated to obtain a complete product.
 Its useful to access some written modules to incorporate in
new program
 It also helps for various team work on different modules
 All these indicate the importance of what we would term as
“ Modular Programming”
 In assembly programming the module concept can be
used to write bigger assembly
 Here different assembly files are tested individually and
have to be linked together
 There are many issues to be resolved for successful
linking and execution:
 i. The different modules that constitute the solution may be
in different code segments.
 ii. The data which is to be used by one module may have
to be accessed by many different modules and the
‘permission’ for this must be indicated.
 iii. Some labels used in a module may not be found
therein. In that case, there must be some indication that
these are defined in some other module to which linking is
possible and will be done.
 MASM has certain directives which are used in our program
in order to resolve these issues
1. THE DIRECTIVE PUBLIC
 When a data item or a procedure is to be allowed to be
accessed by other modules, it is declared as PUBLIC .
 Examples:
PUBLIC num1, num2, num3
 This may also be declared as
PUBLIC num1
PUBLIC num2
PUBLIC num3
 A procedure named MULT can be allowed access from
other modules if it is declared as
PUBLIC mult
 When a module needs to use data and code which have
been defined elsewhere, it should use the directive
EXTRN meaning that the labels being used in this
module are external to the module.
 Format
EXTRN name1
EXTRN name1:type, name2:type
 Examples
EXTRN num1:byte
EXTRN num2:word,num3 : word
EXTRN multi :far ;a far procedure is declared
2. THE DIRECTIVE EXTRN
RUNNING TWO MODULES MODA.ASM AND MODB.ASM
CONTD..
ASSEMBLING THE TWO MODULES
 The modules can be assembled and linked together
using ml.exe.
 The command is
ml filename1.asm fi lename2.asm filename3.asm …
 To see the output of the program
ml moda.asm modb.asm
I/O Programming Concepts in 8086
I/O Programming Concepts in 8086
I/O Programming Concepts in 8086

More Related Content

What's hot

Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Urvashi Singh
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design FileArchita Misra
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language BasicsEducation Front
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formatsMazin Alwaaly
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marksvvcetit
 
Addressing mode
Addressing modeAddressing mode
Addressing modeilakkiya
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)Selomon birhane
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modesBilal Amjad
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programmingKartik Sharma
 
Ec 252 ec-252-l10-instruction sets and addressing modes
Ec 252 ec-252-l10-instruction sets and addressing modesEc 252 ec-252-l10-instruction sets and addressing modes
Ec 252 ec-252-l10-instruction sets and addressing modesbhshmuec
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)bolovv
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 

What's hot (20)

ADDRESSING MODE
ADDRESSING MODEADDRESSING MODE
ADDRESSING MODE
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086
 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design File
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Code generation
Code generationCode generation
Code generation
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marks
 
Addressing mode
Addressing modeAddressing mode
Addressing mode
 
Co&al lecture-07
Co&al lecture-07Co&al lecture-07
Co&al lecture-07
 
Co&al lecture-05
Co&al lecture-05Co&al lecture-05
Co&al lecture-05
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)
 
Co&al lecture-08
Co&al lecture-08Co&al lecture-08
Co&al lecture-08
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 
Ec 252 ec-252-l10-instruction sets and addressing modes
Ec 252 ec-252-l10-instruction sets and addressing modesEc 252 ec-252-l10-instruction sets and addressing modes
Ec 252 ec-252-l10-instruction sets and addressing modes
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
 
Compiler unit 4
Compiler unit 4Compiler unit 4
Compiler unit 4
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 

Similar to I/O Programming Concepts in 8086

The primary purpose of memory interfacing is to facilitate the transfer of da...
The primary purpose of memory interfacing is to facilitate the transfer of da...The primary purpose of memory interfacing is to facilitate the transfer of da...
The primary purpose of memory interfacing is to facilitate the transfer of da...Sindhu Mani
 
Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdfHimanshuPant41
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085ShivamSood22
 
Module 2 instruction set
Module 2 instruction set Module 2 instruction set
Module 2 instruction set Deepak John
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction setStefan Oprea
 
19. io interfacing i
19. io interfacing i19. io interfacing i
19. io interfacing isandip das
 
lecture 2 coal assembly language lecture
lecture 2 coal assembly language lecturelecture 2 coal assembly language lecture
lecture 2 coal assembly language lecturezm745236
 
Microcontroller directives
Microcontroller directivesMicrocontroller directives
Microcontroller directivesManoj Harsule
 
Microprocessor (1)
Microprocessor (1)Microprocessor (1)
Microprocessor (1)Muhd Azlan
 
3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptx3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptxMdAsaduzzaman257266
 
ITEC582-Chapter 12.pptx
ITEC582-Chapter 12.pptxITEC582-Chapter 12.pptx
ITEC582-Chapter 12.pptxSabaNaeem26
 
Microprocessor and microcontroller (MPMC).pdf
Microprocessor and microcontroller (MPMC).pdfMicroprocessor and microcontroller (MPMC).pdf
Microprocessor and microcontroller (MPMC).pdfXyzjakhaAbhuvs
 
Xcs 234 microprocessors
Xcs 234 microprocessorsXcs 234 microprocessors
Xcs 234 microprocessorssweta suman
 
Microprocessor 8085
Microprocessor 8085Microprocessor 8085
Microprocessor 8085Dhaval Barot
 

Similar to I/O Programming Concepts in 8086 (20)

The primary purpose of memory interfacing is to facilitate the transfer of da...
The primary purpose of memory interfacing is to facilitate the transfer of da...The primary purpose of memory interfacing is to facilitate the transfer of da...
The primary purpose of memory interfacing is to facilitate the transfer of da...
 
Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdf
 
Micro overview
Micro overviewMicro overview
Micro overview
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
Module 2 instruction set
Module 2 instruction set Module 2 instruction set
Module 2 instruction set
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
19. io interfacing i
19. io interfacing i19. io interfacing i
19. io interfacing i
 
lecture 2 coal assembly language lecture
lecture 2 coal assembly language lecturelecture 2 coal assembly language lecture
lecture 2 coal assembly language lecture
 
Microcontroller directives
Microcontroller directivesMicrocontroller directives
Microcontroller directives
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Microprocessor (1)
Microprocessor (1)Microprocessor (1)
Microprocessor (1)
 
3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptx3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptx
 
Pdemodule 4
Pdemodule 4Pdemodule 4
Pdemodule 4
 
Qb microprocessors
Qb microprocessorsQb microprocessors
Qb microprocessors
 
ITEC582-Chapter 12.pptx
ITEC582-Chapter 12.pptxITEC582-Chapter 12.pptx
ITEC582-Chapter 12.pptx
 
Microprocessor and microcontroller (MPMC).pdf
Microprocessor and microcontroller (MPMC).pdfMicroprocessor and microcontroller (MPMC).pdf
Microprocessor and microcontroller (MPMC).pdf
 
lecture1423813120.pdf
lecture1423813120.pdflecture1423813120.pdf
lecture1423813120.pdf
 
Xcs 234 microprocessors
Xcs 234 microprocessorsXcs 234 microprocessors
Xcs 234 microprocessors
 
Microprocessor 8085
Microprocessor 8085Microprocessor 8085
Microprocessor 8085
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 

More from SHREEHARI WADAWADAGI

More from SHREEHARI WADAWADAGI (15)

Chapter 15 software product metrics
Chapter 15 software product metricsChapter 15 software product metrics
Chapter 15 software product metrics
 
Chapter 14 software testing techniques
Chapter 14 software testing techniquesChapter 14 software testing techniques
Chapter 14 software testing techniques
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategies
 
Chapter 12 user interface design
Chapter 12 user interface designChapter 12 user interface design
Chapter 12 user interface design
 
Chapter 21 project management concepts
Chapter 21 project management conceptsChapter 21 project management concepts
Chapter 21 project management concepts
 
Ch 11-component-level-design
Ch 11-component-level-designCh 11-component-level-design
Ch 11-component-level-design
 
Ch 9-design-engineering
Ch 9-design-engineeringCh 9-design-engineering
Ch 9-design-engineering
 
An introduction to software engineering
An introduction to software engineeringAn introduction to software engineering
An introduction to software engineering
 
Architectural design
Architectural designArchitectural design
Architectural design
 
Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086
 
Brief description of all the interupts
Brief description of all the interuptsBrief description of all the interupts
Brief description of all the interupts
 
Chapter 7 memory & i/o
Chapter 7  memory & i/oChapter 7  memory & i/o
Chapter 7 memory & i/o
 
Chapter 6 hardware structure of 8086
Chapter 6  hardware structure of 8086Chapter 6  hardware structure of 8086
Chapter 6 hardware structure of 8086
 
Arm processor
Arm processorArm processor
Arm processor
 
8086 complete guide
8086 complete guide 8086 complete guide
8086 complete guide
 

Recently uploaded

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 

Recently uploaded (20)

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 

I/O Programming Concepts in 8086

  • 2.  We all know that the processor we use is connected to the I/O as well as the memory  So far, we have only discussed with data being read from and written to memory  Even though we have used the I/O devices like the keyboard and monitor, but for these we used DOS interrupts, which are functions already written  Lets try for interacting the I/O directly using the instructions of 8086  In practice, I/O devices are not connected directly to the processor but are connected through interfacing chips which provides control signals for the processor to communicate with the peripheral. INTRODUCTION
  • 3. INPUT/ OUTPUT PROGRAMMING  There are many I/O devices connected to the processor, using which data is taken in (input device) or data is given out (output device)  For I/O processing, there appears the concept of a ‘Port’, which means a register or storage area for data, from/to which the data is transferred to the processor  An I/O device is frequently referred to as a ‘port’ with an associated address.  Any I/O device has a unique address, known as ‘port address’ or simply mentioned as ‘port.
  • 4. I/O ports with address bus and data bus and the read and write control signals
  • 5.  Figure shows an input and output device connected tot he processor through the address and data bus & a control pin.  When its address is placed on the address bus and the WR signal is activated, data from the processor is written to the output port  Similarly, data from the input port is read into the processor when the input port is addressed and the RD signal is activated
  • 6.  There are two schemes for connecting an I/O device to the processor  Memory Mapped I/O :  In this scheme, the I/O device has the same address space and addressing scheme as memory.  For example, given the instruction MOV AL, [3456H], the address 3456H may be a memory location or the address of an I/O device.  So I/O addressing does not need any special instructions.  Peripheral or Isolated I/O:  Also referred to as ‘I/O mapped I/O’ .  Here, there are special instructions catering to input and output devices  The address space is disjoint and separate from the memory address space. (Detail in Chapter 7)
  • 7. I/O INSTRUCTIONS  8086 has two instructions to communicate:  IN :  usage: IN accumulator, port  This is the case when data is taken from the I/O device  It implies the device is an input device  using this instruction, an I/O read machine cycle is initiated and the data in the input device is transferred to the accumulator of the processor  OUT :  usage: OUT port, accumulator  here the data is given to an output device from the accumulator with the initiation of an I/O write machine cycle
  • 8. THINGS TO REMEMBER  In both cases, ‘port’ implies the port address, i.e the address of the I/O device  The source has always to be the ‘Accumulator’  Means the AL register if an 8-bit data is being transferred of AX register if a 16-bit register is used  No other register may be used  I/O addresses are limited to a maximum bit size of 16 bits.  Hence, there can be a maximum of 2 ports  Thus, there can be 2 input and 2 output ports, as the instruction used for input and output is different. 16 16 16
  • 9. TWO FORMATS FOR I/O INSTRUCTIONS  1. Fixed Port Addressing :  This is used only when the address of an I/O device is 8 bits wide  Here the address of the port is directly mentioned in the instruction.  Note that data can be 8 bits or 16 bits, depending on the data bus width of the I/O device.  Example: IN AL, 45H ;move 8-bit data into AL from an input port with address 45H IN AX, 12H ; OUT 34H, AL ; move 8-bit data from AL to an output port with address 34H OUT 0FCH, AX ;
  • 10.  2. Variable Port Addressing:  This is used when the addressed port has a 16-bit address.  Here, the port address is to be loaded into DX and then only the I/O instruction can be used.  Only the DX register can be used for this.  Examples  Mov DX, 9876H ; load the address of the port in DX IN AL, DX ; move 8-bit data into AL from an input port whose address is in DX  Mov DX, 0FC6H OUT DX, AX
  • 11. Consider an Example: An 8086 is connected to two ports with 8-bit addresses. The address of the input port is 67H and the address of the output port is FEH. The input port sends a 16-bit data to the processor. Only the lower 12 bits are to be transferred to the output port. Write the relevant program lines for this.
  • 12. SOLUTION IN AX, 67H AND AX, 0FFFH OUT 0FEH, AX
  • 13. MODULAR PROGRAMMING  Suppose to handle large programming problem  Its better to think of breaking it up into modules  then testing the individual modules separately  later they can be integrated to obtain a complete product.  Its useful to access some written modules to incorporate in new program  It also helps for various team work on different modules  All these indicate the importance of what we would term as “ Modular Programming”  In assembly programming the module concept can be used to write bigger assembly  Here different assembly files are tested individually and have to be linked together
  • 14.  There are many issues to be resolved for successful linking and execution:  i. The different modules that constitute the solution may be in different code segments.  ii. The data which is to be used by one module may have to be accessed by many different modules and the ‘permission’ for this must be indicated.  iii. Some labels used in a module may not be found therein. In that case, there must be some indication that these are defined in some other module to which linking is possible and will be done.  MASM has certain directives which are used in our program in order to resolve these issues
  • 15. 1. THE DIRECTIVE PUBLIC  When a data item or a procedure is to be allowed to be accessed by other modules, it is declared as PUBLIC .  Examples: PUBLIC num1, num2, num3  This may also be declared as PUBLIC num1 PUBLIC num2 PUBLIC num3  A procedure named MULT can be allowed access from other modules if it is declared as PUBLIC mult
  • 16.  When a module needs to use data and code which have been defined elsewhere, it should use the directive EXTRN meaning that the labels being used in this module are external to the module.  Format EXTRN name1 EXTRN name1:type, name2:type  Examples EXTRN num1:byte EXTRN num2:word,num3 : word EXTRN multi :far ;a far procedure is declared 2. THE DIRECTIVE EXTRN
  • 17. RUNNING TWO MODULES MODA.ASM AND MODB.ASM
  • 19. ASSEMBLING THE TWO MODULES  The modules can be assembled and linked together using ml.exe.  The command is ml filename1.asm fi lename2.asm filename3.asm …  To see the output of the program ml moda.asm modb.asm