source: atk2-sc3-1.4.0-ntisr/arch/ccrh/gcc2ccrh.rb@ 172

Last change on this file since 172 was 172, checked in by ertl-ishikawa, 8 years ago

ATK2-SC3 1.4.0 RH850依存部 非信頼C2ISR対応を追加

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#! ruby -Ku
2
3if ARGV.size != 1 then
4 puts "Argment Error!"
5 exit
6end
7
8#Input from gcc file
9begin
10 gcc_asm_file = open(ARGV[0])
11rescue
12 puts "File Open Error!"
13 exit
14end
15
16
17cx_asm = ""
18
19#Convert
20while line = gcc_asm_file.gets
21 line = line.gsub('.section .reset.text', "RESET .cseg text")
22
23 line = line.sub('/*', ';/*')
24
25 line = line.sub(/^(\s*)\*/, '\1;*')
26
27 line = line.sub(/.macro\s+(\w+)/, '\1 .macro')
28
29 line = line.sub(/#include\s+[<"](.+)[>"]/, '$include (\1)')
30
31 line = line.sub('.global', '.extern')
32
33 line = line.sub('.globl', '.public')
34
35 line = line.gsub(/AMARG\((\w+)\)/, '\1')
36
37 line = line.gsub(/FLABEL\((\w+)\)/, '\1:')
38
39 line = line.gsub('~', '!')
40
41 line = line.gsub('#ifdef', '$ifdef')
42
43 line = line.gsub('#ifndef', '$ifndef')
44
45 line = line.gsub('#endif', '$endif')
46
47 line = line.gsub('#else', '$else')
48
49 line = line.gsub('#elif', '$elseif')
50
51 line = line.gsub('.section', '.cseg')
52
53 line = line.gsub(/\.endr/i, '.endm')
54
55 line = line.gsub(/\.text/i, 'text')
56
57 line = line.gsub('.word', '.dw')
58
59 cx_asm = cx_asm + line
60end
61
62cx_asm_file_name = File::basename(ARGV[0].sub(".S", ".asm"))
63print sprintf("Output %s\n", cx_asm_file_name)
64
65#Output to asm file
66File.open(cx_asm_file_name, 'w') {|file|
67 file.write cx_asm
68}
Note: See TracBrowser for help on using the repository browser.