asmarm.sh
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:1k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. #!/bin/sh
  2. # Translate the assembler syntax of arm assembler programs
  3. # Usage: asmarm < riscix-asm-file > portable-asm-file
  4. # The portable-asm-file has to be
  5. #   1. preprocessed,
  6. #   2. grep -v '^ *#line' | grep -v '^#'
  7. #   3. sed -e 's,% ,%,g' -e 's,//,@,g' -e 's,$,#,g'
  8. tmpscript1=sed$$tmp1
  9. tmpscript2=sed$$tmp2
  10. tmpremove='rm -f $tmpscript1 $tmpscript2'
  11. trap "$tmpremove" 1 2 15
  12. cat > $tmpscript1 << EOF
  13. # ----------- Remove gcc self-identification
  14. /gcc2_compiled/d
  15. /gnu_compiled_c/d
  16. EOF
  17. cat > $tmpscript2 << EOF
  18. # ----------- Hide comments, to avoid trouble in preprocessing
  19. s,@,//,g
  20. # ----------- Turn # into $, to avoid trouble in preprocessing
  21. s,#,$,g
  22. # ----------- Declare global symbols as functions (we have no variables)
  23. s/.global _([A-Za-z0-9_]*)$/.global _1
  24. DECLARE_FUNCTION(1)/
  25. # ----------- Global symbols depends on ASM_UNDERSCORE
  26. s/_([A-Za-z0-9_:]*)/C(1)/
  27. EOF
  28. sed -f $tmpscript1 | 
  29. sed -f $tmpscript2
  30. eval "$tmpremove"