NASM Forum > Example Code

send characters through serial port

(1/1)

Mac:
how can i use inport/outport from C in nasm?

nobody:
I don't know what "inport" and "outport" are. C functions, I suppose? Push the value, push the port (or perhaps other-way-around), and call 'em, I suppose. Strikes me as a very foolish thing to do. Why not use "in" and "out"?

mov dx, 3F8h
mov al, 42
out dx, al

or for ports under 3FFh (?), you can:

mov al, 42
out 3F8h, al

Unless you're in real mode, the OS may have something to say about whether you can actually access the port...

Best,
Frank

nobody:
> or for ports under 3FFh (?), you can:
> mov al, 42
> out 3F8h, al

It's ^^^ up to $FF only, not $03FF, IIRC ;-)

> Unless you're in real mode, the OS may have something to
> say about whether you can actually access the port...

Right. You should not access ports except:

1. You are writing a great "driver" and have permission to access ports (experts only)
or
2. You know what DOS is (!!! - note that XP or Vi$ta is NOT DOS and don't have DOS !!!), have DOS (!!!) and are in DOS (!!!) ;-)

nobody:
or
3. You're coding an OS ;-)

Navigation

[0] Message Index

Go to full version