/*
 * SIMPLE HELLO WORLD EXAMPLE
 *
 * USE TRICK LEARNED FROM GARY KILDALL TO AVOID REBOOT
 * AND JUST RETURN TO THE CCP INSTEAD.
 */

0FAH:	/* ORIGIN OF THIS PROGRAM FOR CP/M */

DECLARE STACKPOINTER LITERALLY 'STACKPTR';

DECLARE BDOS$PRINT LITERALLY '9';	/* BDOS FUNCTION PRINT STRING */

DECLARE CR LITERALLY '13';		/* ASCII CARRIAGE RETURN */
DECLARE LF LITERALLY '10';		/* ASCII LINEFEED */

/* SET UP STACKPOINTER IN THE LOCAL AREA */
DECLARE STACK(16) ADDRESS, SP ADDRESS;

DECLARE HELLO$STRING DATA ('HELLO WORLD',CR,LF,'$');

HELLO: PROCEDURE BYTE;

    /*
     * PROCEDURE TO CALL BDOS FUNCTIONS
     */
    BDOS: PROCEDURE(FUNC,PARM);
        DECLARE FUNC BYTE;
        DECLARE PARM ADDRESS;
        DECLARE BDOS$JUMP LITERALLY '3206H';
        GO TO BDOS$JUMP;
    END BDOS;

    /*
     * MAIN PROGRAM, PRINT STRING TO CONSOLE AND TERMINATE
     */
    SP = STACKPOINTER; STACKPOINTER = .STACK(LENGTH(STACK));
    CALL BDOS(BDOS$PRINT,.HELLO$STRING);
    STACKPOINTER = SP;
    RETURN 0;

END HELLO;

EOF
