0

i made a code to program a clock but there's a problem
#1, its a bit messy when i view it in command prompt, the words i typed doesn't disappear so that i view the clock neatly.. also it blinks..
#2, how can i have it on marquee up and down?

.model small
.stack
.data


  x db 30
  y db 24
  

  hour_num db         ?
  min_num db           ?
  sec_num db           ?

  hour_out db    '  '
  break1 db        ' : '
  min_out db      '  ' 
  break2 db       ' : '
  sec_out db      '  '
  spacer db        '  '
  am_pm db       'AM'
  ender db          '$'


.code
  ;conventional segment
  mov AX, @data
  mov DS, AX
  mov AX, 0b800h
  mov ES, AX

  mov AX, 2c00h
  int 21h
  mov sec_num, DH

Start:
  ;clear/scroll the screen
mov AX, 2c00h
  int 21h
  mov sec_num, DH
cmp DH, AL
je Start

;call procedures
call get_time
call check_hour
call check_min
call check_sec
call create_box
call print_time

;check for keypass
mov ax, 0b00h
int 21h
cmp AL, 0
je Start


;clear the keyboard buffer
mov ax, 0800h
int 10h

call clear_screen


  ;reposition the cursor
  ;move cursor to top-left portion of the screen
  mov ah, 02h
  mov bh, 00
  mov dh, 00
  mov dl, 00
  int 10h

 ;request to DOS prompt
  mov ax, 4c00h
  int 21h

;**************
;* PROCEDURES*
;*                              * 
;**************

clear_screen proc
mov ax,0600h
mov bh,07h
mov cx,0000h
mov dx,184h
int 10h

ret
clear_screen endp


get_time proc
mov ax,2c00h
int 21h
;ch = hours
;cl = minutes
;dh = seconds
;dl = hundred seconds
mov hour_num,CH
mov min_num,CL
mov sec_num,DH

ret
get_time endp

check_hour proc
xor ah, ah
mov AL, hour_num
cmp AL, 13
jl next_hour

;if 13 or greater
sub AL, 12
mov am_pm, 80
JMP last_hour

next_hour:
;else if hour is less than or equal to 12
mov am_pm, 65

last_hour:
lea SI, hour_out
mov BL, 10
div BL

add AL, 48
mov DS:[SI], AL
inc SI
add AH, 48
mov DS:[SI], AH

ret
check_hour endp

check_min proc
lea SI, min_out
xor AH,  AH
mov AL, min_num
mov BL, 10
div BL

add AL, 48
mov DS:[SI],  AL
inc SI
add AH, 48
mov DS:[SI],  AH

ret
check_min endp

check_sec proc
lea SI, sec_out
xor AH,  AH
mov AL, sec_num
mov BL, 10
div BL

add AL, 48
mov DS:[SI],  AL
inc SI
add AH, 48
mov DS:[SI],  AH


ret
check_sec endp

create_box proc
;reposition cursor
      mov ah, 02h
      mov bh, 00
      mov dh, 08
      mov dl, 21
      int 10h
 
;display top border
      mov ah, 09h
      mov al, 2dh
      mov bh, 00
      mov bl, 09
      mov cx, 40
      int 10h

;reposition cursor
     mov ah, 02h
     mov bh, 00
     mov dh, 16
     mov dl, 21
     int 10h

;display bottom border
     mov ah, 09h
     mov al, 2dh
     mov bh, 00
     mov bl, 09
     mov cx, 40
     int 10h

mov BL, 9
     line:
     ;set cursor
     mov ah, 02
     mov bh, 00
     mov dh, BL
     mov dl, 21
     int 10h
 
     ;draw left border
     mov ah, 09h
     mov al, 7ch
     mov cx, 1
     int 10h

     ;set cursor
     mov ah, 02h
     mov bh, 00
     mov dh, BL
     mov dl, 60
     int 10h

   ;draw right border
   mov ah, 09h
   mov al, 7ch
   mov cx, 1
   int 10h
 
ret
create_box endp


print_time proc
;reposition the cursor
mov ah, 02h
mov bh, 00
mov dh, 12
mov dl, 34
int 10h

;print string
mov ax, 0900h
lea dx, hour_out
int 21h

ret
print_time endp

End
1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by saintrenz
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.