MASM PARALLEL PORT NEED HELP BADLY...

Started by mhyshe, August 27, 2008, 05:17:34 AM

Previous topic - Next topic

mhyshe

Quote from: BogdanOntanu on August 28, 2008, 02:26:14 PM
mhyshe,

It will be more polite of you IF you DID NOT edit your top post and change it seriously AFTER people have answered your original top post. This way people can follow the flow of the discussion. Otherwise the answers might look out of order and other people will not understand the discussion.

Editing your posts after somebody did answer them should be restricted to fixing misspelled words in order to make reading easier.

Just an advice ;)

Thank you very much for the advice sir.. I just hope i could revert what have been done but I can't anymore.. Anyways' i'll follow your advice.. to the rest of my posting..

mhyshe

This is the last thing i would like to ask about controlling parallel port using masm..

How many pins can you control? what are their address. What I only know is that their address are like binary like this one... 00000000 having eight zeros or ones.. or you can use their converted hexadecimal value instead of the binary. What I want to ask you guys is that starting from what address can you command how many are they.. because for what i know some of them are use for grounds and others are reserved. Hope you could help me with this one.

Neil

As MichaelW says the output data port (for LPT1) is 378H. I only know what they do as regards a printer. Bit 0 is the data output setting, Bit 1 is the line feed setting, Bits 2,3 &4 are various initialisation settigs & Bits 5,6 & 7 are not used, but if you are not controlling a printer then you could send a 'one' out to any of them. What the actual pinouts are I don't know, maybe someone else will tell you or just look it up on the Web.

Neil

Here you are I found it straight away :-

25 Pin D-Sub Connector PinOut  Pin #  Pin Name  Pin Description and Function 
1  /STROBE  Strobe 
2  D0  Data Bit 0 
3  D1  Data Bit 1 
4  D2  Data Bit 2 
5  D3  Data Bit 3 
6  D4  Data Bit 4 
7  D5  Data Bit 5 
8  D6  Data Bit 6 
9  D7  Data Bit 7 
10  /ACK  Acknowledge 
11  BUSY  Busy 
12  PE  Paper End 
13  SEL  Select 
14  /AUTOFD  Autofeed 
15  /ERROR  Error 
16  /INIT  Initialize 
17  /SELIN  Select In 
18  GND  Strobe Ground 
19  GND  Data bit 1 and 2 Ground 
20  GND  Data bit 3 and 4 Ground 
21  GND  Data bit 5 and 6 Ground 
22  GND  Data bit 7 and 8 Ground 
23  GND  Busy and Fault Ground 
24  GND  Paper out, Select, and Acknowledge Ground 
25  GND  AutoFeed, Select input and Initialize Ground 

mhyshe

Quote from: Neil on August 30, 2008, 10:06:07 AM
Here you are I found it straight away :-

25 Pin D-Sub Connector PinOut  Pin #  Pin Name  Pin Description and Function 
1  /STROBE  Strobe 
2  D0  Data Bit 0 
3  D1  Data Bit 1 
4  D2  Data Bit 2 
5  D3  Data Bit 3 
6  D4  Data Bit 4 
7  D5  Data Bit 5 
8  D6  Data Bit 6 
9  D7  Data Bit 7 
10  /ACK  Acknowledge 
11  BUSY  Busy 
12  PE  Paper End 
13  SEL  Select 
14  /AUTOFD  Autofeed 
15  /ERROR  Error 
16  /INIT  Initialize 
17  /SELIN  Select In 
18  GND  Strobe Ground 
19  GND  Data bit 1 and 2 Ground 
20  GND  Data bit 3 and 4 Ground 
21  GND  Data bit 5 and 6 Ground 
22  GND  Data bit 7 and 8 Ground 
23  GND  Busy and Fault Ground 
24  GND  Paper out, Select, and Acknowledge Ground 
25  GND  AutoFeed, Select input and Initialize Ground 



Hehehehe i think this is indeed for a printer.. What i don't know if this is the same as what i am searching for.. il try to search for it..
il post it here if ill see it.. but hey Mr. Neil if you can find something that is used to command the LPT port using MASM i would be greatful.. thank you very much.. im searching right now..

MichaelW

For information on the parallel port try these links:
http://en.wikipedia.org/wiki/Parallel_port
http://www.beyondlogic.org/spp/parallel.htm

When programming the parallel port the first thing you need to do is determine how many parallel ports are present and what their base I/O addresses are. Under DOS you would typically start by checking the BIOS data area to determine which parallel ports the BIOS identified during its POST (Power On Self Test) routine. The BIOS stores the base I/O addresses of the first 3 parallel ports it finds in the BIOS data area at locations 40:08h, 40:0Ah, and 40:0Ch, where the 40h is the segment address of the BIOS data area and the 08h, 0Ah, and 0Ch are the offset addresses of the 16-bit words that store the base addresses. Using the Debug Dump command to do this on my Windows 2000 system I get:

-D 40:08
0040:0000                          BC 03 78 03 78 02 C0 9F           ..x.x...


Words are stored in memory with the bytes reversed, so the base I/O addresses are 3BCh, 378h, and 278h. On this system there is actually only 1 parallel port, at base I/O address 378h, and Windows is providing the others as "virtual" parallel ports. I think you will have the same problem under Windows XP. One way around this is to access the BIOS data area from a Win32 program using WinIo and the WinIo import library in include file that I posted here. When I do this on my Windows 2000 system I find only 378h listed in the BIOS data area.

Each parallel port will use 3 sequential I/O addresses starting at the base I/O address, so on my system the parallel port data port will be at I/O address 378h, the status port at 379h, and the control port at 37Ah. Note that all of the ports are 8 bit, the status port is read only, and the control port may be write only. Once you have identified the parallel port and know the base I/O address, you can then use the Debug Input and Output commands to determine if you can write to the data port write latch. Note that this assumes that you have a bi-directional parallel port, which is likely, and that bit5 of the control port is set, which on my Windows 2000 system with a printer attached to the port, it is:

-I 378
AA
-O 378 55
-I 378
55
-


In the above code I read the initial value of the data port as AAh, wrote the value 55h, and then read it back to ensure that the write succeeded. To actually write to the parallel port connector, you would need to clear bit5 of the control port, in which case you would not be able to read the value written back. See the links above for details.
eschew obfuscation

ChrisLeslie

QuoteQuote from: mhyshe on August 27, 2008, 06:17:34 am
Me and my classmate have written this program before but its such a long time and have forgotten the code
So what did it control?

mhyshe is trying to control a bank of leds to make a pretty flashing loop. There is no reason why the parallel port can't, in DOS, control a home built device since it has controllable input and output pins. Trouble is, originally, the loop counter useage was screwed up but luckily would work as a loop because of the 65526 limitation to cx.


Chris

mhyshe

Quote from: ChrisLeslie on August 30, 2008, 09:12:16 PM
QuoteQuote from: mhyshe on August 27, 2008, 06:17:34 am
Me and my classmate have written this program before but its such a long time and have forgotten the code
So what did it control?

mhyshe is trying to control a bank of leds to make a pretty flashing loop. There is no reason why the parallel port can't, in DOS, control a home built device since it has controllable input and output pins. Trouble is, originally, the loop counter useage was screwed up but luckily would work as a loop because of the 65526 limitation to cx.


Chris

yes chris.. this is entirely true.. I am just trying to control some leds connected to the parallel port by also using the parallel cable and connecting it to the said port. thus i can't the program to output the commands.. my main trouble is.. i cant communicate with the device but im sure that the port address is correct.

MichaelW

Did you clear bit 5 of the control port?
eschew obfuscation

tenkey

For LEDs, you need to be sure they are connected in the proper direction, because they have polarity. Never having hooked them up to a parallel port, I can't say if they also need current limiting resistors.

The long loops are necessary because the human eye will blur images as the frequency approaches 24 Hz. Above that frequency, the lights will look solidly lit.

I would start debugging by using DEBUG and a voltmeter. Then hook up one LED and try to turn it on and off with DEBUG. If that works, then you should be able to hook up the rest of the LEDs and run the program.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

Mark Jones

#25
It would be advisable, to wire the pins you are using through TTL buffers or inverters to your LEDs. Reason being, if you short out an LED or accidentally short out a pin while testing with a meter, the "extra chip" will go poof and not your mainboard's I/O controller. The latter is much, much harder to replace. i.e.,


               |
       Parallel|
         Port  |   U1      R1
               |   |\      ___
        Out--> |---| >o---|___|-+
        Pin    |   |/      470  |
               |   Buffer       V -> D1
               |    or          -    LED
               |   Inverter     |
               |               ===
               |               GND
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

daydreamer

trying to prepare a old pc I stripped down to a one board pentium, so I made a CDRW from data I saved from an old win98 start disk and it starts up a very incomplete msdos
but it is enough to place my asmprogram's name in autoexec.bat
I think that is the way to go
do I really need to put a worn noisy cpufan on it?, cant I just put some alumiumplates on it and put it right behind a big car electric fan?


FORTRANS

#27
Quote from: daydreamer on September 10, 2008, 10:08:33 AM
trying to prepare a old pc I stripped down to a one board pentium, so I made a CDRW from data I saved from an old win98 start disk and it starts up a very incomplete msdos
but it is enough to place my asmprogram's name in autoexec.bat
I think that is the way to go
do I really need to put a worn noisy cpufan on it?, cant I just put some alumiumplates on it and put it right behind a big car electric fan?

Hi,

   As they say on television, "insufficient data".  I
would think you could see how hot it gets in a short
time, and extrapolate to continuous usage.  I have a
Pentium laptop with no fan at all.  I also have a
Pentium desktop computer, and the only fan is in
the power supply.  If you meant a much newer
processor (PIII or better), I would use a cpu fan.
And a good heat sink designed for a CPU would
be better than aluminum plates that are not a real
heat sink.  If your motherboard supports it, you
could monitor the temperature with a TSR program.

$0.02

Steve N.

MichaelW

Since you did not specify which Pentium, I recommend that you not try running it at all without a heat sink, in good thermal contact with the processor.
eschew obfuscation

daydreamer

Quote from: MichaelW on September 10, 2008, 08:43:47 PM
Since you did not specify which Pentium, I recommend that you not try running it at all without a heat sink, in good thermal contact with the processor.
comon, I already ran it many times now like that, short intervals and it is still working, it's only a old 75mhz crap that I can throw in dustbin and put in another P1 on mobo if anything happens, even started it with win98 start CDRW successfully from a old slow CDROM drive
I have forgotten where I have lied that CDRW and what program I used that was easy to make a startable CD with