-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.asm
More file actions
1451 lines (1351 loc) · 49.2 KB
/
date.asm
File metadata and controls
1451 lines (1351 loc) · 49.2 KB
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
_date: file format elf32-i386
Disassembly of section .text:
00000000 <dayofweek>:
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
int
dayofweek(int y, int m, int d)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
return (d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7;
4: 83 7d 0c 02 cmpl $0x2,0xc(%ebp)
8: 7f 0b jg 15 <dayofweek+0x15>
a: 8b 45 08 mov 0x8(%ebp),%eax
d: 8d 50 ff lea -0x1(%eax),%edx
10: 89 55 08 mov %edx,0x8(%ebp)
13: eb 06 jmp 1b <dayofweek+0x1b>
15: 8b 45 08 mov 0x8(%ebp),%eax
18: 83 e8 02 sub $0x2,%eax
1b: 01 45 10 add %eax,0x10(%ebp)
1e: 8b 45 0c mov 0xc(%ebp),%eax
21: 6b c8 17 imul $0x17,%eax,%ecx
24: ba 39 8e e3 38 mov $0x38e38e39,%edx
29: 89 c8 mov %ecx,%eax
2b: f7 ea imul %edx
2d: d1 fa sar %edx
2f: 89 c8 mov %ecx,%eax
31: c1 f8 1f sar $0x1f,%eax
34: 29 c2 sub %eax,%edx
36: 8b 45 10 mov 0x10(%ebp),%eax
39: 01 d0 add %edx,%eax
3b: 8d 48 04 lea 0x4(%eax),%ecx
3e: 8b 45 08 mov 0x8(%ebp),%eax
41: 8d 50 03 lea 0x3(%eax),%edx
44: 85 c0 test %eax,%eax
46: 0f 48 c2 cmovs %edx,%eax
49: c1 f8 02 sar $0x2,%eax
4c: 8d 1c 01 lea (%ecx,%eax,1),%ebx
4f: 8b 4d 08 mov 0x8(%ebp),%ecx
52: ba 1f 85 eb 51 mov $0x51eb851f,%edx
57: 89 c8 mov %ecx,%eax
59: f7 ea imul %edx
5b: c1 fa 05 sar $0x5,%edx
5e: 89 c8 mov %ecx,%eax
60: c1 f8 1f sar $0x1f,%eax
63: 29 c2 sub %eax,%edx
65: 89 d0 mov %edx,%eax
67: 29 c3 sub %eax,%ebx
69: 8b 4d 08 mov 0x8(%ebp),%ecx
6c: ba 1f 85 eb 51 mov $0x51eb851f,%edx
71: 89 c8 mov %ecx,%eax
73: f7 ea imul %edx
75: c1 fa 07 sar $0x7,%edx
78: 89 c8 mov %ecx,%eax
7a: c1 f8 1f sar $0x1f,%eax
7d: 29 c2 sub %eax,%edx
7f: 89 d0 mov %edx,%eax
81: 8d 0c 03 lea (%ebx,%eax,1),%ecx
84: ba 93 24 49 92 mov $0x92492493,%edx
89: 89 c8 mov %ecx,%eax
8b: f7 ea imul %edx
8d: 8d 04 0a lea (%edx,%ecx,1),%eax
90: c1 f8 02 sar $0x2,%eax
93: 89 c2 mov %eax,%edx
95: 89 c8 mov %ecx,%eax
97: c1 f8 1f sar $0x1f,%eax
9a: 29 c2 sub %eax,%edx
9c: 89 d0 mov %edx,%eax
9e: 89 c2 mov %eax,%edx
a0: c1 e2 03 shl $0x3,%edx
a3: 29 c2 sub %eax,%edx
a5: 89 c8 mov %ecx,%eax
a7: 29 d0 sub %edx,%eax
}
a9: 5b pop %ebx
aa: 5d pop %ebp
ab: c3 ret
000000ac <main>:
int
main(int argc, char *argv[])
{
ac: 8d 4c 24 04 lea 0x4(%esp),%ecx
b0: 83 e4 f0 and $0xfffffff0,%esp
b3: ff 71 fc pushl -0x4(%ecx)
b6: 55 push %ebp
b7: 89 e5 mov %esp,%ebp
b9: 53 push %ebx
ba: 51 push %ecx
bb: 83 ec 20 sub $0x20,%esp
int day;
struct rtcdate r;
if (date(&r)) {
be: 83 ec 0c sub $0xc,%esp
c1: 8d 45 dc lea -0x24(%ebp),%eax
c4: 50 push %eax
c5: e8 20 04 00 00 call 4ea <date>
ca: 83 c4 10 add $0x10,%esp
cd: 85 c0 test %eax,%eax
cf: 74 1b je ec <main+0x40>
printf(2,"Error: date call failed. %s at line %d\n", __FILE__, __LINE__);
d1: 6a 19 push $0x19
d3: 68 21 0a 00 00 push $0xa21
d8: 68 28 0a 00 00 push $0xa28
dd: 6a 02 push $0x2
df: e8 35 05 00 00 call 619 <printf>
e4: 83 c4 10 add $0x10,%esp
exit();
e7: e8 56 03 00 00 call 442 <exit>
}
day = dayofweek(r.year, r.month, r.day);
ec: 8b 45 e8 mov -0x18(%ebp),%eax
ef: 89 c1 mov %eax,%ecx
f1: 8b 45 ec mov -0x14(%ebp),%eax
f4: 89 c2 mov %eax,%edx
f6: 8b 45 f0 mov -0x10(%ebp),%eax
f9: 83 ec 04 sub $0x4,%esp
fc: 51 push %ecx
fd: 52 push %edx
fe: 50 push %eax
ff: e8 fc fe ff ff call 0 <dayofweek>
104: 83 c4 10 add $0x10,%esp
107: 89 45 f4 mov %eax,-0xc(%ebp)
printf(1, "%s %s %d", days[day], months[r.month], r.day);
10a: 8b 4d e8 mov -0x18(%ebp),%ecx
10d: 8b 45 ec mov -0x14(%ebp),%eax
110: 8b 14 85 20 0d 00 00 mov 0xd20(,%eax,4),%edx
117: 8b 45 f4 mov -0xc(%ebp),%eax
11a: 8b 04 85 54 0d 00 00 mov 0xd54(,%eax,4),%eax
121: 83 ec 0c sub $0xc,%esp
124: 51 push %ecx
125: 52 push %edx
126: 50 push %eax
127: 68 50 0a 00 00 push $0xa50
12c: 6a 01 push $0x1
12e: e8 e6 04 00 00 call 619 <printf>
133: 83 c4 20 add $0x20,%esp
printf(1, " %d:%d:%d UTC %d\n", r.hour, r.minute, r.second, r.year);
136: 8b 5d f0 mov -0x10(%ebp),%ebx
139: 8b 4d dc mov -0x24(%ebp),%ecx
13c: 8b 55 e0 mov -0x20(%ebp),%edx
13f: 8b 45 e4 mov -0x1c(%ebp),%eax
142: 83 ec 08 sub $0x8,%esp
145: 53 push %ebx
146: 51 push %ecx
147: 52 push %edx
148: 50 push %eax
149: 68 59 0a 00 00 push $0xa59
14e: 6a 01 push $0x1
150: e8 c4 04 00 00 call 619 <printf>
155: 83 c4 20 add $0x20,%esp
exit();
158: e8 e5 02 00 00 call 442 <exit>
0000015d <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
15d: 55 push %ebp
15e: 89 e5 mov %esp,%ebp
160: 57 push %edi
161: 53 push %ebx
asm volatile("cld; rep stosb" :
162: 8b 4d 08 mov 0x8(%ebp),%ecx
165: 8b 55 10 mov 0x10(%ebp),%edx
168: 8b 45 0c mov 0xc(%ebp),%eax
16b: 89 cb mov %ecx,%ebx
16d: 89 df mov %ebx,%edi
16f: 89 d1 mov %edx,%ecx
171: fc cld
172: f3 aa rep stos %al,%es:(%edi)
174: 89 ca mov %ecx,%edx
176: 89 fb mov %edi,%ebx
178: 89 5d 08 mov %ebx,0x8(%ebp)
17b: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
17e: 90 nop
17f: 5b pop %ebx
180: 5f pop %edi
181: 5d pop %ebp
182: c3 ret
00000183 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
183: 55 push %ebp
184: 89 e5 mov %esp,%ebp
186: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
189: 8b 45 08 mov 0x8(%ebp),%eax
18c: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
18f: 90 nop
190: 8b 45 08 mov 0x8(%ebp),%eax
193: 8d 50 01 lea 0x1(%eax),%edx
196: 89 55 08 mov %edx,0x8(%ebp)
199: 8b 55 0c mov 0xc(%ebp),%edx
19c: 8d 4a 01 lea 0x1(%edx),%ecx
19f: 89 4d 0c mov %ecx,0xc(%ebp)
1a2: 0f b6 12 movzbl (%edx),%edx
1a5: 88 10 mov %dl,(%eax)
1a7: 0f b6 00 movzbl (%eax),%eax
1aa: 84 c0 test %al,%al
1ac: 75 e2 jne 190 <strcpy+0xd>
;
return os;
1ae: 8b 45 fc mov -0x4(%ebp),%eax
}
1b1: c9 leave
1b2: c3 ret
000001b3 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1b3: 55 push %ebp
1b4: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
1b6: eb 08 jmp 1c0 <strcmp+0xd>
p++, q++;
1b8: 83 45 08 01 addl $0x1,0x8(%ebp)
1bc: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1c0: 8b 45 08 mov 0x8(%ebp),%eax
1c3: 0f b6 00 movzbl (%eax),%eax
1c6: 84 c0 test %al,%al
1c8: 74 10 je 1da <strcmp+0x27>
1ca: 8b 45 08 mov 0x8(%ebp),%eax
1cd: 0f b6 10 movzbl (%eax),%edx
1d0: 8b 45 0c mov 0xc(%ebp),%eax
1d3: 0f b6 00 movzbl (%eax),%eax
1d6: 38 c2 cmp %al,%dl
1d8: 74 de je 1b8 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1da: 8b 45 08 mov 0x8(%ebp),%eax
1dd: 0f b6 00 movzbl (%eax),%eax
1e0: 0f b6 d0 movzbl %al,%edx
1e3: 8b 45 0c mov 0xc(%ebp),%eax
1e6: 0f b6 00 movzbl (%eax),%eax
1e9: 0f b6 c0 movzbl %al,%eax
1ec: 29 c2 sub %eax,%edx
1ee: 89 d0 mov %edx,%eax
}
1f0: 5d pop %ebp
1f1: c3 ret
000001f2 <strlen>:
uint
strlen(char *s)
{
1f2: 55 push %ebp
1f3: 89 e5 mov %esp,%ebp
1f5: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1f8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1ff: eb 04 jmp 205 <strlen+0x13>
201: 83 45 fc 01 addl $0x1,-0x4(%ebp)
205: 8b 55 fc mov -0x4(%ebp),%edx
208: 8b 45 08 mov 0x8(%ebp),%eax
20b: 01 d0 add %edx,%eax
20d: 0f b6 00 movzbl (%eax),%eax
210: 84 c0 test %al,%al
212: 75 ed jne 201 <strlen+0xf>
;
return n;
214: 8b 45 fc mov -0x4(%ebp),%eax
}
217: c9 leave
218: c3 ret
00000219 <memset>:
void*
memset(void *dst, int c, uint n)
{
219: 55 push %ebp
21a: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
21c: 8b 45 10 mov 0x10(%ebp),%eax
21f: 50 push %eax
220: ff 75 0c pushl 0xc(%ebp)
223: ff 75 08 pushl 0x8(%ebp)
226: e8 32 ff ff ff call 15d <stosb>
22b: 83 c4 0c add $0xc,%esp
return dst;
22e: 8b 45 08 mov 0x8(%ebp),%eax
}
231: c9 leave
232: c3 ret
00000233 <strchr>:
char*
strchr(const char *s, char c)
{
233: 55 push %ebp
234: 89 e5 mov %esp,%ebp
236: 83 ec 04 sub $0x4,%esp
239: 8b 45 0c mov 0xc(%ebp),%eax
23c: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
23f: eb 14 jmp 255 <strchr+0x22>
if(*s == c)
241: 8b 45 08 mov 0x8(%ebp),%eax
244: 0f b6 00 movzbl (%eax),%eax
247: 3a 45 fc cmp -0x4(%ebp),%al
24a: 75 05 jne 251 <strchr+0x1e>
return (char*)s;
24c: 8b 45 08 mov 0x8(%ebp),%eax
24f: eb 13 jmp 264 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
251: 83 45 08 01 addl $0x1,0x8(%ebp)
255: 8b 45 08 mov 0x8(%ebp),%eax
258: 0f b6 00 movzbl (%eax),%eax
25b: 84 c0 test %al,%al
25d: 75 e2 jne 241 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
25f: b8 00 00 00 00 mov $0x0,%eax
}
264: c9 leave
265: c3 ret
00000266 <gets>:
char*
gets(char *buf, int max)
{
266: 55 push %ebp
267: 89 e5 mov %esp,%ebp
269: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
26c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
273: eb 42 jmp 2b7 <gets+0x51>
cc = read(0, &c, 1);
275: 83 ec 04 sub $0x4,%esp
278: 6a 01 push $0x1
27a: 8d 45 ef lea -0x11(%ebp),%eax
27d: 50 push %eax
27e: 6a 00 push $0x0
280: e8 d5 01 00 00 call 45a <read>
285: 83 c4 10 add $0x10,%esp
288: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
28b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
28f: 7e 33 jle 2c4 <gets+0x5e>
break;
buf[i++] = c;
291: 8b 45 f4 mov -0xc(%ebp),%eax
294: 8d 50 01 lea 0x1(%eax),%edx
297: 89 55 f4 mov %edx,-0xc(%ebp)
29a: 89 c2 mov %eax,%edx
29c: 8b 45 08 mov 0x8(%ebp),%eax
29f: 01 c2 add %eax,%edx
2a1: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2a5: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
2a7: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2ab: 3c 0a cmp $0xa,%al
2ad: 74 16 je 2c5 <gets+0x5f>
2af: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2b3: 3c 0d cmp $0xd,%al
2b5: 74 0e je 2c5 <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
2b7: 8b 45 f4 mov -0xc(%ebp),%eax
2ba: 83 c0 01 add $0x1,%eax
2bd: 3b 45 0c cmp 0xc(%ebp),%eax
2c0: 7c b3 jl 275 <gets+0xf>
2c2: eb 01 jmp 2c5 <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
2c4: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2c5: 8b 55 f4 mov -0xc(%ebp),%edx
2c8: 8b 45 08 mov 0x8(%ebp),%eax
2cb: 01 d0 add %edx,%eax
2cd: c6 00 00 movb $0x0,(%eax)
return buf;
2d0: 8b 45 08 mov 0x8(%ebp),%eax
}
2d3: c9 leave
2d4: c3 ret
000002d5 <stat>:
int
stat(char *n, struct stat *st)
{
2d5: 55 push %ebp
2d6: 89 e5 mov %esp,%ebp
2d8: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
2db: 83 ec 08 sub $0x8,%esp
2de: 6a 00 push $0x0
2e0: ff 75 08 pushl 0x8(%ebp)
2e3: e8 9a 01 00 00 call 482 <open>
2e8: 83 c4 10 add $0x10,%esp
2eb: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
2ee: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2f2: 79 07 jns 2fb <stat+0x26>
return -1;
2f4: b8 ff ff ff ff mov $0xffffffff,%eax
2f9: eb 25 jmp 320 <stat+0x4b>
r = fstat(fd, st);
2fb: 83 ec 08 sub $0x8,%esp
2fe: ff 75 0c pushl 0xc(%ebp)
301: ff 75 f4 pushl -0xc(%ebp)
304: e8 91 01 00 00 call 49a <fstat>
309: 83 c4 10 add $0x10,%esp
30c: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
30f: 83 ec 0c sub $0xc,%esp
312: ff 75 f4 pushl -0xc(%ebp)
315: e8 50 01 00 00 call 46a <close>
31a: 83 c4 10 add $0x10,%esp
return r;
31d: 8b 45 f0 mov -0x10(%ebp),%eax
}
320: c9 leave
321: c3 ret
00000322 <atoi>:
int
atoi(const char *s)
{
322: 55 push %ebp
323: 89 e5 mov %esp,%ebp
325: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
328: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
32f: eb 25 jmp 356 <atoi+0x34>
n = n*10 + *s++ - '0';
331: 8b 55 fc mov -0x4(%ebp),%edx
334: 89 d0 mov %edx,%eax
336: c1 e0 02 shl $0x2,%eax
339: 01 d0 add %edx,%eax
33b: 01 c0 add %eax,%eax
33d: 89 c1 mov %eax,%ecx
33f: 8b 45 08 mov 0x8(%ebp),%eax
342: 8d 50 01 lea 0x1(%eax),%edx
345: 89 55 08 mov %edx,0x8(%ebp)
348: 0f b6 00 movzbl (%eax),%eax
34b: 0f be c0 movsbl %al,%eax
34e: 01 c8 add %ecx,%eax
350: 83 e8 30 sub $0x30,%eax
353: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
356: 8b 45 08 mov 0x8(%ebp),%eax
359: 0f b6 00 movzbl (%eax),%eax
35c: 3c 2f cmp $0x2f,%al
35e: 7e 0a jle 36a <atoi+0x48>
360: 8b 45 08 mov 0x8(%ebp),%eax
363: 0f b6 00 movzbl (%eax),%eax
366: 3c 39 cmp $0x39,%al
368: 7e c7 jle 331 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
36a: 8b 45 fc mov -0x4(%ebp),%eax
}
36d: c9 leave
36e: c3 ret
0000036f <atoo>:
int
atoo(const char *s)
{
36f: 55 push %ebp
370: 89 e5 mov %esp,%ebp
372: 83 ec 10 sub $0x10,%esp
int n, sign;
n = 0;
375: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s == ' ')
37c: eb 04 jmp 382 <atoo+0x13>
s++;
37e: 83 45 08 01 addl $0x1,0x8(%ebp)
int
atoo(const char *s)
{
int n, sign;
n = 0;
while (*s == ' ')
382: 8b 45 08 mov 0x8(%ebp),%eax
385: 0f b6 00 movzbl (%eax),%eax
388: 3c 20 cmp $0x20,%al
38a: 74 f2 je 37e <atoo+0xf>
s++;
sign = (*s == '-') ? -1 : 1;
38c: 8b 45 08 mov 0x8(%ebp),%eax
38f: 0f b6 00 movzbl (%eax),%eax
392: 3c 2d cmp $0x2d,%al
394: 75 07 jne 39d <atoo+0x2e>
396: b8 ff ff ff ff mov $0xffffffff,%eax
39b: eb 05 jmp 3a2 <atoo+0x33>
39d: b8 01 00 00 00 mov $0x1,%eax
3a2: 89 45 f8 mov %eax,-0x8(%ebp)
if (*s == '+' || *s == '-')
3a5: 8b 45 08 mov 0x8(%ebp),%eax
3a8: 0f b6 00 movzbl (%eax),%eax
3ab: 3c 2b cmp $0x2b,%al
3ad: 74 0a je 3b9 <atoo+0x4a>
3af: 8b 45 08 mov 0x8(%ebp),%eax
3b2: 0f b6 00 movzbl (%eax),%eax
3b5: 3c 2d cmp $0x2d,%al
3b7: 75 27 jne 3e0 <atoo+0x71>
s++;
3b9: 83 45 08 01 addl $0x1,0x8(%ebp)
while ('0' <= *s && *s <= '7')
3bd: eb 21 jmp 3e0 <atoo+0x71>
n = n*8 + *s++ - '0';
3bf: 8b 45 fc mov -0x4(%ebp),%eax
3c2: 8d 0c c5 00 00 00 00 lea 0x0(,%eax,8),%ecx
3c9: 8b 45 08 mov 0x8(%ebp),%eax
3cc: 8d 50 01 lea 0x1(%eax),%edx
3cf: 89 55 08 mov %edx,0x8(%ebp)
3d2: 0f b6 00 movzbl (%eax),%eax
3d5: 0f be c0 movsbl %al,%eax
3d8: 01 c8 add %ecx,%eax
3da: 83 e8 30 sub $0x30,%eax
3dd: 89 45 fc mov %eax,-0x4(%ebp)
while (*s == ' ')
s++;
sign = (*s == '-') ? -1 : 1;
if (*s == '+' || *s == '-')
s++;
while ('0' <= *s && *s <= '7')
3e0: 8b 45 08 mov 0x8(%ebp),%eax
3e3: 0f b6 00 movzbl (%eax),%eax
3e6: 3c 2f cmp $0x2f,%al
3e8: 7e 0a jle 3f4 <atoo+0x85>
3ea: 8b 45 08 mov 0x8(%ebp),%eax
3ed: 0f b6 00 movzbl (%eax),%eax
3f0: 3c 37 cmp $0x37,%al
3f2: 7e cb jle 3bf <atoo+0x50>
n = n*8 + *s++ - '0';
return sign*n;
3f4: 8b 45 f8 mov -0x8(%ebp),%eax
3f7: 0f af 45 fc imul -0x4(%ebp),%eax
}
3fb: c9 leave
3fc: c3 ret
000003fd <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
3fd: 55 push %ebp
3fe: 89 e5 mov %esp,%ebp
400: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
403: 8b 45 08 mov 0x8(%ebp),%eax
406: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
409: 8b 45 0c mov 0xc(%ebp),%eax
40c: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
40f: eb 17 jmp 428 <memmove+0x2b>
*dst++ = *src++;
411: 8b 45 fc mov -0x4(%ebp),%eax
414: 8d 50 01 lea 0x1(%eax),%edx
417: 89 55 fc mov %edx,-0x4(%ebp)
41a: 8b 55 f8 mov -0x8(%ebp),%edx
41d: 8d 4a 01 lea 0x1(%edx),%ecx
420: 89 4d f8 mov %ecx,-0x8(%ebp)
423: 0f b6 12 movzbl (%edx),%edx
426: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
428: 8b 45 10 mov 0x10(%ebp),%eax
42b: 8d 50 ff lea -0x1(%eax),%edx
42e: 89 55 10 mov %edx,0x10(%ebp)
431: 85 c0 test %eax,%eax
433: 7f dc jg 411 <memmove+0x14>
*dst++ = *src++;
return vdst;
435: 8b 45 08 mov 0x8(%ebp),%eax
}
438: c9 leave
439: c3 ret
0000043a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
43a: b8 01 00 00 00 mov $0x1,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <exit>:
SYSCALL(exit)
442: b8 02 00 00 00 mov $0x2,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <wait>:
SYSCALL(wait)
44a: b8 03 00 00 00 mov $0x3,%eax
44f: cd 40 int $0x40
451: c3 ret
00000452 <pipe>:
SYSCALL(pipe)
452: b8 04 00 00 00 mov $0x4,%eax
457: cd 40 int $0x40
459: c3 ret
0000045a <read>:
SYSCALL(read)
45a: b8 05 00 00 00 mov $0x5,%eax
45f: cd 40 int $0x40
461: c3 ret
00000462 <write>:
SYSCALL(write)
462: b8 10 00 00 00 mov $0x10,%eax
467: cd 40 int $0x40
469: c3 ret
0000046a <close>:
SYSCALL(close)
46a: b8 15 00 00 00 mov $0x15,%eax
46f: cd 40 int $0x40
471: c3 ret
00000472 <kill>:
SYSCALL(kill)
472: b8 06 00 00 00 mov $0x6,%eax
477: cd 40 int $0x40
479: c3 ret
0000047a <exec>:
SYSCALL(exec)
47a: b8 07 00 00 00 mov $0x7,%eax
47f: cd 40 int $0x40
481: c3 ret
00000482 <open>:
SYSCALL(open)
482: b8 0f 00 00 00 mov $0xf,%eax
487: cd 40 int $0x40
489: c3 ret
0000048a <mknod>:
SYSCALL(mknod)
48a: b8 11 00 00 00 mov $0x11,%eax
48f: cd 40 int $0x40
491: c3 ret
00000492 <unlink>:
SYSCALL(unlink)
492: b8 12 00 00 00 mov $0x12,%eax
497: cd 40 int $0x40
499: c3 ret
0000049a <fstat>:
SYSCALL(fstat)
49a: b8 08 00 00 00 mov $0x8,%eax
49f: cd 40 int $0x40
4a1: c3 ret
000004a2 <link>:
SYSCALL(link)
4a2: b8 13 00 00 00 mov $0x13,%eax
4a7: cd 40 int $0x40
4a9: c3 ret
000004aa <mkdir>:
SYSCALL(mkdir)
4aa: b8 14 00 00 00 mov $0x14,%eax
4af: cd 40 int $0x40
4b1: c3 ret
000004b2 <chdir>:
SYSCALL(chdir)
4b2: b8 09 00 00 00 mov $0x9,%eax
4b7: cd 40 int $0x40
4b9: c3 ret
000004ba <dup>:
SYSCALL(dup)
4ba: b8 0a 00 00 00 mov $0xa,%eax
4bf: cd 40 int $0x40
4c1: c3 ret
000004c2 <getpid>:
SYSCALL(getpid)
4c2: b8 0b 00 00 00 mov $0xb,%eax
4c7: cd 40 int $0x40
4c9: c3 ret
000004ca <sbrk>:
SYSCALL(sbrk)
4ca: b8 0c 00 00 00 mov $0xc,%eax
4cf: cd 40 int $0x40
4d1: c3 ret
000004d2 <sleep>:
SYSCALL(sleep)
4d2: b8 0d 00 00 00 mov $0xd,%eax
4d7: cd 40 int $0x40
4d9: c3 ret
000004da <uptime>:
SYSCALL(uptime)
4da: b8 0e 00 00 00 mov $0xe,%eax
4df: cd 40 int $0x40
4e1: c3 ret
000004e2 <halt>:
SYSCALL(halt)
4e2: b8 16 00 00 00 mov $0x16,%eax
4e7: cd 40 int $0x40
4e9: c3 ret
000004ea <date>:
SYSCALL(date)
4ea: b8 17 00 00 00 mov $0x17,%eax
4ef: cd 40 int $0x40
4f1: c3 ret
000004f2 <getuid>:
SYSCALL(getuid)
4f2: b8 18 00 00 00 mov $0x18,%eax
4f7: cd 40 int $0x40
4f9: c3 ret
000004fa <getgid>:
SYSCALL(getgid)
4fa: b8 19 00 00 00 mov $0x19,%eax
4ff: cd 40 int $0x40
501: c3 ret
00000502 <getppid>:
SYSCALL(getppid)
502: b8 1a 00 00 00 mov $0x1a,%eax
507: cd 40 int $0x40
509: c3 ret
0000050a <setuid>:
SYSCALL(setuid)
50a: b8 1b 00 00 00 mov $0x1b,%eax
50f: cd 40 int $0x40
511: c3 ret
00000512 <setgid>:
SYSCALL(setgid)
512: b8 1c 00 00 00 mov $0x1c,%eax
517: cd 40 int $0x40
519: c3 ret
0000051a <getprocs>:
SYSCALL(getprocs)
51a: b8 1d 00 00 00 mov $0x1d,%eax
51f: cd 40 int $0x40
521: c3 ret
00000522 <setpriority>:
SYSCALL(setpriority)
522: b8 1e 00 00 00 mov $0x1e,%eax
527: cd 40 int $0x40
529: c3 ret
0000052a <chmod>:
SYSCALL(chmod)
52a: b8 1f 00 00 00 mov $0x1f,%eax
52f: cd 40 int $0x40
531: c3 ret
00000532 <chown>:
SYSCALL(chown)
532: b8 20 00 00 00 mov $0x20,%eax
537: cd 40 int $0x40
539: c3 ret
0000053a <chgrp>:
SYSCALL(chgrp)
53a: b8 21 00 00 00 mov $0x21,%eax
53f: cd 40 int $0x40
541: c3 ret
00000542 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
542: 55 push %ebp
543: 89 e5 mov %esp,%ebp
545: 83 ec 18 sub $0x18,%esp
548: 8b 45 0c mov 0xc(%ebp),%eax
54b: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
54e: 83 ec 04 sub $0x4,%esp
551: 6a 01 push $0x1
553: 8d 45 f4 lea -0xc(%ebp),%eax
556: 50 push %eax
557: ff 75 08 pushl 0x8(%ebp)
55a: e8 03 ff ff ff call 462 <write>
55f: 83 c4 10 add $0x10,%esp
}
562: 90 nop
563: c9 leave
564: c3 ret
00000565 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
565: 55 push %ebp
566: 89 e5 mov %esp,%ebp
568: 53 push %ebx
569: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
56c: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
573: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
577: 74 17 je 590 <printint+0x2b>
579: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
57d: 79 11 jns 590 <printint+0x2b>
neg = 1;
57f: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
586: 8b 45 0c mov 0xc(%ebp),%eax
589: f7 d8 neg %eax
58b: 89 45 ec mov %eax,-0x14(%ebp)
58e: eb 06 jmp 596 <printint+0x31>
} else {
x = xx;
590: 8b 45 0c mov 0xc(%ebp),%eax
593: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
596: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
59d: 8b 4d f4 mov -0xc(%ebp),%ecx
5a0: 8d 41 01 lea 0x1(%ecx),%eax
5a3: 89 45 f4 mov %eax,-0xc(%ebp)
5a6: 8b 5d 10 mov 0x10(%ebp),%ebx
5a9: 8b 45 ec mov -0x14(%ebp),%eax
5ac: ba 00 00 00 00 mov $0x0,%edx
5b1: f7 f3 div %ebx
5b3: 89 d0 mov %edx,%eax
5b5: 0f b6 80 70 0d 00 00 movzbl 0xd70(%eax),%eax
5bc: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
5c0: 8b 5d 10 mov 0x10(%ebp),%ebx
5c3: 8b 45 ec mov -0x14(%ebp),%eax
5c6: ba 00 00 00 00 mov $0x0,%edx
5cb: f7 f3 div %ebx
5cd: 89 45 ec mov %eax,-0x14(%ebp)
5d0: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
5d4: 75 c7 jne 59d <printint+0x38>
if(neg)
5d6: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
5da: 74 2d je 609 <printint+0xa4>
buf[i++] = '-';
5dc: 8b 45 f4 mov -0xc(%ebp),%eax
5df: 8d 50 01 lea 0x1(%eax),%edx
5e2: 89 55 f4 mov %edx,-0xc(%ebp)
5e5: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
5ea: eb 1d jmp 609 <printint+0xa4>
putc(fd, buf[i]);
5ec: 8d 55 dc lea -0x24(%ebp),%edx
5ef: 8b 45 f4 mov -0xc(%ebp),%eax
5f2: 01 d0 add %edx,%eax
5f4: 0f b6 00 movzbl (%eax),%eax
5f7: 0f be c0 movsbl %al,%eax
5fa: 83 ec 08 sub $0x8,%esp
5fd: 50 push %eax
5fe: ff 75 08 pushl 0x8(%ebp)
601: e8 3c ff ff ff call 542 <putc>
606: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
609: 83 6d f4 01 subl $0x1,-0xc(%ebp)
60d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
611: 79 d9 jns 5ec <printint+0x87>
putc(fd, buf[i]);
}
613: 90 nop
614: 8b 5d fc mov -0x4(%ebp),%ebx
617: c9 leave
618: c3 ret
00000619 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
619: 55 push %ebp
61a: 89 e5 mov %esp,%ebp
61c: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
61f: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
626: 8d 45 0c lea 0xc(%ebp),%eax
629: 83 c0 04 add $0x4,%eax
62c: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
62f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
636: e9 59 01 00 00 jmp 794 <printf+0x17b>
c = fmt[i] & 0xff;
63b: 8b 55 0c mov 0xc(%ebp),%edx
63e: 8b 45 f0 mov -0x10(%ebp),%eax