1455 lines
52 KiB
NASM
1455 lines
52 KiB
NASM
|
|
_ls: file format elf32-i386
|
|
|
|
|
|
Disassembly of section .text:
|
|
|
|
00000000 <main>:
|
|
close(fd);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
|
|
4: 83 e4 f0 and $0xfffffff0,%esp
|
|
7: ff 71 fc push -0x4(%ecx)
|
|
a: 55 push %ebp
|
|
b: 89 e5 mov %esp,%ebp
|
|
d: 57 push %edi
|
|
e: 56 push %esi
|
|
f: 53 push %ebx
|
|
10: bb 01 00 00 00 mov $0x1,%ebx
|
|
15: 51 push %ecx
|
|
16: 83 ec 08 sub $0x8,%esp
|
|
19: 8b 31 mov (%ecx),%esi
|
|
1b: 8b 79 04 mov 0x4(%ecx),%edi
|
|
int i;
|
|
|
|
if(argc < 2){
|
|
1e: 83 fe 01 cmp $0x1,%esi
|
|
21: 7e 1f jle 42 <main+0x42>
|
|
23: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
27: 90 nop
|
|
ls(".");
|
|
exit();
|
|
}
|
|
for(i=1; i<argc; i++)
|
|
ls(argv[i]);
|
|
28: 83 ec 0c sub $0xc,%esp
|
|
2b: ff 34 9f push (%edi,%ebx,4)
|
|
for(i=1; i<argc; i++)
|
|
2e: 83 c3 01 add $0x1,%ebx
|
|
ls(argv[i]);
|
|
31: e8 ca 00 00 00 call 100 <ls>
|
|
for(i=1; i<argc; i++)
|
|
36: 83 c4 10 add $0x10,%esp
|
|
39: 39 de cmp %ebx,%esi
|
|
3b: 75 eb jne 28 <main+0x28>
|
|
exit();
|
|
3d: e8 51 05 00 00 call 593 <exit>
|
|
ls(".");
|
|
42: 83 ec 0c sub $0xc,%esp
|
|
45: 68 70 0a 00 00 push $0xa70
|
|
4a: e8 b1 00 00 00 call 100 <ls>
|
|
exit();
|
|
4f: e8 3f 05 00 00 call 593 <exit>
|
|
54: 66 90 xchg %ax,%ax
|
|
56: 66 90 xchg %ax,%ax
|
|
58: 66 90 xchg %ax,%ax
|
|
5a: 66 90 xchg %ax,%ax
|
|
5c: 66 90 xchg %ax,%ax
|
|
5e: 66 90 xchg %ax,%ax
|
|
|
|
00000060 <fmtname>:
|
|
{
|
|
60: 55 push %ebp
|
|
61: 89 e5 mov %esp,%ebp
|
|
63: 56 push %esi
|
|
64: 53 push %ebx
|
|
65: 8b 75 08 mov 0x8(%ebp),%esi
|
|
for(p=path+strlen(path); p >= path && *p != '/'; p--)
|
|
68: 83 ec 0c sub $0xc,%esp
|
|
6b: 56 push %esi
|
|
6c: e8 5f 03 00 00 call 3d0 <strlen>
|
|
71: 83 c4 10 add $0x10,%esp
|
|
74: 01 f0 add %esi,%eax
|
|
76: 89 c3 mov %eax,%ebx
|
|
78: 73 0f jae 89 <fmtname+0x29>
|
|
7a: eb 12 jmp 8e <fmtname+0x2e>
|
|
7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
80: 8d 43 ff lea -0x1(%ebx),%eax
|
|
83: 39 c6 cmp %eax,%esi
|
|
85: 77 0a ja 91 <fmtname+0x31>
|
|
87: 89 c3 mov %eax,%ebx
|
|
89: 80 3b 2f cmpb $0x2f,(%ebx)
|
|
8c: 75 f2 jne 80 <fmtname+0x20>
|
|
p++;
|
|
8e: 83 c3 01 add $0x1,%ebx
|
|
if(strlen(p) >= DIRSIZ)
|
|
91: 83 ec 0c sub $0xc,%esp
|
|
94: 53 push %ebx
|
|
95: e8 36 03 00 00 call 3d0 <strlen>
|
|
9a: 83 c4 10 add $0x10,%esp
|
|
9d: 83 f8 0d cmp $0xd,%eax
|
|
a0: 77 4a ja ec <fmtname+0x8c>
|
|
memmove(buf, p, strlen(p));
|
|
a2: 83 ec 0c sub $0xc,%esp
|
|
a5: 53 push %ebx
|
|
a6: e8 25 03 00 00 call 3d0 <strlen>
|
|
ab: 83 c4 0c add $0xc,%esp
|
|
ae: 50 push %eax
|
|
af: 53 push %ebx
|
|
b0: 68 04 0e 00 00 push $0xe04
|
|
b5: e8 a6 04 00 00 call 560 <memmove>
|
|
memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
|
|
ba: 89 1c 24 mov %ebx,(%esp)
|
|
bd: e8 0e 03 00 00 call 3d0 <strlen>
|
|
c2: 89 1c 24 mov %ebx,(%esp)
|
|
return buf;
|
|
c5: bb 04 0e 00 00 mov $0xe04,%ebx
|
|
memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
|
|
ca: 89 c6 mov %eax,%esi
|
|
cc: e8 ff 02 00 00 call 3d0 <strlen>
|
|
d1: ba 0e 00 00 00 mov $0xe,%edx
|
|
d6: 83 c4 0c add $0xc,%esp
|
|
d9: 29 f2 sub %esi,%edx
|
|
db: 05 04 0e 00 00 add $0xe04,%eax
|
|
e0: 52 push %edx
|
|
e1: 6a 20 push $0x20
|
|
e3: 50 push %eax
|
|
e4: e8 17 03 00 00 call 400 <memset>
|
|
return buf;
|
|
e9: 83 c4 10 add $0x10,%esp
|
|
}
|
|
ec: 8d 65 f8 lea -0x8(%ebp),%esp
|
|
ef: 89 d8 mov %ebx,%eax
|
|
f1: 5b pop %ebx
|
|
f2: 5e pop %esi
|
|
f3: 5d pop %ebp
|
|
f4: c3 ret
|
|
f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
|
|
00000100 <ls>:
|
|
{
|
|
100: 55 push %ebp
|
|
101: 89 e5 mov %esp,%ebp
|
|
103: 57 push %edi
|
|
104: 56 push %esi
|
|
105: 53 push %ebx
|
|
106: 81 ec 64 02 00 00 sub $0x264,%esp
|
|
10c: 8b 7d 08 mov 0x8(%ebp),%edi
|
|
if((fd = open(path, 0)) < 0){
|
|
10f: 6a 00 push $0x0
|
|
111: 57 push %edi
|
|
112: e8 e4 04 00 00 call 5fb <open>
|
|
117: 83 c4 10 add $0x10,%esp
|
|
11a: 85 c0 test %eax,%eax
|
|
11c: 0f 88 9e 01 00 00 js 2c0 <ls+0x1c0>
|
|
if(fstat(fd, &st) < 0){
|
|
122: 83 ec 08 sub $0x8,%esp
|
|
125: 8d b5 d4 fd ff ff lea -0x22c(%ebp),%esi
|
|
12b: 89 c3 mov %eax,%ebx
|
|
12d: 56 push %esi
|
|
12e: 50 push %eax
|
|
12f: e8 8f 04 00 00 call 5c3 <fstat>
|
|
134: 83 c4 10 add $0x10,%esp
|
|
137: 85 c0 test %eax,%eax
|
|
139: 0f 88 c1 01 00 00 js 300 <ls+0x200>
|
|
switch(st.type){
|
|
13f: 0f b7 85 d4 fd ff ff movzwl -0x22c(%ebp),%eax
|
|
146: 66 83 f8 01 cmp $0x1,%ax
|
|
14a: 74 64 je 1b0 <ls+0xb0>
|
|
14c: 66 83 f8 02 cmp $0x2,%ax
|
|
150: 74 1e je 170 <ls+0x70>
|
|
close(fd);
|
|
152: 83 ec 0c sub $0xc,%esp
|
|
155: 53 push %ebx
|
|
156: e8 d0 04 00 00 call 62b <close>
|
|
15b: 83 c4 10 add $0x10,%esp
|
|
}
|
|
15e: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
161: 5b pop %ebx
|
|
162: 5e pop %esi
|
|
163: 5f pop %edi
|
|
164: 5d pop %ebp
|
|
165: c3 ret
|
|
166: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
16d: 8d 76 00 lea 0x0(%esi),%esi
|
|
printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
|
|
170: 83 ec 0c sub $0xc,%esp
|
|
173: 8b 95 e4 fd ff ff mov -0x21c(%ebp),%edx
|
|
179: 8b b5 dc fd ff ff mov -0x224(%ebp),%esi
|
|
17f: 57 push %edi
|
|
180: 89 95 b4 fd ff ff mov %edx,-0x24c(%ebp)
|
|
186: e8 d5 fe ff ff call 60 <fmtname>
|
|
18b: 8b 95 b4 fd ff ff mov -0x24c(%ebp),%edx
|
|
191: 59 pop %ecx
|
|
192: 5f pop %edi
|
|
193: 52 push %edx
|
|
194: 56 push %esi
|
|
195: 6a 02 push $0x2
|
|
197: 50 push %eax
|
|
198: 68 50 0a 00 00 push $0xa50
|
|
19d: 6a 01 push $0x1
|
|
19f: e8 5c 05 00 00 call 700 <printf>
|
|
break;
|
|
1a4: 83 c4 20 add $0x20,%esp
|
|
1a7: eb a9 jmp 152 <ls+0x52>
|
|
1a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
|
|
1b0: 83 ec 0c sub $0xc,%esp
|
|
1b3: 57 push %edi
|
|
1b4: e8 17 02 00 00 call 3d0 <strlen>
|
|
1b9: 83 c4 10 add $0x10,%esp
|
|
1bc: 83 c0 10 add $0x10,%eax
|
|
1bf: 3d 00 02 00 00 cmp $0x200,%eax
|
|
1c4: 0f 87 16 01 00 00 ja 2e0 <ls+0x1e0>
|
|
strcpy(buf, path);
|
|
1ca: 83 ec 08 sub $0x8,%esp
|
|
1cd: 57 push %edi
|
|
1ce: 8d bd e8 fd ff ff lea -0x218(%ebp),%edi
|
|
1d4: 57 push %edi
|
|
1d5: e8 66 01 00 00 call 340 <strcpy>
|
|
p = buf+strlen(buf);
|
|
1da: 89 3c 24 mov %edi,(%esp)
|
|
1dd: e8 ee 01 00 00 call 3d0 <strlen>
|
|
while(read(fd, &de, sizeof(de)) == sizeof(de)){
|
|
1e2: 83 c4 10 add $0x10,%esp
|
|
p = buf+strlen(buf);
|
|
1e5: 01 f8 add %edi,%eax
|
|
*p++ = '/';
|
|
1e7: 8d 48 01 lea 0x1(%eax),%ecx
|
|
p = buf+strlen(buf);
|
|
1ea: 89 85 a8 fd ff ff mov %eax,-0x258(%ebp)
|
|
*p++ = '/';
|
|
1f0: 89 8d a4 fd ff ff mov %ecx,-0x25c(%ebp)
|
|
1f6: c6 00 2f movb $0x2f,(%eax)
|
|
while(read(fd, &de, sizeof(de)) == sizeof(de)){
|
|
1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
200: 83 ec 04 sub $0x4,%esp
|
|
203: 8d 85 c4 fd ff ff lea -0x23c(%ebp),%eax
|
|
209: 6a 10 push $0x10
|
|
20b: 50 push %eax
|
|
20c: 53 push %ebx
|
|
20d: e8 99 03 00 00 call 5ab <read>
|
|
212: 83 c4 10 add $0x10,%esp
|
|
215: 83 f8 10 cmp $0x10,%eax
|
|
218: 0f 85 34 ff ff ff jne 152 <ls+0x52>
|
|
if(de.inum == 0)
|
|
21e: 66 83 bd c4 fd ff ff cmpw $0x0,-0x23c(%ebp)
|
|
225: 00
|
|
226: 74 d8 je 200 <ls+0x100>
|
|
memmove(p, de.name, DIRSIZ);
|
|
228: 83 ec 04 sub $0x4,%esp
|
|
22b: 8d 85 c6 fd ff ff lea -0x23a(%ebp),%eax
|
|
231: 6a 0e push $0xe
|
|
233: 50 push %eax
|
|
234: ff b5 a4 fd ff ff push -0x25c(%ebp)
|
|
23a: e8 21 03 00 00 call 560 <memmove>
|
|
p[DIRSIZ] = 0;
|
|
23f: 8b 85 a8 fd ff ff mov -0x258(%ebp),%eax
|
|
245: c6 40 0f 00 movb $0x0,0xf(%eax)
|
|
if(stat(buf, &st) < 0){
|
|
249: 58 pop %eax
|
|
24a: 5a pop %edx
|
|
24b: 56 push %esi
|
|
24c: 57 push %edi
|
|
24d: e8 7e 02 00 00 call 4d0 <stat>
|
|
252: 83 c4 10 add $0x10,%esp
|
|
255: 85 c0 test %eax,%eax
|
|
257: 0f 88 cb 00 00 00 js 328 <ls+0x228>
|
|
printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
|
|
25d: 83 ec 0c sub $0xc,%esp
|
|
260: 8b 8d e4 fd ff ff mov -0x21c(%ebp),%ecx
|
|
266: 8b 95 dc fd ff ff mov -0x224(%ebp),%edx
|
|
26c: 57 push %edi
|
|
26d: 0f bf 85 d4 fd ff ff movswl -0x22c(%ebp),%eax
|
|
274: 89 8d ac fd ff ff mov %ecx,-0x254(%ebp)
|
|
27a: 89 95 b0 fd ff ff mov %edx,-0x250(%ebp)
|
|
280: 89 85 b4 fd ff ff mov %eax,-0x24c(%ebp)
|
|
286: e8 d5 fd ff ff call 60 <fmtname>
|
|
28b: 5a pop %edx
|
|
28c: 8b 95 b0 fd ff ff mov -0x250(%ebp),%edx
|
|
292: 59 pop %ecx
|
|
293: 8b 8d ac fd ff ff mov -0x254(%ebp),%ecx
|
|
299: 51 push %ecx
|
|
29a: 52 push %edx
|
|
29b: ff b5 b4 fd ff ff push -0x24c(%ebp)
|
|
2a1: 50 push %eax
|
|
2a2: 68 50 0a 00 00 push $0xa50
|
|
2a7: 6a 01 push $0x1
|
|
2a9: e8 52 04 00 00 call 700 <printf>
|
|
2ae: 83 c4 20 add $0x20,%esp
|
|
2b1: e9 4a ff ff ff jmp 200 <ls+0x100>
|
|
2b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
2bd: 8d 76 00 lea 0x0(%esi),%esi
|
|
printf(2, "ls: cannot open %s\n", path);
|
|
2c0: 83 ec 04 sub $0x4,%esp
|
|
2c3: 57 push %edi
|
|
2c4: 68 28 0a 00 00 push $0xa28
|
|
2c9: 6a 02 push $0x2
|
|
2cb: e8 30 04 00 00 call 700 <printf>
|
|
return;
|
|
2d0: 83 c4 10 add $0x10,%esp
|
|
}
|
|
2d3: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
2d6: 5b pop %ebx
|
|
2d7: 5e pop %esi
|
|
2d8: 5f pop %edi
|
|
2d9: 5d pop %ebp
|
|
2da: c3 ret
|
|
2db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
2df: 90 nop
|
|
printf(1, "ls: path too long\n");
|
|
2e0: 83 ec 08 sub $0x8,%esp
|
|
2e3: 68 5d 0a 00 00 push $0xa5d
|
|
2e8: 6a 01 push $0x1
|
|
2ea: e8 11 04 00 00 call 700 <printf>
|
|
break;
|
|
2ef: 83 c4 10 add $0x10,%esp
|
|
2f2: e9 5b fe ff ff jmp 152 <ls+0x52>
|
|
2f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
2fe: 66 90 xchg %ax,%ax
|
|
printf(2, "ls: cannot stat %s\n", path);
|
|
300: 83 ec 04 sub $0x4,%esp
|
|
303: 57 push %edi
|
|
304: 68 3c 0a 00 00 push $0xa3c
|
|
309: 6a 02 push $0x2
|
|
30b: e8 f0 03 00 00 call 700 <printf>
|
|
close(fd);
|
|
310: 89 1c 24 mov %ebx,(%esp)
|
|
313: e8 13 03 00 00 call 62b <close>
|
|
return;
|
|
318: 83 c4 10 add $0x10,%esp
|
|
}
|
|
31b: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
31e: 5b pop %ebx
|
|
31f: 5e pop %esi
|
|
320: 5f pop %edi
|
|
321: 5d pop %ebp
|
|
322: c3 ret
|
|
323: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
327: 90 nop
|
|
printf(1, "ls: cannot stat %s\n", buf);
|
|
328: 83 ec 04 sub $0x4,%esp
|
|
32b: 57 push %edi
|
|
32c: 68 3c 0a 00 00 push $0xa3c
|
|
331: 6a 01 push $0x1
|
|
333: e8 c8 03 00 00 call 700 <printf>
|
|
continue;
|
|
338: 83 c4 10 add $0x10,%esp
|
|
33b: e9 c0 fe ff ff jmp 200 <ls+0x100>
|
|
|
|
00000340 <strcpy>:
|
|
#include "stat.h"
|
|
#include "fcntl.h"
|
|
#include "user.h"
|
|
#include "x86.h"
|
|
|
|
char*strcpy(char *s, const char *t) {
|
|
340: 55 push %ebp
|
|
char *os;
|
|
|
|
os = s;
|
|
while ((*s++ = *t++) != 0) {
|
|
341: 31 c0 xor %eax,%eax
|
|
char*strcpy(char *s, const char *t) {
|
|
343: 89 e5 mov %esp,%ebp
|
|
345: 53 push %ebx
|
|
346: 8b 4d 08 mov 0x8(%ebp),%ecx
|
|
349: 8b 5d 0c mov 0xc(%ebp),%ebx
|
|
34c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
while ((*s++ = *t++) != 0) {
|
|
350: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
|
|
354: 88 14 01 mov %dl,(%ecx,%eax,1)
|
|
357: 83 c0 01 add $0x1,%eax
|
|
35a: 84 d2 test %dl,%dl
|
|
35c: 75 f2 jne 350 <strcpy+0x10>
|
|
;
|
|
}
|
|
return os;
|
|
}
|
|
35e: 8b 5d fc mov -0x4(%ebp),%ebx
|
|
361: 89 c8 mov %ecx,%eax
|
|
363: c9 leave
|
|
364: c3 ret
|
|
365: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
36c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
|
|
00000370 <strcmp>:
|
|
|
|
int strcmp(const char *p, const char *q) {
|
|
370: 55 push %ebp
|
|
371: 89 e5 mov %esp,%ebp
|
|
373: 53 push %ebx
|
|
374: 8b 55 08 mov 0x8(%ebp),%edx
|
|
377: 8b 4d 0c mov 0xc(%ebp),%ecx
|
|
while (*p && *p == *q) {
|
|
37a: 0f b6 02 movzbl (%edx),%eax
|
|
37d: 84 c0 test %al,%al
|
|
37f: 75 17 jne 398 <strcmp+0x28>
|
|
381: eb 3a jmp 3bd <strcmp+0x4d>
|
|
383: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
387: 90 nop
|
|
388: 0f b6 42 01 movzbl 0x1(%edx),%eax
|
|
p++, q++;
|
|
38c: 83 c2 01 add $0x1,%edx
|
|
38f: 8d 59 01 lea 0x1(%ecx),%ebx
|
|
while (*p && *p == *q) {
|
|
392: 84 c0 test %al,%al
|
|
394: 74 1a je 3b0 <strcmp+0x40>
|
|
p++, q++;
|
|
396: 89 d9 mov %ebx,%ecx
|
|
while (*p && *p == *q) {
|
|
398: 0f b6 19 movzbl (%ecx),%ebx
|
|
39b: 38 c3 cmp %al,%bl
|
|
39d: 74 e9 je 388 <strcmp+0x18>
|
|
}
|
|
return (uchar) * p - (uchar) * q;
|
|
39f: 29 d8 sub %ebx,%eax
|
|
}
|
|
3a1: 8b 5d fc mov -0x4(%ebp),%ebx
|
|
3a4: c9 leave
|
|
3a5: c3 ret
|
|
3a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
3ad: 8d 76 00 lea 0x0(%esi),%esi
|
|
return (uchar) * p - (uchar) * q;
|
|
3b0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
|
|
3b4: 31 c0 xor %eax,%eax
|
|
3b6: 29 d8 sub %ebx,%eax
|
|
}
|
|
3b8: 8b 5d fc mov -0x4(%ebp),%ebx
|
|
3bb: c9 leave
|
|
3bc: c3 ret
|
|
return (uchar) * p - (uchar) * q;
|
|
3bd: 0f b6 19 movzbl (%ecx),%ebx
|
|
3c0: 31 c0 xor %eax,%eax
|
|
3c2: eb db jmp 39f <strcmp+0x2f>
|
|
3c4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
3cb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
3cf: 90 nop
|
|
|
|
000003d0 <strlen>:
|
|
|
|
uint strlen(const char *s) {
|
|
3d0: 55 push %ebp
|
|
3d1: 89 e5 mov %esp,%ebp
|
|
3d3: 8b 55 08 mov 0x8(%ebp),%edx
|
|
int n;
|
|
|
|
for (n = 0; s[n]; n++) {
|
|
3d6: 80 3a 00 cmpb $0x0,(%edx)
|
|
3d9: 74 15 je 3f0 <strlen+0x20>
|
|
3db: 31 c0 xor %eax,%eax
|
|
3dd: 8d 76 00 lea 0x0(%esi),%esi
|
|
3e0: 83 c0 01 add $0x1,%eax
|
|
3e3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
|
|
3e7: 89 c1 mov %eax,%ecx
|
|
3e9: 75 f5 jne 3e0 <strlen+0x10>
|
|
;
|
|
}
|
|
return n;
|
|
}
|
|
3eb: 89 c8 mov %ecx,%eax
|
|
3ed: 5d pop %ebp
|
|
3ee: c3 ret
|
|
3ef: 90 nop
|
|
for (n = 0; s[n]; n++) {
|
|
3f0: 31 c9 xor %ecx,%ecx
|
|
}
|
|
3f2: 5d pop %ebp
|
|
3f3: 89 c8 mov %ecx,%eax
|
|
3f5: c3 ret
|
|
3f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
3fd: 8d 76 00 lea 0x0(%esi),%esi
|
|
|
|
00000400 <memset>:
|
|
|
|
void* memset(void *dst, int c, uint n) {
|
|
400: 55 push %ebp
|
|
401: 89 e5 mov %esp,%ebp
|
|
403: 57 push %edi
|
|
404: 8b 55 08 mov 0x8(%ebp),%edx
|
|
"d" (port), "0" (addr), "1" (cnt) :
|
|
"cc");
|
|
}
|
|
|
|
static inline void stosb(void *addr, int data, int cnt) {
|
|
asm volatile ("cld; rep stosb" :
|
|
407: 8b 4d 10 mov 0x10(%ebp),%ecx
|
|
40a: 8b 45 0c mov 0xc(%ebp),%eax
|
|
40d: 89 d7 mov %edx,%edi
|
|
40f: fc cld
|
|
410: f3 aa rep stos %al,%es:(%edi)
|
|
stosb(dst, c, n);
|
|
return dst;
|
|
}
|
|
412: 8b 7d fc mov -0x4(%ebp),%edi
|
|
415: 89 d0 mov %edx,%eax
|
|
417: c9 leave
|
|
418: c3 ret
|
|
419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
|
|
00000420 <strchr>:
|
|
|
|
char* strchr(const char *s, char c) {
|
|
420: 55 push %ebp
|
|
421: 89 e5 mov %esp,%ebp
|
|
423: 8b 45 08 mov 0x8(%ebp),%eax
|
|
426: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
|
|
for (; *s; s++) {
|
|
42a: 0f b6 10 movzbl (%eax),%edx
|
|
42d: 84 d2 test %dl,%dl
|
|
42f: 75 12 jne 443 <strchr+0x23>
|
|
431: eb 1d jmp 450 <strchr+0x30>
|
|
433: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
437: 90 nop
|
|
438: 0f b6 50 01 movzbl 0x1(%eax),%edx
|
|
43c: 83 c0 01 add $0x1,%eax
|
|
43f: 84 d2 test %dl,%dl
|
|
441: 74 0d je 450 <strchr+0x30>
|
|
if (*s == c) {
|
|
443: 38 d1 cmp %dl,%cl
|
|
445: 75 f1 jne 438 <strchr+0x18>
|
|
return (char*)s;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
447: 5d pop %ebp
|
|
448: c3 ret
|
|
449: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
return 0;
|
|
450: 31 c0 xor %eax,%eax
|
|
}
|
|
452: 5d pop %ebp
|
|
453: c3 ret
|
|
454: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
45b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
45f: 90 nop
|
|
|
|
00000460 <gets>:
|
|
|
|
char* gets(char *buf, int max) {
|
|
460: 55 push %ebp
|
|
461: 89 e5 mov %esp,%ebp
|
|
463: 57 push %edi
|
|
464: 56 push %esi
|
|
int i, cc;
|
|
char c;
|
|
|
|
for (i = 0; i + 1 < max;) {
|
|
cc = read(0, &c, 1);
|
|
465: 8d 7d e7 lea -0x19(%ebp),%edi
|
|
char* gets(char *buf, int max) {
|
|
468: 53 push %ebx
|
|
for (i = 0; i + 1 < max;) {
|
|
469: 31 db xor %ebx,%ebx
|
|
char* gets(char *buf, int max) {
|
|
46b: 83 ec 1c sub $0x1c,%esp
|
|
for (i = 0; i + 1 < max;) {
|
|
46e: eb 27 jmp 497 <gets+0x37>
|
|
cc = read(0, &c, 1);
|
|
470: 83 ec 04 sub $0x4,%esp
|
|
473: 6a 01 push $0x1
|
|
475: 57 push %edi
|
|
476: 6a 00 push $0x0
|
|
478: e8 2e 01 00 00 call 5ab <read>
|
|
if (cc < 1) {
|
|
47d: 83 c4 10 add $0x10,%esp
|
|
480: 85 c0 test %eax,%eax
|
|
482: 7e 1d jle 4a1 <gets+0x41>
|
|
break;
|
|
}
|
|
buf[i++] = c;
|
|
484: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
|
|
488: 8b 55 08 mov 0x8(%ebp),%edx
|
|
48b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
|
|
if (c == '\n' || c == '\r') {
|
|
48f: 3c 0a cmp $0xa,%al
|
|
491: 74 1d je 4b0 <gets+0x50>
|
|
493: 3c 0d cmp $0xd,%al
|
|
495: 74 19 je 4b0 <gets+0x50>
|
|
for (i = 0; i + 1 < max;) {
|
|
497: 89 de mov %ebx,%esi
|
|
499: 83 c3 01 add $0x1,%ebx
|
|
49c: 3b 5d 0c cmp 0xc(%ebp),%ebx
|
|
49f: 7c cf jl 470 <gets+0x10>
|
|
break;
|
|
}
|
|
}
|
|
buf[i] = '\0';
|
|
4a1: 8b 45 08 mov 0x8(%ebp),%eax
|
|
4a4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
|
|
return buf;
|
|
}
|
|
4a8: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
4ab: 5b pop %ebx
|
|
4ac: 5e pop %esi
|
|
4ad: 5f pop %edi
|
|
4ae: 5d pop %ebp
|
|
4af: c3 ret
|
|
buf[i] = '\0';
|
|
4b0: 8b 45 08 mov 0x8(%ebp),%eax
|
|
4b3: 89 de mov %ebx,%esi
|
|
4b5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
|
|
}
|
|
4b9: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
4bc: 5b pop %ebx
|
|
4bd: 5e pop %esi
|
|
4be: 5f pop %edi
|
|
4bf: 5d pop %ebp
|
|
4c0: c3 ret
|
|
4c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
4c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
4cf: 90 nop
|
|
|
|
000004d0 <stat>:
|
|
|
|
int stat(const char *n, struct stat *st) {
|
|
4d0: 55 push %ebp
|
|
4d1: 89 e5 mov %esp,%ebp
|
|
4d3: 56 push %esi
|
|
4d4: 53 push %ebx
|
|
int fd;
|
|
int r;
|
|
|
|
fd = open(n, O_RDONLY);
|
|
4d5: 83 ec 08 sub $0x8,%esp
|
|
4d8: 6a 00 push $0x0
|
|
4da: ff 75 08 push 0x8(%ebp)
|
|
4dd: e8 19 01 00 00 call 5fb <open>
|
|
if (fd < 0) {
|
|
4e2: 83 c4 10 add $0x10,%esp
|
|
4e5: 85 c0 test %eax,%eax
|
|
4e7: 78 27 js 510 <stat+0x40>
|
|
return -1;
|
|
}
|
|
r = fstat(fd, st);
|
|
4e9: 83 ec 08 sub $0x8,%esp
|
|
4ec: ff 75 0c push 0xc(%ebp)
|
|
4ef: 89 c3 mov %eax,%ebx
|
|
4f1: 50 push %eax
|
|
4f2: e8 cc 00 00 00 call 5c3 <fstat>
|
|
close(fd);
|
|
4f7: 89 1c 24 mov %ebx,(%esp)
|
|
r = fstat(fd, st);
|
|
4fa: 89 c6 mov %eax,%esi
|
|
close(fd);
|
|
4fc: e8 2a 01 00 00 call 62b <close>
|
|
return r;
|
|
501: 83 c4 10 add $0x10,%esp
|
|
}
|
|
504: 8d 65 f8 lea -0x8(%ebp),%esp
|
|
507: 89 f0 mov %esi,%eax
|
|
509: 5b pop %ebx
|
|
50a: 5e pop %esi
|
|
50b: 5d pop %ebp
|
|
50c: c3 ret
|
|
50d: 8d 76 00 lea 0x0(%esi),%esi
|
|
return -1;
|
|
510: be ff ff ff ff mov $0xffffffff,%esi
|
|
515: eb ed jmp 504 <stat+0x34>
|
|
517: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
51e: 66 90 xchg %ax,%ax
|
|
|
|
00000520 <atoi>:
|
|
|
|
int atoi(const char *s) {
|
|
520: 55 push %ebp
|
|
521: 89 e5 mov %esp,%ebp
|
|
523: 53 push %ebx
|
|
524: 8b 55 08 mov 0x8(%ebp),%edx
|
|
int n;
|
|
|
|
n = 0;
|
|
while ('0' <= *s && *s <= '9') {
|
|
527: 0f be 02 movsbl (%edx),%eax
|
|
52a: 8d 48 d0 lea -0x30(%eax),%ecx
|
|
52d: 80 f9 09 cmp $0x9,%cl
|
|
n = 0;
|
|
530: b9 00 00 00 00 mov $0x0,%ecx
|
|
while ('0' <= *s && *s <= '9') {
|
|
535: 77 1e ja 555 <atoi+0x35>
|
|
537: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
53e: 66 90 xchg %ax,%ax
|
|
n = n * 10 + *s++ - '0';
|
|
540: 83 c2 01 add $0x1,%edx
|
|
543: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
|
|
546: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx
|
|
while ('0' <= *s && *s <= '9') {
|
|
54a: 0f be 02 movsbl (%edx),%eax
|
|
54d: 8d 58 d0 lea -0x30(%eax),%ebx
|
|
550: 80 fb 09 cmp $0x9,%bl
|
|
553: 76 eb jbe 540 <atoi+0x20>
|
|
}
|
|
return n;
|
|
}
|
|
555: 8b 5d fc mov -0x4(%ebp),%ebx
|
|
558: 89 c8 mov %ecx,%eax
|
|
55a: c9 leave
|
|
55b: c3 ret
|
|
55c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
|
|
00000560 <memmove>:
|
|
|
|
void* memmove(void *vdst, const void *vsrc, int n) {
|
|
560: 55 push %ebp
|
|
561: 89 e5 mov %esp,%ebp
|
|
563: 57 push %edi
|
|
564: 8b 45 10 mov 0x10(%ebp),%eax
|
|
567: 8b 55 08 mov 0x8(%ebp),%edx
|
|
56a: 56 push %esi
|
|
56b: 8b 75 0c mov 0xc(%ebp),%esi
|
|
char *dst;
|
|
const char *src;
|
|
|
|
dst = vdst;
|
|
src = vsrc;
|
|
while (n-- > 0) {
|
|
56e: 85 c0 test %eax,%eax
|
|
570: 7e 13 jle 585 <memmove+0x25>
|
|
572: 01 d0 add %edx,%eax
|
|
dst = vdst;
|
|
574: 89 d7 mov %edx,%edi
|
|
576: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
57d: 8d 76 00 lea 0x0(%esi),%esi
|
|
*dst++ = *src++;
|
|
580: a4 movsb %ds:(%esi),%es:(%edi)
|
|
while (n-- > 0) {
|
|
581: 39 f8 cmp %edi,%eax
|
|
583: 75 fb jne 580 <memmove+0x20>
|
|
}
|
|
return vdst;
|
|
}
|
|
585: 5e pop %esi
|
|
586: 89 d0 mov %edx,%eax
|
|
588: 5f pop %edi
|
|
589: 5d pop %ebp
|
|
58a: c3 ret
|
|
|
|
0000058b <fork>:
|
|
name: \
|
|
movl $SYS_ ## name, %eax; \
|
|
int $T_SYSCALL; \
|
|
ret
|
|
|
|
SYSCALL(fork)
|
|
58b: b8 01 00 00 00 mov $0x1,%eax
|
|
590: cd 40 int $0x40
|
|
592: c3 ret
|
|
|
|
00000593 <exit>:
|
|
SYSCALL(exit)
|
|
593: b8 02 00 00 00 mov $0x2,%eax
|
|
598: cd 40 int $0x40
|
|
59a: c3 ret
|
|
|
|
0000059b <wait>:
|
|
SYSCALL(wait)
|
|
59b: b8 03 00 00 00 mov $0x3,%eax
|
|
5a0: cd 40 int $0x40
|
|
5a2: c3 ret
|
|
|
|
000005a3 <pipe>:
|
|
SYSCALL(pipe)
|
|
5a3: b8 04 00 00 00 mov $0x4,%eax
|
|
5a8: cd 40 int $0x40
|
|
5aa: c3 ret
|
|
|
|
000005ab <read>:
|
|
SYSCALL(read)
|
|
5ab: b8 05 00 00 00 mov $0x5,%eax
|
|
5b0: cd 40 int $0x40
|
|
5b2: c3 ret
|
|
|
|
000005b3 <kill>:
|
|
SYSCALL(kill)
|
|
5b3: b8 06 00 00 00 mov $0x6,%eax
|
|
5b8: cd 40 int $0x40
|
|
5ba: c3 ret
|
|
|
|
000005bb <exec>:
|
|
SYSCALL(exec)
|
|
5bb: b8 07 00 00 00 mov $0x7,%eax
|
|
5c0: cd 40 int $0x40
|
|
5c2: c3 ret
|
|
|
|
000005c3 <fstat>:
|
|
SYSCALL(fstat)
|
|
5c3: b8 08 00 00 00 mov $0x8,%eax
|
|
5c8: cd 40 int $0x40
|
|
5ca: c3 ret
|
|
|
|
000005cb <chdir>:
|
|
SYSCALL(chdir)
|
|
5cb: b8 09 00 00 00 mov $0x9,%eax
|
|
5d0: cd 40 int $0x40
|
|
5d2: c3 ret
|
|
|
|
000005d3 <dup>:
|
|
SYSCALL(dup)
|
|
5d3: b8 0a 00 00 00 mov $0xa,%eax
|
|
5d8: cd 40 int $0x40
|
|
5da: c3 ret
|
|
|
|
000005db <getpid>:
|
|
SYSCALL(getpid)
|
|
5db: b8 0b 00 00 00 mov $0xb,%eax
|
|
5e0: cd 40 int $0x40
|
|
5e2: c3 ret
|
|
|
|
000005e3 <sbrk>:
|
|
SYSCALL(sbrk)
|
|
5e3: b8 0c 00 00 00 mov $0xc,%eax
|
|
5e8: cd 40 int $0x40
|
|
5ea: c3 ret
|
|
|
|
000005eb <sleep>:
|
|
SYSCALL(sleep)
|
|
5eb: b8 0d 00 00 00 mov $0xd,%eax
|
|
5f0: cd 40 int $0x40
|
|
5f2: c3 ret
|
|
|
|
000005f3 <uptime>:
|
|
SYSCALL(uptime)
|
|
5f3: b8 0e 00 00 00 mov $0xe,%eax
|
|
5f8: cd 40 int $0x40
|
|
5fa: c3 ret
|
|
|
|
000005fb <open>:
|
|
SYSCALL(open)
|
|
5fb: b8 0f 00 00 00 mov $0xf,%eax
|
|
600: cd 40 int $0x40
|
|
602: c3 ret
|
|
|
|
00000603 <write>:
|
|
SYSCALL(write)
|
|
603: b8 10 00 00 00 mov $0x10,%eax
|
|
608: cd 40 int $0x40
|
|
60a: c3 ret
|
|
|
|
0000060b <mknod>:
|
|
SYSCALL(mknod)
|
|
60b: b8 11 00 00 00 mov $0x11,%eax
|
|
610: cd 40 int $0x40
|
|
612: c3 ret
|
|
|
|
00000613 <unlink>:
|
|
SYSCALL(unlink)
|
|
613: b8 12 00 00 00 mov $0x12,%eax
|
|
618: cd 40 int $0x40
|
|
61a: c3 ret
|
|
|
|
0000061b <link>:
|
|
SYSCALL(link)
|
|
61b: b8 13 00 00 00 mov $0x13,%eax
|
|
620: cd 40 int $0x40
|
|
622: c3 ret
|
|
|
|
00000623 <mkdir>:
|
|
SYSCALL(mkdir)
|
|
623: b8 14 00 00 00 mov $0x14,%eax
|
|
628: cd 40 int $0x40
|
|
62a: c3 ret
|
|
|
|
0000062b <close>:
|
|
SYSCALL(close)
|
|
62b: b8 15 00 00 00 mov $0x15,%eax
|
|
630: cd 40 int $0x40
|
|
632: c3 ret
|
|
|
|
00000633 <getch>:
|
|
SYSCALL(getch)
|
|
633: b8 16 00 00 00 mov $0x16,%eax
|
|
638: cd 40 int $0x40
|
|
63a: c3 ret
|
|
|
|
0000063b <greeting>:
|
|
SYSCALL(greeting)
|
|
63b: b8 17 00 00 00 mov $0x17,%eax
|
|
640: cd 40 int $0x40
|
|
642: c3 ret
|
|
|
|
00000643 <shutdown>:
|
|
SYSCALL(shutdown)
|
|
643: b8 18 00 00 00 mov $0x18,%eax
|
|
648: cd 40 int $0x40
|
|
64a: c3 ret
|
|
64b: 66 90 xchg %ax,%ax
|
|
64d: 66 90 xchg %ax,%ax
|
|
64f: 90 nop
|
|
|
|
00000650 <printint>:
|
|
|
|
static void putc(int fd, char c) {
|
|
write(fd, &c, 1);
|
|
}
|
|
|
|
static void printint(int fd, int xx, int base, int sgn) {
|
|
650: 55 push %ebp
|
|
651: 89 e5 mov %esp,%ebp
|
|
653: 57 push %edi
|
|
654: 56 push %esi
|
|
655: 53 push %ebx
|
|
656: 83 ec 3c sub $0x3c,%esp
|
|
659: 89 4d c4 mov %ecx,-0x3c(%ebp)
|
|
uint x;
|
|
|
|
neg = 0;
|
|
if (sgn && xx < 0) {
|
|
neg = 1;
|
|
x = -xx;
|
|
65c: 89 d1 mov %edx,%ecx
|
|
static void printint(int fd, int xx, int base, int sgn) {
|
|
65e: 89 45 b8 mov %eax,-0x48(%ebp)
|
|
if (sgn && xx < 0) {
|
|
661: 85 d2 test %edx,%edx
|
|
663: 0f 89 7f 00 00 00 jns 6e8 <printint+0x98>
|
|
669: f6 45 08 01 testb $0x1,0x8(%ebp)
|
|
66d: 74 79 je 6e8 <printint+0x98>
|
|
neg = 1;
|
|
66f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp)
|
|
x = -xx;
|
|
676: f7 d9 neg %ecx
|
|
}
|
|
else {
|
|
x = xx;
|
|
}
|
|
|
|
i = 0;
|
|
678: 31 db xor %ebx,%ebx
|
|
67a: 8d 75 d7 lea -0x29(%ebp),%esi
|
|
67d: 8d 76 00 lea 0x0(%esi),%esi
|
|
do {
|
|
buf[i++] = digits[x % base];
|
|
680: 89 c8 mov %ecx,%eax
|
|
682: 31 d2 xor %edx,%edx
|
|
684: 89 cf mov %ecx,%edi
|
|
686: f7 75 c4 divl -0x3c(%ebp)
|
|
689: 0f b6 92 d4 0a 00 00 movzbl 0xad4(%edx),%edx
|
|
690: 89 45 c0 mov %eax,-0x40(%ebp)
|
|
693: 89 d8 mov %ebx,%eax
|
|
695: 8d 5b 01 lea 0x1(%ebx),%ebx
|
|
}
|
|
while ((x /= base) != 0);
|
|
698: 8b 4d c0 mov -0x40(%ebp),%ecx
|
|
buf[i++] = digits[x % base];
|
|
69b: 88 14 1e mov %dl,(%esi,%ebx,1)
|
|
while ((x /= base) != 0);
|
|
69e: 39 7d c4 cmp %edi,-0x3c(%ebp)
|
|
6a1: 76 dd jbe 680 <printint+0x30>
|
|
if (neg) {
|
|
6a3: 8b 4d bc mov -0x44(%ebp),%ecx
|
|
6a6: 85 c9 test %ecx,%ecx
|
|
6a8: 74 0c je 6b6 <printint+0x66>
|
|
buf[i++] = '-';
|
|
6aa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
|
|
buf[i++] = digits[x % base];
|
|
6af: 89 d8 mov %ebx,%eax
|
|
buf[i++] = '-';
|
|
6b1: ba 2d 00 00 00 mov $0x2d,%edx
|
|
}
|
|
|
|
while (--i >= 0) {
|
|
6b6: 8b 7d b8 mov -0x48(%ebp),%edi
|
|
6b9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
|
|
6bd: eb 07 jmp 6c6 <printint+0x76>
|
|
6bf: 90 nop
|
|
putc(fd, buf[i]);
|
|
6c0: 0f b6 13 movzbl (%ebx),%edx
|
|
6c3: 83 eb 01 sub $0x1,%ebx
|
|
write(fd, &c, 1);
|
|
6c6: 83 ec 04 sub $0x4,%esp
|
|
6c9: 88 55 d7 mov %dl,-0x29(%ebp)
|
|
6cc: 6a 01 push $0x1
|
|
6ce: 56 push %esi
|
|
6cf: 57 push %edi
|
|
6d0: e8 2e ff ff ff call 603 <write>
|
|
while (--i >= 0) {
|
|
6d5: 83 c4 10 add $0x10,%esp
|
|
6d8: 39 de cmp %ebx,%esi
|
|
6da: 75 e4 jne 6c0 <printint+0x70>
|
|
}
|
|
}
|
|
6dc: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
6df: 5b pop %ebx
|
|
6e0: 5e pop %esi
|
|
6e1: 5f pop %edi
|
|
6e2: 5d pop %ebp
|
|
6e3: c3 ret
|
|
6e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
neg = 0;
|
|
6e8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
|
|
6ef: eb 87 jmp 678 <printint+0x28>
|
|
6f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
6f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
6ff: 90 nop
|
|
|
|
00000700 <printf>:
|
|
|
|
// Print to the given fd. Only understands %d, %x, %p, %s.
|
|
void printf(int fd, const char *fmt, ...) {
|
|
700: 55 push %ebp
|
|
701: 89 e5 mov %esp,%ebp
|
|
703: 57 push %edi
|
|
704: 56 push %esi
|
|
705: 53 push %ebx
|
|
706: 83 ec 2c sub $0x2c,%esp
|
|
int c, i, state;
|
|
uint *ap;
|
|
|
|
state = 0;
|
|
ap = (uint*)(void*)&fmt + 1;
|
|
for (i = 0; fmt[i]; i++) {
|
|
709: 8b 5d 0c mov 0xc(%ebp),%ebx
|
|
void printf(int fd, const char *fmt, ...) {
|
|
70c: 8b 75 08 mov 0x8(%ebp),%esi
|
|
for (i = 0; fmt[i]; i++) {
|
|
70f: 0f b6 13 movzbl (%ebx),%edx
|
|
712: 84 d2 test %dl,%dl
|
|
714: 74 6a je 780 <printf+0x80>
|
|
ap = (uint*)(void*)&fmt + 1;
|
|
716: 8d 45 10 lea 0x10(%ebp),%eax
|
|
719: 83 c3 01 add $0x1,%ebx
|
|
write(fd, &c, 1);
|
|
71c: 8d 7d e7 lea -0x19(%ebp),%edi
|
|
state = 0;
|
|
71f: 31 c9 xor %ecx,%ecx
|
|
ap = (uint*)(void*)&fmt + 1;
|
|
721: 89 45 d0 mov %eax,-0x30(%ebp)
|
|
724: eb 36 jmp 75c <printf+0x5c>
|
|
726: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
72d: 8d 76 00 lea 0x0(%esi),%esi
|
|
730: 89 4d d4 mov %ecx,-0x2c(%ebp)
|
|
c = fmt[i] & 0xff;
|
|
if (state == 0) {
|
|
if (c == '%') {
|
|
state = '%';
|
|
733: b9 25 00 00 00 mov $0x25,%ecx
|
|
if (c == '%') {
|
|
738: 83 f8 25 cmp $0x25,%eax
|
|
73b: 74 15 je 752 <printf+0x52>
|
|
write(fd, &c, 1);
|
|
73d: 83 ec 04 sub $0x4,%esp
|
|
740: 88 55 e7 mov %dl,-0x19(%ebp)
|
|
743: 6a 01 push $0x1
|
|
745: 57 push %edi
|
|
746: 56 push %esi
|
|
747: e8 b7 fe ff ff call 603 <write>
|
|
74c: 8b 4d d4 mov -0x2c(%ebp),%ecx
|
|
}
|
|
else {
|
|
putc(fd, c);
|
|
74f: 83 c4 10 add $0x10,%esp
|
|
for (i = 0; fmt[i]; i++) {
|
|
752: 0f b6 13 movzbl (%ebx),%edx
|
|
755: 83 c3 01 add $0x1,%ebx
|
|
758: 84 d2 test %dl,%dl
|
|
75a: 74 24 je 780 <printf+0x80>
|
|
c = fmt[i] & 0xff;
|
|
75c: 0f b6 c2 movzbl %dl,%eax
|
|
if (state == 0) {
|
|
75f: 85 c9 test %ecx,%ecx
|
|
761: 74 cd je 730 <printf+0x30>
|
|
}
|
|
}
|
|
else if (state == '%') {
|
|
763: 83 f9 25 cmp $0x25,%ecx
|
|
766: 75 ea jne 752 <printf+0x52>
|
|
if (c == 'd') {
|
|
768: 83 f8 25 cmp $0x25,%eax
|
|
76b: 0f 84 07 01 00 00 je 878 <printf+0x178>
|
|
771: 83 e8 63 sub $0x63,%eax
|
|
774: 83 f8 15 cmp $0x15,%eax
|
|
777: 77 17 ja 790 <printf+0x90>
|
|
779: ff 24 85 7c 0a 00 00 jmp *0xa7c(,%eax,4)
|
|
putc(fd, c);
|
|
}
|
|
state = 0;
|
|
}
|
|
}
|
|
}
|
|
780: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
783: 5b pop %ebx
|
|
784: 5e pop %esi
|
|
785: 5f pop %edi
|
|
786: 5d pop %ebp
|
|
787: c3 ret
|
|
788: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
78f: 90 nop
|
|
write(fd, &c, 1);
|
|
790: 83 ec 04 sub $0x4,%esp
|
|
793: 88 55 d4 mov %dl,-0x2c(%ebp)
|
|
796: 6a 01 push $0x1
|
|
798: 57 push %edi
|
|
799: 56 push %esi
|
|
79a: c6 45 e7 25 movb $0x25,-0x19(%ebp)
|
|
79e: e8 60 fe ff ff call 603 <write>
|
|
putc(fd, c);
|
|
7a3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx
|
|
write(fd, &c, 1);
|
|
7a7: 83 c4 0c add $0xc,%esp
|
|
7aa: 88 55 e7 mov %dl,-0x19(%ebp)
|
|
7ad: 6a 01 push $0x1
|
|
7af: 57 push %edi
|
|
7b0: 56 push %esi
|
|
7b1: e8 4d fe ff ff call 603 <write>
|
|
putc(fd, c);
|
|
7b6: 83 c4 10 add $0x10,%esp
|
|
state = 0;
|
|
7b9: 31 c9 xor %ecx,%ecx
|
|
7bb: eb 95 jmp 752 <printf+0x52>
|
|
7bd: 8d 76 00 lea 0x0(%esi),%esi
|
|
printint(fd, *ap, 16, 0);
|
|
7c0: 83 ec 0c sub $0xc,%esp
|
|
7c3: b9 10 00 00 00 mov $0x10,%ecx
|
|
7c8: 6a 00 push $0x0
|
|
7ca: 8b 45 d0 mov -0x30(%ebp),%eax
|
|
7cd: 8b 10 mov (%eax),%edx
|
|
7cf: 89 f0 mov %esi,%eax
|
|
7d1: e8 7a fe ff ff call 650 <printint>
|
|
ap++;
|
|
7d6: 83 45 d0 04 addl $0x4,-0x30(%ebp)
|
|
7da: 83 c4 10 add $0x10,%esp
|
|
state = 0;
|
|
7dd: 31 c9 xor %ecx,%ecx
|
|
7df: e9 6e ff ff ff jmp 752 <printf+0x52>
|
|
7e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
s = (char*)*ap;
|
|
7e8: 8b 45 d0 mov -0x30(%ebp),%eax
|
|
7eb: 8b 10 mov (%eax),%edx
|
|
ap++;
|
|
7ed: 83 c0 04 add $0x4,%eax
|
|
7f0: 89 45 d0 mov %eax,-0x30(%ebp)
|
|
if (s == 0) {
|
|
7f3: 85 d2 test %edx,%edx
|
|
7f5: 0f 84 8d 00 00 00 je 888 <printf+0x188>
|
|
while (*s != 0) {
|
|
7fb: 0f b6 02 movzbl (%edx),%eax
|
|
state = 0;
|
|
7fe: 31 c9 xor %ecx,%ecx
|
|
while (*s != 0) {
|
|
800: 84 c0 test %al,%al
|
|
802: 0f 84 4a ff ff ff je 752 <printf+0x52>
|
|
808: 89 5d d4 mov %ebx,-0x2c(%ebp)
|
|
80b: 89 d3 mov %edx,%ebx
|
|
80d: 8d 76 00 lea 0x0(%esi),%esi
|
|
write(fd, &c, 1);
|
|
810: 83 ec 04 sub $0x4,%esp
|
|
s++;
|
|
813: 83 c3 01 add $0x1,%ebx
|
|
816: 88 45 e7 mov %al,-0x19(%ebp)
|
|
write(fd, &c, 1);
|
|
819: 6a 01 push $0x1
|
|
81b: 57 push %edi
|
|
81c: 56 push %esi
|
|
81d: e8 e1 fd ff ff call 603 <write>
|
|
while (*s != 0) {
|
|
822: 0f b6 03 movzbl (%ebx),%eax
|
|
825: 83 c4 10 add $0x10,%esp
|
|
828: 84 c0 test %al,%al
|
|
82a: 75 e4 jne 810 <printf+0x110>
|
|
state = 0;
|
|
82c: 8b 5d d4 mov -0x2c(%ebp),%ebx
|
|
82f: 31 c9 xor %ecx,%ecx
|
|
831: e9 1c ff ff ff jmp 752 <printf+0x52>
|
|
836: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
83d: 8d 76 00 lea 0x0(%esi),%esi
|
|
printint(fd, *ap, 10, 1);
|
|
840: 83 ec 0c sub $0xc,%esp
|
|
843: b9 0a 00 00 00 mov $0xa,%ecx
|
|
848: 6a 01 push $0x1
|
|
84a: e9 7b ff ff ff jmp 7ca <printf+0xca>
|
|
84f: 90 nop
|
|
putc(fd, *ap);
|
|
850: 8b 45 d0 mov -0x30(%ebp),%eax
|
|
write(fd, &c, 1);
|
|
853: 83 ec 04 sub $0x4,%esp
|
|
putc(fd, *ap);
|
|
856: 8b 00 mov (%eax),%eax
|
|
write(fd, &c, 1);
|
|
858: 6a 01 push $0x1
|
|
85a: 57 push %edi
|
|
85b: 56 push %esi
|
|
putc(fd, *ap);
|
|
85c: 88 45 e7 mov %al,-0x19(%ebp)
|
|
write(fd, &c, 1);
|
|
85f: e8 9f fd ff ff call 603 <write>
|
|
ap++;
|
|
864: 83 45 d0 04 addl $0x4,-0x30(%ebp)
|
|
868: 83 c4 10 add $0x10,%esp
|
|
state = 0;
|
|
86b: 31 c9 xor %ecx,%ecx
|
|
86d: e9 e0 fe ff ff jmp 752 <printf+0x52>
|
|
872: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
|
|
putc(fd, c);
|
|
878: 88 55 e7 mov %dl,-0x19(%ebp)
|
|
write(fd, &c, 1);
|
|
87b: 83 ec 04 sub $0x4,%esp
|
|
87e: e9 2a ff ff ff jmp 7ad <printf+0xad>
|
|
883: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
887: 90 nop
|
|
s = "(null)";
|
|
888: ba 72 0a 00 00 mov $0xa72,%edx
|
|
while (*s != 0) {
|
|
88d: 89 5d d4 mov %ebx,-0x2c(%ebp)
|
|
890: b8 28 00 00 00 mov $0x28,%eax
|
|
895: 89 d3 mov %edx,%ebx
|
|
897: e9 74 ff ff ff jmp 810 <printf+0x110>
|
|
89c: 66 90 xchg %ax,%ax
|
|
89e: 66 90 xchg %ax,%ax
|
|
|
|
000008a0 <free>:
|
|
typedef union header Header;
|
|
|
|
static Header base;
|
|
static Header *freep;
|
|
|
|
void free(void *ap) {
|
|
8a0: 55 push %ebp
|
|
Header *bp, *p;
|
|
|
|
bp = (Header*)ap - 1;
|
|
for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) {
|
|
8a1: a1 14 0e 00 00 mov 0xe14,%eax
|
|
void free(void *ap) {
|
|
8a6: 89 e5 mov %esp,%ebp
|
|
8a8: 57 push %edi
|
|
8a9: 56 push %esi
|
|
8aa: 53 push %ebx
|
|
8ab: 8b 5d 08 mov 0x8(%ebp),%ebx
|
|
bp = (Header*)ap - 1;
|
|
8ae: 8d 4b f8 lea -0x8(%ebx),%ecx
|
|
for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) {
|
|
8b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
|
|
8b8: 89 c2 mov %eax,%edx
|
|
8ba: 8b 00 mov (%eax),%eax
|
|
8bc: 39 ca cmp %ecx,%edx
|
|
8be: 73 30 jae 8f0 <free+0x50>
|
|
8c0: 39 c1 cmp %eax,%ecx
|
|
8c2: 72 04 jb 8c8 <free+0x28>
|
|
if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) {
|
|
8c4: 39 c2 cmp %eax,%edx
|
|
8c6: 72 f0 jb 8b8 <free+0x18>
|
|
break;
|
|
}
|
|
}
|
|
if (bp + bp->s.size == p->s.ptr) {
|
|
8c8: 8b 73 fc mov -0x4(%ebx),%esi
|
|
8cb: 8d 3c f1 lea (%ecx,%esi,8),%edi
|
|
8ce: 39 f8 cmp %edi,%eax
|
|
8d0: 74 30 je 902 <free+0x62>
|
|
bp->s.size += p->s.ptr->s.size;
|
|
bp->s.ptr = p->s.ptr->s.ptr;
|
|
8d2: 89 43 f8 mov %eax,-0x8(%ebx)
|
|
}
|
|
else {
|
|
bp->s.ptr = p->s.ptr;
|
|
}
|
|
if (p + p->s.size == bp) {
|
|
8d5: 8b 42 04 mov 0x4(%edx),%eax
|
|
8d8: 8d 34 c2 lea (%edx,%eax,8),%esi
|
|
8db: 39 f1 cmp %esi,%ecx
|
|
8dd: 74 3a je 919 <free+0x79>
|
|
p->s.size += bp->s.size;
|
|
p->s.ptr = bp->s.ptr;
|
|
8df: 89 0a mov %ecx,(%edx)
|
|
}
|
|
else {
|
|
p->s.ptr = bp;
|
|
}
|
|
freep = p;
|
|
}
|
|
8e1: 5b pop %ebx
|
|
freep = p;
|
|
8e2: 89 15 14 0e 00 00 mov %edx,0xe14
|
|
}
|
|
8e8: 5e pop %esi
|
|
8e9: 5f pop %edi
|
|
8ea: 5d pop %ebp
|
|
8eb: c3 ret
|
|
8ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
|
|
if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) {
|
|
8f0: 39 c2 cmp %eax,%edx
|
|
8f2: 72 c4 jb 8b8 <free+0x18>
|
|
8f4: 39 c1 cmp %eax,%ecx
|
|
8f6: 73 c0 jae 8b8 <free+0x18>
|
|
if (bp + bp->s.size == p->s.ptr) {
|
|
8f8: 8b 73 fc mov -0x4(%ebx),%esi
|
|
8fb: 8d 3c f1 lea (%ecx,%esi,8),%edi
|
|
8fe: 39 f8 cmp %edi,%eax
|
|
900: 75 d0 jne 8d2 <free+0x32>
|
|
bp->s.size += p->s.ptr->s.size;
|
|
902: 03 70 04 add 0x4(%eax),%esi
|
|
905: 89 73 fc mov %esi,-0x4(%ebx)
|
|
bp->s.ptr = p->s.ptr->s.ptr;
|
|
908: 8b 02 mov (%edx),%eax
|
|
90a: 8b 00 mov (%eax),%eax
|
|
90c: 89 43 f8 mov %eax,-0x8(%ebx)
|
|
if (p + p->s.size == bp) {
|
|
90f: 8b 42 04 mov 0x4(%edx),%eax
|
|
912: 8d 34 c2 lea (%edx,%eax,8),%esi
|
|
915: 39 f1 cmp %esi,%ecx
|
|
917: 75 c6 jne 8df <free+0x3f>
|
|
p->s.size += bp->s.size;
|
|
919: 03 43 fc add -0x4(%ebx),%eax
|
|
freep = p;
|
|
91c: 89 15 14 0e 00 00 mov %edx,0xe14
|
|
p->s.size += bp->s.size;
|
|
922: 89 42 04 mov %eax,0x4(%edx)
|
|
p->s.ptr = bp->s.ptr;
|
|
925: 8b 4b f8 mov -0x8(%ebx),%ecx
|
|
928: 89 0a mov %ecx,(%edx)
|
|
}
|
|
92a: 5b pop %ebx
|
|
92b: 5e pop %esi
|
|
92c: 5f pop %edi
|
|
92d: 5d pop %ebp
|
|
92e: c3 ret
|
|
92f: 90 nop
|
|
|
|
00000930 <malloc>:
|
|
hp->s.size = nu;
|
|
free((void*)(hp + 1));
|
|
return freep;
|
|
}
|
|
|
|
void* malloc(uint nbytes) {
|
|
930: 55 push %ebp
|
|
931: 89 e5 mov %esp,%ebp
|
|
933: 57 push %edi
|
|
934: 56 push %esi
|
|
935: 53 push %ebx
|
|
936: 83 ec 1c sub $0x1c,%esp
|
|
Header *p, *prevp;
|
|
uint nunits;
|
|
|
|
nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1;
|
|
939: 8b 45 08 mov 0x8(%ebp),%eax
|
|
if ((prevp = freep) == 0) {
|
|
93c: 8b 3d 14 0e 00 00 mov 0xe14,%edi
|
|
nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1;
|
|
942: 8d 70 07 lea 0x7(%eax),%esi
|
|
945: c1 ee 03 shr $0x3,%esi
|
|
948: 83 c6 01 add $0x1,%esi
|
|
if ((prevp = freep) == 0) {
|
|
94b: 85 ff test %edi,%edi
|
|
94d: 0f 84 9d 00 00 00 je 9f0 <malloc+0xc0>
|
|
base.s.ptr = freep = prevp = &base;
|
|
base.s.size = 0;
|
|
}
|
|
for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) {
|
|
953: 8b 17 mov (%edi),%edx
|
|
if (p->s.size >= nunits) {
|
|
955: 8b 4a 04 mov 0x4(%edx),%ecx
|
|
958: 39 f1 cmp %esi,%ecx
|
|
95a: 73 6a jae 9c6 <malloc+0x96>
|
|
95c: bb 00 10 00 00 mov $0x1000,%ebx
|
|
961: 39 de cmp %ebx,%esi
|
|
963: 0f 43 de cmovae %esi,%ebx
|
|
p = sbrk(nu * sizeof(Header));
|
|
966: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
|
|
96d: 89 45 e4 mov %eax,-0x1c(%ebp)
|
|
970: eb 17 jmp 989 <malloc+0x59>
|
|
972: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
|
|
for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) {
|
|
978: 8b 02 mov (%edx),%eax
|
|
if (p->s.size >= nunits) {
|
|
97a: 8b 48 04 mov 0x4(%eax),%ecx
|
|
97d: 39 f1 cmp %esi,%ecx
|
|
97f: 73 4f jae 9d0 <malloc+0xa0>
|
|
p->s.size = nunits;
|
|
}
|
|
freep = prevp;
|
|
return (void*)(p + 1);
|
|
}
|
|
if (p == freep) {
|
|
981: 8b 3d 14 0e 00 00 mov 0xe14,%edi
|
|
987: 89 c2 mov %eax,%edx
|
|
989: 39 d7 cmp %edx,%edi
|
|
98b: 75 eb jne 978 <malloc+0x48>
|
|
p = sbrk(nu * sizeof(Header));
|
|
98d: 83 ec 0c sub $0xc,%esp
|
|
990: ff 75 e4 push -0x1c(%ebp)
|
|
993: e8 4b fc ff ff call 5e3 <sbrk>
|
|
if (p == (char*)-1) {
|
|
998: 83 c4 10 add $0x10,%esp
|
|
99b: 83 f8 ff cmp $0xffffffff,%eax
|
|
99e: 74 1c je 9bc <malloc+0x8c>
|
|
hp->s.size = nu;
|
|
9a0: 89 58 04 mov %ebx,0x4(%eax)
|
|
free((void*)(hp + 1));
|
|
9a3: 83 ec 0c sub $0xc,%esp
|
|
9a6: 83 c0 08 add $0x8,%eax
|
|
9a9: 50 push %eax
|
|
9aa: e8 f1 fe ff ff call 8a0 <free>
|
|
return freep;
|
|
9af: 8b 15 14 0e 00 00 mov 0xe14,%edx
|
|
if ((p = morecore(nunits)) == 0) {
|
|
9b5: 83 c4 10 add $0x10,%esp
|
|
9b8: 85 d2 test %edx,%edx
|
|
9ba: 75 bc jne 978 <malloc+0x48>
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
9bc: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
return 0;
|
|
9bf: 31 c0 xor %eax,%eax
|
|
}
|
|
9c1: 5b pop %ebx
|
|
9c2: 5e pop %esi
|
|
9c3: 5f pop %edi
|
|
9c4: 5d pop %ebp
|
|
9c5: c3 ret
|
|
if (p->s.size >= nunits) {
|
|
9c6: 89 d0 mov %edx,%eax
|
|
9c8: 89 fa mov %edi,%edx
|
|
9ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
|
|
if (p->s.size == nunits) {
|
|
9d0: 39 ce cmp %ecx,%esi
|
|
9d2: 74 4c je a20 <malloc+0xf0>
|
|
p->s.size -= nunits;
|
|
9d4: 29 f1 sub %esi,%ecx
|
|
9d6: 89 48 04 mov %ecx,0x4(%eax)
|
|
p += p->s.size;
|
|
9d9: 8d 04 c8 lea (%eax,%ecx,8),%eax
|
|
p->s.size = nunits;
|
|
9dc: 89 70 04 mov %esi,0x4(%eax)
|
|
freep = prevp;
|
|
9df: 89 15 14 0e 00 00 mov %edx,0xe14
|
|
}
|
|
9e5: 8d 65 f4 lea -0xc(%ebp),%esp
|
|
return (void*)(p + 1);
|
|
9e8: 83 c0 08 add $0x8,%eax
|
|
}
|
|
9eb: 5b pop %ebx
|
|
9ec: 5e pop %esi
|
|
9ed: 5f pop %edi
|
|
9ee: 5d pop %ebp
|
|
9ef: c3 ret
|
|
base.s.ptr = freep = prevp = &base;
|
|
9f0: c7 05 14 0e 00 00 18 movl $0xe18,0xe14
|
|
9f7: 0e 00 00
|
|
base.s.size = 0;
|
|
9fa: bf 18 0e 00 00 mov $0xe18,%edi
|
|
base.s.ptr = freep = prevp = &base;
|
|
9ff: c7 05 18 0e 00 00 18 movl $0xe18,0xe18
|
|
a06: 0e 00 00
|
|
for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) {
|
|
a09: 89 fa mov %edi,%edx
|
|
base.s.size = 0;
|
|
a0b: c7 05 1c 0e 00 00 00 movl $0x0,0xe1c
|
|
a12: 00 00 00
|
|
if (p->s.size >= nunits) {
|
|
a15: e9 42 ff ff ff jmp 95c <malloc+0x2c>
|
|
a1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
|
|
prevp->s.ptr = p->s.ptr;
|
|
a20: 8b 08 mov (%eax),%ecx
|
|
a22: 89 0a mov %ecx,(%edx)
|
|
a24: eb b9 jmp 9df <malloc+0xaf>
|