Pergunta

I'm using HLA, and don't understand this instruction:

shl( 5, ax )

I'd like detail on what this instruction is doing.

Foi útil?

Solução

This instruction means that the number in ax will be bit shifted left by 5 bits and filled with zero:

    Before the shift:  ax = 1111 1111 1111 1111 b
     After the shift:  ax = 1111 1111 1110 0000 b

In arithmetic terms it means multiplying ax by 2^5=32 because one shift is equal to multiplying by 2.

Also, if you want to learn assembly language, don't use HLA. Use FASM or NASM instead. This way you will get much more help from the community.

Outras dicas

well, shift is actually just like multiplication

if you are shifting left 1 time, you are multiplying by 2

which means that:

 mov eax, 5
 mov ebx, 2
 mul ebx

is the same as:

     mov eax, 5
     shl eax, 1

Got it?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top