Author Topic: How to have permission to access ports?  (Read 18709 times)

nobody

  • Guest
How to have permission to access ports?
« on: December 18, 2008, 07:44:20 PM »
I write a simple code to read a port with the in instruction but when i run the program the in al, dx create a segmentation fault.

I find that to use in or out instruction in linux i first need permission but i don't know how?

The code:

global _start

section .data

section .text

_start:

mov dx, 03f8h
in al, dx

xor ebx, ebx      ; send 0 as 'exit code'
mov eax, 1      ; terminate process
int 80h         ; execute the syscall

nobody

  • Guest
Re: How to have permission to access ports?
« Reply #1 on: July 01, 2009, 11:50:33 PM »
I think you should use a1 (that's a one)  instead of al (that's an L).

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How to have permission to access ports?
« Reply #2 on: July 02, 2009, 02:56:29 AM »
What effect do you get by replacing "al", a register name, with "a1", an undefined symbol??? Won't assemble for me. :(

Try sys_ioperm.

Best,
Frank