Code:
Here's a handy little program that allows you to embed a string in your program which is accessed by the preceding call. In this case, it's used to write strings to an LCD display but the principle is useful elsewhere. The code was written for a 18F2480 ;The string must be terminated by a null ie ; CALL LCD_STR ; DA "Hello",0 ;On Exit,PC on stack points to next program instruction LCD_STR ;First copy address of string to program memory indirection pointer MOVFF TOSU,TBLPTRU ;Upper word of stack pointer MOVFF TOSH,TBLPTRH ;Middle MOVFF TOSL,TBLPTRL ;Low NEXTCH TBLRD*+ ;Read next byte in string & increment pointer MOVF TABLAT,W ;Get character BZ ENDSTRG LCD_CHAR_W ;Macro to write W to display BRA NEXTCH ;This way to update return address to that following end of string null ENDSTRG ;Beware, if the string is an even length, the return address with be invalid INTERRUPTS_OFF ;Else screwy things can happen BTFSC TBLPTRL,0 ;Is return address odd? TBLRD*+ ;Increment pointer to end on an even address MOVF TBLPTRL,W ;Low MOVWF TOSL MOVF TBLPTRH,W ;Mid MOVWF TOSH MOVF TBLPTRU,W ;Upper MOVWF TOSU INTERRUPTS_ON RETURN+
James Newton of MassMind Says: " Nice! " +
file: /Techref/member/roger_froud-virgin-/index.htm, 1KB, , updated: 2012/11/29 11:13, local time: 2024/12/26 04:53,
owner: roger_froud-virgin-,
3.139.80.194:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.massmind.org/techref/member/roger_froud-virgin-/index.htm"> Member Homepage for roger_froud-virgin-</A> |
Did you find what you needed? From: "http://massmind.org/member/roger_froud-virgin-/index.htm" |