Hi Paul,

I did something similar.  Except I took C source, compiled it under Linux,
used TAS to assemble it, and linked it up on OS/390 to produce non-LE based
zlib and bzip2 libraries.  You can find the libraries in the assembler
section over at http://www.homerow.net, but here's a snippet from the readme
that might help you out:

HOW TO USE

    Since GCC was used to build the object, the standard OS linkage
    conventions are not used.  You will need to pay attention to a
    few things when using the library.

    First, you HAVE to provide a stack before calling any of the
    functions.  A 4096 byte stack seems to be sufficient.

    The address of the stack is placed in register R15 and, since the
    stack is of the top-down variety, the address MUST point to the
    end of the stack minus the first frame.  Each frame is 96 bytes
    unless a function requires more than 5 parameters.

    For instance, calling BZ2_bzBuffToBuffCompress() would require you
    to reserve the standard 96 bytes, plus 8 more since it has 7
    parameters.  So:

        L        R15,Stkptr             Get address of stack
        AL       R15,=F'4096'           Point to end of stack
        SL       R15,=F'104'            Reserve first frame
        ...                             Setup function parms and call

    The first 5 parameters of a function are passed in registers R2
    through R6.  Remaining parameters are placed on the stack starting
    at offset +96.  So, calling BZ2_bzBuffToBuffCompress() would require
    the stack setup above and:

        L        R2,dest                Destination buffer
        LA       R3,destLen             Pointer to destination length
        L        R4,source              Source buffer
        L        R5,sourceLen           Source length
        L        R6,blockSize100k       Block size (compression level)
        MVC      96(4,R15),verbosity    Monitoring/debugging level
        MVC      100(4,R15),workFactor  "Speed control"  ;-)
        ...                             Call function

    The functions use register R14 for the return address, so to call
    the BZ2_bzBuffToBuffCompress() function, do the above setup and:

        L        R1,funcptr             Load function ptr (use any reg)
        BASR     R14,R1                 Call the function

    For functions that return a value, register R2 will contain the
    value upon return.

    Finally, registers R0 through R5 are considered fair game and may
    be destroyed by the functions, so it is important that you preserve
    any contents prior to calling a function.

Others will have to address your 24/31 bit problem, but I would expect that
you'd be okay as long as you didn't use the high byte for addresses for
anything weird.

Leland

Reply via email to