1
0
mirror of https://github.com/lefticus/6502-cpp.git synced 2026-04-20 11:17:18 +00:00

Better label handling

This commit is contained in:
Jason Turner
2021-05-27 08:31:02 -06:00
parent 949e118ef7
commit 8b159faa59
4 changed files with 166 additions and 59 deletions
+20 -1
View File
@@ -2,7 +2,7 @@
static constexpr std::string_view __mulhi3 =
R"(
;;; based on protocol from gcc's calling conventions for AVR
;;; 16x16 = 16 multiply
;;; R25:R24 = R23:R22 * R25:R24
;;; Clobbers: __tmp_reg__, R21..R23
@@ -33,3 +33,22 @@ __mulhi3:
)";
static constexpr std::string_view __mulqi3 =
R"(
;;; based on protocol from gcc's calling conventions for AVR
;;; 8x8 = 8 multiply
;;; R24 = R22 * R24
;;; Clobbers: __tmp_reg__, R22, R24
__mulqi3:
ldi __temp_reg__,0
__mulqi_1:
sbrc r24,0
add __temp_reg__,r22
lsr r24
lsl r22
cpse r24,__zero_reg__
rjmp __mulqi_1
mov r24, __temp_reg__
ret
)";
+5 -3
View File
@@ -285,13 +285,15 @@ bool optimize(std::vector<mos6502> &instructions, [[maybe_unused]] const Persona
}
}
bool block_optimized = false;
bool optimizer_run = false;
for (auto &block : get_optimizable_blocks(instructions)) {
block_optimized = block_optimized || optimize_redundant_lda_after_sta(block)
const bool block_optimized = optimize_redundant_lda_after_sta(block)
|| optimize_dead_sta(block, personality) || optimize_dead_tax(block)
|| optimize_redundant_ldy(block) || optimize_redundant_lda(block, personality);
optimizer_run = optimizer_run || block_optimized;
}
return block_optimized;
return optimizer_run;
}
#endif// INC_6502_CPP_OPTIMIZER_HPP