lt55.asm
来自「汇编语言学习的资料希望对大家有很大的帮助啊!!」· 汇编 代码 · 共 102 行
ASM
102 行
.model small
.stack
.code
;例题5.5a、5.5b、例题5.6
;**********************************
;**********************************
;例题5.5a:具有多个参数的宏定义
;
shl_ext macro shl_oprand , shl_num
push cx
mov cl,shl_num
shl shl_oprand,cl
pop cx
endm
;
;++++++++++++++++++++++++++
;将ax左移6位,宏调用
shl_ext ax , 6
;***********************************
;例题5.5b:操作码做参数,
;用一条宏指令代替四条移位指令
shift macro s_oprand, s_num, s_op_code
push cx
mov cl , s_num
s&s_op_code& s_oprand , cl ;改写成:s_op_code s_oprand , cl
pop cx
endm
;++++++++++++++++++++++++++++
;将ax左移6位的宏调用:
shift ax ,6 , hl ;改写成:shift ax , 6 , shl
;++++++++++++++++++++++++++++
;将bx右移4位的宏调用:
shift bx, 4, hr ;改写成:shift bx , 4 , shr
;***********************************
;将移位和循环移位共8条指令统一
sh_rot macro sh_rot_oprand , srnum , sr_op_code
push cx
mov cl,srnum
sr_op_code sh_rot_oprand , cl
pop cx
endm
;+++++++++++++++++++++++++++++
;将dx小循环右移2位的宏调用
sh_rot dx , 2 , ror
;+++++++++++++++++++++++++++++
;将dx大循环左移2位的宏调用
sh_rot dx , 2 , rcl
;******************************************
;******************************************
;例题5.6 字符串用做宏定义参数
dstring macro string ;string为行参
db '&string&',0dh,0ah,'$'
endm
;+++++++++++++++++++++++++++++
;定义字符串的宏调用
dstring < This is a exsample.> ;由于实参中有空格,要括起来。
;宏展开
db ’This is a example.’ , 0dh, 0ah, ’$’
;+++++++++++++++++++++++++++++
;要定义的字符串中含特殊符号的宏调用,
;使用转义操作符"!"
dstring <0!< number !<10 > ;“<”为一个特殊字符
;宏展开
db ’0 < Number < 10’, 0dh, 0ah, ’$’
;++++++++++++++++++++++++++++++++++++
;"%"号的作用
;宏定义
dstring macro string ;string为行参
db '&string&',0dh,0ah,'$'
endm
;宏调用1:
dstring 1024-1
;宏展开1:
db '1024-1' , 0dh, 0ah, '$';等效于db '1', '0', '2', '4', '-' ,'1',0dh,0ah,'$'
;--------------------------------------------------------
;宏调用2:
dstring %(1024-1)
;宏展开2:
db '1023' , 0dh, 0ah, '$'
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?