I am writing NASM assembly code, and have to do some indexed addressing. I have the index stored in $al, but x86 won't let you use $al as an index register, and I'm already using $bl, so I cant use $bx. So I need to put the byte I have in $al into a 32-but register such as $ecx, however, when I try, it throws an invalid combination of opcode and operand error. Is there any way to do this?
sub al, 97 ; char - 97
push ecx ; b/c al cant be used as indexing register
mov ecx, al ; move byte in al into ecx
mov bl, [table + ecx] ; value_at(first_table_addr + char) -> bx
pop ecx
See Question&Answers more detail:os