assembly programming
org 0000h
sjmp main
org 0050h
main:mov r1,#5
mov r0,#30h
mov r1,#40h
back:mov a,#00h
mov a,@r0
mov @r1,a
inc r0
inc r1
djnz r7,back
end
//ext
org 0000h
sjmp main
org 0050h
main:mov r1,#5
mov r0,#30h
mov dptr,#3000h
back:mov a,@r0
movx@dptr,a
inc r0
inc dptr
djnz r7,back
end
//led
org 0000h
sjmp main
org 30h
main:mov a,#11111110B
abc1:mov p2,a
acall delay
rr a
sjmp abc1
delay:mov r3,#7
mov tmod,#10h
abc:mov tl1,#00h
mov th1,#00h
setb tr1
xyz:jnb tf1,xyz
clr tr1
clr tf1
djnz r3,abc
ret
end
//square
org 0000h
sjmp st
org 000040h
st:clr a
loop:mov p1,a
acall delay
cpl a
sjmp loop
delay:mov tmod,#20h
mov th1,#1ah
setb tr1
back:jnb tf1,back
clr tr1
clr tf1
ret
end
//sine
org 0000h
clr a
up:mov dptr,#sine
mov r0,#24
label:movc a,@a+dptr
mov p2,a
clr a
inc dptr
djnz r0,label
sjmp up
org 050h
sine:
db 127,160,191,217,237,250,255,250,237,217,191,160,127,94,63,37,17,4,0,4,17,37,63,94,127
end
//tri
org 0000h
sjmp main
main:mov a,#00h
abc:mov p1,a
inc a
cjne a,#0ffh,abc
xyz:mov p1,a
dec a
cjne a,#00h,xyz
sjmp abc
ret
end
//step
org 0000h
up:mov p1,#0h
acall delay
mov p1,#04h
acall delay
mov p1,#02h
acall delay
mov p1,#08h
acall delay
sjmp up
delay:
up1:mov r0,#00h
here:djnz r1,here
djnz r0,up1
ret
No comments: