Storing data to program memory with MPASM

Status
Not open for further replies.

kemalkemal

Member level 1
Joined
Jan 27, 2013
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,672
Hi
this is my demo code in order to see whats going on when i use directives like dw or da.
Code:
	list		p=16f877A	
	#include	<p16f877A.inc>	
		__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
	ORG     0x000           
	nop			 
  	goto    main            
	ORG     0x004            
  	retfie                  
main
string1	dw	"xxddd",0
string2	da	"ddfsfdg"
movlw	b'01000110'
goto	main
	END
when i animate it, as shown in the picture below, PCL is loaded with 0x05 normally ,

then one step later it is loaded with 0x4A and going somewhere else skipping string2 line.

why is that ?
(My final aim is to load some string into the program memory and then call them later in order to send an LCD.)
 

When I delete the
Code:
string1	dw	"xxddd",0
line everything became fine. I am able to store packed Ascii codes of "ddfsfdg" into the program memory. But what is the point to store data into the program memory if I have no way to extract that data. By manipulating PCL i can reach to the related portion of program memory but a tool to extract data is not to my knowledge. Is there a way to do it for 16F877A? Thanks
 

Thanks to edaboard community i think i found the solution. key word is IDASM16.ASM which a source file that stays in your MPASM file. You must use this with a relocatable code. If i should brief it there is "init_entry_to_addr" variable in IDASM16 which shows you the data memory address of your idata string. Of course if your idata string is composed of 3 characters than IDASM16 increases init_entry_to_addr one by one each time it stores your variable into the data memory. If you want to use your variable may be you can put a call to your subroutine in IDASM16.
(IDASM16 code section)
Code:
	bsf     STATUS, IRP               ;set the IRP bit.
	movwf   INDF
[COLOR="#FF0000"][B];;;;---->>>call subroutine from here[/B][/COLOR]
;  After copying one entry we need to:
;    1. Increment the program memory (source) address
;    2. Increment the data memory (destination) address
;    3. Decrement the init_entry_size

        BANKSEL init_entry_from_addr

(PS:I dont guarantee that my writings are completely right.)
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…