Linux assembly list
 help / color / mirror / Atom feed
From: Brian Raiter <breadbox@muppetlabs.com>
To: linux-assembly@vger.kernel.org
Subject: Re: I need little help..
Date: Thu, 25 Mar 2004 16:23:33 -0800	[thread overview]
Message-ID: <16483.30725.499924.145613@eidolon.muppetlabs.com> (raw)
In-Reply-To: <S263818AbUCZAAL/20040326000042Z+961@vger.kernel.org>

> Hi again.. I wanted to ask you how to write (in gas style) program
> which gets the user id (using syscall 24) and then printing it to
> the screen (NOT using the printf function , but using syscall 4)...

If you refuse to use printf, then you'll need to translate the number
into the ASCII decimal representation yourself. (I assume that if you
can't use printf(), then sprintf() is also off-limits.)

Once you've done that, you can just output the string directly.

	; itoa:
	; When called, the number to transform is in eax, and a
	; pointer to the buffer to receive the string is in edi.
	; Upon return, itoa leaves the length of the string in eax.

	mov	eax, number
	mov	edi, buffer
	call	itoa

	; now display the string using the write syscall.

	mov	edx, eax
	mov	ecx, buffer
	mov	ebx, FILENO_STDOUT
	mov	eax, 4
	int	0x80

If you don't want to use sprintf(), then you should really try to
write itoa yourself. It's a classic job-interview question, and one
that every hacker ought to try to write themselves.

b

  reply	other threads:[~2004-03-26  0:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-26  4:02 I need little help RaZoR
2004-03-26  0:23 ` Brian Raiter [this message]
2004-03-26  0:54   ` Robert G. Plantz

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=16483.30725.499924.145613@eidolon.muppetlabs.com \
    --to=breadbox@muppetlabs.com \
    --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