aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Orlov <nikitf-97@mail.ru>2021-04-05 01:41:01 +0300
committerNikita Orlov <nikitf-97@mail.ru>2021-04-05 01:41:01 +0300
commitdf61507c50cf8b816bd08b5a2b1a5290a6db8dd3 (patch)
tree4bd40880136d358cffe163d1d88bfabd51ddefe3
parentbb999d34dac7be7f79a1b2c847c0022576847718 (diff)
downloadsuem-df61507c50cf8b816bd08b5a2b1a5290a6db8dd3.tar
suem-df61507c50cf8b816bd08b5a2b1a5290a6db8dd3.tar.xz
suem-df61507c50cf8b816bd08b5a2b1a5290a6db8dd3.zip
ADD and ADDA added
-rw-r--r--src/Instructions.hs42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/Instructions.hs b/src/Instructions.hs
index 3d9ad1a..6287803 100644
--- a/src/Instructions.hs
+++ b/src/Instructions.hs
@@ -284,13 +284,51 @@ doAND :: Int -> Int -> Int -> Int -> Int -> Emulator ()
doAND _ _ _ _ _ = error "AND"
doADDA :: Int -> Int -> Int -> Int -> Emulator ()
-doADDA _ _ _ _ = error "ADDA"
+doADDA dst_reg 0 src_mode src_reg = do
+ incPC
+ (src_get, src_set) <- getOp src_mode src_reg 4
+ src_val <- src_get
+ dst_val <- readA dst_reg 4
+ let value = src_val + dst_val
+ writeA dst_reg 4 value
+ setNegative (checkNegative value 4)
+ setZero (checkZero value)
+--TODO flags
+doADDA src_reg 1 dst_mode dst_reg = do
+ incPC
+ (dst_get, dst_set) <- getOp dst_mode dst_reg 4
+ src_val <- readA src_reg 4
+ dst_val <- dst_get
+ let value = src_val + dst_val
+ dst_set value
+ setNegative (checkNegative value 4)
+ setZero (checkZero value)
+-- TODO flags
doADDX :: Int -> Int -> Int -> Int -> Emulator ()
doADDX _ _ _ _ = error "ADDX"
doADD :: Int -> Int -> Int -> Int -> Int -> Emulator ()
-doADD _ _ _ _ _ = error "ADD"
+doADD dst_reg 0 size src_mode src_reg = do
+ incPC
+ (src_get, src_set) <- getOp src_mode src_reg (getSize size)
+ src_val <- src_get
+ dst_val <- readD dst_reg (getSize size)
+ let value = src_val + dst_val
+ writeD dst_reg (getSize size) value
+ setNegative (checkNegative value (getSize size))
+ setZero (checkZero value)
+-- TODO flags
+doADD src_reg 1 size dst_mode dst_reg = do
+ incPC
+ (dst_get, dst_set) <- getOp dst_mode dst_reg (getSize size)
+ src_val <- readD src_reg (getSize size)
+ dst_val <- dst_get
+ let value = src_val + dst_val
+ dst_set value
+ setNegative (checkNegative value (getSize size))
+ setZero (checkZero value)
+-- TODO flags
doASD :: Int -> Int -> Int -> Emulator ()
doASD _ _ _ = error "ASD"