summaryrefslogtreecommitdiffstats
path: root/private/mvdm/wow16/write/msseqds.asm
blob: acb4843fdba3a74b1c1b22031529a6ddcc89ee4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
        title   Special Export call locations for DS == SS conversion.

; Windows Write, Copyright 1985-1992 Microsoft Corporation

?DF  = 1                     ; Dont generate default segment definitions
?PLM = 1
        .XLIST
        include cmacros.inc
        .LIST

        subttl  Define Windows Groups
        page

MGROUP      group   HEADER,EXPORTS,IMPORTS,IMPORTEND,ENDHEADER
IGROUP      group   _TEXT,_INITTEXT,_ENDTEXT
DGROUP      group   _DATA,DATA,CDATA,CONST,_BSS,c_common,_INITDATA,_ENDDATA,STACK
HEADER      segment para 'MODULE'
HEADER      ENDS
EXPORTS     segment byte 'MODULE'
EXPORTS     ENDS
IMPORTS     segment byte public 'MODULE'
IMPORTS     ENDS
IMPORTEND   segment byte 'MODULE'
IMPORTEND   ENDS
ENDHEADER   segment para 'MODULE'
ENDHEADER   ENDS
_TEXT       segment byte public 'CODE'
_TEXT       ENDS
_INITTEXT   segment para public 'CODE'
_INITTEXT   ends
_ENDTEXT    segment para 'CODE'
_ENDTEXT    ends

_DATA       segment para public 'DATA'

STACKSIZE   =   2048

$$STACK     dw  STACKSIZE   dup (?)
$$STACKTOP  label   word
            dw  0

_DATA       ends

DATA        segment para public 'DATA'
DATA        ends
CDATA       segment word common 'DATA'      ; C globals end up here
CDATA       ends
CONST       segment word public 'CONST'
CONST       ends
_BSS        segment para public 'BSS'
_BSS        ends
c_common    segment para common 'BSS'       ; C globals end up here
c_common    ends
_INITDATA   segment para public 'BSS'
_INITDATA   ends
_ENDDATA    segment para 'BSS'
_ENDDATA    ends

STACK       segment para stack 'STACK'
            DB      0                       ; Force link to write entire DGROUP
STACK       ends

        subttl  ENTRYPOINT definition
        page

ENTRYPOINT  MACRO   name, cwArgs
        extrn   x&name:far
        public  name
name    proc    far
        mov     ax,ds               ; we have to include all this code
        nop                         ; or exe2mod chokes
        inc     bp
        push    bp
        mov     bp,sp
        push    ds
        mov     ds,ax

        mov     cx,cwArgs * 2
        mov     dx,offset igroup:x&name
        jmp     SetLocStack
name    endp

        ENDM

        subttl  external->local stack switcher
        page

_TEXT   segment byte public 'CODE'
        assume  cs:igroup, ds:dgroup, es:dgroup, ss:nothing

;
; SetLocStack
;
;       Purpose:        To switch to a seperate stack located in the
;                       Modules Data Segment.
;
;       Inputs:         AX = module's DS
;                       SS, SP, BP = caller's stack stuff
;                       DS = "true" entry point addr
;                       cx = no. of bytes of parameters on caller's stack
;
SetLocStack  proc    near
        mov     bx,ss                   ; get copy of current segment
        cmp     ax,bx                   ; see if we're already in local stack
        je      inlocal                 ; we are - fall into existing code

        mov     cs:SESPat,cx            ; save arg byte count for return

        mov     ss,ax
        mov     sp,offset dgroup:$$STACKTOP

        push    bx                      ; save old ss
        sub     bp,2                    ; point at the pushed ds
        push    bp                      ; and  old sp
        push    si                      ; save si

        jcxz    argdone

        mov     ds,bx
        lea     si,[bp + 8 - 2]         ; point past ds, bp, far addr to args
        add     si,cx                   ; point at top of args for backward move

        std
        shr     cx,1                    ; divide byte count by two
        jcxz    argdone
argloop:
        lodsw
        push    ax
        loop    argloop
        cld

argdone:
        push    cs
        mov     ax,offset igroup:SetExtStack  ; push setextstack return addr
        push    ax

        mov     ax,ss                   ; get new ds into ds and ax
        mov     ds,ax

        push    dx                      ; jump to true entry point via RET
        ret

inlocal:
        add     dx,10                   ; point past prolog code
        push    dx                      ; jump into middle of prolog code
        ret

SetLocStack     endp

SetExtStack     proc    near
        pop     si                      ; get back saved si
        pop     bp                      ; get old sp
        pop     bx                      ; and old ss

        mov     ss,bx
        mov     sp,bp                   ; now set up the suckers

        pop     ds                      ; standard epilog stuff
        pop     bp
        dec     bp

        db      0cah                    ;RETF n instruction
SESPat  dw      0

SetExtStack     endp

        subttl  Entry point definitions
        page
;
; mp module entry points
;
ENTRYPOINT MMpNew,    3
ENTRYPOINT MMpLoad,   2
ENTRYPOINT MMpFree,   2
;
; routines called by interface module
;
ENTRYPOINT MRgchVal, 6
ENTRYPOINT Mdecode,  2
ENTRYPOINT MEnter,   1
ENTRYPOINT Fill,     1
ENTRYPOINT Clear,    0
ENTRYPOINT Format,   1
ENTRYPOINT MCellsContract, 0
ENTRYPOINT MInsertBents,   8
ENTRYPOINT MSheetCut, 0
ENTRYPOINT MSheetCopy, 0
ENTRYPOINT MSheetPaste, 1
ENTRYPOINT MExeCut, 0
ENTRYPOINT MExePaste, 0
ENTRYPOINT CheckRecalc, 0
ENTRYPOINT recalc, 1
ENTRYPOINT MLoadSheet, 2
ENTRYPOINT MSaveSheet, 3
ENTRYPOINT MSortDialog, 4


_TEXT   ENDS

        end