At 09:09 AM 12/9/2004, Jianhua Zhang wrote: >I have a small delay subroutine in my code: > >..... >call delay >.... > >delay > nop > nop > nop > return > >Now I want to replace the 'call delay' with some 'nop's. >How many 'nop' should I use so the program will run same time as the 'call >delay'? I know a 'call' equals 2 'nop's. what about the 'return'? Others have already mentioned that call and return both require 2 cycles each. But I'm curious: why do you want to eliminate the subroutine call. Are you running out of stack space? If you wanted to achieve the same delay as multiple nop commands but use less code space (and not need any stack space), you could also replace pairs of NOP commands with "goto $+1" so long as you don't cross any 2k page boundaries. In other words, nop nop nop nop nop nop nop is the same as: goto $+1 goto $+1 goto $+1 nop This is an old trick first mentioned by Andy Warren and is one of those brilliant tricks that seem obvious once you've seen it. The problem is seeing that first time! dwayne -- Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 20 years of Engineering Innovation (1984 - 2004) .-. .-. .-. .-. .-. .-. .-. .-. .-. .- `-' `-' `-' `-' `-' `-' `-' `-' `-' Do NOT send unsolicited commercial email to this email address. This message neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email. _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist