查看: 1310|回复: 3
|
霹雳灯asm code+解说
[复制链接]
|
|
-
- status equ 3h
- portb equ 6h
- trisb equ 86h
- flag equ 25h
- org 000h
- nop
- bsf status,5
- movlw 00h
- movwf trisb
- bsf flag,0
- movlw 01h
- movwf portb
- bsf flag,0
- loop btfss status,0
- goto loop1
- comf flag,1
- loop1 btfss flag,0
- goto loop2
- rlf portb,0
- movwf portb
- goto loop3
- loop2 rrf portb,0
- movwf portb
- loop3 call delay
- goto loop
- delay movlw 0ffh
- movwf 20h
- lp0 movlw 0ffh
- movwf 21h
- lp1 decfsz 21h,1
- goto lp1
- decfsz 20h,1
- goto lp0
- return
- end
复制代码 这是霹雳灯asm code,网上来的,小弟不懂第14行(loop btfss status,0)说什么,请各位帮帮忙。
[ 本帖最后由 东邪西毒 于 17-10-2008 08:41 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 16-10-2008 08:18 AM
|
显示全部楼层
首先先找出这是用什么model的PIC
然后google它找data sheet
在datasheet 里有instruction set summary之类的 |
|
|
|
|
|
|
|
发表于 17-10-2008 08:57 AM
|
显示全部楼层
原帖由 东邪西毒 于 15-10-2008 11:26 AM 发表
这是霹雳灯asm code,网上来的,小弟不懂第11行(loop btfss status,0)说什么,请各位帮帮忙。
我的ASM很差,这是我第一次解释ASM, 有错请大家修正。
看看你那行:
loop btfss status,0
Loop 是Label, 只是标签。
btfss = Bit Test File skip Set
如是结果是“1”, 就跳去下一行。
Status 是 03H 的Register (请查看DataSheet)
Status, 0 是指 Status Byte 的Bit 0, 也就是 Carry.Bit (进位)(请查看DataSheet)
btfss Status , 0
意思是 如果 Status Register 的Bit 0 是 “1” 的话,就Skip跳去下一行。
- loop btfss status,0
- goto loop1
- comf flag,1
复制代码
如果 Status,0 = ‘1’ , 就执行 comf flag,1
如果 Status,0 = ‘0’ , 就执行 goto loop1 |
|
|
|
|
|
|
|
楼主 |
发表于 17-10-2008 08:38 PM
|
显示全部楼层
回复 3# pic 的帖子
谢谢,终于明白了,你知道为什么我会hang在那儿吗?
因为第十七行(loop1 btfss flag,0)所导致,以为loop btfss status,0 是打错了。 哈哈哈。。。 原来是对的。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|