Update README.md
Browse files
    	
        README.md
    CHANGED
    
    | 
         @@ -34,11 +34,9 @@ import subprocess 
     | 
|
| 34 | 
         
             
            import os
         
     | 
| 35 | 
         
             
            import re
         
     | 
| 36 | 
         | 
| 37 | 
         
            -
            digit_pattern = r'\b0x[a-fA-F0-9]+\b'# 
     | 
| 38 | 
         
             
            zeros_pattern = r'^0+\s'#0s
         
     | 
| 39 | 
         
             
            OPT = ["O0", "O1", "O2", "O3"]
         
     | 
| 40 | 
         
            -
            before = f"# This is the assembly code with {opt_state} optimization:\n"
         
     | 
| 41 | 
         
            -
            after = "\n# What is the source code?\n"
         
     | 
| 42 | 
         
             
            fileName = 'path/to/file'
         
     | 
| 43 | 
         
             
            with open(fileName+'.c','r') as f:#original file
         
     | 
| 44 | 
         
             
                c_func = f.read()
         
     | 
| 
         @@ -58,7 +56,8 @@ for opt_state in OPT: 
     | 
|
| 58 | 
         
             
                    tmp_asm = tmp_asm.split('#')[0].strip()#remove the comments
         
     | 
| 59 | 
         
             
                    input_asm+=tmp_asm+'\n'
         
     | 
| 60 | 
         
             
                input_asm = re.sub(zeros_pattern, '', input_asm)
         
     | 
| 61 | 
         
            -
                
         
     | 
| 
         | 
|
| 62 | 
         
             
                input_asm_prompt = before+input_asm.strip()+after
         
     | 
| 63 | 
         
             
                with open(fileName +'_' + opt_state +'.asm','w',encoding='utf-8') as f:
         
     | 
| 64 | 
         
             
                    f.write(input_asm_prompt)
         
     | 
| 
         | 
|
| 34 | 
         
             
            import os
         
     | 
| 35 | 
         
             
            import re
         
     | 
| 36 | 
         | 
| 37 | 
         
            +
            digit_pattern = r'\b0x[a-fA-F0-9]+\b'# binary codes in Hexadecimal
         
     | 
| 38 | 
         
             
            zeros_pattern = r'^0+\s'#0s
         
     | 
| 39 | 
         
             
            OPT = ["O0", "O1", "O2", "O3"]
         
     | 
| 
         | 
|
| 
         | 
|
| 40 | 
         
             
            fileName = 'path/to/file'
         
     | 
| 41 | 
         
             
            with open(fileName+'.c','r') as f:#original file
         
     | 
| 42 | 
         
             
                c_func = f.read()
         
     | 
| 
         | 
|
| 56 | 
         
             
                    tmp_asm = tmp_asm.split('#')[0].strip()#remove the comments
         
     | 
| 57 | 
         
             
                    input_asm+=tmp_asm+'\n'
         
     | 
| 58 | 
         
             
                input_asm = re.sub(zeros_pattern, '', input_asm)
         
     | 
| 59 | 
         
            +
                before = f"# This is the assembly code with {opt_state} optimization:\n"#prompt
         
     | 
| 60 | 
         
            +
                after = "\n# What is the source code?\n"#prompt
         
     | 
| 61 | 
         
             
                input_asm_prompt = before+input_asm.strip()+after
         
     | 
| 62 | 
         
             
                with open(fileName +'_' + opt_state +'.asm','w',encoding='utf-8') as f:
         
     | 
| 63 | 
         
             
                    f.write(input_asm_prompt)
         
     |