Chapter Contents

Previous

Next
Communication with Assembler Programs

Adding Assembler Routines to C Programs

Most existing assembler routines can be called from C with little modification, if any. Furthermore, assembler routines called from C can call other C routines if, when C is called, register 12 has the same value that it had when the first assembler routine was entered. (Additional restrictions apply if one of the run-time linkage options =optimize or =minimal is in use, as described later in this chapter.) In compiled code, general register 12 always addresses a block of data known as the C Run-Time Anchor Block (CRAB). The CRAB is explained in detail in The C Run-Time Anchor Block.


Adding Existing Assembler Routines to C Programs

Many existing assembler routines can be called from C without modification. Unless the routine expects a normal C parameter list, you may need to use one or more of the @ operators or the _ _asm , _ _ref , or _ _ibmos keywords to cause the compiler to create the parameter list in the format expected by the assembler routine.


Adding New Assembler Routines to C Programs

Writing an assembler routine for use only by C programs is a relatively simple task. In general, the routine should expect a normal C parameter list and follow the register conventions described earlier. Assembler routines can call functions written in C if general register 12 addresses the CRAB when the C function is called. If the CENTRY and CEXIT macros are used, C library functions can be called.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.