944,196 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 4166
  • Assembly RSS
Jul 10th, 2006
0

Segmentation fault || Istruction OUT

Expand Post »
Hi all..

Assembly Syntax (Toggle Plain Text)
  1. mov al, 0xB6
  2. out 0x43, al

Why the istruction out give me a segmentation fault ?? :rolleyes:
This is the enteire code

Assembly Syntax (Toggle Plain Text)
  1. section .data
  2. hello: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character
  3. helloLen: equ $-hello ; Length of the 'Hello world!' string
  4. ; (I'll explain soon)
  5.  
  6. section .text
  7. global _start
  8.  
  9. _start:
  10. mov eax,4 ; The system call for write (sys_write)
  11. mov ebx,1 ; File descriptor 1 - standard output
  12. mov ecx,hello ; Put the offset of hello in ecx
  13. mov edx,helloLen ; helloLen is a constant, so we don't need to say
  14. ; mov edx,[helloLen] to get it's actual value
  15. int 80h ; Call the kernel
  16.  
  17.  
  18. xor al, al
  19. mov al, 0xB6
  20. out 0x43, al
  21. xor al, al
  22. mov al, 54
  23. out 0x42, al
  24. xor al, al
  25. mov al, 124
  26. out 0x42, al
  27. xor al, al
  28. in al, 0x61
  29. or al, 3
  30. out 0x61, al
  31. xor al, al
  32.  
  33. mov eax,1 ; The system call for exit (sys_exit)
  34. mov ebx,0 ; Exit with return code of 0 (no error)
  35. int 80h

oh, i use linux...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
originof is offline Offline
2 posts
since Jul 2006
Jul 11th, 2006
0

Re: Segmentation fault || Istruction OUT

Linux runs in 32bit protected mode whre all ports are blocked .

The code u r showing will only gonna work in real mode (i.e. 16 bit , MsDos style).

If you really need to execute in/out instruction then consider coding the above prog as a device driver or kernel moddule .

Linux will give u access to ports in Ring 0 only ,where driver runs.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thandermax is offline Offline
14 posts
since Jun 2005
Jul 11th, 2006
0

Re: Segmentation fault || Istruction OUT

Quote originally posted by thandermax ...
Linux runs in 32bit protected mode whre all ports are blocked .

The code u r showing will only gonna work in real mode (i.e. 16 bit , MsDos style).

If you really need to execute in/out instruction then consider coding the above prog as a device driver or kernel moddule .

Linux will give u access to ports in Ring 0 only ,where driver runs.
i'm italian, and my english is poor....:rolleyes:

SO, i cannot execute OUT and IN command in linux ??
:eek:
Reputation Points: 10
Solved Threads: 0
Newbie Poster
originof is offline Offline
2 posts
since Jul 2006
Jul 12th, 2006
0

Re: Segmentation fault || Istruction OUT

No , You Need To Code A Driver / Kernel Moddule To
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thandermax is offline Offline
14 posts
since Jun 2005
Aug 9th, 2006
0

Re: Segmentation fault || Istruction OUT

Hi,

There are some 3rd party drivers that let you access IO ports through them, but you call a function on their DLL not the OUT opcode.

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Clock cycles
Next Thread in Assembly Forum Timeline: Please help with the assembly code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC