diff options
author | Camil Staps | 2016-09-18 20:16:20 +0000 |
---|---|---|
committer | Camil Staps | 2016-09-18 20:16:20 +0000 |
commit | 8c91384816c17856593e835004ee44559f49cc01 (patch) | |
tree | 9db2a0c7fb115bd0dc10e7812b62f7dad6f1f54b | |
parent | Gitignore; copied stuff from arm to thumb2 (diff) |
Adds thumb directives and fixes for storing the PC
Added directives:
- .syntax unified at the start of the file
- .thumb at the start of each code section
- .thumb_func before each code label
Storing the PC:
- PC cannot be Rd for str, hence we need the scratch register
-rw-r--r-- | cgthumb2was.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cgthumb2was.c b/cgthumb2was.c index 8529878..d43a5ec 100644 --- a/cgthumb2was.c +++ b/cgthumb2was.c @@ -92,6 +92,7 @@ static void w_as_to_code_section (VOID) { if (in_data_section){ in_data_section=0; + w_as_instruction_without_parameters (".thumb"); w_as_instruction_without_parameters (".text"); } } @@ -387,6 +388,7 @@ static void w_as_define_code_label (LABEL *label) w_as_newline(); } + w_as_instruction_without_parameters (".thumb_func"); w_as_label (label->label_name); w_as_colon(); w_as_newline(); @@ -1491,15 +1493,21 @@ static void w_as_jsr_instruction (struct instruction *instruction) w_as_newline_after_instruction(); } else { if (instruction->instruction_arity>1) + w_as_opcode ("mov"); + w_as_scratch_register_comma(); + fprintf (assembly_file,"pc"); + w_as_newline_after_instruction(); switch (instruction->instruction_parameters[1].parameter_type){ case P_INDIRECT_WITH_UPDATE: w_as_opcode ("str"); - fprintf (assembly_file,"pc,[sp,#%d]!",instruction->instruction_parameters[1].parameter_offset); + w_as_scratch_register_comma(); + fprintf (assembly_file,"[sp,#%d]!",instruction->instruction_parameters[1].parameter_offset); w_as_newline_after_instruction(); break; case P_INDIRECT: w_as_opcode ("str"); - fprintf (assembly_file,"pc,[sp,#%d]",instruction->instruction_parameters[1].parameter_offset); + w_as_scratch_register_comma(); + fprintf (assembly_file,"[sp,#%d]",instruction->instruction_parameters[1].parameter_offset); w_as_newline_after_instruction(); break; } @@ -2869,6 +2877,8 @@ void write_assembly (VOID) instruction_n_after_ltorg = 0u; ltorg_at_instruction_n = 0u-1u; + fprintf (assembly_file,"\t.syntax unified"); + w_as_newline(); fprintf (assembly_file,"\t.fpu\tvfp"); w_as_newline(); |