home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_37.arc / 86WRLD37.FIG next >
Text File  |  1987-08-05  |  3KB  |  78 lines

  1.  
  2. Listing 2 - ASM file for EXE2LNK example 
  3.  
  4. CODE    SEGMENT
  5.         ASSUME  CS:CODE
  6.  
  7. Link    EQU     6               ; CS, IP and BP
  8.  
  9. Example STRUC                   ; structure to address exported statics
  10. count1  DW      ?
  11. count2  DW      ?
  12. Example ENDS
  13.  
  14. Param1  STRUC                   ; structure to address Proc1 parameters
  15.         DB      Link DUP (?)    ; account for CS, IP and BP
  16. index1  DW      ?
  17. Param1  ENDS
  18.  
  19. Param2  STRUC                   ; structure to address Proc2 parameters
  20.         DB      Link DUP (?)    ; account for CS, IP and BP
  21. value2  DD      ?               ; VAR parameter - takes up 2 words on stack
  22. index2  DW      ?               ; 1 word for offset, 1 for segment
  23. Param2  ENDS
  24.  
  25.  
  26.         ORG     0
  27. DATA    LABEL   WORD            ; at runtime 'm2' is replaced by
  28.                                 ; segment address of exported data
  29.         DB      'm2'            ; for id by EXE2LNK
  30.         DW      SIZE Example    ; size of definition module data
  31.         DW      2               ; number of procedures
  32.         DW      Proc1           ; procedure 1 address
  33.         DW      Proc2           ; procedure 2 address
  34.         DW      Init            ; initialization code address
  35.  
  36. Table   DW       2,  3,  5,  7  ; some table
  37.         DW      11, 13, 17, 19
  38.         DW      23, 29, 31, 37
  39.         DW      41, 43, 47, 53
  40.  
  41. Proc1   PROC    FAR             ; Proc1 code
  42.         PUSH    BP
  43.         MOV     BP,SP
  44.         MOV     DS,DATA         ; static data segment
  45.         INC     DS:[0].count1   ; INC(count1)
  46.         MOV     BX,[BP].index1  ; get index parameter
  47.         SHL     BX,1            ; make word offset
  48.         MOV     BX,Table[BX]    ; function result is returned in BX
  49.         POP     BP
  50.         RET     SIZE Param1-Link; return and pop parameters
  51. Proc1   ENDP
  52.  
  53. Proc2   PROC    FAR             ; Proc2 code
  54.         PUSH    BP
  55.         MOV     BP,SP
  56.         MOV     DS,DATA         ; static data segment
  57.         INC     DS:[0].count2   ; INC(count2);
  58.         MOV     BX,[BP].index2  ; get index parameter
  59.         SHL     BX,1            ; make word offset
  60.         MOV     BX,Table[BX]    ; move table value to BX
  61.         LDS     SI,[BP].value2  ; get address of VAR parameter
  62.         MOV     DS:[SI],BX      ; store table value
  63.         POP     BP
  64.         RET     SIZE Param2-Link; return and pop parameters
  65. Proc2   ENDP
  66.  
  67. Init    PROC    FAR             ; initialization code
  68.         MOV     DS,DATA         ; static data segment
  69.         MOV     AX,0
  70.         MOV     DS:[0].count1,AX; count1 := 0;
  71.         MOV     DS:[0].count2,AX; count2 := 0;
  72.         RET
  73. Init    ENDP
  74.  
  75. CODE    ENDS
  76.         END
  77.  
  78.