Re: Inline Assembly

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



a wrote:
> Why does my stosb line crash with Access Violation?

StringWorked is an uninitialized local variable that points nowhere. When
your stosb writes to *StringWorked, you're getting an access violation.

Presumably you mean to do some kind of transform on the string while copying
it to a new location, so the first thing you need to do is allocate memory
for the new string, not just a pointer to the new string.

On your inline assembly:

1. You don't have to push/pop modified registers. The compiler will do it
for you.
2. Your code:

lea esi, SomeVariable
lodsd
mov edi.eax

is just a longer, slower, less clear way of writing

mov edi, SomeVariable

Unless you're doing something that involves shifts that span byte
boundaries, it's unlikely that your inline asm will be faster than simply
writing this code in C or C++, and it'll be less portable and a lot less
clear.

-cd


.



Relevant Pages

  • Re: Fortran-compiled DLLs in Python
    ... WindowsError: exception: access violation ... > I do not know how fortran passes this parameter, ... strings may pass a "string descriptor", ...
    (comp.lang.python)
  • Re: Way around error?
    ... The code works if the string is allocated from the ... attempted to convert a const value to a non-const pointer. ... >I get the access violation at the first attempt to modify the string. ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: Getting rid of access violation message
    ... A better solution is to correct the problem rather than kill the messenger, ... set the Reg_Sz string value ... Windows Server 2003 or later) so that if a program produces an access violation, that the AV will not be shown, i.e. the program just ends without an error dialog being shown? ...
    (microsoft.public.windows.server.general)
  • AnsiString on Heap.
    ... AnsiString is inside the form. ... If no string is assigned to it it will still give an access violation making ...
    (alt.comp.lang.borland-delphi)
  • Re: Inline Assembly
    ... > your stosb writes to *StringWorked, you're getting an access violation. ... > allocate memory for the new string, not just a pointer to the new string. ... > mov edi, SomeVariable ...
    (microsoft.public.vc.language)