arm64: codea/abgabe_aa.0
[uebersetzerbau-ss10.git] / asma / asma.s
1         .data
2         .align 16
3 const65:
4         .rept 16
5         .byte 0x65
6         .endr
7 const20:
8         .rept 16
9         .byte 0x20
10         .endr
11 constc0:
12         .rept 16
13         .byte 0xc0
14         .endr
15
16         .text
17 .globl asma
18 asma:
19         // folgendes kann umgeformt werden (max_t = 127)
20         // X = 'Z' + 1 + min_t - 'A' > c + min_t - 'A' ? 0xff : 0
21         // X =      -c + max_t + 'A' > - 'Z' -1 + max_t + 'A' ? 0xff : 0
22         // X =         -c + 127 + 65 > - 90 - 1 + 127 + 65 ? 0xff : 0
23         // X =               -c - 64 > 101 ? 0xff : 0
24         // X =               -64 - c > 101 ? 0xff : 0
25         // ...
26         // 101 = 0x65
27         // -64 = 0xc0
28
29         // speicheradresse des pointers zeigt auf 16*8 feld = 128bit
30         movdqu (%rdi), %xmm11
31
32         // -64 - c
33         movdqa constc0, %xmm9
34         psubb %xmm11, %xmm9
35
36         // "Packed COMpare Greater Than (Byte)"
37         // achtung beim intuitiven lesen des befehles. 'kleiner'
38         // ist mit 'groesser' vertauscht und vice versa
39         pcmpgtb const65, %xmm9
40
41         // Y = min(X, 'a' - 'A')
42         // mit 'a'-'A'= 97-65 = 32 = 0x20
43         pand const20, %xmm9
44
45         // c += Y
46         paddb %xmm9, %xmm11
47
48         // retuniere an die richtige speicheradresse
49         mov %rdi, %rax
50         movdqu %xmm11, (%rax)
51
52         ret