flat assembler
Message board for the users of flat assembler.

Index > OS Construction > A parallel port driver...

Author
Thread Post new topic Reply to topic
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
This is a simple parallel port driver. It can send/recieve bytes from the parallel port, though interpreting the bytes read is up to you. It can be used with some old dot-matrix parallel port printers without too much extra code Smile

Code:
; Parallel Port Driver
; Developed by Charles Childers
; -----------------------------------------------------
; * Released into the public domain *
; -----------------------------------------------------
; Port Addresses
;  $378  =  LPT1
;  $278  =  LPT2
; -----------------------------------------------------
  port = $378

; Returns eax = status byte
read_parallel:
  xor eax, eax            ;
  mov dx, port + 1        ; Read a status byte
  in al, dx               ;
ret

; eax = byte to write
write_parallel:
  mov dx, port
  out dx, al
  mov dx, port + 2
  mov al, 13
  out dx, al
  mov dx, port + 2
  mov al, 12
  out dx, al
ret
; -----------------------------------------------------    

_________________
Charles Childers, Programmer
Post 25 Sep 2004, 01:15
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
crc wrote:
This is a simple parallel port driver. It can send/recieve bytes from the parallel port, though interpreting the bytes read is up to you. It can be used with some old dot-matrix parallel port printers without too much extra code Smile

Code:
; Parallel Port Driver
; Developed by Charles Childers
; -----------------------------------------------------
; * Released into the public domain *
; -----------------------------------------------------
; Port Addresses
;  $378  =  LPT1
;  $278  =  LPT2
; -----------------------------------------------------
  port = $378

; Returns eax = status byte
read_parallel:
  xor eax, eax            ;
  mov dx, port + 1        ; Read a status byte
  in al, dx               ;
ret

; eax = byte to write
write_parallel:
  mov dx, port
  out dx, al
  mov dx, port + 2
  mov al, 13
  out dx, al
  mov dx, port + 2
  mov al, 12
  out dx, al
ret
; -----------------------------------------------------    


Hy CRC,

you have interesting code there

do you really mean these?:
Code:
; eax = byte to write

; Returns eax = status byte
    


MATRIX
Post 11 Oct 2004, 20:08
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Yes.

This code is from my operating system, which uses 32-bit values internally. In reality, the original code was written in Forth, so it's not always a clean 1:1 mapping. I guess the comments could say "ax" instead of "eax", but it doesn't really matter too much does it?
Post 11 Oct 2004, 22:23
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.