In 8086 the in
and out
instructions use a PIC port address as stored in AL or AX registers which in further is used with out
instruction.
What happens if we don't give any port number in in
instruction?
Does the out
instruction still work?
If so, then how and what PIC port will be selected?
IN and OUT instructions in 8086
1k views Asked by hadi khan At
1
Actually, the port address is stored in
dx
, notax
. The data you want to write goes inax
oral
.in
andout
work differently than most other operations in thatare perfectly valid even though the register sizes don't match. This is similar to how you're allowed to do
mov al, byte ptr [bx]
, as your operand is using a register as a means of accessing memory, rather than storing it directly into a register itself.I've never used an assembler that didn't have you specify a port, but since you either have to use a constant value or
DX
, it wouldn't be too much of a stretch to imagine there's an assembler out there that usesDX
if only one operand is provided (kind of like how some 6502 assemblers make you typeLSR A
to do a right bit-shift on theA
register when others are fine with justLSR
.)Which port you select is up to you, you're going to need to read the documentation for your associated peripheral to figure out which port number is needed. Remember that if you have a port number that is greater than 255, you'll need to use
DX
. Otherwise, you can just have the port number as a constant.