Subscribe For Free Updates!

We'll not spam mate! We promise.

Wednesday, 20 March 2013

Program to find factorial using 8051


Program to find factorial using 8051  :

MOV R1,#04 
MOV R0,#04 
MOV A,R0
CALL:DEC R0
MOV F0,R0
MUL AB
DJNZ R1,CALL
 SJMP 0

Tuesday, 19 March 2013

Program to generate 50msec delay



26. Program to generate 50msec delay:

mov tmod,#01 ;select timer 0
here:mov tl0,#0fdh ;load tl0 with 0fdh
mov th0,#4bh ;load th0 with 4bh
cpl p1.5 ;compliment p1.5
acall delay ;call delay routine
sjmp here ;jump to here
delay:mov r1,#0c8h ;load r1 with data 0c8h
l1:setb tr0 ;set bit tr0
again:jnb tf0,again ;repeat till tf0=0
clr tr0 ;clear tr0
clr tf0 ;clear tf0
djnz r1,l1 ;decrement r1, jump to l1, if not equal to 0
ret
end