asma: ahh.. man kann ja gleich die speicherstelle der konstanten angeben
[uebersetzerbau-ss10.git] / asma / asma.s
index 275e847b0b6f13350f1672289559e3feb91d0973..e8ef5086f2593e41f4b446665e7a80f824d7d9e5 100644 (file)
@@ -1,10 +1,56 @@
        .file   "asma.c"
+
+.section .rodata
+.align 128
+const9a:
+       .rept 16
+       .byte 0x9a
+       .endr
+const20:
+       .rept 16
+       .byte 0x20
+       .endr
+const3f:
+       .rept 16
+       .byte 0x3f
+       .endr
+
        .text
 .globl asma
        .type   asma, @function
 asma:
 .LFB2:
-       movq    %rdi, %rax
+       /*init %xmm8 mit "'Z' + 1 + min_t - 'A'" fuer jedes byte
+       * 'Z' + 1 + min_t - 'A' = 90 + 1 - 128 - 65 = -102
+       * 102 = 01100110
+       * ~102 = 10011001
+       * (~102)+1 = 10011010 = 0x9A */
+       movdqa const9a, %xmm8
+
+       //speicheradresse des pointers zeigt auf 16*8 feld = 128bit
+       movdqu (%rdi), %xmm11
+
+       /*addiere in %xmm11 "min_t-'A'"
+       * = -128 - 65 = 63 = 0x3f
+       * c+min_t-'A' */
+       paddb const3f, %xmm11
+
+       /*"Packed COMpare Greater Than (Byte)"
+       * X = 'Z' + 1 + min_t - 'A' > c + min_t - 'A' ? 0xff : 0
+       * achtung beim intuitiven lesen des befehles. 'kleiner' 
+       * ist mit 'groesser' vertauscht und vice versa */
+       pcmpgtb %xmm11, %xmm8
+
+       /*Y = min(X, 'a' - 'A')
+       * mit "'a'-'A'= 97-65 = 32 = 0x20 */
+       pminub const20, %xmm8
+
+       //retuniere an die richtige speicheradresse
+       mov %rdi, %rax
+       //c += Y
+       paddb (%rax), %xmm8
+       movapd %xmm8, (%rax)
+
        ret
 .LFE2:
        .size   asma, .-asma