Linux assembly list
 help / color / mirror / Atom feed
* Please give me an example.. - getuid() in nasm
@ 2004-01-24 12:03 RaZoR
  2004-01-24 13:32 ` Brian Raiter
  0 siblings, 1 reply; 2+ messages in thread
From: RaZoR @ 2004-01-24 12:03 UTC (permalink / raw)
  To: linux-assembly

Please give me an example how to use getuid() (syscall 24) in nasm , 
but not copied from asmutils. I want clear example , because I've got big
problems with this one :) 

Thanx 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Please give me an example.. - getuid() in nasm
  2004-01-24 12:03 Please give me an example.. - getuid() in nasm RaZoR
@ 2004-01-24 13:32 ` Brian Raiter
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Raiter @ 2004-01-24 13:32 UTC (permalink / raw)
  To: RaZoR; +Cc: linux-assembly

> Please give me an example how to use getuid() (syscall 24) in nasm ,
> but not copied from asmutils. I want clear example , because I've
> got big problems with this one :)

    Okay ...

	mov	eax, 24
	int	0x80
	; uid now in eax

    Is that clear enough?

    Here's a program that verifies that syscall 24 returns the same
    thing as the getuid() library function:

; uid.asm
BITS 32
GLOBAL main
EXTERN getuid
EXTERN printf
SECTION .text
main:
	call	getuid		; first call the one in libc
	push	eax		; push the result
	mov	eax, 24		; now do the direct syscall
	int	0x80
	push	eax		; push the result
	push	dword fmt	; print the return values on stdout
	call	printf		; so that the user can compare them
	add	esp, byte 12
	xor	eax, eax	; return
	ret
fmt:	db	'syscall 24 => %d', 10, 'getuid()   => %d', 10, 0

    Build this program like so:

nasm -f elf foo.asm && gcc foo.o

    And run it. You should see something like:

syscall 24 => 532
getuid()   => 532

-- 
b

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-24 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-24 12:03 Please give me an example.. - getuid() in nasm RaZoR
2004-01-24 13:32 ` Brian Raiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox