Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*

SubjectRe: emulating register overflow? Reply to this message
Posted byBart T.
Posted on01/24/05 08:43 PM

> Now I'm not sure how I should handle the overflow. Initially I had this:
> 1. add number to register
> 2. if register > 255, set to 255 and set the Carry Flag.

What you're describing is saturation: When a value overflows/underflows and is "clipped" to the maximum/minimum representable number. Saturated arithmetic is only present on some specialized hardware and instruction sets (MMX and other SIMD ISAs have support for it, for example.)

Normal arithmetic, as you discovered, is more useful and it also happens that when implementing ALUs in hardware, it is the natural way things occur (bits carried out of the register are simply lost -- or an extra bit is used to calculate status flags.)

Entire Thread
Subject  Posted byPosted On
*emulating register overflow?  newsdee01/23/05 10:13 PM
.*thanks guys, very interesting insights  newsdee01/28/05 00:02 AM
..*Re: thanks guys, very interesting insights  Bart T.01/28/05 06:55 PM
..Re: emulating register overflow?  Bart T.01/24/05 08:43 PM
.*got it (king of answering my own questions)  newsdee01/23/05 10:23 PM
..*Re: got it (king of answering my own questions)  finaldave01/25/05 11:56 AM