pgubook-readers
[Top][All Lists]
Advanced

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

[Pgubook-readers] Chapter 5: Constants or Labels and other ' concept bug


From: TJLAJK TJALJ
Subject: [Pgubook-readers] Chapter 5: Constants or Labels and other ' concept bugs'
Date: Thu, 17 Mar 2011 21:31:43 -0700 (PDT)

Hi,

I am stumped by the bss declaration on page 82.
 .section .bss
.equ BUFFER_SIZE, 500
.lcomm BUFFER_DATA, BUFFER_SIZE

My question is:
 How can BUFFER_SIZE be both a label and a constant? How is it possible for the assembler (and programmers) to tell them apart?
I have not assembled this code to test-run it yet. Or is the author economical and he should have written it like so:
...
.lcomm BUFFER_DATA
.lcomm BUFFER_SIZE, 500

And I think the text has a concept bug, too. On page 82, we have this line of code:
#Check for end of file marker
cmpl $END_OF_FILE, %eax

which he explains in the last line of page 92: The system call returns the number of bytes actually read, or end -of-file (the number 0).
For beginners like me, this is utter nonsense. I tore my hair over this explanation for quite a while wondering how Linux could return the end of file (\0) number to eax while all it does is return the number of bytes read from the input file. I think this line of text should read like this: The system call returns the number of bytes actually read, and when there are not any bytes left to read, Linux returns the number zero to eax, which signals end-of-file is reached. (I am sorry English is not my mother tounge. But the line should read close to this effect)

Thank you.



reply via email to

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