home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_37.arc
/
86WRLD37.FIG
next >
Wrap
Text File
|
1987-08-05
|
3KB
|
78 lines
Listing 2 - ASM file for EXE2LNK example
CODE SEGMENT
ASSUME CS:CODE
Link EQU 6 ; CS, IP and BP
Example STRUC ; structure to address exported statics
count1 DW ?
count2 DW ?
Example ENDS
Param1 STRUC ; structure to address Proc1 parameters
DB Link DUP (?) ; account for CS, IP and BP
index1 DW ?
Param1 ENDS
Param2 STRUC ; structure to address Proc2 parameters
DB Link DUP (?) ; account for CS, IP and BP
value2 DD ? ; VAR parameter - takes up 2 words on stack
index2 DW ? ; 1 word for offset, 1 for segment
Param2 ENDS
ORG 0
DATA LABEL WORD ; at runtime 'm2' is replaced by
; segment address of exported data
DB 'm2' ; for id by EXE2LNK
DW SIZE Example ; size of definition module data
DW 2 ; number of procedures
DW Proc1 ; procedure 1 address
DW Proc2 ; procedure 2 address
DW Init ; initialization code address
Table DW 2, 3, 5, 7 ; some table
DW 11, 13, 17, 19
DW 23, 29, 31, 37
DW 41, 43, 47, 53
Proc1 PROC FAR ; Proc1 code
PUSH BP
MOV BP,SP
MOV DS,DATA ; static data segment
INC DS:[0].count1 ; INC(count1)
MOV BX,[BP].index1 ; get index parameter
SHL BX,1 ; make word offset
MOV BX,Table[BX] ; function result is returned in BX
POP BP
RET SIZE Param1-Link; return and pop parameters
Proc1 ENDP
Proc2 PROC FAR ; Proc2 code
PUSH BP
MOV BP,SP
MOV DS,DATA ; static data segment
INC DS:[0].count2 ; INC(count2);
MOV BX,[BP].index2 ; get index parameter
SHL BX,1 ; make word offset
MOV BX,Table[BX] ; move table value to BX
LDS SI,[BP].value2 ; get address of VAR parameter
MOV DS:[SI],BX ; store table value
POP BP
RET SIZE Param2-Link; return and pop parameters
Proc2 ENDP
Init PROC FAR ; initialization code
MOV DS,DATA ; static data segment
MOV AX,0
MOV DS:[0].count1,AX; count1 := 0;
MOV DS:[0].count2,AX; count2 := 0;
RET
Init ENDP
CODE ENDS
END