tailieunhanh - Parallel Port Complete- P3

Parallel Port Complete- P3: From its origin as a simple printer interface, the personal computer's parallel port has evolved into a place to plug in just about anything you might want to hook to a computer. The parallel port is popular because it's versatile-you can use it for output, input, or bidirectional links-and because it's available-every PC has one. | Chapter 2 This displays the value of a Status port at 379h unsigned StatusAddress 0x379 int StatusPort StatusPort inp StatusAddress printf Status port Xh n StatusPort return 0 Pascal Pascal programmers can use the port function to access parallel ports. To write AAh to a Data port at 378h port 378h AAh To read a Status port at 379h value port 379h Delphi The 32-bit version of Borland s Delphi Object Pascal compiler has no port function but you can access ports by using the in-line assembler. To write AAh to a Data port at 378h asm push dx mov dx 378 mov al AA out dx al pop dx end To read a Status port at 379h into the variable ByteValue var ByteValue byte asm push dx mov dx 379 in al dx mov ByteValue al pop dx end Assembly Language In assembly language you use the microprocessor s In and out instructions for port access. To write AAh to a Data port at 378h mov dx 378h store port address in dx 30 Parallel Port Complete Please purchase PDF Split-Merge on to remove this watermark. Accessing Ports mov al AAh store data to write in al out dx al write data in al to port address in dx To read a Status port at 379h into register al mov dx 379h store port address in dx in al dx read data at port address into al Other Ways to Access Ports Visual Basic Windows and DOS include other ways to access ports that have been assigned an LPT number. These options are intended for use with printers and other devices with similar interfaces. They write bytes to theparallclport s Data port and automatically check the Status inputs and send astrobe pulsewith each byte. Because this book focuses on uses other than printer drivers most of the examples use direct port reads and writes ratherthanLPT other options do have uses. This section describes these alternate ways toaccess ports. LPT Access in Visual Basic Although Visual Basic has no built-in ability for simple port I O it does include ways to access LPT ports including the Printer object the .