-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtimer.asm
138 lines (104 loc) · 2.94 KB
/
timer.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
134
135
136
137
138
; this sample shows the use of a timer function (int 15h / 86h)
; this code prints some chars with 1 second delay.
; note: Windows XP does not support this interrupt (always sets CF=1),
; to test this program in real environment write it to a floppy disk using
; compiled writebin.asm. after sucessfull compilation of both files,
; type this from command prompt: writebin timer.bin
; note: floppy disk boot record will be overwritten.
; the floppy will not be useable under windows/dos until
; you reformat it, data on floppy disk may be lost.
; use empty floppy disks only.
name "timer"
#make_boot#
org 7c00h
; set the segment registers
mov ax, cs
mov ds, ax
mov es, ax
call set_video_mode
call clear_screen
next_char:
cmp count, 0
jz stop
; print char:
mov al, c1
mov ah, 0eh
int 10h
; next ascii char:
inc c1
dec count
; set 1 million microseconds interval (1 second)
mov cx, 0fh
mov dx, 4240h
mov ah, 86h
int 15h
; stop any error:
jc stop
jmp next_char
stop:
; print message using bios int 10h/13h function
mov al, 1
mov bh, 0
mov bl, 0010_1111b
mov cx, msg_size
mov dl, 4
mov dh, 15
mov bp, offset msg
mov ah, 13h
int 10h
; wait for any key...
mov ah, 0
int 16h
int 19h ; reboot
count db 10
c1 db 'a'
msg db "remove floppy disk and press any key to reboot..."
msg_size = $ - msg
; set video mode and disable blinking (for compatibility).
set_video_mode proc
mov ah, 0
mov al, 3 ; text mode 80x25, 16 colors, 8 pages
int 10h
; blinking disabled for compatibility with dos,
; emulator and windows prompt do not blink anyway.
mov ax, 1003h
mov bx, 0 ; disable blinking.
int 10h
ret
set_video_mode endp
; clear the screen by scrolling entire screen window,
; and set cursor position on top.
; default attribute is changed to black on white.
clear_screen proc near
push ax ; store registers...
push ds ;
push bx ;
push cx ;
push di ;
mov ax, 40h
mov ds, ax ; for getting screen parameters.
mov ah, 06h ; scroll up function id.
mov al, 0 ; scroll all lines!
mov bh, 1111_0000b ; attribute for new lines.
mov ch, 0 ; upper row.
mov cl, 0 ; upper col.
mov di, 84h ; rows on screen -1,
mov dh, [di] ; lower row (byte).
mov di, 4ah ; columns on screen,
mov dl, [di]
dec dl ; lower col.
int 10h
; set cursor position to top
; of the screen:
mov bh, 0 ; current page.
mov dl, 0 ; col.
mov dh, 0 ; row.
mov ah, 02
int 10h
pop di ; re-store registers...
pop cx ;
pop bx ;
pop ds ;
pop ax ;
ret
clear_screen endp