Arrays and Addressing Modes - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Arrays and Addressing Modes

Description:

... one or more of Base register, Index register, and Displacement ... This is the same as Register Indirect, except a displacement is added into the mixture ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 17
Provided by: timma87
Category:

less

Transcript and Presenter's Notes

Title: Arrays and Addressing Modes


1
Arrays and Addressing Modes
  • Assembly Language Programming
  • University of Akron
  • Dr. Tim Margush

2
What Is an Array?
  • Collection of components
  • All components are the same size
  • Components are located in consecutive storage
    locations
  • The base address of the array is the address of
    the first component
  • Components are numbered 0, 1, ...

3
Random Access
  • The address of any component (CA) can be
    determined from the base address (BA), component
    size (CS), and the component index (CI)
  • CA BA CI CS
  • Time to access any component is the same (does
    not depend on component index)
  • Contrast access in a linked list

4
Array Declarations
  • int_arry dw 10, 20, 30
  • byt_arry db 12,'a','xy',0FFh,-1
  • un_arry dd 25 dup (?)
  • zro_arry dw 10 dup (0)
  • spc_arry db 80 dup (" ")
  • The text says array components are numbered 1, 2,
    etc. Ignore this and use C conventions (0, 1, 2,
    )

5
8086 Addressing Modes
  • There are 24 different addressing modes!
  • Fortunately, they break down into a smaller
    number of distinctive categories
  • Addressing Mode means how the address information
    in the instruction is used to select a physical
    address
  • Common modes specify one or more of Base
    register, Index register, and Displacement

6
Direct Addressing
  • Instruction contains a displacement into a
    segment
  • Segment may be implied or specified using the
    segment override operator
  • mov ax,abc
  • mov cl,ss12
  • mov dl,es200

7
Register Indirect
  • Offset is contained in a register - it is a
    pointer to a memory location
  • BP, BX, SI, DI only
  • JMP and CALL allow any GP register to be used
  • The segment register is implied or may be
    specified

8
Register Indirect Examples
  • mov ax,bp
  • mov cl,ssbx
  • mov dl,essi
  • mov di,ax
  • DS is assumed for BX, SI, and DI
  • SS is assumed for BP

9
Base and Indexed Addressing
  • mov ax,numbersSI
  • mov cl,BP4
  • mov ES6DI,AX
  • This is the same as Register Indirect, except a
    displacement is added into the mixture
  • Based BP or BX are used
  • Indexed SI or DI are used

10
Base-Index Addressing
  • mov cl,BXSI
  • mov ax,numbersSIBP
  • mov ES6SIBX,dh
  • One base register and one index register
  • If a displacement is specified, the addressing
    mode is called Base-Index with Displacement

11
PTR and LABEL
  • Ambiguous size operands
  • Use PTR to resolve
  • mov bx,1
  • mov word ptr bx,1
  • mov si, 'A'
  • mov si,byte ptr 'A'
  • X label byte
  • M label word
  • DW 100
  • X and M refer to the same address
  • mov AH,X
  • mov AH,byte ptr M
  • mov AX,M

12
Summing Words In an Array
  • mov cx,10 number of words
  • mov ax,0 initialize total
  • lea bx,arry pointer to array
  • top uses register indirect
  • add ax,bx add next
  • add bx,2 point to next
  • loop top

13
Summing Them Again
  • mov cx,10 number of words
  • mov ax,0 initialize total
  • mov si,0 index into array
  • top uses indexed addressing
  • add ax,arrysi add next
  • add si,2 point to next
  • loop top

14
And Again
  • mov cx,10 number of words
  • mov ax,0 initialize total
  • lea bx,arry base of array
  • mov si,0 index into array
  • top base-index addressing
  • add ax,bxsi add next
  • add si,2 point to next
  • loop top

15
Access to the Stack
  • mov bp,sp BP points to stack top
  • mov ax,bp0 top of stack
  • mov bx,bp2 next to top of stack
  • mov bp3,ah byte at offset 3 in stack
  • mov bp-1,ch byte above top of stack

16
Homework
  • Pg 201
  • 1, 2, 3, 4 (b,c)
Write a Comment
User Comments (0)
About PowerShow.com