Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

806 lines
19 KiB

4 years ago
  1. ;***
  2. ;cruntime.inc - multi-model assembly macros for interfacing to HLLs
  3. ;
  4. ; Copyright (c) 1988, Microsoft Corporation. All rights reserved.
  5. ;
  6. ;Purpose:
  7. ; This file defines the current memory model being used.
  8. ;
  9. ;Revision History:
  10. ; 08-04-88 SJM Initial version to handle all four memory models
  11. ; in 16-bit mode and small model in 32-bit mode
  12. ; 08-08-88 JCR Added CPDIST, ?WIN, PCS, ISHIFT/LSHIFT, OS2,
  13. ; DNPTR/DFPTR, DFLOAT/DDOUBLE/DLDOUBLE
  14. ; 08-16-88 PHG Added FPES, LFPES, CBI, ZXAL, ZXBL, ZXCL, ZXDL
  15. ; 08-17-88 JCR Added CAXDX, modified FPSIZE
  16. ; 08-20-88 PHG Added diagnostic messages, removed 386 16-bit support
  17. ; and 386 large code/data support, added mucho comments,
  18. ; PSS now defined as es: only if SS_NEQ_GROUP defined
  19. ; 08-24-88 JCR Added RBXSAVE and RBXONLY for use in 'proc uses'
  20. ; 08-25-88 JCR Added savereg macro, removed rbxsave/rbxonly...
  21. ; 08-26-88 GJF Added codeseg (text) macro
  22. ; 09-15-88 JCR Corrected savelist/reglist macro to go with new MASM
  23. ; 09-21-88 WAJ Added JS*, static*, global*, and label*, and lab macros
  24. ; 09-22-88 JCR Change 'plm' to 'pascal' in label macro
  25. ; 09-26-88 WAJ Added PUSH16 which will do a 16 bit push in a USE32 seg.
  26. ; 09-28-88 WAJ Added CPWORD and DPWORD
  27. ; 09-29-88 WAJ Added JMPFAR16 macro
  28. ; 10-12-88 JCR Made PCS evaluate to 'cs:' for 16/32 stub testbed
  29. ; 04-24-89 JCR Added 'assume seg:flat' for 386 to avoid masm/link bug
  30. ; 05-25-89 GJF Added APIEXT, a macro that expands to the proper extrn
  31. ; declaration for an API function
  32. ; 06-13-89 JCR Added 'flat:' to DCPTR and DDPTR
  33. ; 09-15-89 JCR Added DCPTR? and DDPTR?, always use "FLAT" not "flat"
  34. ;
  35. ;*******************************************************************************
  36. ;==============================================================================
  37. ;
  38. ;Use the following defines to control processor/segment model
  39. ;
  40. ; -DI86 8086/8088 processor
  41. ; -DI286 80286 processor
  42. ; -DI386 80386 processor with 32-bit code/data segment
  43. ;
  44. ; -Dmem_S Small memory model (near code, near data)
  45. ; -Dmem_M Medium memory model (far code, near data)
  46. ; -Dmem_C Compact memory model (near code, fat data)
  47. ; -Dmem_L Large memory model (far code, far data)
  48. ;
  49. ; -DSS_NEQ_DGROUP SS and DS point to different segments
  50. ;
  51. ; default is -DI86 -Dmem_S
  52. ;
  53. ;==============================================================================
  54. ;
  55. ;The following variables are defined by this file:
  56. ; cpu 86, 286, or 386
  57. ; sizeC code distance; 1 = far code, 0 = near code
  58. ; sizeD data distance; 1 = far data, 0 = near data
  59. ; mmodel english name of the memory model, i.e. "Medium"
  60. ; ISIZE, LSIZE, NSIZE size of ints, longs, shorts
  61. ; FLTSIZE, DBLSIZE, LDBLSIZE size of float, double, long double
  62. ; NPSIZE, FPSIZE size of near/far pointers
  63. ; CPSIZE, DPSIZE size of code/data pointers
  64. ; ISHIFT, LSHIFT bits to shift to convert byte to int/long
  65. ;
  66. ;The following macros allow easy writing of combined 16/32 bit code:
  67. ;
  68. ; 16/32 bit registers:
  69. ; rax, rbx, rcx, rdx, expand to native registers (rax = eax or ax)
  70. ; rsi, rdi, rsp, rbp
  71. ; 16/32 bit register instructions:
  72. ; JRCXZ jump when rcx is zero
  73. ; CBI convert byte to int (al to rax)
  74. ; CAXDX convert rax to rax:rdx
  75. ; ZXAL, ZXBL, ZXCL, ZXDL zero extend al,bl,cl,dl to rax,rbx,rcx,rdx
  76. ; Pointer instructions:
  77. ; LPDS, LPES load data pointer with ES or DS
  78. ; PDS, PES segment overrides when pointer loaded as above
  79. ; PCS, PSS segment override to get at code/stack segment
  80. ; LFPDS, LFPES load far pointer with ES or DS
  81. ; FPDS, FPES segment overrides when pointer loaded as above
  82. ; CPTR data type of code pointer
  83. ; CPDIST distance of code (near/far)
  84. ; DNPTR, DFPTR define near/far pointer
  85. ; DCPTR, DDPTR define code/data pointer
  86. ; DCPTR?, DDPTR? define uninitialized code/data pointer
  87. ; CPWORD, DPWORD data type of code or data pointer
  88. ; Numeric type instructions:
  89. ; IWORD, LWORD, SWORD data type of int, long, short
  90. ; DINT, DLONG, DSHORT define int, long, short
  91. ; DFLOAT, DDOUBLE, DLDOUBLE define float, double, long double
  92. ; Offsets:
  93. ; codeoffset, dataoffset offsets from code and data segments
  94. ; API calls:
  95. ; APIDIST distance of API calls (near/far)
  96. ; APIEXT ApiName extrn declaration for an API function
  97. ;
  98. ;The following utility macros are provided:
  99. ; codeseg define/declare code segment
  100. ; error <msg> stop assembly with message
  101. ; display <msg> display a message, unless QUIET defined
  102. ; savelist [<reg> ...] init list of regs to be save by 'proc uses'
  103. ; _if cond <instruction> assemble instruction only if cond is TRUE
  104. ; _ife cond <instruction> assemble instruction only if cond is FALSE
  105. ; _ifd symbol <instruction> assemble instruction only if symbol defined
  106. ; _ifnd symbol <instruction> assemble instruction only if symbol not defined
  107. ;
  108. ; lab LabelName assembles to "LabelName:" If DEBUG is defined
  109. ; LabelName is made public
  110. ;
  111. ; JS* (ex. JSE,JSZ,JSB ...) assemble to "je short","jz short","jb short"
  112. ;
  113. ; Cmacro look alikes
  114. ; static* Name, InitialValue, Repeat defines a static variable of type *
  115. ; global* Name, InitialValue, Repeat defines a global variable of type *
  116. ; label* Name, {PUBLIC,PASCAL,C} defines a label of type *
  117. ;
  118. ; PUSH16 SegmentReg pushes 16 bits in a use32 segment
  119. ; JMPFAR16 label will do a far 16:16 jmp from a use32 segment
  120. ;
  121. ;==============================================================================
  122. ; error <msg> - Output message and generate error
  123. error MACRO msg
  124. if2 ;; only on pass 2 can we generate errors
  125. %out **********************************************************
  126. %out *** E r r o r -- msg
  127. %out **********************************************************
  128. .err
  129. endif
  130. ENDM
  131. ; display msg - Output message unless QUIET defined
  132. display MACRO msg
  133. ifndef QUIET ;; only when quiet flag not set
  134. if1 ;; and on pass 1, then display message
  135. %out msg
  136. endif
  137. endif
  138. ENDM
  139. ; One line conditionals:
  140. ; here we create the capability of writing code lines like
  141. ;
  142. ; _if sizeD <push ds> as opposed to if sizeD
  143. ; push ds
  144. ; endif
  145. _if MACRO cond,text
  146. if cond
  147. text
  148. endif
  149. ENDM
  150. _ife MACRO cond,text
  151. ife cond
  152. text
  153. endif
  154. ENDM
  155. _ifd MACRO cond,text
  156. ifdef cond
  157. text
  158. endif
  159. ENDM
  160. _ifnd MACRO cond,text
  161. ifndef cond
  162. text
  163. endif
  164. ENDM
  165. ; set windows flag to 0
  166. ?WIN equ 0 ; disable windows-specific code
  167. ; check for MTHREAD, requires 286 or greater processor
  168. ifdef MTHREAD
  169. ifndef I386
  170. ifndef I286
  171. ; MTHREAD implies 286 processor
  172. display <Multi-thread specified - assuming 80286 processor>
  173. I286 equ <>
  174. endif
  175. endif
  176. endif
  177. ; Process memory-model arguments
  178. ifdef mem_M
  179. ; Medium model
  180. sizeC equ 1
  181. sizeD equ 0
  182. mmodel equ <Medium>
  183. elseifdef mem_C
  184. ; Compact model
  185. sizeC equ 0
  186. sizeD equ 1
  187. mmodel equ <Compact>
  188. elseifdef mem_L
  189. ; Large model
  190. sizeC equ 1
  191. sizeD equ 1
  192. mmodel equ <Large>
  193. else
  194. ; Small model - default
  195. sizeC equ 0
  196. sizeD equ 0
  197. mmodel equ <Small>
  198. endif
  199. ; Process processor arguments
  200. ifdef I286
  201. display <Processor: 80286>
  202. cpu equ 286
  203. .286
  204. elseifdef I386
  205. display <Processor: 80386>
  206. cpu equ 386
  207. OS2 equ <> ; Define "OS2" since 386 can only run on that OS
  208. .386
  209. else
  210. display <Processor: 8086/8088>
  211. cpu equ 86
  212. .8086
  213. endif
  214. ; 386 32-bit checking. Currently we are only expecting small model
  215. ; 32 bit segments, so we make a few checks to be sure nothing is
  216. ; incorrectly being defined.
  217. ifdef I386
  218. if sizeC or sizeD
  219. error <Must use Small memory model for 386 version.>
  220. endif
  221. ifdef _LOAD_DGROUP
  222. error <No loading DGROUP in 386 version.>
  223. endif
  224. ifdef SS_NEQ_DGROUP
  225. error <SS always equals DGROUP in 386 version.>
  226. endif
  227. endif
  228. ; Set memory model
  229. % display <Memory model: mmodel>
  230. % .model mmodel, C
  231. ;
  232. ; *** Temporary Workaround ***
  233. ; Currently, MASM will not recognize the 'FLAT' keyword unless it previously
  234. ; appears in an 'assume' statement. Presumably, when the '.model FLAT' feature
  235. ; is implemented, this will go away. [Use 'gs:' since we never use that
  236. ; segment register.
  237. ;
  238. ifdef I386
  239. ; ensure that MASM recognizes 'FLAT'
  240. assume gs:FLAT
  241. endif
  242. ; Define registers:
  243. ; Instead of using the "word" registers directly, we will use a set of
  244. ; text equates. This will allow you to use the native word size instead of
  245. ; hard coded to 16 bit words. We also have some instruction equates for
  246. ; instruction with the register type hard coded in.
  247. ifdef I386
  248. rax equ <eax>
  249. rbx equ <ebx>
  250. rcx equ <ecx>
  251. rdx equ <edx>
  252. rdi equ <edi>
  253. rsi equ <esi>
  254. rbp equ <ebp>
  255. rsp equ <esp>
  256. JRCXZ equ <jecxz>
  257. CBI equ <movsx eax, al> ; convert byte to int (al to rax)
  258. CAXDX equ <cdq> ; convert rax to rdx:rax
  259. ZXAL equ <movzx eax, al> ; zero extend al
  260. ZXBL equ <movzx ebx, bl> ; zero extend bl
  261. ZXCL equ <movzx ecx, cl> ; zero extend cl
  262. ZXDL equ <movzx edx, dl> ; zero extend dl
  263. else
  264. rax equ <ax>
  265. rbx equ <bx>
  266. rcx equ <cx>
  267. rdx equ <dx>
  268. rdi equ <di>
  269. rsi equ <si>
  270. rbp equ <bp>
  271. rsp equ <sp>
  272. JRCXZ equ <jcxz>
  273. CBI equ <cbw> ; convert byte to int (al to rax)
  274. CAXDX equ <cwd> ; convert rax to rdx:rax
  275. ZXAL equ <xor ah, ah> ; zero extend al
  276. ZXBL equ <xor bh, bh> ; zero extend bl
  277. ZXCL equ <xor ch, ch> ; zero extend cl
  278. ZXDL equ <xor dh, dh> ; zero extend dl
  279. endif
  280. ; The following equates deal with the differences in near versus
  281. ; far data pointers, and segment overrides.
  282. ;
  283. ; Use LPES and PES when loading a default size pointer -- it loads
  284. ; a 16-bit pointer register in 286 Small/Medium model,
  285. ; a 16-bit pointer register and 16-bit segment register in 8086/286
  286. ; Compact/Large model, and a 32-bit pointer register in 386 mode.
  287. ;
  288. ; Use LFPES and FPES when loading an always far pointer -- it loads a
  289. ; 16-bit pointer register and 16-bit segment register in 8086/286,
  290. ; all models; a 32-bit pointer register in 386 mode.
  291. if sizeD
  292. LPES equ <les>
  293. LPDS equ <lds>
  294. PDS equ <ds:>
  295. PES equ <es:>
  296. else
  297. LPES equ <mov>
  298. LPDS equ <mov>
  299. PDS equ <>
  300. PES equ <>
  301. endif
  302. ifdef I386
  303. LFPES equ <mov>
  304. LFPDS equ <mov>
  305. FPES equ <>
  306. FPDS equ <>
  307. else
  308. LFPES equ <les>
  309. LFPDS equ <lds>
  310. FPES equ <es:>
  311. FPDS equ <ds:>
  312. endif
  313. if sizeC or @WordSize eq 2
  314. PCS equ <cs:> ; large code model or non-386
  315. else
  316. IF 1 ;*** TEMP 16/32 TESTBED ***
  317. PCS equ <cs:>
  318. ELSE
  319. PCS equ <> ; 386 small code model
  320. ENDIF ;*** END TEMP CODE
  321. endif
  322. ifdef SS_NEQ_DGROUP
  323. PSS equ <ss:> ; SS != DS
  324. else
  325. PSS equ <> ; SS == DS
  326. endif
  327. ; Define offset macros:
  328. ; The 32-bit segments will not have 'groups'
  329. ifdef I386
  330. codeoffset equ <offset FLAT:>
  331. dataoffset equ <offset FLAT:>
  332. else
  333. codeoffset equ <offset @code:>
  334. dataoffset equ <offset DGROUP:>
  335. endif
  336. ; The next set of equates deals with the size of SHORTS, INTS, LONGS, and
  337. ; pointers in the 16 and 32 bit versions.
  338. ifdef I386 ;--- 32 bit segment ---
  339. ; parameters and locals
  340. IWORD equ <dword>
  341. LWORD equ <dword>
  342. SWORD equ <word>
  343. ; static storage
  344. DINT equ <dd>
  345. DLONG equ <dd>
  346. DSHORT equ <dw>
  347. ; sizes for fixing SP, stepping through tables, etc.
  348. ISIZE equ 4
  349. LSIZE equ 4
  350. SSIZE equ 2
  351. NPSIZE equ 4
  352. FPSIZE equ 4
  353. ; bit shift count to convert byte cnt/ptr to int/long cnt/ptr
  354. ISHIFT equ 2 ; byte-to-int shift count
  355. LSHIFT equ 2 ; byte-to-long shift count
  356. ; sizes dependent upon memory model. dq -vs- df is not yet clear
  357. DNPTR equ <dd> ; near pointer
  358. DFPTR equ <dd> ; far pointer
  359. DCPTR equ <dd offset FLAT:>; 32 bit offset only
  360. DCPTR? equ <dd> ; No seg override for uninitialized values
  361. CPSIZE equ 4
  362. CPDIST equ <near> ; code pointers are near
  363. CPTR equ <near ptr>
  364. DDPTR equ <dd offset FLAT:>
  365. DDPTR? equ <dd>
  366. DPSIZE equ 4
  367. CPWORD equ <dword> ; code pointers are dwords
  368. DPWORD equ <dword> ; data pointers are dwords
  369. APIDIST equ <near> ; all API calls are NEAR in the 32 bit model
  370. ; macro to declare API functions
  371. EXTAPI macro apiname
  372. extrn pascal apiname:near
  373. endm
  374. else ;--- 16-bit segment ---
  375. ; parameters and locals
  376. IWORD equ <word>
  377. LWORD equ <dword>
  378. SWORD equ <word>
  379. ; static storage
  380. DINT equ <dw>
  381. DLONG equ <dd>
  382. DSHORT equ <dw>
  383. ; sizes for fixing SP, stepping through tables, etc
  384. ISIZE equ 2
  385. LSIZE equ 4
  386. SSIZE equ 2
  387. NPSIZE equ 2
  388. FPSIZE equ 4
  389. ; bit shift count to convert byte cnt/ptr to int/long cnt/ptr
  390. ISHIFT equ 1 ; byte-to-int shift count
  391. LSHIFT equ 2 ; byte-to-long shift count
  392. ; sizes dependent upon memory model
  393. DNPTR equ <dw> ; near pointer
  394. DFPTR equ <dd> ; far pointer
  395. if sizeC
  396. DCPTR equ <dd> ; 16 bit segment and 16 bit offset
  397. DCPTR? equ <dd>
  398. CPSIZE equ 4
  399. CPDIST equ <far> ; code pointers are far
  400. CPTR equ <far ptr>
  401. CPWORD equ <dword> ; code pointers are dwords
  402. else
  403. DCPTR equ <dw> ; 16 bit offset only
  404. DCPTR? equ <dw>
  405. CPSIZE equ 2
  406. CPDIST equ <near> ; code pointers are near
  407. CPTR equ <near ptr>
  408. CPWORD equ <word> ; code pointers are words
  409. endif
  410. if sizeD
  411. DDPTR equ <dd>
  412. DDPTR? equ <dd>
  413. DPSIZE equ 4
  414. DPWORD equ <dword> ; data pointers are dwords
  415. else
  416. DDPTR equ <dw>
  417. DDPTR? equ <dw>
  418. DPSIZE equ 2
  419. DPWORD equ <word> ; data pointers are words
  420. endif
  421. APIDIST equ <far> ; API calls are FAR in 16 bit model
  422. ; macro to declare API functions
  423. EXTAPI macro apiname
  424. extrn pascal apiname:far
  425. endm
  426. endif ; --- 16/32 segment ---
  427. ; Float/double definitions
  428. ; (currently the same for 16- and 32-bit segments)
  429. FLTSIZE equ 4 ; float
  430. DBLSIZE equ 8 ; double
  431. LDBLSIZE equ 10 ; long double
  432. DFLOAT equ <dd>
  433. DDOUBLE equ <dq>
  434. DLDOUBLE equ <dt>
  435. ;
  436. ; savelist - Generate a list of regs to be saved by the proc 'uses' option.
  437. ;
  438. ; Input:
  439. ; reg1, reg2, reg3, reg4 = registers to be saved across function
  440. ; Output:
  441. ; reglist = text string of registers that can be passed to the 'uses'
  442. ; option on the 'proc' command.
  443. ;
  444. savelist MACRO reg1, reg2, reg3, reg4
  445. local ws, listsize
  446. ws catstr < > ; whitespace char
  447. IFNDEF I386
  448. rbx equ <> ; 8086/286 don't save rbx
  449. ENDIF
  450. IFNB <reg4>
  451. reglist catstr reg1, ws, reg2, ws, reg3, ws, reg4
  452. ELSEIFNB <reg3>
  453. reglist catstr reg1, ws, reg2, ws, reg3, ws
  454. ELSEIFNB <reg2>
  455. reglist catstr reg1, ws, reg2, ws, ws
  456. ELSEIFNB <reg1>
  457. reglist catstr reg1, ws, ws, ws
  458. ELSE
  459. reglist catstr <>
  460. ENDIF
  461. listsize sizestr reglist ; size of register list
  462. IF listsize LE 3 ; if list is only the 3 ws chars...
  463. reglist catstr <>
  464. ENDIF
  465. IFNDEF I386
  466. rbx equ <bx> ; restore rbx
  467. ENDIF
  468. ENDM ; savelist
  469. ;
  470. ; codeseg - Define/declare the standard code segment. Maps to the proper
  471. ; form of the .code directive.
  472. ;
  473. ; Input:
  474. ;
  475. ; Output:
  476. ; .code _TEXT ; for large code models
  477. ; .code ; for small code models
  478. ; assume cs:FLAT ; for 386
  479. ; assume ds:FLAT ; for 386
  480. ; assume es:FLAT ; for 386
  481. ; assume ss:FLAT ; for 386
  482. ;
  483. codeseg MACRO
  484. if sizeC
  485. .code _TEXT
  486. else
  487. .code
  488. endif
  489. ifdef I386
  490. assume cs:FLAT
  491. assume ds:FLAT
  492. assume es:FLAT
  493. assume ss:FLAT
  494. endif
  495. ENDM
  496. ;***************************************************************
  497. ;*
  498. ;* Debug lab macro
  499. ;*
  500. ;***************************************************************
  501. lab macro name
  502. ifdef DEBUG
  503. public pascal name ;; define label public for Symdeb
  504. endif
  505. name:
  506. endm
  507. ;***************************************************************
  508. ;*
  509. ;* Conditional jump short macros
  510. ;*
  511. ;***************************************************************
  512. irp x,<Z,NZ,E,NE,S,NS,C,NC,P,NP,PE,PO,A,AE,B,BE,NB,G,GE,L,LE>
  513. JS&x equ <j&x short>
  514. endm
  515. ;***************************************************************
  516. ;*
  517. ;* Global data definition macros
  518. ;*
  519. ;* Usage:
  520. ;* globalI Name, InitialValue, Repeat
  521. ;*
  522. ;***************************************************************
  523. MakeGlobal macro suffix, DataType ;; makes all of the global* macros
  524. global&suffix macro name, data, rep
  525. public name
  526. ifb <rep>
  527. _repeat = 1
  528. else
  529. _repeat = (rep)
  530. endif
  531. name &DataType _repeat dup( data )
  532. endm
  533. endm
  534. MakeGlobal T, dt ; globalT
  535. MakeGlobal Q, dq ; globalQ
  536. MakeGlobal D, dd ; globalD
  537. MakeGlobal W, dw ; globalW
  538. MakeGlobal B, db ; globalB
  539. % MakeGlobal I, DINT ; globalI
  540. % MakeGlobal DP, DDPTR ; globalDP
  541. % MakeGlobal CP, DCPTR ; globalCP
  542. % MakeGlobal FP, DFPTR ; globalFP
  543. % MakeGlobal NP, DNPTR ; globalNP
  544. ;***************************************************************
  545. ;*
  546. ;* Static data definition macros
  547. ;*
  548. ;* Usage:
  549. ;* staticI Name, InitialValue, Repeat
  550. ;*
  551. ;***************************************************************
  552. MakeStatic macro suffix, DataType ;; makes all of the static* macros
  553. static&suffix macro name, data, rep
  554. ifdef DEBUG
  555. public pascal name ;; make statics public if DEBUG
  556. endif
  557. ifb <rep>
  558. _repeat = 1
  559. else
  560. _repeat = (rep)
  561. endif
  562. name &DataType _repeat dup( data )
  563. endm
  564. endm
  565. MakeStatic T, dt ; staticT
  566. MakeStatic Q, dq ; staticQ
  567. MakeStatic D, dd ; staticD
  568. MakeStatic W, dw ; staticW
  569. MakeStatic B, db ; staticB
  570. % MakeStatic I, DINT ; staticI
  571. % MakeStatic DP, DDPTR ; staticDP
  572. % MakeStatic CP, DCPTR ; staticCP
  573. % MakeStatic FP, DFPTR ; staticFP
  574. % MakeStatic NP, DNPTR ; staticNP
  575. ;***************************************************************
  576. ;*
  577. ;* Label definition macros
  578. ;*
  579. ;***************************************************************
  580. ;*
  581. ;* Label definition macros
  582. ;*
  583. ;* Usage:
  584. ;* labelI Name, {PUBLIC, PASCAL, C}
  585. ;*
  586. ;***************************************************************
  587. __MakePublic macro name, option ;; decides if a label should be
  588. ifidni <option>, <PUBLIC> ;; made public
  589. public name
  590. elseifidni <option>, <PASCAL>
  591. public pascal name
  592. elseifidni <option>, <C>
  593. public C name
  594. elseifb <option>
  595. ifdef DEBUG
  596. public pascal name ;; make public if DEBUG
  597. endif
  598. endif
  599. endm
  600. MakeLabel macro suffix, LabelType ;; makes all of the label* macros
  601. label&suffix macro name, option
  602. __MakePublic <name>,<option>
  603. name label &LabelType
  604. endm
  605. endm
  606. MakeLabel T, tbyte ; make labelT
  607. MakeLabel Q, qword ; make labelQ
  608. MakeLabel D, dword ; make labelD
  609. MakeLabel W, word ; make labelW
  610. MakeLabel B, byte ; make labelB
  611. MakeLabel P, proc ; make labelP
  612. MakeLabel FP, far ; make labelFP
  613. MakeLabel NP, near ; make labelNP
  614. % MakeLabel I, IWORD ; make labelI
  615. labelDP macro name, option ;; labelDP
  616. __MakePublic <name>,<option>
  617. ifdef I386
  618. if sizeD
  619. name label fword
  620. else
  621. name label dword
  622. endif
  623. else ;not I386
  624. if sizeD
  625. name label dword
  626. else
  627. name label word
  628. endif
  629. endif ;not I386
  630. endm
  631. labelCP macro name, option ;; labelCP
  632. __MakePublic <name>,<option>
  633. ifdef I386
  634. if sizeC
  635. name label fword
  636. else
  637. name label dword
  638. endif
  639. else ;not I386
  640. if sizeC
  641. name label dword
  642. else
  643. name label word
  644. endif
  645. endif ;not I386
  646. endm
  647. ;*
  648. ;* PUSH16 SegReg - pushes 16 bits in a use32 segment
  649. ;*
  650. PUSH16 macro SegReg
  651. ifdef I386
  652. nop
  653. db 66h ; operand size over-ride
  654. endif ; I386
  655. push SegReg
  656. endm
  657. ;*
  658. ;* JMPFAR16 label - jmps far from a use32 to a use16 segment
  659. ;*
  660. JMPFAR16 macro label
  661. ifndef I386
  662. error <JMPFAR16 can only be used in a use32 code segment>
  663. endif ;I386
  664. nop
  665. db 66h ;; operand size over-ride
  666. db 0eah ;; jmp far immediate op code
  667. dw offset label
  668. dw seg label
  669. endm