asmb: ueblen hax auskommentieren...
[uebersetzerbau-ss10.git] / asma / asma.s
index 275e847b0b6f13350f1672289559e3feb91d0973..cb1e8bcf36317fda065159f731e50d9f0ef17882 100644 (file)
@@ -1,10 +1,58 @@
        .file   "asma.c"
+
+       .data
+       .align 16
+const65:
+       .rept 16
+       .byte 0x65
+       .endr
+const20:
+       .rept 16
+       .byte 0x20
+       .endr
+constc0:
+       .rept 16
+       .byte 0xc0
+       .endr
+
        .text
 .globl asma
        .type   asma, @function
 asma:
 .LFB2:
-       movq    %rdi, %rax
+       // folgendes kann umgeformt werden (max_t = 127)
+       // X = 'Z' + 1 + min_t - 'A' > c + min_t - 'A' ? 0xff : 0
+       // X =      -c + max_t + 'A' > - 'Z' -1 + max_t + 'A' ? 0xff : 0
+       // X =         -c + 127 + 65 > - 90 - 1 + 127 + 65 ? 0xff : 0
+       // X =               -c - 64 > 101 ? 0xff : 0
+       // X =               -64 - c > 101 ? 0xff : 0
+       // ...
+       // 101 = 0x65
+       // -64 = 0xc0
+
+       // speicheradresse des pointers zeigt auf 16*8 feld = 128bit
+       movdqu (%rdi), %xmm11
+
+       // -64 - c
+       movdqa constc0, %xmm9
+       psubb %xmm11, %xmm9
+
+       // "Packed COMpare Greater Than (Byte)"
+       // achtung beim intuitiven lesen des befehles. 'kleiner'
+       // ist mit 'groesser' vertauscht und vice versa
+       pcmpgtb const65, %xmm9
+
+       // Y = min(X, 'a' - 'A')
+       // mit 'a'-'A'= 97-65 = 32 = 0x20
+       pminub const20, %xmm9
+
+       // c += Y
+       paddb %xmm9, %xmm11
+
+       // retuniere an die richtige speicheradresse
+       mov %rdi, %rax
+       movdqu %xmm11, (%rax)
+
        ret
 .LFE2:
        .size   asma, .-asma