SlideShare a Scribd company logo
2
Most read
8
Most read
19
Most read
Introduction to 8086 Assembly
Language
   Assembly Language Programming
                     University of Akron
                       Dr. Tim Margush
Program Statements
name operation operand(s) comment
• Operation is a predefined or reserved word
   › mnemonic - symbolic operation code
   › directive - pseudo-operation code
• Space or tab separates initial fields
• Comments begin with semicolon
• Most assemblers are not case sensitive

10/21/12       Dr. Tim Margush - Assembly Language Program
                                        2
Program Data and Storage
• Pseudo-ops to define       • These directives
  data or reserve storage      require one or more
   ›   DB - byte(s)            operands
   ›   DW - word(s)              › define memory
   ›   DD - doubleword(s)          contents
   ›   DQ - quadword(s)          › specify amount of
   ›                               storage to reserve for
       DT - tenbyte(s)
                                   run-time data



10/21/12           Dr. Tim Margush - Assembly Language Program
                                            3
Defining Data
• Numeric data values        • A list of values may be
   ›   100 - decimal           used - the following
   ›   100B - binary           creates 4 consecutive
   ›   100H - hexadecimal      words
   ›   '100' - ASCII             DW 40CH,10B,-13,0
   ›   "100" - ASCII         • A ? represents an
• Use the appropriate          uninitialized storage
  DEFINE directive             location
  (byte, word, etc.)             DB 255,?,-128,'X'

10/21/12           Dr. Tim Margush - Assembly Language Program
                                            4
Naming Storage Locations
• Names can be              • ANum refers to a byte
  associated with             storage location,
  storage locations           initialized to FCh
   ANum DB -4               • The next word has no
    DW 17                     associated name
   ONE
                            • ONE and UNO refer
   UNO DW 1
   X DD ?                     to the same word
• These names are called    • X is an unitialized
  variables                   doubleword
10/21/12          Dr. Tim Margush - Assembly Language Program
                                           5
Arrays
• Any consecutive storage locations of the
  same size can be called an array
  X DW 40CH,10B,-13,0
  Y DB 'This is an array'
  Z DD -109236, FFFFFFFFH, -1, 100B
• Components of X are at X, X+2, X+4, X+8
• Components of Y are at Y, Y+1, …, Y+15
• Components of Z are at Z, Z+4, Z+8, Z+12
10/21/12      Dr. Tim Margush - Assembly Language Program
                                       6
DUP
• Allows a sequence of storage locations to
  be defined or reserved
• Only used as an operand of a define
  directive
DB   40 DUP (?)
DW   10h DUP (0)
DB   3 dup ("ABC")
db   4 dup(3 dup (0,1), 2 dup('$'))
10/21/12      Dr. Tim Margush - Assembly Language Program
                                       7
Word Storage
• Word, doubleword, and quadword data are
  stored in reverse byte order (in memory)
Directive            Bytes in Storage
DW 256               00 01
DD 1234567H          67 45 23 01
DQ 10                0A 00 00 00 00 00 00 00
X DW 35DAh           DA 35
   Low byte of X is at X, high byte of X is at X+1

10/21/12          Dr. Tim Margush - Assembly Language Program
                                           8
Named Constants
• Symbolic names associated with storage locations
  represent addresses
• Named constants are symbols created to represent
  specific values determined by an expression
• Named constants can be numeric or string
• Some named constants can be redefined
• No storage is allocated for these values


10/21/12        Dr. Tim Margush - Assembly Language Program
                                         9
Equal Sign Directive
• name = expression
   › expression must be numeric
   › these symbols may be redefined at any time
   maxint = 7FFFh
   count = 1
   DW count
   count = count * 2
   DW count

10/21/12        Dr. Tim Margush - Assembly Language Program
                                         10
EQU Directive
• name EQU expression
   › expression can be string or numeric
   › Use < and > to specify a string EQU
   › these symbols cannot be redefined later in the
     program
   sample EQU 7Fh
   aString EQU <1.234>
   message EQU <This is a message>
10/21/12         Dr. Tim Margush - Assembly Language Program
                                          11
Data Transfer Instructions
• MOV target, source          • reg can be any non-
   ›   reg, reg                 segment register
   ›   mem, reg                 except IP cannot be
   ›   reg, mem                 the target register
   ›   mem, immed             • MOV's between a
   ›   reg, immed               segment register and
• Sizes of both operands        memory or a 16-bit
  must be the same              register are possible


10/21/12            Dr. Tim Margush - Assembly Language Program
                                             12
Sample MOV Instructions
b db 4Fh       • When a variable is created with a
w dw 2048        define directive, it is assigned a
                 default size attribute (byte, word,
mov   bl,dh      etc)
mov   ax,w     • You can assign a size attribute
mov   ch,b       using LABEL
mov   al,255      LoByte LABEL BYTE
mov   w,-100      aWord DW 97F2h
mov   b,0

10/21/12        Dr. Tim Margush - Assembly Language Program
                                         13
Addresses with Displacements
b db 4Fh, 20h, 3Ch            • The assembler
w dw 2048, -100, 0              computes an address
                                based on the
mov bx, w+2                     expression
mov b+1, ah                   • NOTE: These are address
mov ah, b+5                     computations done at
mov dx, w-3                     assembly time
                                   MOV ax, b-1
• Type checking is still in
                                will not subtract 1 from
  effect                        the value stored at b

10/21/12            Dr. Tim Margush - Assembly Language Program
                                             14
eXCHanGe
• XCHG target, source     • This provides an
   › reg, reg               efficient means to
   › reg, mem               swap the operands
   › mem, reg                 › No temporary storage
• MOV and XCHG                  is needed
                              › Sorting often requires
  cannot perform
                                this type of operation
  memory to memory
                              › This works only with
  moves                         the general registers


10/21/12        Dr. Tim Margush - Assembly Language Program
                                         15
Arithmetic Instructions
ADD dest, source          • source can be a
SUB dest, source            general register,
INC dest                    memory location, or
                            constant
DEC dest
                          • dest can be a register
NEG dest                    or memory location
• Operands must be of         › except operands cannot
  the same size                 both be memory


10/21/12        Dr. Tim Margush - Assembly Language Program
                                         16
Program Segment Structure
• Data Segments               • Stack Segment
   › Storage for variables      › used to set aside
   › Variable addresses are       storage for the stack
     computed as offsets        › Stack addresses are
     from start of this           computed as offsets
     segment                      into this segment
• Code Segment                • Segment directives
   › contains executable        .data
     instructions               .code
                                .stack size

10/21/12          Dr. Tim Margush - Assembly Language Program
                                           17
Memory Models
• .Model memory_model
   ›   tiny: code+data <= 64K (.com program)
   ›   small: code<=64K, data<=64K, one of each
   ›   medium: data<=64K, one data segment
   ›   compact: code<=64K, one code segment
   ›   large: multiple code and data segments
   ›   huge: allows individual arrays to exceed 64K
   ›   flat: no segments, 32-bit addresses, protected
       mode only (80386 and higher)
10/21/12           Dr. Tim Margush - Assembly Language Program
                                            18
Program Skeleton
.model small         •   Select a memory model
.stack 100H          •   Define the stack size
.data                •   Declare variables
  ;declarations      •   Write code
.code                    › organize into procedures
main proc            • Mark the end of the
  ;code                source file
main endp                › optionally, define the
  ;other procs             entry point
end main
10/21/12     Dr. Tim Margush - Assembly Language Program
                                      19

More Related Content

PPTX
Subroutine
PoojaChoudhary313113
 
PPTX
Stacks & subroutines 1
deval patel
 
PPT
Architecture of 8086 Microprocessor
Mustapha Fatty
 
PPTX
Direct memory access (dma)
Zubair Khalid
 
PPTX
Instruction set of 8086
9840596838
 
PPTX
INTERRUPTS OF 8086 MICROPROCESSOR
Gurudev joshi
 
PPTX
Status register
Pradeep Kumar TS
 
PPTX
Addressing modes of 8086
Dr. AISHWARYA N
 
Stacks & subroutines 1
deval patel
 
Architecture of 8086 Microprocessor
Mustapha Fatty
 
Direct memory access (dma)
Zubair Khalid
 
Instruction set of 8086
9840596838
 
INTERRUPTS OF 8086 MICROPROCESSOR
Gurudev joshi
 
Status register
Pradeep Kumar TS
 
Addressing modes of 8086
Dr. AISHWARYA N
 

What's hot (20)

PPTX
3.programmable interrupt controller 8259
MdFazleRabbi18
 
PDF
8085 microprocessor ramesh gaonkar
SAQUIB AHMAD
 
PPTX
Accessing I/O Devices
Slideshare
 
PPTX
8086 microprocessor-architecture
prasadpawaskar
 
DOCX
8086 pin diagram description
Akhil Singal
 
PPTX
Lecture 3 instruction set
Pradeep Kumar TS
 
PPTX
Microprocessor 8086 instructions
Ravi Anand
 
PPTX
Minimum mode and Maximum mode Configuration in 8086
Jismy .K.Jose
 
PPT
Memory & I/O interfacing
deval patel
 
PPTX
Serial Communication in 8051
Sudhanshu Janwadkar
 
PPTX
Interrupts
Albin Panakkal
 
PPTX
8051 timer counter
vishalgohel12195
 
PPTX
Interfacing with peripherals: analog to digital converters and digital to ana...
NimeshSingh27
 
PPT
Programming with 8085
Shehrevar Davierwala
 
PPTX
8085 MICROPROCESSOR ARCHITECTURE AND ITS OPERATIONS
RamaPrabha24
 
PPTX
Interrupts of 8086
Albin Panakkal
 
PDF
Typical Embedded System
anand hd
 
PPT
8251 universal synchronous asynchronous receiver transmitter
ShivangiSharma879191
 
PPT
8086-instruction-set-ppt
jemimajerome
 
PDF
Instruction formats-in-8086
MNM Jain Engineering College
 
3.programmable interrupt controller 8259
MdFazleRabbi18
 
8085 microprocessor ramesh gaonkar
SAQUIB AHMAD
 
Accessing I/O Devices
Slideshare
 
8086 microprocessor-architecture
prasadpawaskar
 
8086 pin diagram description
Akhil Singal
 
Lecture 3 instruction set
Pradeep Kumar TS
 
Microprocessor 8086 instructions
Ravi Anand
 
Minimum mode and Maximum mode Configuration in 8086
Jismy .K.Jose
 
Memory & I/O interfacing
deval patel
 
Serial Communication in 8051
Sudhanshu Janwadkar
 
Interrupts
Albin Panakkal
 
8051 timer counter
vishalgohel12195
 
Interfacing with peripherals: analog to digital converters and digital to ana...
NimeshSingh27
 
Programming with 8085
Shehrevar Davierwala
 
8085 MICROPROCESSOR ARCHITECTURE AND ITS OPERATIONS
RamaPrabha24
 
Interrupts of 8086
Albin Panakkal
 
Typical Embedded System
anand hd
 
8251 universal synchronous asynchronous receiver transmitter
ShivangiSharma879191
 
8086-instruction-set-ppt
jemimajerome
 
Instruction formats-in-8086
MNM Jain Engineering College
 
Ad

Similar to 8086 assembly language (20)

PPTX
Assembly 8086
Mustafa Salah
 
PPTX
CHAPTER 4and answer equation and cf.pptx
BerentoYasin
 
PPT
8051assembly language
Hisham Mat Hussin
 
PPT
Assembler Language Tutorial for Mainframe Programmers
Srinimf-Slides
 
PPTX
Introduction to Assembly Language & various basic things
ishitasabrincse
 
PDF
Assembly language 8086
John Cutajar
 
PPT
Wk1to4
raymondmy08
 
PPT
Instruction set of 8086
Tirumalesh Nizampatnam
 
PDF
Assembly language 8086 intermediate
John Cutajar
 
PPT
12 mt06ped008
vijaydeepakg
 
PDF
Alp 05
Murali Krishna
 
PDF
Alp 05
gswapnil86
 
PPT
Al2ed chapter4
Abdullelah Al-Fahad
 
PDF
Assembler directives and basic steps ALP of 8086
Urvashi Singh
 
PPTX
6 assembly language computer organization
wewiv47743
 
PPT
chap3lec5.pptgfhgfhghghgfhgfhgfhfghgfhfg
YumnaShahzaad
 
PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
PPT
data transfers, addressing and arithmetic
YumnaShahzaad
 
Assembly 8086
Mustafa Salah
 
CHAPTER 4and answer equation and cf.pptx
BerentoYasin
 
8051assembly language
Hisham Mat Hussin
 
Assembler Language Tutorial for Mainframe Programmers
Srinimf-Slides
 
Introduction to Assembly Language & various basic things
ishitasabrincse
 
Assembly language 8086
John Cutajar
 
Wk1to4
raymondmy08
 
Instruction set of 8086
Tirumalesh Nizampatnam
 
Assembly language 8086 intermediate
John Cutajar
 
12 mt06ped008
vijaydeepakg
 
Alp 05
gswapnil86
 
Al2ed chapter4
Abdullelah Al-Fahad
 
Assembler directives and basic steps ALP of 8086
Urvashi Singh
 
6 assembly language computer organization
wewiv47743
 
chap3lec5.pptgfhgfhghghgfhgfhgfhfghgfhfg
YumnaShahzaad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
data transfers, addressing and arithmetic
YumnaShahzaad
 
Ad

More from Mir Majid (20)

DOC
Use case diagrams
Mir Majid
 
PPT
Dfd and flowchart
Mir Majid
 
DOC
.Net framework interview questions
Mir Majid
 
DOC
My sql technical reference manual
Mir Majid
 
PDF
Dotnet basics
Mir Majid
 
DOC
Holographic memory
Mir Majid
 
PPT
Data recovery
Mir Majid
 
RTF
Simulation programs
Mir Majid
 
PDF
Router bridge
Mir Majid
 
PPT
Compiler Design
Mir Majid
 
PPT
Assembler
Mir Majid
 
PPS
Lessons from life_2
Mir Majid
 
PPS
Child faces 2
Mir Majid
 
PPS
Time management
Mir Majid
 
PPS
Lest weforget
Mir Majid
 
PPT
E hospital manager
Mir Majid
 
PPT
Crypt
Mir Majid
 
PPT
Smart cards
Mir Majid
 
PPT
Rfid
Mir Majid
 
DOC
Rfid seminar
Mir Majid
 
Use case diagrams
Mir Majid
 
Dfd and flowchart
Mir Majid
 
.Net framework interview questions
Mir Majid
 
My sql technical reference manual
Mir Majid
 
Dotnet basics
Mir Majid
 
Holographic memory
Mir Majid
 
Data recovery
Mir Majid
 
Simulation programs
Mir Majid
 
Router bridge
Mir Majid
 
Compiler Design
Mir Majid
 
Assembler
Mir Majid
 
Lessons from life_2
Mir Majid
 
Child faces 2
Mir Majid
 
Time management
Mir Majid
 
Lest weforget
Mir Majid
 
E hospital manager
Mir Majid
 
Crypt
Mir Majid
 
Smart cards
Mir Majid
 
Rfid seminar
Mir Majid
 

8086 assembly language

  • 1. Introduction to 8086 Assembly Language Assembly Language Programming University of Akron Dr. Tim Margush
  • 2. Program Statements name operation operand(s) comment • Operation is a predefined or reserved word › mnemonic - symbolic operation code › directive - pseudo-operation code • Space or tab separates initial fields • Comments begin with semicolon • Most assemblers are not case sensitive 10/21/12 Dr. Tim Margush - Assembly Language Program 2
  • 3. Program Data and Storage • Pseudo-ops to define • These directives data or reserve storage require one or more › DB - byte(s) operands › DW - word(s) › define memory › DD - doubleword(s) contents › DQ - quadword(s) › specify amount of › storage to reserve for DT - tenbyte(s) run-time data 10/21/12 Dr. Tim Margush - Assembly Language Program 3
  • 4. Defining Data • Numeric data values • A list of values may be › 100 - decimal used - the following › 100B - binary creates 4 consecutive › 100H - hexadecimal words › '100' - ASCII DW 40CH,10B,-13,0 › "100" - ASCII • A ? represents an • Use the appropriate uninitialized storage DEFINE directive location (byte, word, etc.) DB 255,?,-128,'X' 10/21/12 Dr. Tim Margush - Assembly Language Program 4
  • 5. Naming Storage Locations • Names can be • ANum refers to a byte associated with storage location, storage locations initialized to FCh ANum DB -4 • The next word has no DW 17 associated name ONE • ONE and UNO refer UNO DW 1 X DD ? to the same word • These names are called • X is an unitialized variables doubleword 10/21/12 Dr. Tim Margush - Assembly Language Program 5
  • 6. Arrays • Any consecutive storage locations of the same size can be called an array X DW 40CH,10B,-13,0 Y DB 'This is an array' Z DD -109236, FFFFFFFFH, -1, 100B • Components of X are at X, X+2, X+4, X+8 • Components of Y are at Y, Y+1, …, Y+15 • Components of Z are at Z, Z+4, Z+8, Z+12 10/21/12 Dr. Tim Margush - Assembly Language Program 6
  • 7. DUP • Allows a sequence of storage locations to be defined or reserved • Only used as an operand of a define directive DB 40 DUP (?) DW 10h DUP (0) DB 3 dup ("ABC") db 4 dup(3 dup (0,1), 2 dup('$')) 10/21/12 Dr. Tim Margush - Assembly Language Program 7
  • 8. Word Storage • Word, doubleword, and quadword data are stored in reverse byte order (in memory) Directive Bytes in Storage DW 256 00 01 DD 1234567H 67 45 23 01 DQ 10 0A 00 00 00 00 00 00 00 X DW 35DAh DA 35 Low byte of X is at X, high byte of X is at X+1 10/21/12 Dr. Tim Margush - Assembly Language Program 8
  • 9. Named Constants • Symbolic names associated with storage locations represent addresses • Named constants are symbols created to represent specific values determined by an expression • Named constants can be numeric or string • Some named constants can be redefined • No storage is allocated for these values 10/21/12 Dr. Tim Margush - Assembly Language Program 9
  • 10. Equal Sign Directive • name = expression › expression must be numeric › these symbols may be redefined at any time maxint = 7FFFh count = 1 DW count count = count * 2 DW count 10/21/12 Dr. Tim Margush - Assembly Language Program 10
  • 11. EQU Directive • name EQU expression › expression can be string or numeric › Use < and > to specify a string EQU › these symbols cannot be redefined later in the program sample EQU 7Fh aString EQU <1.234> message EQU <This is a message> 10/21/12 Dr. Tim Margush - Assembly Language Program 11
  • 12. Data Transfer Instructions • MOV target, source • reg can be any non- › reg, reg segment register › mem, reg except IP cannot be › reg, mem the target register › mem, immed • MOV's between a › reg, immed segment register and • Sizes of both operands memory or a 16-bit must be the same register are possible 10/21/12 Dr. Tim Margush - Assembly Language Program 12
  • 13. Sample MOV Instructions b db 4Fh • When a variable is created with a w dw 2048 define directive, it is assigned a default size attribute (byte, word, mov bl,dh etc) mov ax,w • You can assign a size attribute mov ch,b using LABEL mov al,255 LoByte LABEL BYTE mov w,-100 aWord DW 97F2h mov b,0 10/21/12 Dr. Tim Margush - Assembly Language Program 13
  • 14. Addresses with Displacements b db 4Fh, 20h, 3Ch • The assembler w dw 2048, -100, 0 computes an address based on the mov bx, w+2 expression mov b+1, ah • NOTE: These are address mov ah, b+5 computations done at mov dx, w-3 assembly time MOV ax, b-1 • Type checking is still in will not subtract 1 from effect the value stored at b 10/21/12 Dr. Tim Margush - Assembly Language Program 14
  • 15. eXCHanGe • XCHG target, source • This provides an › reg, reg efficient means to › reg, mem swap the operands › mem, reg › No temporary storage • MOV and XCHG is needed › Sorting often requires cannot perform this type of operation memory to memory › This works only with moves the general registers 10/21/12 Dr. Tim Margush - Assembly Language Program 15
  • 16. Arithmetic Instructions ADD dest, source • source can be a SUB dest, source general register, INC dest memory location, or constant DEC dest • dest can be a register NEG dest or memory location • Operands must be of › except operands cannot the same size both be memory 10/21/12 Dr. Tim Margush - Assembly Language Program 16
  • 17. Program Segment Structure • Data Segments • Stack Segment › Storage for variables › used to set aside › Variable addresses are storage for the stack computed as offsets › Stack addresses are from start of this computed as offsets segment into this segment • Code Segment • Segment directives › contains executable .data instructions .code .stack size 10/21/12 Dr. Tim Margush - Assembly Language Program 17
  • 18. Memory Models • .Model memory_model › tiny: code+data <= 64K (.com program) › small: code<=64K, data<=64K, one of each › medium: data<=64K, one data segment › compact: code<=64K, one code segment › large: multiple code and data segments › huge: allows individual arrays to exceed 64K › flat: no segments, 32-bit addresses, protected mode only (80386 and higher) 10/21/12 Dr. Tim Margush - Assembly Language Program 18
  • 19. Program Skeleton .model small • Select a memory model .stack 100H • Define the stack size .data • Declare variables ;declarations • Write code .code › organize into procedures main proc • Mark the end of the ;code source file main endp › optionally, define the ;other procs entry point end main 10/21/12 Dr. Tim Margush - Assembly Language Program 19