Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

inb outb

584 views
Skip to first unread message

Aaron Coombs

unread,
Oct 25, 2001, 2:24:19 AM10/25/01
to
Hello,

the inb and outb asm functions are not defined in the intel instruction set
reference yet I see them used everywhere. Are they a part of gcc? Are they
based on the IN and OUT instructions?

Thanks,

Aaron


Chewy509

unread,
Oct 25, 2001, 4:58:15 AM10/25/01
to

"Aaron Coombs" babbled in message...

IN and OUT instructions have three forms, a BYTE form, a WORD form, and a
DWORD form (on 32bit CPUs only). So inb and outb are the byte form, inw and
outw are the word form, and ind and outd are the dword form. The difference
between them is, that the byte form outputs a single byte to the port, and
the word form outputs the low-byte to the port and the hgih-byte to port+1,
and so on. So to summarise:
outb 60h, al = outputs al to port 60h.
outw 60h, ax = outputs al to port 60h, and ah to port 61h.
outd 60h, eax = outputs al to port 60h, ah to port 61h, next 8bits to port
62h, and the last 8 bits to port 63h

Now, some assemblers know which size to use, but you can use an override
(which is what you are seeing), forcing the assembler to generate the
correct operand size, (either byte, word or dword form).

Chewy509...

PS. For more info read chap 9, vol 1, and chap2, vol 2 of the intel pentium
manuals. To generate input/output to a single 8bit port, then use the
ins/outs instructions.


Aaron Coombs

unread,
Oct 25, 2001, 10:34:29 AM10/25/01
to
thank you.

"Chewy509" <Chew...@austarnet.com.au> wrote in message
news:9r8lkm$s7obr$2...@ID-98691.news.dfncis.de...

Richard Harris

unread,
Oct 25, 2001, 6:38:37 PM10/25/01
to
You are referring to functions which are normally implemented in inline
assembly or linked assembled modules.

The functions you are referring to are:

inb = in byte (1 byte)

inw = in word (2 bytes

ind = in dword(4 bytes)

outb = out byte (1 byte)

outw = out word (2 bytes)

outd = out dword (4 bytes)

These are usaly functions that wrap the instructions "in" and "out". Have a
look in the Intel Architecture Manual: Instruction Set Reference.


"Aaron Coombs" <a.co...@home.com> wrote in message
news:neOB7.118170$ob.26...@news1.rdc1.bc.home.com...

Richard Harris

unread,
Oct 25, 2001, 6:47:41 PM10/25/01
to
Note it is also common to implement in and out instructions as macros,
inline functions for in and out are found in microsoft visual C++ as inp,
outp....


"Aaron Coombs" <a.co...@home.com> wrote in message
news:neOB7.118170$ob.26...@news1.rdc1.bc.home.com...

0 new messages