LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2011, 07:39 AM   #1
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Rep: Reputation: 15
Question 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

Last edited by topheraholic; 06-19-2011 at 07:41 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-19-2011, 08:04 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
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
 
Old 06-19-2011, 10:56 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.

Last edited by theNbomr; 06-19-2011 at 10:57 AM.
 
1 members found this post helpful.
Old 06-19-2011, 12:11 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 06-19-2011 at 12:14 PM.
 
2 members found this post helpful.
Old 06-20-2011, 07:44 AM   #5
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Original Poster
Rep: Reputation: 15
oh,thanks you guys!it helped so much!!! i learn assembly language because i wanna do reversing!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Assembly Language considered a Structured Language? theKbStockpiler Programming 4 01-30-2011 09:09 AM
How to learn assembly language? darkangel29 Programming 8 01-12-2009 12:30 PM
bios interrupt in linux assembly efdefd Programming 4 09-14-2008 10:41 PM
assembly language in linux herbertgnanaraja Programming 12 09-21-2006 03:52 AM
SPARC assembly language jclark00001 Programming 3 02-26-2003 08:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration