473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

__asm in C#

I feel pressure to start using C# but I'm worried about losing
control.

It appears C# does not allow "__asm" for those "if it don't work,
force it" situations that crop up. Is that true? Is there any way to
get close to the machine with C#? How does one use assembler
language in C#? Can I get to MFC? How about low level functions
like "_open" and _clock()" available in straight C - are they
available in C#?
Nov 15 '05 #1
5 7012

"Bill" <wi***********@cox.net> wrote in message
news:9q********************************@4ax.com...
I feel pressure to start using C# but I'm worried about losing
control.

It appears C# does not allow "__asm" for those "if it don't work,
force it" situations that crop up. Is that true? Is there any way to
get close to the machine with C#? How does one use assembler
language in C#? Can I get to MFC? How about low level functions
like "_open" and _clock()" available in straight C - are they
available in C#? No, C# is not actually derived from C/C++, it is a C style language similar
to java. C# exists entirely within a managed runtime called the CLR(VB.NET
also exists within this runtime), which provides garbage collection and
other services to your application. C# doesn't directly compile to machine
code either, it compiles to an intermediate assembly language (IL), which is
converted into machine code at runtime.
Frankly, its not meant for situations where you need to worry about
performance or behaviour to hte point wherey ou would want to break into
assembly.

Likewise, MFC is a C++ framework and is not available in C#. You can use
Managed C++ however which provides you a mixture between managed and native
code using C++.

Nov 15 '05 #2
You can simply call every native function from every DLL you want.
In C# itself you cannot use assembler, you have to put your asm code in a
DLL.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #3
I missed it too for a while :) - C# automates a lot of memory managmenet;
hence __asm is out of the question; also, C#'s pointer functionality is very
very limited (you can use them but working with (Manager/Unmanaged Code) &
pointers is painful.

I'd recommend going Managed C++ if you need ASM in there you could run both
Managed and Unmanaged code in the same place; - probably will ease your pain

"Bill" <wi***********@cox.net> wrote in message
news:9q********************************@4ax.com...
I feel pressure to start using C# but I'm worried about losing
control.

It appears C# does not allow "__asm" for those "if it don't work,
force it" situations that crop up. Is that true? Is there any way to
get close to the machine with C#? How does one use assembler
language in C#? Can I get to MFC? How about low level functions
like "_open" and _clock()" available in straight C - are they
available in C#?

Nov 15 '05 #4
Some remarks;
C# doesn't automate memory management, the CLR does it.
You don't use _asm in C++ only to use pointers or do some pointer
arithmetic's, but because you have some highly optimized assembly code to
merge with your C++ code.
_asm is not allowed in MEC++, for the same reason it's not done in C#.
If you need this, your only option is (unmanaged) C++.

Willy.

"Arthur Mnev" <ar********@optonline-no-spam.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
I missed it too for a while :) - C# automates a lot of memory managmenet;
hence __asm is out of the question; also, C#'s pointer functionality is
very
very limited (you can use them but working with (Manager/Unmanaged Code) &
pointers is painful.

I'd recommend going Managed C++ if you need ASM in there you could run
both
Managed and Unmanaged code in the same place; - probably will ease your
pain

"Bill" <wi***********@cox.net> wrote in message
news:9q********************************@4ax.com...
I feel pressure to start using C# but I'm worried about losing
control.

It appears C# does not allow "__asm" for those "if it don't work,
force it" situations that crop up. Is that true? Is there any way to
get close to the machine with C#? How does one use assembler
language in C#? Can I get to MFC? How about low level functions
like "_open" and _clock()" available in straight C - are they
available in C#?


Nov 15 '05 #5
Also, as an aside, there's a few projects to come up with abstract IL
compilers (similar to ASM, but writes IL instead of native op codes).
Although, my suspicions are that this won't become part of C# unless there's
an incredibly good reason to do it (and a lot of pressure). More likely, you
can create an assembly of highly-optimized IL, and use it from your C#
programs. Additionally, C# does a pretty decent job of optimization, and
furthermore, the JIT compiler optimzes the IL to native code, so specifying
IL instructions directly isn't the end-all to optimization, and there's no
guarantee the JIT compiler won't do something unexpected behind your back.

-Rob Teixeira [MVP]

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
Some remarks;
C# doesn't automate memory management, the CLR does it.
You don't use _asm in C++ only to use pointers or do some pointer
arithmetic's, but because you have some highly optimized assembly code to
merge with your C++ code.
_asm is not allowed in MEC++, for the same reason it's not done in C#.
If you need this, your only option is (unmanaged) C++.

Willy.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Cristian Tota | last post by:
If I am using inline asm in functions, like this: void func(){ __asm{ // asm code }; }; is it guaranteed that this does not mess up the registries? (As opposed to using inline asm in...
16
by: robin.pain | last post by:
Inlining assembler in a *.c file:- Both __asm("nop \n") and __asm("nop")
5
by: Seven Kast USA | last post by:
Hi i need information how to include Assembly language in c , tell me some tutorials or website or guildlines of it by KAST
2
by: Keith | last post by:
Hi I'd like to get the stackpointer value in my C program I tried this, but I keep getting a compiler error What am I doing wrong monitorStackPointer( long value __asm { mov value, SP
6
by: Gabest | last post by:
I'm asking this because I'd like to include a few (but often used) inline assembly code via marcos to make the whole thing a bit more readable, and more resistant to typos (by keeping the repeating...
3
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, Out of curiousity, I sometimes look at the produced assembly after compilation in release mode. What you often see, is that CPP, always fully addresses registers to copy values from a to...
85
by: fermineutron | last post by:
Some compilers support __asm{ } statement which allows integration of C and raw assembly code. A while back I asked a question about such syntax and was told that __asm is not a part of a C...
1
by: Siegfried Heintze | last post by:
I have a VB.NET program that is working fine from Visual Studio 2005. However, when I try to compile and run it from the cmd.exe prompt, it throws an exception. If this was C++, I would insert...
2
by: Charles Zhang | last post by:
For Win32 application, I could use "__asm pause". However, for X64 platform, the inline assembler is not supported. Is there a compiler intrinsics for "__asm pause"? Thanks Charles Zhang
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.