stm8s单片机流水灯的汇编语言(要求改程序)高分在线等! 100
1,将时钟设置为外部时钟源2,将一个一个亮变为2个2个亮,即12亮,然后34亮。。。程序如下#include"mapping.inc"#include"STM8S105C...
1,将时钟设置为外部时钟源
2,将一个一个亮变为2个2个亮,即12亮,然后34亮。。。
程序如下
#include "mapping.inc"
#include "STM8S105C_S.inc"
segment 'rom'
main.l
; initialize SP
ldw X,#stack_end
ldw SP,X
#ifdef RAM0
; clear RAM0
ram0_start.b EQU $ram0_segment_start
ram0_end.b EQU $ram0_segment_end
ldw X,#ram0_start
clear_ram0.l
clr (X)
incw X
cpw X,#ram0_end
jrule clear_ram0
#endif
#ifdef RAM1
; clear RAM1
ram1_start.w EQU $ram1_segment_start
ram1_end.w EQU $ram1_segment_end
ldw X,#ram1_start
clear_ram1.l
clr (X)
incw X
cpw X,#ram1_end
jrule clear_ram1
#endif
; clear stack
stack_start.w EQU $stack_segment_start
stack_end.w EQU $stack_segment_end
ldw X,#stack_start
clear_stack.l
clr (X)
incw X
cpw X,#stack_end
jrule clear_stack
intel
mov PB_DDR,#0ffh;PB口输出
mov PB_CR1,#0ffh;推挽
mov PB_CR2,#00h
rcf ;进位清0
ld a,#0ffh
next
rlc a ;字节循环左移
ld PB_ODR,a
call delay
jra next
interrupt NonHandledInterrupt
NonHandledInterrupt.l
iret
delay
push cc
ldw y,#5
loop1 ldw x,#0ffffh
loop decw x
jrne loop
decw y
jrne loop1
pop cc
ret 展开
2,将一个一个亮变为2个2个亮,即12亮,然后34亮。。。
程序如下
#include "mapping.inc"
#include "STM8S105C_S.inc"
segment 'rom'
main.l
; initialize SP
ldw X,#stack_end
ldw SP,X
#ifdef RAM0
; clear RAM0
ram0_start.b EQU $ram0_segment_start
ram0_end.b EQU $ram0_segment_end
ldw X,#ram0_start
clear_ram0.l
clr (X)
incw X
cpw X,#ram0_end
jrule clear_ram0
#endif
#ifdef RAM1
; clear RAM1
ram1_start.w EQU $ram1_segment_start
ram1_end.w EQU $ram1_segment_end
ldw X,#ram1_start
clear_ram1.l
clr (X)
incw X
cpw X,#ram1_end
jrule clear_ram1
#endif
; clear stack
stack_start.w EQU $stack_segment_start
stack_end.w EQU $stack_segment_end
ldw X,#stack_start
clear_stack.l
clr (X)
incw X
cpw X,#stack_end
jrule clear_stack
intel
mov PB_DDR,#0ffh;PB口输出
mov PB_CR1,#0ffh;推挽
mov PB_CR2,#00h
rcf ;进位清0
ld a,#0ffh
next
rlc a ;字节循环左移
ld PB_ODR,a
call delay
jra next
interrupt NonHandledInterrupt
NonHandledInterrupt.l
iret
delay
push cc
ldw y,#5
loop1 ldw x,#0ffffh
loop decw x
jrne loop
decw y
jrne loop1
pop cc
ret 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询