Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How Create Loop with large repeat?(8051 ASM)

Status
Not open for further replies.

panda1234

Full Member level 2
Joined
Jan 22, 2015
Messages
125
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,172
Hi,
I want to create loop with large repeat (for example 500) how do this?
Thanks
 

i use below delay routines in my assembly

FLASHDEL MOVLW D'255'
MOVWF TIMER2
FLD1 MOVWF TIMER1
FLD2 DECFSZ TIMER1,F
GOTO FLD2
DECFSZ TIMER2,F
GOTO FLD1
RETURN

RFDELAY MOVLW D'30'
MOVWF TIMER3
RFDL CALL FLASHDEL
DECFSZ TIMER3
GOTO RFDL
RETURN




PULSEDEL MOVLW D'225' ;TIMER 1 VALUE THE LARGER THE LONGER THE DELAY
MOVWF TIMER1
PDLOO DECFSZ TIMER1,F
GOTO PDLOO
RETURN
where timer1, timer2, and timer3 are the 3 variables

but in c the way is far simple, u just need to type

delay_ms(500); or dellay_us(500);
 

@peter002

You have posted PIC asm code. He is asking for 8051 asm code.
 

brother the procedure is same for any processor, let me expain... this code is for pic, i never worked on 8051 processor but still the idea remains same for any processur although the language is diff...

the delay is only the time for what we keep the processor busy in any useless work..

in my code i filled three variable with 255 decimal value then i meade codefor cpu to decrese them only, that code vl work ti the variable gets empty and after that the routine quits...

ok let me xplain the code, lets assume my code for the smallest delay

PULSEDEL MOVLW D'225' ;TIMER 1 VALUE THE LARGER THE LONGER THE DELAY
MOVWF TIMER1
PDLOO DECFSZ TIMER1,F
GOTO PDLOO
RETURN

look the above code, in that first line is "
pulsedel movlw d'255'
here
is the lable of the routine, wen ever u need to call it, the instruction wud be "
call pusedel
"
next line is
movlw d'255
', that means mov decimal 255 or hex ff or binary 11111111 to accumulator

next line is "
movwf timer1
" , means move the contents of accumuator to the variable named timer1, so timer1 holds a value 255 in it..

now in the next line
is a label, next command is
decfsz timer1,f
, that means decrement the file named as timer1 by 1, ,f means the result after decrementation shud be kept in the timer1 file, but if after decrement the file gets 0 then skip the very next command, so decrement keeps happening till the timer1 gets zeror and cpu jumps to pdloo everytime, but as the file gets 0 the cpu skippes goto command and the routine quits... decfsz means decrements file but skip next command if file gets 0..

thats simple, now u can make the delay routine having same idea for ur processor..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top