title: x86 assembly: Irvine32 - Get last element of an array
body: <p>I'm new to Assembly, I need help with an assignment in Assembly Language Irvine32. I want to know where I'm going wrong. I believe my code is 80% right but there's something I'm not seeing or recognizing. Here's the program details. </p>
  
  <p>"Write an assembly language program that has an array of words. The program loads the last element of the array into an appropriately sized register and prints it. (Do not hardcode the index of the last element.)"</p>
  
  <pre><code>INCLUDE Irvine32.inc    
  .data
    val1 word 1,2,3,4,5,6
    val2 = ($-val1)/2
  .code
  main PROC        
    mov ax, 0
    mov ax, val1[val2]
  
    Call WriteDec
    Call DumpRegs
   exit
  main ENDP
  END main
  </code></pre>