Download "user manual"
Transcript
Dynamic functions such as printf Table 2: dinkusr.s Functions Function name Function definition write_char DINK32 put character to the output buffer. The simple steps for using these dynamic addresses are: 1. Use DINK32 V11.1 or later. 2. Use #define for local functions that you wish to connect to the DINK32 functions example: #define printf dink_printf 3. The first executable statement in your C code must be: set_up_transfer_base(); 4. Now whenever your program calls one of these functions, such as printf, it will transfer control to the equivalent DINK32 function. G.5 Error Conditions. The only error condition is a trapword exception, which indicates that the dink_transfer_table address is zero. This is caused by one of the following conditions: 1. The user has not called set_up_transfer_base() 2. R12 is getting trashed before set_up_transfer_base() is called. 3. The DINK32 version does not support dynamic functions. DINK32 V11.0.2 was the last version that DID NOT support this feature. Ensure that you are using DINK32 V12.0 or greater. G.6 Alternative method for Metaware only. While printf is fairly straightforward, scanf is more complex. In the drystone directory, a local copy of scanf is supplied in the file, support.c. Scanf and printf can also be emulated in a simpler program when using the metaware compiler. Two metaware functions are supplied to the user to give control to characters that are scanned into and out of the program buffers. Refer to the metaware documentation for more information than is given here. When the user compiles and links with the -Hsds flag, two functions, int _putcanon(int a), and int _getcanon() are called whenever the user gets or receives a character. Thus, the user can write the simple functions shown below, and scanf and printf will use the DINK32 functions for printf and scanf. In this case, it is not necessary to use #define to change the name of the printf or scanf functions or write your own printf or scanf function. It is still necessary to call set_up_transfer_base() as the first statement in your program. 10G-110 Dink32 R12 User’s Manual