diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-06-28 21:38:42 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-06-28 21:38:42 +0100 |
| commit | dfbf83a9a42907063aa5b3789f1ce9606de32e84 (patch) | |
| tree | eea8e2232f9f6b8841bcf4a3a740cf895afdd629 /src/main/kotlin/BitManipulation.kt | |
| parent | 6f87feb0c835589adcd566323e058a9158860071 (diff) | |
| download | KGB-dfbf83a9a42907063aa5b3789f1ce9606de32e84.tar.xz KGB-dfbf83a9a42907063aa5b3789f1ce9606de32e84.zip | |
Add register flags and set from LDHL SP,n op
Diffstat (limited to 'src/main/kotlin/BitManipulation.kt')
| -rw-r--r-- | src/main/kotlin/BitManipulation.kt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/kotlin/BitManipulation.kt b/src/main/kotlin/BitManipulation.kt index b4215e8..b655718 100644 --- a/src/main/kotlin/BitManipulation.kt +++ b/src/main/kotlin/BitManipulation.kt @@ -28,4 +28,15 @@ object BitManipulation { } } + fun isSignedBitNegative(value: Int): Boolean { + return value and (1 shl 7) != 0 + } + + fun getAbsoluteValue(value: Int ): Int{ + return if(isSignedBitNegative(value)) { + 0x0100 - value // 1 00000000 - 1xxxxxx = value, due to 2s compliment + } else { + value + } + } }
\ No newline at end of file |