Keil Logo

LARGE 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  XDATA: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
00000D 7C7B          46             MOV      R7,R11
00000F 900000     E  47             MOV      DPTR,#WORD0 val
000012 E0            48             MOVX     A,@DPTR    ; A=R11
000013 2CB7          49             ADD      R11,R7
000015 F0            50             MOVX     @DPTR,A    ; A=R11
                     51     ; func2 returns a integer in WR6
000016 1A3B          52             MOVS     WR6,R11
000018 22            53             RET
                     54             ENDP
                     55
                     56             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.