-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptoday.asm
133 lines (90 loc) · 1.8 KB
/
ptoday.asm
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
; ptoday.asm
; Author: Nathan Acosta
; Date: February 22 2018
.MODEL small
.STACK 100h
.DATA
Today1 DB 10, 13, 'Today is $'
.CODE
Today PROC
mov ax, @data
mov ds, ax
;First display the message
mov dx, OFFSET Today1
mov ah, 09h
int 21h
;Get system date
mov ah, 02ah
int 21h
;al contains day of week
;cx contains the year
;dh contains the month
;dl contains the day
;save the year
push cx
;save the day
mov cl, dl
mov ch, 0
push cx
;save the month
mov dl, dh
mov dh, 0
push dx
;display month digits
call disp10
;move / to character holder
mov dl, '/'
; display the character
mov ah, 02h
int 21h
;display day digits
call disp10
;move / to character holder
mov dl, '/'
; display the character
mov ah, 02h
int 21h
;display year digits
call disp10
;Exit to DOS
mov al, 0
mov ah, 4ch
int 21h
Today ENDP
disp10 PROC
;pop instruction pointer from stack
pop bx
;pop the number to be displayed
pop ax
;push the ip back on the stack
push bx
;set up counter and set it to zero
mov cx, 0
;set divisor to 10
mov bx, 10
numdiv: ;label to return to when ready to divide again
;setup division
mov dx, 0
;divide
div bx
;save the remainder
push dx
;increment the counter
add cx, 1
;check to see if quotient is zero
cmp ax, 0
;if not, make your way to numdiv
jne numdiv
numdisp:
; retrieve a digit from storage - into dx
pop dx
;change digit into character
add dl, 30h
;display the character
mov ah, 02h
int 21h
;if more digits, make your way to numdisp
LOOP numdisp
ret
disp10 ENDP
END Today