this might do what you want
note with the da method char values must be<128 ie 7 bit ascii
just noticed I left an arraywrite in there it can/should be removed and the bit setting the 0 at end of the string was fixed too
Code:'**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 4/14/2015 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 4/14/2015 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** #CONFIG CONFIG FOSC = INTIO67 CONFIG FCMEN = OFF CONFIG IESO = OFF CONFIG PWRT = OFF CONFIG BOREN = SBORDIS CONFIG BORV = 18 CONFIG WDTEN = ON CONFIG WDTPS = 512 CONFIG CCP2MX = PORTC CONFIG PBADEN = OFF CONFIG LPT1OSC = OFF CONFIG HFOFST = ON CONFIG MCLRE = ON CONFIG STVREN = ON CONFIG LVP = OFF CONFIG XINST = OFF CONFIG DEBUG = OFF CONFIG CP0 = OFF CONFIG CP1 = OFF CONFIG CP2 = OFF CONFIG CP3 = OFF CONFIG CPB = OFF CONFIG CPD = OFF CONFIG WRT0 = OFF CONFIG WRT1 = OFF CONFIG WRT2 = OFF CONFIG WRT3 = OFF CONFIG WRTC = OFF CONFIG WRTB = OFF CONFIG WRTD = OFF CONFIG EBTR0 = OFF CONFIG EBTR1 = OFF CONFIG EBTR2 = OFF CONFIG EBTR3 = OFF CONFIG EBTRB = OFF #ENDCONFIG define OSC 64 osccon=$70 '64 mhz OSCTUNE.6=1 pause 2000 Serout2 PORTb.7,84,["ready",13,10] Addr var word Char var byte cnt var word inbuff var byte[30] buff var byte[30] Clear goto StartLoop ' Required String1: @ da "This is a string",0 AnotherString: @ da "Here is another string",0 '------------GetAddress Macro - Location insensitive ------------------------- ASM GetAddress macro Label, Wout ; Returns the Address of a Label as a Word CHK?RP Wout movlw low Label movwf Wout movlw High Label movwf Wout + 1 endm ENDASM ASM Loadb macro buffer CHK?RP _cnt movlw low buffer movwf FSR2L movlw High buffer movwf FSR2H endm ENDASM ARRAYWRITE buff,["123"] StartLoop: ' This loop repeats continuously just as a test. @ GetAddress _String1, _Addr ' Get address of String @ Loadb _inbuff CNT=0 gosub StringOut ' Send the String Serout2 PORTb.7,84, ["inbuff "," c ",hex CNT," ",str inbuff\CNT ,13,10] ' New Line @ GetAddress _AnotherString, _Addr ' Get address of String @ Loadb _inbuff CNT=0 gosub StringOut ' Send the String Serout2 PORTb.7,84, ["inbuff "," c ",hex CNT," ",str inbuff\CNT ,13,10] ' New Line pause 500 goto StartLoop ' Repeat StringOut: ' Send the string out via Hserout Readcode Addr, Char ' Get a character if Char = 0 then StringDone ' Look for Null char, Stop if found bfill: asm CHK?RP _Char movf _Char ,w movwf POSTINC2 endasm cnt=cnt+1 Addr = Addr + 1 ' Point to next character goto StringOut ' Continue with rest of the string StringDone: asm movlw 0 movwf INDF2 endasm return end




Bookmarks