NASM - The Netwide Assembler
NASM Forum => Example Code => Topic started by: Mac on July 20, 2007, 11:52:00 PM
-
how can i use inport/outport from C in nasm?
-
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
-
> 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 (!!!) ;-)
-
or
3. You're coding an OS ;-)