' PCode.bas ' Quick Demo Program ' showing how you can play with 
' Program Code Space ' 
' Only works on PICs that allow access to Program Codespace 
' like the 16F876, 16F877 etc... ' 
' Melanie Newman ' 17/11/2003 ' ' 
' Hardware Defines ' ---------------- 
' Change these to suit your LCD Configuration 
DEFINE LCD_DREG PORTB 		' Port for LCD Data 
DEFINE LCD_DBIT 4 			' Use upper 4 bits of Port 
DEFINE LCD_RSREG PORTB 		' Port for RegisterSelect (RS) bit 
DEFINE LCD_RSBIT 1 			' Port Pin For RS BIT 
DEFINE LCD_EREG  PORTB 		' Port for Enable (E) bit 
DEFINE LCD_EBIT 3 			' Port Pin For E BIT 
DEFINE LCD_BITS 4 			' Using 4-bit bus 
DEFINE LCD_LINES 2 			' Using 2 line Display 
DEFINE LCD_COMMANDUS 2000 	' Command Delay (uS) Define 
LCD_DATAUS 50 				' Data Delay (uS) ' 
' RAM Assignments & Variables ' 
--------------------------- 
PCAddress VAR WORD 			' Used to determine ADDRESS of Data ' within Program Code space 
PCData 	  VAR BYTE 			' Data Variable - in this example a BYTE '  
PCWord    VAR WORD 			' but could be a WORD as each memory ' address is capable of storing 14-bits
' Start Program ' ============= 
			 Pause 1000     ' Wait For LCD TO settle 
DoitAgain: 	 PCAddress=7190 ' Pointer to start of Data area 
' ' Read & Display till we get a stop character ' 
------------------------------------------- 
ReadCodeLoop:ReadCode PCAddress,PCData  ' Sequentially read bytes 
			 IF PCData>0 Then 			' Until a Stop character Is found 
			 LCDOut PCData 				' Print all Data 
			 PCAddress=PCAddress+1 		' Remembering TO increment our address 
			 GoTo ReadCodeLoop 
			 EndIF 
			 Pause 2000 
' ' Read a set number of locations ' (two in this case - to Clear the LCD) ' 
------------------------------------- ' 
			 For PCAddress=7190 TO 7191 ' Read-in bytes from a set location 
			 ReadCode PCAddress,PCData 
			 LCDOut PCData 
			 Next PCAddress 
			 Pause 1000 
			 GoTo DoitAgain 
			 End 						
' ' Program Codespace Reserved for Data ' 
----------------------------------- 
' If you're leaving comments between the Asm AND EndAsm ' statements, do so in Assembler style with a ';' 
             Asm CODE 7190 ; This statement sets the ADDRESS location DB 254 DB 1 
            			   ; DB statements allow you TO preset DB "Hey, Beautiful" 
				           ; your Program Code space - one BYTE per word DB 254 DB 192 DB "What's Cookin?" 
				           ; You can even save alphanumeric strings DB 0 
			 EndAsm 