Computing.Net > Forums > Programming > Parallel Port Access in Assembly

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Parallel Port Access in Assembly

Reply to Message Icon

Name: bryboy2002
Date: December 19, 2004 at 12:48:23 Pacific
OS: XP
CPU/Ram: 256
Comment:

Hi again,

I was told by Elric that using parallel ports are better than serial ports, so I did some research to try to find out how to send data to them. After hours of surfing the internet I used this code to send data to the parallel port.

mov al,00000001
mov dx,378h
out dx,al

The purpose of the program this was included in was to turn an LED on and off. Please help me with any information you have. Source code would be great. Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: bryboy2002
Date: December 19, 2004 at 14:47:01 Pacific
Reply:

I forgot to add that I am using Windows XP and that my ports sometimes do not allow access to them without some type of permission. Any help on this would be great too.


0

Response Number 2
Name: wizard-fred
Date: December 19, 2004 at 17:07:48 Pacific
Reply:

It might be easier to use a floppy to boot and run your program in DOS.


0

Response Number 3
Name: elric
Date: December 19, 2004 at 21:08:52 Pacific
Reply:

G'day,

The parallel port is certainly better suited to what you want to do. However, with WINXP you may have access problems.
Wizard-fred's point about using "real" DOS is valid. I use an old 386 DOS machine purely for this purpose.
You can, however, get around the problem by using kernel drivers, API and MFC methods.
Have a look at this site:
www.lvr.com
It has advice on running both serial and parallel ports in WIN2000 and above.
You might also consider using VB or C++ and a DLL file suited to the task. There is one I know of called io.dll that can be used with both C++ and VB. There is also one on the lvr site.
Good luck,
Elric


0

Response Number 4
Name: BraveStone
Date: December 21, 2004 at 08:56:27 Pacific
Reply:

HI people,

As so far I've found out,there are two ways to access the parallel port: One is to open the port using CreatFile(),and the other is to call outp()with the help of inpout.dll which is to swich to the Kernel Mode when a 2000 or above OP has been detected.I have tried both,neither of them worked out:when I write one bit to the data register after calling CreatFile(),it hands up the whole program;when I tried the second method,I didn't get the expected signal at the particular pin.Anyone by any chance has any clues?


0

Response Number 5
Name: elric
Date: December 21, 2004 at 11:19:13 Pacific
Reply:

G'day,

Have you set up the hardware correctly: ie with a current limiting resistor. What port pins are you using on the parallel port?
Not all ports can source enough current (they sink it better): it might be a good idea to put a multimeter in its place (an oscilloscope would be even better) and check that the signals from the port are wrong, and it is not a fault with your hardware.
Try looking at Jan Axelson's (at lvr.com) FAQ at :http://www.lvr.com/jansfaq.htm.
If you have all those in place, post back.
Also, are you restricted to using pure assembly? I've no doubt you have bigger plans for the future, but VB6/ C++/Delphi etc will all accomplish your task easily.
regards and best wishes for Xmas and the New Year.
Elric


0

Related Posts

See More



Response Number 6
Name: bryboy2002
Date: December 22, 2004 at 11:56:14 Pacific
Reply:

Hi,

I have thought about your advice to use Visual Basic or some other language, but I would really prefer using assembly language (TASM). I have found several examples programs that use parallel ports and now know how to do it. My problem however seems to be in the hardware: when I connect the LED to pin 2 and a ground pin, it lights up when no program is running and when I tell it to turn off. It seems that I can't control and it will always be turned on. If someone could tell how to fix this, I believe I would have no more problems.
Thanks.


0

Response Number 7
Name: elric
Date: December 23, 2004 at 10:15:16 Pacific
Reply:

G'day,

TASM will do the job, if that is what you want to use;but, how have you set up the hardware?
It seems that you have two unkowns here.
Pin2 is data1 out- fine, but at what voltage?
Have you done what I suggested in my last post?
ie remove the LED circuit and put a multimeter in its place.
Does the output change when you write to the port?
When you are happy that this works, you can eliminate the PC/Printer port as the problem and look at the LED circuit in more detail.
Good luck and best wishes,
Elric


0

Response Number 8
Name: wizard-fred
Date: December 23, 2004 at 12:09:07 Pacific
Reply:

It is disturbing that pin2 is active on powerup. Apparently the port is initialized active. In normal operation the port data is valid after the BUSY is driven low and during the STROBE pulse. I feel that the Windows driver is not passing the signal through. I would prefer confirming the signals with logic analyzer or oscilloscope.


0

Response Number 9
Name: hrf
Date: January 11, 2005 at 15:18:30 Pacific
Reply:

The port is not initialized active! The parallel port is never initialised. It is just there, always ready to be used. It is an anceint contraption which (in its basic mode) acts exactly the same as it did on an 8088 in 1981 :)
The strobe signal is only called "strobe" when you are talking to printers otherwise its function is acedemic and can be controlled independantly of every other pin.
To get access to the IO ports eg 0x378-0x37C you need a kernal mode driver. Search google for "UserPort.Zip"
Once this is running you can quickly test your port by using the following:
Start > Run > "Debug"
at the - type
O378,xx (where xx is the byte you wish to write to pins 2 to 9)
and type
q
to quit

Then you can write ASM once you have got familiar.

hope this helps

HRF!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Batch file interval timer Batch File to clean folde...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Parallel Port Access in Assembly

parallel port progm. in assembly www.computing.net/answers/programming/parallel-port-progm-in-assembly-/17833.html

Parallel port access www.computing.net/answers/programming/parallel-port-access/7081.html

Parallel port communication in VB5 www.computing.net/answers/programming/parallel-port-communication-in-vb5/4260.html