write system call

  • Follow


Does the 'write' linux system call require kernel mode?


I get a Permission denied problem with :

...section .rodata
...l1:
...string "some text"

...text
main:
mov $0x4,%eax   ;system call 4 - write
mov $0x1,%ebx   ;write 1st arg, write to stdout (file descriptor 1)
mov $.l1,%ecx     ;write 2nd arg, pass "some text"
mov $0x9,%edx   ;write 3rd arg, pass length of 9
int $0x80              ;make a system call
ret

Thanks.
-- 
Raymond.




0
Reply Raymond 4/23/2004 11:10:02 AM

Raymond Martin wrote:

> I get a Permission denied problem with :
> 
> ..section .rodata
> ..l1:
> ..string "some text"
> 
> ..text
> main:
> mov $0x4,%eax   ;system call 4 - write
> mov $0x1,%ebx   ;write 1st arg, write to stdout (file descriptor 1)
> mov $.l1,%ecx   ;write 2nd arg, pass "some text"
> mov $0x9,%edx   ;write 3rd arg, pass length of 9
> int $0x80       ;make a system call
> ret

The code below works for me.

$ cat hello.s
..globl _start

..text
_start:
   mov $4,%eax
   mov $1,%ebx
   mov $buf,%ecx
   mov $6,%edx
   int $0x80

   mov $1,%eax
   xor %ebx,%ebx
   int $0x80

..data
   buf: .string "Hello\n"

$ as hello.s -o hello.o ; ld hello.o

$ ./a.out
Hello

0
Reply Grumble 4/23/2004 1:09:41 PM


> The code below works for me.
>
> $ cat hello.s
> .globl _start
>
> .text
> _start:
>    mov $4,%eax
>    mov $1,%ebx
>    mov $buf,%ecx
>    mov $6,%edx
>    int $0x80
>
>    mov $1,%eax
>    xor %ebx,%ebx
>    int $0x80
>
> .data
>    buf: .string "Hello\n"
>
> $ as hello.s -o hello.o ; ld hello.o
>
> $ ./a.out
> Hello
>

Just getting familiar with assembly, I forgot to link it :P
thanks though.


0
Reply Raymond 4/30/2004 7:06:40 AM

2 Replies
334 Views

(page loaded in 0.038 seconds)

Similiar Articles:













7/24/2012 4:52:37 PM


Reply: