Hey dear,That's just an example excerpt to demonstrate toggling the LED at the end of each half cycle. It can only become a working example if you fill in the missing pieces. Sorry!
The DelayCy() line is a macro call to a cycle-accurate delay sub-subsystem that allows specifying delays in cycles, microseconds, or milliseconds plus or minus 'n' cycles. Just replace it with a call to your own ~1-msec delay function. However, if you're interested, I've included a DelayCy() fixed delay sub-system demo below. The sub-system can be used to produce cycle-accurate delays in your code at almost any clock (4, 8, 16, 20, 32, etc.).
Code:;****************************************************************** ; DelayCy() Demo, (C)2010, Mike McLaren * ;****************************************************************** cblock 0x70 delayhi ; DelayCy() sub-system timing variable endc ;================================================================== ; K8LH DelayCy() subsystem macro generates four instructions = ;================================================================== radix dec clock equ 4 ; 4, 8, 12, 16, 20 (MHz), etc. usecs equ clock/4 ; cycles/microsecond multiplier msecs equ usecs*1000 ; cycles/millisecond multiplier dloop equ 5 ; loop size, 5 to ??? cycles ; ; -- loop -- -- delay range -- -- memory overhead ---------- ; 5-cyc loop, 11..327690 cycles, 9 words (+4 each macro call) ; 6-cyc loop, 11..393226 cycles, 10 words (+4 each macro call) ; 7-cyc loop, 11..458762 cycles, 11 words (+4 each macro call) ; 8-cyc loop, 11..524298 cycles, 12 words (+4 each macro call) ; 9-cyc loop, 11..589834 cycles, 13 words (+4 each macro call) ; DelayCy macro cycles ; range, see above if (cycles<11)|(cycles>(dloop*65536+10)) error " DelayCy range error " else movlw high((cycles-11)/dloop)+1 movwf delayhi movlw low ((cycles-11)/dloop) call uLoop-((cycles-11)%dloop) endif endm ;****************************************************************** ; example code for simulation testing * ;****************************************************************** org 0x000 SimTest DelayCy(20*msecs) ; <- put simulator PC here goto $ ; <- put simulator break point here ;****************************************************************** ; K8LH DelayCy() subsystem 16-bit 'uLoop' timing subroutine * ;****************************************************************** a = dloop-1 while a > 0 nop ; (cycles-11)%dloop entry points |B0 a -= 1 endw uLoop addlw -1 ; subtract 'dloop' loop time |B0 skpc ; borrow? no, skip, else |B0 decfsz delayhi,F ; done? yes, skip, else |B0 goto uLoop-dloop+5 ; do another loop |B0 return ; |B0 ;****************************************************************** end
When u say replace the missing parts what do u mean ?
And how many of them?