|
|||
ASSEMBLY PROGRAMMING AND OS DESIGN
<HOME>
|
CH2.3 DOS Int Calls
The main call we will be concerned with for now is the DOS interrupt call of
21h. A call to this interrupt would look like: int 21h This will transfer control of the computer to DOS in order for DOS to perform some useful task for us. In this case, we simply want DOS to return to the command prompt when we are done running our code. In order to do this, we must tell int 21h that is what we want. This is done by passing it a function number. The function number is passed in the high byte of AX which is AH. The function number for this task is 4ch. Don't worry about remembering this. You will see and use this so many times that you will not be able to forget it. Let's look at example 1 again, except this time it will be a complete program that we can type in, compile, and execute. Ex. 4 org 100h mov AX,2 ;move the number 2 into AX add AX,2 ;add 2 to AX and store the result in AX mov AH,4Ch ;function 4Ch will return us to the DOS prompt int 21h ;call the function Before you read any further, type in this code and call it ex4.asm. Compile it using the command line NASMW -o ex4.exe ex4.asm. This will compile your code and produce the executable ex4.exe. When you run the executable, it will seem like nothing happened. Although, with a closer look, you will realize that your program was not designed to produce any output and returned to the prompt as designed. Now let's print something to the screen. int 21h function 02h will output a character to the standard output which is by default the display screen. AH contains the function number 02h and DL is the character you want to display. Ex. 5
org 100h The code can be compiled using NASMW -o ex5.exe ex5.asm.
Obviously this is a very painful way to write Hello World. Lets
start looking into the basic commands available to us to make this easier. |
| www.cynergysoft.com |
Email any questions to the author, Nathan Daniels. |
Copyright © 2001 |