🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #4621

Re: Using DOS INT21 to read from a file

#4621
From: Len Reed
Date: Fri, 08 Feb 1991 21:34
39 lines
1869 bytes
In article <26647@uflorida.cis.ufl.EDU> jdb@reef.cis.ufl.edu (Brian K. W. Hook) writes:
=I am using TASM and TC++ to try and read from a file in section of code
=of mine.  I am using inline assembly....
=
=char c[2];
=
=asm {
=	mov ah, 3FH
=	mov bx, fhandle
=	mov cx, 0001H
=	mov dx, c
=	int 21
=}
=
=Now fhandle is 0 for stdin, I am just trying to read a single character.
=I want to use the DOS INT instead of read or fread since I want my code
=as small as possible.

This is misguided.  Read support is probably already pulled
in by the startup code or something else you did.  Maybe not, though.
Still, this seems a poor reason to use in-line assembly.  There may
be lower level access to this function in the TCC library.  (Microsoft
C has _dos_read, for example.)

=AX returns 86C0, which is REALLY wrong.  AX should be the number of bytes
=read or at least an error code....what am I doing wrong?

I don't know Turbo C.  I assume that "mov dx,c" will move the address of
c (in the C style of using an array name as the address of the array).
If not, you may need lea (load effective address).  I assume that DS
is set up properly; presumably this is a small model program.

Are you really doing "int 21" and not "int 21h"?  If so, you're actually
calling 15h with AH == 3Fh, which is who knows what.
-- 
Len Reed
Holos Software, Inc.
Voice: (404) 496-1358
UUCP: ...!gatech!holos0!lbr
Technical Details
Message-ID: <1991Feb8.213430.4215@holos0.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!emory!wa4mei!holos0!lbr
References: <26647@uflorida.cis.ufl.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!emory!wa4mei!holos0!lbr
From: lbr@holos0.uucp (Len Reed)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Using DOS INT21 to read from a file
Message-ID: <1991Feb8.213430.4215@holos0.uucp>
Date: 8 Feb 91 21:34:30 GMT
References: <26647@uflorida.cis.ufl.EDU>
Organization: Holos Software, Inc., Atlanta, GA
Lines: 39