Keil Logo

SMALL Model

LOC    OBJ         LINE     SOURCE

                      1     $CASE ; make CASE sensitive for C interface
                      2
                      3                     NAME A251_MODULE
                      4
                      5     ; /***********************************/
                      6     ; /* Sample Assembler to C Interface */
                      7     ; /***********************************/
                      8     ;
                      9     ; extern char func1 (int a1, char a2, bit b);
                     10     ;
                     11     ; extern bit flag;
                     12     ; extern char val;
                     13     ;
                     14     ; int func2 (int *ip, char *cp)  {
                     15     ;   char c;
                     16     ;
                     17     ;   c = func1 (*ip, *cp, flag);
                     18     ;   val += c;
                     19     ;   return (val);
                     20     ; }
                     21
                     22
                     23     EXTRN  BIT        (flag)
                     24     EXTRN  DATA :BYTE (val)
                     25     EXTRN  CODE :NEAR (func1)
                     26     EXTRN  BIT        (?func1?BIT)
                     27
------               28     ?PR?FUNC2?ASM1  SEGMENT  CODE
                     29
                     30     PUBLIC func2  ; entry point for func2
                     31
------               32             RSEG       ?PR?FUNC2?ASM1
                     33     func2 PROC NEAR
                     34     ; Variable 'cp' is passed in Register 'DR4'
                     35     ; Variable 'ip' is passed in Register 'DR0'
                     36
                     37     ; func1 is called with parameters
                     38     ; copy flag to parameter area
                     39     ; all other parameters are passed in registers
000000 A200       E  40             MOV      C,flag
000002 9200       E  41             MOV      ?func1?BIT,C
000004 7E1BB0        42             MOV      R11,@DR4
000007 0B0A30        43             MOV      WR6,@DR0
00000A 120000     E  44             LCALL    func1
                     45     ; func1 returns a character in R11 (same as A)
00000D 2500       E  46             ADD      A,val
00000F F500       E  47             MOV      val,A
                     48     ; func2 returns a integer in WR6
000011 1A3B          49             MOVS     WR6,R11
000013 22            50             RET
                     51             ENDP
                     52
                     53             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.