📄 rxdosmac.asm
字号:
ife pushedseg-no ; if not pushed
push ax
mov word ptr arg_name [bp+2],seg ; really a value.
endif
ifnb <reg>
irp treg,<ax,bx,cx,dx,bp,si,di,es,ds,ss,cs,f>
ifidn <reg>,<treg>
tpush reg
pushedreg = yes
endif
endm
ife pushedreg-no ; if not pushed (while reg not blank)
push ax
mov word ptr arg_name [bp],reg
endif
else
ife pushedseg-no ; if not pushed
push ax ;
endif
endif
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Defines n word arguments on stack ;
;...............................................................;
DefWords macro arg_name, size
ifb <arg_name>
error 'Def must have an arg_name parameter.'
endif
?tempSize = ( 2 * size )
_defEntry = _defEntry - ?tempSize
arg_name = _defEntry
sub sp, ?tempSize
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Defines n byte arguments on stack (ends on even boundry) ;
;...............................................................;
DefBytes macro arg_name, size
ifb <arg_name>
error 'Def must have an arg_name parameter.'
endif
?tempSize = ((size + 1) AND 0FFFEh)
_defEntry = _defEntry - ?tempSize
arg_name = _defEntry
sub sp, ?tempSize
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Creates an argument definition but you must do the push ;
;...............................................................;
Temp macro arg_name
ifb <arg_name>
error 'Temp must have an arg_name parameter.'
endif
_defEntry = _defEntry - 2
arg_name = _defEntry
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Creates a dd argument definition but you must do the push ;
;...............................................................;
DTemp macro arg_name
ifb <arg_name>
error 'Def must have an arg_name parameter.'
endif
_defEntry = _defEntry - 4
arg_name = _defEntry
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Returns from Entry or FarEntry ;
;...............................................................;
Return macro
mov sp, bp
pop bp
ret (2 * _retEntry)
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Set Error ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; sets carry, ;
; loads an error value into ax, ;
; optionally jumps to an address. ;
; ;
;...............................................................;
SetError macro errcode, opt_jumpto
stc
mov ax, offset errcode
ifnb < opt_jumpto >
jmp opt_jumpto
endif
endm
iferror macro errcode, opt_jumpto
local label
ifb < opt_jumpto >
error 'must have a goto label'
else
jnc label
mov ax, offset errcode
jmp opt_jumpto
label:
endif
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Compare and Goto ;
;...............................................................;
Goto macro value, loc
local label
if ( value GT 00ffh )
cmp ax, value
else
cmp al, value
endif
jnz label
jmp loc
label:
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Long Cond Jumps (ifCarry, ifNCarry) ;
;...............................................................;
ifc macro addr
local label
jnc label
jmp addr
label:
endm
ifnc macro addr
local label
jc label
jmp addr
label:
endm
ifz macro addr
local label
jnz label
jmp addr
label:
endm
ifnz macro addr
local label
jz label
jmp addr
label:
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Jump Far ;
;...............................................................;
Jmp_far macro seg, addr
db 0EAh
dw addr, seg
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Normalize Seg and Offset ;
;...............................................................;
NormalizeBuffer macro seg, offset
push offset
shr offset, 1
shr offset, 1
shr offset, 1
shr offset, 1
push ax
mov ax, seg
add ax, offset
mov seg, ax
pop ax
pop offset
and offset, 000fh
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Clear Memory (assumes start address at ES:DI) ;
;...............................................................;
clearMemory macro size, init
local skip
push di
push ax
push cx
ifnb < size >
mov cx, size
endif
ifnb < init >
mov ax, init
else
xor ax, ax
endif
shr cx, 1
rep stosw
jnc skip
stosb
skip:
pop cx
pop ax
pop di
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Fast Move ;
;...............................................................;
fastmove macro arg1, arg2 ; args not used
local label
shr cx, 1 ; optimize for words
rep movsw ; move them
jnc label ; even bytes -->
movsb ; move odd byte
label:
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Return Called Stack Frame ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; reg defined contains stack reference at current Int 21. ;
; ;
;...............................................................;
RetCallersStackFrame macro seg, reg
ifb < seg >
error "must have both seg and reg"
exitm
endif
ifb < reg >
error "must have both seg and reg"
exitm
endif
ifidn <seg>,<ss>
error "can't seg change to ss"
exitm
else
call _RetCallersStackFrame
pop reg
pop seg
endif
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Define Command ;
;...............................................................;
Cmnd macro loc, asciz1, asciz2, asciz3, asciz4, asciz5, asciz6
dw loc
ifnb <asciz1>
db asciz1, 0
endif
ifnb <asciz2>
db asciz2, 0
endif
ifnb <asciz3>
db asciz3, 0
endif
ifnb <asciz4>
db asciz4, 0
endif
ifnb <asciz5>
db asciz5, 0
endif
ifnb <asciz6>
db asciz6, 0
endif
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Define Switches ;
;...............................................................;
Switch macro letter, flags, min, max, value
ifb <letter>
db -1
else
ifb <flags>
db letter
dw 00, 0000, 0000, 0000
else
ifb <min>
db letter
dw flags, 0000, 0000, 0000
else
ifb <max>
db letter
dw flags, min, 0000, 0000
else
ifb <value>
db letter
dw flags, min, max, 0000
else
db letter
dw flags, min, max, value
endif
endif
endif
endif
endif
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Asciz ;
;...............................................................;
Asciz macro arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
ifnb <arg1>
db arg1
endif
ifnb <arg2>
db arg2
endif
ifnb <arg3>
db arg3
endif
ifnb <arg4>
db arg4
endif
ifnb <arg5>
db arg5
endif
ifnb <arg6>
db arg6
endif
ifnb <arg7>
db arg7
endif
ifnb <arg8>
db arg8
endif
ifnb <arg9>
db arg9
endif
db 0
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; IFS ;
;...............................................................;
IFS macro fct
ifnb <fct>
mov al, fct
endif
pushf
call Interrupt2F
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Internal Int21 Emulation call ;
;...............................................................;
Int21 macro arg1, arg2
ifnb < arg1 >
ifnb < arg2 >
if ( arg1 GT 00ffh )
mov ax, arg1 + arg2
else
mov ax, ( arg1 * 256 + arg2 )
endif
endif
ifb < arg2 >
if ( arg1 GT 00ffh )
mov ax, arg1
else
mov ah, arg1
endif
endif
endif
IFNDEF RxDOS_DEBUG
int 21h ;** DOS
else
int 21h ;** debug
endif
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Int 2E ;
;...............................................................;
Int2E macro arg1, arg2
ifnb < arg1 >
ifnb < arg2 >
if ( arg1 GT 00ffh )
mov ax, arg1 + arg2
else
mov ax, ( arg1 * 256 + arg2 )
endif
endif
ifb < arg2 >
if ( arg1 GT 00ffh )
mov ax, arg1
else
mov ah, arg1
endif
endif
endif
int 2Eh
endm
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Extended Int Function ;
;...............................................................;
ExInt macro arg
push bp
int arg
pop bp
endm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -