home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,092 of 2,978   
   Marco van de Voort to Jim Leonard   
   Re: Multi-dimensional array access via i   
   20 Mar 06 08:33:58   
   
   From: marcov@stack.nl   
      
   On 2006-03-20, Jim Leonard  wrote:   
   > var   
   >   precalc:array[0..maxx-1,0..maxy-1] of word;   
   >   
   > (...fill the array...)   
   >   
   > asm {lookup values for index "x,y" and stick in ax}   
   >   mov bx,x   
   >   shl bx,1   
   >   mov si,y   
   >   shl si,1   
   >   mov ax,[offset precalc+bx+si]   
   > end;   
   >   
   > I'm missing something obvious; can anyone help?   
      
   Always try to write something in pascal notation for your assembler. Then   
   you'll se that what you did is roughly equal to precalc[x+y] not   
   precalc[x][y]   
      
   Try something that looks more like precalc[x*maxy+y]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca