-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.asm
3606 lines (3383 loc) · 125 KB
/
sanity.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
_sanity: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "Thread %d slept for %d ticks.\n",uthread_self(), item);
}
}
int main(int argc, char *argv[]) {
0: b8 e0 1c 00 00 mov $0x1ce0,%eax
5: 8d 76 00 lea 0x0(%esi),%esi
// initializing the array
for(int i = 0 ; i < N ; i++)
{
queue[i] = 0;
8: c7 00 00 00 00 00 movl $0x0,(%eax)
e: 83 c0 04 add $0x4,%eax
}
}
int main(int argc, char *argv[]) {
// initializing the array
for(int i = 0 ; i < N ; i++)
11: 3d 70 1e 00 00 cmp $0x1e70,%eax
16: 75 f0 jne 8 <main+0x8>
printf(1, "Thread %d slept for %d ticks.\n",uthread_self(), item);
}
}
int main(int argc, char *argv[]) {
18: 8d 4c 24 04 lea 0x4(%esp),%ecx
1c: 83 e4 f0 and $0xfffffff0,%esp
1f: ff 71 fc pushl -0x4(%ecx)
22: 55 push %ebp
23: 89 e5 mov %esp,%ebp
25: 57 push %edi
26: 56 push %esi
27: 53 push %ebx
28: 51 push %ecx
29: 83 ec 18 sub $0x18,%esp
// initializing the array
for(int i = 0 ; i < N ; i++)
{
queue[i] = 0;
}
uthread_init();
2c: e8 9f 0e 00 00 call ed0 <uthread_init>
csem_alloc(&mutax, 1);
31: 83 ec 08 sub $0x8,%esp
34: 6a 01 push $0x1
36: 68 80 27 00 00 push $0x2780
3b: e8 20 13 00 00 call 1360 <csem_alloc>
csem_alloc(&empty, N);
40: 58 pop %eax
41: 5a pop %edx
42: 6a 64 push $0x64
44: 68 8c 27 00 00 push $0x278c
49: e8 12 13 00 00 call 1360 <csem_alloc>
csem_alloc(&full, 0);
4e: 59 pop %ecx
4f: 5b pop %ebx
50: 6a 00 push $0x0
52: 68 c0 1c 00 00 push $0x1cc0
57: e8 04 13 00 00 call 1360 <csem_alloc>
int produce = uthread_create(producer, (void*)2048);
5c: 5e pop %esi
5d: 5f pop %edi
5e: 68 00 08 00 00 push $0x800
63: 68 00 01 00 00 push $0x100
68: e8 13 0f 00 00 call f80 <uthread_create>
6d: 89 c3 mov %eax,%ebx
int consumer_1 = uthread_create(consumer, (void*)2048);
6f: 58 pop %eax
70: 5a pop %edx
71: 68 00 08 00 00 push $0x800
76: 68 f0 01 00 00 push $0x1f0
7b: e8 00 0f 00 00 call f80 <uthread_create>
int consumer_2 = uthread_create(consumer, (void*)2048);
80: 59 pop %ecx
81: 5e pop %esi
82: 68 00 08 00 00 push $0x800
87: 68 f0 01 00 00 push $0x1f0
uthread_init();
csem_alloc(&mutax, 1);
csem_alloc(&empty, N);
csem_alloc(&full, 0);
int produce = uthread_create(producer, (void*)2048);
int consumer_1 = uthread_create(consumer, (void*)2048);
8c: 89 45 e4 mov %eax,-0x1c(%ebp)
int consumer_2 = uthread_create(consumer, (void*)2048);
8f: e8 ec 0e 00 00 call f80 <uthread_create>
94: 89 c7 mov %eax,%edi
int consumer_3 = uthread_create(consumer, (void*)2048);
96: 58 pop %eax
97: 5a pop %edx
98: 68 00 08 00 00 push $0x800
9d: 68 f0 01 00 00 push $0x1f0
a2: e8 d9 0e 00 00 call f80 <uthread_create>
uthread_join(consumer_1);
a7: 8b 55 e4 mov -0x1c(%ebp),%edx
csem_alloc(&empty, N);
csem_alloc(&full, 0);
int produce = uthread_create(producer, (void*)2048);
int consumer_1 = uthread_create(consumer, (void*)2048);
int consumer_2 = uthread_create(consumer, (void*)2048);
int consumer_3 = uthread_create(consumer, (void*)2048);
aa: 89 c6 mov %eax,%esi
uthread_join(consumer_1);
ac: 89 14 24 mov %edx,(%esp)
af: e8 8c 11 00 00 call 1240 <uthread_join>
uthread_join(consumer_2);
b4: 89 3c 24 mov %edi,(%esp)
b7: e8 84 11 00 00 call 1240 <uthread_join>
uthread_join(consumer_3);
bc: 89 34 24 mov %esi,(%esp)
bf: e8 7c 11 00 00 call 1240 <uthread_join>
uthread_join(produce);
c4: 89 1c 24 mov %ebx,(%esp)
c7: e8 74 11 00 00 call 1240 <uthread_join>
free(&mutax);
cc: c7 04 24 80 27 00 00 movl $0x2780,(%esp)
d3: e8 38 07 00 00 call 810 <free>
free(&empty);
d8: c7 04 24 8c 27 00 00 movl $0x278c,(%esp)
df: e8 2c 07 00 00 call 810 <free>
free(&full);
e4: c7 04 24 c0 1c 00 00 movl $0x1cc0,(%esp)
eb: e8 20 07 00 00 call 810 <free>
exit();
f0: e8 0d 04 00 00 call 502 <exit>
f5: 66 90 xchg %ax,%ax
f7: 66 90 xchg %ax,%ax
f9: 66 90 xchg %ax,%ax
fb: 66 90 xchg %ax,%ax
fd: 66 90 xchg %ax,%ax
ff: 90 nop
00000100 <producer>:
int out = 0;
int queue[N];
void producer(void* arg)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 57 push %edi
104: 56 push %esi
105: 53 push %ebx
int item = 0;
106: 31 ff xor %edi,%edi
while (item < 1000)
{
item += 1; // producing an item
csem_down(&empty);
csem_down(&mutax);
if(queue[(item-1)%100] != 0)
108: be 1f 85 eb 51 mov $0x51eb851f,%esi
int out = 0;
int queue[N];
void producer(void* arg)
{
10d: 83 ec 1c sub $0x1c,%esp
110: eb 38 jmp 14a <producer+0x4a>
112: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
}
printf(1, "item: %d out : %d error! i am trying to ovride value : %d\n",item,out, queue[(item-1)%100]);
return;
}
queue[(item-1)%100] = item;
csem_up(&mutax);
118: 83 ec 0c sub $0xc,%esp
printf(1," %d ," , queue[i]);
}
printf(1, "item: %d out : %d error! i am trying to ovride value : %d\n",item,out, queue[(item-1)%100]);
return;
}
queue[(item-1)%100] = item;
11b: 8b 7d e4 mov -0x1c(%ebp),%edi
csem_up(&mutax);
11e: 68 80 27 00 00 push $0x2780
printf(1," %d ," , queue[i]);
}
printf(1, "item: %d out : %d error! i am trying to ovride value : %d\n",item,out, queue[(item-1)%100]);
return;
}
queue[(item-1)%100] = item;
123: 89 3c 9d e0 1c 00 00 mov %edi,0x1ce0(,%ebx,4)
csem_up(&mutax);
12a: e8 e1 12 00 00 call 1410 <csem_up>
csem_up(&full);
12f: c7 04 24 c0 1c 00 00 movl $0x1cc0,(%esp)
136: e8 d5 12 00 00 call 1410 <csem_up>
int queue[N];
void producer(void* arg)
{
int item = 0;
while (item < 1000)
13b: 83 c4 10 add $0x10,%esp
13e: 81 ff e8 03 00 00 cmp $0x3e8,%edi
144: 0f 84 93 00 00 00 je 1dd <producer+0xdd>
{
item += 1; // producing an item
csem_down(&empty);
14a: 83 ec 0c sub $0xc,%esp
void producer(void* arg)
{
int item = 0;
while (item < 1000)
{
item += 1; // producing an item
14d: 8d 47 01 lea 0x1(%edi),%eax
csem_down(&empty);
150: 68 8c 27 00 00 push $0x278c
void producer(void* arg)
{
int item = 0;
while (item < 1000)
{
item += 1; // producing an item
155: 89 45 e4 mov %eax,-0x1c(%ebp)
csem_down(&empty);
158: e8 63 12 00 00 call 13c0 <csem_down>
csem_down(&mutax);
15d: c7 04 24 80 27 00 00 movl $0x2780,(%esp)
164: e8 57 12 00 00 call 13c0 <csem_down>
if(queue[(item-1)%100] != 0)
169: 89 f8 mov %edi,%eax
16b: 83 c4 10 add $0x10,%esp
16e: f7 ee imul %esi
170: 89 f8 mov %edi,%eax
172: c1 f8 1f sar $0x1f,%eax
175: c1 fa 05 sar $0x5,%edx
178: 29 c2 sub %eax,%edx
17a: 6b da 64 imul $0x64,%edx,%ebx
17d: 29 df sub %ebx,%edi
17f: 8b 04 bd e0 1c 00 00 mov 0x1ce0(,%edi,4),%eax
186: 89 fb mov %edi,%ebx
188: 85 c0 test %eax,%eax
18a: 74 8c je 118 <producer+0x18>
18c: bf e0 1c 00 00 mov $0x1ce0,%edi
191: be 70 1e 00 00 mov $0x1e70,%esi
196: 8d 76 00 lea 0x0(%esi),%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
{
for(int i = 0 ; i<N ; i++){
printf(1," %d ," , queue[i]);
1a0: 83 ec 04 sub $0x4,%esp
1a3: ff 37 pushl (%edi)
1a5: 83 c7 04 add $0x4,%edi
1a8: 68 5c 14 00 00 push $0x145c
1ad: 6a 01 push $0x1
1af: e8 bc 04 00 00 call 670 <printf>
item += 1; // producing an item
csem_down(&empty);
csem_down(&mutax);
if(queue[(item-1)%100] != 0)
{
for(int i = 0 ; i<N ; i++){
1b4: 83 c4 10 add $0x10,%esp
1b7: 39 fe cmp %edi,%esi
1b9: 75 e5 jne 1a0 <producer+0xa0>
printf(1," %d ," , queue[i]);
}
printf(1, "item: %d out : %d error! i am trying to ovride value : %d\n",item,out, queue[(item-1)%100]);
1bb: 83 ec 0c sub $0xc,%esp
1be: ff 34 9d e0 1c 00 00 pushl 0x1ce0(,%ebx,4)
1c5: ff 35 a0 1c 00 00 pushl 0x1ca0
1cb: ff 75 e4 pushl -0x1c(%ebp)
1ce: 68 64 14 00 00 push $0x1464
1d3: 6a 01 push $0x1
1d5: e8 96 04 00 00 call 670 <printf>
return;
1da: 83 c4 20 add $0x20,%esp
}
queue[(item-1)%100] = item;
csem_up(&mutax);
csem_up(&full);
}
}
1dd: 8d 65 f4 lea -0xc(%ebp),%esp
1e0: 5b pop %ebx
1e1: 5e pop %esi
1e2: 5f pop %edi
1e3: 5d pop %ebp
1e4: c3 ret
1e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001f0 <consumer>:
void consumer(void *arg)
{
int item = 0;
while (out < 1000)
1f0: 81 3d a0 1c 00 00 e7 cmpl $0x3e7,0x1ca0
1f7: 03 00 00
1fa: 0f 8f b7 00 00 00 jg 2b7 <consumer+0xc7>
csem_up(&full);
}
}
void consumer(void *arg)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 56 push %esi
204: 53 push %ebx
205: be 1f 85 eb 51 mov $0x51eb851f,%esi
20a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
int item = 0;
while (out < 1000)
{
csem_down(&full);
210: 83 ec 0c sub $0xc,%esp
213: 68 c0 1c 00 00 push $0x1cc0
218: e8 a3 11 00 00 call 13c0 <csem_down>
csem_down(&mutax);
21d: c7 04 24 80 27 00 00 movl $0x2780,(%esp)
224: e8 97 11 00 00 call 13c0 <csem_down>
item = queue[out%100];
229: 8b 0d a0 1c 00 00 mov 0x1ca0,%ecx
queue[out%100] = 0;
if(out <= 1000)
22f: 83 c4 10 add $0x10,%esp
int item = 0;
while (out < 1000)
{
csem_down(&full);
csem_down(&mutax);
item = queue[out%100];
232: 89 c8 mov %ecx,%eax
234: f7 ee imul %esi
236: 89 c8 mov %ecx,%eax
238: c1 f8 1f sar $0x1f,%eax
23b: c1 fa 05 sar $0x5,%edx
23e: 29 c2 sub %eax,%edx
240: 89 c8 mov %ecx,%eax
242: 6b d2 64 imul $0x64,%edx,%edx
245: 29 d0 sub %edx,%eax
queue[out%100] = 0;
if(out <= 1000)
247: 81 f9 e8 03 00 00 cmp $0x3e8,%ecx
int item = 0;
while (out < 1000)
{
csem_down(&full);
csem_down(&mutax);
item = queue[out%100];
24d: 8b 1c 85 e0 1c 00 00 mov 0x1ce0(,%eax,4),%ebx
queue[out%100] = 0;
254: c7 04 85 e0 1c 00 00 movl $0x0,0x1ce0(,%eax,4)
25b: 00 00 00 00
if(out <= 1000)
25f: 7f 09 jg 26a <consumer+0x7a>
{
out++;
261: 83 c1 01 add $0x1,%ecx
264: 89 0d a0 1c 00 00 mov %ecx,0x1ca0
}
csem_up(&mutax);
26a: 83 ec 0c sub $0xc,%esp
26d: 68 80 27 00 00 push $0x2780
272: e8 99 11 00 00 call 1410 <csem_up>
csem_up(&empty);
277: c7 04 24 8c 27 00 00 movl $0x278c,(%esp)
27e: e8 8d 11 00 00 call 1410 <csem_up>
uthread_sleep(item);
283: 89 1c 24 mov %ebx,(%esp)
286: e8 85 10 00 00 call 1310 <uthread_sleep>
printf(1, "Thread %d slept for %d ticks.\n",uthread_self(), item);
28b: e8 90 0f 00 00 call 1220 <uthread_self>
290: 53 push %ebx
291: 50 push %eax
292: 68 a0 14 00 00 push $0x14a0
297: 6a 01 push $0x1
299: e8 d2 03 00 00 call 670 <printf>
}
void consumer(void *arg)
{
int item = 0;
while (out < 1000)
29e: 83 c4 20 add $0x20,%esp
2a1: 81 3d a0 1c 00 00 e7 cmpl $0x3e7,0x1ca0
2a8: 03 00 00
2ab: 0f 8e 5f ff ff ff jle 210 <consumer+0x20>
csem_up(&empty);
uthread_sleep(item);
printf(1, "Thread %d slept for %d ticks.\n",uthread_self(), item);
}
}
2b1: 8d 65 f8 lea -0x8(%ebp),%esp
2b4: 5b pop %ebx
2b5: 5e pop %esi
2b6: 5d pop %ebp
2b7: f3 c3 repz ret
2b9: 66 90 xchg %ax,%ax
2bb: 66 90 xchg %ax,%ax
2bd: 66 90 xchg %ax,%ax
2bf: 90 nop
000002c0 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
2c0: 55 push %ebp
2c1: 89 e5 mov %esp,%ebp
2c3: 53 push %ebx
2c4: 8b 45 08 mov 0x8(%ebp),%eax
2c7: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
2ca: 89 c2 mov %eax,%edx
2cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2d0: 83 c1 01 add $0x1,%ecx
2d3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
2d7: 83 c2 01 add $0x1,%edx
2da: 84 db test %bl,%bl
2dc: 88 5a ff mov %bl,-0x1(%edx)
2df: 75 ef jne 2d0 <strcpy+0x10>
;
return os;
}
2e1: 5b pop %ebx
2e2: 5d pop %ebp
2e3: c3 ret
2e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
2ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000002f0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
2f0: 55 push %ebp
2f1: 89 e5 mov %esp,%ebp
2f3: 56 push %esi
2f4: 53 push %ebx
2f5: 8b 55 08 mov 0x8(%ebp),%edx
2f8: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
2fb: 0f b6 02 movzbl (%edx),%eax
2fe: 0f b6 19 movzbl (%ecx),%ebx
301: 84 c0 test %al,%al
303: 75 1e jne 323 <strcmp+0x33>
305: eb 29 jmp 330 <strcmp+0x40>
307: 89 f6 mov %esi,%esi
309: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
310: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
313: 0f b6 02 movzbl (%edx),%eax
p++, q++;
316: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
319: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
31d: 84 c0 test %al,%al
31f: 74 0f je 330 <strcmp+0x40>
321: 89 f1 mov %esi,%ecx
323: 38 d8 cmp %bl,%al
325: 74 e9 je 310 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
327: 29 d8 sub %ebx,%eax
}
329: 5b pop %ebx
32a: 5e pop %esi
32b: 5d pop %ebp
32c: c3 ret
32d: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
330: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
332: 29 d8 sub %ebx,%eax
}
334: 5b pop %ebx
335: 5e pop %esi
336: 5d pop %ebp
337: c3 ret
338: 90 nop
339: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000340 <strlen>:
uint
strlen(char *s)
{
340: 55 push %ebp
341: 89 e5 mov %esp,%ebp
343: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
346: 80 39 00 cmpb $0x0,(%ecx)
349: 74 12 je 35d <strlen+0x1d>
34b: 31 d2 xor %edx,%edx
34d: 8d 76 00 lea 0x0(%esi),%esi
350: 83 c2 01 add $0x1,%edx
353: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
357: 89 d0 mov %edx,%eax
359: 75 f5 jne 350 <strlen+0x10>
;
return n;
}
35b: 5d pop %ebp
35c: c3 ret
uint
strlen(char *s)
{
int n;
for(n = 0; s[n]; n++)
35d: 31 c0 xor %eax,%eax
;
return n;
}
35f: 5d pop %ebp
360: c3 ret
361: eb 0d jmp 370 <memset>
363: 90 nop
364: 90 nop
365: 90 nop
366: 90 nop
367: 90 nop
368: 90 nop
369: 90 nop
36a: 90 nop
36b: 90 nop
36c: 90 nop
36d: 90 nop
36e: 90 nop
36f: 90 nop
00000370 <memset>:
void*
memset(void *dst, int c, uint n)
{
370: 55 push %ebp
371: 89 e5 mov %esp,%ebp
373: 57 push %edi
374: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
377: 8b 4d 10 mov 0x10(%ebp),%ecx
37a: 8b 45 0c mov 0xc(%ebp),%eax
37d: 89 d7 mov %edx,%edi
37f: fc cld
380: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
382: 89 d0 mov %edx,%eax
384: 5f pop %edi
385: 5d pop %ebp
386: c3 ret
387: 89 f6 mov %esi,%esi
389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000390 <strchr>:
char*
strchr(const char *s, char c)
{
390: 55 push %ebp
391: 89 e5 mov %esp,%ebp
393: 53 push %ebx
394: 8b 45 08 mov 0x8(%ebp),%eax
397: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
39a: 0f b6 10 movzbl (%eax),%edx
39d: 84 d2 test %dl,%dl
39f: 74 1d je 3be <strchr+0x2e>
if(*s == c)
3a1: 38 d3 cmp %dl,%bl
3a3: 89 d9 mov %ebx,%ecx
3a5: 75 0d jne 3b4 <strchr+0x24>
3a7: eb 17 jmp 3c0 <strchr+0x30>
3a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3b0: 38 ca cmp %cl,%dl
3b2: 74 0c je 3c0 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
3b4: 83 c0 01 add $0x1,%eax
3b7: 0f b6 10 movzbl (%eax),%edx
3ba: 84 d2 test %dl,%dl
3bc: 75 f2 jne 3b0 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
3be: 31 c0 xor %eax,%eax
}
3c0: 5b pop %ebx
3c1: 5d pop %ebp
3c2: c3 ret
3c3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000003d0 <gets>:
char*
gets(char *buf, int max)
{
3d0: 55 push %ebp
3d1: 89 e5 mov %esp,%ebp
3d3: 57 push %edi
3d4: 56 push %esi
3d5: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
3d6: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
3d8: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
3db: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
3de: eb 29 jmp 409 <gets+0x39>
cc = read(0, &c, 1);
3e0: 83 ec 04 sub $0x4,%esp
3e3: 6a 01 push $0x1
3e5: 57 push %edi
3e6: 6a 00 push $0x0
3e8: e8 2d 01 00 00 call 51a <read>
if(cc < 1)
3ed: 83 c4 10 add $0x10,%esp
3f0: 85 c0 test %eax,%eax
3f2: 7e 1d jle 411 <gets+0x41>
break;
buf[i++] = c;
3f4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
3f8: 8b 55 08 mov 0x8(%ebp),%edx
3fb: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
3fd: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
3ff: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
403: 74 1b je 420 <gets+0x50>
405: 3c 0d cmp $0xd,%al
407: 74 17 je 420 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
409: 8d 5e 01 lea 0x1(%esi),%ebx
40c: 3b 5d 0c cmp 0xc(%ebp),%ebx
40f: 7c cf jl 3e0 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
411: 8b 45 08 mov 0x8(%ebp),%eax
414: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
418: 8d 65 f4 lea -0xc(%ebp),%esp
41b: 5b pop %ebx
41c: 5e pop %esi
41d: 5f pop %edi
41e: 5d pop %ebp
41f: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
420: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
423: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
425: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
429: 8d 65 f4 lea -0xc(%ebp),%esp
42c: 5b pop %ebx
42d: 5e pop %esi
42e: 5f pop %edi
42f: 5d pop %ebp
430: c3 ret
431: eb 0d jmp 440 <stat>
433: 90 nop
434: 90 nop
435: 90 nop
436: 90 nop
437: 90 nop
438: 90 nop
439: 90 nop
43a: 90 nop
43b: 90 nop
43c: 90 nop
43d: 90 nop
43e: 90 nop
43f: 90 nop
00000440 <stat>:
int
stat(char *n, struct stat *st)
{
440: 55 push %ebp
441: 89 e5 mov %esp,%ebp
443: 56 push %esi
444: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
445: 83 ec 08 sub $0x8,%esp
448: 6a 00 push $0x0
44a: ff 75 08 pushl 0x8(%ebp)
44d: e8 f0 00 00 00 call 542 <open>
if(fd < 0)
452: 83 c4 10 add $0x10,%esp
455: 85 c0 test %eax,%eax
457: 78 27 js 480 <stat+0x40>
return -1;
r = fstat(fd, st);
459: 83 ec 08 sub $0x8,%esp
45c: ff 75 0c pushl 0xc(%ebp)
45f: 89 c3 mov %eax,%ebx
461: 50 push %eax
462: e8 f3 00 00 00 call 55a <fstat>
467: 89 c6 mov %eax,%esi
close(fd);
469: 89 1c 24 mov %ebx,(%esp)
46c: e8 b9 00 00 00 call 52a <close>
return r;
471: 83 c4 10 add $0x10,%esp
474: 89 f0 mov %esi,%eax
}
476: 8d 65 f8 lea -0x8(%ebp),%esp
479: 5b pop %ebx
47a: 5e pop %esi
47b: 5d pop %ebp
47c: c3 ret
47d: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
480: b8 ff ff ff ff mov $0xffffffff,%eax
485: eb ef jmp 476 <stat+0x36>
487: 89 f6 mov %esi,%esi
489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000490 <atoi>:
return r;
}
int
atoi(const char *s)
{
490: 55 push %ebp
491: 89 e5 mov %esp,%ebp
493: 53 push %ebx
494: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
497: 0f be 11 movsbl (%ecx),%edx
49a: 8d 42 d0 lea -0x30(%edx),%eax
49d: 3c 09 cmp $0x9,%al
49f: b8 00 00 00 00 mov $0x0,%eax
4a4: 77 1f ja 4c5 <atoi+0x35>
4a6: 8d 76 00 lea 0x0(%esi),%esi
4a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
4b0: 8d 04 80 lea (%eax,%eax,4),%eax
4b3: 83 c1 01 add $0x1,%ecx
4b6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
4ba: 0f be 11 movsbl (%ecx),%edx
4bd: 8d 5a d0 lea -0x30(%edx),%ebx
4c0: 80 fb 09 cmp $0x9,%bl
4c3: 76 eb jbe 4b0 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
4c5: 5b pop %ebx
4c6: 5d pop %ebp
4c7: c3 ret
4c8: 90 nop
4c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000004d0 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
4d0: 55 push %ebp
4d1: 89 e5 mov %esp,%ebp
4d3: 56 push %esi
4d4: 53 push %ebx
4d5: 8b 5d 10 mov 0x10(%ebp),%ebx
4d8: 8b 45 08 mov 0x8(%ebp),%eax
4db: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
4de: 85 db test %ebx,%ebx
4e0: 7e 14 jle 4f6 <memmove+0x26>
4e2: 31 d2 xor %edx,%edx
4e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
4e8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
4ec: 88 0c 10 mov %cl,(%eax,%edx,1)
4ef: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
4f2: 39 da cmp %ebx,%edx
4f4: 75 f2 jne 4e8 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
4f6: 5b pop %ebx
4f7: 5e pop %esi
4f8: 5d pop %ebp
4f9: c3 ret
000004fa <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
4fa: b8 01 00 00 00 mov $0x1,%eax
4ff: cd 40 int $0x40
501: c3 ret
00000502 <exit>:
SYSCALL(exit)
502: b8 02 00 00 00 mov $0x2,%eax
507: cd 40 int $0x40
509: c3 ret
0000050a <wait>:
SYSCALL(wait)
50a: b8 03 00 00 00 mov $0x3,%eax
50f: cd 40 int $0x40
511: c3 ret
00000512 <pipe>:
SYSCALL(pipe)
512: b8 04 00 00 00 mov $0x4,%eax
517: cd 40 int $0x40
519: c3 ret
0000051a <read>:
SYSCALL(read)
51a: b8 05 00 00 00 mov $0x5,%eax
51f: cd 40 int $0x40
521: c3 ret
00000522 <write>:
SYSCALL(write)
522: b8 10 00 00 00 mov $0x10,%eax
527: cd 40 int $0x40
529: c3 ret
0000052a <close>:
SYSCALL(close)
52a: b8 15 00 00 00 mov $0x15,%eax
52f: cd 40 int $0x40
531: c3 ret
00000532 <kill>:
SYSCALL(kill)
532: b8 06 00 00 00 mov $0x6,%eax
537: cd 40 int $0x40
539: c3 ret
0000053a <exec>:
SYSCALL(exec)
53a: b8 07 00 00 00 mov $0x7,%eax
53f: cd 40 int $0x40
541: c3 ret
00000542 <open>:
SYSCALL(open)
542: b8 0f 00 00 00 mov $0xf,%eax
547: cd 40 int $0x40
549: c3 ret
0000054a <mknod>:
SYSCALL(mknod)
54a: b8 11 00 00 00 mov $0x11,%eax
54f: cd 40 int $0x40
551: c3 ret
00000552 <unlink>:
SYSCALL(unlink)
552: b8 12 00 00 00 mov $0x12,%eax
557: cd 40 int $0x40
559: c3 ret
0000055a <fstat>:
SYSCALL(fstat)
55a: b8 08 00 00 00 mov $0x8,%eax
55f: cd 40 int $0x40
561: c3 ret
00000562 <link>:
SYSCALL(link)
562: b8 13 00 00 00 mov $0x13,%eax
567: cd 40 int $0x40
569: c3 ret
0000056a <mkdir>:
SYSCALL(mkdir)
56a: b8 14 00 00 00 mov $0x14,%eax
56f: cd 40 int $0x40
571: c3 ret