flat assembler
Message board for the users of flat assembler.

Index > Main > writing more than byte to port

Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
hi, i am confused about writing more than one byte to port.

Does this code:
Code:
mov dx, 1234
out dx, ax    

write one byte to 1234 and other to 1235, or does it write both to 1234, or is it port-dependent?
Post 19 Jul 2007, 21:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Pavia



Joined: 20 Jul 2007
Posts: 2
Location: Russia
Pavia
Is undoc.
IMHO
For all ports. Code OUT DX,AX write AL in DX and AH in DX+1.
Execpt only HDD Data Register
Post 20 Jul 2007, 01:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
The I/O system is similar to the memory system as far as where the bytes go.

You can write OUT dx,ax and two bytes are sent the port, the lsb to dx, and msb to dx+1. The same for a 32bit write, lsb to dx and msb to dx+3.

If you have an older machine (ISA bus) then some hardware cards did not support 16 bit writes so you also need to be mindful of what device you are writing to.
Post 20 Jul 2007, 04:47
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
Intel Basic Architecture Manual wrote:
Any two consecutive 8-bit ports can be treated as a 16-bit port, and any four consecutive
ports can be a 32-bit port. In this manner, the processor can transfer 8, 16, or
32 bits to or from a device in the I/O address space.

Intel Instruction Set Manual wrote:
The size of the I/O port being accessed is determined by the opcode for an 8-bit I/O
port or by the operand-size attribute of the instruction for a 16- or 32-bit I/O port.

Code:
OUT DX, AL ; 8-bit port
OUT DX, AX ; 16-bit port
OUT DX, EAX ; 32-bit port
    

Note that there is no OUT DX, RAX instruction.
Post 20 Jul 2007, 07:23
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
thanks...
Post 20 Jul 2007, 09:30
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.