473,657 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# and my indispensable inline assembly code

I am about to move my C++ application to C#. Parts of my previous
application consisted of inline SSE2 assembly code optimized for the P4
processor. What options do I have to integrate that part into my C#
application?
There are no such things as intrinsics support in C#, right?

Thank you very much!
regards, Teis
Nov 16 '05 #1
14 2676
As far as I know this is not possible. You could separate your assembly
code out into a DLL which you call from your C# code using p/invoke but of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am about to move my C++ application to C#. Parts of my previous
application consisted of inline SSE2 assembly code optimized for the P4
processor. What options do I have to integrate that part into my C#
application?
There are no such things as intrinsics support in C#, right?

Thank you very much!
regards, Teis

Nov 16 '05 #2
-Thank you for your reply!
Any way I reach my beloved assembly is perfect for me. I'm still a C#
novice; is your proposal using a DLL and p/invoke the best and only solution
or are there other options that I could take into consideration?
My SSE2 code handles reatime video so both bandwidth and latency are issues
while communicating with the assembly section.

thank you very much, Teis
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:ei******** *****@TK2MSFTNG P11.phx.gbl...
As far as I know this is not possible. You could separate your assembly
code out into a DLL which you call from your C# code using p/invoke but of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed. http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am about to move my C++ application to C#. Parts of my previous
application consisted of inline SSE2 assembly code optimized for the P4
processor. What options do I have to integrate that part into my C#
application?
There are no such things as intrinsics support in C#, right?

Thank you very much!
regards, Teis


Nov 16 '05 #3
is this really true Bob? Seems odd that Anders would have left that ability
out (cos I'm sure I remember this ability in Delphi -which of course is part
of Anders' background).
Maybe he's done this for code safety/ seperation/ readability?
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:ei******** *****@TK2MSFTNG P11.phx.gbl...
As far as I know this is not possible. You could separate your assembly
code out into a DLL which you call from your C# code using p/invoke but of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed. http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am about to move my C++ application to C#. Parts of my previous
application consisted of inline SSE2 assembly code optimized for the P4
processor. What options do I have to integrate that part into my C#
application?
There are no such things as intrinsics support in C#, right?

Thank you very much!
regards, Teis


Nov 16 '05 #4
But Delphi is unmanaged code, while C# results in managed code (IL) running
in the CLR, where it's translated to machine code by the JITter. The IL
produced by the C# compiler is secure/verifiable code and this is essential
for the language, allowing to embed assembly (unverifiable) would render the
language unverifiable (you don't wan't your assembly code to be translated
int IL do you?).

Willy.
"Mark Broadbent" <no************ @no-spam-please.com> wrote in message
news:OE******** ******@TK2MSFTN GP10.phx.gbl...
is this really true Bob? Seems odd that Anders would have left that
ability
out (cos I'm sure I remember this ability in Delphi -which of course is
part
of Anders' background).
Maybe he's done this for code safety/ seperation/ readability?
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:ei******** *****@TK2MSFTNG P11.phx.gbl...
As far as I know this is not possible. You could separate your assembly
code out into a DLL which you call from your C# code using p/invoke but
of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well

Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> I am about to move my C++ application to C#. Parts of my previous
> application consisted of inline SSE2 assembly code optimized for the P4
> processor. What options do I have to integrate that part into my C#
> application?
> There are no such things as intrinsics support in C#, right?
>
> Thank you very much!
> regards, Teis
>
>



Nov 16 '05 #5
Yes, the embedding of assembly language would render the assembly (and the
language as a feature) unverifiable. The CLR has absolutely no visibility
into unmanaged code and thus cannot control it's type safety or lifetime.

You could use MC++ which using IJW allows you to mix and match unmanaged and
managed C++ even in the same module but as long as there is assembly
language, the assembly will be non-verifiable.

--
Sam Gentile
Microsoft MVP - C#/.NET
INETA Speaker
Read my CLR blog http://samgentile.com/blog/
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:ep******** *****@TK2MSFTNG P12.phx.gbl...
But Delphi is unmanaged code, while C# results in managed code (IL)
running in the CLR, where it's translated to machine code by the JITter.
The IL produced by the C# compiler is secure/verifiable code and this is
essential for the language, allowing to embed assembly (unverifiable)
would render the language unverifiable (you don't wan't your assembly code
to be translated int IL do you?).

Willy.
"Mark Broadbent" <no************ @no-spam-please.com> wrote in message
news:OE******** ******@TK2MSFTN GP10.phx.gbl...
is this really true Bob? Seems odd that Anders would have left that
ability
out (cos I'm sure I remember this ability in Delphi -which of course is
part
of Anders' background).
Maybe he's done this for code safety/ seperation/ readability?
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:ei******** *****@TK2MSFTNG P11.phx.gbl...
As far as I know this is not possible. You could separate your assembly
code out into a DLL which you call from your C# code using p/invoke but
of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well

Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> I am about to move my C++ application to C#. Parts of my previous
> application consisted of inline SSE2 assembly code optimized for the
> P4
> processor. What options do I have to integrate that part into my C#
> application?
> There are no such things as intrinsics support in C#, right?
>
> Thank you very much!
> regards, Teis
>
>



Nov 16 '05 #6
I just miss the possibility in C# (.NET) to specifically target modern
processors supporting SIMD instructions like SSE2 and 3D Now. Nevertheless
inner loops making use of SIMD can boost the process by several times.
Is that completely incompatible with MSIL?

regards, Teis
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:ep******** *****@TK2MSFTNG P12.phx.gbl...
But Delphi is unmanaged code, while C# results in managed code (IL) running in the CLR, where it's translated to machine code by the JITter. The IL
produced by the C# compiler is secure/verifiable code and this is essential for the language, allowing to embed assembly (unverifiable) would render the language unverifiable (you don't wan't your assembly code to be translated
int IL do you?).

Willy.
"Mark Broadbent" <no************ @no-spam-please.com> wrote in message
news:OE******** ******@TK2MSFTN GP10.phx.gbl...
is this really true Bob? Seems odd that Anders would have left that
ability
out (cos I'm sure I remember this ability in Delphi -which of course is
part
of Anders' background).
Maybe he's done this for code safety/ seperation/ readability?
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:ei******** *****@TK2MSFTNG P11.phx.gbl...
As far as I know this is not possible. You could separate your assembly code out into a DLL which you call from your C# code using p/invoke but
of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well

Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> I am about to move my C++ application to C#. Parts of my previous
> application consisted of inline SSE2 assembly code optimized for the P4 > processor. What options do I have to integrate that part into my C#
> application?
> There are no such things as intrinsics support in C#, right?
>
> Thank you very much!
> regards, Teis
>
>



Nov 16 '05 #7
Teis,

Yes I know, but this is not the level you are programming at when using a
managed language, if you really need this you should stick to (VS C++7.x)
C/C++ where you can mix managed code and unmanaged code (and asm).
As for your SSE2 support, this is up to the CLR (JITter) to decide whether
these are available and use them when appropriate, but again if you want
play with your own toys ;-) just ignore C# for this and use C++.

Willy.

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:Oa******** ******@TK2MSFTN GP09.phx.gbl...
I just miss the possibility in C# (.NET) to specifically target modern
processors supporting SIMD instructions like SSE2 and 3D Now. Nevertheless
inner loops making use of SIMD can boost the process by several times.
Is that completely incompatible with MSIL?

regards, Teis

Nov 16 '05 #8


----- Teis Draiby wrote: ----
I just miss the possibility in C# (.NET) to specifically target moder
processors supporting SIMD instructions like SSE2 and 3D Now. Nevertheles
inner loops making use of SIMD can boost the process by several times
Is that completely incompatible with MSIL


yes, because that defeats the whole purpose of having a "virtual machine". remember, when you right in .NET, you are writing code for something imaginary, there's no SSE2 or 3D Now in our imaginary world.
Nov 16 '05 #9
yeah your right, I personally thought it might be nice to be able to embed
code like assembly that would be unmanaged and bypass the CLR (obviously in
the unsafe context) but I guess it is just as easy to import it via a dll
like Bob suggested.

--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:ep******** *****@TK2MSFTNG P12.phx.gbl...
But Delphi is unmanaged code, while C# results in managed code (IL) running in the CLR, where it's translated to machine code by the JITter. The IL
produced by the C# compiler is secure/verifiable code and this is essential for the language, allowing to embed assembly (unverifiable) would render the language unverifiable (you don't wan't your assembly code to be translated
int IL do you?).

Willy.
"Mark Broadbent" <no************ @no-spam-please.com> wrote in message
news:OE******** ******@TK2MSFTN GP10.phx.gbl...
is this really true Bob? Seems odd that Anders would have left that
ability
out (cos I'm sure I remember this ability in Delphi -which of course is
part
of Anders' background).
Maybe he's done this for code safety/ seperation/ readability?
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:ei******** *****@TK2MSFTNG P11.phx.gbl...
As far as I know this is not possible. You could separate your assembly code out into a DLL which you call from your C# code using p/invoke but
of
course this won't be inlined.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well

Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Teis Draiby" <te************ *@draiby.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> I am about to move my C++ application to C#. Parts of my previous
> application consisted of inline SSE2 assembly code optimized for the P4 > processor. What options do I have to integrate that part into my C#
> application?
> There are no such things as intrinsics support in C#, right?
>
> Thank you very much!
> regards, Teis
>
>



Nov 16 '05 #10

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

Similar topics

4
4079
by: Cristian Tota | last post by:
I am programming Visual C++ 6.0, using inline asm. MSDN says that code with inline asm is not fully portable to other hardware platforms. What does this reffer to? On what platforms isn't the code portable? Cristian
3
3669
by: Ganesh Tawde | last post by:
Hi. I am trying to use the below pure assembly code as inline assembly in C. The pure assembly code gives proper data but the inline assembly code gives me distorted data. I am not able to figure out the problem. can any body help me on this? here is the working pure assembly function *************************************************************************
18
5051
by: Method Man | last post by:
If I don't care about the size of my executable or compile time, is there any reason why I wouldn't want to inline every function in my code to make the program run more efficient?
8
1748
by: neilmcguigan | last post by:
I just wanted to list some reasons why I prefer inline code to code-behind. 1. you can fix some bugs more quickly. remote desktop into server, change the aspx file, and she's good to go. I'd say this is one of the major reasons classic ASP became so popular. 2. don't have to upload the large codebehind site DLL to fix one bug. 3. updating the codebehind site DLL restarts the application. fixing
9
2894
by: chinu | last post by:
hi all, i did a small experiment to grasp the advantages of declaring a function as inline. inline int fun1(); int main(){ unsigned int start=0,end=0; asm("rdtsc\n\t"
15
479
by: niklaus | last post by:
Hi, I have a doubt regarding inline functions. 1) When does the inline of function happen. During the preprocessing stage or just before the object code is produced. Can we see the source code after we have function inline just like cpp abc.C shows me the expanded macros on linux. 2) Is it the source code that is inlined or the assembly code (object code).
2
1823
by: =?Utf-8?B?TWljayBPJ05laWxs?= | last post by:
I am currently trying to wrap an old library (ImageMagick) in .NET, and am having problems with inline expansions. I have recompiled the library in vc++ 2005 OK. However, when I try to access any inline methods of the library classes from my managed classes, the inlining does not seem to occur, and I end up with a linker error 2001 - unresolved external. Is there a trick for getting this to work. I have tried using Default inline (/Ob0) in...
17
1666
by: skip | last post by:
I don't personally use __call__ methods in my classes, but I have encountered it every now and then here at work in code written by other people. The other day I replaced __call__ with a more obvious method name, so now instead of executing obj(foo, bar, baz) the code in question is obj.execute(foo, bar, baz)
4
1679
by: raashid bhatt | last post by:
hi by the definition of inline functions "In computer science, an inline function is a programming language construct used to suggest to a compiler that a particular function be subjected to in-line expansion; that is, it suggests that the compiler insert the complete body of the function in every context where that function is used."
0
8420
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7353
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.