[Solved] Assembly - Passing Integer Command Line Parameters

This is as good a place to ask as any I suppose, so here goes.
I'm really only interested in knowing if it is at all possible to push actual values, in this case integers, on the stack from the command Line, i.e. passing arguments and if so how, because as far as I can gather, it is simply impossible to pass anything other than strings.
Yes I am a noob at assembly, if anyone should doubt that.
Best regards.
I thought the best thing to do is simply to explain what I'm actually doing.
In short, I need to derive the Lightness/Luminance level of a pixel. This of course can be done a number of way. Initially I experimented with image magic, but when I couldn't figure it out, I thought: "Hey, why not learn something along the way?"
So here I an, trying to do some assembly under linux.
For those interested the process is actually rather sinbple:
1. get and convert the rgb input as needed.
2. Determine the highest and lowest channel (progress so far):
mov ax, $1;
mov cx, $2;
mov dx, $3;
cmp ax, cx;
jng else;
mov ax, ax;
mox bx, cx;
jmp next;
else:
mov ax, cx;
mov bx, ax;
next:
cmp dx, ax;
jng else2;
mov ax, dx;
jmp end;
else2:
cmp bx, dx;
jnl end;
mov bx, dx
end:
3. add the two values and divide by two. possible implement a way to check if the addition is even or not, so to enable proper rounding.
4. output the result in one form or another.
Last edited by zacariaz (2012-09-03 20:30:14)

Lux Perpetua wrote:
zacariaz wrote:
Well, at the same time it makes sense and it don't.
I makes sense to have a "common language", so to speak, so that various applications can be piped together.
At the same time however, it's a waste to have the majority of the code dedicated to making conversions. First one for the input and then one for the output.
But that life I guess.
Thanks for now.
When you run a program on a Linux system, it ultimately all boils down to the following function:
int execve(const char *path, char *const argv[], char *const envp[]);
Without going into full detail: the first argument is the path to the program being executed. The second argument is literally the "argv" argument list the program sees (which is a null-pointer-terminated array of pointers to null-character-terminated strings). The third argument is the environment. Relevant to you is the second argument. It doesn't matter if it's an assembly program, a C program, or a shell script; the "command-line" arguments to the program, i.e., the argv array, are pointers to strings.
Lest you have the brilliant idea to take an integer apart into bytes and stick them in a string as one of the argument as some others have suggested, you should consider the following: what if one of the bytes of the integer is 0? That technically ends the "string," and everything following that byte is discarded by execve. Adding 1 to all the bytes wouldn't work, since 0xff would wrap around to 0 again. To make it work, you'd need to encode the integer in some other complicated way to avoid null characters and then decode it inside your program. In other words, you might as well just pass an ordinary string and parse it with atoi or strtol.
You are of course right, and thanks for the very nice explanation, however it's still a pain in the but.
I like working with number, not with letters, but enough of this.
Thanks to all and to all a good night, day or whatever you please.
Best regards

Similar Messages

  • XSQL Command-Line, parameters with blanks

    Is it possible to use XSQL Command-Line with parameters containing blanks (space characters).
    In an URL parameter spaces can be encoded with "+" or "%20", but this does'nt seem to work with XSQL Command-Line parameters.
    -- Peter

    I can't make this work on Unix (solaris), but I can see it is a shell script problem, not a XSQL problem.
    The normal syntax for Unix shell script would be
    $ script.sh foo="one two"
    but the standard Oracle-supplied xsql unix shell script sets environment and passes all command-line parameters to the java program with
    oracle.xml.xsql.XSQLCommandLine $*
    and thereby the quotes disappear.
    The problem is not really big, since I could just do
    oracle.xml.xsql.XSQLCommandLine test.xsql "foo=one two"
    after setting classpath. Anyway, if anybody knows how to make the xsql script work with quoted parameters, let me know.
    -- Peter

  • How to pass command line parameters in calling ant file

    Hi All, I m using a Build file which calls another build file.
    That build file is run from the command prompt by give ant -lib <path of jars it needs for executing>.
    Now i m calling this file from main build file but it does not work as i m not able to set <b>-lib </b>.
    Pls can anybody let me know how to set such command line parameters to call the build file in ant script.
    Thanks in Advance.
    Ketan.B.Parekh

    Create the control file dynamically (and fill one of the columns with the file name as a constant) before you start SQL*Loader
    Another option is to use external tables
    Re: Data Loading
    Message was edited by:
    Jens Petersen

  • How to pass command line parameters During server start up

    Hi,
      I am trying to use Net Beans profiling tool.On the server side i required to pass a command line option to enable remote profiling.
    Regards,
    Kiran.

    Hi, MB.
    If you are talking about the automatic Java Web Start support for launching app clients in GlassFish, you can pass the equivalent of command line arguments using the query string of the URL you use to launch the app client.
    Briefly, use
    http://host:port/client-path?arg=first-arg&arg=second-arg& ...
    specifying the argument values in the order that you want them passed to the client.
    The GlassFish server will do the right thing and generates the correct JNLP so your arguments are passed to the app client.
    The GlassFish developer's guide http://glassfish.dev.java.net/nonav/javaee5/docs/AS91DG.pdf discusses this and all aspects of the Java Web Start support. You can also take a look at this blog entry http://blogs.sun.com/quinn/entry/command_line_arguments_and_properties that focuses on how to pass arguments.
    Since this technique deals with argument passing in the URL, it works no matter how you launch the app client: a URL in a browser, the javaws command, etc.
    - Tim

  • Pass the command line argument (argc and argv) to a LabVIEW built shared library.

    Hello,
    I have successully use this trick to build a LabVIEW application that runs on Linux without X Display.
    http://digital.ni.com/public.nsf/allkb/5D6EC36DCF43343786257449006919E6
    I'd like to know if it's possible to pass the command line arguments ( ./TEST A B C D) directly into the shared library without having to pass the arguments using a array of strings which would require to write code using DSNewHandle, DSSetHandleSize, extract the arguments and ..... (I'm not proficient in C, but if I don't have a choice I will do it and improve my C skills).
    int main(int argc, char *argv[])
            Test(argc, argv);
            return 0;
    Thanks,
    Michel
    Solved!
    Go to Solution.

    Well, you can always flatten it back into a space separated single string and pass it like that. Basically reverse what the OS does when it calls your main function with the command line parameters. And while the first element in the array is always the program name itself you can just skip that here, but then format all the rest into a single string.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Edit command line parameters without restarting LabVIEW

    Is there a way to edit the command line parameters passed to a VI WITHOUT having to restart LabVIEW?  Perhaps I'm accustomed to how it works in just about every other development environment, but having to do so is quite frustrating.
    Solved!
    Go to Solution.

    ronbrown wrote:
    I'm just surprised that LabVIEW doesn't have just a simple "command line parameters" option somewhere in the VI options for debugging purposes, just like Visual Studio and other deveopment environments.
    If memory serves, Visual Studio runs the compiled program as a separate process. That should make it easier to give it separate switches. In LabVIEW, if you let the user change the parameters, you would have to do some conflict resolution, since this is a global setting (e.g. did the changes you make affect everything or a single VI/hierarchy/app instance, are the original switches lost or can you get them back somehow and when).
    If you want a workaround, I suggest you create a simple subVI with a 1D array output and a 1D array control on its FP or BD. If the control has something in it, use it. Otherwise, use the CLA[] property. Alternatively, you can check if you're running in the IDE or use a boolean, etc. Personally, the only time I think I needed to use switches, I believe the code was simple and I simply tested it by building the EXE. It probably took longer to figure out that I needed to explicitly turn on CLA support for the EXE than the actual testing.
    Try to take over the world!

  • Command line parameters and resuming

    Hi,
    I am researching for a client who wishes to have several students (K-12) using Adobe Captivate course on the same computer. Another constraint is that a course is run from DVD (1+ GB in size) so it's published as standalone application (.exe for Windows, .app for Mac). Quick questions:
    Can a course have an action to parse command line parameters? I haven't found that.
    Explanation: this would be used to simply parse a name and e-mail address (if possible) and last module passed to a course player. Resuming could be disabled (there is an answer how to do that in the forum) or overridden but the learner should be transferred to a slide to resume based on the calling parameter (and not the default resuming - there will be several users so each must resume from the last passed module slide).
    Can a progress of the current learner using the course be saved to a database (no LMS, e-mail, Acrobat.com etc)?
    Explanation: this is needed for the current learner and for each one separately. I guess I already have a solution in mind (custom application, having small internal web server like Mongoose, with a script that replaces internalServerReporting.php and saves the data to a internal database, SQLite). But for this to work spawning a course with command line parameters and course itself reading these parameters would need to work.
    If there is a (better) solution for the above, please reply. The goal is have minimal changes on the course e.g. if there are command line parameters, then parse them and do something (mark modules passed, open appropriate next slide). If parameters are not given/recognized, do nothing (so the course would still work on computers used by one learner only, including resuming etc).
    My opinion is that this should also be one-way as much as possible. E.g. additional application handles user name, e-mail and current progress and spawns Captivate course. The published course itself should not depend on the application like reading progress from a text file (though an URL call could return current progress from an application for the same user name). So ideally only changes to use internal server publishing to save current progress and adding a logic to check parameters at start would be applied to a course.
    Waiting for your smart answers.
    Matt

    DVDs, when finalized, are read-only... so unless you are considering to do an Install of the course from the DVD to the machine, you're not going to be able to write to a database.  A USB stick may be more suitable in this situation.
    Command line params are not possible with EXEs unless you create your own EXE wrapper.  If you're going to go through that trouble, you'd be better off creating an Adobe Air application that can run your local web content without security restrictions and use SQLite or some other backend to store the data.
    Can the progress be saved?  It depends what you mean by progress.  If you just want to allow the student to resume from the slide where they left off... you can do that with a bit of JavaScript.  However, if you want to ensure that any previous questions answered on a quiz were also resumed and intact from the previous session... not possible without an LMS.
    Why not run a Moodle installation via a USB stick and you can have a full featured LMS with a database and ability to resume a previous session?
    http://docs.moodle.org/19/en/Installation_guide_-_Moodle_for_Windows_on_a_USB_Memory_Stick
    Just some things to consider...

  • Command Line Parameters Nightmare!

    My issue--and it seems to only be my issue--is with the Command Line Parameters. I have been trying to install iTunes 5.0 for five days now. I have tried everything posted in these forums. Dmitry, thanks for such a great resource; it helped some, but not with this one problem, unfortunately.
    Anyway, everytime I open the iTunes installer I get a message about command line parameters. It gives me a list of a bunch of parameters that I know nothing about. If you would like to see a screen shot of this travesty, you can go to this link: http://staff.fcps.net/nfish/specialdownloadspage.htm.
    Anyone know how to fix this problem or know an alternative solution? Thanks.

    I solved my problem...Everyone who has this problem needs to go see Tim's incredible solution at Nathanael Fish, "new error......" #13, 09:55am Sep 23, 2005 CDT
    It will fix this problem, guaranteed.
    Nate

  • How to pass a command line argument to a jsp file...

    Hi guys,
    I'm writing a jsp file in which I have some java codes. I want to pass some command line arguments to that jsp file. In other words, I have some files located somewhere on my C drive and I want to pass the path to these files to my jsp file. How can it be done? I have never done before.
    Any suggestion will be very hepful...
    Thanks....

    I dont know if I truly understand your problem...
    For instance, when you place the url of your jsp you can add, at the end some parameters. For example:
    http://myserver/myapp/myjsp.jsp?MyParameter=C:\Temp\JavaTutorial.html
    In your JSP, you can place this code on a scriplet to get the value:
    String path = request.getParameter("MyParameter");
    Hope it helps.

  • Command line parameters for OMBPlus?

    Hi,
    Is it possible to pass command line parameters to TCL scripts running in OMBPlus.sh, and if so, can someone provide an example?
    I'm able to use the argv0 variable to get the script name itself but not sure how to get any other additional parms...
    Thanks,
    Jim

    Jim,
    If you are building command-line scripts to automate OMB+ commands, there is another factor you should be aware of. If your script errors out cleanly, the OMBPlus.sh does NOT pass this back to the shell. The return code is evaluated within OMBPlus as the return from a "source" command and then OMBPlus exits normally.
    For example:
    #file test.tcl
    return -code error
    Unix/shell> OMBPlus.sh test.tcl
    Unix/shell> echo $?
    0What I do to pass an error state back to the shell is to create a flag file in my script if exiting due to error. My shell script deletes this file prior to running the script and then tests for it after the run as part of the conditional logic
    Function in tcl file:
    #Get location where this script installed
    #This variable is set at the top of the script.
    set theScriptDir  [ file dirname [info script]]
    #If we want to bail in the script at any point we call exit_failure with an appropriate error message
    proc exit_failure { msg } {
       global theScriptDir 
       set ERRFLAGFILE "$theScriptDir/ers_owb_import.error"
    #rollback any uncommitted work
       OMBROLLBACK
    #Log the error and exit
       set fout [open "$ERRFLAGFILE" a+]     
       puts $fout "Error:-> $msg"
       close $fout
       # return and also bail from calling function
       return -code error
    }And my shell script does something like:
    cd ${JOB_DIR}
    rm -f ers_owb_import.error 2>/dev/null
    echo \\nBegining Uninstall of OWB Project
    ./OMBPlus.sh ${JOB_DIR}/my_tcl_Script.tcl
    if [ -f ${JOB_DIR}/ers_owb_import.error ] ; then
          echo \\nERROR - SCRIPT FAILED
    else
         echo \\nScript Succeeded.
         # script logic continues....
    fiCheers,
    Mike

  • Starting Projector w/Command line Parameters

    I would like pass one to three command line parameters to the projectors embedded SWF at runtime.
    Player 11.1
    myProjector.exe param1, param1
    Thanks,
    Jim

    Im looking to do this via a command line. Ultimately how I intend on using this is creating a Windows Explorer Context Menu that allows me to right click on a folder or file and automatically add it to iTunes.
    Ive already created one to 'Play in iTunes' and using the command line mentioned above and it works like a charm.
    Thanks again!

  • MAX command line parameters

    I could program a whole panel to allow the user to modify the setup parameters for a DAQmx task, but decided that it's easer to simply stop the task and launch MAX with LaunchExecutableEx and let the user play with the task settings there. Is there any way to tell MAX, e.g. through command line parameters, to open up and display a particular DAQmx task upon startup?
    Solved!
    Go to Solution.

    Helo pblase,
    I do not believe that it is possible to configure MAX to open up on a particular task. It also appears that there is no MAX ActiveX Automation Server that we can access.
    Jacob R. | Applications Engineer | National Instruments

  • XSQL command line parameters

    I have a situation where I am generating some XML from a query in an XSQL and I want to use some command line parameters. This ony seems to work inside queries, e.g. given the command line "xsql quote.xsql quotetype=carhire quotenum=123" this will substitute 123 for "{@quotenum}" given the command line and leave "{@quotetype}" untouched.
    <pre>
    <quote type="{@quotetype}">
    <xsql:query>
    select price from quotes where number={@quotenum}
    </xsql:query>
    </quote>
    </pre>
    Is there a way to substitute the {@quotetype} part in XSQL?

    I'm already using XSLT and I've put <xsl:param name="type"> in the stylesheet, but references to $type don't seem to get any result, e.g.
    <xsl:value-of select="$type"/> is blank
    and
    <xsl:if test="$type='carhire'">
    <xsl:text>car hire</xsl:text>
    </xsl:if>
    doesn't generate any output either, so either I've got my syntax for parameters wrong, or the parameters don't get passed from the XSQL front end to the XSLT back end.

  • Command line parameters and path problem

    hello ....
    I have to execute an application from my java program. My application called "AIMSS" takes 2 command line parameters. Now, when i mention those parameters with complete path to my executeable, windows reports that "unable to open the shortcut". Below is what i am trying:
    private static final String WIN_PATH = "rundll32";
    private static final String WIN_FLAG  "url.dll,FileProtocolHandler";
    private String cmd = null;
    private String url = null;
    public void runMyFileWithMessage(String msg)
        try
    url = "C:\\Program Files\\Raytheon\\AIMSS 4.0\\Runtime\\Standard\\aimss40.exe" + " AAAVIETM 3457";
                 cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
                 System.out.println(url);
                 Runtime.getRuntime().exec(cmd);
            catch(IOException io)
                System.out.println("AIMSS problem. Below is the Stack Trace.");
                io.printStackTrace();
        }Although, when i tried to run the executeable from Start->Run, by giving it same complete path and 2 arguments, it runs fine. Any help would be greatly appreciated.
    Raheel.

    Passing multiple paramters in a String to exec() doesn't work. Use the exec method that takes a String array instead and pass the call and each parameter in as a separate String.
    Off the top of my head (check the api) it will be something like
    String[] cmd = {"C:\\Program Files\\Raytheon\\AIMSS 4.0\\Runtime\\Standard\\aimss40.exe","AAAVIETM", "3457"};
    Runtime.getRuntime().exec(cmd);

  • Running a class with command line parameters from IDE

    Hi there,
    I want to run a class from with the developer IDE. But I also want to pass in some command line parameters. Is there any way to do this from within the IDE, without having to go out to a Dos Prompt or shell?
    Thanks in advance
    Johnny

    In JDeveloper 10.1.3, Project Properties->Run/Debug->Edit
    choose the program that should be be the default run target.
    Click "Tool Settings" in the left pane and then in the right pane under "Additional Runner Options" select "Allow program input".
    It works, but the input works better in the command prompt. The problem is that after entering one input the Input-line looses focus and one have to click it to re-focus. A bug?
    However, this lets me use the "Run" button. All in all, a more efficient way of developing programs.

Maybe you are looking for

  • Rolling back of Quick Pay Pre-payment and Quick Pay in case of void cheque

    Hi All I am facing an issue if you can help me out of if Here is a scenario a payroll manager runs the following processes. 1. Payroll run 2. Pre-Payments 3. Payroll Archiver 4. Payment Output file After running all these process payroll manager find

  • What is Business one and its use?

    Hi I would like to know abt Busniess one and why it is used. Also Is it poosible to integrate with SAP XI. If yes what kind of adapter we need to use. Looking for ur response. thkx Prabhu

  • Transfer AVI movie file to Itunes to upload to Ipod Touch

    Hi Just got Ipod touch and have some movies/tv shows on desktop that I want to put to my ipod. Tried the Save file to library on itunes but nothing happens. Does anyone know how I can put these AVI files to my ipod touch. Simple instructions apprecia

  • 'SO_DOCUMENT _SEND_AP1' and CC recipients

    In 'SO_DOCUMENT SENDAP1' is there a parameter to flag to send e-mail to CC recipients (instead of primary recipient ) ? Thanks in advance Andrew

  • Plugin for itunes

    for some reason i cant log on to my itunes account .i had no problem in tell i purchased a mini series ,after i got my confirmation # i went to burn my shows and i got the message ituns need to close, this was two weeks ago i get the message plugin d