Abstract

Before understanding the implementation of C procedures it is necessary to understand how C allocates and accesses global and local variables. Global variables, which are declared outside a procedure, can be allocated by the compiler by the equivalent of assembly language ORG statement and define space (DS) statements. Local variables that are declared within, and are generally at the beginning of a procedure are allocated at run time by the means of a LEAS statement. A C program can have global variables, and global constants. Global constants are initialized by writing them into RAM when the program is downloaded or in ROM in a standalone microcontroller. A C procedure is generally called using a JSR or BSR instruction, with the input arguments pushed on the stack. The return value of a function is generally left in accumulator D. If the input argument is a vector, or an “&” sign appears before the name, then the address is passed on the stack, using call by name; otherwise the data themselves are pushed on the stack, using call by value. C++ generally has similar operators and implements them in assembly language in similar ways.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call