Library: Add fixed ashlsi3 code to the C library
authorAlan Cox <alan@linux.intel.com>
Sat, 6 Jun 2015 13:56:05 +0000 (14:56 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 6 Jun 2015 13:56:05 +0000 (14:56 +0100)
Library/libs/Makefile.6809
Library/libs/ashlsi3_6809.s [new file with mode: 0644]

index 7c96c22..6f3ab52 100644 (file)
@@ -4,12 +4,12 @@ AR = m6809-unknown-ar
 PLATFORM = 6809
 export PLATFORM
 CC_OPT = -c -Os -I../include -I../include/6502
-# for stuff that gives sdcc nightmares
+# for stuff that gives gcc nightmares
 CC_NOOPT = $(CC_OPT)
 ASM_OPT = -o
 SRC_CRT0 = crt0_$(PLATFORM).s
 OBJ_CRT0 = $(SRC_CRT0:.s=.o)
-SRC_ASM = setjmp_6809.s
+SRC_ASM = setjmp_6809.s ashlsi3_6809.s
 OBJ_ASM = $(SRC_ASM:.s=.o)
 SRC_C =  __argv.c abort.c asctime.c assert.c atexit.c
 SRC_C += bcmp.c bcopy.c bsearch.c bzero.c calloc.c cfree.c clock.c closedir.c
diff --git a/Library/libs/ashlsi3_6809.s b/Library/libs/ashlsi3_6809.s
new file mode 100644 (file)
index 0000000..86dd0e0
--- /dev/null
@@ -0,0 +1,47 @@
+       .globl  ___ashlsi3
+
+       .area .text
+
+___ashlsi3:
+       pshs    u
+
+       ; FIXME temporary hack until we fix gcc-6809 or our use of it
+       ; the argument passing doesn't match so we'll mangle it
+       ldu 4,s
+       stu ,x
+       ldu 6,s
+       stu 2,x
+       ldb 9,s
+
+       cmpb    #16
+       blt     try8
+       subb    #16
+       ; Shift by 16
+       ldu     2,x
+       stu     ,x
+       ldu     #0
+       stu     2,x
+try8:
+       cmpb    #8
+       blt     try_rest
+       subb    #8
+       ; Shift by 8
+       ldu     1,x
+       stu     ,x
+       lda     3,x
+       sta     2,x
+       clr     3,x
+
+try_rest:
+       tstb
+       beq     done
+do_rest:
+       ; Shift by 1
+       asl     3,x
+       rol     2,x
+       rol     1,x
+       rol     ,x
+       decb
+       bne     do_rest
+done:
+       puls    u,pc