diff options
author | Michael Pavone <pavone@retrodev.com> | 2014-12-27 14:50:28 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2014-12-27 14:50:28 -0800 |
commit | 60afc143f247bf58fa01cff73516d30511c97c82 (patch) | |
tree | ba204de8a922fae314494e6f39eaea2b0073b687 /gentests.py | |
parent | 4bf9f13589dc4c9e59ead0a864dac28a518949f0 (diff) |
Don't use out of bounds displacements in indexed mode even if our targeted address is out of RAM range
Diffstat (limited to 'gentests.py')
-rwxr-xr-x | gentests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gentests.py b/gentests.py index 000f73e..428d6a0 100755 --- a/gentests.py +++ b/gentests.py @@ -178,9 +178,17 @@ class Indexed(object): self.disp -= (address & 0xFFFFFF) else: self.disp += 0xE00000-(address & 0xFFFFFF) + if self.disp > 127: + self.disp = 127 + elif self.disp < -128: + self.disp = -128 address = base + index + self.disp elif (address & 0xFFFFFF) > 0xFFFFFC: self.disp -= (address & 0xFFFFFF) - 0xFFFFFC + if self.disp > 127: + self.disp = 127 + elif self.disp < -128: + self.disp = -128 address = base + index + self.disp if size != 'b' and address & 1: self.disp = self.disp ^ 1 |