Linking External 'C' Programs into APPX


The ability to invoke external programs and routines written in ‘C’ is available from within APPX. Once the code has been compiled, it can be called anywhere within APPX ILF code with the “CALL” statement.

Due to the method of linking on the IBM RS6000 machines, any externally executable program can be called directly from the ILF code without having to compile and link it into the APPX engine. On all other platforms, to make the required code executable from within APPX, we have provided a stub program named ‘call.c’ in which you can include your required code. This program is included in the “linkable” subdirectory created below the directory into which you installed APPX.

To call a routine from the ‘call.c’ program, put the code you want to call within the program and make entries in the places indicated. Refer to the examples hello and get_addr included with your installation materials.

Then, compile the code and link it to the engine by issuing the following command:

make appx -f Makefile.callable

 

This will compile the file ‘call.c’ and then link the executable code into the APPX engine.

To call the required routine, for example hello, you insert a CALL statement within the ILF code where you want the routine to be called. In the case of the hello routine, the line would be:

CALL .hello RESIDENT? N END? N FAIL 0

 

Another example is included called get_addr which will return the address of the first parameter passed to it as the second parameter. The necessary PASS and CALL statements to execute this routine are:      

TRAP

PASS --- TEMP 79 FIELD SHARE? Y

PASS —-- AI FIELD SHARE? Y

CALL .get_addr RESIDENT? N END? N FAIL? 0

SET —-- AI = -— AI

 

This will show that AI, initially zero, will contain the address of TEMP 79 upon returning from get_addr.

Note that the leading period in the CALL statement for the function is required.