|
| MEDIUM Model
LOC OBJ LINE SOURCE
1 ; A166 must be CASE sensitive for interfacing with C166.
2 $CASE
3 ; MEDIUM 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 : FAR
25 EXTRN val : WORD ; near value based DPP2
26 EXTRN flag : BIT
27
28 ?PR?A166_modul SECTION CODE 'NCODE'
29
30 PUBLIC func2 ; entry point for func2
31
32 func2 PROC FAR
33 ;---- Variable 'x2' is passed in Register 'R9'.
34 ;---- Variable 'x1' is passed in Register 'R8'.
0000 ECFF 35 PUSH R15 ; Save R15 because of Bit Parameter
0002 A899 36 MOV R9,[R9]
0004 A888 37 MOV R8,[R8]
0006 4A??FF?0 E 38 BMOV R15.0,flag
000A DA?????? E 39 CALLS SEG (func1), func1
40 ;---- The function value of 'func1' is returned in Register 'R4'.
41 ;---- temporary Variable 'y' is saved in Register 'R5'.
000E 04F4???? E 42 ADD DPP2:val,R4 ; NEAR variable requires DPP2
43
0012 FCFF 44 POP R15 ; restore R15
45 ;---- The function value 'y' is placed in 'R4'
0014 DB00 46 RETS
47
48 func2 ENDP
49
50 ?PR?A166_modul ENDS
51
52 END
|
|