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