GAS LISTING /tmp/cc0f9pg4.s page 1
1 .file "ll.c"
9 .Ltext0:
10 .comm m,24,16
11 .globl add
13 add:
14 .LFB0:
15 .file 1 "ll.c"
0:ll.c **** #include <stdio.h>
1:ll.c **** #include <stdlib.h>
2:ll.c ****
3:ll.c **** struct e {
4:ll.c **** struct e *next;
5:ll.c **** struct e *prev;
6:ll.c **** int count;
7:ll.c **** } m;
8:ll.c ****
9:ll.c **** // in this case we add b.
10:ll.c **** void add(struct e *x, struct e *y) {
16 .loc 1 11 0
17 .cfi_startproc
18 0000 55 pushq %rbp
19 .cfi_def_cfa_offset 16
20 0001 4889E5 movq %rsp, %rbp
21 .cfi_offset 6, -16
22 .cfi_def_cfa_register 6
23 0004 48897DF8 movq %rdi, -8(%rbp)
24 0008 488975F0 movq %rsi, -16(%rbp)
11:ll.c ****
12:ll.c **** x->next->prev = y;
25 .loc 1 13 0
26 000c 488B45F8 movq -8(%rbp), %rax
27 0010 488B00 movq (%rax), %rax
28 0013 488B55F0 movq -16(%rbp), %rdx
29 0017 48895008 movq %rdx, 8(%rax)
13:ll.c **** y->prev = x;
30 .loc 1 14 0
31 001b 488B45F0 movq -16(%rbp), %rax
32 001f 488B55F8 movq -8(%rbp), %rdx
33 0023 48895008 movq %rdx, 8(%rax)
14:ll.c **** y->next = x->next;
34 .loc 1 15 0
35 0027 488B45F8 movq -8(%rbp), %rax
36 002b 488B10 movq (%rax), %rdx
37 002e 488B45F0 movq -16(%rbp), %rax
38 0032 488910 movq %rdx, (%rax)
15:ll.c **** x->next = y;
39 .loc 1 16 0
40 0035 488B45F8 movq -8(%rbp), %rax
41 0039 488B55F0 movq -16(%rbp), %rdx
42 003d 488910 movq %rdx, (%rax)
16:ll.c ****
17:ll.c **** }
43 .loc 1 18 0
44 0040 C9 leave
45 .cfi_def_cfa 7, 8
46 0041 C3 ret
47 .cfi_endproc
GAS LISTING /tmp/cc0f9pg4.s page 2
48 .LFE0:
50 .globl delete
52 delete:
53 .LFB1:
18:ll.c ****
19:ll.c ****
20:ll.c **** // in this case we get b.
21:ll.c **** void delete (struct e *x) {
54 .loc 1 22 0
55 .cfi_startproc
56 0042 55 pushq %rbp
57 .cfi_def_cfa_offset 16
58 0043 4889E5 movq %rsp, %rbp
59 .cfi_offset 6, -16
60 .cfi_def_cfa_register 6
61 0046 4883EC10 subq $16, %rsp
62 004a 48897DF8 movq %rdi, -8(%rbp)
22:ll.c ****
23:ll.c **** x->prev->next = x->next;
63 .loc 1 24 0
64 004e 488B45F8 movq -8(%rbp), %rax
65 0052 488B4008 movq 8(%rax), %rax
66 0056 488B55F8 movq -8(%rbp), %rdx
67 005a 488B12 movq (%rdx), %rdx
68 005d 488910 movq %rdx, (%rax)
24:ll.c **** x->next->prev = x->prev;
69 .loc 1 25 0
70 0060 488B45F8 movq -8(%rbp), %rax
71 0064 488B00 movq (%rax), %rax
72 0067 488B55F8 movq -8(%rbp), %rdx
73 006b 488B5208 movq 8(%rdx), %rdx
74 006f 48895008 movq %rdx, 8(%rax)
25:ll.c **** free(x);
75 .loc 1 26 0
76 0073 488B45F8 movq -8(%rbp), %rax
77 0077 4889C7 movq %rax, %rdi
78 007a E8000000 call free
78 00
26:ll.c **** }
79 .loc 1 27 0
80 007f C9 leave
81 .cfi_def_cfa 7, 8
82 0080 C3 ret
83 .cfi_endproc
84 .LFE1:
86 .section .rodata
87 .LC0:
88 0000 25642000 .string "%d "
89 .text
90 .globl show
92 show:
93 .LFB2:
27:ll.c ****
28:ll.c **** // show the list at the current point in time.
29:ll.c **** void show( struct e *head ) {
94 .loc 1 30 0
95 .cfi_startproc
GAS LISTING /tmp/cc0f9pg4.s page 3
96 0081 55 pushq %rbp
97 .cfi_def_cfa_offset 16
98 0082 4889E5 movq %rsp, %rbp
99 .cfi_offset 6, -16
100 .cfi_def_cfa_register 6
101 0085 4883EC20 subq $32, %rsp
102 0089 48897DE8 movq %rdi, -24(%rbp)
30:ll.c ****
31:ll.c **** struct e *tmp;
32:ll.c **** tmp = head;
103 .loc 1 33 0
104 008d 488B45E8 movq -24(%rbp), %rax
105 0091 488945F8 movq %rax, -8(%rbp)
106 .L6:
33:ll.c ****
34:ll.c **** do {
35:ll.c **** printf("%d " , tmp->count) ;
107 .loc 1 36 0
108 0095 488B45F8 movq -8(%rbp), %rax
109 0099 8B5010 movl 16(%rax), %edx
110 009c B8000000 movl $.LC0, %eax
110 00
111 00a1 89D6 movl %edx, %esi
112 00a3 4889C7 movq %rax, %rdi
113 00a6 B8000000 movl $0, %eax
113 00
114 00ab E8000000 call printf
114 00
36:ll.c **** tmp = tmp->next;
115 .loc 1 37 0
116 00b0 488B45F8 movq -8(%rbp), %rax
117 00b4 488B00 movq (%rax), %rax
118 00b7 488945F8 movq %rax, -8(%rbp)
37:ll.c **** } while(tmp != NULL) ;
119 .loc 1 38 0
120 00bb 48837DF8 cmpq $0, -8(%rbp)
120 00
121 00c0 75D3 jne .L6
38:ll.c ****
39:ll.c **** printf("\n");
122 .loc 1 40 0
123 00c2 BF0A0000 movl $10, %edi
123 00
124 00c7 E8000000 call putchar
124 00
40:ll.c ****
41:ll.c **** }
125 .loc 1 42 0
126 00cc C9 leave
127 .cfi_def_cfa 7, 8
128 00cd C3 ret
129 .cfi_endproc
130 .LFE2:
132 .globl main
134 main:
135 .LFB3:
42:ll.c ****
GAS LISTING /tmp/cc0f9pg4.s page 4
43:ll.c **** int main(void) {
136 .loc 1 44 0
137 .cfi_startproc
138 00ce 55 pushq %rbp
139 .cfi_def_cfa_offset 16
140 00cf 4889E5 movq %rsp, %rbp
141 .cfi_offset 6, -16
142 .cfi_def_cfa_register 6
143 00d2 4883EC20 subq $32, %rsp
44:ll.c ****
45:ll.c ****
46:ll.c **** struct e *a;
47:ll.c **** struct e *b;
48:ll.c **** struct e *c;
49:ll.c ****
50:ll.c **** a = (struct e *) malloc(sizeof(struct e));
144 .loc 1 51 0
145 00d6 BF180000 movl $24, %edi
145 00
146 00db E8000000 call malloc
146 00
147 00e0 488945E8 movq %rax, -24(%rbp)
51:ll.c **** b = (struct e *) malloc(sizeof(struct e));
148 .loc 1 52 0
149 00e4 BF180000 movl $24, %edi
149 00
150 00e9 E8000000 call malloc
150 00
151 00ee 488945F0 movq %rax, -16(%rbp)
52:ll.c **** c = (struct e *) malloc(sizeof(struct e));
152 .loc 1 53 0
153 00f2 BF180000 movl $24, %edi
153 00
154 00f7 E8000000 call malloc
154 00
155 00fc 488945F8 movq %rax, -8(%rbp)
53:ll.c ****
54:ll.c **** a->count = 1;
156 .loc 1 55 0
157 0100 488B45E8 movq -24(%rbp), %rax
158 0104 C7401001 movl $1, 16(%rax)
158 000000
55:ll.c **** b->count = 2;
159 .loc 1 56 0
160 010b 488B45F0 movq -16(%rbp), %rax
161 010f C7401002 movl $2, 16(%rax)
161 000000
56:ll.c **** c->count = 3;
162 .loc 1 57 0
163 0116 488B45F8 movq -8(%rbp), %rax
164 011a C7401003 movl $3, 16(%rax)
164 000000
57:ll.c ****
58:ll.c **** a->prev = NULL;
165 .loc 1 59 0
166 0121 488B45E8 movq -24(%rbp), %rax
167 0125 48C74008 movq $0, 8(%rax)
GAS LISTING /tmp/cc0f9pg4.s page 5
167 00000000
59:ll.c **** a->next = c;
168 .loc 1 60 0
169 012d 488B45E8 movq -24(%rbp), %rax
170 0131 488B55F8 movq -8(%rbp), %rdx
171 0135 488910 movq %rdx, (%rax)
60:ll.c **** c->prev = a;
172 .loc 1 61 0
173 0138 488B45F8 movq -8(%rbp), %rax
174 013c 488B55E8 movq -24(%rbp), %rdx
175 0140 48895008 movq %rdx, 8(%rax)
61:ll.c ****
62:ll.c **** show(a);
176 .loc 1 63 0
177 0144 488B45E8 movq -24(%rbp), %rax
178 0148 4889C7 movq %rax, %rdi
179 014b E8000000 call show
179 00
63:ll.c **** // add b after a
64:ll.c **** add(a,b);
180 .loc 1 65 0
181 0150 488B55F0 movq -16(%rbp), %rdx
182 0154 488B45E8 movq -24(%rbp), %rax
183 0158 4889D6 movq %rdx, %rsi
184 015b 4889C7 movq %rax, %rdi
185 015e E8000000 call add
185 00
65:ll.c ****
66:ll.c **** show(a);
186 .loc 1 67 0
187 0163 488B45E8 movq -24(%rbp), %rax
188 0167 4889C7 movq %rax, %rdi
189 016a E8000000 call show
189 00
67:ll.c ****
68:ll.c **** // delete b
69:ll.c **** delete(b);
190 .loc 1 70 0
191 016f 488B45F0 movq -16(%rbp), %rax
192 0173 4889C7 movq %rax, %rdi
193 0176 E8000000 call delete
193 00
70:ll.c ****
71:ll.c **** show(a);
194 .loc 1 72 0
195 017b 488B45E8 movq -24(%rbp), %rax
196 017f 4889C7 movq %rax, %rdi
197 0182 E8000000 call show
197 00
72:ll.c ****
73:ll.c ****
74:ll.c ****
75:ll.c **** }
198 .loc 1 76 0
199 0187 C9 leave
200 .cfi_def_cfa 7, 8
201 0188 C3 ret
GAS LISTING /tmp/cc0f9pg4.s page 6
202 .cfi_endproc
203 .LFE3:
205 .Letext0:
GAS LISTING /tmp/cc0f9pg4.s page 7
DEFINED SYMBOLS
*ABS*:0000000000000000 ll.c
*COM*:0000000000000018 m
/tmp/cc0f9pg4.s:13 .text:0000000000000000 add
/tmp/cc0f9pg4.s:52 .text:0000000000000042 delete
/tmp/cc0f9pg4.s:92 .text:0000000000000081 show
/tmp/cc0f9pg4.s:134 .text:00000000000000ce main
UNDEFINED SYMBOLS
free
printf
putchar
malloc