.equ __P24FJ64GA002,1 ;required "boiler-plate" (BP) .include "p24Fxxxx.inc" ;BP #include "xc.inc" ;BP ;the next two lines set up the actual chip for operation - required config __CONFIG2, POSCMOD_EC & I2C1SEL_SEC & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSECME & FNOSC_FRC & SOSCSEL_LPSOSC & WUTSEL_FST & IESO_OFF config __CONFIG1, WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & COE_ON & BKBUG_ON & GWRP_ON & GCP_ON & JTAGEN_OFF .global ALLVar .global BLLVar .global CLLVar .global op1 .bss ;put the following labels in RAM AStr: .space 20 ;declare a string BStr: .space 20 ;declare a string stack: .space 32 ;this will be our stack area .text ;BP (put the following data in ROM(program memory)) .global _main ;BP ;get string starting addr in w1, return length in w2 strlen: push w1 clr w2 testZ: cp0.b [w1++] bra z, endStr inc WREG2 bra testZ endStr: pop w1 return op1: .byte 'a', 'p', 'p', 'l', 'e', 0 op2: .ascii "Orange\0" op3: .ascii "pear\0" op4: .byte 0 ;because we are using the C compiler to assemble our code, we need a "_main" label ;somewhere. (There's a link step that looks for it.) _main: bclr CLKDIV,#8 ;BP mov #stack,w15 ;initialize the stack pointer clr PSVPAG bset CORCON,#PSV mov #psvoffset(op4), w8 mov #AStr, w9 mainloop: repeat #10 mov [w8++],[w9++] mov #AStr, w1 rcall strlen lpbk: bra lpbk .end