Use faster way to calculate buffer pointer.
One of the few instructions that can use the high registers (r8-r14) is the add instruction, which can add any two registers, as long as one of them is also used as the destination register. By using this form of add , we can add buf_base (in a high register) to the offset within the buffer (in a low register), to get the desired pointer value (buf_ptr) which we want to access. This saves one cycle by eliminating the need to move buf_base to a low register first.
This commit is contained in:
@ -66,8 +66,8 @@ shadow registers.
|
|||||||
|
|
||||||
There are two key code paths, with the following worst-case timings:
|
There are two key code paths, with the following worst-case timings:
|
||||||
|
|
||||||
RX: 141 cycles
|
RX: 140 cycles
|
||||||
TX: 126 cycles
|
TX: 125 cycles
|
||||||
|
|
||||||
Design
|
Design
|
||||||
======
|
======
|
||||||
@ -178,9 +178,8 @@ loop:
|
|||||||
str r0, [sgpio_int, #INT_CLEAR] // 8
|
str r0, [sgpio_int, #INT_CLEAR] // 8
|
||||||
|
|
||||||
// ... and grab the address of the buffer segment we want to write to / read from.
|
// ... and grab the address of the buffer segment we want to write to / read from.
|
||||||
mov r0, buf_base // r0 = &buffer // 1
|
ldr buf_ptr, [state, #OFFSET] // buf_ptr = position_in_buffer // 2
|
||||||
ldr r2, [state, #OFFSET] // r2 = position_in_buffer // 2
|
add buf_ptr, buf_base // buf_ptr = &buffer + position_in_buffer // 1
|
||||||
add buf_ptr, r0, r2 // buf_ptr = &buffer + position_in_buffer // 1
|
|
||||||
|
|
||||||
// Load direction (TX or RX)
|
// Load direction (TX or RX)
|
||||||
ldr r0, [state, #TX] // 2
|
ldr r0, [state, #TX] // 2
|
||||||
|
Reference in New Issue
Block a user