flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > MSVC inline assembly

Author
Thread Post new topic Reply to topic
bcdsys



Joined: 04 Aug 2008
Posts: 41
bcdsys 26 Oct 2008, 04:00
I have c code and in it I have character array and IMAGE_SECTION_HEADER struct and need copy first 8 bytes from struct to char array. Tried in c but can't get stupid useless type casts to work! Tried inline asm, but it has different syntax to fasm and can't get pointer to char array. Can anyone help? Also, is there anything in c that I can just move memory around without stupid compiler errors?
Post 26 Oct 2008, 04:00
View user's profile Send private message Reply with quote
bcdsys



Joined: 04 Aug 2008
Posts: 41
bcdsys 26 Oct 2008, 04:04
here is asm code tested
Code:
__asm {
           mov esi, section_header
             mov edi, section_name_ptr
           mov ecx, 2
          cld
         rep movsd
   }
    


c code version:
Code:
section_name[0] = ((DWORD*) &section_header)[0];
section_name[4] = ((DWORD*) &section_header)[1];
    


asm version not compile, c code compile but incorrect result, verified cause this line
can anyone help?
Post 26 Oct 2008, 04:04
View user's profile Send private message Reply with quote
Kain



Joined: 26 Oct 2003
Posts: 108
Kain 26 Oct 2008, 06:12
Have you checked your indexing? Maybe it should be section_name[1]

For the asm part, it looks like you're moving the address of the pointer variable (section_name_ptr) into edi rather than the address of section_name which should be the contents of the section_name_ptr. You probably need to dereference the dword at edi.
Post 26 Oct 2008, 06:12
View user's profile Send private message Reply with quote
bcdsys



Joined: 04 Aug 2008
Posts: 41
bcdsys 26 Oct 2008, 12:35
problem fixed
used:
Code:
((DWORD*) section_name)[0] = ((DWORD*) &section_header)[0];
((DWORD*) section_name)[1] = ((DWORD*) &section_header)[1];
    
Post 26 Oct 2008, 12:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.