-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathasm_tutorial_04.html
executable file
·136 lines (90 loc) · 3.32 KB
/
asm_tutorial_04.html
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
<HTML>
<HEAD>
<TITLE>8086 assembler tutorial for beginners (part 4)</TITLE>
<META name="description" content="Interrupts - 8086 Assembler">
</HEAD>
<BODY>
<FONT FACE="Verdana" SIZE=3>
<FONT SIZE=+1>
<B>8086 assembler tutorial for beginners (part 4)</B>
</FONT>
<BR><BR>
<FONT SIZE=+2><B>Interrupts</B></FONT>
<BR><BR>
Interrupts can be seen as a number of functions. These functions make
the programming much easier, instead of writing a code to print
a character you can simply call the interrupt and it will do everything
for you. There are also interrupt functions that work with disk drive
and other hardware. We call such functions <B>software interrupts</B>.
<BR><BR>
Interrupts are also triggered by different hardware,
these are called <B>hardware interrupts</B>. Currently we are interested
in <B>software interrupts</B> only.
<BR><BR>
<BR>
To make a <B>software interrupt</B> there is an <B>INT</B> instruction,
it has very simple syntax:
<BLOCKQUOTE>
<B>INT value</B>
</BLOCKQUOTE>
Where <B>value</B> can be a number between 0 to 255 (or 0 to 0FFh),<BR>
generally we will use hexadecimal numbers.
<BR>
You may think that there are only 256 functions, but that is not correct.
Each interrupt may have sub-functions.
<BR>
To specify a sub-function <B>AH</B> register should be set before calling
interrupt.<BR>
Each interrupt may have up to 256 sub-functions
(so we get <NOBR>256 * 256 = 65536</NOBR> functions).
In general <B>AH</B> register is used, but sometimes other registers
maybe in use. Generally other registers are used to pass parameters
and data to sub-function.<BR><BR>
The following example uses <B>INT 10h</B> sub-function <B>0Eh</B> to
type a "Hello!" message. This functions displays a character on
the screen, advancing the cursor and scrolling the screen as necessary.
<BR><BR>
<TABLE BORDER=1 CELLPADDING=10 WIDTH=50%><TR><TD>
<PRE><FONT FACE="Fixedsys">
ORG 100h ; instruct compiler to make simple single segment .com file.
; The sub-function that we are using
; does not modify the AH register on
; return, so we may set it only once.
MOV AH, 0Eh ; select sub-function.
; INT 10h / 0Eh sub-function
; receives an ASCII code of the
; character that will be printed
; in AL register.
MOV AL, 'H' ; ASCII code: 72
INT 10h ; print it!
MOV AL, 'e' ; ASCII code: 101
INT 10h ; print it!
MOV AL, 'l' ; ASCII code: 108
INT 10h ; print it!
MOV AL, 'l' ; ASCII code: 108
INT 10h ; print it!
MOV AL, 'o' ; ASCII code: 111
INT 10h ; print it!
MOV AL, '!' ; ASCII code: 33
INT 10h ; print it!
RET ; returns to operating system.
</FONT></PRE>
</TD></TR></TABLE>
<BR><BR>
Copy & paste the above program to the source code editor,
and press [<B>Compile and Emulate</B>] button. Run it!
<BR><BR>
See <A HREF="8086_bios_and_dos_interrupts.html"><B>list of supported interrupts</B></A>
for more information about interrupts.
<BR><BR><BR>
<HR>
<CENTER>
<A HREF="asm_tutorial_03.html"><B> <<< previous part <<< </B></A>
<A HREF="asm_tutorial_05.html"><B> >>> Next Part >>> </B></A>
</CENTER>
<HR>
<BR>
</FONT>
</BODY>
</HTML>