Initialise register with a constant value before SGIO loop.

Previously this register was reloaded with the same value during each loop.
Initialising it once, outside the loop, saves two cycles.

Note the separation of the loop start ("loop") from the entry point ("main").
Code between these labels will be run once, at startup.
This commit is contained in:
Martin Ling
2021-12-20 12:25:41 +00:00
parent f61a03dead
commit c6362381d1

View File

@ -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: 159 cycles RX: 157 cycles
TX: 144 cycles TX: 142 cycles
Design Design
====== ======
@ -128,6 +128,9 @@ buf_ptr .req r6
.global main .global main
.thumb_func .thumb_func
main: // Cycle counts: main: // Cycle counts:
// Grab the base address of the SGPIO shadow registers...
ldr sgpio_data, =SGPIO_SHADOW_REGISTERS_BASE // 2
loop:
// The worst case timing is assumed to occur when reading the interrupt // The worst case timing is assumed to occur when reading the interrupt
// status register *just* misses the flag being set - so we include the // status register *just* misses the flag being set - so we include the
// cycles required to check it a second time. // cycles required to check it a second time.
@ -151,16 +154,13 @@ main:
lsr r0, #1 // 1, twice lsr r0, #1 // 1, twice
// ... and if not, jump back to the beginning. // ... and if not, jump back to the beginning.
bcc main // 3, then 1 bcc loop // 3, then 1
// Clear the interrupt pending bits for the SGPIO slices we're working with. // Clear the interrupt pending bits for the SGPIO slices we're working with.
ldr r0, =SGPIO_EXCHANGE_INTERRUPT_CLEAR_REG // 2 ldr r0, =SGPIO_EXCHANGE_INTERRUPT_CLEAR_REG // 2
ldr r1, =0xffff // 2 ldr r1, =0xffff // 2
str r1, [r0] // 8 str r1, [r0] // 8
// Grab the base address of the SGPIO shadow registers...
ldr sgpio_data, =SGPIO_SHADOW_REGISTERS_BASE // 2
// ... 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.
ldr r0, =TARGET_DATA_BUFFER // r0 = &buffer // 2 ldr r0, =TARGET_DATA_BUFFER // r0 = &buffer // 2
ldr r3, =TARGET_BUFFER_POSITION // r3 = &position_in_buffer // 2 ldr r3, =TARGET_BUFFER_POSITION // r3 = &position_in_buffer // 2
@ -217,4 +217,4 @@ done:
mov r1, r8 // 1 mov r1, r8 // 1
str r0, [r1] // pos_in_buffer = (pos_in_buffer + size_copied) % buffer_size // 2 str r0, [r1] // pos_in_buffer = (pos_in_buffer + size_copied) % buffer_size // 2
b main // 3 b loop // 3