home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v5.zip / TOOLKT21 / ASM / SAMPLES / PDD / PDD.INC < prev    next >
Text File  |  1993-03-12  |  16KB  |  406 lines

  1. ;       SCCSID = @(#)pdd.inc    6.1 91/12/19
  2. ;***    TCA.INC
  3. ;
  4. ;
  5. ;       MVDM Physical 3270 Device Driver Exported Definitions
  6. ; ***************************************************************************
  7. ;                                                                           *
  8. ;                        IBM/Microsoft Confidential                         *
  9. ;                                                                           *
  10. ;                  Copyright (c) IBM Corporation  1987, 1990                *
  11. ;                            All Rights Reserved                            *
  12. ;                                                                           *
  13. ; ***************************************************************************
  14. ;
  15. ;
  16. ;
  17. ;
  18.  
  19.  
  20.   ?CS_16bit equ 0         ; constants for ?cstype
  21.   ?CS_32bit equ 1
  22.   ?cstype  = ?CS_16bit
  23.  
  24.   ;***    TCA constants
  25.   ;
  26.  
  27.  
  28.   ;***    TCA data types
  29.   ;
  30.  
  31.  
  32.   ;***    TCA function prototypes
  33.   ;
  34.   setDS   MACRO   segname
  35.           push    ax
  36.           mov     ax,segname
  37.           mov     ds,ax
  38.           pop     ax
  39.           ASSUME  ds:segname
  40.           endm
  41.  
  42.   Stack_Data      struc
  43.           old_bp  dw      ?
  44.           old_cs  dd      ?
  45.           old_ip  dd      ?
  46.           ul2     dd      ?
  47.           ul1     dd      ?
  48.           uFunc   dd      ?
  49.   Stack_Data      ends
  50.  
  51.   Flat_Pointer    struc
  52.           fp_offlo        DW      ?
  53.           fp_offhi        DW      ?
  54.           fp_sel          DW      ?
  55.   Flat_Pointer    ends
  56.  
  57.   PhysAddr struc
  58.           _lo     dw      (?)     ; low word of a 32-bit pointer
  59.           _hi     dw      (?)     ; high word of a 32-bit pointer
  60.   PhysAddr ends
  61.  
  62.  
  63.  
  64. ; Procedure macro   name,distance,scope,treg,abase,blank
  65. ; ifdef ALIGNCODE
  66. ;     align 4
  67. ; endif
  68. ;     ProcError macro msg
  69. ; %       %out @FileName.asm: Error in Procedure name: msg
  70. ;     endm
  71. ; ;   if2
  72. ; ;       ifnb <treg>
  73. ; ;           ProcError <treg_arg must be _blank: treg>
  74. ; ;           .err
  75. ; ;       endif
  76. ; ;       ifnb <blank>
  77. ; ;           ProcError <Too many parameters>
  78. ; ;           .err
  79. ; ;       endif
  80. ; ;       if ?depth gt 1
  81. ; ;           ProcError <Nesting too deep>
  82. ; ;           .err
  83. ; ;       endif
  84. ; ;   endif
  85. ;     ?depth       = ?depth + 1
  86. ;     ?olddistance = ?distance    ;; save previous value
  87. ;     ?frame       = 0
  88. ;     ?aframe      = 0
  89. ;     ?initstack   = ?stackdepth  ;; beginning of procedure
  90. ;     ?local       = 0            ;; default to public
  91. ;     ?distance    = 0            ;; default is set elsewhere
  92. ;     ?argfar      = 0            ;; okay to use ArgVar
  93. ;     ?nfields     = 0            ;; used here to count ArgVars
  94. ;     ?name        equ <name>     ;; save current procedure name
  95. ;     ?wdsz        = 2            ;; default word size
  96. ;     if (?cstype eq ?CS_32bit)
  97. ;         ?wdsz = 4
  98. ;     endif
  99. ;     ifnb <scope>
  100. ;         irp x,<scope>
  101. ;             ifidni <x>,<nearlocal>              ;; near is local
  102. ;                 ?local = ?local or ?LC_NEARLOCAL
  103. ;             elseifidni <x>,<far16local>         ;; far16 is local
  104. ;                 ?local = ?local or ?LC_FAR16LOCAL
  105. ;             elseifidni <x>,<far32local>         ;; far16 is local
  106. ;                 ?local = ?local or ?LC_FAR32LOCAL
  107. ;             elseifidni <x>,<farlocal>           ;; faronly is local
  108. ;                 ?local = ?local or ?LC_FARLOCAL
  109. ;             elseifidni <x>,<local>              ;; all are local
  110. ;                 ?local = ?local or ?LC_NEARLOCAL or ?LC_FARLOCAL \
  111. ;                                 or ?LC_FAR16LOCAL or ?LC_FAR32LOCAL \
  112. ;                                 or ?LC_LOCAL
  113. ;             elseif2
  114. ;                 ProcError <Bad scope_arg: x>
  115. ;                 .err
  116. ;             endif
  117. ;         endm
  118. ;     endif
  119. ;     .lall
  120. ;     ?bm1 = ?local                               ;; only for listing files
  121. ;     .xall
  122. ;
  123. ;     ifnb <distance>
  124. ;         irp x,<distance>
  125. ;             ifidni <x>,<near>           ;; is near
  126. ;                 ?distance = ?distance or ?PD_NEAR or ?PD_DIST
  127. ;             elseifidni <x>,<far16>      ;; is 16 bit callable from 32
  128. ;                 ?distance = ?distance or ?PD_FAR16 or ?PD_DIST
  129. ;             elseifidn <x>,<far32>       ;; is 32 bit callable from 16
  130. ;                 ?distance = ?distance or ?PD_FAR32 or ?PD_DIST
  131. ;             elseifidni <x>,<far>        ;; is 16 bit far
  132. ;                 ?distance = ?distance or ?PD_FAR or ?PD_DIST
  133. ;             elseifidni <x>,<faronly>    ;; is 16 bit faronly
  134. ;                 ?distance = ?distance or ?PD_FARONLY or ?PD_DIST
  135. ;             elseifidni <x>,<hybrid>     ;; is 16-bit near/faronly hybrid
  136. ;                 ?distance = ?distance or ?PD_NEAR or ?PD_FARONLY or ?PD_DIST
  137. ;             elseifidn <x>,<cdecl>       ;; is cdecl (caller cleanup)
  138. ;                 ?distance = ?distance or ?PD_CDECL
  139. ;             elseifidn <x>,<pascal>      ;; is pascal (callee cleanup)
  140. ;                 ?distance = ?distance or ?PD_PASCAL
  141. ;             elseif2
  142. ;                 ProcError <Bad distance_arg: x>
  143. ;                 .err
  144. ;             endif
  145. ;         endm
  146. ;
  147. ;         ;; If both types of 16 bit thunks are required, add a near
  148. ;         ;; procedure body, and have both thunks call it near:
  149. ;
  150. ;         if ((?distance and ?PD_DISTMASK) eq (?PD_FAR16 or ?PD_FARONLY))
  151. ;             ?distance = ?distance or ?PD_NEAR
  152. ;         endif
  153. ;
  154. ;         if2
  155. ;             ;; Disallow 16 bit thunks in 32 bit code.
  156. ;
  157. ;             if (?cstype eq ?CS_32bit)
  158. ;                 if (?distance and (?PD_FAR16 or ?PD_FARONLY))
  159. ;                     ProcError <16-bit Procedure in 32-bit code>
  160. ;                     .err
  161. ;                 endif
  162. ;             else
  163. ;                 if (?distance and ?PD_FAR32)
  164. ;                     ProcError <32-bit Procedure in 16-bit code>
  165. ;                     .err
  166. ;                 endif
  167. ;             endif
  168. ;             if (?distance and ?PD_FAR)
  169. ;                 if ((?distance and ?PD_DISTMASK) ne ?PD_FAR)
  170. ;                     ProcError <distance_arg cannot use FAR combinations>
  171. ;                     .err
  172. ;                 endif
  173. ;             endif
  174. ;             if ((?distance and (?PD_CDECL or ?PD_PASCAL)) eq \
  175. ;                 (?PD_CDECL or ?PD_PASCAL))
  176. ;
  177. ;                 ProcError <pascal and cdecl conflict>
  178. ;                 .err
  179. ;             endif
  180. ;         endif
  181. ;     endif
  182. ;     if ((?distance and ?PD_DIST) eq 0)
  183. ;         ?distance = ?distance or ?PD_NEAR       ;; default is near
  184. ;     endif
  185. ;     ifndef STDCALL
  186. ;         if ((?distance and ?PD_PASCAL) eq 0)
  187. ;             ?distance = ?distance or ?PD_CDECL  ;; force cdecl override
  188. ;         endif
  189. ;     endif
  190. ;     .lall
  191. ;     ?bm1 = ?distance                            ;; only for listing files
  192. ;     .xall
  193. ;
  194. ;     RETP macro n                                ;; use masm's default RET type
  195. ;         ret n
  196. ;     endm
  197. ;
  198. ;     ;; if near, generate any needed thunks first
  199. ;
  200. ;     if (?distance and ?PD_NEAR)
  201. ;         if (?distance and ?PD_FAR16)            ;; if far16 thunk needed
  202. ;             if (?distance and ?PD_FARONLY)      ;; and if faronly thunk needed,
  203. ;                 if (?local and ?LC_FARLOCAL)    ;; use call for faronly thunk
  204. ;                     GenHybrid name,<local>,<usecall>
  205. ;                 else
  206. ;                     GenHybrid name,,<usecall>
  207. ;                 endif
  208. ;             endif
  209. ;             if (?local and ?LC_FAR16LOCAL)      ;; far16 thunk falls through
  210. ;                 ?Gen16 name,local
  211. ;             else
  212. ;                 ?Gen16 name
  213. ;             endif
  214. ;                                                 ;; far16 thunk not needed
  215. ;         elseif (?distance and ?PD_FARONLY)      ;; if faronly thunk needed,
  216. ;             if (?local and ?LC_FARLOCAL)        ;; faronly thunk falls through
  217. ;                 GenHybrid name,local
  218. ;             else
  219. ;                 GenHybrid name
  220. ;             endif
  221. ;         elseif (?distance and ?PD_FAR32)        ;; if far32 thunk needed
  222. ;             if (?local and ?LC_FAR32LOCAL)      ;; use call for far32 thunk
  223. ;                 GenFar32 name,local
  224. ;             else
  225. ;                 GenFar32 name
  226. ;             endif
  227. ;         endif
  228. ;         if (?local and ?LC_NEARLOCAL)           ;; generate main proc label
  229. ;             GenPublic name,<local>,code
  230. ;         else
  231. ;             GenPublic name,,code
  232. ;         endif
  233. ;         name proc near                          ;; main proc is near
  234. ;     else
  235. ;
  236. ;     ;; main proc isn't near; may need to prepend HYBPRE_, F16PRE_ or F32PRE_
  237. ;
  238. ;         if (?distance and ?PD_FARONLY)
  239. ;             if (?local and ?LC_FARLOCAL)        ;; generate proc HYBPRE_label
  240. ;                 ?PrePublic %HYBPRE_, name,<local>,code
  241. ;             else
  242. ;                 ?PrePublic %HYBPRE_, name,,code
  243. ;             endif
  244. ;             CatPrefix , %HYBPRE_, <name>, <proc far> ;; main proc is far
  245. ;         endif
  246. ;         if (?distance and ?PD_FAR16)
  247. ;             if (?local and ?LC_FAR16LOCAL)      ;; generate proc F16PRE_label
  248. ;                 ?PrePublic %F16PRE_, name,<local>,code
  249. ;             else
  250. ;                 ?PrePublic %F16PRE_, name,,code
  251. ;             endif
  252. ;             CatPrefix , %F16PRE_, <name>, <proc far> ;; main proc is far
  253. ;             RETP macro n                        ;; use RETFD
  254. ;                 RETFD n
  255. ;             endm
  256. ;         endif
  257. ;         if (?distance and ?PD_FAR32)
  258. ;             if (?local and ?LC_FAR32LOCAL)      ;; generate proc F32PRE_label
  259. ;                 ?PrePublic %F32PRE_, name,<local>,code
  260. ;             else
  261. ;                 ?PrePublic %F32PRE_, name,,code
  262. ;             endif
  263. ;             CatPrefix , %F32PRE_, <name>, <proc far> ;; main proc is far
  264. ;         endif
  265. ;         if (?distance and ?PD_FAR)
  266. ;             if (?local and ?LC_LOCAL)           ;; generate main proc label
  267. ;                 GenPublic name,<local>,code
  268. ;             else
  269. ;                 GenPublic name,,code
  270. ;             endif
  271. ;             name proc far                       ;; main proc is far
  272. ;         endif
  273. ;     endif
  274. ;
  275. ;     if (?distance and ?PD_NEAR)
  276. ;         ?abase = 4 + 4                  ;; ret address, EBP are 4 bytes each?
  277. ;         if (?cstype ne ?CS_32bit)
  278. ;             ?abase = 2 + 2              ;; ret address, BP are 2 bytes each?
  279. ;         endif
  280. ;         if (?distance and (?PD_FAR32 or ?PD_FAR16))
  281. ;             ?argfar = 8                 ;; extra 32 bit far call on stack
  282. ;         endif
  283. ;         if (?distance and ?PD_FARONLY)
  284. ;             ife ?argfar
  285. ;                 ?argfar = 4             ;; extra 16 bit far call on stack
  286. ;             else
  287. ;                 ?argfar = -1            ;; doesn't work when thunks combined
  288. ;             endif
  289. ;         endif
  290. ;     else
  291. ;         if (?distance and ?PD_FAR32)
  292. ;             ?abase = 8 + 4              ;; ret addr is 8 bytes, EBP is 4 bytes!
  293. ;         endif
  294. ;         if (?distance and ?PD_FAR16)
  295. ;             ?abase = 8 + 2              ;; ret addr is 8 bytes, BP is 2 bytes!
  296. ;         endif
  297. ;         if (?distance and ?PD_FARONLY)
  298. ;             ?abase = 4 + 2              ;; ret addr is 4 bytes, BP is 2 bytes!
  299. ;         endif
  300. ;         if (?distance and ?PD_FAR)
  301. ;             ?abase = 8 + 4              ;; ret addr is 8 bytes, EBP is 4 bytes?
  302. ;             if (?cstype ne ?CS_32bit)
  303. ;                 ?abase = 4 + 2          ;; ret addr is 4 bytes, BP is 2 bytes!
  304. ;             endif
  305. ;         endif
  306. ;     endif
  307. ;     ifnb <abase>                        ;; if abase is not blank, then use it
  308. ;         ifidni <abase>,<esp>            ;; if abase is ESP, then no [E]BP frame
  309. ;             ?abase = ?abase - 4         ;; uncompensate for EBP
  310. ;             if (?cstype ne ?CS_32bit)
  311. ;                 ?abase = ?abase + 2     ;; oops.  uncompensate only for BP
  312. ;             endif
  313. ;             ?distance = ?distance or ?PD_ESPFRAME
  314. ;         else
  315. ;             ?abase = abase
  316. ;         endif
  317. ;     endif
  318. ;     .lall
  319. ;     ?bm1 = ?abase                               ;; only for listing files
  320. ;     ?bm1 = ?argfar                              ;; only for listing files
  321. ;     .xall
  322. ; endm
  323. ;
  324. ; ;*** EndProc - End a procedure
  325. ; ;
  326. ; ;   This ends a procedure declaration by generating appropriate
  327. ; ;   endp pseudo ops. It also checks to make sure the number of
  328. ; ;   registers saved with SaveReg are the same as the number of
  329. ; ;   registers restored with RestoreReg within the procedure body.
  330. ; ;   This check is not fool-proof because it assumes all the
  331. ; ;   SaveReg and RestoreReg macros will be executed exactly once
  332. ; ;   during run time, which may not be a valid assumption.
  333. ; ;
  334. ; ;   ENTRY   name = name of procedure to end
  335. ; ;           chk  = blank - verify #registers saved by SaveReg
  336. ; ;                  and restored by RestoreReg are the same.
  337. ; ;                = "NoCheck" - don't check
  338. ; ;   (global var)
  339. ; ;           ?depth       = level of Procedure nested.  Max is 1.
  340. ; ;           ?distance    = set by Procedure macro
  341. ; ;           ?olddistance = value of ?distance when Procedure macro
  342. ; ;                          was called.
  343. ; ;
  344. ; ;   EXIT    "endp" with appropriate label generated.
  345. ; ;   (global variables)
  346. ; ;           ?depth   = decremented
  347. ; ;           ?distance = restored to previous value when
  348. ; ;                       Procedure macro was called.
  349. ; ;
  350. ; ;   SEE ALSO: Procedure, ArgVar, LocalVar, EnterProc, SaveReg,
  351. ; ;             RestoreReg, LeaveProc, EndProc.
  352. ;
  353. ; EndProc macro name, chk
  354. ; ifdef ALIGNCODE
  355. ;     align 4
  356. ; endif
  357. ;     if2
  358. ;         if (?distance and ?PD_ENTERED)
  359. ;             ifdif <chk>,<NoCheck>
  360. ;                 ProcError <EndProc invoked without LeaveProc>
  361. ;                 .err
  362. ;             endif
  363. ;         endif
  364. ;         ife ?depth
  365. ;             ProcError <EndProc without matching Procedure>
  366. ;             .err
  367. ;         endif
  368. ;         ?bm1 = 0                                ;; assume no NoCheck
  369. ;         ifnb <chk>
  370. ;             ifdif <chk>,<NoCheck>
  371. ;                 ProcError <EndProc: bad NoCheck arg: chk>
  372. ;                 .err
  373. ;             else
  374. ;                 ?bm1 = 1                        ;; saw NoCheck
  375. ;             endif
  376. ;         endif
  377. ;         if (?bm1 eq 0)
  378. ;             if (?initstack ne ?stackdepth)      ;; is it different?
  379. ;                 ProcError <SaveReg/RestoreReg mismatch>
  380. ;             endif
  381. ;         endif
  382. ;     endif
  383. ;     if (?distance and ?PD_NEAR)
  384. ;         name endp                       ;; procedure is near
  385. ;     elseif (?distance and ?PD_FAR16)
  386. ;         CatPrefix , %F16PRE_, <name>, <endp> ;; procedure is is far16
  387. ;     elseif (?distance and ?PD_FAR32)
  388. ;         CatPrefix , %F32PRE_, <name>, <endp> ;; procedure is is far32
  389. ;     elseif (?distance and ?PD_FARONLY)
  390. ;         CatPrefix , %HYBPRE_, <name>, <endp> ;; procedure is is faronly
  391. ;     else
  392. ;         name endp                       ;; procedure is far
  393. ;     endif
  394. ;     ?depth = ?depth - 1
  395. ;     ?distance = ?olddistance            ;; restore previous value
  396. ;     ifdef KILLASSUMES
  397. ;         assume ds:nothing, es:nothing, ss:nothing
  398. ;         if (?cstype eq ?CS_32bit)
  399. ;             assume fs:nothing, gs:nothing
  400. ;         endif
  401. ;     endif
  402. ; ifdef ALIGNCODE
  403. ;     align 4
  404. ; endif
  405. ; endm
  406.