pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pgubook-readers] (no subject)


From: Bryn M. Reeves
Subject: Re: [Pgubook-readers] (no subject)
Date: Tue, 21 May 2013 10:28:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

On 05/20/2013 07:42 AM, Kanish Katariya wrote:
     I am reading programmin ground up book on assembly langauge and I
have a doubt,which I am unable to pass.
The first program in chapter 3 in which we just exit, I found that
inserting tha max 32bit value in the %ebx register and it is replying
255 instead of the maximum value(4294967296), when I enter the 'echo $?'
Command in terminal. Plz clear my doubt why it is repliying different
number.

The definition of the POSIX wait(2) function limits the size of the return code portion of the status field to 8-bits:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html

WEXITSTATUS(stat_val)

If the value of WIFEXITED(stat_val) is non-zero, this macro evaluates to the low-order 8 bits of the status argument that the child process passed to _exit() or exit(), or the value the child process returned from main().

So what you're seeing here is truncation of the value passed by the program (to fit in the low order 8-bit field of the status word).

In effect all POSIX exit status are (value % 256).

Regards,
Bryn.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]