打印

延时的宏 汇编自定义的一个宏,怎样加到头文件中?

[复制链接]
1341|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
龙的图腾|  楼主 | 2009-4-5 19:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
;Required Routines & Macros: 
;--------------------------------------------------------------------------------------------- 
;MACROS: 
;--------------------------------------------------------------------------------------------- 
DELAY     macro      Time                  ;Delay "Cycles" instruction cycles    
    if (Time==1)
            nop
            exitm
    endif
        if (Time==2)
            goto $ + 1
            exitm
    endif
        if (Time==3)
            nop
            goto $ + 1
            exitm
    endif
        if (Time==4)
            goto $ + 1
            goto $ + 1              
        exitm
    endif
        if (Time==5)
            goto $ + 1
            goto $ + 1                    
        nop
            exitm
    endif
        if (Time==6)
            goto $ + 1
            goto $ + 1                    
        goto $ + 1
            exitm
    endif    
        if (Time==7)
            goto $ + 1
            goto $ + 1             
        goto $ + 1
            nop
            exitm
    endif    
    if (Time%4==0)
            movlw (Time-4)/4
            call Delay_Routine
            exitm
    endif    
    if (Time%4==1)                    
        movlw (Time-5)/4
            call Delay_Routine
            nop
            exitm
    endif    
    if (Time%4==2)
            movlw (Time-6)/4
            call Delay_Routine
            goto $ + 1                    
        exitm
    endif    
    if (Time%4==3)
            movlw (Time-7)/4
            call Delay_Routine                    
        goto $ + 1
            nop
            exitm
    endif
    endm 
;--------------------------------------------------------------------------------------------- 
; DELAY: 
;--------------------------------------------------------------------------------------------- ;Delays 4w+4 cycles (including call,return, and movlw) (0=256) 
Delay_Routine        addlw     -1   ;Precise delays used in  I/O                                   
                      btfss    STATUS, Z                       
             goto    Delay_Routine
                       return 

相关帖子

沙发
ayb_ice| | 2009-4-6 12:20 | 只看该作者

直接定义一个专用宏头文件

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

9

帖子

0

粉丝