Python: parsing and extracting op-codes from asm -


i parse assembly file , extract opcodes, stripping-of operands. each line in input file consists of 3 opcodes. should extract first word after "[" in each line , accumulate in list ? there better way of doing this?

here input file format:

[slli a3,a3,4] [add.n a3,a3,a8] [l32i a11,a3,128] [add.n a3,a3,a8] [l32i a11,a3,128] [l32r a9,0x1fff8954] [l32i a11,a3,128] [l32r a9,0x1fff8954] [l32i.n a10,a11,4] [l32r a9,0x1fff8954] [l32i.n a10,a11,4] [l8ui a8,a11,0] 

my expected output should this:

[ slli  : add.n  : l32i   ] [ add.n : l32i   : l32r   ] [ l32i  : l32r   : l32i.n ] [ l32r  : l32i.n  : l8ui  ] 

finding op-codes:

>>> import re >>> re.findall(r'\[(?=([a-z0-9.]+))','[slli a3,a3,4] [add.n a3,a3,a8] [l32i a11,a3,128]') ['slli', 'add.n', 'l32i'] 

you should wrap function.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -