2016-09-19 32 views

回答

7

我不知道任何特定的程序集,但你提到的東西可以用sed完成。

幾件事情需要注意:

  • 助記符由正則表達式匹配[A-Za-z0-9]+。關於我的頭頂,我想不出任何包含其他角色的助記符。
  • GPR的上半部分匹配r(8|9|1[0-5])(b|w|d)
  • 字節GPRS(不含R8B-r15b)由[abcd](l|h)|(sp|bp|si|di)l
  • 匹配的16,32和64位的低8個GPR則通過[er]?([abcd]x|sp|bp|si|di)匹配
  • SSE寄存器可以與該正則表達式匹配xmm(1[0-5]?|[0,2-9])

例如:

# Replace tabs with spaces, then clean up lines of the form "op reg/imm, ..." 
# N.B. without the /I option the match will be case-sensitive 
sed 's/\t/ /g' <test.s | sed 's/^\s*\([a-z0-9][a-z0-9]*\)\s\s*\([a-z0-9][a-z0-9]*\)\s*,\s*/\t\1\t\2, /I' 

# Lowercase all GPRs and SSE vector registers" 
# I have chosen not to use the more compact patterns above in the interest of readability. 
... | sed '/\([^a-z]\)\(AL|AH|AX|EAX|RAX|...XMM0|XMM1|...|XMM15\)/\1\L\2/gI' 

# Lowercase all instruction mnemonics. More specifically, matches the first thing on every line except when it is followed by a colon. 
... | sed '/^\s*\([a-z0-9][a-z0-9]*\)\([^:]\)/\L\1\2/I 
+0

這很好,如果我沒有找到任何得到它全部完成,我將使用this.Thanks!仍然留給我大寫的指示,我只是小寫一切,但標籤是camelCase。 –

+0

這有點粗糙,我只覆蓋了一些最小的案例來傳達想法,但它會做你想做的:sed's/\(ADD \ | OR \ | ADC \ | SBB \ | SUB \ | AND \ | XOR \ | CMP \ | AL \ | AH \ | AX \ | EAX \ | RAX \)/ \ L \ 1/g' icecreamsword

+0

我想我必須這樣做,但問題我使用了幾十個SSE指令,看起來像PUNPCKLWD。可能可能在某處獲得列表,並解析它以創建一個可用的sed命令。稍後再嘗試。 –

相關問題