From de08c2e979b838e3142a6a380a6edc76ed86cc15 Mon Sep 17 00:00:00 2001 From: Nikita Orlov Date: Fri, 2 Apr 2021 18:55:32 +0300 Subject: Instructions rename --- src/Commands.hs | 272 -------------------- src/Instructions.hs | 272 ++++++++++++++++++++ src/Machine.hs | 10 +- src/Suem.hs | 704 ++++++++++++++++++++++++++-------------------------- 4 files changed, 629 insertions(+), 629 deletions(-) delete mode 100644 src/Commands.hs create mode 100644 src/Instructions.hs diff --git a/src/Commands.hs b/src/Commands.hs deleted file mode 100644 index ea0a50d..0000000 --- a/src/Commands.hs +++ /dev/null @@ -1,272 +0,0 @@ --- This module describes the semantics of machine commands. -module Commands where - -import Prelude hiding (Word) -import Machine -import Utils -import Data.IORef - - -doORICCR :: Emulator () -doORICCR = return () - -doORISR :: Emulator () -doORISR = return () - -doORI :: Int -> Int -> Int -> Emulator () -doORI _ _ _ = return () - -doANDICCR :: Emulator () -doANDICCR = return () - -doANDISR :: Emulator () -doANDISR = return () - -doANDI :: Int -> Int -> Int -> Emulator () -doANDI _ _ _ = return () - -doSUBI :: Int -> Int -> Int -> Emulator () -doSUBI _ _ _ = return () - -doADDI :: Int -> Int -> Int -> Emulator () -doADDI _ _ _ = return () - -doEORICCR :: Emulator () -doEORICCR = return () - -doEORISR :: Emulator () -doEORISR = return () - -doEORI :: Int -> Int -> Int -> Emulator () -doEORI _ _ _ = return () - -doCMPI :: Int -> Int -> Int -> Emulator () -doCMPI _ _ _ = return () - -doMOVEP :: Int -> Int -> Int -> Int -> Emulator () -doMOVEP _ _ _ _ = return () - -doBTST :: Int -> Int -> Int -> Int -> Emulator () -doBTST _ _ _ _ = return () - -doBCHG :: Int -> Int -> Int -> Int -> Emulator () -doBCHG _ _ _ _ = return () - -doBCLR :: Int -> Int -> Int -> Int -> Emulator () -doBCLR _ _ _ _ = return () - -doBSET :: Int -> Int -> Int -> Int -> Emulator () -doBSET _ _ _ _ = return () - -doMOVEA :: Int -> Int -> Int -> Int -> Emulator () -doMOVEA _ _ _ _ = return () - -doMOVE :: Int -> Int -> Int -> Int -> Int -> Emulator () -doMOVE _ _ _ _ _ = return () - -doSRMOVE :: Int -> Int -> Emulator () -doSRMOVE _ _ = return () - -doMOVECCR :: Int -> Int -> Emulator () -doMOVECCR _ _ = return () - -doMOVESR :: Int -> Int -> Emulator () -doMOVESR _ _ = return () - -doNEGX :: Int -> Int -> Int -> Emulator () -doNEGX _ _ _ = return () - -doCLR :: Int -> Int -> Int -> Emulator () -doCLR _ _ _ = return () - -doNEG :: Int -> Int -> Int -> Emulator () -doNEG _ _ _ = return () - -doNOT :: Int -> Int -> Int -> Emulator () -doNOT _ _ _ = return () - -doEXT :: Int -> Int -> Emulator () -doEXT _ _ = return () - -doNBCD :: Int -> Int -> Emulator () -doNBCD _ _ = return () - -doSWAP :: Int -> Emulator () -doSWAP _ = return () - -doPEA :: Int -> Int -> Emulator () -doPEA _ _ = return () - -doILLEGAL :: Emulator () -doILLEGAL = return () - -doTAS :: Int -> Int -> Emulator () -doTAS _ _ = return () - -doTST :: Int -> Int -> Int -> Emulator () -doTST _ _ _ = return () - -doTRAP :: Int -> Emulator () -doTRAP _ = return () - -doLINK :: Int -> Emulator () -doLINK a = do - incPC - addr <- readA a 4 - sp <- readA 7 4 - writeA 7 4 (sp - 4) - setLong (sp - 4) addr - -doUNLK :: Int -> Emulator () -doUNLK a = do - incPC - addr <- readA a 4 - val <- getLong addr - writeA a 4 val - writeA 7 4 (addr + 4) - -doMOVEUSP :: Int -> Int -> Emulator () -doMOVEUSP _ _ = return () - -doRESET :: Emulator () -doRESET = return () - -doNOP :: Emulator () -doNOP = with pc $ \pc -> do - pcval <- readIORef pc - writeIORef pc (pcval + 2) - -doSTOP :: Emulator () -doSTOP = return () - -doRTE :: Emulator () -doRTE = return () - -doRTS :: Emulator () -doRTS = return () - -doTRAPV :: Emulator () -doTRAPV = return () - -doRTR :: Emulator () -doRTR = return () - -doJSR :: Int -> Int -> Emulator () -doJSR _ _ = return () - -doJMP :: Int -> Int -> Emulator () -doJMP _ _ = return () - -doMOVEM :: Int -> Int -> Int -> Int -> Emulator () -doMOVEM _ _ _ _ = return () - -doLEA :: Int -> Int -> Int -> Emulator () -doLEA _ _ _ = return () - -doCHK :: Int -> Int -> Int -> Emulator () -doCHK _ _ _ = return () - -doDBcc :: Int -> Int -> Emulator () -doDBcc _ _ = return () - -doScc :: Int -> Int -> Int -> Emulator () -doScc _ _ _ = return () - -doADDQ :: Int -> Int -> Int -> Int -> Emulator () -doADDQ _ _ _ _ = return () - -doSUBQ :: Int -> Int -> Int -> Int -> Emulator () -doSUBQ _ _ _ _ = return () - -doBRA :: Int -> Emulator () -doBRA _ = return () - -doBSR :: Int -> Emulator () -doBSR _ = return () - -doBcc :: Int -> Int -> Emulator () -doBcc _ _ = return () - -doMOVEQ :: Int -> Int -> Emulator () -doMOVEQ _ _ = return () - -doDIVU :: Int -> Int -> Int -> Emulator () -doDIVU _ _ _ = return () - -doDIVS :: Int -> Int -> Int -> Emulator () -doDIVS _ _ _ = return () - -doSBCD :: Int -> Int -> Int -> Emulator () -doSBCD _ _ _ = return () - -doOR :: Int -> Int -> Int -> Int -> Int -> Emulator () -doOR _ _ _ _ _ = return () - -doSUBA :: Int -> Int -> Int -> Int -> Emulator () -doSUBA _ _ _ _ = return () - -doSUBX :: Int -> Int -> Int -> Int -> Emulator () -doSUBX _ _ _ _ = return () - -doSUB :: Int -> Int -> Int -> Int -> Int -> Emulator () -doSUB _ _ _ _ _ = return () - -doCMPA :: Int -> Int -> Int -> Int -> Emulator () -doCMPA _ _ _ _ = return () - -doCMP :: Int -> Int -> Int -> Int -> Emulator () -doCMP _ _ _ _ = return () - -doCMPM :: Int -> Int -> Int -> Emulator () -doCMPM _ _ _ = return () - -doEOR :: Int -> Int -> Int -> Int -> Emulator () -doEOR _ _ _ _ = return () - -doMULU :: Int -> Int -> Int -> Emulator () -doMULU _ _ _ = return () - -doMULS :: Int -> Int -> Int -> Emulator () -doMULS _ _ _ = return () - -doABCD :: Int -> Int -> Int -> Emulator () -doABCD _ _ _ = return () - -doEXG :: Int -> Int -> Int -> Int -> Emulator () -doEXG _ _ _ _ = return () - -doAND :: Int -> Int -> Int -> Int -> Int -> Emulator () -doAND _ _ _ _ _ = return () - -doADDA :: Int -> Int -> Int -> Int -> Emulator () -doADDA _ _ _ _ = return () - -doADDX :: Int -> Int -> Int -> Int -> Emulator () -doADDX _ _ _ _ = return () - -doADD :: Int -> Int -> Int -> Int -> Int -> Emulator () -doADD _ _ _ _ _ = return () - -doASD :: Int -> Int -> Int -> Emulator () -doASD _ _ _ = return () - -doLSD :: Int -> Int -> Int -> Emulator () -doLSD _ _ _ = return () - -doROXd :: Int -> Int -> Int -> Emulator () -doROXd _ _ _ = return () - -doROd :: Int -> Int -> Int -> Emulator () -doROd _ _ _ = return () - -doADSR :: Int -> Int -> Int -> Int -> Int -> Emulator () -doADSR _ _ _ _ _ = return () - -doLSDR :: Int -> Int -> Int -> Int -> Int -> Emulator () -doLSDR _ _ _ _ _ = return () - -doROXdR :: Int -> Int -> Int -> Int -> Int -> Emulator () -doROXdR _ _ _ _ _ = return () - -doROdR :: Int -> Int -> Int -> Int -> Int -> Emulator () -doROdR _ _ _ _ _ = return () diff --git a/src/Instructions.hs b/src/Instructions.hs new file mode 100644 index 0000000..9c2e2cb --- /dev/null +++ b/src/Instructions.hs @@ -0,0 +1,272 @@ +-- This module describes the semantics of machine instructions. +module Instructions where + +import Prelude hiding (Word) +import Machine +import Utils +import Data.IORef + + +doORICCR :: Emulator () +doORICCR = return () + +doORISR :: Emulator () +doORISR = return () + +doORI :: Int -> Int -> Int -> Emulator () +doORI _ _ _ = return () + +doANDICCR :: Emulator () +doANDICCR = return () + +doANDISR :: Emulator () +doANDISR = return () + +doANDI :: Int -> Int -> Int -> Emulator () +doANDI _ _ _ = return () + +doSUBI :: Int -> Int -> Int -> Emulator () +doSUBI _ _ _ = return () + +doADDI :: Int -> Int -> Int -> Emulator () +doADDI _ _ _ = return () + +doEORICCR :: Emulator () +doEORICCR = return () + +doEORISR :: Emulator () +doEORISR = return () + +doEORI :: Int -> Int -> Int -> Emulator () +doEORI _ _ _ = return () + +doCMPI :: Int -> Int -> Int -> Emulator () +doCMPI _ _ _ = return () + +doMOVEP :: Int -> Int -> Int -> Int -> Emulator () +doMOVEP _ _ _ _ = return () + +doBTST :: Int -> Int -> Int -> Int -> Emulator () +doBTST _ _ _ _ = return () + +doBCHG :: Int -> Int -> Int -> Int -> Emulator () +doBCHG _ _ _ _ = return () + +doBCLR :: Int -> Int -> Int -> Int -> Emulator () +doBCLR _ _ _ _ = return () + +doBSET :: Int -> Int -> Int -> Int -> Emulator () +doBSET _ _ _ _ = return () + +doMOVEA :: Int -> Int -> Int -> Int -> Emulator () +doMOVEA _ _ _ _ = return () + +doMOVE :: Int -> Int -> Int -> Int -> Int -> Emulator () +doMOVE _ _ _ _ _ = return () + +doSRMOVE :: Int -> Int -> Emulator () +doSRMOVE _ _ = return () + +doMOVECCR :: Int -> Int -> Emulator () +doMOVECCR _ _ = return () + +doMOVESR :: Int -> Int -> Emulator () +doMOVESR _ _ = return () + +doNEGX :: Int -> Int -> Int -> Emulator () +doNEGX _ _ _ = return () + +doCLR :: Int -> Int -> Int -> Emulator () +doCLR _ _ _ = return () + +doNEG :: Int -> Int -> Int -> Emulator () +doNEG _ _ _ = return () + +doNOT :: Int -> Int -> Int -> Emulator () +doNOT _ _ _ = return () + +doEXT :: Int -> Int -> Emulator () +doEXT _ _ = return () + +doNBCD :: Int -> Int -> Emulator () +doNBCD _ _ = return () + +doSWAP :: Int -> Emulator () +doSWAP _ = return () + +doPEA :: Int -> Int -> Emulator () +doPEA _ _ = return () + +doILLEGAL :: Emulator () +doILLEGAL = return () + +doTAS :: Int -> Int -> Emulator () +doTAS _ _ = return () + +doTST :: Int -> Int -> Int -> Emulator () +doTST _ _ _ = return () + +doTRAP :: Int -> Emulator () +doTRAP _ = return () + +doLINK :: Int -> Emulator () +doLINK a = do + incPC + addr <- readA a 4 + sp <- readA 7 4 + writeA 7 4 (sp - 4) + setLong (sp - 4) addr + +doUNLK :: Int -> Emulator () +doUNLK a = do + incPC + addr <- readA a 4 + val <- getLong addr + writeA a 4 val + writeA 7 4 (addr + 4) + +doMOVEUSP :: Int -> Int -> Emulator () +doMOVEUSP _ _ = return () + +doRESET :: Emulator () +doRESET = return () + +doNOP :: Emulator () +doNOP = with pc $ \pc -> do + pcval <- readIORef pc + writeIORef pc (pcval + 2) + +doSTOP :: Emulator () +doSTOP = return () + +doRTE :: Emulator () +doRTE = return () + +doRTS :: Emulator () +doRTS = return () + +doTRAPV :: Emulator () +doTRAPV = return () + +doRTR :: Emulator () +doRTR = return () + +doJSR :: Int -> Int -> Emulator () +doJSR _ _ = return () + +doJMP :: Int -> Int -> Emulator () +doJMP _ _ = return () + +doMOVEM :: Int -> Int -> Int -> Int -> Emulator () +doMOVEM _ _ _ _ = return () + +doLEA :: Int -> Int -> Int -> Emulator () +doLEA _ _ _ = return () + +doCHK :: Int -> Int -> Int -> Emulator () +doCHK _ _ _ = return () + +doDBcc :: Int -> Int -> Emulator () +doDBcc _ _ = return () + +doScc :: Int -> Int -> Int -> Emulator () +doScc _ _ _ = return () + +doADDQ :: Int -> Int -> Int -> Int -> Emulator () +doADDQ _ _ _ _ = return () + +doSUBQ :: Int -> Int -> Int -> Int -> Emulator () +doSUBQ _ _ _ _ = return () + +doBRA :: Int -> Emulator () +doBRA _ = return () + +doBSR :: Int -> Emulator () +doBSR _ = return () + +doBcc :: Int -> Int -> Emulator () +doBcc _ _ = return () + +doMOVEQ :: Int -> Int -> Emulator () +doMOVEQ _ _ = return () + +doDIVU :: Int -> Int -> Int -> Emulator () +doDIVU _ _ _ = return () + +doDIVS :: Int -> Int -> Int -> Emulator () +doDIVS _ _ _ = return () + +doSBCD :: Int -> Int -> Int -> Emulator () +doSBCD _ _ _ = return () + +doOR :: Int -> Int -> Int -> Int -> Int -> Emulator () +doOR _ _ _ _ _ = return () + +doSUBA :: Int -> Int -> Int -> Int -> Emulator () +doSUBA _ _ _ _ = return () + +doSUBX :: Int -> Int -> Int -> Int -> Emulator () +doSUBX _ _ _ _ = return () + +doSUB :: Int -> Int -> Int -> Int -> Int -> Emulator () +doSUB _ _ _ _ _ = return () + +doCMPA :: Int -> Int -> Int -> Int -> Emulator () +doCMPA _ _ _ _ = return () + +doCMP :: Int -> Int -> Int -> Int -> Emulator () +doCMP _ _ _ _ = return () + +doCMPM :: Int -> Int -> Int -> Emulator () +doCMPM _ _ _ = return () + +doEOR :: Int -> Int -> Int -> Int -> Emulator () +doEOR _ _ _ _ = return () + +doMULU :: Int -> Int -> Int -> Emulator () +doMULU _ _ _ = return () + +doMULS :: Int -> Int -> Int -> Emulator () +doMULS _ _ _ = return () + +doABCD :: Int -> Int -> Int -> Emulator () +doABCD _ _ _ = return () + +doEXG :: Int -> Int -> Int -> Int -> Emulator () +doEXG _ _ _ _ = return () + +doAND :: Int -> Int -> Int -> Int -> Int -> Emulator () +doAND _ _ _ _ _ = return () + +doADDA :: Int -> Int -> Int -> Int -> Emulator () +doADDA _ _ _ _ = return () + +doADDX :: Int -> Int -> Int -> Int -> Emulator () +doADDX _ _ _ _ = return () + +doADD :: Int -> Int -> Int -> Int -> Int -> Emulator () +doADD _ _ _ _ _ = return () + +doASD :: Int -> Int -> Int -> Emulator () +doASD _ _ _ = return () + +doLSD :: Int -> Int -> Int -> Emulator () +doLSD _ _ _ = return () + +doROXd :: Int -> Int -> Int -> Emulator () +doROXd _ _ _ = return () + +doROd :: Int -> Int -> Int -> Emulator () +doROd _ _ _ = return () + +doADSR :: Int -> Int -> Int -> Int -> Int -> Emulator () +doADSR _ _ _ _ _ = return () + +doLSDR :: Int -> Int -> Int -> Int -> Int -> Emulator () +doLSDR _ _ _ _ _ = return () + +doROXdR :: Int -> Int -> Int -> Int -> Int -> Emulator () +doROXdR _ _ _ _ _ = return () + +doROdR :: Int -> Int -> Int -> Int -> Int -> Emulator () +doROdR _ _ _ _ _ = return () diff --git a/src/Machine.hs b/src/Machine.hs index 57d4c9e..4dd40d3 100644 --- a/src/Machine.hs +++ b/src/Machine.hs @@ -370,14 +370,14 @@ getOp 4 ar s = do return (getMemory addr s, setMemory addr s) getOp 5 ar s = do pc <- readPC - incPC + skipOp 2 disp <- getMemory pc 2 addr <- readA ar 4 let addr = addr + disp return (getMemory addr s, setMemory addr s) getOp 6 ar s = do pc <- readPC - incPC + skipOp 2 prefix <- getMemory pc 1 index <- (if testBit prefix 0 then readA else readD) (extractBits prefix [1..3]) @@ -388,13 +388,13 @@ getOp 6 ar s = do return (getMemory addr s, setMemory addr s) getOp 7 2 s = do addr <- readPC - incPC + skipOp 2 disp <- getMemory addr 2 let addr = addr + disp return (getMemory addr s, setMemory addr s) getOp 7 3 s = do addr <- readPC - incPC + skipOp 2 prefix <- getMemory addr 1 index <- (if testBit prefix 0 then readA else readD) (extractBits prefix [1..3]) @@ -404,7 +404,7 @@ getOp 7 3 s = do return (getMemory addr s, setMemory addr s) getOp 7 0 s = do pc <- readPC - incPC + skipOp 2 addr <- getMemory pc 2 return (getMemory addr s, setMemory addr s) getOp 7 1 s = do diff --git a/src/Suem.hs b/src/Suem.hs index 5edd041..63e52d2 100644 --- a/src/Suem.hs +++ b/src/Suem.hs @@ -14,7 +14,7 @@ import Data.IP import Network.Socket import Numeric import Machine -import Commands +import Instructions import Utils import Device @@ -22,355 +22,355 @@ import Device ------------------------------------------------------------------------------ -- Main loop and command deciphering. -doCommand :: Word16 -> Emulator () -doCommand 0b0000000000111100 = doORICCR -doCommand 0b0000000001111100 = doORISR -doCommand 0b0000001000111100 = doANDICCR -doCommand 0b0000001001111100 = doANDISR -doCommand 0b0000101000111100 = doEORICCR -doCommand 0b0000101001111100 = doEORISR -doCommand 0b0100101011111100 = doILLEGAL -doCommand 0b0100111001110000 = doRESET -doCommand 0b0100111001110001 = doNOP -doCommand 0b0100111001110010 = doSTOP -doCommand 0b0100111001110011 = doRTE -doCommand 0b0100111001110101 = doRTS -doCommand 0b0100111001110110 = doTRAPV -doCommand 0b0100111001110111 = doRTR -doCommand cmd - | (extractBits cmd [0..7]) == 0b00000000 = - doORI (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b00000010 = - doANDI (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b00000100 = - doSUBI (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b00000110 = - doADDI (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b00001010 = - doEORI (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b00001100 = - doCMPI (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0000 && - (extractBits cmd [7]) == 0b0 && - (extractBits cmd [10..12]) == 0b001 = - doMOVEP (extractBits cmd [4..6]) - (extractBits cmd [8]) - (extractBits cmd [9]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0000 && - (extractBits cmd [8..9]) == 0b00 = - doBTST (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0000 && - (extractBits cmd [8..9]) == 0b01 = - doBCHG (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0000 && - (extractBits cmd [8..9]) == 0b10 = - doBCLR (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0000 && - (extractBits cmd [8..9]) == 0b11 = - doBSET (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..1]) == 0b00 && - (extractBits cmd [7..9]) == 0b001 = - doMOVEA (extractBits cmd [2..3]) - (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..1]) == 0b00 = - doMOVE (extractBits cmd [2..3]) - (extractBits cmd [4..6]) - (extractBits cmd [7..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100000011 = - doSRMOVE (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100010011 = - doMOVECCR (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100011011 = - doMOVESR (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b01000000 = - doNEGX (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b01000010 = - doCLR (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b01000100 = - doNEG (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b01000110 = - doNOT (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..8]) == 0b010010001 && - (extractBits cmd [10..12]) == 0b000 = - doEXT (extractBits cmd [9]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100100000 = - doNBCD (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..12]) == 0b0100100001000 = - doSWAP (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100100001 = - doPEA (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100100011 = - doTAS (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b01001010 = - doTST (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..11]) == 0b010011100100 = - doTRAP (extractBits cmd [12..15]) - | (extractBits cmd [0..12]) == 0b0100111001010 = - doLINK (extractBits cmd [13..15]) - | (extractBits cmd [0..12]) == 0b0100111001011 = - doUNLK (extractBits cmd [13..15]) - | (extractBits cmd [0..11]) == 0b010011100110 = - doMOVEUSP (extractBits cmd [12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100111010 = - doJSR (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..9]) == 0b0100111011 = - doJMP (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..4]) == 0b01001 && - (extractBits cmd [6..8]) == 0b001 = - doMOVEM (extractBits cmd [5]) - (extractBits cmd [9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0100 && - (extractBits cmd [7..9]) == 0b111 = - doLEA (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0100 && - (extractBits cmd [7..9]) == 0b110 = - doCHK (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0101 && - (extractBits cmd [8..12]) == 0b11001 = - doDBcc (extractBits cmd [4..7]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0101 && - (extractBits cmd [8..9]) == 0b11 = - doScc (extractBits cmd [4..7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0101 && - (extractBits cmd [7]) == 0b0 = - doADDQ (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b0101 && - (extractBits cmd [7]) == 0b1 = - doSUBQ (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..7]) == 0b01100000 = - doBRA (extractBits cmd [8..15]) - | (extractBits cmd [0..7]) == 0b01100000 = - doBSR (extractBits cmd [8..15]) - | (extractBits cmd [0..3]) == 0b0110 = - doBcc (extractBits cmd [4..7]) - (extractBits cmd [8..15]) - | (extractBits cmd [0..3]) == 0b0111 && - (extractBits cmd [7]) == 0b0 = - doMOVEQ (extractBits cmd [4..6]) - (extractBits cmd [8..15]) - | (extractBits cmd [0..3]) == 0b1000 && - (extractBits cmd [7..9]) == 0b011 = - doDIVU (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1000 && - (extractBits cmd [7..9]) == 0b111 = - doDIVS (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1000 && - (extractBits cmd [7..11]) == 0b10000 = - doSBCD (extractBits cmd [4..6]) - (extractBits cmd [12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1000 = - doOR (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1001 && - (extractBits cmd [8..9]) == 0b11 = - doSUBA (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1001 && - (extractBits cmd [7]) == 0b1 && - (extractBits cmd [10..11]) == 0b00 = - doSUBX (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1001 = - doSUB (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1011 && - (extractBits cmd [8..9]) == 0b11 = - doCMPA (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1011 && - (extractBits cmd [7]) == 0b0 = - doCMP (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1011 && - (extractBits cmd [7]) == 0b1 && - (extractBits cmd [10..12]) == 0b001 = - doCMPM (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1011 && - (extractBits cmd [7]) == 0b1 = - doEOR (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1100 && - (extractBits cmd [7..9]) == 0b011 = - doMULU (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1100 && - (extractBits cmd [7..9]) == 0b111 = - doMULS (extractBits cmd [4..6]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1100 && - (extractBits cmd [7..11]) == 0b10000 = - doABCD (extractBits cmd [4..6]) - (extractBits cmd [12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1100 && - (extractBits cmd [7]) == 0b1 && - (extractBits cmd [10..11]) == 0b00 = - doEXG (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1100 = - doAND (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1101 && - (extractBits cmd [8..9]) == 0b11 = - doADDA (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1101 && - (extractBits cmd [7]) == 0b1 && - (extractBits cmd [10..11]) == 0b00 = - doADDX (extractBits cmd [4..6]) - (extractBits cmd [8..9]) - (extractBits cmd [12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1101 = - doADD (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..6]) == 0b1110000 && - (extractBits cmd [8..9]) == 0b11 = - doASD (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..6]) == 0b1110001 && - (extractBits cmd [8..9]) == 0b11 = - doLSD (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..6]) == 0b1110010 && - (extractBits cmd [8..9]) == 0b11 = - doROXd (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..6]) == 0b1110011 && - (extractBits cmd [8..9]) == 0b11 = - doROd (extractBits cmd [7]) - (extractBits cmd [10..12]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1110 && - (extractBits cmd [11..12]) == 0b00 = - doADSR (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1110 && - (extractBits cmd [11..12]) == 0b01 = - doLSDR (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1110 && - (extractBits cmd [11..12]) == 0b10 = - doROXdR (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10]) - (extractBits cmd [13..15]) - | (extractBits cmd [0..3]) == 0b1110 && - (extractBits cmd [11..12]) == 0b11 = - doROdR (extractBits cmd [4..6]) - (extractBits cmd [7]) - (extractBits cmd [8..9]) - (extractBits cmd [10]) - (extractBits cmd [13..15]) +doInstruction :: Word16 -> Emulator () +doInstruction 0b0000000000111100 = doORICCR +doInstruction 0b0000000001111100 = doORISR +doInstruction 0b0000001000111100 = doANDICCR +doInstruction 0b0000001001111100 = doANDISR +doInstruction 0b0000101000111100 = doEORICCR +doInstruction 0b0000101001111100 = doEORISR +doInstruction 0b0100101011111100 = doILLEGAL +doInstruction 0b0100111001110000 = doRESET +doInstruction 0b0100111001110001 = doNOP +doInstruction 0b0100111001110010 = doSTOP +doInstruction 0b0100111001110011 = doRTE +doInstruction 0b0100111001110101 = doRTS +doInstruction 0b0100111001110110 = doTRAPV +doInstruction 0b0100111001110111 = doRTR +doInstruction opcode + | (extractBits opcode [0..7]) == 0b00000000 = + doORI (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b00000010 = + doANDI (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b00000100 = + doSUBI (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b00000110 = + doADDI (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b00001010 = + doEORI (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b00001100 = + doCMPI (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0000 && + (extractBits opcode [7]) == 0b0 && + (extractBits opcode [10..12]) == 0b001 = + doMOVEP (extractBits opcode [4..6]) + (extractBits opcode [8]) + (extractBits opcode [9]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0000 && + (extractBits opcode [8..9]) == 0b00 = + doBTST (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0000 && + (extractBits opcode [8..9]) == 0b01 = + doBCHG (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0000 && + (extractBits opcode [8..9]) == 0b10 = + doBCLR (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0000 && + (extractBits opcode [8..9]) == 0b11 = + doBSET (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..1]) == 0b00 && + (extractBits opcode [7..9]) == 0b001 = + doMOVEA (extractBits opcode [2..3]) + (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..1]) == 0b00 = + doMOVE (extractBits opcode [2..3]) + (extractBits opcode [4..6]) + (extractBits opcode [7..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100000011 = + doSRMOVE (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100010011 = + doMOVECCR (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100011011 = + doMOVESR (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b01000000 = + doNEGX (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b01000010 = + doCLR (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b01000100 = + doNEG (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b01000110 = + doNOT (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..8]) == 0b010010001 && + (extractBits opcode [10..12]) == 0b000 = + doEXT (extractBits opcode [9]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100100000 = + doNBCD (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..12]) == 0b0100100001000 = + doSWAP (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100100001 = + doPEA (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100100011 = + doTAS (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b01001010 = + doTST (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..11]) == 0b010011100100 = + doTRAP (extractBits opcode [12..15]) + | (extractBits opcode [0..12]) == 0b0100111001010 = + doLINK (extractBits opcode [13..15]) + | (extractBits opcode [0..12]) == 0b0100111001011 = + doUNLK (extractBits opcode [13..15]) + | (extractBits opcode [0..11]) == 0b010011100110 = + doMOVEUSP (extractBits opcode [12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100111010 = + doJSR (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..9]) == 0b0100111011 = + doJMP (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..4]) == 0b01001 && + (extractBits opcode [6..8]) == 0b001 = + doMOVEM (extractBits opcode [5]) + (extractBits opcode [9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0100 && + (extractBits opcode [7..9]) == 0b111 = + doLEA (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0100 && + (extractBits opcode [7..9]) == 0b110 = + doCHK (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0101 && + (extractBits opcode [8..12]) == 0b11001 = + doDBcc (extractBits opcode [4..7]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0101 && + (extractBits opcode [8..9]) == 0b11 = + doScc (extractBits opcode [4..7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0101 && + (extractBits opcode [7]) == 0b0 = + doADDQ (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b0101 && + (extractBits opcode [7]) == 0b1 = + doSUBQ (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..7]) == 0b01100000 = + doBRA (extractBits opcode [8..15]) + | (extractBits opcode [0..7]) == 0b01100000 = + doBSR (extractBits opcode [8..15]) + | (extractBits opcode [0..3]) == 0b0110 = + doBcc (extractBits opcode [4..7]) + (extractBits opcode [8..15]) + | (extractBits opcode [0..3]) == 0b0111 && + (extractBits opcode [7]) == 0b0 = + doMOVEQ (extractBits opcode [4..6]) + (extractBits opcode [8..15]) + | (extractBits opcode [0..3]) == 0b1000 && + (extractBits opcode [7..9]) == 0b011 = + doDIVU (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1000 && + (extractBits opcode [7..9]) == 0b111 = + doDIVS (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1000 && + (extractBits opcode [7..11]) == 0b10000 = + doSBCD (extractBits opcode [4..6]) + (extractBits opcode [12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1000 = + doOR (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1001 && + (extractBits opcode [8..9]) == 0b11 = + doSUBA (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1001 && + (extractBits opcode [7]) == 0b1 && + (extractBits opcode [10..11]) == 0b00 = + doSUBX (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1001 = + doSUB (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1011 && + (extractBits opcode [8..9]) == 0b11 = + doCMPA (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1011 && + (extractBits opcode [7]) == 0b0 = + doCMP (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1011 && + (extractBits opcode [7]) == 0b1 && + (extractBits opcode [10..12]) == 0b001 = + doCMPM (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1011 && + (extractBits opcode [7]) == 0b1 = + doEOR (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1100 && + (extractBits opcode [7..9]) == 0b011 = + doMULU (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1100 && + (extractBits opcode [7..9]) == 0b111 = + doMULS (extractBits opcode [4..6]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1100 && + (extractBits opcode [7..11]) == 0b10000 = + doABCD (extractBits opcode [4..6]) + (extractBits opcode [12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1100 && + (extractBits opcode [7]) == 0b1 && + (extractBits opcode [10..11]) == 0b00 = + doEXG (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1100 = + doAND (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1101 && + (extractBits opcode [8..9]) == 0b11 = + doADDA (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1101 && + (extractBits opcode [7]) == 0b1 && + (extractBits opcode [10..11]) == 0b00 = + doADDX (extractBits opcode [4..6]) + (extractBits opcode [8..9]) + (extractBits opcode [12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1101 = + doADD (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..6]) == 0b1110000 && + (extractBits opcode [8..9]) == 0b11 = + doASD (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..6]) == 0b1110001 && + (extractBits opcode [8..9]) == 0b11 = + doLSD (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..6]) == 0b1110010 && + (extractBits opcode [8..9]) == 0b11 = + doROXd (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..6]) == 0b1110011 && + (extractBits opcode [8..9]) == 0b11 = + doROd (extractBits opcode [7]) + (extractBits opcode [10..12]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1110 && + (extractBits opcode [11..12]) == 0b00 = + doADSR (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1110 && + (extractBits opcode [11..12]) == 0b01 = + doLSDR (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1110 && + (extractBits opcode [11..12]) == 0b10 = + doROXdR (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10]) + (extractBits opcode [13..15]) + | (extractBits opcode [0..3]) == 0b1110 && + (extractBits opcode [11..12]) == 0b11 = + doROdR (extractBits opcode [4..6]) + (extractBits opcode [7]) + (extractBits opcode [8..9]) + (extractBits opcode [10]) + (extractBits opcode [13..15]) | otherwise = do pc <- readPC sr <- readSR @@ -413,8 +413,8 @@ doCommand cmd runMachine :: Emulator () runMachine = forM_ [0..] $ \_ -> do pc <- with pc $ \pc -> readIORef pc - cmd <- getWord $ fromIntegral pc - doCommand cmd + opcode <- getWord $ fromIntegral pc + doInstruction opcode checkInteruptsFromDevices -- cgit v1.2.3