Linux assembly list
 help / color / mirror / Atom feed
From: Brian Raiter <breadbox@muppetlabs.com>
To: RaZoR <RaZoR@darksorcerers.org>
Cc: linux-assembly@vger.kernel.org
Subject: Re: Please give me an example.. - getuid() in nasm
Date: Sat, 24 Jan 2004 05:32:08 -0800	[thread overview]
Message-ID: <16402.29656.426159.617362@eidolon.muppetlabs.com> (raw)
In-Reply-To: <S266928AbUAXMIm/20040124120842Z+36743@vger.kernel.org>

> 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

      reply	other threads:[~2004-01-24 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-24 12:03 Please give me an example.. - getuid() in nasm RaZoR
2004-01-24 13:32 ` Brian Raiter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16402.29656.426159.617362@eidolon.muppetlabs.com \
    --to=breadbox@muppetlabs.com \
    --cc=RaZoR@darksorcerers.org \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox