Safe Haskell | None |
---|---|
Language | Haskell2010 |
- parseInst :: ByteString -> Either [String] [Inst]
- parseInstFile :: FilePath -> IO [Inst]
- runDbg :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> (TrcLog, CpuState)
- runDbgIO :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> IO ()
- data DbgTrc
- data DbgBrk
- data DbgOrd
- type TrcLog = ByteString
- runIdbIO :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> IO ()
- runProf :: [ProfMode] -> InstImage -> DataImage -> String
- runProfIO :: [ProfMode] -> InstImage -> DataImage -> IO ()
- prof :: [ProfMode] -> ByteString -> String
- data ProfMode
Assembler
parseInst :: ByteString -> Either [String] [Inst] Source
parse instructions from a ByteString data
Example:
> parseInst (B.pack "mov r0,1\n halt\n") [MOVI R0 1,HALT]
parseInstFile :: FilePath -> IO [Inst] Source
parse instructions from a file
Example:
> parseInstFile "examples/test0.asm" [MOVI R0 1,HALT]
Debugger
runDbg :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> (TrcLog, CpuState) Source
debugging run
Example: run with a break condition. (break at pc == 1)
> runDbg [] [(BrkPc BEQ 1)] [(0,[MOVI R0 7, MOVI R1 8, HALT])] [] pc : 1 gr : [7,0,0,0,0,0,0,0] fl : [False,False]
Example: run with trace output. (instruction trace)
> runDbg [TrcInst] [] [(0,[MOVI R0 7, MOVI R1 8, HALT])] [] TrcInst: pc : 0 MOVI R0 7 TrcInst: pc : 1 MOVI R1 8 TrcInst: pc : 2 HALT
runDbgIO :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> IO () Source
debugging run for IO output
Example: run with trace output. (instruction trace)
> runDbgIO [TrcInst] [] [(0,[MOVI R0 7, MOVI R1 8, HALT])] [] TrcInst: pc : 0 MOVI R0 7 TrcInst: pc : 1 MOVI R1 8 TrcInst: pc : 2 HALT
break conditions
Example:
BrkPc BEQ 3 -- pc == 3 BrkPc BGE 0x80 -- pc >= 0x80 BrkGReg R0 BEQ 7 -- R0 == 7 BrkDmem 0x20 BLT 4 -- *0x20 < 4
break operators
type TrcLog = ByteString Source
data type for runDbg
log
Interactive Debugger
runIdbIO :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> IO () Source
interactive debugger driver.
Example:
> runIdbIO [TrcInst] [] [(0,insts)] [] For help, type "help". (idb) info reg pc : 0 gr : [0,0,0,0,0,0,0,0] fl : [False,False] (idb) s TrcInst: pc : 0 MOVI R0 0 (idb) s TrcInst: pc : 1 MOVI R1 1 (idb) b 4 Num Enb What 1 y pc == 4 (idb) c TrcInst: pc : 2 MOVI R2 2 TrcInst: pc : 3 MOVI R3 3 (idb) x/10 0 0x00000000: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000004: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000008: 0x00000000 0x00000000 (idb) q
please see "help" command
Profiler
runProf :: [ProfMode] -> InstImage -> DataImage -> String Source
run the profiler
Example: instruction count profile
> runProf [ProfInst] [(0,[MOVI R1 0, MOVI R2 8, ST R1 R2, HALT])] [] instruction profile: MOVI 2 HALT 1 ST 1 total 4
Example: memory store profile
> runProf [ProfStore] [(0,insts)] [] Memory store address profile: address count 0x00000000 1 0x00000001 1 0x00000002 1 0x00000003 1 0x00000004 1 0x00000005 1 0x00000006 1 total 7
Example: branch,jump,call profile
> runProf [ProfBranch] [(0,insts)] [] Branch/Jump/Call target profile: address count 0x00000007 6 total 6 Branch/Jump/Call direction profile: T/N count Taken 6 Not 1 total 7
runProfIO :: [ProfMode] -> InstImage -> DataImage -> IO () Source
run the profiler for IO output
Example:
> runProfIO [ProfInst] [(0,[MOVI R1 0, MOVI R2 8, ST R1 R2, HALT])] [] instruction profile: MOVI 2 HALT 1 ST 1 total 4
prof :: [ProfMode] -> ByteString -> String Source
profile function
Example:
> prof [ProfInst] $ fst $ runDbg [TrcInst] [] [(0,insts)] [] instruction profile: MOVI 2 HALT 1 ST 1 total 4