Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 791599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:51:49+00:00 2026-05-14T21:51:49+00:00

Let’s say we use NASM as they do in this answer: how to write

  • 0

Let’s say we use NASM as they do in this answer: how to write hellow world in assembly under windows.

I got a couple of thoughts and questions regarding assembly combined with c# or any other .net languages for that matter.

First of all I want to be able to create a library that has the following function HelloWorld that takes this parameter:

  • Name

In C# the method signature would looke like this: void HelloWorld(string name) and it would print out something like

Hello World from name

I’ve searched around a bit but can’t find that much good and clean material for this to get me started. I know some basic assembly from before mostly gasthough.

So any pointers in the right direction is very much apprechiated.

To sum it up

  • Create a routine in ASM ( NASM ) that takes one or more parameters
  • Compile and create a library of the above functionality
  • Include the library in any .net language
  • Call the included library function

Bonus features

  • How does one handle returned values?
  • Is it possible to write the ASM-method inline?

When creating libraries in assembly or c, you do follow a certain “pre defined” way, the c calling convetion, correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:51:49+00:00Added an answer on May 14, 2026 at 9:51 pm

    Something like this should get you a working DLL:

    extern _printf
    
    section .text
    global _hello
    _hello:
        push ebp
        mov ebp, esp
    
        mov eax, [ebp+12]
        push eax
        push helloWorld
        call _printf
        add esp, 8
        pop ebp
        ret
    
    export _hello
    
    helloWorld: db 'Hello world from %s', 10, 0
    

    You then just need to call the ‘hello’ function using P/Invoke. It doesn’t clean up after itself, so you need to set CallingConvention to Cdecl; you also need to tell it you’re using ANSI strings. Untested, but it should work fine.

    using System.Runtime.InteropServices;
    
    namespace Test {
        public class Test {
            public static Main() {
                Hello("C#");
            }
    
            [DllImport("test.dll", EntryPoint="hello", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
            public static extern Hello(string from_);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I can call a method like this: core::get() . What is the
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let say I've this URL: http://example.com/image-title/987654/ I want to insert download to the part
Let's say I got a Map<String, String> and I wanna remove all the entries
Let's say I have the string: hello world; some random text; foo; How could
Let's say I have table with column 'URL' whrere I store urls like this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.