Parallel Port Programming: x86 Assembly

Assembly language programming can often be complicated, but writing to the parallel port in x86 asm isn't too bad. There is a simple instruction called out. Its format is

out accumulator, port

The details of this instruction are explained in the comments below. The program below simply writes the value of 48 to the parallel port.

title Parallel Port Writer

; This program writes a single value to the parallel port.
; The out instruction is used.  Its format is out accumulator, port
; Accumulator must be AL for 8-bit, or AX for 16-bit.  Port may
; be a constant in the range of 0 - FF hex, or a value in DX from
; 0 and FFFF hex.

dosseg
.model small
.stack 100h

.code
main proc
	mov al,48	; 8-bit output value stored in al
	mov dx,378h	; parallel port is 378 hex
	out dx,al	; write it

	mov ax,4C00h	; return to DOS
	int 21h
main endp
end main