[ASM] Code explanation required

🚫
Exiled
Joined
Oct 24, 2005
Messages
268
Reaction score
0
Can you guys explain in detail what this code is doing besides shifting bytes to the left 3 times?

Code:
      asm
        push    edx
        mov     dl, [btch]
        rol     dl, 3
        mov     [btch], dl
        pop     edx
      end;
 
Thats all its doing nothing more? :)


{ asm
push edx
mov dl, [btch]
rol dl, 3
mov [btch], dl
pop edx
end; }
IS this the quivelent to this: btch := btch shl 3;

edit: it would be btch := btch shl 3 + 3; :)
 
Last edited:
Re: sage

No.

Rotate, not shift. See the Intel IA-32 programmer's reference manual volume II for more information.

Ok changed function to rotating but it kind of out puts the same.. any idea why the numbers off by 3 compared to delphi. Using vb6.
 
Re: sage

Wait, what?

Sorry, the asm is from a delphi function.. and I can't seem to figure out the appropriate function to cope for the asm in vb6.

function rol(Value : integer ; N : integer) : integer ;
var
val1:integer;
begin
val1:=8*sizeof(value);
Result := (Value shl N) or (Value shr (val1-N))
end ;

is what I'm using to ROL in delphi.. gives 64 for h and the asm function gives 67 any idea why?
 
I figured it out.. was due to me not using a byte to return the value. stupid me. :)
 
Back