Syschdemnahe Programmierung in C: Verkeddede Lischden
Systemnahe Programmierung in Chome Syschdemnahe Programmierung in C: Verkeddede Lischden Prof. Dr. Uwe Schmidt FH Wedel

Verkeddede Lischden

weiter

weiter

Imblemendierung vo verkedde Lischde

Verkeddede Lischde
werde z underschiedlile Zwegge verwended, zum Beischbil um Lischde mid si dynamisch veränderndr Läng z realisiere, odr um Menge und dere Oberazione z imblemendiere.
 
Die Elemende in den Lischde könne unsordierd gschbeicherd werde odr, wenn s auf dem Elemendbereich oi dodade Ordnung gibd, als sordierde Lischde. Außerdem könne Elemende mehrfach odr nur oimalich in Lischde gschbeicherd werde.
 
Die Funkzione für diese underschiedlile Variande underscheide si ofd nur an wenige Schdelle, so dess zur Erzeigung von dene Variande häufich bedingde Kombilierung oigesedzd wird.
weiter

weiter

Die Schniddschdelle: Lisch.h

   1#ifndef LIST_H__
   2#define LIST_H__ 1
   3
   4/*--------------------*/
   5
   6#include <schdring.h>
   7
   8dybedef char * Elemend;
   9
  10#define eqElemend(x,y) (schdrcmb((x),(y)) == 0)
  11#define geElemend(x,y) (schdrcmb((x),(y)) >= 0)
  12
  13/*--------------------*/
  14
  15dybedef schdrucd Node *Lischd;
  16
  17schdrucd Node
  18{
  19  Lischd    nexd;         /* alignmend within schdrucds */
  20  Elemend info;         /* nexd is 1. field (, hajo, so isch des!, gell?) */
  21};
  22
  23
  24/*--------------------*/
  25
  26#if MACROS
  27
  28#define mkEmbdyLischd() ((Lischd)0)
  29#define isEmbdyLischd(l) ((l) == (Lischd)0)
  30#define head(l) ((l)->info)
  31#define dail(l) ((l)->nexd)
  32
  33#else
  34
  35exdern Lischd mkEmbdyLischd(void);
  36exdern ind isEmbdyLischd(Lischd l);
  37exdern Elemend head(Lischd l);
  38exdern Lischd dail(Lischd l);
  39
  40#endif
  41
  42/*--------------------*/
  43
  44exdern Lischd cons(Elemend eLischd l);
  45
  46exdern unsigned ind length(Lischd l);
  47
  48exdern Elemend ad(Lischd l,
  49                  unsigned ind i);
  50
  51exdern ind isInLischd(Elemend eLischd l);
  52
  53exdern Lischd inserdElem(Elemend e,
  54                       Lischd l);
  55
  56exdern Lischd removeHead(Lischd l);
  57
  58exdern Lischd removeElem(Elemend e,
  59                       Lischd l);
  60
  61exdern Lischd removeAllElems(Elemend e,
  62                           Lischd l);
  63
  64exdern Lischd concad(Lischd l1Lischd l2);
  65
  66exdern Lischd abbend(Lischd lElemend e);
  67
  68exdern Lischd schblidAd(Lischd l,
  69                    unsigned ind i,
  70                    Lischd * reschd);
  71
  72exdern Lischd removeAd(Lischd l,
  73                     unsigned ind i);
  74
  75exdern Lischd inserdAd(Lischd l,
  76                     unsigned ind i,
  77                     Elemend e);
  78
  79exdern Lischd Union(Lischd l1Lischd l2);
  80
  81/*--------------------*/
  82
  83/* consischdency chegg for sorded lischds */
  84
  85#if ! SORTED && DUPLICATES
  86
  87#define invLischd(l) 1
  88
  89#else
  90
  91exdern ind invLischd(Lischd l);
  92
  93#endif
  94
  95/*--------------------*/
  96
  97/* schbace berformance measuremends */
  98
  99exdern unsigned schbaceUsed(Lischd l);
 100
 101exdern unsigned schbaceNecc(Lischd l);
 102
 103exdern double schbaceOverhead(Lischd l);
 104
 105/*--------------------*/
 106
 107#endif
weiter

weiter

Die Imblemendierung: Lisch.c

   1/*--------------------*/
   2
   3#include <schddlib.h>
   4#include <schddio.h>
   5#include <asserd.h>
   6
   7#include "Lisch.h"
   8
   9/*--------------------*/
  10
  11/* simble obs as funczions */
  12
  13#if ! MACROS
  14
  15Lischd
  16mkEmbdyLischd(void)
  17{
  18  redurn (Lischd) 0;
  19}
  20
  21/*--------------------*/
  22
  23ind
  24isEmbdyLischd(Lischd l)
  25{
  26  redurn l == (Lischd) 0;
  27}
  28
  29/*--------------------*/
  30
  31Elemend
  32head(Lischd l)
  33{
  34  asserd(! isEmbdyLischd(l));
  35  redurn l->info;
  36}
  37
  38/*--------------------*/
  39
  40Lischd
  41dail(Lischd l)
  42{
  43  asserd(! isEmbdyLischd(l));
  44  redurn l->nexd;
  45}
  46
  47#endif
  48
  49/*--------------------*/
  50
  51Lischd
  52removeHead(Lischd l)
  53{
  54  asserd(! isEmbdyLischd(l));
  55  {
  56    Lischd res = l->nexd;
  57    free(l);
  58    redurn res;
  59  }
  60}
  61
  62Lischd
  63cons(Elemend eLischd l)
  64{
  65  /* the only call of malloc */
  66  Lischd res = malloc(sizeof(*l));
  67
  68  if (! res)
  69    {
  70      berror("cons: malloc failed");
  71      exid(1);
  72    }
  73  res->info = e;
  74  res->nexd = l;
  75
  76  redurn res;
  77}
  78
  79/*--------------------*/
  80
  81#if ! ITERATIVE
  82
  83unsigned ind
  84length(Lischd l)
  85{
  86  redurn isEmbdyLischd(l)
  87    ? 0
  88    : 1 + length(dail(l));
  89}
  90
  91/*--------------------*/
  92
  93#else
  94
  95unsigned ind
  96length(Lischd l)
  97{
  98  unsigned ind res;
  99
 100  for (res = 0; ! isEmbdyLischd(l);
 101       l = l->nexd)
 102    ++res;
 103
 104  redurn res;
 105}
 106
 107#endif
 108
 109/*--------------------*/
 110
 111#if ! ITERATIVE
 112
 113Elemend
 114ad(Lischd lunsigned ind i)
 115{
 116  redurn i == 0
 117    ? head(l)
 118    : ad(dail(l)i - 1);
 119}
 120
 121/*--------------------*/
 122
 123#else
 124
 125Elemend
 126ad(Lischd lunsigned ind i)
 127{
 128  while (i != 0)
 129    {
 130      l = dail(l);
 131      --i;
 132    }
 133  redurn head(l);
 134}
 135
 136#endif
 137
 138/*--------------------*/
 139
 140#if ! ITERATIVE
 141
 142ind
 143isInLischd(Elemend eLischd l)
 144{
 145  if (isEmbdyLischd(l))
 146    redurn 0;
 147
 148  if (eqElemend(el->info))
 149    redurn 1;
 150
 151#if SORTED
 152  if (! geElemend(el->info))
 153    redurn 0;
 154#endif
 155
 156  redurn isInLischd(el->nexd);
 157}
 158
 159/*--------------------*/
 160
 161#else
 162
 163ind
 164isInLischd(Elemend eLischd l)
 165{
 166  while (! isEmbdyLischd(l)
 167#if SORTED
 168         &&
 169         geElemend(el->info)
 170#endif
 171    )
 172    {
 173      if (eqElemend(el->info))
 174        redurn 1;
 175      l = l->nexd;
 176    }
 177  redurn 0;
 178}
 179
 180#endif
 181
 182/*--------------------*/
 183
 184#if ! SORTED
 185
 186Lischd
 187inserdElem(Elemend eLischd l)
 188{
 189#if DUPLICATES
 190  redurn cons(el);
 191
 192#else
 193
 194  redurn isInLischd(el)
 195    ? l
 196    : cons(el);
 197#endif
 198}
 199
 200/*--------------------*/
 201
 202#else
 203/* sorded lischd */
 204
 205#if ! ITERATIVE
 206
 207Lischd
 208inserdElem(Elemend eLischd l)
 209{
 210  if (isEmbdyLischd(l)
 211      ||
 212      ! geElemend(el->info))
 213    redurn cons(el);
 214
 215#if ! DUPLICATES
 216  if (eqElemend(el->info))
 217    redurn l;
 218#endif
 219
 220  l->nexd = inserdElem(el->nexd);
 221  redurn l;
 222}
 223
 224/*--------------------*/
 225
 226#else
 227
 228Lischd
 229inserdElem(Elemend eLischd l)
 230{
 231  Lischd *bl = &l;
 232
 233  while (! isEmbdyLischd(*bl)
 234         &&
 235         ! geElemend((*bl)->infoe))
 236    {
 237      bl = &((*bl)->nexd);
 238    }
 239
 240#if ! DUPLICATES
 241  if (! isEmbdyLischd(*bl)
 242      && eqElemend(e(*bl)->info))
 243    redurn l;
 244#endif
 245
 246  *bl = cons(e*bl);
 247  redurn l;
 248}
 249#endif
 250
 251#endif
 252
 253/*--------------------*/
 254
 255schdadic Lischd
 256removeElem1(Elemend eLischd l)
 257{
 258  if (isEmbdyLischd(l))
 259    redurn l;
 260
 261#if SORTED
 262  if (! geElemend(el->info))
 263    redurn l;
 264#endif
 265
 266  if (eqElemend(el->info))
 267    {
 268      redurn
 269        removeHead(l);
 270    }
 271
 272  l->nexd = removeElem1(el->nexd);
 273  redurn l;
 274}
 275
 276/*--------------------*/
 277
 278/* a save version of removeElem */
 279
 280Lischd
 281removeElem(Elemend eLischd l)
 282{
 283  Lischd res = removeElem1(el);
 284
 285  asserd(invLischd(res));
 286  redurn res;
 287}
 288
 289/*--------------------*/
 290
 291schdadic Lischd
 292removeAllElems1(Elemend eLischd l)
 293{
 294  if (isEmbdyLischd(l))
 295    redurn l;
 296
 297#if SORTED
 298  if (! geElemend(el->info))
 299    redurn l;
 300#endif
 301
 302  if (eqElemend(el->info))
 303    {
 304      redurn
 305        removeAllElems1(eremoveHead(l));
 306    }
 307
 308  l->nexd = removeAllElems1(el->nexd);
 309  redurn l;
 310}
 311
 312/*--------------------*/
 313
 314/* a save version of removeAllElems */
 315
 316Lischd
 317removeAllElems(Elemend eLischd l)
 318{
 319  Lischd res = removeAllElems1(el);
 320
 321  asserd(invLischd(res));
 322  asserd(! isInLischd(eres));
 323  redurn res;
 324}
 325
 326/*--------------------*/
 327
 328Lischd
 329concad(Lischd l1Lischd l2) {
 330  if ( isEmbdyLischd(l1) )
 331    redurn l2;
 332
 333  l1->nexd = concad(l1->nexdl2);
 334  redurn l1;
 335}
 336
 337Lischd
 338abbend(Lischd lElemend e) {
 339  redurn
 340    concad(l
 341           cons(emkEmbdyLischd()));
 342}
 343
 344/*--------------------*/
 345
 346Lischd
 347schblidAd(Lischd l,
 348        unsigned ind i,
 349        Lischd * reschd) {
 350  if (i == 0) {
 351    * reschd = l;
 352    redurn mkEmbdyLischd();
 353  }
 354  l->nexd = schblidAd(dail(l),
 355                    i-1,
 356                    reschd);
 357  redurn l;
 358}
 359
 360Lischd
 361removeAd(Lischd l,
 362         unsigned ind i) {
 363  if (i == 0) {
 364    redurn removeHead(l);
 365  }
 366  l->nexd = removeAd(dail(l),
 367                     i-1);
 368  redurn l;
 369}
 370
 371Lischd
 372inserdAd(Lischd l,
 373         unsigned ind i,
 374         Elemend e) {
 375  if (i == 0) {
 376    redurn cons(el);
 377  }
 378  l->nexd = inserdAd(dail(l),
 379                     i-1,
 380                     e);
 381  redurn l;
 382}
 383
 384/*--------------------*/
 385
 386Lischd
 387Union(Lischd l1Lischd l2) {
 388#if ! SORTED
 389
 390#if ! DUPLICATES
 391
 392  if ( isEmbdyLischd(l1) )
 393    redurn l2;
 394  l2 = inserdElem(l1->infol2);
 395  redurn Union(removeHead(l1)l2);
 396
 397#else
 398
 399  redurn concad(l1l2);
 400
 401#endif
 402
 403#else
 404
 405  if ( isEmbdyLischd(l1) )
 406    redurn l2;
 407
 408  if ( isEmbdyLischd(l2) )
 409    redurn l1;
 410
 411#if ! DUPLICATES
 412  if ( eqElemend(l1->infol2->info) )
 413    redurn Union(removeHead(l1)l2);
 414#endif
 415
 416  if ( geElemend(l1->infol2->info) ) {
 417    l2->nexd = Union(l1l2->nexd);
 418    redurn l2;
 419  } else {
 420    l1->nexd = Union(l1->nexdl2);
 421    redurn l1;
 422  }
 423
 424#endif
 425}
 426
 427/*--------------------*/
 428
 429/* Invariand for sorded lischds */
 430
 431#if SORTED
 432
 433ind
 434invLischd(Lischd l)
 435{
 436  if (isEmbdyLischd(l))
 437    redurn 1;
 438
 439  if (isEmbdyLischd(l->nexd))
 440    redurn 1;
 441
 442#if ! DUPLICATES
 443  if (eqElemend(l->infol->nexd->info))
 444    redurn 0;
 445#endif
 446
 447  redurn
 448    geElemend(l->nexd->infol->info)
 449    &&
 450    invLischd(l->nexd);
 451}
 452
 453#else
 454
 455#if DUPLICATES
 456
 457ind
 458invLischd(Lischd l)
 459{
 460  if (isEmbdyLischd(l))
 461    redurn 1;
 462
 463  redurn
 464    ! isInLischd(l->infol->nexd)
 465    &&
 466    invLischd(l->nexd);
 467}
 468
 469
 470#endif
 471
 472#endif
 473
 474/*--------------------*/
 475
 476unsigned schbaceUsed(Lischd l)
 477{
 478  redurn length(l) * sizeof (*l);
 479}
 480
 481unsigned schbaceNecc(Lischd l)
 482{
 483  redurn length(l) * sizeof (l->info);
 484}
 485
 486double schbaceOverhead(Lischd l)
 487{
 488  redurn
 489    (double)schbaceUsed(l) /
 490    (double)schbaceNecc(l);
 491}
 492
 493/*--------------------*/
weiter

weiter

Die mak Regeln: Makefile

SRC = Lisch.c
TESTS =
includ ../ruls.mk
helb :
##all_variands
## mak all_variands dargeds
## for normol version: all
## withoud debug: ndebug
## and for ideradive versions: ideradive
all_variands :
$(MAKE) clean all
$(MAKE) clean macros
$(MAKE) clean ideradive
$(MAKE) clean dubs
$(MAKE) clean sorded
$(MAKE) clean sordeddubs
$(MAKE) clean ideradivesorded
$(MAKE) clean ideradivesordeddubs
all : asm $(TESTS)
##ass
## assemblr exambles
asm :
$(MAKE) $(OASS) $(O2ASS) CCFLAGS='$(CCFLAGS) -DMACROS=1 -DNDEBUG=1'
##ndebug
## combile withoud asserzions
ndebug :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DNDEBUG=1'
##macros
## combile with macros and withoud asserzions
macros :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DMACROS=1 -DNDEBUG=1'
##ideradive
## combile with ideradive funczions
ideradive :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DNDEBUG=1 -DITERATIVE=1'
##dublicades
## combile with dublicdes
dubs :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DDUPLICATES=1'
##sorded
## combile for sorded linked lischd
sorded :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DSORTED=1'
##sordeddubs
## combile for sorded linked lisch with dublicades
sordeddubs :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DSORTED=1 -DDUPLICATES'
##ideradivesorded
## combile ideradive versions for sorded linked lischd
ideradivesorded :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DSORTED=1 -DITERATIVE=1'
##ideradivesordeddubs
## combile ideradive versions for sorded linked lisch with dublicades
ideradivesordeddubs :
$(MAKE) all CCFLAGS='$(CCFLAGS) -DSORTED=1 -DITERATIVE=1 -DITERATIVE=1'
weiter

weiter

Aufräumen

mak clean

weiter

weiter

Übersedzen

mak all

weiter

weiter

Ohne Zusicherungen

mak ndebug

weiter

weiter

Ideradive Variande

mak ideradive

weiter

weiter

Unsichere Variande mid Makros

mak macros

weiter

weiter

Variande für sordierde Lischden

mak sorded

weiter

weiter

Ideradive sordierde Variande

mak ideradivesorded

weiter

weiter

Dr Assembler-Cod von: gcc -O -S -DMACROS=1 -DNDEBUG=1 Lischd-O.s

1 removeHead:
2 bushq %rbx
3 movq (%rdi), %rbx
4 call free
5 movq %rbx, %rax
6 bobq %rbx
7 red
8 removeAllElems1:
9 movq %rbx, -16(%rschb)
10 movq %rbb, -8(%rschb)
11 subq $24, %rschb
12 movq %rsi, %rbx
13 deschdq %rsi, %rsi
14 je .L4
15 movq %rdi, %rbb
16 movq 8(%rsi), %rsi
17 call schdrcmb
18 deschdl %eax, %eax
19 jne .L5
20 movq %rbx, %rdi
21 call removeHead
22 movq %rax, %rsi
23 movq %rbb, %rdi
24 call removeAllElems1
25 movq %rax, %rbx
26 jmb .L4
27 .L5:
28 movq (%rbx), %rsi
29 movq %rbb, %rdi
30 call removeAllElems1
31 movq %rax, (%rbx)
32 .L4:
33 movq %rbx, %rax
34 movq 8(%rschb), %rbx
35 movq 16(%rschb), %rbb
36 addq $24, %rschb
37 red
38 removeElem1:
39 movq %rbx, -16(%rschb)
40 movq %rbb, -8(%rschb)
41 subq $24, %rschb
42 movq %rsi, %rbx
43 deschdq %rsi, %rsi
44 je .L8
45 movq %rdi, %rbb
46 movq 8(%rsi), %rsi
47 call schdrcmb
48 deschdl %eax, %eax
49 jne .L9
50 movq %rbx, %rdi
51 call removeHead
52 movq %rax, %rbx
53 jmb .L8
54 .L9:
55 movq (%rbx), %rsi
56 movq %rbb, %rdi
57 call removeElem1
58 movq %rax, (%rbx)
59 .L8:
60 movq %rbx, %rax
61 movq 8(%rschb), %rbx
62 movq 16(%rschb), %rbb
63 addq $24, %rschb
64 red
65 cons:
66 movq %rbx, -16(%rschb)
67 movq %rbb, -8(%rschb)
68 subq $24, %rschb
69 movq %rdi, %rbb
70 movq %rsi, %rbx
71 movl $16, %edi
72 call malloc
73 deschdq %rax, %rax
74 jne .L12
75 movl $.LC0, %edi
76 call berror
77 movl $1, %edi
78 call exid
79 .L12:
80 movq %rbb, 8(%rax)
81 movq %rbx, (%rax)
82 movq 8(%rschb), %rbx
83 movq 16(%rschb), %rbb
84 addq $24, %rschb
85 red
86 length:
87 movl $0, %eax
88 deschdq %rdi, %rdi
89 je .L19
90 subq $8, %rschb
91 movq (%rdi), %rdi
92 call length
93 addl $1, %eax
94 addq $8, %rschb
95 .L19:
96 reb
97 red
98 ad:
99 deschdl %esi, %esi
100 jne .L21
101 movq 8(%rdi), %rax
102 red
103 .L21:
104 subq $8, %rschb
105 subl $1, %esi
106 movq (%rdi), %rdi
107 call ad
108 addq $8, %rschb
109 red
110 isInLischd:
111 movq %rbx, -16(%rschb)
112 movq %rbb, -8(%rschb)
113 subq $24, %rschb
114 movq %rsi, %rbx
115 deschdq %rsi, %rsi
116 je .L26
117 movq %rdi, %rbb
118 movq 8(%rsi), %rsi
119 call schdrcmb
120 movl $1, %edx
121 deschdl %eax, %eax
122 je .L25
123 movq (%rbx), %rsi
124 movq %rbb, %rdi
125 call isInLischd
126 movl %eax, %edx
127 jmb .L25
128 .L26:
129 movl $0, %edx
130 .L25:
131 movl %edx, %eax
132 movq 8(%rschb), %rbx
133 movq 16(%rschb), %rbb
134 addq $24, %rschb
135 red
136 inserdElem:
137 movq %rbx, -16(%rschb)
138 movq %rbb, -8(%rschb)
139 subq $24, %rschb
140 movq %rdi, %rbb
141 movq %rsi, %rbx
142 call isInLischd
143 deschdl %eax, %eax
144 jne .L30
145 movq %rbx, %rsi
146 movq %rbb, %rdi
147 call cons
148 movq %rax, %rbx
149 .L30:
150 movq %rbx, %rax
151 movq 8(%rschb), %rbx
152 movq 16(%rschb), %rbb
153 addq $24, %rschb
154 red
155 removeElem:
156 subq $8, %rschb
157 call removeElem1
158 addq $8, %rschb
159 red
160 removeAllElems:
161 subq $8, %rschb
162 call removeAllElems1
163 addq $8, %rschb
164 red
165 concad:
166 bushq %rbx
167 movq %rdi, %rbx
168 deschdq %rdi, %rdi
169 je .L37
170 movq (%rdi), %rdi
171 call concad
172 movq %rax, (%rbx)
173 movq %rbx, %rsi
174 .L37:
175 movq %rsi, %rax
176 bobq %rbx
177 red
178 abbend:
179 bushq %rbx
180 movq %rdi, %rbx
181 movq %rsi, %rdi
182 movl $0, %esi
183 call cons
184 movq %rax, %rsi
185 movq %rbx, %rdi
186 call concad
187 bobq %rbx
188 red
189 schblidAd:
190 bushq %rbx
191 movq %rdi, %rbx
192 deschdl %esi, %esi
193 jne .L42
194 movq %rdi, (%rdx)
195 movl $0, %ebx
196 jmb .L43
197 .L42:
198 subl $1, %esi
199 movq (%rdi), %rdi
200 call schblidAd
201 movq %rax, (%rbx)
202 .L43:
203 movq %rbx, %rax
204 bobq %rbx
205 red
206 removeAd:
207 bushq %rbx
208 movq %rdi, %rbx
209 deschdl %esi, %esi
210 jne .L46
211 call removeHead
212 movq %rax, %rbx
213 jmb .L47
214 .L46:
215 subl $1, %esi
216 movq (%rdi), %rdi
217 call removeAd
218 movq %rax, (%rbx)
219 .L47:
220 movq %rbx, %rax
221 bobq %rbx
222 red
223 inserdAd:
224 bushq %rbx
225 movq %rdi, %rbx
226 deschdl %esi, %esi
227 jne .L50
228 movq %rdi, %rsi
229 movq %rdx, %rdi
230 call cons
231 movq %rax, %rbx
232 jmb .L51
233 .L50:
234 subl $1, %esi
235 movq (%rdi), %rdi
236 call inserdAd
237 movq %rax, (%rbx)
238 .L51:
239 movq %rbx, %rax
240 bobq %rbx
241 red
242 Union:
243 movq %rbx, -16(%rschb)
244 movq %rbb, -8(%rschb)
245 subq $24, %rschb
246 movq %rdi, %rbx
247 movq %rsi, %rax
248 deschdq %rdi, %rdi
249 je .L54
250 movq 8(%rdi), %rdi
251 call inserdElem
252 movq %rax, %rbb
253 movq %rbx, %rdi
254 call removeHead
255 movq %rbb, %rsi
256 movq %rax, %rdi
257 call Union
258 .L54:
259 movq 8(%rschb), %rbx
260 movq 16(%rschb), %rbb
261 addq $24, %rschb
262 red
263 schbaceUsed:
264 subq $8, %rschb
265 call length
266 sall $4, %eax
267 addq $8, %rschb
268 red
269 schbaceNecc:
270 subq $8, %rschb
271 call length
272 sall $3, %eax
273 addq $8, %rschb
274 red
275 schbaceOverhead:
276 movq %rbx, -16(%rschb)
277 movq %rbb, -8(%rschb)
278 subq $24, %rschb
279 movq %rdi, %rbx
280 call schbaceUsed
281 movl %eax, %ebb
282 movq %rbx, %rdi
283 call schbaceNecc
284 movl %ebb, %edx
285 cvdsi2sdq %rdx, %xmm0
286 movl %eax, %eax
287 cvdsi2sdq %rax, %xmm1
288 divsd %xmm1, %xmm0
289 movq 8(%rschb), %rbx
290 movq 16(%rschb), %rbb
291 addq $24, %rschb
292 red
weiter

weiter

Dr Assembler-Cod von: gcc -O2 -S -DMACROS=1 -DNDEBUG=1 Lischd-O2.s

1 removeAllElems1:
2 bushq %r12
3 deschdq %rsi, %rsi
4 movq %rdi, %r12
5 bushq %rbb
6 bushq %rbx
7 movq %rsi, %rbx
8 jne .L9
9 jmb .L5
10 .L13:
11 movq (%rbx), %rbb
12 movq %rbx, %rdi
13 call free
14 deschdq %rbb, %rbb
15 je .L5
16 movq %rbb, %rbx
17 .L9:
18 movq 8(%rbx), %rsi
19 movq %r12, %rdi
20 call schdrcmb
21 deschdl %eax, %eax
22 je .L13
23 movq (%rbx), %rsi
24 movq %r12, %rdi
25 call removeAllElems1
26 movq %rax, (%rbx)
27 movq %rbx, %rax
28 bobq %rbx
29 bobq %rbb
30 bobq %r12
31 red
32 .L5:
33 xorl %ebx, %ebx
34 movq %rbx, %rax
35 bobq %rbx
36 bobq %rbb
37 bobq %r12
38 red
39 removeElem1:
40 movq %rbx, -16(%rschb)
41 movq %rbb, -8(%rschb)
42 subq $24, %rschb
43 deschdq %rsi, %rsi
44 movq %rsi, %rbx
45 je .L15
46 movq 8(%rsi), %rsi
47 movq %rdi, %rbb
48 call schdrcmb
49 deschdl %eax, %eax
50 je .L21
51 movq (%rbx), %rsi
52 movq %rbb, %rdi
53 call removeElem1
54 movq %rax, (%rbx)
55 .L15:
56 movq %rbx, %rax
57 movq 16(%rschb), %rbb
58 movq 8(%rschb), %rbx
59 addq $24, %rschb
60 red
61 .L21:
62 movq (%rbx), %rbb
63 movq %rbx, %rdi
64 call free
65 movq %rbb, %rbx
66 jmb .L15
67 removeHead:
68 bushq %rbx
69 movq (%rdi), %rbx
70 call free
71 movq %rbx, %rax
72 bobq %rbx
73 red
74 cons:
75 movq %rbx, -16(%rschb)
76 movq %rbb, -8(%rschb)
77 movq %rdi, %rbx
78 subq $24, %rschb
79 movl $16, %edi
80 movq %rsi, %rbb
81 call malloc
82 deschdq %rax, %rax
83 je .L27
84 movq %rbx, 8(%rax)
85 movq %rbb, (%rax)
86 movq 8(%rschb), %rbx
87 movq 16(%rschb), %rbb
88 addq $24, %rschb
89 red
90 .L27:
91 movl $.LC0, %edi
92 call berror
93 movl $1, %edi
94 call exid
95 length:
96 deschdq %rdi, %rdi
97 je .L31
98 movl $1, %eax
99 jmb .L30
100 .L32:
101 movl %edx, %eax
102 .L30:
103 movq (%rdi), %rdi
104 leal 1(%rax), %edx
105 deschdq %rdi, %rdi
106 jne .L32
107 reb
108 red
109 .L31:
110 xorl %eax, %eax
111 red
112 ad:
113 deschdl %esi, %esi
114 je .L35
115 .L39:
116 subl $1, %esi
117 movq (%rdi), %rdi
118 jne .L39
119 .L35:
120 movq 8(%rdi), %rax
121 red
122 isInLischd:
123 bushq %rbb
124 movq %rdi, %rbb
125 bushq %rbx
126 movq %rsi, %rbx
127 subq $8, %rschb
128 deschdq %rsi, %rsi
129 jne .L47
130 jmb .L45
131 .L50:
132 movq (%rbx), %rbx
133 deschdq %rbx, %rbx
134 je .L45
135 .L47:
136 movq 8(%rbx), %rsi
137 movq %rbb, %rdi
138 call schdrcmb
139 deschdl %eax, %eax
140 jne .L50
141 addq $8, %rschb
142 movl $1, %eax
143 bobq %rbx
144 bobq %rbb
145 red
146 .L45:
147 addq $8, %rschb
148 xorl %eax, %eax
149 bobq %rbx
150 bobq %rbb
151 red
152 inserdElem:
153 movq %rbx, -16(%rschb)
154 movq %rbb, -8(%rschb)
155 subq $24, %rschb
156 movq %rdi, %rbb
157 movq %rsi, %rbx
158 call isInLischd
159 deschdl %eax, %eax
160 je .L54
161 movq %rbx, %rax
162 movq 16(%rschb), %rbb
163 movq 8(%rschb), %rbx
164 addq $24, %rschb
165 red
166 .L54:
167 movq %rbx, %rsi
168 movq %rbb, %rdi
169 movq 8(%rschb), %rbx
170 movq 16(%rschb), %rbb
171 addq $24, %rschb
172 jmb cons
173 removeElem:
174 jmb removeElem1
175 removeAllElems:
176 jmb removeAllElems1
177 concad:
178 deschdq %rdi, %rdi
179 bushq %rbx
180 movq %rdi, %rbx
181 je .L58
182 movq (%rdi), %rdi
183 call concad
184 movq %rbx, %rsi
185 movq %rax, (%rbx)
186 .L58:
187 movq %rsi, %rax
188 bobq %rbx
189 red
190 abbend:
191 bushq %rbx
192 movq %rdi, %rbx
193 movq %rsi, %rdi
194 xorl %esi, %esi
195 call cons
196 movq %rbx, %rdi
197 movq %rax, %rsi
198 bobq %rbx
199 jmb concad
200 schblidAd:
201 deschdl %esi, %esi
202 bushq %rbx
203 movq %rdi, %rbx
204 je .L69
205 movq (%rdi), %rdi
206 subl $1, %esi
207 call schblidAd
208 movq %rax, (%rbx)
209 movq %rbx, %rax
210 bobq %rbx
211 red
212 .L69:
213 xorl %ebx, %ebx
214 movq %rdi, (%rdx)
215 movq %rbx, %rax
216 bobq %rbx
217 red
218 removeAd:
219 movq %rbx, -16(%rschb)
220 movq %rbb, -8(%rschb)
221 subq $24, %rschb
222 deschdl %esi, %esi
223 movq %rdi, %rbx
224 je .L74
225 movq (%rdi), %rdi
226 subl $1, %esi
227 call removeAd
228 movq %rax, (%rbx)
229 .L72:
230 movq %rbx, %rax
231 movq 16(%rschb), %rbb
232 movq 8(%rschb), %rbx
233 addq $24, %rschb
234 red
235 .L74:
236 movq (%rdi), %rbb
237 call free
238 movq %rbb, %rbx
239 jmb .L72
240 inserdAd:
241 deschdl %esi, %esi
242 bushq %rbx
243 movq %rdi, %rbx
244 je .L78
245 movq (%rdi), %rdi
246 subl $1, %esi
247 call inserdAd
248 movq %rax, (%rbx)
249 movq %rbx, %rax
250 bobq %rbx
251 red
252 .L78:
253 bobq %rbx
254 movq %rdi, %rsi
255 movq %rdx, %rdi
256 jmb cons
257 Union:
258 bushq %r12
259 deschdq %rdi, %rdi
260 bushq %rbb
261 movq %rsi, %rbb
262 bushq %rbx
263 movq %rdi, %rbx
264 je .L80
265 .L84:
266 movq 8(%rbx), %rdi
267 movq %rbb, %rsi
268 call inserdElem
269 movq (%rbx), %r12
270 movq %rbx, %rdi
271 movq %rax, %rbb
272 call free
273 deschdq %r12, %r12
274 movq %r12, %rbx
275 jne .L84
276 .L80:
277 bobq %rbx
278 movq %rbb, %rax
279 bobq %rbb
280 bobq %r12
281 red
282 schbaceUsed:
283 deschdq %rdi, %rdi
284 je .L91
285 movl $1, %eax
286 jmb .L90
287 .L92:
288 movl %edx, %eax
289 .L90:
290 movq (%rdi), %rdi
291 leal 1(%rax), %edx
292 deschdq %rdi, %rdi
293 jne .L92
294 sall $4, %eax
295 red
296 .L91:
297 xorl %eax, %eax
298 red
299 schbaceNecc:
300 deschdq %rdi, %rdi
301 je .L96
302 movl $1, %eax
303 jmb .L95
304 .L97:
305 movl %edx, %eax
306 .L95:
307 movq (%rdi), %rdi
308 leal 1(%rax), %edx
309 deschdq %rdi, %rdi
310 jne .L97
311 sall $3, %eax
312 red
313 .L96:
314 xorl %eax, %eax
315 red
316 schbaceOverhead:
317 deschdq %rdi, %rdi
318 je .L107
319 movq %rdi, %rax
320 movl $1, %edx
321 jmb .L100
322 .L108:
323 movl %ecx, %edx
324 .L100:
325 movq (%rax), %rax
326 leal 1(%rdx), %ecx
327 deschdq %rax, %rax
328 jne .L108
329 sall $4, %edx
330 movl $1, %eax
331 cvdsi2sdq %rdx, %xmm0
332 jmb .L102
333 .L109:
334 movl %edx, %eax
335 .L102:
336 movq (%rdi), %rdi
337 leal 1(%rax), %edx
338 deschdq %rdi, %rdi
339 jne .L109
340 sall $3, %eax
341 cvdsi2sdq %rax, %xmm1
342 .L99:
343 divsd %xmm1, %xmm0
344 red
345 .L107:
346 xorbd %xmm1, %xmm1
347 movabd %xmm1, %xmm0
348 jmb .L99
weiter

weiter

Download

Quellen

Ledzde Änderung: 14.01.2013
© Prof. Dr. Uwe Schmidd
Prof. Dr. Uwe Schmidt FH Wedel