Keil™, An ARM® Company

Cx51 User's Guide

Interfacing C programs to PL/M-51

Intel's PL/M-51 is a popular programming language that is similar to C in many ways. You can easily interface the Cx51 Compiler to routines written in PL/M-51.

  • You can access PL/M-51 functions from C by declaring them with the alien function type specifier.
  • Public variables declared in the PL/M-51 module are available to your C programs.
  • The PL/M-51 compiler generates object files in the OMF-51 format.

The Cx51 Compiler can generate code using the PL/M-51 parameter passing conventions. The alien function type specifier is used to declare public or external functions that are compatible with PL/M-51 in any memory model. For example:

extern alien char plm_func (int, char);

alien unsigned int c_func (unsigned char x, unsigned char y)  {
  return (x * y);
}

Parameters and return values of PL/M-51 functions may be any of the following types: bit, char, unsigned char, int, and unsigned int. Other types, including long, float, and all types of pointers, can be declared in C functions with the alien type specifier. However, use these types with care because PL/M-51 does not directly support 32-bit binary integers or floating-point numbers.

Note

  • PL/M-51 does not support variable-length argument lists. Therefore, functions declared using the alien type specifier must have a fixed number of arguments. The ellipsis notation used for variable-length argument lists is not allowed for alien functions and causes the Cx51 Compiler to generate an error message. For example:
    extern alien unsigned int  plm_i (char, int, ...);
    
    *** ERROR IN LINE 1 OF A.C: 'plm_i': Var_parms on alien function