The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: GODlike on May 29, 2005, 09:52:35 AM

Title: Sending and Reading from a COM port.
Post by: GODlike on May 29, 2005, 09:52:35 AM
I have successfully made a 16bit program for COM communication using BIOS's "int 14h". Now I want to make the same thing using MASM32. I've used the "int 14h" but I get runtime error. I've also used the command "in" and the "out" but I still get runtime error.

My question is how to read and receive from a COM port using MASM32 and if possible without using WIN32 API's functions??



Thanks!!
Title: Re: Sending and Reading from a COM port.
Post by: Tedd on May 29, 2005, 11:29:57 AM
In Win32 you're not allowed direct access to the Ints :P You're not allowed access to ports with in/out either :bdg
Look for functions with "comm" in their name - eg. "CommConfigDialog", "GetCommState", "SetupComm", "TransmitCommChar", etc
I think you need to get an id for the device, and then open it with CreateFile. You can then use the handle returned to access it.
Title: Re: Sending and Reading from a COM port.
Post by: AeroASM on May 29, 2005, 12:28:21 PM
DOing anything without using the Win32 API functions is impossible. I suggest you do what Tedd suggested.

However if you want to confuse yourself then download the KMD Kit and look at the giveio.sys driver as a way to give your program direct access to the in/out commands.
Title: Re: Sending and Reading from a COM port.
Post by: farrier on May 29, 2005, 03:39:06 PM
For the FAQ and GODlike (?):

Use the following link to set up the Com Port

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/configuring_a_communications_resource.asp

Then use the WriteFile and ReadFile function with the hCom handle created in the above link.  This works fine and requires no special drivers.  The CreateFile, WriteFIle, and ReadFile functions work fine for the parallel ports also.

farrier
Title: Re: Sending and Reading from a COM port.
Post by: Mark Jones on May 29, 2005, 04:49:41 PM
That is good to know, thanks Farrier. :bg
Title: Re: Sending and Reading from a COM port.
Post by: GODlike on May 29, 2005, 09:02:59 PM
Thanks for the support :U. I will try this and I'll post the results.