home *** CD-ROM | disk | FTP | other *** search
- ; .286c -- DO NOT ADD THESE;
- ; .286p
- ; .287
- ; otherwise fwaits will be omitted and it won't work for the 8086/8087.
-
-
- eax equ ax
- ebx equ bx
- ecx equ cx
- edx equ dx
- edi equ di
- esi equ si
- esp equ sp
- ebp equ bp
- movzx equ mov
- ebadf = 6
- edeadlock = 25
- eaccess equ 5
- enoent equ 2
- ; Set pointer size.
- ifdef Large_data
- Ptr_size = 4
- Ptr_reg equ es ; Use es.
- Stack_reg equ ss ; Use ss.
- else
- Ptr_size = 2
- Ptr_reg equ ds ; Can use ds, since = es.
- Stack_reg equ ds ; Can use ds, since = ss.
- endif
-
- ifdef Small_code
- Pbase = 4 ; Location of first parameter.
- Routine_size= 4 ; link + offset.
- return macro Pop_bytes
- ifb <Pop_bytes>
- db 0c3h
- else
- db 0c2h
- dw Pop_bytes
- endif
- endm
- extrnf macro name
- extrn name:near
- endm
- else
- Pbase = 6 ; Location of first parameter.
- Routine_size= 6 ; Link + offset + segment.
- return macro Pop_bytes
- ifb <Pop_bytes>
- db 0cbh
- else
- db 0cah
- dw Pop_bytes
- endif
- endm
- extrnf macro name
- extrn name:far
- endm
- endif
-
- Word_size = 2
-
- prolog macro
- push bp
- mov bp,sp
- ifdef Large_data ; Save DS whether or not 1 DS, in case we modify it.
- push ds
- endif
- endm
- epilog macro Pop_bytes
- ifdef Large_data
- pop ds
- endif
- pop bp
- return Pop_bytes
- endm
-
- ; We would have preferred a procbeg and procend macro, but
- ; the "proc" directive can't go inside a macro -- yet another
- ; of the many bugs in the flaky Microsoft assembler.
- publab macro procname
- public _mw&procname
- _mw&procname:
- endm
-
- cseg macro segname,status
- name &segname
- cseg2 &segname,&status
- endm
-
- ; Same as cseg, but without the "name" directive. It's because you
- ; can't override a name directive.
- cseg2 macro segname,status
- ifb <status>
- _mw&segname segment word 'code'
- else
- _mw&segname segment word 'code' public
- endif
- assume cs:_mw&segname
- ifdef Small_code
- cgroup group _mw&segname
- assume cs:cgroup
- endif
- endm
-
- endcseg macro segname
- _mw&segname ends
- endm
-
- pubnames macro names
- irp name,<names>
- ifdef USING_PHARLAP
- public _mw&name
- else
- public _mw&&name
- endif
- endm
- endm
- def macro x,y,z
- _mw&x y z
- endm
- defequ macro x,y,z
- _mw&x y z
- x equ _mw&x
- endm
- extequ macro x,type
- extrn _mw&x:type
- x equ _mw&x
- endm
- ext macro x,type
- extrn _mw&x:type
- endm
- ; Macros for parameter set-up that take care of small vs. large code
- ; and to some extent small vs. large data.
- ; Callling sequence:
- ; parms <<N1,T1>,<N2,T2>,...>
- ; where Ni are the names and Ti the types.
- ; This expands into
- ; Ni equ T1 ptr offset[bp]
- ; where offset starts at the appropriate value for a procedure
- ; (assuming BP has been pushed, and taking into account small vs lg code)
- ; and is incremented as follows:
- ; if Ti = "ptr" then increment by Ptr_size
- ; otherwise increment by 2.
- ; For example:
- ; parms <<Src,word>,<Dest,ptr>,<Cnt,word>>
- ; generates
- ; Src equ word ptr 6[bp]
- ; Dest equ dword ptr 8[bp]
- ; Cnt equ word ptr 12[bp]
- ; assuming parms start at 6.
- parm macro P,Type
- local offset
- offset equ Poff+0 ; +0 avoids alias; forces pass1 computation of expn.
- ifidn <Type>,<ptr> ; Type = "ptr"?
- ifdef Small_data
- P equ word ptr offset[bp]
- else
- P equ dword ptr offset[bp]
- endif
- Poff = Poff + Ptr_size
- else
- ifidn <Type>,<routine> ; Type = "routine"?
- ifdef Small_code
- P equ word ptr offset[bp]
- else
- P equ dword ptr offset[bp]
- endif
- Poff = Poff + Routine_size - 2 ; DOES NOT skip link.
- else
- P equ Type ptr offset[bp]
- Poff = Poff + 2
- endif
- endif
- endm
- parms macro Parmlist
- Poff = Pbase ; ret addr + pushed bp.
- irp P,<Parmlist>
- parm P
- endm
- endm
- parm86 macro parmlist
- parms <parmlist>
- endm
- parm386 macro parmlist
- endm
-
- ; Load a pointer.
- ifdef Small_data
- loadptr macro Seginstr,Ireg,Operand
- mov Ireg,Operand
- endm
- else
- loadptr macro Seginstr,Ireg,Operand
- Seginstr Ireg,Operand
- endm
- endif
-
- ; Load a formal routine parameter.
- ifdef Small_code
- loadrout macro Segreg,Ireg,Operand
- mov Ireg,Operand
- push cs
- pop Segreg
- endm
- else
- loadrout macro Segreg,Ireg,Operand
- L&Segreg Ireg,dword ptr Operand
- endm
- endif
-
- ; Call a procedure.
- ifdef Small_code
- pcall macro procname
- call cgroup:(near ptr procname)
- endm
- else
- pcall macro procname
- call far ptr procname
- endm
- endif