SlideServe
Menu
Preferences
© SlideServe · v2026

Variable Storage

cachez avatar
12 slides · 284 Views · 120 likes · Sep 11, 2014

Variable Storage. Memory Locations (Logical) Stack Heap Program Code Register Variable Classes Automatic (locals) Parameters Globals. Variable Types. Scalars Arrays Structs Unions Objects ?. Row Major Array Storage. char A[20][15][10];. Column Major Array Storage.

Variable Storage - slide 1
01 / 12Variable Storage
1 / 17

Download Presentation

Variable Storage
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

More Related Content

Presentation Transcript
  1. Variable Storage Memory Locations (Logical) Stack Heap Program Code Register Variable Classes Automatic (locals) Parameters Globals

  2. Variable Types • Scalars • Arrays • Structs • Unions • Objects ?

  3. Row Major Array Storage char A[20][15][10];

  4. Column Major Array Storage char A[20][15][10];

  5. OR (Row Major) char A[20][15][10];

  6. Array Declaration Algorithm Dimension Node { int min; int max; int size; }

  7. Declaration Algorithm (2) • Doubly linked list of dimension nodes • Pass 1 – while parsing • Build linked list from left to right • Insert min, max • Size = size of an element • Append node to end of list • min = max = size = 1

  8. Declaration Algorithm (3)Pass 2 • Traverse list from tail to head • For each node, n, going “right” to “left” • Factor = n.max – n.min + 1 • For each node, m, right to left starting with n • m.size = m.size * factor • For each node, n, going left to right • N->right->max = max; N->right->min = min • Delete first element of list

  9. Array Declaration (Row Major) int weight[2000..2005][1..12][1..31]; list of “dimension” nodes int min, max, size size of element of this dimension 1448 124 4

  10. Array Offset (Row Major) Traverse list summing (max-min) * size int weight[2000..2005][1..12][1..31]; x = [2002][5][31] (2002-2000) * 1448 + (5-1) * 124 + (31-1) * 4 1448 124 4

  11. Your Turn • Assume • int A[10][20][30]; • Row major order • “Show” A’s dimension list • Show hypothetical 3-addr code for • X = A[2][3][4] ; • A[3][4][5] = 9

  12. Your Turn 2 • Assume • int A[10][20][30]; • Column major order • “Show” A’s dimension list • Show hypothetical 3-addr code for • X = A[2][3][4] ; • A[3][4][5] = 9