6a3afe20a15cd2322913fdad7896d3d7da43fe28
[uebersetzerbau-ss10.git] / asmb / asmb.s
1         .file   "asmb.c"
2         .text
3 .globl asmb
4         .type   asmb, @function
5 asmb:
6 .LFB2:
7         xor %rdx, %rdx
8         xor %ecx, %ecx
9
10         //soll einfach null sein
11         pxor %xmm14, %xmm14
12
13 .nextround:
14         /*init %xmm8 mit "'Z' + 1 + min_t - 'A'" fuer jedes byte
15         * 'Z' + 1 + min_t - 'A' = 90 + 1 - 128 - 65 = -102
16         * 102 = 01100110
17         * ~102 = 10011001
18         * (~102)+1 = 10011010 = 0x9A */
19         mov $0x9a9a9a9a9a9a9a9a, %rax
20         movq %rax, %xmm15
21         movddup %xmm15, %xmm8
22
23         //init %xmm9 mit "'a'-'A'= 97-65 = 32 = 0x20
24         mov $0x2020202020202020, %rax
25         movq %rax, %xmm15
26         movddup %xmm15, %xmm9
27
28         //speicheradresse des pointers zeigt auf 16*8 feld = 128bit
29         movdqu (%rdi, %rdx, 8), %xmm11
30         movdqu (%rdi, %rdx, 8), %xmm12
31
32         /*addiere in %xmm11 "min_t-'A'"
33         * = -128 - 65 = 63 = 0x3f */
34         mov $0x3f3f3f3f3f3f3f3f, %rax
35         movq %rax, %xmm15
36         movddup %xmm15, %xmm10
37
38         //c+min_t-'A'
39         paddb %xmm10, %xmm11
40
41         /*"Packed COMpare Greater Than (Byte)"
42         * X = 'Z' + 1 + min_t - 'A' > c + min_t - 'A' ? 0xff : 0
43         * achtung beim intuitiven lesen des befehles. 'kleiner' 
44         * ist mit 'groesser' vertauscht und vice versa */
45         pcmpgtb %xmm11, %xmm8
46
47         //Y = min(X, 'a' - 'A')
48         pminub %xmm9, %xmm8
49
50         //c += Y
51         paddb %xmm8, %xmm12
52
53         //retuniere an die richtige speicheradresse
54         movapd %xmm12, (%rdi, %rdx, 8)
55
56         //ist ein byte groesser als 0? dann steht 0xff drin
57         pcmpeqb %xmm14, %xmm12
58         //hol die MSBs aller bytes raus
59         pmovmskb %xmm12, %ecx
60         inc %rdx
61         inc %rdx
62         //ist %ecx gleich null? dann die naechsten 16byte bitte
63         jecxz .nextround
64
65         mov %rdi, %rax
66         ret
67 .LFE2:
68         .size   asmb, .-asmb
69         .section        .eh_frame,"a",@progbits
70 .Lframe1:
71         .long   .LECIE1-.LSCIE1
72 .LSCIE1:
73         .long   0x0
74         .byte   0x1
75         .string "zR"
76         .uleb128 0x1
77         .sleb128 -8
78         .byte   0x10
79         .uleb128 0x1
80         .byte   0x3
81         .byte   0xc
82         .uleb128 0x7
83         .uleb128 0x8
84         .byte   0x90
85         .uleb128 0x1
86         .align 8
87 .LECIE1:
88 .LSFDE1:
89         .long   .LEFDE1-.LASFDE1
90 .LASFDE1:
91         .long   .LASFDE1-.Lframe1
92         .long   .LFB2
93         .long   .LFE2-.LFB2
94         .uleb128 0x0
95         .align 8
96 .LEFDE1:
97         .ident  "GCC: (Debian 4.3.2-1.1) 4.3.2"
98         .section        .note.GNU-stack,"",@progbits