flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Kikin
Hey people:
I need to know exactly how to write to the parallel port using nasm. Do I have to open a device or something? Is there any permissions issue? Thanks in advance... |
|||
![]() |
|
DJ Mauretto
Set your bios as Bidirectional Parallel port mode (SPP)
![]() This set I/O permission Code: mov eax,101 ; SYS_IOPERM mov ebx,Base_Parallel ; 378H mov ecx,Size ; 3 mov edx,1 ; Turn ON int 80H test eax,eax js Error_Set_IO to write Code: mov dx,37ah in al,dx and al,11011111b ; reset bit 5 ( Write mode) out dx,al mov al,0ffh ; turn on all 8 pin mov dx,378h out dx,al ; Write byte to read Code: mov dx,37ah in al,dx or al,00100000b ; set bit 5 ( Read mode) out dx,al mov dx,378h in al,dx ; Read byte |
|||
![]() |
|
Kikin
Ok, first of all, sorry for posting this issue here, but it was the only forum referring assembly I could find and since the question was more OS-specific rather than assembler-specific I decided it wouldn't hurt anybody's feelings.
Thanks DJ Mauretto, I still don't understand quite well the part where you set/reset bit 5 on port 37ah, but it looks great, can't wait to try it out. Just one question, do I need to run my program as root in order to get permission with ioperm? |
|||
![]() |
|
DJ Mauretto
Quote: Just one question, do I need to run my program as root in order to get permission with ioperm? yes ![]() Quote: I still don't understand quite well the part where you set/reset bit 5 on port 37ah, but it looks great, can't wait to try it out. When the parallel port is bidirectional mode it use same 8 pin for IN/OUT, you must tell at the controller ( port 37ah) that you want perform a Read or Write operation,with bit 5 you select Write or Read operation ![]() Remember to set Bidirectional mode in your Bios. Note that if you need only to Write then forget bit 5 and bidirectional mode, the only code that you need is: Code: mov dx,378h mov al,Value ; Value to Write out dx,al Parallel port is standard from 20 years ,there are many tutorial on line this is only a simply way to go ,but you can do it better and more learning about Paralel Port ![]() |
|||
![]() |
|
Chewy509
Umm, to read/write to the parallel port don't you just open "/dev/lp0" for reading/writing using the standard open/read/write/close syscalls, and let the kernel do all the hard stuff like buffering, etc...
PS. If you want to talk directly to the port as described, then yes you'll need to run as root (or set your application as setuid root). |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.