您的位置:逆风者 汇编技术 正文
原作者:www.upwinder.com 添加时间:2007-09-02 原文发表:2007-08-31 人气:7 来源:未知

本文章共2379字,分2页,当前第1页,快速翻页:
 
; Macro file for MSDOS.
;

SUBTTL BREAK a listing into pages and give new subtitles
PAGE
BREAK MACRO subtitle
SUBTTL subtitle
PAGE
ENDM

BREAK <I_NEED: declare a variable external, if necessary, and allocate a size>
逆风编程精品

;
; declare a variable external and allocate a size
;
I_NEED MACRO sym,len
CODE ENDS
DATA SEGMENT BYTE PUBLIC 'DATA'

IFIDN <len>,<WORD>
EXTRN &sym:WORD
ELSE
IFIDN <len>,<DWORD>
EXTRN &sym:DWORD
ELSE
EXTRN &sym:BYTE
ENDIF
ENDIF

DATA ENDS
CODE SEGMENT BYTE PUBLIC 'CODE'
ENDM

;
; call a procedure that may be external. The call will be short.
;
invoke MACRO name
&.xcref
add_ext name,near
&.cref
CALL name
ENDM

PAGE
;
; jump to a label that may be external. The call will be near.
;
transfer MACRO name
&.xcref
add_ext name,near
&.cref
JUMP name
ENDM

;
; get a short address in a word
;
short_addr MACRO name
IFDIF <name>,<?>
&.xcref
add_ext name,near
&.cref
DW OFFSET DOSGROUP:name
ELSE
DW ?
ENDIF
ENDM

;
; get a long address in a dword
;
long_addr MACRO name
&.xcref
add_ext name,far
&.cref
DD name
ENDM

;
; declare a PROC near or far but PUBLIC nonetheless
;
procedure MACRO name,distance
PUBLIC name
name PROC distance
ENDM

PAGE
;
; define a data item to be public and of an appropriate size/type
;
I_AM MACRO name,size
PUBLIC name

IFIDN <size>,<WORD>
name DW ?
ELSE
IFIDN <size>,<DWORD>
name DD ?
ELSE
IFIDN <size>,<BYTE>
name DB ?
ELSE
name DB size DUP (?)
ENDIF
ENDIF
ENDIF
ENDM

PAGE
;
; play games with a possible external. Create a new
; macro for the symbol and text, and string it together
; with a central invoker
;

.xcref
.xcref ?i
.xcref def_mac
.xcref ?z0
.xcref add_ext
.cref

IF1
?i=0
ENDIF

?z0 macro
endm

;
; add an external declaration to s with type t if it is not defined
;
add_ext macro s,t
&.xcref
&.xcref ?&s
&.cref
IFNDEF ?&s
?i = ?i 1
def_mac ?z&%?i,?z&%(?i-1),s,t
ENDIF
endm

;
; define a macro called that possibly externals s:t and then calls macro n
;
def_mac macro m,n,s,t
&.xcref
&.xcref ?&s
&.xcref m
&.cref
m macro
ifndef s
extrn s:&t
endif
purge m
purge ?&s
n
endm
?&s macro
&endm
endm

;
; call the macro chain
;
do_ext macro
&.xcref
expand_mac ?z%?i
&.cref
endm

PAGE
expand_mac macro m
m
endm

;
; define an entry in a procedure
;
entry macro name
PUBLIC name
name:
endm

BREAK <ERROR - print a message and then jump to a label>

error macro code
local a
.xcref
MOV AL,code
transfer SYS_RET_ERR
.cref
ENDM

BREAK <JUMP - real jump that links up shortwise>
;
; given a label <lbl> either 2 byte jump to another label <lbl>_J
; if it is near enough or 3 byte jump to <lbl>
;

jump macro lbl
local a
.xcref
a:
ifndef lbl&_J ; is this the first invocation
JMP lbl
ELSE
IF lbl&_J GE $
JMP lbl
ELSE
IF ($-lbl&_J) GT 126 ; is the jump too far away?
JMP lbl
ELSE ; do the short one...
JMP lbl&_J
ENDIF
ENDIF
ENDIF
endm

BREAK <RETURN - return from a function>

return macro
local a
.xcref
a:
RET
ret_l = a
endm

BREAK <CONDRET - conditional return>

makelab macro l,cc,ncc
j&ncc a ; j<NCC> a:
return ; return
 
本文章更多内容1 - 2 - 下一页>>
相关文章

专截320*200的截画程序
汇编源码--circle
汇编源码--COBLOAD
PRINT FILE PROGRAM (打印文件)
汇编源码--inthand
一个旋转的3D箱子(动画)
汇编源码--ctrladel
汇编源码--getseg_c
The 808 Virus
获取当前系统时间
汇编源码--basmain
简单密码输入
汇编源码--CLEANF
鼠标控制CD-Audio播放程序
汇编源码--DRIVER
汇编源码--CLEAR
简单的取系统时间小程序
汇编源码--dskwatch
汇编源码--BURNOUT
汇编源码--col

相关评论


本文章所属分类:首页 汇编技术

  热门关键字:
进制数据输出的通用程序 2007-09-12
汇编源码--showmem 2007-08-31
汇编源码--CLEAN 2007-08-31
汇编源码--hdr 2007-08-31
汇编源码--basload 2007-08-31
汇编源码--CHAR 2007-08-31
汇编源码--fxn 2007-08-31
汇编源码--alarm 2007-08-31
汇编源码--getsect 2007-08-31
汇编源码--DEV 2007-08-31
汇编源码--getspace 2007-08-31
汇编源码--frespace 2007-08-31
CIH文件型病毒检测消除程序 2007-08-31
Mixer Volume Ctrler V1.0 2007-08-31
汇编源码--COMINT 2007-08-31
自己用汇编语言写的一个病毒(源码... 2007-08-31
汇编源码--col 2007-08-31
汇编源码--BURNOUT 2007-08-31