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

0

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


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

 

接上篇:http://www.xjtudll.cn/Exp/42/


5
、位操作

位清零

;BIT清零 RAM 00~6FH 70~7FH也可用,但是浪费了两条语句                              

CLRB                          .macro REG,BIT

                                                        MRW R0,REG

                                                        .if BIT=0

                                                               ANDI* R0,1110B

                                                        .elseif BIT=1

                                                               ANDI* R0,1101B

                                                        .elseif BIT=2

                                                               ANDI* R0,1011B

                                                        .elseif BIT=3

                                                               ANDI* R0,0111B         

                                                        .endif                                                                    

                                                        MWR REG,R0

                                   .endm



1

; BIT1  RAM 00~6FH 70~7FH也可用,但是浪费了两条语句

SETB                           .macro REG,BIT

                                                        MRW R0,REG

                                                        .if BIT=0

                                                               ORI* R0,0001B

                                                        .elseif BIT=1

                                                               ORI* R0,0010B

                                                        .elseif BIT=2

                                                               ORI* R0,0100B

                                                        .elseif BIT=3

                                                               ORI* R0,1000B                                              

                                                        .endif                   

                                                        MWR REG,R0                                                

                            .endm

6、环移

左环移

;左环移 最高位保存到CF 低位填0

RLC                            .macro Reg

                                                 MRA Reg

                                                 SL0 Reg

                                   .endm

 

右环移

;右环移 最低位保存到CF 高位填0 R0所在地址不能操作

RRC                                   .macro Reg

                                                 MRW R0,Reg

                                                 SL0 R0

                                                 SL0 R0

                                                 SL0 R0

                                                 MRA R0

                                                 SR0 Reg

                                          .endm

 

7、常数赋值操作

 RAM 7FH~FFH(需索引赋值的)

;如果不用高地址,则调用方式为 MOVX ,AddrL,Num

MOVX                                .macro AddrH,AddrL,Num

                                                        .ifnblank AddrH ;判断宏的参数是否有串入

                                                               LDS R0,AddrH

                                                               MVH R0

                                                        .endif

                                                               LDS R0,AddrL

                                                               MVL R0

                                                               LDS R0,Num                                                  

                                                               MRW @HL,R0                                               

                                          .endm

 

8、程序跳转

RAM所存储的数值与常数比较

 

小于跳转

;小于跳转 可操作RAM 00~7FH   70~7FH浪费一条语句

CJSE                                  .macro Reg,Data,Address

                                                        MRW      R0,Reg

                                                        SUBI R0,Data

                                                        JNC Address                                                   

                                          .endm

 

不等跳转                            

;不等跳转  可操作RAM 00~7FH  除去R0

CJNE                                  .macro Reg,Data,Address

                                                        LDS R0,Data;Data¸øROºÍAC

                                                        EOR Reg

                                                        JNZ Address                                                   

                                          .endm

 

相等跳转                       

;相等跳转  可操作RAM 00~7FH  除去R0

CJE                                    .macro Reg,Data,Address

                                                        LDS R0,Data;Data¸øROºÍAC

                                                        EOR Reg

                                                        JZ Address                                                      

                                          .endm

 

      -1不等于0跳转                            

;-1不等于0跳转  可操作RAM 00~7FH

DJNZ                                  .macro Reg,Address      

                                                 .locallabel DJNZGO

                                                 .locallabel DJNZOUT

                                                        LDA Reg

                                                        JNZ DJNZGO

                                                        JMP DJNZOUT

DJNZGO:                                  

                                                        DEC* Reg

                                                        JNZ Address  

DJNZOUT:                  

                                                 .endm

 

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

相关文章:

42. tenx(十速)TM87系列常用宏(一)  (2010-2-8 18:2:27)

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 ?