Macros (notes)

http://www.emu8086.com/assembler_tutorial/asm_tutorial_10.html

 

1. like proc but not really.

exist only until the code  is compiled.

after compilation, all macros are replaced with real instructions.

 

2.definition:

 

name MACRO [parameters,...]

<instructions>

ENDM

 

Unlike proc, macros should be defined above the code that uses it.

 

3. Some important facts

 

  • use- "CALL MyProc" vs "MyMacro" (no CALL in using macro)
  • procedure is located at some specific address in memory. When using  it 100 times, the size grows very insignificantly. Macro is opposite because macro is expanded directly in program's code.
  • Different in the method of passing parameters
  • ENDM vs ENDP

4. Use LOCAL followed by names of variables, labels or procedure names in Macro

example:

MyMacro2    MACRO
	LOCAL label1, label2

	CMP  AX, 2
	JE label1
	CMP  AX, 3
	JE label2
	label1:
		 INC  AX
	label2:
		 ADD  AX, 2
ENDM

ORG 100h
MyMacro2
MyMacro2
RET

 

5. If using macros in several programs, put them in a INC file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值