I was doing a tutorial on inline assemble tricks for C and C++ when I
came upon a little detail that I can't figure out. I was doing a test
program to test out a concept which seems like it should flat out work,
but of course doesn't in a certain circumstance.
I get this error ...
Unhandled exception at 0x004000be in Demo.exe: 0xC0000096: Privileged
instruction.
when I run:
void main()
{
goto Label2;
Label:;
_asm RET
Label2:;
_asm CALL Label
return;
}
....but if I do...
void main()
{
if(0)
_asm JMP Label
goto Label2;
Label:;
_asm RET
Label2:;
_asm CALL Label
return;
}
... Then it works like I would expect. In fact, all I have to do is
somewhere mention the label again using a JMP , even if it's never
called. I looked as the dissassembly Visual Studio 2003 outputed for
the label is completely wrong unless I mention the label
somewhere/anywhere else.
so this also works...
void main()
{
goto Label2;
Label:;
_asm RET
Label2:;
_asm CALL Label
return;
_asm JMP Label;
}
any ideas? Some compiler standard I don't know about or a bug in the
compiler? 5 1774 Re*****@gmail.com wrote: I was doing a tutorial on inline assemble tricks for C and C++ when I came upon a little detail that I can't figure out. I was doing a test program to test out a concept which seems like it should flat out work, but of course doesn't in a certain circumstance.
I get this error ...
Unhandled exception at 0x004000be in Demo.exe: 0xC0000096: Privileged instruction.
when I run:
void main() { goto Label2; Label:; _asm RET Label2:; _asm CALL Label return; }
...
This isn't anything to do with the C language. The _asm keyword must be
an extension implemented by whatever compiler you are using. You'd be
best to ask about this in a newsgroup which discusses the compiler and
platform you are using. Re*****@gmail.com said: I was doing a tutorial on inline assemble tricks for C and C++
Before you write a tutorial about C, it might be a good idea to learn it.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously) Re*****@gmail.com wrote: I was doing a tutorial on inline assemble tricks for C and C++ when I came upon a little detail that I can't figure out. I was doing a test program to test out a concept which seems like it should flat out work, but of course doesn't in a certain circumstance.
I get this error ...
Unhandled exception at 0x004000be in Demo.exe: 0xC0000096: Privileged instruction.
when I run:
void main() { goto Label2; Label:; _asm RET Label2:; _asm CALL Label return; }
...but if I do...
void main() { if(0) _asm JMP Label goto Label2; Label:; _asm RET Label2:; _asm CALL Label return; }
.. Then it works like I would expect. In fact, all I have to do is somewhere mention the label again using a JMP , even if it's never called. I looked as the dissassembly Visual Studio 2003 outputed for the label is completely wrong unless I mention the label somewhere/anywhere else.
so this also works...
void main() { goto Label2; Label:; _asm RET Label2:; _asm CALL Label return; _asm JMP Label; }
any ideas? Some compiler standard I don't know about or a bug in the compiler?
The following - which is only a slight mod of your first piece of code
[which also ran fine] runs ok for me when using cl version 12.00.8804.
#include <stdio.h>
int main(void)
{
goto Label2;
Label:
puts("pre _asm RET");
_asm RET
Label2:
puts("pre _asm CALL Label");
_asm CALL Label
puts("post _asm CALL Label");
return 0;
}
I /think/ you've nul statements after your labels btw, i.e., the ';' aren't
needed.
Conclusion ... dunno.
--
==============
Not a pedant
==============
pemo wrote: Re*****@gmail.com wrote: I was doing a tutorial on inline assemble tricks for C and C++ when I came upon a little detail that I can't figure out. I was doing a test program to test out a concept which seems like it should flat out work, but of course doesn't in a certain circumstance.
I get this error ...
Unhandled exception at 0x004000be in Demo.exe: 0xC0000096: Privileged instruction.
when I run:
void main() { goto Label2; Label:; _asm RET
<snip>
The following - which is only a slight mod of your first piece of code [which also ran fine] runs ok for me when using cl version 12.00.8804.
#include <stdio.h>
int main(void) { goto Label2;
Label:
puts("pre _asm RET"); _asm RET
<snip>
Strangely enough, neither compilers on my system. Possibly this is
because it isn't actually C but some compiler specific extension?
pemo, you have been around here long enough to know we only deal with
standard C not code that has very little to do with C.
Conclusion ... dunno.
If you don't know, why bother posting at all?
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro: http://clc-wiki.net/wiki/Intro_to_clc
Flash Gordon wrote: pemo wrote: Re*****@gmail.com wrote: I was doing a tutorial on inline assemble tricks for C and C++ when I came upon a little detail that I can't figure out. I was doing a test program to test out a concept which seems like it should flat out work, but of course doesn't in a certain circumstance.
I get this error ...
Unhandled exception at 0x004000be in Demo.exe: 0xC0000096: Privileged instruction.
when I run:
void main() { goto Label2; Label:; _asm RET
<snip>
The following - which is only a slight mod of your first piece of code [which also ran fine] runs ok for me when using cl version 12.00.8804. #include <stdio.h>
int main(void) { goto Label2;
Label:
puts("pre _asm RET"); _asm RET
<snip>
Strangely enough, neither compilers on my system. Possibly this is because it isn't actually C but some compiler specific extension?
pemo, you have been around here long enough to know we only deal with standard C not code that has very little to do with C.
Conclusion ... dunno.
If you don't know, why bother posting at all?
True - it's OT, and for that I apologise.
Still, I would like to find out what the OP's problem was/is due to ... I
v.rarely use assembly in any of my code [possibly once every 10 years or
so], but I guess I'm just curious.
Still nuff said - it's OT.
--
==============
Not a pedant
============== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Martin Drautzburg |
last post by:
In the wx demoy TreeCtrl.py I find the following code, that should
have no effect but seems to be needed nevertheless.
class TestTreeCtrlPanel(wx.Panel):
def __init__(self, parent, log):
, isz)...
|
by: knoak |
last post by:
Hi there,
In my form, after validation, labels of wrong
fields are turned into a red color.
What i want now is when you hit 'reset', to make all
the labels grey again.
I have the next code:...
|
by: lkrubner |
last post by:
Is there any reason why this code wouldn't prompt someone to save their
work every 5 minutes? It doesn't seem to be working. This code shows up
in the HEAD of an HTML document.
function...
|
by: vbnewbie |
last post by:
I am having problems accessing properties of dynamically generated
objects in VB2005. Can someone please help?
In a nutshell:
My app creates an equal number of checkboxes and labels that share the...
|
by: stevewy |
last post by:
If I am using srcElement (or "target" for non-IE models) to return
various properties of an object I have clicked on, can I access for
"label for" value in any way? I'm thinking, for example, of...
|
by: Angus |
last post by:
I have a web page with a toolbar containing a Save button. The Save
button can change contextually to be a Search button in some cases.
Hence the button name searchsavechanges.
The snippet of...
|
by: RandomElle |
last post by:
Hi there
I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
|
by: bappai |
last post by:
Hello,
I am trying to actually call a GUI from my C++ code which would have buttons and therefore can call functions from C++ again, ie extend the C++ code also.
I am faced with a peculiar...
|
by: Ty |
last post by:
Hello all,
I am creating a web site with Visual Stuido 2008. I am trying to use
a java script file to create a busybox for login from this page
http://blogs.crsw.com/mark/articles/642.aspx.
I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |