Re: Inline Assembly
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Fri, 21 Oct 2005 07:43:18 -0700
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
.
- Follow-Ups:
- Re: Inline Assembly
- From: Scherbina Vladimir
- Re: Inline Assembly
- From: z
- Re: Inline Assembly
- References:
- Inline Assembly
- From: a
- Inline Assembly
- Prev by Date: CListBox::CompareItem
- Next by Date: Re: C2783 in VS 6.0 but not in VS.NET 2003
- Previous by thread: Inline Assembly
- Next by thread: Re: Inline Assembly
- Index(es):
Relevant Pages
|