aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Instructions.hs20
-rw-r--r--src/Machine.hs13
2 files changed, 27 insertions, 6 deletions
diff --git a/src/Instructions.hs b/src/Instructions.hs
index cff8d9b..fb9695b 100644
--- a/src/Instructions.hs
+++ b/src/Instructions.hs
@@ -62,10 +62,10 @@ doMOVEA :: Int -> Int -> Int -> Int -> Emulator ()
doMOVEA _ _ _ _ = error "MOVEA"
doMOVE :: Int -> Int -> Int -> Int -> Int -> Emulator ()
-doMOVE 1 dst_reg dst_mode src_mode src_reg = do
+doMOVE size dst_reg dst_mode src_mode src_reg = do
incPC
- (src_get, src_set) <- getOp src_mode src_reg 1
- (dst_get, dst_set) <- getOp dst_mode dst_reg 1
+ (src_get, src_set) <- getOp src_mode src_reg (getMoveSize size)
+ (dst_get, dst_set) <- getOp dst_mode dst_reg (getMoveSize size)
src_val <- src_get
dst_set src_val
@@ -120,13 +120,13 @@ doLINK a = do
addr <- readA a 4
sp <- readA 7 4
writeA 7 4 (sp - 4)
- setLong (sp - 4) addr
+ setMemory (sp - 4) 4 addr
doUNLK :: Int -> Emulator ()
doUNLK a = do
incPC
addr <- readA a 4
- val <- getLong addr
+ val <- getMemory addr 4
writeA a 4 val
writeA 7 4 (addr + 4)
@@ -183,7 +183,15 @@ doSUBQ :: Int -> Int -> Int -> Int -> Emulator ()
doSUBQ _ _ _ _ = error "SUBQ"
doBRA :: Int -> Emulator ()
-doBRA _ = error "BRA"
+doBRA 0 = do
+ incPC
+ pc <- readPC
+ disp <- getMemory pc 2
+ writePC (pc + disp)
+doBRA disp = do
+ incPC
+ pc <- readPC
+ writePC (pc + (fromIntegral disp))
doBSR :: Int -> Emulator ()
doBSR _ = error "BSR"
diff --git a/src/Machine.hs b/src/Machine.hs
index 443482c..b254f7e 100644
--- a/src/Machine.hs
+++ b/src/Machine.hs
@@ -417,3 +417,16 @@ getOp 7 4 s = do
skipOp s
let naddr = addr + if s == 1 then 1 else 0
return (getMemory naddr s, setMemory naddr s)
+
+-------------------------------------------------------------------------------
+-- Size converter
+
+getSize :: Int -> Int
+getSize 0 = 1
+getSize 1 = 2
+getSize 2 = 4
+
+getMoveSize :: Int -> Int
+getMoveSize 1 = 1
+getMoveSize 3 = 2
+getMoveSize 2 = 4