cleaner asm
authorDavid Odin <david@forma3dev.fr>
Tue, 20 Jun 2017 23:13:16 +0000 (01:13 +0200)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:05 +0000 (17:03 +0100)
Makefile
extdrv/ssd130x_oled_buffer.c
extdrv/ssd130x_oled_buffer_s.s [new file with mode: 0644]
include/extdrv/ssd130x_oled_buffer.h

index 3f7ef78..9d2ec29 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ ARCH = armv6-m
 
 CROSS_COMPILE ?= arm-none-eabi-
 CC = $(CROSS_COMPILE)gcc
-#DEBUG = -g
+# DEBUG = -ggdb3
 LD_DEBUG = $(DEBUG)
 #LD_DEBUG = $(DEBUG) -Wl,--print-memory-usage
 #LD_DEBUG = $(DEBUG) -Wl,--print-gc-sections -Wl,--print-output-format \
@@ -34,10 +34,16 @@ INCLUDES = include/
 TARGET_INCLUDES = $(TARGET_DIR)/
 OBJDIR = objs
 
-SRC = $(wildcard */*.c)
-SRC += $(wildcard lib/*/*.c)
-SRC += $(wildcard lib/protocols/*/*.c)
-OBJS = ${SRC:%.c=${OBJDIR}/%.o}
+C_SRC = $(wildcard */*.c)
+C_SRC += $(wildcard lib/*/*.c)
+C_SRC += $(wildcard lib/protocols/*/*.c)
+
+A_SRC = $(wildcard */*.s)
+A_SRC += $(wildcard lib/*/*.s)
+A_SRC += $(wildcard lib/protocols/*/*.s)
+
+
+OBJS = ${C_SRC:%.c=${OBJDIR}/%.o} ${A_SRC:%.s=${OBJDIR}/%.o}
 DEPS = ${OBJS:%.o=$(OBJDIR)/%.d}
 
 NAME_SRC = $(wildcard $(TARGET_DIR)/*.c)
index 89018b6..6c048c2 100644 (file)
@@ -56,7 +56,7 @@ int ssd130x_buffer_set_tile(uint8_t* gddram, uint8_t x0, uint8_t y0, uint8_t* ti
 }
 
 /* Simple RLE decompressor */
-void uncompress_image(uint8_t *compressed_data,
+void uncompress_image(const uint8_t *compressed_data,
                       uint8_t *buffer)
 {
        int i;
@@ -79,8 +79,8 @@ void uncompress_image(uint8_t *compressed_data,
 }
 
 /* Simple RLE decompressor, asm implementation, experimental */
-void uncompress_image_asm(uint8_t *compressed_data,
-                          uint8_t *buffer)
+void uncompress_image_asm_old(const uint8_t *compressed_data,
+                              uint8_t *buffer)
 {
   // note: r0 is compressed_data/in, r1 is buffer
   // r2 is end_buffer
diff --git a/extdrv/ssd130x_oled_buffer_s.s b/extdrv/ssd130x_oled_buffer_s.s
new file mode 100644 (file)
index 0000000..91f0805
--- /dev/null
@@ -0,0 +1,58 @@
+@   extdrv/ssd130x_oled_buffer.c
+@
+@ Set of functions helping using the 128x64 buffer for the SSD130X
+@
+@ Copyright 2017 Nathael Pajani <nathael.pajani@ed3l.fr>
+@
+@
+@ This program is free software: you can redistribute it and/or modify
+@ it under the terms of the GNU General Public License as published by
+@ the Free Software Foundation, either version 2 of the License, or
+@ (at your option) any later version.
+@
+@ This program is distributed in the hope that it will be useful,
+@ but WITHOUT ANY WARRANTY; without even the implied warranty of
+@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+@ GNU General Public License for more details.
+@
+@ You should have received a copy of the GNU General Public License
+@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+.syntax unified
+.cpu cortex-m0
+.thumb
+
+@ exported symbol:
+.global uncompress_image_asm
+
+/* Simple RLE decompressor, asm implementation, experimental */
+.thumb_func
+uncompress_image_asm:
+ push    {r4,r5,r14}  @
+ movs    r2, 128      @
+ lsls    r2, 3        @
+ adds    r2, r2, r1   @
+.label1:
+ ldrb    r3, [r0]     @
+ adds    r0, 1        @
+ sxtb    r3, r3       @
+ cmp     r3, 0        @
+ bpl     .set
+ rsbs    r3, r3, 0    @ negs...
+ movs    r5, 1        @
+ b       .copy2
+.set:
+ adds    r3, 3        @
+ movs    r5, 0        @
+.copy2:
+ ldrb    r4, [r0]     @
+ strb    r4, [r1]     @
+ adds    r0, r5       @
+ adds    r1, 1        @
+ subs    r3, 1        @
+ bne     .copy2
+ subs    r0, r0, r5   @
+ adds    r0, r0, 1    @
+ cmp     r1, r2       @
+ bne     .label1
+ pop     {r4,r5,r15}  @ restaure r4 & r5
index 2241d8a..d3b9f49 100644 (file)
@@ -34,9 +34,11 @@ int ssd130x_buffer_set_pixel(uint8_t* gddram, uint8_t x0, uint8_t y0, uint8_t st
 int ssd130x_buffer_set_tile(uint8_t* gddram, uint8_t x0, uint8_t y0, uint8_t* tile);
 
 /* Simple RLE decompressor (two implementations, wip) */
-void uncompress_image(uint8_t* compressed_data,
+void uncompress_image(const uint8_t* compressed_data,
                       uint8_t* buffer);
-void uncompress_image_asm(uint8_t* compressed_data,
+void uncompress_image_asm(const uint8_t* compressed_data,
+                          uint8_t* buffer);
+void uncompress_image_asm_old(const uint8_t* compressed_data,
                           uint8_t* buffer);
 
 #endif