to read as words


Code:
 
 
 pause 2000
 
 Serout2 PORTb.7,84,["ready",13,10] 
 addr var word
 inbuff  var byte[30]
 buff var byte[30]       $4f0
 lb var byte
 hb var byte
 lc var byte
 lp var word
 Clear

 



 goto StartLoop ' Required

 String1:
 @ data "may \"Hello\"\0"

 String2:
 @ db "say",34,"hello",34,0
 
 String3:
 @ dw      0x003F,0xFC00,0x3FFC,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000;,0x00  

 '------------Flash2Ram Macro - Location insensitive -------------------------
 ASM
Flash2Ram macro buffer, msg ; Fills the buffer from flash msg
   movlw   UPPER msg
   movwf   TBLPTRU
   movlw   HIGH msg
   movwf   TBLPTRH
   movlw   LOW msg
   movwf   TBLPTRL
   movlw   low buffer		
   movwf   FSR2L
   movlw   High buffer
   movwf   FSR2H
   L?CALL  _bfill
   endm
 ENDASM  
   
 ASM   
GetAddress macro Label, Wout
    CHK?RP Wout
    movlw low Label          ; get low byte
    movwf Wout
    movlw High Label         ; get high byte
    movwf Wout + 1
    endm
  
   
   
   
   
   
 ENDASM

       


 
 
 
 
 

StartLoop: ' This loop repeats continuously just as a test.
@ Flash2Ram  _buff,_String1' Get a String from flash memory
 Serout2 PORTb.7,84, ["buff ",str buff ,13,10] '  and print it
@ Flash2Ram  _inbuff,_String2' Get a String from flash memory
 Serout2 PORTb.7,84, ["inbuff ",str inbuff ,13,10] '
 pause 500
@ GetAddress _String3 ,_addr  
for lc=0 to 3 
readcode addr ,lb
addr=addr+1 
readcode addr ,hb
addr=addr+1 
Serout2 PORTb.7,84, ["hb ",hex2 hb," lb ",hex2 lb,13,10]
next  

  
@ GetAddress _String3 ,_addr   
 for lc=0 to 3 
readcode addr ,lp
addr=addr+2 


 Serout2 PORTb.7,84, ["lp ",hex4 lp,13,10] 

next  
 
 
 
 
 goto StartLoop ' Repeat
end 
 
 

 




 
bfill: 
ASM
Next_Char
   tblrd   *+
   movf   TABLAT,w
   movwf  POSTINC2
   btfss STATUS,Z 
   goto   Next_Char
   return   
ENDASM

output

lp 3FFC
lp 0000
buff may "Hello"
inbuff say"hello"
hb 00 lb 3F
hb FC lb 00
hb 3F lb FC
hb 00 lb 00
lp 003F
lp FC00
lp 3FFC
lp 0000
buff may "Hello"
inbuff say"hello"
hb 00 lb 3F
h