;This program moves a message across the screen one letter at a time
.model small
.stack 100h
.data
msg         db  'Warning!  Meltdown in 02 minutes !!!!',0
end_col     db  ?
screen_char db  ?
screen_attr db  ?
.code
main:   mov ax,@data
	mov ds,ax
	mov dh, 10              ; row to print message
	mov dl, 19              ; start column for message
	mov bl, 84h             ; flashing red on black
	mov si, offset msg
msg_lp: cmp byte ptr [si],0
	je fini
	mov al, [si]
	call float
	inc si
	inc dl
	jmp msg_lp
	
fini:
	mov ax, 4c00H
	int 21H

float   proc
;
; this subroutine "floats" an ascii char from the right side of the
; screen, restoring the chars it passes over
;  INPUTS:
;  al = ascii char
;  bl = attribute colors
;  dh, dl = row, col
;
	push dx
	mov end_col, dl         ; save ending column
	mov dl, 79              ; starting position to write char
draw_it: 
	call setpos
	call save               ; save ascii + attrib in screen_char
				; and screen_attrib
	call paint_it
	call delay
	call restore_it         ; restore screen as it was
	dec dl                  ; next char to left
	cmp dl, end_col
	jae draw_it
	call paint_it           ; repaint it to screen
	pop dx
	ret
float   endp
setpos  proc
;
; sets cursor at (dh, dl)
;
	push ax
	push bx
	xor bh, bh              ; set page
	mov ah,2                ; set cursor subfunction
	int 10h
	pop bx
	pop ax
	ret
setpos  endp
paint_it proc
;
; puts 1 char on the screen. assumes cursor already set
; INPUTS: al - char
;         bl - attribute
;
	push ax
	push bx
	push cx
	mov cx, 1               ; one char output
	mov ah, 9               ; write char subfunction
	mov bh, 0               ; page 0
	int 10h
	pop cx
	pop bx
	pop ax
	ret
paint_it endp
save    proc
	push ax
	push bx
	mov bh, 0
	mov ah, 8
	int 10h
	mov screen_attr, ah
	mov screen_char, al
	pop bx
	pop ax
	ret
save   endp
restore_it  proc
	push ax
	push bx
	mov al, screen_char
	mov bl, screen_attr
	call paint_it
	pop bx
	pop ax
	ret
restore_it endp
delay:  push ax
	push bx
	mov bx, 5
big:    mov ax, 0ffffh
lp:     sub ax, 1
	jnz lp
	sub bx,1
	jnz big
	pop bx
	pop ax
	ret
END   main