Assembly Language for x86 Use DUP to allocate (create space for) an array or string Assembly language: data array BYTE 1000 DUP(?) code
Arrays ? Arrays in assembly language: ? The address of the first element of the array is used to store and access the elements of the array
Array • A list of values arranged sequentially in memory • Example: a list of telephone Expression a[4] refers to the 5th element of the array a
Arrays ? A list of elements all of same size (and type) ? Accessing array element ? starting address in memory ? element size ? index
Assembler Arrays Declaring an array An array is declared as shown below, with the values listed, separated by commas arr dword 5, 7, 19
Example : you've seen this in swap: •function that's supposed to swap the values of its arguments 8 Page 5
Code: ORG $6000 ; NOTE: this time the data is at the end LEA L DATA,A1 ; initialize array pointer BSR LEN ; branch to subroutine LEN
Machine code C x86 assembly programming Procedures stacks Arrays structs Memory caches Processes Virtual memory Memory allocaKon Java vs C
Assembly language: Machine code: 0111010000011000 100011010000010000000010 1000100111000010 110000011111101000011111 Computer system: OS: Memory data
Unlike high-level programming languages, assembly language has no special notion for an array An array is just a block of memory In fact, all data structures
A 2-dimensional array is made up of rows and columns In general for a 2D array of element-size S, the correct index value Assembly Language Program