asm{a,b}: spass
[uebersetzerbau-ss10.git] / asmb / asmb.s
1         .file   "asmb.c"
2         .data
3         .align 16
4 const65:
5         .rept 16
6         .byte 0x65
7         .endr
8 const20:
9         .rept 16
10         .byte 0x20
11         .endr
12 constc0:
13         .rept 16
14         .byte 0xc0
15         .endr
16
17         .text
18 .globl asmb
19         .type   asmb, @function
20 asmb:
21 .LFB2:
22         xor %rdx, %rdx
23
24         //soll einfach null sein
25         pxor %xmm14, %xmm14
26
27 .nextround:
28         //speicheradresse des pointers zeigt auf 16*8 feld = 128bit
29         movdqu (%rdi, %rdx, 8), %xmm11
30
31         // -64 - c
32         movdqa constc0, %xmm9
33         psubb %xmm11, %xmm9
34
35         // Packed COMpare Greater Than (Byte)"
36         // achtung beim intuitiven lesen des befehles. 'kleiner'
37         // ist mit 'groesser' vertauscht und vice versa
38         pcmpgtb const65, %xmm9
39
40 .differenz:
41         // Y = min(X, 'a' - 'A')
42         pand const20, %xmm9
43
44         // c += Y
45         paddb %xmm9, %xmm11
46
47         // retuniere an die richtige speicheradresse
48         movdqu %xmm11, (%rdi, %rdx, 8)
49
50         //entspricht ein byte dem nullbyte dann steht an jener stelle 0xff sonst 0x00
51         pcmpeqb %xmm14, %xmm11
52         //hol die MSBs aller bytes raus
53         pmovmskb %xmm11, %ecx
54         add $2, %rdx
55
56         //ist %ecx gleich null? dann die naechsten 16byte bitte
57         jecxz .nextround
58
59         //speicheradresse des parameters zurueckgeben (wird noch modifziert)
60         mov %rdi, %rax
61
62 /*
63         //===============
64         //ab hier uebler hax um nach \0 trotzdem die gleichen bytes wie
65         //input zu haben, also um selbiges verhalten wie asmb_ref zu erzwingen
66
67         //\0 byte stelle durch rausfinden des MSB des %ecx
68         bsf %ecx, %r11d
69
70         //das ergebnis zweimal abspeichern
71         mov %r11d, %ecx
72
73         //hint: in %xmm9 ist differenz gespeichert (vgl .differenz)
74
75         //leider shiften nur mit immediate! :(
76         btr $3, %r11d
77         jnc .rechtsshift1
78         psrldq $8, %xmm9
79
80 .rechtsshift1:
81         btr $2, %r11d
82         jnc .rechtsshift2
83         psrldq $4, %xmm9
84
85 .rechtsshift2:
86         btr $1, %r11d
87         jnc .rechtsshift3
88         psrldq $2, %xmm9
89
90 .rechtsshift3:
91         btr $0, %r11d
92         jnc .linksshift
93         psrldq $1, %xmm9
94 #==================
95 .linksshift:
96         btr $3, %ecx
97         jnc .linksshift1
98         pslldq $8, %xmm9
99
100 .linksshift1:
101         btr $2, %ecx
102         jnc .linksshift2
103         pslldq $4, %xmm9
104
105 .linksshift2:
106         btr $1, %ecx
107         jnc .linksshift3
108         pslldq $2, %xmm9
109
110 .linksshift3:
111         btr $0, %ecx
112         jnc .endshift
113         pslldq $1, %xmm9
114
115 .endshift:
116         //betreffende speicherstelle in %xmm11 laden
117         movdqu -16(%rax, %rdx, 8), %xmm11
118         //und overhead wieder subtrahieren
119         psubb %xmm9, %xmm11
120
121         //ergebnis zurueckspielen und fertig \o/
122         movdqu %xmm11, -16(%rax, %rdx, 8)
123 */
124
125         ret
126 .LFE2:
127         .size   asmb, .-asmb
128         .section        .eh_frame,"a",@progbits
129 .Lframe1:
130         .long   .LECIE1-.LSCIE1
131 .LSCIE1:
132         .long   0x0
133         .byte   0x1
134         .string "zR"
135         .uleb128 0x1
136         .sleb128 -8
137         .byte   0x10
138         .uleb128 0x1
139         .byte   0x3
140         .byte   0xc
141         .uleb128 0x7
142         .uleb128 0x8
143         .byte   0x90
144         .uleb128 0x1
145         .align 8
146 .LECIE1:
147 .LSFDE1:
148         .long   .LEFDE1-.LASFDE1
149 .LASFDE1:
150         .long   .LASFDE1-.Lframe1
151         .long   .LFB2
152         .long   .LFE2-.LFB2
153         .uleb128 0x0
154         .align 8
155 .LEFDE1:
156         .ident  "GCC: (Debian 4.3.2-1.1) 4.3.2"
157         .section        .note.GNU-stack,"",@progbits