Feedjit

Articles for you

Tuesday, December 31, 2013

.asm Assembly Language MASM, ASM, To Display Clock Timing COAL Sir Asim CS

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
.model small
.stack 100h
.data
 hr dw ?
 min dw ?
 sec dw ?
 am_time db " AM$";
 pm_time db " PM$";
 time_is db "Your System Current time is  $" ;
 
.code
main:
 
 mov ax,@data
 mov ds,ax
 mov es,ax    ; Put it in ES  For valid string to be displayed
 
 mov ah,2ch    ;2ch returns time hours in ch,minutes in cl,sec in dh
 int 21h
store_hours:
 mov ax,0
 mov al,ch
 mov hr,ax
store_minutes:
 mov ax,0
 mov al,cl
 mov min,ax
store_seconds:
 mov ax,0
 mov al,dh
 mov sec,ax
Calculate_hrs:
 mov ax,0
 mov cx,0
 mov ax,hr
 cmp ax,11
 jg pm_1digit
rest_time:
 cmp al,0
 jg am_2digit
 mov dl,al
 add dl,12
 mov dh,0
 mov ax,dx
 call two_digits_handle
 mov dl,':'
 mov ah,2h
 int 21h
 jmp calc_mins
am_2digit:
 call two_digits_handle
 mov dl,':'
 mov ah,2h
 int 21h
calc_mins:
 mov ax,min
 call two_digits_handle
 mov dl,':'
 mov ah,2h
 int 21h
calc_secs:
 mov ax,sec 
 call two_digits_handle
 cmp hr,12
 jnl  pmdisp
 lea dx,am_time
 mov ah,9h
 int 21h
 jmp end_lbl
pmdisp:
 lea dx,pm_time
 mov ah,9h
 int 21h
 jmp end_lbl
pm_1digit:
 sub ax,12   
 cmp ax,0
 jg  pm_2digit
 mov dl,al
 add dl,12
 mov dh,0
 mov ax,dx
 call two_digits_handle
 mov dl,':'
 mov ah,2h
 int 21h
 jmp calc_mins
pm_2digit:
 call two_digits_handle
 mov dl,':'
 mov ah,2h
 int 21h
 jmp calc_mins
;;;;;;;;;;;;;;;;;;;;;;;;; 
two_digits_handle proc
  mov  dl,10
 div dl
 mov bl,ah
 mov dl,al
 add dl,30h
 mov ah,2h
 int 21h
 mov dl,bl
 add dl,30h
 mov ah,2h
 int 21h
 ret
two_digits_handle endp

end_lbl: 
mov ah,4ch
int 21h
end main

Read More

Articles for you