From 9206a8b7526d75f91dc06dfcb6fab3dbcbc8c6b3 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Mon, 20 Dec 2021 12:21:06 +0000 Subject: [PATCH] Free up two registers by accessing SGPIO in two 16-byte chunks. The current code does reads and writes in two chunks: one of 6 words, followed by one of 2. Instead, use two chunks of 4 words each. This takes the same number of total cycles, but frees up two registers for other uses. Note that we can't do things in one chunk, because we'd need eight registers to hold the data, plus a ninth to hold the buffer pointer. The ldm/stm instructions can only use the eight low registers, r0-r7. So we have to use two chunks, and the most register-efficient way to do that is to use two equal chunks. --- firmware/hackrf_usb/sgpio_m0.s | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/firmware/hackrf_usb/sgpio_m0.s b/firmware/hackrf_usb/sgpio_m0.s index 713b1092..f062739d 100644 --- a/firmware/hackrf_usb/sgpio_m0.s +++ b/firmware/hackrf_usb/sgpio_m0.s @@ -179,17 +179,17 @@ loop: direction_tx: - ldm buf_ptr!, {r0-r5} // 7 + ldm buf_ptr!, {r0-r3} // 5 str r0, [sgpio_data, #SLICE0] // 8 str r1, [sgpio_data, #SLICE1] // 8 str r2, [sgpio_data, #SLICE2] // 8 str r3, [sgpio_data, #SLICE3] // 8 - str r4, [sgpio_data, #SLICE4] // 8 - str r5, [sgpio_data, #SLICE5] // 8 - ldm buf_ptr!, {r0-r1} // 3 - str r0, [sgpio_data, #SLICE6] // 8 - str r1, [sgpio_data, #SLICE7] // 8 + ldm buf_ptr!, {r0-r3} // 5 + str r0, [sgpio_data, #SLICE4] // 8 + str r1, [sgpio_data, #SLICE5] // 8 + str r2, [sgpio_data, #SLICE6] // 8 + str r3, [sgpio_data, #SLICE7] // 8 b done // 3 @@ -199,13 +199,13 @@ direction_rx: ldr r1, [sgpio_data, #SLICE1] // 10 ldr r2, [sgpio_data, #SLICE2] // 10 ldr r3, [sgpio_data, #SLICE3] // 10 - ldr r4, [sgpio_data, #SLICE4] // 10 - ldr r5, [sgpio_data, #SLICE5] // 10 - stm buf_ptr!, {r0-r5} // 7 + stm buf_ptr!, {r0-r3} // 5 - ldr r0, [sgpio_data, #SLICE6] // 10 - ldr r1, [sgpio_data, #SLICE7] // 10 - stm buf_ptr!, {r0-r1} // 3 + ldr r0, [sgpio_data, #SLICE4] // 10 + ldr r1, [sgpio_data, #SLICE5] // 10 + ldr r2, [sgpio_data, #SLICE6] // 10 + ldr r3, [sgpio_data, #SLICE7] // 10 + stm buf_ptr!, {r0-r3} // 5 done: