/ HELLO - "Hello, World!" program for PAL8 assembly, which also
/         happens to test the PRINTS routine, included inline below.
/
/ Created by Warren Young of tangentsoft.com, 2016.11.30
/
/ Copyright © 2016 Warren Young
/
/ Permission is hereby granted, free of charge, to any person obtaining a
/ copy of this software and associated documentation files (the "Software"),
/ to deal in the Software without restriction, including without limitation
/ the rights to use, copy, modify, merge, publish, distribute, sublicense,
/ and/or sell copies of the Software, and to permit persons to whom the
/ Software is furnished to do so, subject to the following conditions:
/
/ The above copyright notice and this permission notice shall be included in
/ all copies or substantial portions of the Software.
/
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
/ THE AUTHORS LISTED ABOVE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
/ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/ DEALINGS IN THE SOFTWARE.
/
/ Except as contained in this notice, the names of the authors above shall
/ not be used in advertising or otherwise to promote the sale, use or other
/ dealings in this Software without prior written authorization from those
/ authors.
////////////////////////////////////////////////////////////////////////


//// MAIN /////////////////////////////////////////////////////////////

PAGE 1
	CLA
	TLS		/ send null character to terminal to prepare it
	TAD (HWSTR)
	JMS PRINTS
	HLT

// "HELLO, WORLD!\r\n" in octal ASCIIZ
HWSTR,	110; 105; 114; 114; 117;	/ HELLO
	54;				/ comma
	40;				/ space
	127; 117; 122; 114; 104;	/ WORLD
	41;				/ bang
	15; 12;				/ CRLF
	0				/ null string terminator


//// PRINTS ////////////////////////////////////////////////////////////

PRINTS,0
	DCA SADDR	/ save AC as string address
PSNEXT,	TAD I SADDR	/ load next character
	SNA
	JMP I PRINTS	/ found the null terminator; leave

	TSF		/ wait for terminal to be ready
	JMP .-1
	TLS		/ write character to the terminal

	CLA		/ increment string address pointer
	TAD SADDR
	IAC
	DCA SADDR
		
	JMP PSNEXT	/ look at next character
SADDR,	0


//// END ///////////////////////////////////////////////////////////////
$
