rwosdev wrote:
Hey, thanks for the suggestion.
I tried it but polling for BUSY results in an infinite loop and ignoring it causes only one character to be written on the parallel output.
Code:
PollParallelBusy:
push ax
push dx
mov dx, 0x379
.loop:
in al, dx
and al, 10000000b
cmp al, 0
jnz .loop
No need for the "cmp al,0" instruction. The "and" sets the flags identical to the "cmp". In fact, the "cmp" is an "and" instruction, disregarding the results.
In my first reply, I tried to point you in the right direction, which it seems I did, though I tried not to do it for you.
Please search a little more and find out what value to watch for in bit 7. A lot of places say that it is the busy bit, which is correct, but is it set or clear to indicate busy?
rwosdev wrote:
Code:
pop dx
pop ax
ret
StringOut:
...
.debugOutLoop:
lodsb
inc edx
; For Bochs
out 0xE9, al
; For QEMU:
push dx
;call PollParallelBusy
; Write character
mov dx, 0x378
out dx, al
; Toggle bit 0 (STROBE) of 0x37A to say data is ready
mov dx, 0x37A
in al, dx
or al, 00000001b
out dx, al
; ... Left out polling 0x379 acknowledge for now
The reason it only outputs one char, is that you never turn off the strobe to be able to turn it back on, indicating another character. An on bit only indicates to the other side to read the parallel lines for the char. Only when the bit goes low (drops the power on that line), does the hardware indicate that it needs to be ready for the next char. This is where timing comes into play. How fast can I toggle (strobe) the strobe line and the "other side" will receive all my characters intact? For a simple thing as outputting to a file using an emulator, the fact that the line goes high, then low is enough. No need for timing. However, my code pauses for a slight bit, while the line is high, before dropping the strobe, just to be sure.
rwosdev wrote:
Code:
.next:
pop dx
cmp edx, ecx
jl .debugOutLoop
Side note: The Parallel Port hardware, in the standard form, has little or no circuitry. It simply is a bit representation of the status of each of the pins. If a pin is high (has power), the bit will be set (or clear), period. Writing a value to the data port, simply sets high all lines (pins) that have a bit set, dropping the power (setting to low) all the pins that have a zero bit. It is the closest you can come to actually physically manipulating the hardware without any firmware getting in the way. Long live the Parall....oh, ya, its dead...
Hope this helps,
Ben