💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › MiscInfo › Programmin… captured on 2023-01-29 at 10:17:37.

View Raw

More Information

-=-=-=-=-=-=-


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <ek273vcmbhe8g33rgad43o0bsies9mvqah@4ax.com>,
Jeff Blakeney  <CUTjblakeney@sentex.net> wrote:
>On Sun, 26 Jan 2003 06:18:08 GMT, "Terry & Utahna"
><tolsen64@hotmail.com> wrote:
>
>>It's been many years since I've done any assembly programming.  Now I'm
>>working on a project but for the life of me I can't remember the "inline
>>print" routine I used to use.  It went something like:
>>
>>    jsr PrintRoutine
>>    asc "Hello World!",00
>>    ...continue assembly code here
>>
>>The print routine somehow knew to RTS to the instruction just after the 00
>>termination on that string.  I think the return address was pulled from the
>>stack and the "modified" return address was pushed just before the RTS...Am
>>I close????
>
>Yes, that is what you can do for an inline print routine.
>
>The print routine needs to pull the RTS address off the stack and use
>that as the address of the first character to print and when it hits
>the $00 at the end of the string it needs to push the address of the
>location after the $00 and do an RTS.

Here's one that I used in a hex editor I wrote.  In my program, strings were
surrounded by nulls on each side to tell the relocating loader where they
were.  If you put the string right after the JSR, change the ADC #2 near the
top to ADC #1.


MSGOUT	PLA		;get the string's address
	CLC	
	ADC	#2
	STA	]1
	PLA	
	ADC	#0
	STA	]1+1
]1	EQU	*+1
]2	LDA	$FFFF	;get a character
	BEQ	]4	;exit if null
	LDY	LDFLAG	;convert lowercase to uppercase?
	BNE	]3
	JSR	CONVERT
]3	JSR	COUT	;print it
	INC	[1
	BNE	[2
	INC	[1+1
	BNE	[2
]4	LDA	[1+1	;push new return address onto stack
	PHA	
	LDA	[1
	PHA	
	RTS 

(Get the program this came out of at http://alfter.us/files/tmle.1.2.bxy. 
It's GPL'd, so you can use it in your own GPL'd software.)

  _/_   Scott Alfter
 / v \  salfter@salfter.dyndns.org
(IIGS(  http://salfter.dyndns.org   Top-posting!
 \_^_/  pkill -9 /bin/laden         >What is the most annoying thing on Usenet?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+NWlsVgTKos01OwkRAtGoAJ9JPzt7KhCxBbI9lhlpXSM32vDqqQCfZ8Rj
xlx4vytD8SQDGR2O1VcbOtA=
=oAss
-----END PGP SIGNATURE-----