Keil Logo

Using the SRC Directive

The SRC directive instructs the C251 compiler to generate an assembly routine instead of an object module. You may use this directive to generate the shell of an assembly source file or to help you determine the parameter passing conventions the compiler expects.

To create an assembly source file, you must use the SRC directive with the C251 Compiler. For example:

#pragma SRC   /* the SRC directive generates assembler output */
#pragma XTINY /* specify the memory model you want to use     */

unsigned int asmfunc1 (unsigned int arg)  {
  return (1 + arg);
}

generates the following assembly output file:

        $NOMACRO
$MODSRC
$MODEL(5)
$CASE
;
; 'ASM1.SRC' generated from 'ASM1.C'
; COMPILER INVOKED BY:
;        C:\C251\BIN\C251V2.EXE ASM1.C
;
                NAME ASM1
        ?PR?ASMFUNC1?ASM1  SEGMENT  CODE

;--- special function registers and bits:
             ACC  DATA  0E0H
             PSW  DATA  0D0H
             DPL  DATA  082H
             DPH  DATA  083H
               B  DATA  0F0H
              SP  DATA  081H
            PSW1  DATA  0D1H
               Z  BIT   0D1H.1
              EA  BIT   0A8H.7
;--- end of special function registers and bits.

        PUBLIC        asmfunc1
; line 1: #pragma SRC   /* the SRC directive generates assembler output */
; line 2: #pragma XTINY /* specify the memory model you want to use     */
; line 3:
; line 4:
; line 5: unsigned int asmfunc1 (unsigned int arg)  {
        RSEG       ?PR?ASMFUNC1?ASM1
     USING  0
        asmfunc1 PROC
;---- Variable 'arg' assigned to Register 'WR6' ----
; line 6:   return (1 + arg);
        INC      WR6,#01H
; line 7: }
        RET
        ENDP
        END
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.