LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   assembly language about interrupt 21h,thanks (https://www.linuxquestions.org/questions/programming-9/assembly-language-about-interrupt-21h-thanks-887159/)

topheraholic 06-19-2011 07:39 AM

assembly language about interrupt 21h,thanks
 
why
Code:

int 21h function 6
can both use as write a character to standard output and read character from standard input?how to distinguish them? is it base on the value of DL register? because read from input needs DL to be FFh while write to output needs DL to be the character value that output.is this the only way to distinguish them?
Code:


mov ah,6
mov dl,"A"
int 21

while the other one is
Code:

mov ah,6
mov dl,0FFh
int 21
jz skip
mov char,AL

;AL contains the character’s ASCII code.

thanks very much

ButterflyMelissa 06-19-2011 08:04 AM

Hi,

The "int 21" cluster (as I use to call it) is a collection of sub funtions. Int 21 does pretty much. You address the sub funtions with a code in AH (as you seem to have done) and let that info be a "parameter" for the int 21 function.

Int 21 is pretty much a work horse...

AH = 02 writes to stdout, and AH = 09 reads from the stdin...

Thor

theNbomr 06-19-2011 10:56 AM

DOS functions (to be clear) are accessed throught he software interrupt 21H. All parameter passing is done through registers, with the AH register always containing the function code. Other registers are used according to the requirements of the function. Examples of common uses of registers or register pairs are 'DL' holding single byte data, 'DS:DX' pointing to input buffer, and 'AL' used as the return status of the function call. I haven't done any DOS assembler programming for a couple of decades, but when I did I always had one of my copies of the Programmers's PC Sourcebook by Thom Hogan nearby. In it, he says function 09H is 'Display String'. The definitive online guide to PC real-mode programming has long been Ralf Brown's Interrupt List, and in it you can find the table of Int21H functions.
MS-DOS has a fairly weak concept and implementation of 'stdout' and 'stdin', and I always resist the temptation to use those terms in the context of DOS.
--- rod.

paulsm4 06-19-2011 12:11 PM

topheraholic -

Please remember that everything you do with Int 21, MS-DOS and 16-bit assembler is *completely* obsolete.

If you really want to learn assembler, this is probably a much better reference:

Programming from the Ground Up, Jonathan Bartlett

Here's a free download of an older (but still very useful) edition:

http://savannah.nongnu.org/projects/pgubook/

PS:
Here's another good book - about 32-bit Linux assembler - that I own and heartily recommend:

Professional Assembly Language, Richard Blum

topheraholic 06-20-2011 07:44 AM

oh,thanks you guys!it helped so much!!! i learn assembly language because i wanna do reversing!


All times are GMT -5. The time now is 03:48 PM.