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