Dam*_*ira 3 assembly code-formatting x86-64
我有一些我想清理的集会.它具有全部大写,不一致的间距和许多不需要的换行符.
如何美化这个x86_64汇编代码?
我不知道任何具体的装配,但你提到的事情可以用sed完成.
有几点需要注意:
[A-Za-z0-9]+
.在我的脑海中,我想不出任何包含其他角色的助记符.r(8|9|1[0-5])(b|w|d)
?[abcd](l|h)|(sp|bp|si|di)l
[er]?([abcd]x|sp|bp|si|di)
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
Run Code Online (Sandbox Code Playgroud)