I
I
IndusDev2017-11-03 10:15:26
C++ / C#
IndusDev, 2017-11-03 10:15:26

Question about the K&R book?

Here is an excerpt from the book:

The unary operator ~ bitwise "reverses" an integer, i.e., turns each 1 bit into a zero bit and vice versa. For example
, x = x & ~077
zeros out the last 6 bits in x. Note that the notation x & ~077 does not depend on the length (!!!) of the word (what else?) , and therefore it is better than x & 0177700 , since the latter implies that x takes 16 bits. The machine-independent notation of ~077 will not incur additional computational overhead, since ~077 is a constant expression that will be evaluated at compile time.

Could you clarify the highlighted sentences?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lander, 2017-11-03
@IndusDev

A word is two bytes or 16 bits (As written).
upd: if you look at the processor registers, then
ax is a word (two bytes)
ah is the high part of the register ax (bytes)
al is the low part of the register ax (bytes)
eax is a 4-byte register, the low part of which is the register ax. The upper part of the eax register cannot be accessed, so the maximum length of the register that can be parsed into components (ax) was called a word, and eax was called a double word.

S
Sergey Gornostaev, 2017-11-03
@sergey-gornostaev

At the beginning there was a word, and the word was two bytes.

G
GavriKos, 2017-11-03
@GavriKos

what other word?

Machine. So google - "machine word". Understanding the second segment will come when you understand what limits the machine word.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question