/ HELLO - "Hello, World!" program for PAL8 assembly.
/
/ This also happens to test the PRINTS routine, included inline below.
/
/ Created by Warren Young of tangentsoft.com, 2016.11.30
/
/ Copyright © 2016, 2018 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-1)	/ point AC at word before output string
	JMS PRINTS	/ print the string following it
	HLT

// "HELLO, WORLD!\r\n" in octal ASCIIZ with the 8th bit set per PDP-8
// terminal I/O conventions: http://homepage.cs.uiowa.edu/~jones/pdp8/refcard/65.html
HWSTR,	310; 305; 314; 314; 317;	/ HELLO
	254;				/ comma
	240;				/ space
	327; 317; 322; 314; 304;	/ WORLD
	241;				/ bang
	215; 212;			/ CRLF
	0				/ null string terminator


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

TYPE,   0		/ helper routine for sending a single character
	TSF
	JMP .-1
	TLS
	CLA
	JMP I TYPE

SADDR=10		/ autoinc register for walking the string
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
	JMS TYPE	/ print that character
	JMP PSNEXT	/ look at next character


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