tenx(十速)TM87系列常用宏(一)

0

本文作者:xjtudll  发布于:2010-2-8  分类:技术心得  点击:


tenx(十速)TM87系列常用宏(一)

 

首先,定义一些寄存器,用于存储临时变量,定义R0R770H~77H,方便LCD显示。

定义如下:

ORG 70H

R0 DN 1

R1 DN 1

R2 DN 1

R3 DN 1

R4 DN 1

R5 DN 1

R6 DN 1

R7 DN 1

由于累加器AC和状态寄存器CF无法直接操作,所以定义两个寄存器给ACCF

ACC DN 1

CF DN 1

比较常用的宏有:

1RAM清零

单片机上电后,RAM值是未知的,未避免出现错误,所以需要对RAM清零。

ClearRAM                    .macro 

                                                 .locallabel ClearRAMLoop

                                                        LDS R0,$00

                                                        MVU R0 

                                                        MVH R0

                                                        MVL R0

ClearRAMLoop: 

                                                        MRW# @HL,R0

                                                        CPHL $00

                                                        JMP ClearRAMLoop

             .endm

2LCD清屏

ClearScreen                        .macro

                                                        LDS R0,$00

                                                        MVU R0

                                                        MVH R0

                                                        MVL R0

                                                        LCPX 0

                                                        LCPX 1

                                                        LCPX 2

                                                        LCPX 3                       

                                          .endm

3、中断压栈和出栈

压栈

;压栈

PUSH                                .macro

                                                        STA ACC

                                                        MAF CF

                                          .endm

出栈

;出栈                                                      

POP                                    .macro

                                                        LDA ACC

                                                        MRA CF

                                          .endm

4、清除CFAC

清除CF

;清除CF

CLRCF                               .macro

                                                        RF C

                                          .endm

清除AC

;清除AC

CLRAC                               .macro

                                                        LDS R0,$0

                                          .endm

 

本文标签: tenx  TM87  单片机  
本文Url: http://www.xjtudll.cn/Exp/42/ (出自: 鸟的天空)
我要引用: 点击这里获取该日志的TrackBack引用地址

相关文章:

41. 宏与子程序的区别  (2010-2-8 17:58:33)

39. Proteus 7.6SP4破解1.0完美补丁  (2010-2-7 13:34:53)

36. 简易方波信号发生器  (2010-1-31 12:2:11)

35. 51串口通信  (2010-1-29 18:1:49)

0 Comments

Write a comment ?