So I have this array:
fib BYTE 9, 123, 92, 0, 0, 0, 0
And I'm wanting to be able to access the different elements of the array and move them, individually, into a register.
I've noticed so far that I can, for example, do this:
mov al, fib + 2
to move the 3rd elements value, 92, into the al register.
However, if I try to do this:
mov ah, 2
mov al, fib + ah
so that I can change the value of ah and thus change the element that I am moving into al, the assembler says that the second line is an "invalid use of a register"
So my question is, is there any way that I can rewrite that second line in a way that would allow me to access the value of the element in the fib array that is offset, from the beginning, by the value that is stored in ah?
Edit:
I am writing this code in Visual Studio on Windows 10. The target platform is x86. The entire source code is:
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode: DWORD
.data
fib BYTE 9, 123, 92, 0, 0, 0, 0
.code
main PROC
mov bx, 2
mov al, [fib + bx]
INVOKE ExitProcess, 0
main ENDP
END main
There's really not much to it considering this is just my attempt at learning more about arrays in assembly language