3 Computer Arithmetic

The reality of computing is that we have a finite number of bits. In the previous chapter, you learned that each data item must fit within a fixed number of bits, depending on its data type. This chapter will show that this limit complicates even our most basic mathematical operations. For both signed and unsigned numbers, a limited number of bits is a constraint we don’t normally think about when doing math on paper or in our heads.

Fortunately, the carry flag (CF) and overflow flag (OF) in the status flags portion of the CPU’s rflags register allow us to detect when adding and subtracting binary numbers yields results ...

Get Introduction to Computer Organization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.