cseg segment
         assume cs:cseg , ds:cseg
         org 100H
enter:jmp begin
;---------------------------------
         db 13,'GOODDAY from R.M.Wilson, c(o) 1986',26
string1  db '   Good   ',0DH
string2  db ' Morning! ',0DH
string3  db 'Afternoon!',0DH
string4  db ' Evening! ',0DH
string5  db '  Night!  ',0DH
string6  db ' T G I F  ',0DH

hold db 80 dup(0)     ;Holds 8 bytes for 10 characters.
screen dw 0B000H      ;Will be set correctly.
;---------------------------
   begin:xor ax,ax    ;First, decide which monitor.
         mov ds,ax
         mov ax,0B000H
         test byte ptr ds:[410H],10H
         jne over1
         add ax,800H  ;if color monitor
         over1:push cs
         pop ds
         mov screen,ax
         mov es,ax
         mov cx,2000
         mov ax,1320H
         xor di,di
         rep stosw     ;Clear screen.

         xor bp,bp
         xor di,di
         call send     ;Say "Good".

         mov ah,2CH
         int 21H       ;Get time.
         cmp ch,6
         jb nigh
         cmp ch,12
         jb morn
         cmp ch,18
         jb afte
         jmp short even

morn:    mov bp,11 
         jmp short over2  
afte:    mov bp,22 
         jmp short over2  
even:    mov bp,33 
         jmp short over2  
nigh:    mov bp,44 
         jmp short over2

   over2:mov di,8*160 
         call send 
         mov ah,2AH    ;Check whether it's Friday.
         int 21H
         cmp al,5
         jne cursor
         mov bp,55
         mov di,17*160
         call send
cursor:  xor bh,bh     ;Place the cursor and return.
         mov dx,0F00H
         mov ah,2
         int 10H
         ret
;------------------------------------------

form:    mov bl,cs:string1[bp]
         cmp bl,0DH
         jne over
         ret
       over:xor bh,bh
         shl bx,1
         shl bx,1
         shl bx,1        ;mult by 8
         push si
         add si,bx  
         mov cx,8
         rep movsb
         pop si
         inc bp
         jmp form

send:    push di         ;This routine writes the message at offset 3+bp
         push cs         ;on the screen starting at offset di.
         pop es
         mov si,0FA6EH   ;Point ds:si to address in ROM 
         mov ax,0F000H   ;where character set is stored.
         mov ds,ax
         mov di,offset hold
         call form
         push cs
         pop ds
         pop di
         mov ax,cs:screen
         mov es,ax
         xor bp,bp

         up2:mov si, offset hold
         add si,bp
                   mov cx,10
                   up:lodsb
                               mov bl,80H   ;8 bytes
                               up3:push ax
                               mov dl,32
                               and al,bl
                               jz over4
                               mov dl,219
                               over4:mov es:[di],dl
                               mov byte ptr es:[di+1],13H
                               inc di
                               inc di
                               ror bl,1
                               pop ax
                               cmp bl,80H
                               jne up3
                   add si,7
                   loop up
         inc bp
         cmp bp,8
         jl up2
         ret
;-----------------------
cseg ends
end enter

