8086 build issues

It may be very simple, but I cannot understand it.

I use ports 8255 A and B to enter a word. I have something like:

PORT_A EQU 0008h // inputs low byte
PORT_B EQU 000Ah // inputs high byte

Later in the code segment, I have a part that does this:

MOV DX, PORT_B
IN AL, DX
MOV AH, AL
MOV DX, PORT_A
IN AL, DX
MOV DX, AX

I have a few questions. What effectively does MOV DX, PORT_B? Does it save the address PORT_B in DX? Why does it enter the high byte in AL and then move AL to AH instead of just writing it as IN AH, DX?

What do you need to make decisions "0008h" and "000Ah" for addresses for ports A and B? I only ever worked with assembly 8085, and there I would not have chosen 000A (0000 0000 0000 1010b), if I had chosen 0008h (0000 0000 0000 1000b) before, because bit A3 overlaps (for example, d select 0001h (.. .0001b) and 0002h (.... 0010b) so that no bits overlap).

+4
3

8255 A B

8255 A 8255. B.

- , - DX. in . :

  • , in al, dx
  • , in ax, dx
  • dword, in eax, dx

in /. (AH !)

wallyk , . , , .


, .

PORT_A EQU 0008h // inputs low byte
PORT_B EQU 000Ah // inputs high byte

, . /, , 0000h 00FFh, DX . in.

:

IN   AL, PORT_B   ; Fetch high byte from port B
MOV  DH, AL       ; Becomes high byte of end result in DX
IN   AL, PORT_A   ; Fetch low byte from port A
MOV  DL, AL       ; Becomes low byte of end result in DX

1 ( ):

IN   AL, PORT_B   ; Fetch high byte from port B
MOV  AH, AL       ; Store in AH for now
IN   AL, PORT_A   ; Fetch low byte from port A
XCHG DX, AX       ; Transfer AX to end result in DX
+3

, .

MOV  DX, PORT_B     ; set up address of port B
IN   AL, DX         ; read high byte from port B
MOV  AH, AL         ; save result from port B as most significant byte

MOV  DX, PORT_A     ; set up address of port A
IN   AL, DX         ; read low byte from port A
MOV  DX, AX         ; DX = 16 bit result

AL, AL AH IN AH, DX?

in   al, dx        ; read 8 bits
in   ax, dx        ; read 16 bits
in   eax, dx       ; (32 bit mode only, i.e. 80386+) read 32 bits

in ah, dx. x86 , , .

+2

MOV DX PORT_B moves the value of the constant (EQU creates the constant) PORT_B to the 16-bit DX register. Thus, AX gets the value 000Ah (10 in the base 10). IN is executed in low byte, because 000Ah is small enough to fit into the 8-bit part of AX. AH receives the value of AL, so that the value of PORT_B can be stored, while PORT_A is placed in AL.

0
source

Source: https://habr.com/ru/post/1677360/


All Articles