Importing C extern errno into HP-UX assembler - HP UX

This is a discussion on Importing C extern errno into HP-UX assembler - HP UX ; I have tried many various .IMPORT statements and intsructions to import the C extern errno variable into a PA-RISC assembler procedure in order to modify errno from the assembler program. So far, everything I've tried either has no effect or ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Importing C extern errno into HP-UX assembler

  1. Importing C extern errno into HP-UX assembler

    I have tried many various .IMPORT statements and intsructions
    to import the C extern errno variable into a PA-RISC assembler
    procedure in order to modify errno from the assembler program.
    So far, everything I've tried either has no effect or causes
    the program to crash. This is for a PA-RISC 1.1 architecture.
    I have a main.c where errno is defined with errno.h, and the
    assembler subroutine which needs to be able to modify errno.
    I assemble the procedure into a .o file, then use cc to compile
    main.c and link it to the .o file. Does anyone have a fully
    detailed example of what I need to do to accomplish this?

  2. Re: Importing C extern errno into HP-UX assembler

    marnol01@mail.win.org writes:

    > I have tried many various .IMPORT statements and intsructions
    > to import the C extern errno variable into a PA-RISC assembler
    > procedure in order to modify errno from the assembler program.
    > So far, everything I've tried either has no effect or causes
    > the program to crash. This is for a PA-RISC 1.1 architecture.
    > I have a main.c where errno is defined with errno.h, and the
    > assembler subroutine which needs to be able to modify errno.
    > I assemble the procedure into a .o file, then use cc to compile
    > main.c and link it to the .o file. Does anyone have a fully
    > detailed example of what I need to do to accomplish this?


    Compile the following code to assembly (with 'cc -S t.c'):

    #include
    void foo() { errno = 42; }

    The resulting assembly is *exactly* what you need.
    The proof:

    $ cat t1.c
    #include
    int main()
    {
    foo();
    printf("%d\n", errno);
    return 0;
    }

    $ cc -S t.c && cc -c t.s && cc t1.c t.o && ./a.out
    42

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: Importing C extern errno into HP-UX assembler

    Super! The resulting assembler listing showed me how to fix up my
    assembler subroutine.

    Thanks!

    Mike


    Paul Pluzhnikov wrote:
    > marnol01@mail.win.org writes:
    >
    > > I have tried many various .IMPORT statements and intsructions
    > > to import the C extern errno variable into a PA-RISC assembler
    > > procedure in order to modify errno from the assembler program.
    > > So far, everything I've tried either has no effect or causes
    > > the program to crash. This is for a PA-RISC 1.1 architecture.
    > > I have a main.c where errno is defined with errno.h, and the
    > > assembler subroutine which needs to be able to modify errno.
    > > I assemble the procedure into a .o file, then use cc to compile
    > > main.c and link it to the .o file. Does anyone have a fully
    > > detailed example of what I need to do to accomplish this?

    >
    > Compile the following code to assembly (with 'cc -S t.c'):
    >
    > #include
    > void foo() { errno = 42; }
    >
    > The resulting assembly is *exactly* what you need.
    > The proof:
    >
    > $ cat t1.c
    > #include
    > int main()
    > {
    > foo();
    > printf("%d\n", errno);
    > return 0;
    > }
    >
    > $ cc -S t.c && cc -c t.s && cc t1.c t.o && ./a.out
    > 42
    >
    > Cheers,
    > --
    > In order to understand recursion you must first understand recursion.
    > Remove /-nsp/ for email.


+ Reply to Thread