face allan's uh homepage worm
schoollinks what is the matrix

> SCHOOL > ICS 312 > INPUT/OUTPUT COMMANDS


The following is a summary of the input and output commands and their usage:


Input and output are achieved through the execution of predefined DOS functions that you specify in the AH register. To perform a function, you must set AH to the appropriate function number. Then, issue the command INT 21H to execute the function. (See Table of functions for the different function numbers.)

If you want to send a character to the screen, you must first copy the character to the DL register. To print a string, copy the offset of the string variable to the DX register. This can be done by copying the offset of the string to DX (MOV DX,OFFSET VAR1) or loading the effective address to DX (LEA DX,VAR1). Note that strings must end with a terminator ('$').

Example: To print a question mark to the screen...

         MOV DL,'$'
         MOV AH,2
         INT 21H

The order in which the above MOV directives are issued is not important. INT 21H will execute whatever function number is currently in AH and print whatever is specified by DX (or DL).

See Input/Output example for examples of getting an input character and displaying a string to the console.


INT 21H Function Numbers (for AH)
1
Input a character to AL
2
Print a character from DL
9
Print a string whose address is in DX


Go Back to 312 Page


Last modified: 01/31/00

 

main | school | links