Segmentation fault || Istruction OUT

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2006
Posts: 2
Reputation: originof is an unknown quantity at this point 
Solved Threads: 0
originof originof is offline Offline
Newbie Poster

Segmentation fault || Istruction OUT

 
0
  #1
Jul 10th, 2006
Hi all..

  1. mov al, 0xB6
  2. out 0x43, al

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

  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...
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 14
Reputation: thandermax is an unknown quantity at this point 
Solved Threads: 0
thandermax thandermax is offline Offline
Newbie Poster

Re: Segmentation fault || Istruction OUT

 
0
  #2
Jul 11th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 2
Reputation: originof is an unknown quantity at this point 
Solved Threads: 0
originof originof is offline Offline
Newbie Poster

Re: Segmentation fault || Istruction OUT

 
0
  #3
Jul 11th, 2006
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:
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 14
Reputation: thandermax is an unknown quantity at this point 
Solved Threads: 0
thandermax thandermax is offline Offline
Newbie Poster

Re: Segmentation fault || Istruction OUT

 
0
  #4
Jul 12th, 2006
No , You Need To Code A Driver / Kernel Moddule To
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Segmentation fault || Istruction OUT

 
0
  #5
Aug 9th, 2006
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
Best regards,
Loren Soth

Crimson K. Software _________________________________________________________________ Crimson K. Blog
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3057 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC