ucsam
Advanced Member level 4
- Joined
- Oct 12, 2010
- Messages
- 119
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- kathmandu,nepal
- Activity points
- 2,058
i use 8051 and and 8051 does not have instructions like movlw and movwf..can u please just provide the C code?
thanks
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 org 0000h sjmp start org 0050h start: mov a,#00h setb p0.0 x:jnb p1.0,is1 jnb p1.1,ds2 cjne a,#00h,x11 sjmp x x11: clr p0.0 mov r2,a x1: lcall delay djnz r2,x1 setb p0.0 mov r1,a mov a,#64h subb a,r1 ; a = a - r1 mov r2,a ; result into r2 reg mov a,r1 ; a old value from r1 x12: lcall delay djnz r2,x12 sjmp x is1: add a,#10h loop: jnb p1.0,loop sjmp x11 ds2: subb a,#10h loop1: jnb p1.1,loop1 sjmp x11 delay: mov r3,#0ffh q:djnz r3,q ret end
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 main: btfsc PORTB,1 call mode_change bsf PORTB,0 call delay_1 bcf PORTB,0 call delay_2 goto main mode_change: incf delay_temp movlw D'04' subwf delay_temp,0 btfss STATUS,Z clrf delay_temp return delay_1: movf delay_temp,W sublw D'0' btfsc STATUS,Z delay of 25msec with return instruction (Depending on speed you want for ON time for 100msec) movf delay_temp,W sublw D'1' btfsc STATUS,Z delay of 50msec with return instruction (Depending on speed you want for ON time for 100msec) movf delay_temp,W sublw D'2' btfsc STATUS,Z delay of 75msec with return instruction (Depending on speed you want for ON time for 100msec) movf delay_temp,W sublw D'3' btfsc STATUS,Z delay of 100msec with return instruction (Depending on speed you want for ON time for 100msec) delay_2: movf delay_temp,W sublw D'0' btfsc STATUS,Z delay of 75msec with return instruction (Depending on speed you want for ON time for 100msec) movf delay_temp,W sublw D'1' btfsc STATUS,Z delay of 50msec with return instruction (Depending on speed you want for ON time for 100msec) movf delay_temp,W sublw D'2' btfsc STATUS,Z delay of 25msec with return instruction (Depending on speed you want for ON time for 100msec) movf delay_temp,W sublw D'3' btfsc STATUS,Z delay of 0msec with return instruction (Depending on speed you want for ON time for 100msec)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?