Hi folks,
I'm going crazy, I've spent a couple of days banging my head against what should be a simple piece of asm code

HELP!
In Freebasic, I prepare the following array:
DIM SHARED PSINES(512) AS INTEGER
DIM I AS INTEGER
DIM RAD AS DOUBLE
FOR I=0 TO 512
RAD=(I*0.703125)*0.0174532
PSINES(I)=SIN(RAD)*511
NEXT
Now, unless I'm going nuts, this array now holds a sine table as signed integers.
I now want to grab four of those values and add them together in asm. So I prepare the following variables outside of my subroutine
DIM SHARED TPOS1 AS UINTEGER=0
DIM SHARED TPOS2 AS UINTEGER=0
DIM SHARED TPOS3 AS UINTEGER=0
DIM SHARED TPOS4 AS UINTEGER=0
These variables will hold values from 0-511.
I then prepare the following pointer in my routine
DIM PTRSINE AS INTEGER PTR
The appropriate piece of the asm code to add these numbers together is:
mov edi,[PTRSINE]
mov esi,[tpos1]
mov eax,[edi+esi]
mov ebx,eax
mov edi,[PTRSINE]
mov esi,[tpos2]
mov eax,[edi+esi]
add ebx,eax
mov edi,[PTRSINE]
mov esi,[tpos3]
mov eax,[edi+esi]
add ebx,eax
mov edi,[PTRSINE]
mov esi,[tpos4]
mov eax,[edi+esi]
add ebx,eax
I'm fairly sure that I'm doing something silly. I'm wondering if two's complement is killing me. I don't know how INTEGERS are stored and am assuming that it's the grabbing and adding of these numbers that is messing me around.
Then again, it could be the logic of my additions (I've gone through assorted variations, that's just the current version). I'm hoping it isn't down to particular registers being used for addition functions by default and I'm oblivious to registers that I'm using being overwritten by the calculations.
I'm going to keep at it, but any input/advice is really really welcome.