From: Kyle Wilson on
I'm writing a program for a class mostly in assembler converted
originally from c-code. The problem I'm having is that whenever I make
a c-function call from within the inline assembler, I'm getting an
"Unhandled Exception" error. It goes something like this:

void getData( int* n, int* r )
{
char scanString[] = "%d %d";
_asm
{
push r;
push n;
lea ebx, scanString;
push ebx;
call scanf;
HERE> add esp,12;
}
}

"HERE>" marks where the exception occurs. "Unhandled exception at
0x004182c0 in Combinations and Permutations.exe: 0xC0000005: Access
violation writing location 0xe7430e45." According to more than one
guide I've found (including my professor's) this is exactly how it
should be. (in fact, he provided an example which I tried to run just
to see what would happen, and it also gave an unhandled exception
error "Unhandled exception at 0x004182bc in test.exe: 0xC000001E: An
attempt was made to execute an invalid lock sequence.") Any advice on
what could be causing this error would be much appreciated. Thanks.


--
Kyle Wilson
From: Jack Klein on
On Tue, 21 Mar 2006 09:04:21 -0800, Kyle Wilson
<ktwilson9999(a)NOSPAM.comcast.net> wrote in alt.comp.lang.learn.c-c++:

> I'm writing a program for a class mostly in assembler converted
> originally from c-code. The problem I'm having is that whenever I make
> a c-function call from within the inline assembler, I'm getting an
> "Unhandled Exception" error. It goes something like this:

The C language does not define or support inline assembly language in
any way, shape, or form. The C++ language, which is also discussed
here, allows for inline assembly language, but with a completely
different format than that used by your compiler. And even C++ takes
no responsibility for the proper use or results of inline assembly
language, that is entirely implementation specific.

> void getData( int* n, int* r )
> {
> char scanString[] = "%d %d";
> _asm
> {
> push r;
> push n;
> lea ebx, scanString;
> push ebx;
> call scanf;
> HERE> add esp,12;
> }
> }
>
> "HERE>" marks where the exception occurs. "Unhandled exception at
> 0x004182c0 in Combinations and Permutations.exe: 0xC0000005: Access
> violation writing location 0xe7430e45." According to more than one
> guide I've found (including my professor's) this is exactly how it
> should be. (in fact, he provided an example which I tried to run just
> to see what would happen, and it also gave an unhandled exception
> error "Unhandled exception at 0x004182bc in test.exe: 0xC000001E: An
> attempt was made to execute an invalid lock sequence.") Any advice on
> what could be causing this error would be much appreciated. Thanks.

What you have here is not a C or C++ language issue, but one that is
specific to your compiler and operating system, and perhaps your
assembler, if it gets involved.

You need to ask this in a group that supports your combination of
tools, perhaps news:comp.os.ms-windows.programmer.win32, or one of
Microsoft's support groups in the news:microsoft.public.* family. It
is off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
From: Zealot The Crazy Lui on
On Tue, 21 Mar 2006 16:12:08 -0600, Jack Klein <jackklein(a)spamcop.net>
wrote:
>The C language does not define or support inline assembly language in
>any way, shape, or form. The C++ language, which is also discussed
>here, allows for inline assembly language, but with a completely
>different format than that used by your compiler. And even C++ takes
>no responsibility for the proper use or results of inline assembly
>language, that is entirely implementation specific.

>What you have here is not a C or C++ language issue, but one that is
>specific to your compiler and operating system, and perhaps your
>assembler, if it gets involved.
>
>You need to ask this in a group that supports your combination of
>tools, perhaps news:comp.os.ms-windows.programmer.win32, or one of
>Microsoft's support groups in the news:microsoft.public.* family. It
>is off-topic here.

Got it. I wasn't sure if I was passing parameters correctly to the
scanf function (which is part of the c lang). I'll try one of those
other groups.

--
"No I'm saying that I'm a cow dung." - Stephen "Suupernuubie" Ung
"Eat a bag of hell." - Cyric The Mad
"I'm all for the girl on girl action, but it could put a strain on the marriage" - LTP

MSN:ktwilson86(a)hotmail.com (BUT DON'T SEND E-MAIL!) YIM: ktwilson AIM: YahooKyleW
Zealot the Crazy Lui
Grand 16-Star General and overall director of AGSC operations for the Pronoun Army(and webmaster)
http://pronounarmy.homestead.com/ http://thirty-five-mil.blogspot.com/
re-vamped sig 7D6h.3h.Ch
 | 
Pages: 1
Prev: A recursive BFS of a graph
Next: help with program