flat assembler
Message board for the users of flat assembler.

Index > Main > Quick IN/OUT question

Author
Thread Post new topic Reply to topic
score_under



Joined: 27 Aug 2009
Posts: 27
score_under
Is:
Code:
in al,dx
xchg al,ah
in al,dx
xchg al,ah    

The same as
Code:
in ax,dx    
?

And how about:
Code:
xchg al,ah
out dx,al
xchg al,ah
out dx,al    

Is that the same as:
Code:
out dx,ax    
?

And finally, are "rep outs[b/w/d]" interchangeable so long as the count is modified accordingly?
Post 20 Jun 2010, 16:22
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Usually the documentation tells you what they want - if you are told to pass WORD, then you cannot pass two BYTEs and the other way round, because what you pass (BYTE, WORD, DWORD) will change the behaviour of the IN and OUT.
Post 20 Jun 2010, 18:35
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
score_under,

in al, dx reads byte-sized port, whereas in ax, dx reads word-sized one. Reading byte-sized port twice rarely substitutes for latter. The same for ins / out / outs.

Most modern hardware understands word-sized out instead of two byte-sized to adjacent ports. Good example of this is VGA programming (GC and CRTC registers follow index/data scheme).
Post 20 Jun 2010, 19:28
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> Is that the same as

Definitely NOT. May "seem to work" with some hardware (even worse with NTVDM "hardware") but is different and such bad use of IN or OUT may hang the PC Sad

PS: you can't read the PIC as WORD, and when reading 2 separate Byte's, the result can be wrong, guess why Sad
Post 27 Jun 2010, 11:05
View user's profile Send private message 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.

Powered by rwasa.