Download Target Language Compiler Reference Guide
Transcript
3 Code Generation Architecture Code Generation Concepts The Target Language Compiler uses a target language that is a general programming language, and you can use it as such. It is important, however, to remember that the Target Language Compiler was designed for one purpose: to convert a model.rtw file to generated code. Thus, the target language provides many features that are particularly useful for this task but does not provide some of the features that other languages like C provide. Before you start modifying or creating target files for use within the Real-Time Workshop, you might find some of the following general programming examples useful to familiarize yourself with the basic constructs used within the Target Language Compiler. Output Streams The typical “Hello World” example is rather simple in the target language. Type the following in a file named hello.tlc %selectfile STDOUT Hello, World To run this Target Language Compiler program, type tlc hello.tlc at the MATLAB prompt. This simple program demonstrates some important concepts underlying the purpose (and hence the design) of the Target Language Compiler. Since the primary purpose of the Target Language Compiler is to generate code, it is output (or stream) oriented. It makes it easy to handle buffers of text and output them easily. In the above program, the %selectfile directive tells the Target Language Compiler to send any following text that it does not recognize to the standard output device. All syntax that the Target Language Compiler recognizes begins with the % character. Since Hello, World is not recognized, it is sent directly to the output. You could just as easily change the output destination to be a file. 3-8
Related documents