1

I want to execute a shell script(exactly as mentioned in the code below) from my .asm file but can,t find the alternative to the following lines in assembly.I am using masm611 to assemble and compile the files.

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "myscript.sh";
proc.Start();

2 Answers 2

2

First, you don't say which architecture; so this is unanswerable. An easy solution should be to just code this in C, then compile to assembly code - that's a switch all popular C compilers have, AFAIK - then just transplant to your own code, linking with appropriate libraries.

Disclaimer: I don't work in assembly.

Sign up to request clarification or add additional context in comments.

Comments

0

Since your example is in .NET and you mention MASM, I assume that you work on Windows. On Windows, you can use either Win32 API to start a process, or the C RTL. Either way, you have to link to a static (.lib) library and call a function. In Win32 API, ShellExecute() is the easiest one to use (there's also CreateProcess(), but the calling sequence is a pain). In the RTL, there's _execl() and its relatives. Read up on consuming static libraries from assembly.

.NET code, like the Process.Start() stuff you've mentioned, does not translate into x86 assembly at all.

May I ask why this has to be done from assembly? "Assembly" and "shell scripts" rarely go together. Note: on Windows, shell scripts have a .bat or a .cmd extension. .sh, on the other hand, is characteristic of *nix or MacOS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.