pusha		; Push all registers

	mov ah,3
	mov bh,0
	int 10h
	mov byte [.row],dh
	mov byte [.col],dl

    mov ah,0Ah			; INT 10h teletype
	mov bh,0			; Graphics page 0
	mov bl,01001111b	; Bright white on red
	mov cx,1

.loop:
    lodsb		; Get byte from string
    or al,al	; Null terminator reached?
    jz .done	; Yes, end printing

	cmp al,0Ah		; \n reached?
	je .newline		; Yes, go to the special handler

    int 10h		; No, print the character
    
	cmp byte [.col],80
	je .newline

	inc byte [.col]

	pusha
	mov ah,02h	; Cursor to near upper corner of the window
	mov bh,0  ; Make sure Page is set to 0
	mov dh,byte [.row]
	mov dl,byte [.col]
	int 10h
	popa
	
	inc word [.charsp]	; Increment chars printed
	jmp .loop		; Loop!

.done:
	popa	; Pop all registers
    ret		; Return

.newline:
	mov al,0Dh	; CR
	int 10h
	mov al,0Ah	; LF
	int 10h
	
	inc byte [.row]
	mov byte [.col],0
	
	pusha
	mov ah,02h	; Cursor to near upper corner of the window
	mov bh,0  ; Make sure Page is set to 0
	mov dh,byte [.row]
	mov dl,byte [.col]
	int 10h
	popa
	
	jmp .loop	; Loop!

.charsp dw 0
.row db 0
.col db 0