Author Topic: Parallel port problems  (Read 13807 times)


  • Guest
Parallel port problems
« on: November 11, 2004, 02:48:50 AM »
I am having trouble writing directly to the parallel port. I've tried writing to ports 3BCh, 378h, and 278h with no luck. Any idea what may be going wrong, and would anyone be able to supply example code for directly programming the parallel port, or good sources of info on how to in asm? Thanks.


  • Guest
Re: Parallel port problems
« Reply #1 on: November 13, 2004, 10:36:53 PM »
Can anyone help??

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Parallel port problems
« Reply #2 on: November 14, 2004, 07:08:05 AM »
What happens when you have "no luck"? What OS? Are you the same "nobody" who's trying to do this in Linux? I *think* that under "real dos", you'd have actual access to the hardware. Under "vm86/dos" or Win9x, the ports are emulated - usually it should work the same as "real" access... with exceptions... the IDE controller, for example, seems to be "off limits". I understand NT-based Windows blocks access to ports entirely, the way around it is to write a "vxd" (virtual device driver) - maybe other options(?). Under Linux, access is blocked, but you can get permission with sys_ioperm or sys_iopl. I mentioned this to the "linux nobody", and (s)he responded with a reference to a LRMI library - sounds interesting, but I don't know anything about it. I suppose you'd use it like any other library(?)...

If I were trying to learn port programming, I think I'd start out in "real dos" - booting from floppy if all else fails - just to eliminate any "complications". But assuming we've got access, one way or another, I think there's more to it than just writing to 378h (or wherever - that's most likely, I think). I think I'd first read the status port (at 379h - or "base + 1"), and check to see if we're "selected" and not "busy" or "out of paper"... maybe we can check just the "no error" bit(?). Then write our data to 378h. Then, I think we have to "strobe" bit 0 of the control port (37Ah or "base + 2") before we can expect to see our data appear on the pins.

Then there's the question of what's attached to this parallel port. I doubt if a modern printer will do anything sensible if you just start throwing ascii at it - I suspect there's some "setup" required. I used to be able to get what I wanted out of a 9-pin dot-matrix, to a degree, but I imagine it's more complicated these days! The printer manual would help... some... probably...

If it's something else... a cable to another computer, perhaps, the receiving end might have some responsibilities like sending an ACK(?). The "linux nobody" mentioned that the value remained 0FFh... If this was determined by means of an LED readout (as opposed to simply reading the port - 0FFh is what I see when I try to read the IDE controller from win98, for example), that would be ideal. Unless I'm mistaken, there are plans for such a device in the old AoA16 "lab manual" available at Webster - probably easily found other places, too. If someone had the ambition to build such a device... Failing that, I'd at least display every byte I read back... But I lack confidence in what I might read back from an OS that might be "emulating" things...

You can get the basic info on the ports from Ralf Brown's Interrupt List ("ports.lst", not "interrup.lst", of course). I imagine a google for "parallel port FAQ" would turn up more than you want to know. Maybe if you show us what's not working, somebody can spot something...



  • Guest
Re: Parallel port problems
« Reply #3 on: November 15, 2004, 03:22:33 AM »
I looked around and tried to use the information I found to edit the code I wrote, but it seems it still doesnt work. I tried both an led and a voltometer to detect a signal. here is the code:

org 07ch
   mov dx,[ppb+1]
   in al,dx
   cmp al,10000000b
   jne prewrt
   mov dx,[ppb]
   mov al,1
   out dx,al

mov dx,[ppb+2]
   mov al,0
   out dx,al
   jmp hang

ppb dw 378h

times 510-($$-$) db 0
dw 0aa55h

any idea what is wrong? Thanks.