Implement new specification
This commit is contained in:
parent
75821abb2c
commit
957f65c380
5 changed files with 55 additions and 25 deletions
|
|
@ -29,13 +29,19 @@ printWord n word = do
|
|||
T.putStr $ T.justifyRight n ' ' $ toDec word
|
||||
putStr ")"
|
||||
|
||||
-- Color scheme:
|
||||
-- Red: HALT
|
||||
-- Yellow: Instructions for accessing other registers
|
||||
-- Green: Instructions that can modify the IAR (jumps)
|
||||
-- Blue: Instructions that read from or write to memory
|
||||
-- Cyan: Logical operations and calculations that modify the ACC
|
||||
printInstruction :: Instruction -> IO ()
|
||||
printInstruction (SmallInstruction so lv) = do
|
||||
setSGR [SetConsoleIntensity BoldIntensity]
|
||||
if | so `elem` [JMP, JMN, CALL] -> setSGR [SetColor Foreground Dull Green]
|
||||
| so `elem` [LDC, LDV, STV, LDIV, STIV, LDVR, STVR] -> setSGR [SetColor Foreground Vivid Blue]
|
||||
| so `elem` [ADD, AND, OR, XOR, EQL] -> setSGR [SetColor Foreground Vivid Cyan]
|
||||
| otherwise -> pure ()
|
||||
if | so `elem` [JMP, JMN, CALL] -> setSGR [SetColor Foreground Dull Green]
|
||||
| so `elem` [LDC, LDV, STV, LDIV, STIV] -> setSGR [SetColor Foreground Vivid Blue]
|
||||
| so `elem` [ADD, AND, OR, XOR, EQL, ADC] -> setSGR [SetColor Foreground Vivid Cyan]
|
||||
| otherwise -> pure ()
|
||||
T.putStr $ toText so
|
||||
putStr " "
|
||||
setSGR [SetColor Foreground Vivid Black]
|
||||
|
|
@ -44,12 +50,13 @@ printInstruction (SmallInstruction so lv) = do
|
|||
printInstruction (LargeInstruction lo sv) = do
|
||||
setSGR [SetConsoleIntensity BoldIntensity]
|
||||
if | lo == HALT -> setSGR [SetColor Foreground Vivid Red]
|
||||
| lo == RET -> setSGR [SetColor Foreground Dull Green]
|
||||
| lo `elem` [NOT, RAR, ADC] -> setSGR [SetColor Foreground Vivid Cyan]
|
||||
| lo `elem` [LDRA, STRA, LDSP, STSP, LDFP, STFP] -> setSGR [SetColor Foreground Dull Yellow]
|
||||
| lo == RET -> setSGR [SetColor Foreground Dull Green]
|
||||
| lo `elem` [LDRS, STRS, LDRF, STRF] -> setSGR [SetColor Foreground Vivid Blue]
|
||||
| lo `elem` [NOT, RAR] -> setSGR [SetColor Foreground Vivid Cyan]
|
||||
| otherwise -> pure ()
|
||||
T.putStr $ toText lo
|
||||
when (lo == ADC || sv /= zeroBits) $ do
|
||||
when (lo `elem` [LDRS, STRS, LDRF, STRF] || sv /= zeroBits) $ do
|
||||
putStr " "
|
||||
setSGR [SetColor Foreground Vivid Black]
|
||||
T.putStr $ toDec sv
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue