Keil Logo

COMPACT Model

LOC  OBJ       LINE     SOURCE
                  1     ; A166 must be CASE sensitive for interfacing with C166.
                  2     $CASE
                  3     ; COMPACT model works in SEGMENTED mode of the 80C166.
                  4     $SEGMENTED
                  5
                  6                     NAME    A166_modul
                  7     ;  /***********************************/
                  8     ;  /* Sample Assembler to C Interface */
                  9     ;  /***********************************/
                 10     ;
                 11     ;  extern int func1 (int a1, int a2, bit b);
                 12     ;
                 13     ;  extern bit flag;
                 14     ;  extern int near val;
                 15     ;
                 16     ;  int func2 (int *x1, int *x2)  {
                 17     ;    int y;
                 18     ;
                 19     ;    y = func1 (*x1, *x2, flag);
                 20     ;    val += y;
                 21     ;    return (y);
                 22     ;  }
                 23
                 24     EXTRN   func1 : NEAR
                 25     EXTRN   val   : WORD        ; near value based DPP2
                 26     EXTRN   flag  : BIT
                 27
                 28     ?PR?A166_modul  SECTION CODE 'NCODE'
                 29     NCODE           CGROUP  ?PR?A166_modul
                 30
                 31     PUBLIC          func2           ; entry point for func2
                 32
                 33     ASSUME  DPP3:SYSTEM             ; required for SFR accesses
                 34
                 35     func2           PROC    NEAR
                 36     ;---- Variable 'x2' is a far * and passed in Register 'R10, R11'.
                 37     ;---- Variable 'x1' is a far * and passed in Register 'R8, R9'.
0000 ECFF        38                     PUSH    R15     ; Save R15 because of Bit Parameter
0002 F6F900FE    39                     MOV     DPP0,R9
0006 CC00        40                     NOP
0008 A888        41                     MOV     R8,[R8]
000A F6FB00FE    42                     MOV     DPP0,R11
000E CC00        43                     NOP
0010 A89A        44                     MOV     R9,[R10]
0012 4A??FF?0 E  45                     BMOV    R15.0,flag
0016 CA00???? E  46                     CALLA   cc_UC,func1
                 47     ;---- The function value of 'func1' is returned in Register 'R4'
                 48     ;---- temporary Variable 'y' is saved in Register 'R5'.
001A 04F4???? E  49                     ADD     DPP2:val,R4   ; NEAR variable requires DPP2
                 50
001E FCFF        51                     POP     R15     ; restore R15
                 52     ;---- The function value 'y' is placed in 'R4'
0020 CB00        53                     RET
                 54     func2           ENDP
                 55
                 56     ?PR?A166_modul  ENDS
                 57
                 58                     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.