Skip to content

Commit

Permalink
Refactored 16 bit division by two into seperate macro #112 (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
stylesuxx authored Jun 19, 2023
1 parent d799538 commit 4901cde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/Modules/Macros.asm
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,9 @@ Divide_By_4 MACRO ih,il,oh,ol
rrc A
mov ol, A
ENDM

Divide_16Bit_By_2 MACRO hi, lo
clr C
rrca hi
rrca lo
ENDM
16 changes: 4 additions & 12 deletions src/Modules/Timing.asm
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ calc_next_comm_div_8_2:
Divide_11Bit_By_8 Temp4, Temp3, Temp5
mov Temp6, #0

clr C ; Divide by 2
rrca Temp2
rrca Temp1
Divide_16Bit_By_2 Temp2, Temp1

sjmp calc_next_comm_average_and_update

Expand All @@ -180,9 +178,7 @@ calc_next_comm_div_8_2_slow:
; Divide Temp4/3 by 8 and store in Temp6/5
Divide_By_8 Temp4, Temp3, Temp6, Temp5

clr C ; Divide by 2
rrca Temp2
rrca Temp1
Divide_16Bit_By_2 Temp2, Temp1

sjmp calc_next_comm_average_and_update

Expand Down Expand Up @@ -549,13 +545,9 @@ setup_zc_scan_timeout:

mov Temp1, Comm_Period4x_L ; Set long timeout when starting
mov Temp2, Comm_Period4x_H
clr C
rrca Temp2
rrca Temp1
Divide_16Bit_By_2 Temp2, Temp1
IF MCU_TYPE == MCU_BB1
clr C
rrca Temp2
rrca Temp1
Divide_16Bit_By_2 Temp2, Temp1
ENDIF
jnb Flag_Startup_Phase, setup_zc_scan_timeout_startup_done

Expand Down

0 comments on commit 4901cde

Please sign in to comment.