I am having some trouble using local arrays.
whenever i try some code like this:

myproc proc
LOCAL array[10]:BYTE
mov bx,0
mov al,array
myproc endp

i get a "multiple base registers not allowed" error
this is probably because LOCAL variables are offsets from BP, so having BX as well creates 2 base registers. The problem is that all the solutions i have found look like

add array,bl
mov al,
sub array,bl

which is 3 instructions instead of 1-not very efficient.
how are you SUPPOSED to use register offsets in LOCAL arrays?
Posted on 2001-12-01 17:55:38 by LOLTH
I just realized that that solution doesnt work at all!
Posted on 2001-12-01 18:17:55 by LOLTH
try replacing the BX with EBX, like this:

myproc proc
LOCAL array[10]:BYTE
mov ebx,0
mov al, array[ebx]
myproc endp

Posted on 2001-12-01 18:32:32 by savage
Then i get a "cannot mix 16- and 32-bit registers" error
its a dos exe anyway, so i want to stay away from 32-bit addressing modes, if that is an option
Posted on 2001-12-01 18:43:26 by LOLTH
try this one then, not sure if it works:

mov bx, 0
lea si, array
mov al, byte ptr
Posted on 2001-12-01 19:18:10 by savage
BP and BX are both considered "base" registers. Try using SI or DI ("Index" registers) instead of BX:

mov si,0
mov al,array

Posted on 2001-12-01 19:19:39 by S/390
What about:

myproc proc
LOCAL array[10]:BYTE
push bx
mov bx,0
mov al,array
pop bx
myproc endp

Maybe the trouble is because the constant change that then bx will suffer.
Posted on 2001-12-01 20:03:04 by CodeLover
that works prefectly
Posted on 2001-12-01 20:29:17 by LOLTH
Just wanted to point out that this is another "disadvantage" to the 16 bit instruction set. You could only use specific regs for certain parts of the address, like BP and BX as bases, and SI and DI as an index. The 32 bit set lets you use almost any combination, so is a valid 32 bit mode... :)
Posted on 2001-12-02 22:01:14 by S/390