8086 assembly language
Upcoming SlideShare
Loading in...5

8086 assembly language






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

8086 assembly language 8086 assembly language Presentation Transcript

  • Introduction to 8086 AssemblyLanguage Assembly Language Programming University of Akron Dr. Tim Margush
  • Program Statementsname 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 sensitive10/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 data10/21/12 Dr. Tim Margush - Assembly Language Program 3 View slide
  • 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,X10/21/12 Dr. Tim Margush - Assembly Language Program 4 View slide
  • 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 doubleword10/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+1210/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 directiveDB 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 StorageDW 256 00 01DD 1234567H 67 45 23 01DQ 10 0A 00 00 00 00 00 00 00X DW 35DAh DA 35 Low byte of X is at X, high byte of X is at X+110/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 values10/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 count10/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 • MOVs between a › reg, immed segment register and• Sizes of both operands memory or a 16-bit must be the same register are possible10/21/12 Dr. Tim Margush - Assembly Language Program 12
  • Sample MOV Instructionsb db 4Fh • When a variable is created with aw 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 attributemov ch,b using LABELmov al,255 LoByte LABEL BYTEmov w,-100 aWord DW 97F2hmov b,010/21/12 Dr. Tim Margush - Assembly Language Program 13
  • Addresses with Displacementsb db 4Fh, 20h, 3Ch • The assemblerw dw 2048, -100, 0 computes an address based on themov bx, w+2 expressionmov b+1, ah • NOTE: These are addressmov ah, b+5 computations done atmov dx, w-3 assembly time MOV ax, b-1• Type checking is still in will not subtract 1 from effect the value stored at b10/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 registers10/21/12 Dr. Tim Margush - Assembly Language Program 15
  • Arithmetic InstructionsADD dest, source • source can be aSUB dest, source general register,INC dest memory location, or constantDEC dest • dest can be a registerNEG dest or memory location• Operands must be of › except operands cannot the same size both be memory10/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 size10/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 proceduresmain proc • Mark the end of the ;code source filemain endp › optionally, define the ;other procs entry pointend main10/21/12 Dr. Tim Margush - Assembly Language Program 19