Skip to content

Commit

Permalink
Merge pull request #154 from shattered/_3eb91b1c
Browse files Browse the repository at this point in the history
8080, z80: swapping args to ADD1 produces smaller code
  • Loading branch information
davidgiven authored Jun 27, 2024
2 parents 04dec33 + 6282594 commit 9965d37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/cowbe/arch8080.cow.ng
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,15 @@ gen STORE4(stk4, DEREF4(hl)) uses all

// --- 8-bit arithmetic -----------------------------------------------------

gen a := ADD1(b|d|h:lhs, a)
gen a := ADD1(a, b|d|h:lhs)
{ E_add($lhs); }

gen a := ADD1(DEREF1(hl), a)
gen a := ADD1(a, DEREF1(hl))
{ R_flush(REG_A); E("\tadd m\n"); }

gen a := ADD1($$, CONSTANT():c)
{ E_adi($c.value as uint8); }

gen a|b|d|h := ADD1($$, CONSTANT(value==-1))
{ E_dcr($$); }

Expand Down
2 changes: 1 addition & 1 deletion src/cowbe/archz80.cow.ng
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ gen STORE4(CONSTANT():c, DEREF4(ADDRESS():a)) uses hl

// --- 8-bit arithmetic -----------------------------------------------------

gen a := ADD1(b|d|h:lhs, a)
gen a := ADD1(a, b|d|h:lhs)
{ E_add(REG_A, $lhs); }

gen a|b|d|h := ADD1($$, CONSTANT(value==-1))
Expand Down

0 comments on commit 9965d37

Please sign in to comment.