2019-05-21 18:08:21 +00:00
|
|
|
org 0x7C00
|
|
|
|
bits 16
|
|
|
|
|
|
|
|
WIDTH equ 0x50
|
|
|
|
HEIGHT equ 0x18
|
|
|
|
VIDEO_MODE equ 0x3
|
|
|
|
|
|
|
|
;; see http://www.ctyme.com/intr/int-10.htm for interrupts
|
|
|
|
|
|
|
|
start:
|
|
|
|
;; Use color mode
|
|
|
|
mov ax, VIDEO_MODE
|
|
|
|
int 10h
|
|
|
|
|
|
|
|
;; Clear screen
|
|
|
|
mov ah, 0x06
|
|
|
|
mov al, 0x00
|
|
|
|
mov bh, 0x0F
|
|
|
|
mov cx, 0x0000
|
|
|
|
mov dh, HEIGHT
|
|
|
|
mov dl, WIDTH
|
|
|
|
int 0x10
|
|
|
|
|
2019-06-14 09:01:36 +00:00
|
|
|
;; Turn on interrupts
|
|
|
|
sti
|
|
|
|
|
2019-05-21 18:08:21 +00:00
|
|
|
;; Set cursor to bottom of screen
|
|
|
|
mov dh, HEIGHT
|
|
|
|
mov dl, 0x00
|
|
|
|
mov bh, 0x00
|
|
|
|
mov ah, 0x02
|
|
|
|
int 0x10
|
|
|
|
|
2019-06-14 09:01:36 +00:00
|
|
|
;; Start serial connection
|
|
|
|
mov ah, 0
|
|
|
|
mov al, 0b11100011
|
|
|
|
mov dx, 0
|
|
|
|
int 0x14
|
|
|
|
|
2019-05-21 18:08:21 +00:00
|
|
|
.loop:
|
2019-06-14 09:01:36 +00:00
|
|
|
;; Print a '.' to debug
|
|
|
|
mov ah, 0x01
|
|
|
|
mov al, '.'
|
|
|
|
mov dx, 0
|
|
|
|
int 0x14
|
|
|
|
|
|
|
|
|
|
|
|
;; Check status of COM1
|
|
|
|
mov ah, 0x03
|
|
|
|
mov dx, 0
|
|
|
|
int 0x14
|
|
|
|
|
|
|
|
;; If not ok, wait
|
|
|
|
and ah, 0x01
|
|
|
|
jz .loop
|
|
|
|
|
|
|
|
;; If ok, start reading character
|
|
|
|
mov ah, 0x02
|
|
|
|
mov dx, 0
|
|
|
|
int 0x14
|
2019-05-21 18:08:21 +00:00
|
|
|
|
|
|
|
cmp al, 0x0d ; newline
|
|
|
|
je .newline
|
|
|
|
cmp al, 0x08 ; delete character
|
|
|
|
je .change_color_mode
|
|
|
|
jmp .nonewline
|
|
|
|
|
|
|
|
.change_color_mode:
|
2019-06-05 10:44:28 +00:00
|
|
|
;; Read character
|
|
|
|
mov ah, 0x00
|
|
|
|
int 0x16
|
|
|
|
mov [color_mode], al
|
|
|
|
jmp .loop
|
2019-05-21 18:08:21 +00:00
|
|
|
|
|
|
|
.newline:
|
|
|
|
;; Scroll up window
|
|
|
|
mov ah, 0x06
|
|
|
|
mov al, 0x01
|
|
|
|
mov bh, 0x0F
|
|
|
|
mov cx, 0x0000
|
|
|
|
mov dh, HEIGHT
|
|
|
|
mov dl, WIDTH
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
;; Get current cursor position
|
|
|
|
mov bh, 0x00
|
|
|
|
mov ah, 0x03
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
;; Move cursor to beginning of screen
|
|
|
|
mov dl, 0x00
|
|
|
|
mov ah, 0x02
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
|
|
|
|
.nonewline:
|
|
|
|
|
|
|
|
;; Write character
|
2019-06-14 09:01:36 +00:00
|
|
|
mov ah, 0x09
|
2019-05-21 18:08:21 +00:00
|
|
|
mov bh, 0x00
|
|
|
|
mov bl, [color_mode]
|
|
|
|
mov cx, 0x01
|
2019-06-14 09:01:36 +00:00
|
|
|
int 0x10
|
2019-05-21 18:08:21 +00:00
|
|
|
|
|
|
|
;; Get current cursor position
|
|
|
|
mov ah, 0x03
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
cmp dl, WIDTH
|
|
|
|
jge .eol
|
|
|
|
jmp .noeol
|
|
|
|
|
|
|
|
.eol:
|
|
|
|
;; Scroll up window
|
|
|
|
mov ah, 0x06
|
|
|
|
mov al, 0x01
|
|
|
|
mov bh, 0x0F
|
|
|
|
mov cx, 0x0000
|
|
|
|
mov dh, HEIGHT
|
|
|
|
mov dl, WIDTH
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
;; Move cursor to beginning of screen
|
|
|
|
mov bh, 0
|
|
|
|
mov dh, HEIGHT
|
|
|
|
mov dl, 0x00
|
|
|
|
mov ah, 0x02
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
.noeol:
|
|
|
|
|
|
|
|
;; Move cursor forward
|
|
|
|
inc dl
|
|
|
|
mov ah, 0x02
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
halt: hlt
|
|
|
|
|
|
|
|
color_mode: db 0x05
|
|
|
|
|
|
|
|
times 510 - ($ - $$) db 0
|
|
|
|
dw 0xAA55
|