From 717a132ea55eb634eda375d59d73df826712cd8b Mon Sep 17 00:00:00 2001 From: Nikita Orlov Date: Sat, 3 Apr 2021 22:28:49 +0300 Subject: BSR and RTS added --- src/Utils.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Utils.hs') diff --git a/src/Utils.hs b/src/Utils.hs index ee1cd7a..cd2f1e3 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -64,3 +64,15 @@ checkZero 0 = True checkZero _ = False -- TODO: carry & overflow checkers + +------------------------------------------------------------------------------- +-- Sign extender + +signExtend :: Word32 -> Int -> Word32 +signExtend x 1 + | x < 0x80 = x + | otherwise = x + 0xffffff00 +signExtend x 2 + | x < 0x8000 = x + | otherwise = x + 0xffff0000 +signExtend x 4 = x -- cgit v1.2.3