;-------------------------------------------------------------------------------
; Print string: R1 - string address, 0 is string terminator, corrupts R0
PRINT:
1$:             MOVB    (R1)+, R0       ; MOV affects processor flags!
                BEQ     RET             ; return if end of the string is reached
2$:             TSTB    @#177564        ; channel 0 is ready?
                BPL     2$              ; wait if not
                MOV     R0, @#177566    ; send symbol into the channel 0
                BR      1$              ; next symbol
RET:            RETURN

newline:
	mov r0,-(sp)
		mov #15,r0		;CHR 13
		jsr PC,PrintChar
		mov #12,r0		;CHR 10
		jsr PC,PrintChar
	mov (sp)+,r0		
	RTS PC
PrintChar:		;Only first 6 characters of symbols are used


	tstb @#177564
	bpl PrintChar		;Wait for transmit ready
	mov r0,@#177566 	; transmit data
	RTS PC
; Subroutine: Waiting for a character from the keyboard: R0 = received character
WaitChar: 
		TSTB @ # 177560
		BPL WaitChar
		CLR R0
		MOVB @ # 177562, R0; character in R0
		CMPB R0, # 33
		BNE RETN
ESCKEY: TSTB @ # 177560
		BPL ESCKEY
		MOVB @ # 177562, R0; character in R0
		BIS # 15400, R0; # 33 in high byte
RETN: 	RETURN
