Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    whatup777+'s Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    246
    Reputation
    11
    Thanks
    15
    Quote Originally Posted by mmbob View Post
    memcpy is (at least with Visual Studio) an optimized assembly function. Hand written assembly will nearly always be faster than C++, unless the assembly coder has no idea what he is doing. I believe memcpy copies in DWORD chunks also, which would make it much faster than a for loop.
    Nigga knows shit.

  2. #17
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Then may I suggest inline assembly using the "mov" assembly statement

  3. #18
    Gordon`'s Avatar
    Join Date
    Dec 2007
    Gender
    male
    Posts
    283
    Reputation
    24
    Thanks
    325
    Quote Originally Posted by Departure View Post
    Then may I suggest inline assembly using the "mov" assembly statement
    you can only copy/write 1, 2 or 4 bytes with mov.

    Code:
    mov byte ptr [address], al
    mov word ptr [address], ax
    mov dword ptr [address], eax
    Last edited by Gordon`; 02-09-2011 at 09:34 PM.


  4. #19
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Yes true Gordon, if you do a straight mov... Look at example below to explain what I mean using REP MOVSB

    Code:
    procedure CopyMemory(Destination, Source:Pointer; dwSize:LongWord);
    asm
      PUSH ECX
      PUSH ESI
      PUSH EDI
      MOV EDI, Destination
      MOV ESI, Source
      MOV ECX, dwSize
      REP MOVSB
      POP EDI
      POP ESI
      POP ECX
    end;

    All we do here is use MOVSB which will mov bytes from address in ESI to address in EDI, this will repeat using the REP statement Untill ECX = 0 allowing us to use any amount of bytes.

    Reference
    https://faydoc.tripod.com/cpu/movsb.htm
    Last edited by Departure; 02-10-2011 at 01:55 AM.

  5. The Following User Says Thank You to Departure For This Useful Post:

    Xlilzoosk8rX (02-10-2011)

Page 2 of 2 FirstFirst 12