diff --git a/_argtest b/_argtest new file mode 100644 index 0000000..c93bec2 Binary files /dev/null and b/_argtest differ diff --git a/_cat b/_cat new file mode 100644 index 0000000..d6728e0 Binary files /dev/null and b/_cat differ diff --git a/_cls b/_cls new file mode 100644 index 0000000..5787f6b Binary files /dev/null and b/_cls differ diff --git a/_count b/_count new file mode 100644 index 0000000..9382801 Binary files /dev/null and b/_count differ diff --git a/_echo b/_echo new file mode 100644 index 0000000..2c6726e Binary files /dev/null and b/_echo differ diff --git a/_forktest b/_forktest new file mode 100644 index 0000000..51ab323 Binary files /dev/null and b/_forktest differ diff --git a/_grep b/_grep new file mode 100644 index 0000000..2668231 Binary files /dev/null and b/_grep differ diff --git a/_hello b/_hello new file mode 100644 index 0000000..d685260 Binary files /dev/null and b/_hello differ diff --git a/_init b/_init new file mode 100644 index 0000000..b9b8886 Binary files /dev/null and b/_init differ diff --git a/_kill b/_kill new file mode 100644 index 0000000..d9c9a7c Binary files /dev/null and b/_kill differ diff --git a/_ln b/_ln new file mode 100644 index 0000000..3a8baa6 Binary files /dev/null and b/_ln differ diff --git a/_ls b/_ls new file mode 100644 index 0000000..3aca050 Binary files /dev/null and b/_ls differ diff --git a/_maze b/_maze new file mode 100644 index 0000000..fd75f4c Binary files /dev/null and b/_maze differ diff --git a/_mkdir b/_mkdir new file mode 100644 index 0000000..4463bee Binary files /dev/null and b/_mkdir differ diff --git a/_rm b/_rm new file mode 100644 index 0000000..76c61c0 Binary files /dev/null and b/_rm differ diff --git a/_screen b/_screen new file mode 100644 index 0000000..7b6821b Binary files /dev/null and b/_screen differ diff --git a/_sh b/_sh new file mode 100644 index 0000000..ab57690 Binary files /dev/null and b/_sh differ diff --git a/_shutdown b/_shutdown new file mode 100644 index 0000000..29dbda2 Binary files /dev/null and b/_shutdown differ diff --git a/_stressfs b/_stressfs new file mode 100644 index 0000000..77d010e Binary files /dev/null and b/_stressfs differ diff --git a/_usertests b/_usertests new file mode 100644 index 0000000..7fd2312 Binary files /dev/null and b/_usertests differ diff --git a/_wc b/_wc new file mode 100644 index 0000000..0592ba9 Binary files /dev/null and b/_wc differ diff --git a/_zombie b/_zombie new file mode 100644 index 0000000..38ee707 Binary files /dev/null and b/_zombie differ diff --git a/argtest.asm b/argtest.asm new file mode 100644 index 0000000..2d20cb2 --- /dev/null +++ b/argtest.asm @@ -0,0 +1,1174 @@ + +_argtest: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "user.h" + +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: 51 push %ecx + 11: 83 ec 08 sub $0x8,%esp + 14: 8b 31 mov (%ecx),%esi + 16: 8b 79 04 mov 0x4(%ecx),%edi + for (int i = 1; i < argc; i++) { + 19: 83 fe 01 cmp $0x1,%esi + 1c: 7e 24 jle 42 + 1e: bb 01 00 00 00 mov $0x1,%ebx + 23: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 27: 90 nop + printf(1, "Arg %d: %s\n", i, argv[i]); + 28: ff 34 9f push (%edi,%ebx,4) + 2b: 53 push %ebx + for (int i = 1; i < argc; i++) { + 2c: 83 c3 01 add $0x1,%ebx + printf(1, "Arg %d: %s\n", i, argv[i]); + 2f: 68 48 07 00 00 push $0x748 + 34: 6a 01 push $0x1 + 36: e8 e5 03 00 00 call 420 + for (int i = 1; i < argc; i++) { + 3b: 83 c4 10 add $0x10,%esp + 3e: 39 de cmp %ebx,%esi + 40: 75 e6 jne 28 + } + + exit(); + 42: e8 5c 02 00 00 call 2a3 + 47: 66 90 xchg %ax,%ax + 49: 66 90 xchg %ax,%ax + 4b: 66 90 xchg %ax,%ax + 4d: 66 90 xchg %ax,%ax + 4f: 90 nop + +00000050 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 50: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 51: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 53: 89 e5 mov %esp,%ebp + 55: 53 push %ebx + 56: 8b 4d 08 mov 0x8(%ebp),%ecx + 59: 8b 5d 0c mov 0xc(%ebp),%ebx + 5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 60: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 64: 88 14 01 mov %dl,(%ecx,%eax,1) + 67: 83 c0 01 add $0x1,%eax + 6a: 84 d2 test %dl,%dl + 6c: 75 f2 jne 60 + ; + } + return os; +} + 6e: 8b 5d fc mov -0x4(%ebp),%ebx + 71: 89 c8 mov %ecx,%eax + 73: c9 leave + 74: c3 ret + 75: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000080 : + +int strcmp(const char *p, const char *q) { + 80: 55 push %ebp + 81: 89 e5 mov %esp,%ebp + 83: 53 push %ebx + 84: 8b 55 08 mov 0x8(%ebp),%edx + 87: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 8a: 0f b6 02 movzbl (%edx),%eax + 8d: 84 c0 test %al,%al + 8f: 75 17 jne a8 + 91: eb 3a jmp cd + 93: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 97: 90 nop + 98: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 9c: 83 c2 01 add $0x1,%edx + 9f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + a2: 84 c0 test %al,%al + a4: 74 1a je c0 + p++, q++; + a6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + a8: 0f b6 19 movzbl (%ecx),%ebx + ab: 38 c3 cmp %al,%bl + ad: 74 e9 je 98 + } + return (uchar) * p - (uchar) * q; + af: 29 d8 sub %ebx,%eax +} + b1: 8b 5d fc mov -0x4(%ebp),%ebx + b4: c9 leave + b5: c3 ret + b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + bd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + c0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + c4: 31 c0 xor %eax,%eax + c6: 29 d8 sub %ebx,%eax +} + c8: 8b 5d fc mov -0x4(%ebp),%ebx + cb: c9 leave + cc: c3 ret + return (uchar) * p - (uchar) * q; + cd: 0f b6 19 movzbl (%ecx),%ebx + d0: 31 c0 xor %eax,%eax + d2: eb db jmp af + d4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + df: 90 nop + +000000e0 : + +uint strlen(const char *s) { + e0: 55 push %ebp + e1: 89 e5 mov %esp,%ebp + e3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + e6: 80 3a 00 cmpb $0x0,(%edx) + e9: 74 15 je 100 + eb: 31 c0 xor %eax,%eax + ed: 8d 76 00 lea 0x0(%esi),%esi + f0: 83 c0 01 add $0x1,%eax + f3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + f7: 89 c1 mov %eax,%ecx + f9: 75 f5 jne f0 + ; + } + return n; +} + fb: 89 c8 mov %ecx,%eax + fd: 5d pop %ebp + fe: c3 ret + ff: 90 nop + for (n = 0; s[n]; n++) { + 100: 31 c9 xor %ecx,%ecx +} + 102: 5d pop %ebp + 103: 89 c8 mov %ecx,%eax + 105: c3 ret + 106: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 10d: 8d 76 00 lea 0x0(%esi),%esi + +00000110 : + +void* memset(void *dst, int c, uint n) { + 110: 55 push %ebp + 111: 89 e5 mov %esp,%ebp + 113: 57 push %edi + 114: 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" : + 117: 8b 4d 10 mov 0x10(%ebp),%ecx + 11a: 8b 45 0c mov 0xc(%ebp),%eax + 11d: 89 d7 mov %edx,%edi + 11f: fc cld + 120: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 122: 8b 7d fc mov -0x4(%ebp),%edi + 125: 89 d0 mov %edx,%eax + 127: c9 leave + 128: c3 ret + 129: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000130 : + +char* strchr(const char *s, char c) { + 130: 55 push %ebp + 131: 89 e5 mov %esp,%ebp + 133: 8b 45 08 mov 0x8(%ebp),%eax + 136: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 13a: 0f b6 10 movzbl (%eax),%edx + 13d: 84 d2 test %dl,%dl + 13f: 75 12 jne 153 + 141: eb 1d jmp 160 + 143: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 147: 90 nop + 148: 0f b6 50 01 movzbl 0x1(%eax),%edx + 14c: 83 c0 01 add $0x1,%eax + 14f: 84 d2 test %dl,%dl + 151: 74 0d je 160 + if (*s == c) { + 153: 38 d1 cmp %dl,%cl + 155: 75 f1 jne 148 + return (char*)s; + } + } + return 0; +} + 157: 5d pop %ebp + 158: c3 ret + 159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 160: 31 c0 xor %eax,%eax +} + 162: 5d pop %ebp + 163: c3 ret + 164: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 16b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 16f: 90 nop + +00000170 : + +char* gets(char *buf, int max) { + 170: 55 push %ebp + 171: 89 e5 mov %esp,%ebp + 173: 57 push %edi + 174: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 175: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 178: 53 push %ebx + for (i = 0; i + 1 < max;) { + 179: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 17b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 17e: eb 27 jmp 1a7 + cc = read(0, &c, 1); + 180: 83 ec 04 sub $0x4,%esp + 183: 6a 01 push $0x1 + 185: 57 push %edi + 186: 6a 00 push $0x0 + 188: e8 2e 01 00 00 call 2bb + if (cc < 1) { + 18d: 83 c4 10 add $0x10,%esp + 190: 85 c0 test %eax,%eax + 192: 7e 1d jle 1b1 + break; + } + buf[i++] = c; + 194: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 198: 8b 55 08 mov 0x8(%ebp),%edx + 19b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 19f: 3c 0a cmp $0xa,%al + 1a1: 74 1d je 1c0 + 1a3: 3c 0d cmp $0xd,%al + 1a5: 74 19 je 1c0 + for (i = 0; i + 1 < max;) { + 1a7: 89 de mov %ebx,%esi + 1a9: 83 c3 01 add $0x1,%ebx + 1ac: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1af: 7c cf jl 180 + break; + } + } + buf[i] = '\0'; + 1b1: 8b 45 08 mov 0x8(%ebp),%eax + 1b4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1b8: 8d 65 f4 lea -0xc(%ebp),%esp + 1bb: 5b pop %ebx + 1bc: 5e pop %esi + 1bd: 5f pop %edi + 1be: 5d pop %ebp + 1bf: c3 ret + buf[i] = '\0'; + 1c0: 8b 45 08 mov 0x8(%ebp),%eax + 1c3: 89 de mov %ebx,%esi + 1c5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1c9: 8d 65 f4 lea -0xc(%ebp),%esp + 1cc: 5b pop %ebx + 1cd: 5e pop %esi + 1ce: 5f pop %edi + 1cf: 5d pop %ebp + 1d0: c3 ret + 1d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1df: 90 nop + +000001e0 : + +int stat(const char *n, struct stat *st) { + 1e0: 55 push %ebp + 1e1: 89 e5 mov %esp,%ebp + 1e3: 56 push %esi + 1e4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 1e5: 83 ec 08 sub $0x8,%esp + 1e8: 6a 00 push $0x0 + 1ea: ff 75 08 push 0x8(%ebp) + 1ed: e8 19 01 00 00 call 30b + if (fd < 0) { + 1f2: 83 c4 10 add $0x10,%esp + 1f5: 85 c0 test %eax,%eax + 1f7: 78 27 js 220 + return -1; + } + r = fstat(fd, st); + 1f9: 83 ec 08 sub $0x8,%esp + 1fc: ff 75 0c push 0xc(%ebp) + 1ff: 89 c3 mov %eax,%ebx + 201: 50 push %eax + 202: e8 cc 00 00 00 call 2d3 + close(fd); + 207: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 20a: 89 c6 mov %eax,%esi + close(fd); + 20c: e8 2a 01 00 00 call 33b + return r; + 211: 83 c4 10 add $0x10,%esp +} + 214: 8d 65 f8 lea -0x8(%ebp),%esp + 217: 89 f0 mov %esi,%eax + 219: 5b pop %ebx + 21a: 5e pop %esi + 21b: 5d pop %ebp + 21c: c3 ret + 21d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 220: be ff ff ff ff mov $0xffffffff,%esi + 225: eb ed jmp 214 + 227: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 22e: 66 90 xchg %ax,%ax + +00000230 : + +int atoi(const char *s) { + 230: 55 push %ebp + 231: 89 e5 mov %esp,%ebp + 233: 53 push %ebx + 234: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 237: 0f be 02 movsbl (%edx),%eax + 23a: 8d 48 d0 lea -0x30(%eax),%ecx + 23d: 80 f9 09 cmp $0x9,%cl + n = 0; + 240: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 245: 77 1e ja 265 + 247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 24e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 250: 83 c2 01 add $0x1,%edx + 253: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 256: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 25a: 0f be 02 movsbl (%edx),%eax + 25d: 8d 58 d0 lea -0x30(%eax),%ebx + 260: 80 fb 09 cmp $0x9,%bl + 263: 76 eb jbe 250 + } + return n; +} + 265: 8b 5d fc mov -0x4(%ebp),%ebx + 268: 89 c8 mov %ecx,%eax + 26a: c9 leave + 26b: c3 ret + 26c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000270 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 270: 55 push %ebp + 271: 89 e5 mov %esp,%ebp + 273: 57 push %edi + 274: 8b 45 10 mov 0x10(%ebp),%eax + 277: 8b 55 08 mov 0x8(%ebp),%edx + 27a: 56 push %esi + 27b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 27e: 85 c0 test %eax,%eax + 280: 7e 13 jle 295 + 282: 01 d0 add %edx,%eax + dst = vdst; + 284: 89 d7 mov %edx,%edi + 286: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 28d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 290: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 291: 39 f8 cmp %edi,%eax + 293: 75 fb jne 290 + } + return vdst; +} + 295: 5e pop %esi + 296: 89 d0 mov %edx,%eax + 298: 5f pop %edi + 299: 5d pop %ebp + 29a: c3 ret + +0000029b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 29b: b8 01 00 00 00 mov $0x1,%eax + 2a0: cd 40 int $0x40 + 2a2: c3 ret + +000002a3 : +SYSCALL(exit) + 2a3: b8 02 00 00 00 mov $0x2,%eax + 2a8: cd 40 int $0x40 + 2aa: c3 ret + +000002ab : +SYSCALL(wait) + 2ab: b8 03 00 00 00 mov $0x3,%eax + 2b0: cd 40 int $0x40 + 2b2: c3 ret + +000002b3 : +SYSCALL(pipe) + 2b3: b8 04 00 00 00 mov $0x4,%eax + 2b8: cd 40 int $0x40 + 2ba: c3 ret + +000002bb : +SYSCALL(read) + 2bb: b8 05 00 00 00 mov $0x5,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(kill) + 2c3: b8 06 00 00 00 mov $0x6,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(exec) + 2cb: b8 07 00 00 00 mov $0x7,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(fstat) + 2d3: b8 08 00 00 00 mov $0x8,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(chdir) + 2db: b8 09 00 00 00 mov $0x9,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(dup) + 2e3: b8 0a 00 00 00 mov $0xa,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(getpid) + 2eb: b8 0b 00 00 00 mov $0xb,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(sbrk) + 2f3: b8 0c 00 00 00 mov $0xc,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(sleep) + 2fb: b8 0d 00 00 00 mov $0xd,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(uptime) + 303: b8 0e 00 00 00 mov $0xe,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(open) + 30b: b8 0f 00 00 00 mov $0xf,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(write) + 313: b8 10 00 00 00 mov $0x10,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(mknod) + 31b: b8 11 00 00 00 mov $0x11,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(unlink) + 323: b8 12 00 00 00 mov $0x12,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(link) + 32b: b8 13 00 00 00 mov $0x13,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(mkdir) + 333: b8 14 00 00 00 mov $0x14,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(close) + 33b: b8 15 00 00 00 mov $0x15,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(getch) + 343: b8 16 00 00 00 mov $0x16,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(greeting) + 34b: b8 17 00 00 00 mov $0x17,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(shutdown) + 353: b8 18 00 00 00 mov $0x18,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(screen) + 35b: b8 19 00 00 00 mov $0x19,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(cls) + 363: b8 1a 00 00 00 mov $0x1a,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + 36b: 66 90 xchg %ax,%ax + 36d: 66 90 xchg %ax,%ax + 36f: 90 nop + +00000370 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 370: 55 push %ebp + 371: 89 e5 mov %esp,%ebp + 373: 57 push %edi + 374: 56 push %esi + 375: 53 push %ebx + 376: 83 ec 3c sub $0x3c,%esp + 379: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 37c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 37e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 381: 85 d2 test %edx,%edx + 383: 0f 89 7f 00 00 00 jns 408 + 389: f6 45 08 01 testb $0x1,0x8(%ebp) + 38d: 74 79 je 408 + neg = 1; + 38f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 396: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 398: 31 db xor %ebx,%ebx + 39a: 8d 75 d7 lea -0x29(%ebp),%esi + 39d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3a0: 89 c8 mov %ecx,%eax + 3a2: 31 d2 xor %edx,%edx + 3a4: 89 cf mov %ecx,%edi + 3a6: f7 75 c4 divl -0x3c(%ebp) + 3a9: 0f b6 92 b4 07 00 00 movzbl 0x7b4(%edx),%edx + 3b0: 89 45 c0 mov %eax,-0x40(%ebp) + 3b3: 89 d8 mov %ebx,%eax + 3b5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3b8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3bb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3be: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3c1: 76 dd jbe 3a0 + if (neg) { + 3c3: 8b 4d bc mov -0x44(%ebp),%ecx + 3c6: 85 c9 test %ecx,%ecx + 3c8: 74 0c je 3d6 + buf[i++] = '-'; + 3ca: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3cf: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3d1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3d6: 8b 7d b8 mov -0x48(%ebp),%edi + 3d9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3dd: eb 07 jmp 3e6 + 3df: 90 nop + putc(fd, buf[i]); + 3e0: 0f b6 13 movzbl (%ebx),%edx + 3e3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 3e6: 83 ec 04 sub $0x4,%esp + 3e9: 88 55 d7 mov %dl,-0x29(%ebp) + 3ec: 6a 01 push $0x1 + 3ee: 56 push %esi + 3ef: 57 push %edi + 3f0: e8 1e ff ff ff call 313 + while (--i >= 0) { + 3f5: 83 c4 10 add $0x10,%esp + 3f8: 39 de cmp %ebx,%esi + 3fa: 75 e4 jne 3e0 + } +} + 3fc: 8d 65 f4 lea -0xc(%ebp),%esp + 3ff: 5b pop %ebx + 400: 5e pop %esi + 401: 5f pop %edi + 402: 5d pop %ebp + 403: c3 ret + 404: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 408: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 40f: eb 87 jmp 398 + 411: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 418: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 41f: 90 nop + +00000420 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 420: 55 push %ebp + 421: 89 e5 mov %esp,%ebp + 423: 57 push %edi + 424: 56 push %esi + 425: 53 push %ebx + 426: 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++) { + 429: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 42c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 42f: 0f b6 13 movzbl (%ebx),%edx + 432: 84 d2 test %dl,%dl + 434: 74 6a je 4a0 + ap = (uint*)(void*)&fmt + 1; + 436: 8d 45 10 lea 0x10(%ebp),%eax + 439: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 43c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 43f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 441: 89 45 d0 mov %eax,-0x30(%ebp) + 444: eb 36 jmp 47c + 446: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 44d: 8d 76 00 lea 0x0(%esi),%esi + 450: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 453: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 458: 83 f8 25 cmp $0x25,%eax + 45b: 74 15 je 472 + write(fd, &c, 1); + 45d: 83 ec 04 sub $0x4,%esp + 460: 88 55 e7 mov %dl,-0x19(%ebp) + 463: 6a 01 push $0x1 + 465: 57 push %edi + 466: 56 push %esi + 467: e8 a7 fe ff ff call 313 + 46c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 46f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 472: 0f b6 13 movzbl (%ebx),%edx + 475: 83 c3 01 add $0x1,%ebx + 478: 84 d2 test %dl,%dl + 47a: 74 24 je 4a0 + c = fmt[i] & 0xff; + 47c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 47f: 85 c9 test %ecx,%ecx + 481: 74 cd je 450 + } + } + else if (state == '%') { + 483: 83 f9 25 cmp $0x25,%ecx + 486: 75 ea jne 472 + if (c == 'd') { + 488: 83 f8 25 cmp $0x25,%eax + 48b: 0f 84 07 01 00 00 je 598 + 491: 83 e8 63 sub $0x63,%eax + 494: 83 f8 15 cmp $0x15,%eax + 497: 77 17 ja 4b0 + 499: ff 24 85 5c 07 00 00 jmp *0x75c(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4a0: 8d 65 f4 lea -0xc(%ebp),%esp + 4a3: 5b pop %ebx + 4a4: 5e pop %esi + 4a5: 5f pop %edi + 4a6: 5d pop %ebp + 4a7: c3 ret + 4a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4af: 90 nop + write(fd, &c, 1); + 4b0: 83 ec 04 sub $0x4,%esp + 4b3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4b6: 6a 01 push $0x1 + 4b8: 57 push %edi + 4b9: 56 push %esi + 4ba: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4be: e8 50 fe ff ff call 313 + putc(fd, c); + 4c3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4c7: 83 c4 0c add $0xc,%esp + 4ca: 88 55 e7 mov %dl,-0x19(%ebp) + 4cd: 6a 01 push $0x1 + 4cf: 57 push %edi + 4d0: 56 push %esi + 4d1: e8 3d fe ff ff call 313 + putc(fd, c); + 4d6: 83 c4 10 add $0x10,%esp + state = 0; + 4d9: 31 c9 xor %ecx,%ecx + 4db: eb 95 jmp 472 + 4dd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 4e0: 83 ec 0c sub $0xc,%esp + 4e3: b9 10 00 00 00 mov $0x10,%ecx + 4e8: 6a 00 push $0x0 + 4ea: 8b 45 d0 mov -0x30(%ebp),%eax + 4ed: 8b 10 mov (%eax),%edx + 4ef: 89 f0 mov %esi,%eax + 4f1: e8 7a fe ff ff call 370 + ap++; + 4f6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 4fa: 83 c4 10 add $0x10,%esp + state = 0; + 4fd: 31 c9 xor %ecx,%ecx + 4ff: e9 6e ff ff ff jmp 472 + 504: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 508: 8b 45 d0 mov -0x30(%ebp),%eax + 50b: 8b 10 mov (%eax),%edx + ap++; + 50d: 83 c0 04 add $0x4,%eax + 510: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 513: 85 d2 test %edx,%edx + 515: 0f 84 8d 00 00 00 je 5a8 + while (*s != 0) { + 51b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 51e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 520: 84 c0 test %al,%al + 522: 0f 84 4a ff ff ff je 472 + 528: 89 5d d4 mov %ebx,-0x2c(%ebp) + 52b: 89 d3 mov %edx,%ebx + 52d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 530: 83 ec 04 sub $0x4,%esp + s++; + 533: 83 c3 01 add $0x1,%ebx + 536: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 539: 6a 01 push $0x1 + 53b: 57 push %edi + 53c: 56 push %esi + 53d: e8 d1 fd ff ff call 313 + while (*s != 0) { + 542: 0f b6 03 movzbl (%ebx),%eax + 545: 83 c4 10 add $0x10,%esp + 548: 84 c0 test %al,%al + 54a: 75 e4 jne 530 + state = 0; + 54c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 54f: 31 c9 xor %ecx,%ecx + 551: e9 1c ff ff ff jmp 472 + 556: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 55d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 560: 83 ec 0c sub $0xc,%esp + 563: b9 0a 00 00 00 mov $0xa,%ecx + 568: 6a 01 push $0x1 + 56a: e9 7b ff ff ff jmp 4ea + 56f: 90 nop + putc(fd, *ap); + 570: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 573: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 576: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 578: 6a 01 push $0x1 + 57a: 57 push %edi + 57b: 56 push %esi + putc(fd, *ap); + 57c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 57f: e8 8f fd ff ff call 313 + ap++; + 584: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 588: 83 c4 10 add $0x10,%esp + state = 0; + 58b: 31 c9 xor %ecx,%ecx + 58d: e9 e0 fe ff ff jmp 472 + 592: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 598: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 59b: 83 ec 04 sub $0x4,%esp + 59e: e9 2a ff ff ff jmp 4cd + 5a3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5a7: 90 nop + s = "(null)"; + 5a8: ba 54 07 00 00 mov $0x754,%edx + while (*s != 0) { + 5ad: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5b0: b8 28 00 00 00 mov $0x28,%eax + 5b5: 89 d3 mov %edx,%ebx + 5b7: e9 74 ff ff ff jmp 530 + 5bc: 66 90 xchg %ax,%ax + 5be: 66 90 xchg %ax,%ax + +000005c0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5c0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5c1: a1 68 0a 00 00 mov 0xa68,%eax +void free(void *ap) { + 5c6: 89 e5 mov %esp,%ebp + 5c8: 57 push %edi + 5c9: 56 push %esi + 5ca: 53 push %ebx + 5cb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5ce: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5d8: 89 c2 mov %eax,%edx + 5da: 8b 00 mov (%eax),%eax + 5dc: 39 ca cmp %ecx,%edx + 5de: 73 30 jae 610 + 5e0: 39 c1 cmp %eax,%ecx + 5e2: 72 04 jb 5e8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5e4: 39 c2 cmp %eax,%edx + 5e6: 72 f0 jb 5d8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 5e8: 8b 73 fc mov -0x4(%ebx),%esi + 5eb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5ee: 39 f8 cmp %edi,%eax + 5f0: 74 30 je 622 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 5f2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 5f5: 8b 42 04 mov 0x4(%edx),%eax + 5f8: 8d 34 c2 lea (%edx,%eax,8),%esi + 5fb: 39 f1 cmp %esi,%ecx + 5fd: 74 3a je 639 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 5ff: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 601: 5b pop %ebx + freep = p; + 602: 89 15 68 0a 00 00 mov %edx,0xa68 +} + 608: 5e pop %esi + 609: 5f pop %edi + 60a: 5d pop %ebp + 60b: c3 ret + 60c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 610: 39 c2 cmp %eax,%edx + 612: 72 c4 jb 5d8 + 614: 39 c1 cmp %eax,%ecx + 616: 73 c0 jae 5d8 + if (bp + bp->s.size == p->s.ptr) { + 618: 8b 73 fc mov -0x4(%ebx),%esi + 61b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 61e: 39 f8 cmp %edi,%eax + 620: 75 d0 jne 5f2 + bp->s.size += p->s.ptr->s.size; + 622: 03 70 04 add 0x4(%eax),%esi + 625: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 628: 8b 02 mov (%edx),%eax + 62a: 8b 00 mov (%eax),%eax + 62c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 62f: 8b 42 04 mov 0x4(%edx),%eax + 632: 8d 34 c2 lea (%edx,%eax,8),%esi + 635: 39 f1 cmp %esi,%ecx + 637: 75 c6 jne 5ff + p->s.size += bp->s.size; + 639: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 63c: 89 15 68 0a 00 00 mov %edx,0xa68 + p->s.size += bp->s.size; + 642: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 645: 8b 4b f8 mov -0x8(%ebx),%ecx + 648: 89 0a mov %ecx,(%edx) +} + 64a: 5b pop %ebx + 64b: 5e pop %esi + 64c: 5f pop %edi + 64d: 5d pop %ebp + 64e: c3 ret + 64f: 90 nop + +00000650 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 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 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 659: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 65c: 8b 3d 68 0a 00 00 mov 0xa68,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 662: 8d 70 07 lea 0x7(%eax),%esi + 665: c1 ee 03 shr $0x3,%esi + 668: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 66b: 85 ff test %edi,%edi + 66d: 0f 84 9d 00 00 00 je 710 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 673: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 675: 8b 4a 04 mov 0x4(%edx),%ecx + 678: 39 f1 cmp %esi,%ecx + 67a: 73 6a jae 6e6 + 67c: bb 00 10 00 00 mov $0x1000,%ebx + 681: 39 de cmp %ebx,%esi + 683: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 686: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 68d: 89 45 e4 mov %eax,-0x1c(%ebp) + 690: eb 17 jmp 6a9 + 692: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 698: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 69a: 8b 48 04 mov 0x4(%eax),%ecx + 69d: 39 f1 cmp %esi,%ecx + 69f: 73 4f jae 6f0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6a1: 8b 3d 68 0a 00 00 mov 0xa68,%edi + 6a7: 89 c2 mov %eax,%edx + 6a9: 39 d7 cmp %edx,%edi + 6ab: 75 eb jne 698 + p = sbrk(nu * sizeof(Header)); + 6ad: 83 ec 0c sub $0xc,%esp + 6b0: ff 75 e4 push -0x1c(%ebp) + 6b3: e8 3b fc ff ff call 2f3 + if (p == (char*)-1) { + 6b8: 83 c4 10 add $0x10,%esp + 6bb: 83 f8 ff cmp $0xffffffff,%eax + 6be: 74 1c je 6dc + hp->s.size = nu; + 6c0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6c3: 83 ec 0c sub $0xc,%esp + 6c6: 83 c0 08 add $0x8,%eax + 6c9: 50 push %eax + 6ca: e8 f1 fe ff ff call 5c0 + return freep; + 6cf: 8b 15 68 0a 00 00 mov 0xa68,%edx + if ((p = morecore(nunits)) == 0) { + 6d5: 83 c4 10 add $0x10,%esp + 6d8: 85 d2 test %edx,%edx + 6da: 75 bc jne 698 + return 0; + } + } + } +} + 6dc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 6df: 31 c0 xor %eax,%eax +} + 6e1: 5b pop %ebx + 6e2: 5e pop %esi + 6e3: 5f pop %edi + 6e4: 5d pop %ebp + 6e5: c3 ret + if (p->s.size >= nunits) { + 6e6: 89 d0 mov %edx,%eax + 6e8: 89 fa mov %edi,%edx + 6ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 6f0: 39 ce cmp %ecx,%esi + 6f2: 74 4c je 740 + p->s.size -= nunits; + 6f4: 29 f1 sub %esi,%ecx + 6f6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 6f9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 6fc: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 6ff: 89 15 68 0a 00 00 mov %edx,0xa68 +} + 705: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 708: 83 c0 08 add $0x8,%eax +} + 70b: 5b pop %ebx + 70c: 5e pop %esi + 70d: 5f pop %edi + 70e: 5d pop %ebp + 70f: c3 ret + base.s.ptr = freep = prevp = &base; + 710: c7 05 68 0a 00 00 6c movl $0xa6c,0xa68 + 717: 0a 00 00 + base.s.size = 0; + 71a: bf 6c 0a 00 00 mov $0xa6c,%edi + base.s.ptr = freep = prevp = &base; + 71f: c7 05 6c 0a 00 00 6c movl $0xa6c,0xa6c + 726: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 729: 89 fa mov %edi,%edx + base.s.size = 0; + 72b: c7 05 70 0a 00 00 00 movl $0x0,0xa70 + 732: 00 00 00 + if (p->s.size >= nunits) { + 735: e9 42 ff ff ff jmp 67c + 73a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 740: 8b 08 mov (%eax),%ecx + 742: 89 0a mov %ecx,(%edx) + 744: eb b9 jmp 6ff diff --git a/argtest.d b/argtest.d new file mode 100644 index 0000000..2c57752 --- /dev/null +++ b/argtest.d @@ -0,0 +1 @@ +argtest.o: argtest.c /usr/include/stdc-predef.h types.h user.h diff --git a/argtest.o b/argtest.o new file mode 100644 index 0000000..2afe6e0 Binary files /dev/null and b/argtest.o differ diff --git a/argtest.sym b/argtest.sym new file mode 100644 index 0000000..69f8e8c --- /dev/null +++ b/argtest.sym @@ -0,0 +1,50 @@ +00000000 argtest.c +00000000 ulib.c +00000000 printf.c +00000370 printint +000007b4 digits.0 +00000000 umalloc.c +00000a68 freep +00000a6c base +00000050 strcpy +00000420 printf +0000034b greeting +00000270 memmove +0000031b mknod +00000170 gets +000002eb getpid +0000035b screen +00000650 malloc +000002fb sleep +000002b3 pipe +00000343 getch +00000313 write +000002d3 fstat +000002c3 kill +000002db chdir +000002cb exec +000002ab wait +000002bb read +00000323 unlink +0000029b fork +000002f3 sbrk +00000303 uptime +00000a68 __bss_start +00000110 memset +00000000 main +00000080 strcmp +00000353 shutdown +000002e3 dup +000001e0 stat +00000a68 _edata +00000a74 _end +0000032b link +000002a3 exit +00000230 atoi +00000363 cls +000000e0 strlen +0000030b open +00000130 strchr +00000333 mkdir +0000033b close +000005c0 free diff --git a/bio.d b/bio.d new file mode 100644 index 0000000..b4bbd30 --- /dev/null +++ b/bio.d @@ -0,0 +1,2 @@ +bio.o: bio.c /usr/include/stdc-predef.h types.h defs.h param.h spinlock.h \ + sleeplock.h fs.h buf.h diff --git a/bio.o b/bio.o new file mode 100644 index 0000000..2362439 Binary files /dev/null and b/bio.o differ diff --git a/bootasm.d b/bootasm.d new file mode 100644 index 0000000..3b3dc19 --- /dev/null +++ b/bootasm.d @@ -0,0 +1 @@ +bootasm.o: bootasm.S asm.h memlayout.h mmu.h diff --git a/bootasm.o b/bootasm.o new file mode 100644 index 0000000..0db07cc Binary files /dev/null and b/bootasm.o differ diff --git a/bootblock b/bootblock new file mode 100644 index 0000000..ccebab4 Binary files /dev/null and b/bootblock differ diff --git a/bootblock.asm b/bootblock.asm new file mode 100644 index 0000000..bece2ca --- /dev/null +++ b/bootblock.asm @@ -0,0 +1,341 @@ + +bootblock.o: file format elf32-i386 + + +Disassembly of section .text: + +00007c00 : +# with %cs=0 %ip=7c00. + +.code16 # Assemble for 16-bit mode +.globl start +start: + cli # BIOS enabled interrupts; disable + 7c00: fa cli + + # Zero data segment registers DS, ES, and SS. + xorw %ax,%ax # Set %ax to zero + 7c01: 31 c0 xor %eax,%eax + movw %ax,%ds # -> Data Segment + 7c03: 8e d8 mov %eax,%ds + movw %ax,%es # -> Extra Segment + 7c05: 8e c0 mov %eax,%es + movw %ax,%ss # -> Stack Segment + 7c07: 8e d0 mov %eax,%ss + +00007c09 : + + # Physical address line A20 is tied to zero so that the first PCs + # with 2 MB would run software that assumed 1 MB. Undo that. +seta20.1: + inb $0x64,%al # Wait for not busy + 7c09: e4 64 in $0x64,%al + testb $0x2,%al + 7c0b: a8 02 test $0x2,%al + jnz seta20.1 + 7c0d: 75 fa jne 7c09 + + movb $0xd1,%al # 0xd1 -> port 0x64 + 7c0f: b0 d1 mov $0xd1,%al + outb %al,$0x64 + 7c11: e6 64 out %al,$0x64 + +00007c13 : + +seta20.2: + inb $0x64,%al # Wait for not busy + 7c13: e4 64 in $0x64,%al + testb $0x2,%al + 7c15: a8 02 test $0x2,%al + jnz seta20.2 + 7c17: 75 fa jne 7c13 + + movb $0xdf,%al # 0xdf -> port 0x60 + 7c19: b0 df mov $0xdf,%al + outb %al,$0x60 + 7c1b: e6 60 out %al,$0x60 + + # Switch from real to protected mode. Use a bootstrap GDT that makes + # virtual addresses map directly to physical addresses so that the + # effective memory map doesn't change during the transition. + lgdt gdtdesc + 7c1d: 0f 01 16 lgdtl (%esi) + 7c20: 68 7c 0f 20 c0 push $0xc0200f7c + movl %cr0, %eax + orl $CR0_PE, %eax + 7c25: 66 83 c8 01 or $0x1,%ax + movl %eax, %cr0 + 7c29: 0f 22 c0 mov %eax,%cr0 + + # Complete the transition to 32-bit protected mode by using a long jmp + # to reload %cs and %eip. The segment descriptors are set up with no + # translation, so that the mapping is still the identity mapping. + ljmp $(SEG_KCODE<<3), $start32 + 7c2c: ea .byte 0xea + 7c2d: 31 7c 08 00 xor %edi,0x0(%eax,%ecx,1) + +00007c31 : + +.code32 # Tell assembler to generate 32-bit code now. +start32: + # Set up the protected-mode data segment registers + movw $(SEG_KDATA<<3), %ax # Our data segment selector + 7c31: 66 b8 10 00 mov $0x10,%ax + movw %ax, %ds # -> DS: Data Segment + 7c35: 8e d8 mov %eax,%ds + movw %ax, %es # -> ES: Extra Segment + 7c37: 8e c0 mov %eax,%es + movw %ax, %ss # -> SS: Stack Segment + 7c39: 8e d0 mov %eax,%ss + movw $0, %ax # Zero segments not ready for use + 7c3b: 66 b8 00 00 mov $0x0,%ax + movw %ax, %fs # -> FS + 7c3f: 8e e0 mov %eax,%fs + movw %ax, %gs # -> GS + 7c41: 8e e8 mov %eax,%gs + + # Set up the stack pointer and call into C. + movl $start, %esp + 7c43: bc 00 7c 00 00 mov $0x7c00,%esp + call bootmain + 7c48: e8 e0 00 00 00 call 7d2d + +00007c4d : + + # If bootmain returns (it shouldn't), loop. +spin: + jmp spin + 7c4d: eb fe jmp 7c4d + 7c4f: 90 nop + +00007c50 : + ... + 7c58: ff (bad) + 7c59: ff 00 incl (%eax) + 7c5b: 00 00 add %al,(%eax) + 7c5d: 9a cf 00 ff ff 00 00 lcall $0x0,$0xffff00cf + 7c64: 00 .byte 0x0 + 7c65: 92 xchg %eax,%edx + 7c66: cf iret + ... + +00007c68 : + 7c68: 17 pop %ss + 7c69: 00 50 7c add %dl,0x7c(%eax) + ... + +00007c6e : +// Routines to let C code use special x86 instructions. + +static inline uchar inb(ushort port) { + uchar data; + + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); + 7c6e: ba f7 01 00 00 mov $0x1f7,%edx + 7c73: ec in (%dx),%al + entry(); +} + +void waitdisk(void) { + // Wait for disk ready. + while ((inb(0x1F7) & 0xC0) != 0x40) { + 7c74: 83 e0 c0 and $0xffffffc0,%eax + 7c77: 3c 40 cmp $0x40,%al + 7c79: 75 f8 jne 7c73 + ; + } +} + 7c7b: c3 ret + +00007c7c : + +// Read a single sector at offset into dst. +void readsect(void *dst, uint offset) { + 7c7c: 55 push %ebp + 7c7d: 89 e5 mov %esp,%ebp + 7c7f: 57 push %edi + 7c80: 53 push %ebx + 7c81: 8b 5d 0c mov 0xc(%ebp),%ebx + // Issue command. + waitdisk(); + 7c84: e8 e5 ff ff ff call 7c6e + "d" (port), "0" (addr), "1" (cnt) : + "memory", "cc"); +} + +static inline void outb(ushort port, uchar data) { + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); + 7c89: b8 01 00 00 00 mov $0x1,%eax + 7c8e: ba f2 01 00 00 mov $0x1f2,%edx + 7c93: ee out %al,(%dx) + 7c94: ba f3 01 00 00 mov $0x1f3,%edx + 7c99: 89 d8 mov %ebx,%eax + 7c9b: ee out %al,(%dx) + outb(0x1F2, 1); // count = 1 + outb(0x1F3, offset); + outb(0x1F4, offset >> 8); + 7c9c: 89 d8 mov %ebx,%eax + 7c9e: c1 e8 08 shr $0x8,%eax + 7ca1: ba f4 01 00 00 mov $0x1f4,%edx + 7ca6: ee out %al,(%dx) + outb(0x1F5, offset >> 16); + 7ca7: 89 d8 mov %ebx,%eax + 7ca9: c1 e8 10 shr $0x10,%eax + 7cac: ba f5 01 00 00 mov $0x1f5,%edx + 7cb1: ee out %al,(%dx) + outb(0x1F6, (offset >> 24) | 0xE0); + 7cb2: 89 d8 mov %ebx,%eax + 7cb4: c1 e8 18 shr $0x18,%eax + 7cb7: 83 c8 e0 or $0xffffffe0,%eax + 7cba: ba f6 01 00 00 mov $0x1f6,%edx + 7cbf: ee out %al,(%dx) + 7cc0: b8 20 00 00 00 mov $0x20,%eax + 7cc5: ba f7 01 00 00 mov $0x1f7,%edx + 7cca: ee out %al,(%dx) + outb(0x1F7, 0x20); // cmd 0x20 - read sectors + + // Read data. + waitdisk(); + 7ccb: e8 9e ff ff ff call 7c6e + asm volatile ("cld; rep insl" : + 7cd0: 8b 7d 08 mov 0x8(%ebp),%edi + 7cd3: b9 80 00 00 00 mov $0x80,%ecx + 7cd8: ba f0 01 00 00 mov $0x1f0,%edx + 7cdd: fc cld + 7cde: f3 6d rep insl (%dx),%es:(%edi) + insl(0x1F0, dst, SECTSIZE / 4); +} + 7ce0: 5b pop %ebx + 7ce1: 5f pop %edi + 7ce2: 5d pop %ebp + 7ce3: c3 ret + +00007ce4 : + +// Read 'count' bytes at 'offset' from kernel into physical address 'pa'. +// Might copy more than asked. + +void readseg(uchar* pa, uint count, uint offset) { + 7ce4: 55 push %ebp + 7ce5: 89 e5 mov %esp,%ebp + 7ce7: 57 push %edi + 7ce8: 56 push %esi + 7ce9: 53 push %ebx + 7cea: 83 ec 0c sub $0xc,%esp + 7ced: 8b 5d 08 mov 0x8(%ebp),%ebx + 7cf0: 8b 75 10 mov 0x10(%ebp),%esi + uchar* epa; + + epa = pa + count; + 7cf3: 89 df mov %ebx,%edi + 7cf5: 03 7d 0c add 0xc(%ebp),%edi + + // Round down to sector boundary. + pa -= offset % SECTSIZE; + 7cf8: 89 f0 mov %esi,%eax + 7cfa: 25 ff 01 00 00 and $0x1ff,%eax + 7cff: 29 c3 sub %eax,%ebx + + // Translate from bytes to sectors; kernel starts at sector 1. + offset = (offset / SECTSIZE) + 1; + 7d01: c1 ee 09 shr $0x9,%esi + 7d04: 83 c6 01 add $0x1,%esi + + // If this is too slow, we could read lots of sectors at a time. + // We'd write more to memory than asked, but it doesn't matter -- + // we load in increasing order. + for (; pa < epa; pa += SECTSIZE, offset++) { + 7d07: 39 df cmp %ebx,%edi + 7d09: 76 1a jbe 7d25 + readsect(pa, offset); + 7d0b: 83 ec 08 sub $0x8,%esp + 7d0e: 56 push %esi + 7d0f: 53 push %ebx + 7d10: e8 67 ff ff ff call 7c7c + for (; pa < epa; pa += SECTSIZE, offset++) { + 7d15: 81 c3 00 02 00 00 add $0x200,%ebx + 7d1b: 83 c6 01 add $0x1,%esi + 7d1e: 83 c4 10 add $0x10,%esp + 7d21: 39 df cmp %ebx,%edi + 7d23: 77 e6 ja 7d0b + } +} + 7d25: 8d 65 f4 lea -0xc(%ebp),%esp + 7d28: 5b pop %ebx + 7d29: 5e pop %esi + 7d2a: 5f pop %edi + 7d2b: 5d pop %ebp + 7d2c: c3 ret + +00007d2d : +void bootmain(void) { + 7d2d: 55 push %ebp + 7d2e: 89 e5 mov %esp,%ebp + 7d30: 57 push %edi + 7d31: 56 push %esi + 7d32: 53 push %ebx + 7d33: 83 ec 10 sub $0x10,%esp + readseg((uchar*)elf, 4096, 0); + 7d36: 6a 00 push $0x0 + 7d38: 68 00 10 00 00 push $0x1000 + 7d3d: 68 00 00 01 00 push $0x10000 + 7d42: e8 9d ff ff ff call 7ce4 + if (elf->magic != ELF_MAGIC) { + 7d47: 83 c4 10 add $0x10,%esp + 7d4a: 81 3d 00 00 01 00 7f cmpl $0x464c457f,0x10000 + 7d51: 45 4c 46 + 7d54: 75 21 jne 7d77 + ph = (struct proghdr*)((uchar*)elf + elf->phoff); + 7d56: a1 1c 00 01 00 mov 0x1001c,%eax + 7d5b: 8d 98 00 00 01 00 lea 0x10000(%eax),%ebx + eph = ph + elf->phnum; + 7d61: 0f b7 35 2c 00 01 00 movzwl 0x1002c,%esi + 7d68: c1 e6 05 shl $0x5,%esi + 7d6b: 01 de add %ebx,%esi + for (; ph < eph; ph++) { + 7d6d: 39 f3 cmp %esi,%ebx + 7d6f: 72 15 jb 7d86 + entry(); + 7d71: ff 15 18 00 01 00 call *0x10018 +} + 7d77: 8d 65 f4 lea -0xc(%ebp),%esp + 7d7a: 5b pop %ebx + 7d7b: 5e pop %esi + 7d7c: 5f pop %edi + 7d7d: 5d pop %ebp + 7d7e: c3 ret + for (; ph < eph; ph++) { + 7d7f: 83 c3 20 add $0x20,%ebx + 7d82: 39 de cmp %ebx,%esi + 7d84: 76 eb jbe 7d71 + pa = (uchar*)ph->paddr; + 7d86: 8b 7b 0c mov 0xc(%ebx),%edi + readseg(pa, ph->filesz, ph->off); + 7d89: 83 ec 04 sub $0x4,%esp + 7d8c: ff 73 04 push 0x4(%ebx) + 7d8f: ff 73 10 push 0x10(%ebx) + 7d92: 57 push %edi + 7d93: e8 4c ff ff ff call 7ce4 + if (ph->memsz > ph->filesz) { + 7d98: 8b 4b 14 mov 0x14(%ebx),%ecx + 7d9b: 8b 43 10 mov 0x10(%ebx),%eax + 7d9e: 83 c4 10 add $0x10,%esp + 7da1: 39 c1 cmp %eax,%ecx + 7da3: 76 da jbe 7d7f + stosb(pa + ph->filesz, 0, ph->memsz - ph->filesz); + 7da5: 01 c7 add %eax,%edi + 7da7: 29 c1 sub %eax,%ecx + "d" (port), "0" (addr), "1" (cnt) : + "cc"); +} + +static inline void stosb(void *addr, int data, int cnt) { + asm volatile ("cld; rep stosb" : + 7da9: b8 00 00 00 00 mov $0x0,%eax + 7dae: fc cld + 7daf: f3 aa rep stos %al,%es:(%edi) + "=D" (addr), "=c" (cnt) : + "0" (addr), "1" (cnt), "a" (data) : + "memory", "cc"); +} + 7db1: eb cc jmp 7d7f diff --git a/bootblock.o b/bootblock.o new file mode 100644 index 0000000..485cd59 Binary files /dev/null and b/bootblock.o differ diff --git a/bootblockother.o b/bootblockother.o new file mode 100644 index 0000000..83514b1 Binary files /dev/null and b/bootblockother.o differ diff --git a/bootmain.d b/bootmain.d new file mode 100644 index 0000000..b32eaf5 --- /dev/null +++ b/bootmain.d @@ -0,0 +1 @@ +bootmain.o: bootmain.c types.h elf.h x86.h memlayout.h diff --git a/bootmain.o b/bootmain.o new file mode 100644 index 0000000..0734b91 Binary files /dev/null and b/bootmain.o differ diff --git a/cat.asm b/cat.asm new file mode 100644 index 0000000..c6fa4ab --- /dev/null +++ b/cat.asm @@ -0,0 +1,1268 @@ + +_cat: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + printf(1, "cat: read error\n"); + exit(); + } +} + +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: be 01 00 00 00 mov $0x1,%esi + 14: 53 push %ebx + 15: 51 push %ecx + 16: 83 ec 18 sub $0x18,%esp + 19: 8b 01 mov (%ecx),%eax + 1b: 8b 59 04 mov 0x4(%ecx),%ebx + 1e: 89 45 e4 mov %eax,-0x1c(%ebp) + 21: 83 c3 04 add $0x4,%ebx + int fd, i; + + if (argc <= 1) { + 24: 83 f8 01 cmp $0x1,%eax + 27: 7e 54 jle 7d + 29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cat(0); + exit(); + } + + for (i = 1; i < argc; i++) { + if ((fd = open(argv[i], 0)) < 0) { + 30: 83 ec 08 sub $0x8,%esp + 33: 6a 00 push $0x0 + 35: ff 33 push (%ebx) + 37: e8 8f 03 00 00 call 3cb + 3c: 83 c4 10 add $0x10,%esp + 3f: 89 c7 mov %eax,%edi + 41: 85 c0 test %eax,%eax + 43: 78 24 js 69 + printf(1, "cat: cannot open %s\n", argv[i]); + exit(); + } + cat(fd); + 45: 83 ec 0c sub $0xc,%esp + for (i = 1; i < argc; i++) { + 48: 83 c6 01 add $0x1,%esi + 4b: 83 c3 04 add $0x4,%ebx + cat(fd); + 4e: 50 push %eax + 4f: e8 3c 00 00 00 call 90 + close(fd); + 54: 89 3c 24 mov %edi,(%esp) + 57: e8 9f 03 00 00 call 3fb + for (i = 1; i < argc; i++) { + 5c: 83 c4 10 add $0x10,%esp + 5f: 39 75 e4 cmp %esi,-0x1c(%ebp) + 62: 75 cc jne 30 + } + exit(); + 64: e8 fa 02 00 00 call 363 + printf(1, "cat: cannot open %s\n", argv[i]); + 69: 50 push %eax + 6a: ff 33 push (%ebx) + 6c: 68 2b 08 00 00 push $0x82b + 71: 6a 01 push $0x1 + 73: e8 68 04 00 00 call 4e0 + exit(); + 78: e8 e6 02 00 00 call 363 + cat(0); + 7d: 83 ec 0c sub $0xc,%esp + 80: 6a 00 push $0x0 + 82: e8 09 00 00 00 call 90 + exit(); + 87: e8 d7 02 00 00 call 363 + 8c: 66 90 xchg %ax,%ax + 8e: 66 90 xchg %ax,%ax + +00000090 : +void cat(int fd) { + 90: 55 push %ebp + 91: 89 e5 mov %esp,%ebp + 93: 56 push %esi + 94: 8b 75 08 mov 0x8(%ebp),%esi + 97: 53 push %ebx + while ((n = read(fd, buf, sizeof(buf))) > 0) { + 98: eb 1d jmp b7 + 9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (write(1, buf, n) != n) { + a0: 83 ec 04 sub $0x4,%esp + a3: 53 push %ebx + a4: 68 a0 0b 00 00 push $0xba0 + a9: 6a 01 push $0x1 + ab: e8 23 03 00 00 call 3d3 + b0: 83 c4 10 add $0x10,%esp + b3: 39 d8 cmp %ebx,%eax + b5: 75 25 jne dc + while ((n = read(fd, buf, sizeof(buf))) > 0) { + b7: 83 ec 04 sub $0x4,%esp + ba: 68 00 02 00 00 push $0x200 + bf: 68 a0 0b 00 00 push $0xba0 + c4: 56 push %esi + c5: e8 b1 02 00 00 call 37b + ca: 83 c4 10 add $0x10,%esp + cd: 89 c3 mov %eax,%ebx + cf: 85 c0 test %eax,%eax + d1: 7f cd jg a0 + if (n < 0) { + d3: 75 1b jne f0 +} + d5: 8d 65 f8 lea -0x8(%ebp),%esp + d8: 5b pop %ebx + d9: 5e pop %esi + da: 5d pop %ebp + db: c3 ret + printf(1, "cat: write error\n"); + dc: 83 ec 08 sub $0x8,%esp + df: 68 08 08 00 00 push $0x808 + e4: 6a 01 push $0x1 + e6: e8 f5 03 00 00 call 4e0 + exit(); + eb: e8 73 02 00 00 call 363 + printf(1, "cat: read error\n"); + f0: 50 push %eax + f1: 50 push %eax + f2: 68 1a 08 00 00 push $0x81a + f7: 6a 01 push $0x1 + f9: e8 e2 03 00 00 call 4e0 + exit(); + fe: e8 60 02 00 00 call 363 + 103: 66 90 xchg %ax,%ax + 105: 66 90 xchg %ax,%ax + 107: 66 90 xchg %ax,%ax + 109: 66 90 xchg %ax,%ax + 10b: 66 90 xchg %ax,%ax + 10d: 66 90 xchg %ax,%ax + 10f: 90 nop + +00000110 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 110: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 111: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 113: 89 e5 mov %esp,%ebp + 115: 53 push %ebx + 116: 8b 4d 08 mov 0x8(%ebp),%ecx + 119: 8b 5d 0c mov 0xc(%ebp),%ebx + 11c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 120: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 124: 88 14 01 mov %dl,(%ecx,%eax,1) + 127: 83 c0 01 add $0x1,%eax + 12a: 84 d2 test %dl,%dl + 12c: 75 f2 jne 120 + ; + } + return os; +} + 12e: 8b 5d fc mov -0x4(%ebp),%ebx + 131: 89 c8 mov %ecx,%eax + 133: c9 leave + 134: c3 ret + 135: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 13c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000140 : + +int strcmp(const char *p, const char *q) { + 140: 55 push %ebp + 141: 89 e5 mov %esp,%ebp + 143: 53 push %ebx + 144: 8b 55 08 mov 0x8(%ebp),%edx + 147: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 14a: 0f b6 02 movzbl (%edx),%eax + 14d: 84 c0 test %al,%al + 14f: 75 17 jne 168 + 151: eb 3a jmp 18d + 153: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 157: 90 nop + 158: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 15c: 83 c2 01 add $0x1,%edx + 15f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 162: 84 c0 test %al,%al + 164: 74 1a je 180 + p++, q++; + 166: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 168: 0f b6 19 movzbl (%ecx),%ebx + 16b: 38 c3 cmp %al,%bl + 16d: 74 e9 je 158 + } + return (uchar) * p - (uchar) * q; + 16f: 29 d8 sub %ebx,%eax +} + 171: 8b 5d fc mov -0x4(%ebp),%ebx + 174: c9 leave + 175: c3 ret + 176: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 17d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 180: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 184: 31 c0 xor %eax,%eax + 186: 29 d8 sub %ebx,%eax +} + 188: 8b 5d fc mov -0x4(%ebp),%ebx + 18b: c9 leave + 18c: c3 ret + return (uchar) * p - (uchar) * q; + 18d: 0f b6 19 movzbl (%ecx),%ebx + 190: 31 c0 xor %eax,%eax + 192: eb db jmp 16f + 194: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 19b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 19f: 90 nop + +000001a0 : + +uint strlen(const char *s) { + 1a0: 55 push %ebp + 1a1: 89 e5 mov %esp,%ebp + 1a3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 1a6: 80 3a 00 cmpb $0x0,(%edx) + 1a9: 74 15 je 1c0 + 1ab: 31 c0 xor %eax,%eax + 1ad: 8d 76 00 lea 0x0(%esi),%esi + 1b0: 83 c0 01 add $0x1,%eax + 1b3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 1b7: 89 c1 mov %eax,%ecx + 1b9: 75 f5 jne 1b0 + ; + } + return n; +} + 1bb: 89 c8 mov %ecx,%eax + 1bd: 5d pop %ebp + 1be: c3 ret + 1bf: 90 nop + for (n = 0; s[n]; n++) { + 1c0: 31 c9 xor %ecx,%ecx +} + 1c2: 5d pop %ebp + 1c3: 89 c8 mov %ecx,%eax + 1c5: c3 ret + 1c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1cd: 8d 76 00 lea 0x0(%esi),%esi + +000001d0 : + +void* memset(void *dst, int c, uint n) { + 1d0: 55 push %ebp + 1d1: 89 e5 mov %esp,%ebp + 1d3: 57 push %edi + 1d4: 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" : + 1d7: 8b 4d 10 mov 0x10(%ebp),%ecx + 1da: 8b 45 0c mov 0xc(%ebp),%eax + 1dd: 89 d7 mov %edx,%edi + 1df: fc cld + 1e0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1e2: 8b 7d fc mov -0x4(%ebp),%edi + 1e5: 89 d0 mov %edx,%eax + 1e7: c9 leave + 1e8: c3 ret + 1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000001f0 : + +char* strchr(const char *s, char c) { + 1f0: 55 push %ebp + 1f1: 89 e5 mov %esp,%ebp + 1f3: 8b 45 08 mov 0x8(%ebp),%eax + 1f6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 1fa: 0f b6 10 movzbl (%eax),%edx + 1fd: 84 d2 test %dl,%dl + 1ff: 75 12 jne 213 + 201: eb 1d jmp 220 + 203: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 207: 90 nop + 208: 0f b6 50 01 movzbl 0x1(%eax),%edx + 20c: 83 c0 01 add $0x1,%eax + 20f: 84 d2 test %dl,%dl + 211: 74 0d je 220 + if (*s == c) { + 213: 38 d1 cmp %dl,%cl + 215: 75 f1 jne 208 + return (char*)s; + } + } + return 0; +} + 217: 5d pop %ebp + 218: c3 ret + 219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 220: 31 c0 xor %eax,%eax +} + 222: 5d pop %ebp + 223: c3 ret + 224: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 22b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 22f: 90 nop + +00000230 : + +char* gets(char *buf, int max) { + 230: 55 push %ebp + 231: 89 e5 mov %esp,%ebp + 233: 57 push %edi + 234: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 235: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 238: 53 push %ebx + for (i = 0; i + 1 < max;) { + 239: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 23b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 23e: eb 27 jmp 267 + cc = read(0, &c, 1); + 240: 83 ec 04 sub $0x4,%esp + 243: 6a 01 push $0x1 + 245: 57 push %edi + 246: 6a 00 push $0x0 + 248: e8 2e 01 00 00 call 37b + if (cc < 1) { + 24d: 83 c4 10 add $0x10,%esp + 250: 85 c0 test %eax,%eax + 252: 7e 1d jle 271 + break; + } + buf[i++] = c; + 254: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 258: 8b 55 08 mov 0x8(%ebp),%edx + 25b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 25f: 3c 0a cmp $0xa,%al + 261: 74 1d je 280 + 263: 3c 0d cmp $0xd,%al + 265: 74 19 je 280 + for (i = 0; i + 1 < max;) { + 267: 89 de mov %ebx,%esi + 269: 83 c3 01 add $0x1,%ebx + 26c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 26f: 7c cf jl 240 + break; + } + } + buf[i] = '\0'; + 271: 8b 45 08 mov 0x8(%ebp),%eax + 274: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 278: 8d 65 f4 lea -0xc(%ebp),%esp + 27b: 5b pop %ebx + 27c: 5e pop %esi + 27d: 5f pop %edi + 27e: 5d pop %ebp + 27f: c3 ret + buf[i] = '\0'; + 280: 8b 45 08 mov 0x8(%ebp),%eax + 283: 89 de mov %ebx,%esi + 285: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 289: 8d 65 f4 lea -0xc(%ebp),%esp + 28c: 5b pop %ebx + 28d: 5e pop %esi + 28e: 5f pop %edi + 28f: 5d pop %ebp + 290: c3 ret + 291: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 298: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 29f: 90 nop + +000002a0 : + +int stat(const char *n, struct stat *st) { + 2a0: 55 push %ebp + 2a1: 89 e5 mov %esp,%ebp + 2a3: 56 push %esi + 2a4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 2a5: 83 ec 08 sub $0x8,%esp + 2a8: 6a 00 push $0x0 + 2aa: ff 75 08 push 0x8(%ebp) + 2ad: e8 19 01 00 00 call 3cb + if (fd < 0) { + 2b2: 83 c4 10 add $0x10,%esp + 2b5: 85 c0 test %eax,%eax + 2b7: 78 27 js 2e0 + return -1; + } + r = fstat(fd, st); + 2b9: 83 ec 08 sub $0x8,%esp + 2bc: ff 75 0c push 0xc(%ebp) + 2bf: 89 c3 mov %eax,%ebx + 2c1: 50 push %eax + 2c2: e8 cc 00 00 00 call 393 + close(fd); + 2c7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 2ca: 89 c6 mov %eax,%esi + close(fd); + 2cc: e8 2a 01 00 00 call 3fb + return r; + 2d1: 83 c4 10 add $0x10,%esp +} + 2d4: 8d 65 f8 lea -0x8(%ebp),%esp + 2d7: 89 f0 mov %esi,%eax + 2d9: 5b pop %ebx + 2da: 5e pop %esi + 2db: 5d pop %ebp + 2dc: c3 ret + 2dd: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 2e0: be ff ff ff ff mov $0xffffffff,%esi + 2e5: eb ed jmp 2d4 + 2e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2ee: 66 90 xchg %ax,%ax + +000002f0 : + +int atoi(const char *s) { + 2f0: 55 push %ebp + 2f1: 89 e5 mov %esp,%ebp + 2f3: 53 push %ebx + 2f4: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 2f7: 0f be 02 movsbl (%edx),%eax + 2fa: 8d 48 d0 lea -0x30(%eax),%ecx + 2fd: 80 f9 09 cmp $0x9,%cl + n = 0; + 300: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 305: 77 1e ja 325 + 307: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 30e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 310: 83 c2 01 add $0x1,%edx + 313: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 316: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 31a: 0f be 02 movsbl (%edx),%eax + 31d: 8d 58 d0 lea -0x30(%eax),%ebx + 320: 80 fb 09 cmp $0x9,%bl + 323: 76 eb jbe 310 + } + return n; +} + 325: 8b 5d fc mov -0x4(%ebp),%ebx + 328: 89 c8 mov %ecx,%eax + 32a: c9 leave + 32b: c3 ret + 32c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000330 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 330: 55 push %ebp + 331: 89 e5 mov %esp,%ebp + 333: 57 push %edi + 334: 8b 45 10 mov 0x10(%ebp),%eax + 337: 8b 55 08 mov 0x8(%ebp),%edx + 33a: 56 push %esi + 33b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 33e: 85 c0 test %eax,%eax + 340: 7e 13 jle 355 + 342: 01 d0 add %edx,%eax + dst = vdst; + 344: 89 d7 mov %edx,%edi + 346: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 34d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 350: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 351: 39 f8 cmp %edi,%eax + 353: 75 fb jne 350 + } + return vdst; +} + 355: 5e pop %esi + 356: 89 d0 mov %edx,%eax + 358: 5f pop %edi + 359: 5d pop %ebp + 35a: c3 ret + +0000035b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 35b: b8 01 00 00 00 mov $0x1,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(exit) + 363: b8 02 00 00 00 mov $0x2,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(wait) + 36b: b8 03 00 00 00 mov $0x3,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(pipe) + 373: b8 04 00 00 00 mov $0x4,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(read) + 37b: b8 05 00 00 00 mov $0x5,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(kill) + 383: b8 06 00 00 00 mov $0x6,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + +0000038b : +SYSCALL(exec) + 38b: b8 07 00 00 00 mov $0x7,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(fstat) + 393: b8 08 00 00 00 mov $0x8,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + +0000039b : +SYSCALL(chdir) + 39b: b8 09 00 00 00 mov $0x9,%eax + 3a0: cd 40 int $0x40 + 3a2: c3 ret + +000003a3 : +SYSCALL(dup) + 3a3: b8 0a 00 00 00 mov $0xa,%eax + 3a8: cd 40 int $0x40 + 3aa: c3 ret + +000003ab : +SYSCALL(getpid) + 3ab: b8 0b 00 00 00 mov $0xb,%eax + 3b0: cd 40 int $0x40 + 3b2: c3 ret + +000003b3 : +SYSCALL(sbrk) + 3b3: b8 0c 00 00 00 mov $0xc,%eax + 3b8: cd 40 int $0x40 + 3ba: c3 ret + +000003bb : +SYSCALL(sleep) + 3bb: b8 0d 00 00 00 mov $0xd,%eax + 3c0: cd 40 int $0x40 + 3c2: c3 ret + +000003c3 : +SYSCALL(uptime) + 3c3: b8 0e 00 00 00 mov $0xe,%eax + 3c8: cd 40 int $0x40 + 3ca: c3 ret + +000003cb : +SYSCALL(open) + 3cb: b8 0f 00 00 00 mov $0xf,%eax + 3d0: cd 40 int $0x40 + 3d2: c3 ret + +000003d3 : +SYSCALL(write) + 3d3: b8 10 00 00 00 mov $0x10,%eax + 3d8: cd 40 int $0x40 + 3da: c3 ret + +000003db : +SYSCALL(mknod) + 3db: b8 11 00 00 00 mov $0x11,%eax + 3e0: cd 40 int $0x40 + 3e2: c3 ret + +000003e3 : +SYSCALL(unlink) + 3e3: b8 12 00 00 00 mov $0x12,%eax + 3e8: cd 40 int $0x40 + 3ea: c3 ret + +000003eb : +SYSCALL(link) + 3eb: b8 13 00 00 00 mov $0x13,%eax + 3f0: cd 40 int $0x40 + 3f2: c3 ret + +000003f3 : +SYSCALL(mkdir) + 3f3: b8 14 00 00 00 mov $0x14,%eax + 3f8: cd 40 int $0x40 + 3fa: c3 ret + +000003fb : +SYSCALL(close) + 3fb: b8 15 00 00 00 mov $0x15,%eax + 400: cd 40 int $0x40 + 402: c3 ret + +00000403 : +SYSCALL(getch) + 403: b8 16 00 00 00 mov $0x16,%eax + 408: cd 40 int $0x40 + 40a: c3 ret + +0000040b : +SYSCALL(greeting) + 40b: b8 17 00 00 00 mov $0x17,%eax + 410: cd 40 int $0x40 + 412: c3 ret + +00000413 : +SYSCALL(shutdown) + 413: b8 18 00 00 00 mov $0x18,%eax + 418: cd 40 int $0x40 + 41a: c3 ret + +0000041b : +SYSCALL(screen) + 41b: b8 19 00 00 00 mov $0x19,%eax + 420: cd 40 int $0x40 + 422: c3 ret + +00000423 : +SYSCALL(cls) + 423: b8 1a 00 00 00 mov $0x1a,%eax + 428: cd 40 int $0x40 + 42a: c3 ret + 42b: 66 90 xchg %ax,%ax + 42d: 66 90 xchg %ax,%ax + 42f: 90 nop + +00000430 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 430: 55 push %ebp + 431: 89 e5 mov %esp,%ebp + 433: 57 push %edi + 434: 56 push %esi + 435: 53 push %ebx + 436: 83 ec 3c sub $0x3c,%esp + 439: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 43c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 43e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 441: 85 d2 test %edx,%edx + 443: 0f 89 7f 00 00 00 jns 4c8 + 449: f6 45 08 01 testb $0x1,0x8(%ebp) + 44d: 74 79 je 4c8 + neg = 1; + 44f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 456: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 458: 31 db xor %ebx,%ebx + 45a: 8d 75 d7 lea -0x29(%ebp),%esi + 45d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 460: 89 c8 mov %ecx,%eax + 462: 31 d2 xor %edx,%edx + 464: 89 cf mov %ecx,%edi + 466: f7 75 c4 divl -0x3c(%ebp) + 469: 0f b6 92 a0 08 00 00 movzbl 0x8a0(%edx),%edx + 470: 89 45 c0 mov %eax,-0x40(%ebp) + 473: 89 d8 mov %ebx,%eax + 475: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 478: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 47b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 47e: 39 7d c4 cmp %edi,-0x3c(%ebp) + 481: 76 dd jbe 460 + if (neg) { + 483: 8b 4d bc mov -0x44(%ebp),%ecx + 486: 85 c9 test %ecx,%ecx + 488: 74 0c je 496 + buf[i++] = '-'; + 48a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 48f: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 491: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 496: 8b 7d b8 mov -0x48(%ebp),%edi + 499: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 49d: eb 07 jmp 4a6 + 49f: 90 nop + putc(fd, buf[i]); + 4a0: 0f b6 13 movzbl (%ebx),%edx + 4a3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 4a6: 83 ec 04 sub $0x4,%esp + 4a9: 88 55 d7 mov %dl,-0x29(%ebp) + 4ac: 6a 01 push $0x1 + 4ae: 56 push %esi + 4af: 57 push %edi + 4b0: e8 1e ff ff ff call 3d3 + while (--i >= 0) { + 4b5: 83 c4 10 add $0x10,%esp + 4b8: 39 de cmp %ebx,%esi + 4ba: 75 e4 jne 4a0 + } +} + 4bc: 8d 65 f4 lea -0xc(%ebp),%esp + 4bf: 5b pop %ebx + 4c0: 5e pop %esi + 4c1: 5f pop %edi + 4c2: 5d pop %ebp + 4c3: c3 ret + 4c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 4c8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 4cf: eb 87 jmp 458 + 4d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4df: 90 nop + +000004e0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 4e0: 55 push %ebp + 4e1: 89 e5 mov %esp,%ebp + 4e3: 57 push %edi + 4e4: 56 push %esi + 4e5: 53 push %ebx + 4e6: 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++) { + 4e9: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 4ec: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 4ef: 0f b6 13 movzbl (%ebx),%edx + 4f2: 84 d2 test %dl,%dl + 4f4: 74 6a je 560 + ap = (uint*)(void*)&fmt + 1; + 4f6: 8d 45 10 lea 0x10(%ebp),%eax + 4f9: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 4fc: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 4ff: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 501: 89 45 d0 mov %eax,-0x30(%ebp) + 504: eb 36 jmp 53c + 506: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 50d: 8d 76 00 lea 0x0(%esi),%esi + 510: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 513: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 518: 83 f8 25 cmp $0x25,%eax + 51b: 74 15 je 532 + write(fd, &c, 1); + 51d: 83 ec 04 sub $0x4,%esp + 520: 88 55 e7 mov %dl,-0x19(%ebp) + 523: 6a 01 push $0x1 + 525: 57 push %edi + 526: 56 push %esi + 527: e8 a7 fe ff ff call 3d3 + 52c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 52f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 532: 0f b6 13 movzbl (%ebx),%edx + 535: 83 c3 01 add $0x1,%ebx + 538: 84 d2 test %dl,%dl + 53a: 74 24 je 560 + c = fmt[i] & 0xff; + 53c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 53f: 85 c9 test %ecx,%ecx + 541: 74 cd je 510 + } + } + else if (state == '%') { + 543: 83 f9 25 cmp $0x25,%ecx + 546: 75 ea jne 532 + if (c == 'd') { + 548: 83 f8 25 cmp $0x25,%eax + 54b: 0f 84 07 01 00 00 je 658 + 551: 83 e8 63 sub $0x63,%eax + 554: 83 f8 15 cmp $0x15,%eax + 557: 77 17 ja 570 + 559: ff 24 85 48 08 00 00 jmp *0x848(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 560: 8d 65 f4 lea -0xc(%ebp),%esp + 563: 5b pop %ebx + 564: 5e pop %esi + 565: 5f pop %edi + 566: 5d pop %ebp + 567: c3 ret + 568: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 56f: 90 nop + write(fd, &c, 1); + 570: 83 ec 04 sub $0x4,%esp + 573: 88 55 d4 mov %dl,-0x2c(%ebp) + 576: 6a 01 push $0x1 + 578: 57 push %edi + 579: 56 push %esi + 57a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 57e: e8 50 fe ff ff call 3d3 + putc(fd, c); + 583: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 587: 83 c4 0c add $0xc,%esp + 58a: 88 55 e7 mov %dl,-0x19(%ebp) + 58d: 6a 01 push $0x1 + 58f: 57 push %edi + 590: 56 push %esi + 591: e8 3d fe ff ff call 3d3 + putc(fd, c); + 596: 83 c4 10 add $0x10,%esp + state = 0; + 599: 31 c9 xor %ecx,%ecx + 59b: eb 95 jmp 532 + 59d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 5a0: 83 ec 0c sub $0xc,%esp + 5a3: b9 10 00 00 00 mov $0x10,%ecx + 5a8: 6a 00 push $0x0 + 5aa: 8b 45 d0 mov -0x30(%ebp),%eax + 5ad: 8b 10 mov (%eax),%edx + 5af: 89 f0 mov %esi,%eax + 5b1: e8 7a fe ff ff call 430 + ap++; + 5b6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5ba: 83 c4 10 add $0x10,%esp + state = 0; + 5bd: 31 c9 xor %ecx,%ecx + 5bf: e9 6e ff ff ff jmp 532 + 5c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 5c8: 8b 45 d0 mov -0x30(%ebp),%eax + 5cb: 8b 10 mov (%eax),%edx + ap++; + 5cd: 83 c0 04 add $0x4,%eax + 5d0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 5d3: 85 d2 test %edx,%edx + 5d5: 0f 84 8d 00 00 00 je 668 + while (*s != 0) { + 5db: 0f b6 02 movzbl (%edx),%eax + state = 0; + 5de: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 5e0: 84 c0 test %al,%al + 5e2: 0f 84 4a ff ff ff je 532 + 5e8: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5eb: 89 d3 mov %edx,%ebx + 5ed: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 5f0: 83 ec 04 sub $0x4,%esp + s++; + 5f3: 83 c3 01 add $0x1,%ebx + 5f6: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 5f9: 6a 01 push $0x1 + 5fb: 57 push %edi + 5fc: 56 push %esi + 5fd: e8 d1 fd ff ff call 3d3 + while (*s != 0) { + 602: 0f b6 03 movzbl (%ebx),%eax + 605: 83 c4 10 add $0x10,%esp + 608: 84 c0 test %al,%al + 60a: 75 e4 jne 5f0 + state = 0; + 60c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 60f: 31 c9 xor %ecx,%ecx + 611: e9 1c ff ff ff jmp 532 + 616: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 61d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 620: 83 ec 0c sub $0xc,%esp + 623: b9 0a 00 00 00 mov $0xa,%ecx + 628: 6a 01 push $0x1 + 62a: e9 7b ff ff ff jmp 5aa + 62f: 90 nop + putc(fd, *ap); + 630: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 633: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 636: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 638: 6a 01 push $0x1 + 63a: 57 push %edi + 63b: 56 push %esi + putc(fd, *ap); + 63c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 63f: e8 8f fd ff ff call 3d3 + ap++; + 644: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 648: 83 c4 10 add $0x10,%esp + state = 0; + 64b: 31 c9 xor %ecx,%ecx + 64d: e9 e0 fe ff ff jmp 532 + 652: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 658: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 65b: 83 ec 04 sub $0x4,%esp + 65e: e9 2a ff ff ff jmp 58d + 663: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 667: 90 nop + s = "(null)"; + 668: ba 40 08 00 00 mov $0x840,%edx + while (*s != 0) { + 66d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 670: b8 28 00 00 00 mov $0x28,%eax + 675: 89 d3 mov %edx,%ebx + 677: e9 74 ff ff ff jmp 5f0 + 67c: 66 90 xchg %ax,%ax + 67e: 66 90 xchg %ax,%ax + +00000680 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 680: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 681: a1 a0 0d 00 00 mov 0xda0,%eax +void free(void *ap) { + 686: 89 e5 mov %esp,%ebp + 688: 57 push %edi + 689: 56 push %esi + 68a: 53 push %ebx + 68b: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 68e: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 698: 89 c2 mov %eax,%edx + 69a: 8b 00 mov (%eax),%eax + 69c: 39 ca cmp %ecx,%edx + 69e: 73 30 jae 6d0 + 6a0: 39 c1 cmp %eax,%ecx + 6a2: 72 04 jb 6a8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 6a4: 39 c2 cmp %eax,%edx + 6a6: 72 f0 jb 698 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 6a8: 8b 73 fc mov -0x4(%ebx),%esi + 6ab: 8d 3c f1 lea (%ecx,%esi,8),%edi + 6ae: 39 f8 cmp %edi,%eax + 6b0: 74 30 je 6e2 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 6b2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 6b5: 8b 42 04 mov 0x4(%edx),%eax + 6b8: 8d 34 c2 lea (%edx,%eax,8),%esi + 6bb: 39 f1 cmp %esi,%ecx + 6bd: 74 3a je 6f9 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 6bf: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 6c1: 5b pop %ebx + freep = p; + 6c2: 89 15 a0 0d 00 00 mov %edx,0xda0 +} + 6c8: 5e pop %esi + 6c9: 5f pop %edi + 6ca: 5d pop %ebp + 6cb: c3 ret + 6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 6d0: 39 c2 cmp %eax,%edx + 6d2: 72 c4 jb 698 + 6d4: 39 c1 cmp %eax,%ecx + 6d6: 73 c0 jae 698 + if (bp + bp->s.size == p->s.ptr) { + 6d8: 8b 73 fc mov -0x4(%ebx),%esi + 6db: 8d 3c f1 lea (%ecx,%esi,8),%edi + 6de: 39 f8 cmp %edi,%eax + 6e0: 75 d0 jne 6b2 + bp->s.size += p->s.ptr->s.size; + 6e2: 03 70 04 add 0x4(%eax),%esi + 6e5: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 6e8: 8b 02 mov (%edx),%eax + 6ea: 8b 00 mov (%eax),%eax + 6ec: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 6ef: 8b 42 04 mov 0x4(%edx),%eax + 6f2: 8d 34 c2 lea (%edx,%eax,8),%esi + 6f5: 39 f1 cmp %esi,%ecx + 6f7: 75 c6 jne 6bf + p->s.size += bp->s.size; + 6f9: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 6fc: 89 15 a0 0d 00 00 mov %edx,0xda0 + p->s.size += bp->s.size; + 702: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 705: 8b 4b f8 mov -0x8(%ebx),%ecx + 708: 89 0a mov %ecx,(%edx) +} + 70a: 5b pop %ebx + 70b: 5e pop %esi + 70c: 5f pop %edi + 70d: 5d pop %ebp + 70e: c3 ret + 70f: 90 nop + +00000710 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 710: 55 push %ebp + 711: 89 e5 mov %esp,%ebp + 713: 57 push %edi + 714: 56 push %esi + 715: 53 push %ebx + 716: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 719: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 71c: 8b 3d a0 0d 00 00 mov 0xda0,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 722: 8d 70 07 lea 0x7(%eax),%esi + 725: c1 ee 03 shr $0x3,%esi + 728: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 72b: 85 ff test %edi,%edi + 72d: 0f 84 9d 00 00 00 je 7d0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 733: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 735: 8b 4a 04 mov 0x4(%edx),%ecx + 738: 39 f1 cmp %esi,%ecx + 73a: 73 6a jae 7a6 + 73c: bb 00 10 00 00 mov $0x1000,%ebx + 741: 39 de cmp %ebx,%esi + 743: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 746: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 74d: 89 45 e4 mov %eax,-0x1c(%ebp) + 750: eb 17 jmp 769 + 752: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 758: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 75a: 8b 48 04 mov 0x4(%eax),%ecx + 75d: 39 f1 cmp %esi,%ecx + 75f: 73 4f jae 7b0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 761: 8b 3d a0 0d 00 00 mov 0xda0,%edi + 767: 89 c2 mov %eax,%edx + 769: 39 d7 cmp %edx,%edi + 76b: 75 eb jne 758 + p = sbrk(nu * sizeof(Header)); + 76d: 83 ec 0c sub $0xc,%esp + 770: ff 75 e4 push -0x1c(%ebp) + 773: e8 3b fc ff ff call 3b3 + if (p == (char*)-1) { + 778: 83 c4 10 add $0x10,%esp + 77b: 83 f8 ff cmp $0xffffffff,%eax + 77e: 74 1c je 79c + hp->s.size = nu; + 780: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 783: 83 ec 0c sub $0xc,%esp + 786: 83 c0 08 add $0x8,%eax + 789: 50 push %eax + 78a: e8 f1 fe ff ff call 680 + return freep; + 78f: 8b 15 a0 0d 00 00 mov 0xda0,%edx + if ((p = morecore(nunits)) == 0) { + 795: 83 c4 10 add $0x10,%esp + 798: 85 d2 test %edx,%edx + 79a: 75 bc jne 758 + return 0; + } + } + } +} + 79c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 79f: 31 c0 xor %eax,%eax +} + 7a1: 5b pop %ebx + 7a2: 5e pop %esi + 7a3: 5f pop %edi + 7a4: 5d pop %ebp + 7a5: c3 ret + if (p->s.size >= nunits) { + 7a6: 89 d0 mov %edx,%eax + 7a8: 89 fa mov %edi,%edx + 7aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 7b0: 39 ce cmp %ecx,%esi + 7b2: 74 4c je 800 + p->s.size -= nunits; + 7b4: 29 f1 sub %esi,%ecx + 7b6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 7b9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 7bc: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 7bf: 89 15 a0 0d 00 00 mov %edx,0xda0 +} + 7c5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 7c8: 83 c0 08 add $0x8,%eax +} + 7cb: 5b pop %ebx + 7cc: 5e pop %esi + 7cd: 5f pop %edi + 7ce: 5d pop %ebp + 7cf: c3 ret + base.s.ptr = freep = prevp = &base; + 7d0: c7 05 a0 0d 00 00 a4 movl $0xda4,0xda0 + 7d7: 0d 00 00 + base.s.size = 0; + 7da: bf a4 0d 00 00 mov $0xda4,%edi + base.s.ptr = freep = prevp = &base; + 7df: c7 05 a4 0d 00 00 a4 movl $0xda4,0xda4 + 7e6: 0d 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 7e9: 89 fa mov %edi,%edx + base.s.size = 0; + 7eb: c7 05 a8 0d 00 00 00 movl $0x0,0xda8 + 7f2: 00 00 00 + if (p->s.size >= nunits) { + 7f5: e9 42 ff ff ff jmp 73c + 7fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 800: 8b 08 mov (%eax),%ecx + 802: 89 0a mov %ecx,(%edx) + 804: eb b9 jmp 7bf diff --git a/cat.d b/cat.d new file mode 100644 index 0000000..8f55acc --- /dev/null +++ b/cat.d @@ -0,0 +1 @@ +cat.o: cat.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/cat.o b/cat.o new file mode 100644 index 0000000..226c1c0 Binary files /dev/null and b/cat.o differ diff --git a/cat.sym b/cat.sym new file mode 100644 index 0000000..633343e --- /dev/null +++ b/cat.sym @@ -0,0 +1,52 @@ +00000000 cat.c +00000000 ulib.c +00000000 printf.c +00000430 printint +000008a0 digits.0 +00000000 umalloc.c +00000da0 freep +00000da4 base +00000110 strcpy +000004e0 printf +0000040b greeting +00000330 memmove +000003db mknod +00000230 gets +000003ab getpid +00000090 cat +0000041b screen +00000710 malloc +000003bb sleep +00000373 pipe +00000403 getch +000003d3 write +00000393 fstat +00000383 kill +0000039b chdir +0000038b exec +0000036b wait +0000037b read +000003e3 unlink +0000035b fork +000003b3 sbrk +000003c3 uptime +00000b84 __bss_start +000001d0 memset +00000000 main +00000140 strcmp +00000413 shutdown +000003a3 dup +00000ba0 buf +000002a0 stat +00000b84 _edata +00000dac _end +000003eb link +00000363 exit +000002f0 atoi +00000423 cls +000001a0 strlen +000003cb open +000001f0 strchr +000003f3 mkdir +000003fb close +00000680 free diff --git a/cls.asm b/cls.asm new file mode 100644 index 0000000..5463e0d --- /dev/null +++ b/cls.asm @@ -0,0 +1,1142 @@ + +_cls: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "user.h" + +int main(int argc, char *argv[]) { + 0: 55 push %ebp + 1: 89 e5 mov %esp,%ebp + 3: 83 e4 f0 and $0xfffffff0,%esp + cls(); + 6: e8 18 03 00 00 call 323 + //printf(1, "$ "); + exit(); + b: e8 53 02 00 00 call 263 + +00000010 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 10: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 11: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 13: 89 e5 mov %esp,%ebp + 15: 53 push %ebx + 16: 8b 4d 08 mov 0x8(%ebp),%ecx + 19: 8b 5d 0c mov 0xc(%ebp),%ebx + 1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 20: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 24: 88 14 01 mov %dl,(%ecx,%eax,1) + 27: 83 c0 01 add $0x1,%eax + 2a: 84 d2 test %dl,%dl + 2c: 75 f2 jne 20 + ; + } + return os; +} + 2e: 8b 5d fc mov -0x4(%ebp),%ebx + 31: 89 c8 mov %ecx,%eax + 33: c9 leave + 34: c3 ret + 35: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000040 : + +int strcmp(const char *p, const char *q) { + 40: 55 push %ebp + 41: 89 e5 mov %esp,%ebp + 43: 53 push %ebx + 44: 8b 55 08 mov 0x8(%ebp),%edx + 47: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 4a: 0f b6 02 movzbl (%edx),%eax + 4d: 84 c0 test %al,%al + 4f: 75 17 jne 68 + 51: eb 3a jmp 8d + 53: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 57: 90 nop + 58: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 5c: 83 c2 01 add $0x1,%edx + 5f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 62: 84 c0 test %al,%al + 64: 74 1a je 80 + p++, q++; + 66: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 68: 0f b6 19 movzbl (%ecx),%ebx + 6b: 38 c3 cmp %al,%bl + 6d: 74 e9 je 58 + } + return (uchar) * p - (uchar) * q; + 6f: 29 d8 sub %ebx,%eax +} + 71: 8b 5d fc mov -0x4(%ebp),%ebx + 74: c9 leave + 75: c3 ret + 76: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 7d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 80: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 84: 31 c0 xor %eax,%eax + 86: 29 d8 sub %ebx,%eax +} + 88: 8b 5d fc mov -0x4(%ebp),%ebx + 8b: c9 leave + 8c: c3 ret + return (uchar) * p - (uchar) * q; + 8d: 0f b6 19 movzbl (%ecx),%ebx + 90: 31 c0 xor %eax,%eax + 92: eb db jmp 6f + 94: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 9b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 9f: 90 nop + +000000a0 : + +uint strlen(const char *s) { + a0: 55 push %ebp + a1: 89 e5 mov %esp,%ebp + a3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + a6: 80 3a 00 cmpb $0x0,(%edx) + a9: 74 15 je c0 + ab: 31 c0 xor %eax,%eax + ad: 8d 76 00 lea 0x0(%esi),%esi + b0: 83 c0 01 add $0x1,%eax + b3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + b7: 89 c1 mov %eax,%ecx + b9: 75 f5 jne b0 + ; + } + return n; +} + bb: 89 c8 mov %ecx,%eax + bd: 5d pop %ebp + be: c3 ret + bf: 90 nop + for (n = 0; s[n]; n++) { + c0: 31 c9 xor %ecx,%ecx +} + c2: 5d pop %ebp + c3: 89 c8 mov %ecx,%eax + c5: c3 ret + c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cd: 8d 76 00 lea 0x0(%esi),%esi + +000000d0 : + +void* memset(void *dst, int c, uint n) { + d0: 55 push %ebp + d1: 89 e5 mov %esp,%ebp + d3: 57 push %edi + d4: 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" : + d7: 8b 4d 10 mov 0x10(%ebp),%ecx + da: 8b 45 0c mov 0xc(%ebp),%eax + dd: 89 d7 mov %edx,%edi + df: fc cld + e0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + e2: 8b 7d fc mov -0x4(%ebp),%edi + e5: 89 d0 mov %edx,%eax + e7: c9 leave + e8: c3 ret + e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000000f0 : + +char* strchr(const char *s, char c) { + f0: 55 push %ebp + f1: 89 e5 mov %esp,%ebp + f3: 8b 45 08 mov 0x8(%ebp),%eax + f6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + fa: 0f b6 10 movzbl (%eax),%edx + fd: 84 d2 test %dl,%dl + ff: 75 12 jne 113 + 101: eb 1d jmp 120 + 103: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 107: 90 nop + 108: 0f b6 50 01 movzbl 0x1(%eax),%edx + 10c: 83 c0 01 add $0x1,%eax + 10f: 84 d2 test %dl,%dl + 111: 74 0d je 120 + if (*s == c) { + 113: 38 d1 cmp %dl,%cl + 115: 75 f1 jne 108 + return (char*)s; + } + } + return 0; +} + 117: 5d pop %ebp + 118: c3 ret + 119: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 120: 31 c0 xor %eax,%eax +} + 122: 5d pop %ebp + 123: c3 ret + 124: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 12b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 12f: 90 nop + +00000130 : + +char* gets(char *buf, int max) { + 130: 55 push %ebp + 131: 89 e5 mov %esp,%ebp + 133: 57 push %edi + 134: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 135: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 138: 53 push %ebx + for (i = 0; i + 1 < max;) { + 139: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 13b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 13e: eb 27 jmp 167 + cc = read(0, &c, 1); + 140: 83 ec 04 sub $0x4,%esp + 143: 6a 01 push $0x1 + 145: 57 push %edi + 146: 6a 00 push $0x0 + 148: e8 2e 01 00 00 call 27b + if (cc < 1) { + 14d: 83 c4 10 add $0x10,%esp + 150: 85 c0 test %eax,%eax + 152: 7e 1d jle 171 + break; + } + buf[i++] = c; + 154: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 158: 8b 55 08 mov 0x8(%ebp),%edx + 15b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 15f: 3c 0a cmp $0xa,%al + 161: 74 1d je 180 + 163: 3c 0d cmp $0xd,%al + 165: 74 19 je 180 + for (i = 0; i + 1 < max;) { + 167: 89 de mov %ebx,%esi + 169: 83 c3 01 add $0x1,%ebx + 16c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 16f: 7c cf jl 140 + break; + } + } + buf[i] = '\0'; + 171: 8b 45 08 mov 0x8(%ebp),%eax + 174: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 178: 8d 65 f4 lea -0xc(%ebp),%esp + 17b: 5b pop %ebx + 17c: 5e pop %esi + 17d: 5f pop %edi + 17e: 5d pop %ebp + 17f: c3 ret + buf[i] = '\0'; + 180: 8b 45 08 mov 0x8(%ebp),%eax + 183: 89 de mov %ebx,%esi + 185: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 189: 8d 65 f4 lea -0xc(%ebp),%esp + 18c: 5b pop %ebx + 18d: 5e pop %esi + 18e: 5f pop %edi + 18f: 5d pop %ebp + 190: c3 ret + 191: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 198: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 19f: 90 nop + +000001a0 : + +int stat(const char *n, struct stat *st) { + 1a0: 55 push %ebp + 1a1: 89 e5 mov %esp,%ebp + 1a3: 56 push %esi + 1a4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 1a5: 83 ec 08 sub $0x8,%esp + 1a8: 6a 00 push $0x0 + 1aa: ff 75 08 push 0x8(%ebp) + 1ad: e8 19 01 00 00 call 2cb + if (fd < 0) { + 1b2: 83 c4 10 add $0x10,%esp + 1b5: 85 c0 test %eax,%eax + 1b7: 78 27 js 1e0 + return -1; + } + r = fstat(fd, st); + 1b9: 83 ec 08 sub $0x8,%esp + 1bc: ff 75 0c push 0xc(%ebp) + 1bf: 89 c3 mov %eax,%ebx + 1c1: 50 push %eax + 1c2: e8 cc 00 00 00 call 293 + close(fd); + 1c7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1ca: 89 c6 mov %eax,%esi + close(fd); + 1cc: e8 2a 01 00 00 call 2fb + return r; + 1d1: 83 c4 10 add $0x10,%esp +} + 1d4: 8d 65 f8 lea -0x8(%ebp),%esp + 1d7: 89 f0 mov %esi,%eax + 1d9: 5b pop %ebx + 1da: 5e pop %esi + 1db: 5d pop %ebp + 1dc: c3 ret + 1dd: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 1e0: be ff ff ff ff mov $0xffffffff,%esi + 1e5: eb ed jmp 1d4 + 1e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ee: 66 90 xchg %ax,%ax + +000001f0 : + +int atoi(const char *s) { + 1f0: 55 push %ebp + 1f1: 89 e5 mov %esp,%ebp + 1f3: 53 push %ebx + 1f4: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 1f7: 0f be 02 movsbl (%edx),%eax + 1fa: 8d 48 d0 lea -0x30(%eax),%ecx + 1fd: 80 f9 09 cmp $0x9,%cl + n = 0; + 200: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 205: 77 1e ja 225 + 207: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 20e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 210: 83 c2 01 add $0x1,%edx + 213: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 216: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 21a: 0f be 02 movsbl (%edx),%eax + 21d: 8d 58 d0 lea -0x30(%eax),%ebx + 220: 80 fb 09 cmp $0x9,%bl + 223: 76 eb jbe 210 + } + return n; +} + 225: 8b 5d fc mov -0x4(%ebp),%ebx + 228: 89 c8 mov %ecx,%eax + 22a: c9 leave + 22b: c3 ret + 22c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000230 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 230: 55 push %ebp + 231: 89 e5 mov %esp,%ebp + 233: 57 push %edi + 234: 8b 45 10 mov 0x10(%ebp),%eax + 237: 8b 55 08 mov 0x8(%ebp),%edx + 23a: 56 push %esi + 23b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 23e: 85 c0 test %eax,%eax + 240: 7e 13 jle 255 + 242: 01 d0 add %edx,%eax + dst = vdst; + 244: 89 d7 mov %edx,%edi + 246: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 24d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 250: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 251: 39 f8 cmp %edi,%eax + 253: 75 fb jne 250 + } + return vdst; +} + 255: 5e pop %esi + 256: 89 d0 mov %edx,%eax + 258: 5f pop %edi + 259: 5d pop %ebp + 25a: c3 ret + +0000025b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 25b: b8 01 00 00 00 mov $0x1,%eax + 260: cd 40 int $0x40 + 262: c3 ret + +00000263 : +SYSCALL(exit) + 263: b8 02 00 00 00 mov $0x2,%eax + 268: cd 40 int $0x40 + 26a: c3 ret + +0000026b : +SYSCALL(wait) + 26b: b8 03 00 00 00 mov $0x3,%eax + 270: cd 40 int $0x40 + 272: c3 ret + +00000273 : +SYSCALL(pipe) + 273: b8 04 00 00 00 mov $0x4,%eax + 278: cd 40 int $0x40 + 27a: c3 ret + +0000027b : +SYSCALL(read) + 27b: b8 05 00 00 00 mov $0x5,%eax + 280: cd 40 int $0x40 + 282: c3 ret + +00000283 : +SYSCALL(kill) + 283: b8 06 00 00 00 mov $0x6,%eax + 288: cd 40 int $0x40 + 28a: c3 ret + +0000028b : +SYSCALL(exec) + 28b: b8 07 00 00 00 mov $0x7,%eax + 290: cd 40 int $0x40 + 292: c3 ret + +00000293 : +SYSCALL(fstat) + 293: b8 08 00 00 00 mov $0x8,%eax + 298: cd 40 int $0x40 + 29a: c3 ret + +0000029b : +SYSCALL(chdir) + 29b: b8 09 00 00 00 mov $0x9,%eax + 2a0: cd 40 int $0x40 + 2a2: c3 ret + +000002a3 : +SYSCALL(dup) + 2a3: b8 0a 00 00 00 mov $0xa,%eax + 2a8: cd 40 int $0x40 + 2aa: c3 ret + +000002ab : +SYSCALL(getpid) + 2ab: b8 0b 00 00 00 mov $0xb,%eax + 2b0: cd 40 int $0x40 + 2b2: c3 ret + +000002b3 : +SYSCALL(sbrk) + 2b3: b8 0c 00 00 00 mov $0xc,%eax + 2b8: cd 40 int $0x40 + 2ba: c3 ret + +000002bb : +SYSCALL(sleep) + 2bb: b8 0d 00 00 00 mov $0xd,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(uptime) + 2c3: b8 0e 00 00 00 mov $0xe,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(open) + 2cb: b8 0f 00 00 00 mov $0xf,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(write) + 2d3: b8 10 00 00 00 mov $0x10,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(mknod) + 2db: b8 11 00 00 00 mov $0x11,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(unlink) + 2e3: b8 12 00 00 00 mov $0x12,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(link) + 2eb: b8 13 00 00 00 mov $0x13,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(mkdir) + 2f3: b8 14 00 00 00 mov $0x14,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(close) + 2fb: b8 15 00 00 00 mov $0x15,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(getch) + 303: b8 16 00 00 00 mov $0x16,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(greeting) + 30b: b8 17 00 00 00 mov $0x17,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(shutdown) + 313: b8 18 00 00 00 mov $0x18,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(screen) + 31b: b8 19 00 00 00 mov $0x19,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(cls) + 323: b8 1a 00 00 00 mov $0x1a,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + 32b: 66 90 xchg %ax,%ax + 32d: 66 90 xchg %ax,%ax + 32f: 90 nop + +00000330 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 330: 55 push %ebp + 331: 89 e5 mov %esp,%ebp + 333: 57 push %edi + 334: 56 push %esi + 335: 53 push %ebx + 336: 83 ec 3c sub $0x3c,%esp + 339: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 33c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 33e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 341: 85 d2 test %edx,%edx + 343: 0f 89 7f 00 00 00 jns 3c8 + 349: f6 45 08 01 testb $0x1,0x8(%ebp) + 34d: 74 79 je 3c8 + neg = 1; + 34f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 356: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 358: 31 db xor %ebx,%ebx + 35a: 8d 75 d7 lea -0x29(%ebp),%esi + 35d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 360: 89 c8 mov %ecx,%eax + 362: 31 d2 xor %edx,%edx + 364: 89 cf mov %ecx,%edi + 366: f7 75 c4 divl -0x3c(%ebp) + 369: 0f b6 92 68 07 00 00 movzbl 0x768(%edx),%edx + 370: 89 45 c0 mov %eax,-0x40(%ebp) + 373: 89 d8 mov %ebx,%eax + 375: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 378: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 37b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 37e: 39 7d c4 cmp %edi,-0x3c(%ebp) + 381: 76 dd jbe 360 + if (neg) { + 383: 8b 4d bc mov -0x44(%ebp),%ecx + 386: 85 c9 test %ecx,%ecx + 388: 74 0c je 396 + buf[i++] = '-'; + 38a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 38f: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 391: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 396: 8b 7d b8 mov -0x48(%ebp),%edi + 399: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 39d: eb 07 jmp 3a6 + 39f: 90 nop + putc(fd, buf[i]); + 3a0: 0f b6 13 movzbl (%ebx),%edx + 3a3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 3a6: 83 ec 04 sub $0x4,%esp + 3a9: 88 55 d7 mov %dl,-0x29(%ebp) + 3ac: 6a 01 push $0x1 + 3ae: 56 push %esi + 3af: 57 push %edi + 3b0: e8 1e ff ff ff call 2d3 + while (--i >= 0) { + 3b5: 83 c4 10 add $0x10,%esp + 3b8: 39 de cmp %ebx,%esi + 3ba: 75 e4 jne 3a0 + } +} + 3bc: 8d 65 f4 lea -0xc(%ebp),%esp + 3bf: 5b pop %ebx + 3c0: 5e pop %esi + 3c1: 5f pop %edi + 3c2: 5d pop %ebp + 3c3: c3 ret + 3c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 3c8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 3cf: eb 87 jmp 358 + 3d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3df: 90 nop + +000003e0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 3e0: 55 push %ebp + 3e1: 89 e5 mov %esp,%ebp + 3e3: 57 push %edi + 3e4: 56 push %esi + 3e5: 53 push %ebx + 3e6: 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++) { + 3e9: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 3ec: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 3ef: 0f b6 13 movzbl (%ebx),%edx + 3f2: 84 d2 test %dl,%dl + 3f4: 74 6a je 460 + ap = (uint*)(void*)&fmt + 1; + 3f6: 8d 45 10 lea 0x10(%ebp),%eax + 3f9: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 3fc: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 3ff: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 401: 89 45 d0 mov %eax,-0x30(%ebp) + 404: eb 36 jmp 43c + 406: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 40d: 8d 76 00 lea 0x0(%esi),%esi + 410: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 413: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 418: 83 f8 25 cmp $0x25,%eax + 41b: 74 15 je 432 + write(fd, &c, 1); + 41d: 83 ec 04 sub $0x4,%esp + 420: 88 55 e7 mov %dl,-0x19(%ebp) + 423: 6a 01 push $0x1 + 425: 57 push %edi + 426: 56 push %esi + 427: e8 a7 fe ff ff call 2d3 + 42c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 42f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 432: 0f b6 13 movzbl (%ebx),%edx + 435: 83 c3 01 add $0x1,%ebx + 438: 84 d2 test %dl,%dl + 43a: 74 24 je 460 + c = fmt[i] & 0xff; + 43c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 43f: 85 c9 test %ecx,%ecx + 441: 74 cd je 410 + } + } + else if (state == '%') { + 443: 83 f9 25 cmp $0x25,%ecx + 446: 75 ea jne 432 + if (c == 'd') { + 448: 83 f8 25 cmp $0x25,%eax + 44b: 0f 84 07 01 00 00 je 558 + 451: 83 e8 63 sub $0x63,%eax + 454: 83 f8 15 cmp $0x15,%eax + 457: 77 17 ja 470 + 459: ff 24 85 10 07 00 00 jmp *0x710(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 460: 8d 65 f4 lea -0xc(%ebp),%esp + 463: 5b pop %ebx + 464: 5e pop %esi + 465: 5f pop %edi + 466: 5d pop %ebp + 467: c3 ret + 468: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 46f: 90 nop + write(fd, &c, 1); + 470: 83 ec 04 sub $0x4,%esp + 473: 88 55 d4 mov %dl,-0x2c(%ebp) + 476: 6a 01 push $0x1 + 478: 57 push %edi + 479: 56 push %esi + 47a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 47e: e8 50 fe ff ff call 2d3 + putc(fd, c); + 483: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 487: 83 c4 0c add $0xc,%esp + 48a: 88 55 e7 mov %dl,-0x19(%ebp) + 48d: 6a 01 push $0x1 + 48f: 57 push %edi + 490: 56 push %esi + 491: e8 3d fe ff ff call 2d3 + putc(fd, c); + 496: 83 c4 10 add $0x10,%esp + state = 0; + 499: 31 c9 xor %ecx,%ecx + 49b: eb 95 jmp 432 + 49d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 4a0: 83 ec 0c sub $0xc,%esp + 4a3: b9 10 00 00 00 mov $0x10,%ecx + 4a8: 6a 00 push $0x0 + 4aa: 8b 45 d0 mov -0x30(%ebp),%eax + 4ad: 8b 10 mov (%eax),%edx + 4af: 89 f0 mov %esi,%eax + 4b1: e8 7a fe ff ff call 330 + ap++; + 4b6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 4ba: 83 c4 10 add $0x10,%esp + state = 0; + 4bd: 31 c9 xor %ecx,%ecx + 4bf: e9 6e ff ff ff jmp 432 + 4c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 4c8: 8b 45 d0 mov -0x30(%ebp),%eax + 4cb: 8b 10 mov (%eax),%edx + ap++; + 4cd: 83 c0 04 add $0x4,%eax + 4d0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 4d3: 85 d2 test %edx,%edx + 4d5: 0f 84 8d 00 00 00 je 568 + while (*s != 0) { + 4db: 0f b6 02 movzbl (%edx),%eax + state = 0; + 4de: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 4e0: 84 c0 test %al,%al + 4e2: 0f 84 4a ff ff ff je 432 + 4e8: 89 5d d4 mov %ebx,-0x2c(%ebp) + 4eb: 89 d3 mov %edx,%ebx + 4ed: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 4f0: 83 ec 04 sub $0x4,%esp + s++; + 4f3: 83 c3 01 add $0x1,%ebx + 4f6: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 4f9: 6a 01 push $0x1 + 4fb: 57 push %edi + 4fc: 56 push %esi + 4fd: e8 d1 fd ff ff call 2d3 + while (*s != 0) { + 502: 0f b6 03 movzbl (%ebx),%eax + 505: 83 c4 10 add $0x10,%esp + 508: 84 c0 test %al,%al + 50a: 75 e4 jne 4f0 + state = 0; + 50c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 50f: 31 c9 xor %ecx,%ecx + 511: e9 1c ff ff ff jmp 432 + 516: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 51d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 520: 83 ec 0c sub $0xc,%esp + 523: b9 0a 00 00 00 mov $0xa,%ecx + 528: 6a 01 push $0x1 + 52a: e9 7b ff ff ff jmp 4aa + 52f: 90 nop + putc(fd, *ap); + 530: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 533: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 536: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 538: 6a 01 push $0x1 + 53a: 57 push %edi + 53b: 56 push %esi + putc(fd, *ap); + 53c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 53f: e8 8f fd ff ff call 2d3 + ap++; + 544: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 548: 83 c4 10 add $0x10,%esp + state = 0; + 54b: 31 c9 xor %ecx,%ecx + 54d: e9 e0 fe ff ff jmp 432 + 552: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 558: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 55b: 83 ec 04 sub $0x4,%esp + 55e: e9 2a ff ff ff jmp 48d + 563: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 567: 90 nop + s = "(null)"; + 568: ba 08 07 00 00 mov $0x708,%edx + while (*s != 0) { + 56d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 570: b8 28 00 00 00 mov $0x28,%eax + 575: 89 d3 mov %edx,%ebx + 577: e9 74 ff ff ff jmp 4f0 + 57c: 66 90 xchg %ax,%ax + 57e: 66 90 xchg %ax,%ax + +00000580 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 580: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 581: a1 08 0a 00 00 mov 0xa08,%eax +void free(void *ap) { + 586: 89 e5 mov %esp,%ebp + 588: 57 push %edi + 589: 56 push %esi + 58a: 53 push %ebx + 58b: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 58e: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 591: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 598: 89 c2 mov %eax,%edx + 59a: 8b 00 mov (%eax),%eax + 59c: 39 ca cmp %ecx,%edx + 59e: 73 30 jae 5d0 + 5a0: 39 c1 cmp %eax,%ecx + 5a2: 72 04 jb 5a8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5a4: 39 c2 cmp %eax,%edx + 5a6: 72 f0 jb 598 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 5a8: 8b 73 fc mov -0x4(%ebx),%esi + 5ab: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5ae: 39 f8 cmp %edi,%eax + 5b0: 74 30 je 5e2 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 5b2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 5b5: 8b 42 04 mov 0x4(%edx),%eax + 5b8: 8d 34 c2 lea (%edx,%eax,8),%esi + 5bb: 39 f1 cmp %esi,%ecx + 5bd: 74 3a je 5f9 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 5bf: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 5c1: 5b pop %ebx + freep = p; + 5c2: 89 15 08 0a 00 00 mov %edx,0xa08 +} + 5c8: 5e pop %esi + 5c9: 5f pop %edi + 5ca: 5d pop %ebp + 5cb: c3 ret + 5cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5d0: 39 c2 cmp %eax,%edx + 5d2: 72 c4 jb 598 + 5d4: 39 c1 cmp %eax,%ecx + 5d6: 73 c0 jae 598 + if (bp + bp->s.size == p->s.ptr) { + 5d8: 8b 73 fc mov -0x4(%ebx),%esi + 5db: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5de: 39 f8 cmp %edi,%eax + 5e0: 75 d0 jne 5b2 + bp->s.size += p->s.ptr->s.size; + 5e2: 03 70 04 add 0x4(%eax),%esi + 5e5: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 5e8: 8b 02 mov (%edx),%eax + 5ea: 8b 00 mov (%eax),%eax + 5ec: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 5ef: 8b 42 04 mov 0x4(%edx),%eax + 5f2: 8d 34 c2 lea (%edx,%eax,8),%esi + 5f5: 39 f1 cmp %esi,%ecx + 5f7: 75 c6 jne 5bf + p->s.size += bp->s.size; + 5f9: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 5fc: 89 15 08 0a 00 00 mov %edx,0xa08 + p->s.size += bp->s.size; + 602: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 605: 8b 4b f8 mov -0x8(%ebx),%ecx + 608: 89 0a mov %ecx,(%edx) +} + 60a: 5b pop %ebx + 60b: 5e pop %esi + 60c: 5f pop %edi + 60d: 5d pop %ebp + 60e: c3 ret + 60f: 90 nop + +00000610 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 610: 55 push %ebp + 611: 89 e5 mov %esp,%ebp + 613: 57 push %edi + 614: 56 push %esi + 615: 53 push %ebx + 616: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 619: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 61c: 8b 3d 08 0a 00 00 mov 0xa08,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 622: 8d 70 07 lea 0x7(%eax),%esi + 625: c1 ee 03 shr $0x3,%esi + 628: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 62b: 85 ff test %edi,%edi + 62d: 0f 84 9d 00 00 00 je 6d0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 633: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 635: 8b 4a 04 mov 0x4(%edx),%ecx + 638: 39 f1 cmp %esi,%ecx + 63a: 73 6a jae 6a6 + 63c: bb 00 10 00 00 mov $0x1000,%ebx + 641: 39 de cmp %ebx,%esi + 643: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 646: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 64d: 89 45 e4 mov %eax,-0x1c(%ebp) + 650: eb 17 jmp 669 + 652: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 658: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 65a: 8b 48 04 mov 0x4(%eax),%ecx + 65d: 39 f1 cmp %esi,%ecx + 65f: 73 4f jae 6b0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 661: 8b 3d 08 0a 00 00 mov 0xa08,%edi + 667: 89 c2 mov %eax,%edx + 669: 39 d7 cmp %edx,%edi + 66b: 75 eb jne 658 + p = sbrk(nu * sizeof(Header)); + 66d: 83 ec 0c sub $0xc,%esp + 670: ff 75 e4 push -0x1c(%ebp) + 673: e8 3b fc ff ff call 2b3 + if (p == (char*)-1) { + 678: 83 c4 10 add $0x10,%esp + 67b: 83 f8 ff cmp $0xffffffff,%eax + 67e: 74 1c je 69c + hp->s.size = nu; + 680: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 683: 83 ec 0c sub $0xc,%esp + 686: 83 c0 08 add $0x8,%eax + 689: 50 push %eax + 68a: e8 f1 fe ff ff call 580 + return freep; + 68f: 8b 15 08 0a 00 00 mov 0xa08,%edx + if ((p = morecore(nunits)) == 0) { + 695: 83 c4 10 add $0x10,%esp + 698: 85 d2 test %edx,%edx + 69a: 75 bc jne 658 + return 0; + } + } + } +} + 69c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 69f: 31 c0 xor %eax,%eax +} + 6a1: 5b pop %ebx + 6a2: 5e pop %esi + 6a3: 5f pop %edi + 6a4: 5d pop %ebp + 6a5: c3 ret + if (p->s.size >= nunits) { + 6a6: 89 d0 mov %edx,%eax + 6a8: 89 fa mov %edi,%edx + 6aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 6b0: 39 ce cmp %ecx,%esi + 6b2: 74 4c je 700 + p->s.size -= nunits; + 6b4: 29 f1 sub %esi,%ecx + 6b6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 6b9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 6bc: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 6bf: 89 15 08 0a 00 00 mov %edx,0xa08 +} + 6c5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 6c8: 83 c0 08 add $0x8,%eax +} + 6cb: 5b pop %ebx + 6cc: 5e pop %esi + 6cd: 5f pop %edi + 6ce: 5d pop %ebp + 6cf: c3 ret + base.s.ptr = freep = prevp = &base; + 6d0: c7 05 08 0a 00 00 0c movl $0xa0c,0xa08 + 6d7: 0a 00 00 + base.s.size = 0; + 6da: bf 0c 0a 00 00 mov $0xa0c,%edi + base.s.ptr = freep = prevp = &base; + 6df: c7 05 0c 0a 00 00 0c movl $0xa0c,0xa0c + 6e6: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6e9: 89 fa mov %edi,%edx + base.s.size = 0; + 6eb: c7 05 10 0a 00 00 00 movl $0x0,0xa10 + 6f2: 00 00 00 + if (p->s.size >= nunits) { + 6f5: e9 42 ff ff ff jmp 63c + 6fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 700: 8b 08 mov (%eax),%ecx + 702: 89 0a mov %ecx,(%edx) + 704: eb b9 jmp 6bf diff --git a/cls.d b/cls.d new file mode 100644 index 0000000..e190e0d --- /dev/null +++ b/cls.d @@ -0,0 +1 @@ +cls.o: cls.c /usr/include/stdc-predef.h types.h user.h diff --git a/cls.o b/cls.o new file mode 100644 index 0000000..de9d3b9 Binary files /dev/null and b/cls.o differ diff --git a/cls.sym b/cls.sym new file mode 100644 index 0000000..f2d93f0 --- /dev/null +++ b/cls.sym @@ -0,0 +1,50 @@ +00000000 cls.c +00000000 ulib.c +00000000 printf.c +00000330 printint +00000768 digits.0 +00000000 umalloc.c +00000a08 freep +00000a0c base +00000010 strcpy +000003e0 printf +0000030b greeting +00000230 memmove +000002db mknod +00000130 gets +000002ab getpid +0000031b screen +00000610 malloc +000002bb sleep +00000273 pipe +00000303 getch +000002d3 write +00000293 fstat +00000283 kill +0000029b chdir +0000028b exec +0000026b wait +0000027b read +000002e3 unlink +0000025b fork +000002b3 sbrk +000002c3 uptime +00000a08 __bss_start +000000d0 memset +00000000 main +00000040 strcmp +00000313 shutdown +000002a3 dup +000001a0 stat +00000a08 _edata +00000a14 _end +000002eb link +00000263 exit +000001f0 atoi +00000323 cls +000000a0 strlen +000002cb open +000000f0 strchr +000002f3 mkdir +000002fb close +00000580 free diff --git a/console.d b/console.d new file mode 100644 index 0000000..7b5564c --- /dev/null +++ b/console.d @@ -0,0 +1,3 @@ +console.o: console.c /usr/include/stdc-predef.h types.h defs.h param.h \ + traps.h spinlock.h sleeplock.h fs.h file.h memlayout.h mmu.h proc.h \ + x86.h diff --git a/console.o b/console.o new file mode 100644 index 0000000..7028655 Binary files /dev/null and b/console.o differ diff --git a/count.asm b/count.asm new file mode 100644 index 0000000..0681283 --- /dev/null +++ b/count.asm @@ -0,0 +1,1275 @@ + +_count: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "user.h" + +// Simple user app to do a count from 0 to the given number (1000 by defaulf) +// for testing concurrency +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: 51 push %ecx + 11: 83 ec 18 sub $0x18,%esp + 14: 8b 01 mov (%ecx),%eax + 16: 8b 71 04 mov 0x4(%ecx),%esi + 19: 89 45 e4 mov %eax,-0x1c(%ebp) + int countto = 1000; + + for (int i = 1; i < argc; i++) { + 1c: 83 f8 01 cmp $0x1,%eax + 1f: 0f 8e f5 00 00 00 jle 11a + 25: bf 01 00 00 00 mov $0x1,%edi + int countto = 1000; + 2a: bb e8 03 00 00 mov $0x3e8,%ebx + 2f: eb 20 jmp 51 + 31: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (strcmp(argv[i], "-c") == 0) { + countto = atoi(argv[i + 1]); + 38: 83 ec 0c sub $0xc,%esp + 3b: ff 74 be 04 push 0x4(%esi,%edi,4) + 3f: e8 dc 02 00 00 call 320 + 44: 83 c4 10 add $0x10,%esp + 47: 89 c3 mov %eax,%ebx + for (int i = 1; i < argc; i++) { + 49: 83 c7 01 add $0x1,%edi + 4c: 39 7d e4 cmp %edi,-0x1c(%ebp) + 4f: 74 6b je bc + if (strcmp(argv[i], "-c") == 0) { + 51: 83 ec 08 sub $0x8,%esp + 54: 68 38 08 00 00 push $0x838 + 59: ff 34 be push (%esi,%edi,4) + 5c: e8 0f 01 00 00 call 170 + 61: 83 c4 10 add $0x10,%esp + 64: 85 c0 test %eax,%eax + 66: 74 d0 je 38 + } + else if (strcmp(argv[i], "-help") == 0) + 68: 83 ec 08 sub $0x8,%esp + 6b: 68 3b 08 00 00 push $0x83b + 70: ff 34 be push (%esi,%edi,4) + 73: e8 f8 00 00 00 call 170 + 78: 83 c4 10 add $0x10,%esp + 7b: 85 c0 test %eax,%eax + 7d: 75 ca jne 49 + { + printf(1, "Counts from 0 to the given number.\n"); + 7f: 51 push %ecx + 80: 51 push %ecx + 81: 68 78 08 00 00 push $0x878 + 86: 6a 01 push $0x1 + 88: e8 83 04 00 00 call 510 + printf(1, "Default: 1000\n"); + 8d: 5b pop %ebx + 8e: 5e pop %esi + 8f: 68 41 08 00 00 push $0x841 + 94: 6a 01 push $0x1 + 96: e8 75 04 00 00 call 510 + printf(1, "Options:\n"); + 9b: 5f pop %edi + 9c: 58 pop %eax + 9d: 68 50 08 00 00 push $0x850 + a2: 6a 01 push $0x1 + a4: e8 67 04 00 00 call 510 + printf(1, "-c [Number] : Sets the value to count upto.\n"); + a9: 58 pop %eax + aa: 5a pop %edx + ab: 68 9c 08 00 00 push $0x89c + b0: 6a 01 push $0x1 + b2: e8 59 04 00 00 call 510 + exit(); + b7: e8 d7 02 00 00 call 393 + return 0; + } + } + + cls(); + bc: e8 92 03 00 00 call 453 + printf(1, "Start Count\n"); + c1: 50 push %eax + c2: 50 push %eax + c3: 68 5a 08 00 00 push $0x85a + c8: 6a 01 push $0x1 + ca: e8 41 04 00 00 call 510 + for (int i = 0; i < countto; i++) + cf: 83 c4 10 add $0x10,%esp + d2: 85 db test %ebx,%ebx + d4: 7e 30 jle 106 + d6: 31 f6 xor %esi,%esi + d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + df: 90 nop + { + printf(1, "%d\n", i); + e0: 83 ec 04 sub $0x4,%esp + e3: 56 push %esi + for (int i = 0; i < countto; i++) + e4: 83 c6 01 add $0x1,%esi + printf(1, "%d\n", i); + e7: 68 67 08 00 00 push $0x867 + ec: 6a 01 push $0x1 + ee: e8 1d 04 00 00 call 510 + sleep(10); + f3: c7 04 24 0a 00 00 00 movl $0xa,(%esp) + fa: e8 ec 02 00 00 call 3eb + for (int i = 0; i < countto; i++) + ff: 83 c4 10 add $0x10,%esp + 102: 39 f3 cmp %esi,%ebx + 104: 7f da jg e0 + } + printf(1, "Count Ended\n"); + 106: 83 ec 08 sub $0x8,%esp + 109: 68 6b 08 00 00 push $0x86b + 10e: 6a 01 push $0x1 + 110: e8 fb 03 00 00 call 510 + exit(); + 115: e8 79 02 00 00 call 393 + cls(); + 11a: e8 34 03 00 00 call 453 + int countto = 1000; + 11f: bb e8 03 00 00 mov $0x3e8,%ebx + printf(1, "Start Count\n"); + 124: 52 push %edx + 125: 52 push %edx + 126: 68 5a 08 00 00 push $0x85a + 12b: 6a 01 push $0x1 + 12d: e8 de 03 00 00 call 510 + 132: 83 c4 10 add $0x10,%esp + 135: eb 9f jmp d6 + 137: 66 90 xchg %ax,%ax + 139: 66 90 xchg %ax,%ax + 13b: 66 90 xchg %ax,%ax + 13d: 66 90 xchg %ax,%ax + 13f: 90 nop + +00000140 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 140: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 141: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 143: 89 e5 mov %esp,%ebp + 145: 53 push %ebx + 146: 8b 4d 08 mov 0x8(%ebp),%ecx + 149: 8b 5d 0c mov 0xc(%ebp),%ebx + 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 150: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 154: 88 14 01 mov %dl,(%ecx,%eax,1) + 157: 83 c0 01 add $0x1,%eax + 15a: 84 d2 test %dl,%dl + 15c: 75 f2 jne 150 + ; + } + return os; +} + 15e: 8b 5d fc mov -0x4(%ebp),%ebx + 161: 89 c8 mov %ecx,%eax + 163: c9 leave + 164: c3 ret + 165: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 16c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000170 : + +int strcmp(const char *p, const char *q) { + 170: 55 push %ebp + 171: 89 e5 mov %esp,%ebp + 173: 53 push %ebx + 174: 8b 55 08 mov 0x8(%ebp),%edx + 177: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 17a: 0f b6 02 movzbl (%edx),%eax + 17d: 84 c0 test %al,%al + 17f: 75 17 jne 198 + 181: eb 3a jmp 1bd + 183: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 187: 90 nop + 188: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 18c: 83 c2 01 add $0x1,%edx + 18f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 192: 84 c0 test %al,%al + 194: 74 1a je 1b0 + p++, q++; + 196: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 198: 0f b6 19 movzbl (%ecx),%ebx + 19b: 38 c3 cmp %al,%bl + 19d: 74 e9 je 188 + } + return (uchar) * p - (uchar) * q; + 19f: 29 d8 sub %ebx,%eax +} + 1a1: 8b 5d fc mov -0x4(%ebp),%ebx + 1a4: c9 leave + 1a5: c3 ret + 1a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ad: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 1b0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 1b4: 31 c0 xor %eax,%eax + 1b6: 29 d8 sub %ebx,%eax +} + 1b8: 8b 5d fc mov -0x4(%ebp),%ebx + 1bb: c9 leave + 1bc: c3 ret + return (uchar) * p - (uchar) * q; + 1bd: 0f b6 19 movzbl (%ecx),%ebx + 1c0: 31 c0 xor %eax,%eax + 1c2: eb db jmp 19f + 1c4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1cb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1cf: 90 nop + +000001d0 : + +uint strlen(const char *s) { + 1d0: 55 push %ebp + 1d1: 89 e5 mov %esp,%ebp + 1d3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 1d6: 80 3a 00 cmpb $0x0,(%edx) + 1d9: 74 15 je 1f0 + 1db: 31 c0 xor %eax,%eax + 1dd: 8d 76 00 lea 0x0(%esi),%esi + 1e0: 83 c0 01 add $0x1,%eax + 1e3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 1e7: 89 c1 mov %eax,%ecx + 1e9: 75 f5 jne 1e0 + ; + } + return n; +} + 1eb: 89 c8 mov %ecx,%eax + 1ed: 5d pop %ebp + 1ee: c3 ret + 1ef: 90 nop + for (n = 0; s[n]; n++) { + 1f0: 31 c9 xor %ecx,%ecx +} + 1f2: 5d pop %ebp + 1f3: 89 c8 mov %ecx,%eax + 1f5: c3 ret + 1f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1fd: 8d 76 00 lea 0x0(%esi),%esi + +00000200 : + +void* memset(void *dst, int c, uint n) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 57 push %edi + 204: 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" : + 207: 8b 4d 10 mov 0x10(%ebp),%ecx + 20a: 8b 45 0c mov 0xc(%ebp),%eax + 20d: 89 d7 mov %edx,%edi + 20f: fc cld + 210: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 212: 8b 7d fc mov -0x4(%ebp),%edi + 215: 89 d0 mov %edx,%eax + 217: c9 leave + 218: c3 ret + 219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000220 : + +char* strchr(const char *s, char c) { + 220: 55 push %ebp + 221: 89 e5 mov %esp,%ebp + 223: 8b 45 08 mov 0x8(%ebp),%eax + 226: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 22a: 0f b6 10 movzbl (%eax),%edx + 22d: 84 d2 test %dl,%dl + 22f: 75 12 jne 243 + 231: eb 1d jmp 250 + 233: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 237: 90 nop + 238: 0f b6 50 01 movzbl 0x1(%eax),%edx + 23c: 83 c0 01 add $0x1,%eax + 23f: 84 d2 test %dl,%dl + 241: 74 0d je 250 + if (*s == c) { + 243: 38 d1 cmp %dl,%cl + 245: 75 f1 jne 238 + return (char*)s; + } + } + return 0; +} + 247: 5d pop %ebp + 248: c3 ret + 249: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 250: 31 c0 xor %eax,%eax +} + 252: 5d pop %ebp + 253: c3 ret + 254: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 25f: 90 nop + +00000260 : + +char* gets(char *buf, int max) { + 260: 55 push %ebp + 261: 89 e5 mov %esp,%ebp + 263: 57 push %edi + 264: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 265: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 268: 53 push %ebx + for (i = 0; i + 1 < max;) { + 269: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 26b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 26e: eb 27 jmp 297 + cc = read(0, &c, 1); + 270: 83 ec 04 sub $0x4,%esp + 273: 6a 01 push $0x1 + 275: 57 push %edi + 276: 6a 00 push $0x0 + 278: e8 2e 01 00 00 call 3ab + if (cc < 1) { + 27d: 83 c4 10 add $0x10,%esp + 280: 85 c0 test %eax,%eax + 282: 7e 1d jle 2a1 + break; + } + buf[i++] = c; + 284: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 288: 8b 55 08 mov 0x8(%ebp),%edx + 28b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 28f: 3c 0a cmp $0xa,%al + 291: 74 1d je 2b0 + 293: 3c 0d cmp $0xd,%al + 295: 74 19 je 2b0 + for (i = 0; i + 1 < max;) { + 297: 89 de mov %ebx,%esi + 299: 83 c3 01 add $0x1,%ebx + 29c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 29f: 7c cf jl 270 + break; + } + } + buf[i] = '\0'; + 2a1: 8b 45 08 mov 0x8(%ebp),%eax + 2a4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 2a8: 8d 65 f4 lea -0xc(%ebp),%esp + 2ab: 5b pop %ebx + 2ac: 5e pop %esi + 2ad: 5f pop %edi + 2ae: 5d pop %ebp + 2af: c3 ret + buf[i] = '\0'; + 2b0: 8b 45 08 mov 0x8(%ebp),%eax + 2b3: 89 de mov %ebx,%esi + 2b5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 2b9: 8d 65 f4 lea -0xc(%ebp),%esp + 2bc: 5b pop %ebx + 2bd: 5e pop %esi + 2be: 5f pop %edi + 2bf: 5d pop %ebp + 2c0: c3 ret + 2c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2cf: 90 nop + +000002d0 : + +int stat(const char *n, struct stat *st) { + 2d0: 55 push %ebp + 2d1: 89 e5 mov %esp,%ebp + 2d3: 56 push %esi + 2d4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 2d5: 83 ec 08 sub $0x8,%esp + 2d8: 6a 00 push $0x0 + 2da: ff 75 08 push 0x8(%ebp) + 2dd: e8 19 01 00 00 call 3fb + if (fd < 0) { + 2e2: 83 c4 10 add $0x10,%esp + 2e5: 85 c0 test %eax,%eax + 2e7: 78 27 js 310 + return -1; + } + r = fstat(fd, st); + 2e9: 83 ec 08 sub $0x8,%esp + 2ec: ff 75 0c push 0xc(%ebp) + 2ef: 89 c3 mov %eax,%ebx + 2f1: 50 push %eax + 2f2: e8 cc 00 00 00 call 3c3 + close(fd); + 2f7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 2fa: 89 c6 mov %eax,%esi + close(fd); + 2fc: e8 2a 01 00 00 call 42b + return r; + 301: 83 c4 10 add $0x10,%esp +} + 304: 8d 65 f8 lea -0x8(%ebp),%esp + 307: 89 f0 mov %esi,%eax + 309: 5b pop %ebx + 30a: 5e pop %esi + 30b: 5d pop %ebp + 30c: c3 ret + 30d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 310: be ff ff ff ff mov $0xffffffff,%esi + 315: eb ed jmp 304 + 317: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 31e: 66 90 xchg %ax,%ax + +00000320 : + +int atoi(const char *s) { + 320: 55 push %ebp + 321: 89 e5 mov %esp,%ebp + 323: 53 push %ebx + 324: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 327: 0f be 02 movsbl (%edx),%eax + 32a: 8d 48 d0 lea -0x30(%eax),%ecx + 32d: 80 f9 09 cmp $0x9,%cl + n = 0; + 330: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 335: 77 1e ja 355 + 337: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 33e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 340: 83 c2 01 add $0x1,%edx + 343: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 346: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 34a: 0f be 02 movsbl (%edx),%eax + 34d: 8d 58 d0 lea -0x30(%eax),%ebx + 350: 80 fb 09 cmp $0x9,%bl + 353: 76 eb jbe 340 + } + return n; +} + 355: 8b 5d fc mov -0x4(%ebp),%ebx + 358: 89 c8 mov %ecx,%eax + 35a: c9 leave + 35b: c3 ret + 35c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000360 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 360: 55 push %ebp + 361: 89 e5 mov %esp,%ebp + 363: 57 push %edi + 364: 8b 45 10 mov 0x10(%ebp),%eax + 367: 8b 55 08 mov 0x8(%ebp),%edx + 36a: 56 push %esi + 36b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 36e: 85 c0 test %eax,%eax + 370: 7e 13 jle 385 + 372: 01 d0 add %edx,%eax + dst = vdst; + 374: 89 d7 mov %edx,%edi + 376: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 37d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 380: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 381: 39 f8 cmp %edi,%eax + 383: 75 fb jne 380 + } + return vdst; +} + 385: 5e pop %esi + 386: 89 d0 mov %edx,%eax + 388: 5f pop %edi + 389: 5d pop %ebp + 38a: c3 ret + +0000038b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 38b: b8 01 00 00 00 mov $0x1,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(exit) + 393: b8 02 00 00 00 mov $0x2,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + +0000039b : +SYSCALL(wait) + 39b: b8 03 00 00 00 mov $0x3,%eax + 3a0: cd 40 int $0x40 + 3a2: c3 ret + +000003a3 : +SYSCALL(pipe) + 3a3: b8 04 00 00 00 mov $0x4,%eax + 3a8: cd 40 int $0x40 + 3aa: c3 ret + +000003ab : +SYSCALL(read) + 3ab: b8 05 00 00 00 mov $0x5,%eax + 3b0: cd 40 int $0x40 + 3b2: c3 ret + +000003b3 : +SYSCALL(kill) + 3b3: b8 06 00 00 00 mov $0x6,%eax + 3b8: cd 40 int $0x40 + 3ba: c3 ret + +000003bb : +SYSCALL(exec) + 3bb: b8 07 00 00 00 mov $0x7,%eax + 3c0: cd 40 int $0x40 + 3c2: c3 ret + +000003c3 : +SYSCALL(fstat) + 3c3: b8 08 00 00 00 mov $0x8,%eax + 3c8: cd 40 int $0x40 + 3ca: c3 ret + +000003cb : +SYSCALL(chdir) + 3cb: b8 09 00 00 00 mov $0x9,%eax + 3d0: cd 40 int $0x40 + 3d2: c3 ret + +000003d3 : +SYSCALL(dup) + 3d3: b8 0a 00 00 00 mov $0xa,%eax + 3d8: cd 40 int $0x40 + 3da: c3 ret + +000003db : +SYSCALL(getpid) + 3db: b8 0b 00 00 00 mov $0xb,%eax + 3e0: cd 40 int $0x40 + 3e2: c3 ret + +000003e3 : +SYSCALL(sbrk) + 3e3: b8 0c 00 00 00 mov $0xc,%eax + 3e8: cd 40 int $0x40 + 3ea: c3 ret + +000003eb : +SYSCALL(sleep) + 3eb: b8 0d 00 00 00 mov $0xd,%eax + 3f0: cd 40 int $0x40 + 3f2: c3 ret + +000003f3 : +SYSCALL(uptime) + 3f3: b8 0e 00 00 00 mov $0xe,%eax + 3f8: cd 40 int $0x40 + 3fa: c3 ret + +000003fb : +SYSCALL(open) + 3fb: b8 0f 00 00 00 mov $0xf,%eax + 400: cd 40 int $0x40 + 402: c3 ret + +00000403 : +SYSCALL(write) + 403: b8 10 00 00 00 mov $0x10,%eax + 408: cd 40 int $0x40 + 40a: c3 ret + +0000040b : +SYSCALL(mknod) + 40b: b8 11 00 00 00 mov $0x11,%eax + 410: cd 40 int $0x40 + 412: c3 ret + +00000413 : +SYSCALL(unlink) + 413: b8 12 00 00 00 mov $0x12,%eax + 418: cd 40 int $0x40 + 41a: c3 ret + +0000041b : +SYSCALL(link) + 41b: b8 13 00 00 00 mov $0x13,%eax + 420: cd 40 int $0x40 + 422: c3 ret + +00000423 : +SYSCALL(mkdir) + 423: b8 14 00 00 00 mov $0x14,%eax + 428: cd 40 int $0x40 + 42a: c3 ret + +0000042b : +SYSCALL(close) + 42b: b8 15 00 00 00 mov $0x15,%eax + 430: cd 40 int $0x40 + 432: c3 ret + +00000433 : +SYSCALL(getch) + 433: b8 16 00 00 00 mov $0x16,%eax + 438: cd 40 int $0x40 + 43a: c3 ret + +0000043b : +SYSCALL(greeting) + 43b: b8 17 00 00 00 mov $0x17,%eax + 440: cd 40 int $0x40 + 442: c3 ret + +00000443 : +SYSCALL(shutdown) + 443: b8 18 00 00 00 mov $0x18,%eax + 448: cd 40 int $0x40 + 44a: c3 ret + +0000044b : +SYSCALL(screen) + 44b: b8 19 00 00 00 mov $0x19,%eax + 450: cd 40 int $0x40 + 452: c3 ret + +00000453 : +SYSCALL(cls) + 453: b8 1a 00 00 00 mov $0x1a,%eax + 458: cd 40 int $0x40 + 45a: c3 ret + 45b: 66 90 xchg %ax,%ax + 45d: 66 90 xchg %ax,%ax + 45f: 90 nop + +00000460 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 460: 55 push %ebp + 461: 89 e5 mov %esp,%ebp + 463: 57 push %edi + 464: 56 push %esi + 465: 53 push %ebx + 466: 83 ec 3c sub $0x3c,%esp + 469: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 46c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 46e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 471: 85 d2 test %edx,%edx + 473: 0f 89 7f 00 00 00 jns 4f8 + 479: f6 45 08 01 testb $0x1,0x8(%ebp) + 47d: 74 79 je 4f8 + neg = 1; + 47f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 486: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 488: 31 db xor %ebx,%ebx + 48a: 8d 75 d7 lea -0x29(%ebp),%esi + 48d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 490: 89 c8 mov %ecx,%eax + 492: 31 d2 xor %edx,%edx + 494: 89 cf mov %ecx,%edi + 496: f7 75 c4 divl -0x3c(%ebp) + 499: 0f b6 92 28 09 00 00 movzbl 0x928(%edx),%edx + 4a0: 89 45 c0 mov %eax,-0x40(%ebp) + 4a3: 89 d8 mov %ebx,%eax + 4a5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 4a8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 4ab: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 4ae: 39 7d c4 cmp %edi,-0x3c(%ebp) + 4b1: 76 dd jbe 490 + if (neg) { + 4b3: 8b 4d bc mov -0x44(%ebp),%ecx + 4b6: 85 c9 test %ecx,%ecx + 4b8: 74 0c je 4c6 + buf[i++] = '-'; + 4ba: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 4bf: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 4c1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 4c6: 8b 7d b8 mov -0x48(%ebp),%edi + 4c9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 4cd: eb 07 jmp 4d6 + 4cf: 90 nop + putc(fd, buf[i]); + 4d0: 0f b6 13 movzbl (%ebx),%edx + 4d3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 4d6: 83 ec 04 sub $0x4,%esp + 4d9: 88 55 d7 mov %dl,-0x29(%ebp) + 4dc: 6a 01 push $0x1 + 4de: 56 push %esi + 4df: 57 push %edi + 4e0: e8 1e ff ff ff call 403 + while (--i >= 0) { + 4e5: 83 c4 10 add $0x10,%esp + 4e8: 39 de cmp %ebx,%esi + 4ea: 75 e4 jne 4d0 + } +} + 4ec: 8d 65 f4 lea -0xc(%ebp),%esp + 4ef: 5b pop %ebx + 4f0: 5e pop %esi + 4f1: 5f pop %edi + 4f2: 5d pop %ebp + 4f3: c3 ret + 4f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 4f8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 4ff: eb 87 jmp 488 + 501: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 508: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 50f: 90 nop + +00000510 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 510: 55 push %ebp + 511: 89 e5 mov %esp,%ebp + 513: 57 push %edi + 514: 56 push %esi + 515: 53 push %ebx + 516: 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++) { + 519: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 51c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 51f: 0f b6 13 movzbl (%ebx),%edx + 522: 84 d2 test %dl,%dl + 524: 74 6a je 590 + ap = (uint*)(void*)&fmt + 1; + 526: 8d 45 10 lea 0x10(%ebp),%eax + 529: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 52c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 52f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 531: 89 45 d0 mov %eax,-0x30(%ebp) + 534: eb 36 jmp 56c + 536: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 53d: 8d 76 00 lea 0x0(%esi),%esi + 540: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 543: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 548: 83 f8 25 cmp $0x25,%eax + 54b: 74 15 je 562 + write(fd, &c, 1); + 54d: 83 ec 04 sub $0x4,%esp + 550: 88 55 e7 mov %dl,-0x19(%ebp) + 553: 6a 01 push $0x1 + 555: 57 push %edi + 556: 56 push %esi + 557: e8 a7 fe ff ff call 403 + 55c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 55f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 562: 0f b6 13 movzbl (%ebx),%edx + 565: 83 c3 01 add $0x1,%ebx + 568: 84 d2 test %dl,%dl + 56a: 74 24 je 590 + c = fmt[i] & 0xff; + 56c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 56f: 85 c9 test %ecx,%ecx + 571: 74 cd je 540 + } + } + else if (state == '%') { + 573: 83 f9 25 cmp $0x25,%ecx + 576: 75 ea jne 562 + if (c == 'd') { + 578: 83 f8 25 cmp $0x25,%eax + 57b: 0f 84 07 01 00 00 je 688 + 581: 83 e8 63 sub $0x63,%eax + 584: 83 f8 15 cmp $0x15,%eax + 587: 77 17 ja 5a0 + 589: ff 24 85 d0 08 00 00 jmp *0x8d0(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 590: 8d 65 f4 lea -0xc(%ebp),%esp + 593: 5b pop %ebx + 594: 5e pop %esi + 595: 5f pop %edi + 596: 5d pop %ebp + 597: c3 ret + 598: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 59f: 90 nop + write(fd, &c, 1); + 5a0: 83 ec 04 sub $0x4,%esp + 5a3: 88 55 d4 mov %dl,-0x2c(%ebp) + 5a6: 6a 01 push $0x1 + 5a8: 57 push %edi + 5a9: 56 push %esi + 5aa: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 5ae: e8 50 fe ff ff call 403 + putc(fd, c); + 5b3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 5b7: 83 c4 0c add $0xc,%esp + 5ba: 88 55 e7 mov %dl,-0x19(%ebp) + 5bd: 6a 01 push $0x1 + 5bf: 57 push %edi + 5c0: 56 push %esi + 5c1: e8 3d fe ff ff call 403 + putc(fd, c); + 5c6: 83 c4 10 add $0x10,%esp + state = 0; + 5c9: 31 c9 xor %ecx,%ecx + 5cb: eb 95 jmp 562 + 5cd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 5d0: 83 ec 0c sub $0xc,%esp + 5d3: b9 10 00 00 00 mov $0x10,%ecx + 5d8: 6a 00 push $0x0 + 5da: 8b 45 d0 mov -0x30(%ebp),%eax + 5dd: 8b 10 mov (%eax),%edx + 5df: 89 f0 mov %esi,%eax + 5e1: e8 7a fe ff ff call 460 + ap++; + 5e6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5ea: 83 c4 10 add $0x10,%esp + state = 0; + 5ed: 31 c9 xor %ecx,%ecx + 5ef: e9 6e ff ff ff jmp 562 + 5f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 5f8: 8b 45 d0 mov -0x30(%ebp),%eax + 5fb: 8b 10 mov (%eax),%edx + ap++; + 5fd: 83 c0 04 add $0x4,%eax + 600: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 603: 85 d2 test %edx,%edx + 605: 0f 84 8d 00 00 00 je 698 + while (*s != 0) { + 60b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 60e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 610: 84 c0 test %al,%al + 612: 0f 84 4a ff ff ff je 562 + 618: 89 5d d4 mov %ebx,-0x2c(%ebp) + 61b: 89 d3 mov %edx,%ebx + 61d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 620: 83 ec 04 sub $0x4,%esp + s++; + 623: 83 c3 01 add $0x1,%ebx + 626: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 629: 6a 01 push $0x1 + 62b: 57 push %edi + 62c: 56 push %esi + 62d: e8 d1 fd ff ff call 403 + while (*s != 0) { + 632: 0f b6 03 movzbl (%ebx),%eax + 635: 83 c4 10 add $0x10,%esp + 638: 84 c0 test %al,%al + 63a: 75 e4 jne 620 + state = 0; + 63c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 63f: 31 c9 xor %ecx,%ecx + 641: e9 1c ff ff ff jmp 562 + 646: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 64d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 650: 83 ec 0c sub $0xc,%esp + 653: b9 0a 00 00 00 mov $0xa,%ecx + 658: 6a 01 push $0x1 + 65a: e9 7b ff ff ff jmp 5da + 65f: 90 nop + putc(fd, *ap); + 660: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 663: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 666: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 668: 6a 01 push $0x1 + 66a: 57 push %edi + 66b: 56 push %esi + putc(fd, *ap); + 66c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 66f: e8 8f fd ff ff call 403 + ap++; + 674: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 678: 83 c4 10 add $0x10,%esp + state = 0; + 67b: 31 c9 xor %ecx,%ecx + 67d: e9 e0 fe ff ff jmp 562 + 682: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 688: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 68b: 83 ec 04 sub $0x4,%esp + 68e: e9 2a ff ff ff jmp 5bd + 693: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 697: 90 nop + s = "(null)"; + 698: ba c9 08 00 00 mov $0x8c9,%edx + while (*s != 0) { + 69d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 6a0: b8 28 00 00 00 mov $0x28,%eax + 6a5: 89 d3 mov %edx,%ebx + 6a7: e9 74 ff ff ff jmp 620 + 6ac: 66 90 xchg %ax,%ax + 6ae: 66 90 xchg %ax,%ax + +000006b0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 6b0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 6b1: a1 dc 0b 00 00 mov 0xbdc,%eax +void free(void *ap) { + 6b6: 89 e5 mov %esp,%ebp + 6b8: 57 push %edi + 6b9: 56 push %esi + 6ba: 53 push %ebx + 6bb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 6be: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 6c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 6c8: 89 c2 mov %eax,%edx + 6ca: 8b 00 mov (%eax),%eax + 6cc: 39 ca cmp %ecx,%edx + 6ce: 73 30 jae 700 + 6d0: 39 c1 cmp %eax,%ecx + 6d2: 72 04 jb 6d8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 6d4: 39 c2 cmp %eax,%edx + 6d6: 72 f0 jb 6c8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 6d8: 8b 73 fc mov -0x4(%ebx),%esi + 6db: 8d 3c f1 lea (%ecx,%esi,8),%edi + 6de: 39 f8 cmp %edi,%eax + 6e0: 74 30 je 712 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 6e2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 6e5: 8b 42 04 mov 0x4(%edx),%eax + 6e8: 8d 34 c2 lea (%edx,%eax,8),%esi + 6eb: 39 f1 cmp %esi,%ecx + 6ed: 74 3a je 729 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 6ef: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 6f1: 5b pop %ebx + freep = p; + 6f2: 89 15 dc 0b 00 00 mov %edx,0xbdc +} + 6f8: 5e pop %esi + 6f9: 5f pop %edi + 6fa: 5d pop %ebp + 6fb: c3 ret + 6fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 700: 39 c2 cmp %eax,%edx + 702: 72 c4 jb 6c8 + 704: 39 c1 cmp %eax,%ecx + 706: 73 c0 jae 6c8 + if (bp + bp->s.size == p->s.ptr) { + 708: 8b 73 fc mov -0x4(%ebx),%esi + 70b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 70e: 39 f8 cmp %edi,%eax + 710: 75 d0 jne 6e2 + bp->s.size += p->s.ptr->s.size; + 712: 03 70 04 add 0x4(%eax),%esi + 715: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 718: 8b 02 mov (%edx),%eax + 71a: 8b 00 mov (%eax),%eax + 71c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 71f: 8b 42 04 mov 0x4(%edx),%eax + 722: 8d 34 c2 lea (%edx,%eax,8),%esi + 725: 39 f1 cmp %esi,%ecx + 727: 75 c6 jne 6ef + p->s.size += bp->s.size; + 729: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 72c: 89 15 dc 0b 00 00 mov %edx,0xbdc + p->s.size += bp->s.size; + 732: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 735: 8b 4b f8 mov -0x8(%ebx),%ecx + 738: 89 0a mov %ecx,(%edx) +} + 73a: 5b pop %ebx + 73b: 5e pop %esi + 73c: 5f pop %edi + 73d: 5d pop %ebp + 73e: c3 ret + 73f: 90 nop + +00000740 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 740: 55 push %ebp + 741: 89 e5 mov %esp,%ebp + 743: 57 push %edi + 744: 56 push %esi + 745: 53 push %ebx + 746: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 749: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 74c: 8b 3d dc 0b 00 00 mov 0xbdc,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 752: 8d 70 07 lea 0x7(%eax),%esi + 755: c1 ee 03 shr $0x3,%esi + 758: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 75b: 85 ff test %edi,%edi + 75d: 0f 84 9d 00 00 00 je 800 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 763: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 765: 8b 4a 04 mov 0x4(%edx),%ecx + 768: 39 f1 cmp %esi,%ecx + 76a: 73 6a jae 7d6 + 76c: bb 00 10 00 00 mov $0x1000,%ebx + 771: 39 de cmp %ebx,%esi + 773: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 776: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 77d: 89 45 e4 mov %eax,-0x1c(%ebp) + 780: eb 17 jmp 799 + 782: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 788: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 78a: 8b 48 04 mov 0x4(%eax),%ecx + 78d: 39 f1 cmp %esi,%ecx + 78f: 73 4f jae 7e0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 791: 8b 3d dc 0b 00 00 mov 0xbdc,%edi + 797: 89 c2 mov %eax,%edx + 799: 39 d7 cmp %edx,%edi + 79b: 75 eb jne 788 + p = sbrk(nu * sizeof(Header)); + 79d: 83 ec 0c sub $0xc,%esp + 7a0: ff 75 e4 push -0x1c(%ebp) + 7a3: e8 3b fc ff ff call 3e3 + if (p == (char*)-1) { + 7a8: 83 c4 10 add $0x10,%esp + 7ab: 83 f8 ff cmp $0xffffffff,%eax + 7ae: 74 1c je 7cc + hp->s.size = nu; + 7b0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 7b3: 83 ec 0c sub $0xc,%esp + 7b6: 83 c0 08 add $0x8,%eax + 7b9: 50 push %eax + 7ba: e8 f1 fe ff ff call 6b0 + return freep; + 7bf: 8b 15 dc 0b 00 00 mov 0xbdc,%edx + if ((p = morecore(nunits)) == 0) { + 7c5: 83 c4 10 add $0x10,%esp + 7c8: 85 d2 test %edx,%edx + 7ca: 75 bc jne 788 + return 0; + } + } + } +} + 7cc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 7cf: 31 c0 xor %eax,%eax +} + 7d1: 5b pop %ebx + 7d2: 5e pop %esi + 7d3: 5f pop %edi + 7d4: 5d pop %ebp + 7d5: c3 ret + if (p->s.size >= nunits) { + 7d6: 89 d0 mov %edx,%eax + 7d8: 89 fa mov %edi,%edx + 7da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 7e0: 39 ce cmp %ecx,%esi + 7e2: 74 4c je 830 + p->s.size -= nunits; + 7e4: 29 f1 sub %esi,%ecx + 7e6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 7e9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 7ec: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 7ef: 89 15 dc 0b 00 00 mov %edx,0xbdc +} + 7f5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 7f8: 83 c0 08 add $0x8,%eax +} + 7fb: 5b pop %ebx + 7fc: 5e pop %esi + 7fd: 5f pop %edi + 7fe: 5d pop %ebp + 7ff: c3 ret + base.s.ptr = freep = prevp = &base; + 800: c7 05 dc 0b 00 00 e0 movl $0xbe0,0xbdc + 807: 0b 00 00 + base.s.size = 0; + 80a: bf e0 0b 00 00 mov $0xbe0,%edi + base.s.ptr = freep = prevp = &base; + 80f: c7 05 e0 0b 00 00 e0 movl $0xbe0,0xbe0 + 816: 0b 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 819: 89 fa mov %edi,%edx + base.s.size = 0; + 81b: c7 05 e4 0b 00 00 00 movl $0x0,0xbe4 + 822: 00 00 00 + if (p->s.size >= nunits) { + 825: e9 42 ff ff ff jmp 76c + 82a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 830: 8b 08 mov (%eax),%ecx + 832: 89 0a mov %ecx,(%edx) + 834: eb b9 jmp 7ef diff --git a/count.d b/count.d new file mode 100644 index 0000000..c289379 --- /dev/null +++ b/count.d @@ -0,0 +1 @@ +count.o: count.c /usr/include/stdc-predef.h types.h user.h diff --git a/count.o b/count.o new file mode 100644 index 0000000..d00400c Binary files /dev/null and b/count.o differ diff --git a/count.sym b/count.sym new file mode 100644 index 0000000..679e546 --- /dev/null +++ b/count.sym @@ -0,0 +1,50 @@ +00000000 count.c +00000000 ulib.c +00000000 printf.c +00000460 printint +00000928 digits.0 +00000000 umalloc.c +00000bdc freep +00000be0 base +00000140 strcpy +00000510 printf +0000043b greeting +00000360 memmove +0000040b mknod +00000260 gets +000003db getpid +0000044b screen +00000740 malloc +000003eb sleep +000003a3 pipe +00000433 getch +00000403 write +000003c3 fstat +000003b3 kill +000003cb chdir +000003bb exec +0000039b wait +000003ab read +00000413 unlink +0000038b fork +000003e3 sbrk +000003f3 uptime +00000bdc __bss_start +00000200 memset +00000000 main +00000170 strcmp +00000443 shutdown +000003d3 dup +000002d0 stat +00000bdc _edata +00000be8 _end +0000041b link +00000393 exit +00000320 atoi +00000453 cls +000001d0 strlen +000003fb open +00000220 strchr +00000423 mkdir +0000042b close +000006b0 free diff --git a/echo.asm b/echo.asm new file mode 100644 index 0000000..2ed5d9c --- /dev/null +++ b/echo.asm @@ -0,0 +1,1181 @@ + +_echo: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "stat.h" +#include "user.h" + +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: 51 push %ecx + 11: 83 ec 08 sub $0x8,%esp + 14: 8b 31 mov (%ecx),%esi + 16: 8b 79 04 mov 0x4(%ecx),%edi + int i; + + for (i = 1; i < argc; i++) { + 19: 83 fe 01 cmp $0x1,%esi + 1c: 7e 47 jle 65 + 1e: bb 01 00 00 00 mov $0x1,%ebx + printf(1, "%s%s", argv[i], i + 1 < argc ? " " : "\n"); + 23: 83 c3 01 add $0x1,%ebx + 26: 8b 44 9f fc mov -0x4(%edi,%ebx,4),%eax + 2a: 39 f3 cmp %esi,%ebx + 2c: 74 22 je 50 + 2e: 66 90 xchg %ax,%ax + 30: 68 68 07 00 00 push $0x768 + 35: 83 c3 01 add $0x1,%ebx + 38: 50 push %eax + 39: 68 6a 07 00 00 push $0x76a + 3e: 6a 01 push $0x1 + 40: e8 fb 03 00 00 call 440 + 45: 8b 44 9f fc mov -0x4(%edi,%ebx,4),%eax + 49: 83 c4 10 add $0x10,%esp + 4c: 39 f3 cmp %esi,%ebx + 4e: 75 e0 jne 30 + 50: 68 6f 07 00 00 push $0x76f + 55: 50 push %eax + 56: 68 6a 07 00 00 push $0x76a + 5b: 6a 01 push $0x1 + 5d: e8 de 03 00 00 call 440 + 62: 83 c4 10 add $0x10,%esp + } + exit(); + 65: e8 59 02 00 00 call 2c3 + 6a: 66 90 xchg %ax,%ax + 6c: 66 90 xchg %ax,%ax + 6e: 66 90 xchg %ax,%ax + +00000070 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 70: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 71: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 73: 89 e5 mov %esp,%ebp + 75: 53 push %ebx + 76: 8b 4d 08 mov 0x8(%ebp),%ecx + 79: 8b 5d 0c mov 0xc(%ebp),%ebx + 7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 80: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 84: 88 14 01 mov %dl,(%ecx,%eax,1) + 87: 83 c0 01 add $0x1,%eax + 8a: 84 d2 test %dl,%dl + 8c: 75 f2 jne 80 + ; + } + return os; +} + 8e: 8b 5d fc mov -0x4(%ebp),%ebx + 91: 89 c8 mov %ecx,%eax + 93: c9 leave + 94: c3 ret + 95: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000000a0 : + +int strcmp(const char *p, const char *q) { + a0: 55 push %ebp + a1: 89 e5 mov %esp,%ebp + a3: 53 push %ebx + a4: 8b 55 08 mov 0x8(%ebp),%edx + a7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + aa: 0f b6 02 movzbl (%edx),%eax + ad: 84 c0 test %al,%al + af: 75 17 jne c8 + b1: eb 3a jmp ed + b3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + b7: 90 nop + b8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + bc: 83 c2 01 add $0x1,%edx + bf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + c2: 84 c0 test %al,%al + c4: 74 1a je e0 + p++, q++; + c6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + c8: 0f b6 19 movzbl (%ecx),%ebx + cb: 38 c3 cmp %al,%bl + cd: 74 e9 je b8 + } + return (uchar) * p - (uchar) * q; + cf: 29 d8 sub %ebx,%eax +} + d1: 8b 5d fc mov -0x4(%ebp),%ebx + d4: c9 leave + d5: c3 ret + d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + dd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + e0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + e4: 31 c0 xor %eax,%eax + e6: 29 d8 sub %ebx,%eax +} + e8: 8b 5d fc mov -0x4(%ebp),%ebx + eb: c9 leave + ec: c3 ret + return (uchar) * p - (uchar) * q; + ed: 0f b6 19 movzbl (%ecx),%ebx + f0: 31 c0 xor %eax,%eax + f2: eb db jmp cf + f4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ff: 90 nop + +00000100 : + +uint strlen(const char *s) { + 100: 55 push %ebp + 101: 89 e5 mov %esp,%ebp + 103: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 106: 80 3a 00 cmpb $0x0,(%edx) + 109: 74 15 je 120 + 10b: 31 c0 xor %eax,%eax + 10d: 8d 76 00 lea 0x0(%esi),%esi + 110: 83 c0 01 add $0x1,%eax + 113: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 117: 89 c1 mov %eax,%ecx + 119: 75 f5 jne 110 + ; + } + return n; +} + 11b: 89 c8 mov %ecx,%eax + 11d: 5d pop %ebp + 11e: c3 ret + 11f: 90 nop + for (n = 0; s[n]; n++) { + 120: 31 c9 xor %ecx,%ecx +} + 122: 5d pop %ebp + 123: 89 c8 mov %ecx,%eax + 125: c3 ret + 126: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 12d: 8d 76 00 lea 0x0(%esi),%esi + +00000130 : + +void* memset(void *dst, int c, uint n) { + 130: 55 push %ebp + 131: 89 e5 mov %esp,%ebp + 133: 57 push %edi + 134: 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" : + 137: 8b 4d 10 mov 0x10(%ebp),%ecx + 13a: 8b 45 0c mov 0xc(%ebp),%eax + 13d: 89 d7 mov %edx,%edi + 13f: fc cld + 140: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 142: 8b 7d fc mov -0x4(%ebp),%edi + 145: 89 d0 mov %edx,%eax + 147: c9 leave + 148: c3 ret + 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000150 : + +char* strchr(const char *s, char c) { + 150: 55 push %ebp + 151: 89 e5 mov %esp,%ebp + 153: 8b 45 08 mov 0x8(%ebp),%eax + 156: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 15a: 0f b6 10 movzbl (%eax),%edx + 15d: 84 d2 test %dl,%dl + 15f: 75 12 jne 173 + 161: eb 1d jmp 180 + 163: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 167: 90 nop + 168: 0f b6 50 01 movzbl 0x1(%eax),%edx + 16c: 83 c0 01 add $0x1,%eax + 16f: 84 d2 test %dl,%dl + 171: 74 0d je 180 + if (*s == c) { + 173: 38 d1 cmp %dl,%cl + 175: 75 f1 jne 168 + return (char*)s; + } + } + return 0; +} + 177: 5d pop %ebp + 178: c3 ret + 179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 180: 31 c0 xor %eax,%eax +} + 182: 5d pop %ebp + 183: c3 ret + 184: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 18b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 18f: 90 nop + +00000190 : + +char* gets(char *buf, int max) { + 190: 55 push %ebp + 191: 89 e5 mov %esp,%ebp + 193: 57 push %edi + 194: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 195: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 198: 53 push %ebx + for (i = 0; i + 1 < max;) { + 199: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 19b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 19e: eb 27 jmp 1c7 + cc = read(0, &c, 1); + 1a0: 83 ec 04 sub $0x4,%esp + 1a3: 6a 01 push $0x1 + 1a5: 57 push %edi + 1a6: 6a 00 push $0x0 + 1a8: e8 2e 01 00 00 call 2db + if (cc < 1) { + 1ad: 83 c4 10 add $0x10,%esp + 1b0: 85 c0 test %eax,%eax + 1b2: 7e 1d jle 1d1 + break; + } + buf[i++] = c; + 1b4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1b8: 8b 55 08 mov 0x8(%ebp),%edx + 1bb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1bf: 3c 0a cmp $0xa,%al + 1c1: 74 1d je 1e0 + 1c3: 3c 0d cmp $0xd,%al + 1c5: 74 19 je 1e0 + for (i = 0; i + 1 < max;) { + 1c7: 89 de mov %ebx,%esi + 1c9: 83 c3 01 add $0x1,%ebx + 1cc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1cf: 7c cf jl 1a0 + break; + } + } + buf[i] = '\0'; + 1d1: 8b 45 08 mov 0x8(%ebp),%eax + 1d4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1d8: 8d 65 f4 lea -0xc(%ebp),%esp + 1db: 5b pop %ebx + 1dc: 5e pop %esi + 1dd: 5f pop %edi + 1de: 5d pop %ebp + 1df: c3 ret + buf[i] = '\0'; + 1e0: 8b 45 08 mov 0x8(%ebp),%eax + 1e3: 89 de mov %ebx,%esi + 1e5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1e9: 8d 65 f4 lea -0xc(%ebp),%esp + 1ec: 5b pop %ebx + 1ed: 5e pop %esi + 1ee: 5f pop %edi + 1ef: 5d pop %ebp + 1f0: c3 ret + 1f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ff: 90 nop + +00000200 : + +int stat(const char *n, struct stat *st) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 56 push %esi + 204: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 205: 83 ec 08 sub $0x8,%esp + 208: 6a 00 push $0x0 + 20a: ff 75 08 push 0x8(%ebp) + 20d: e8 19 01 00 00 call 32b + if (fd < 0) { + 212: 83 c4 10 add $0x10,%esp + 215: 85 c0 test %eax,%eax + 217: 78 27 js 240 + return -1; + } + r = fstat(fd, st); + 219: 83 ec 08 sub $0x8,%esp + 21c: ff 75 0c push 0xc(%ebp) + 21f: 89 c3 mov %eax,%ebx + 221: 50 push %eax + 222: e8 cc 00 00 00 call 2f3 + close(fd); + 227: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 22a: 89 c6 mov %eax,%esi + close(fd); + 22c: e8 2a 01 00 00 call 35b + return r; + 231: 83 c4 10 add $0x10,%esp +} + 234: 8d 65 f8 lea -0x8(%ebp),%esp + 237: 89 f0 mov %esi,%eax + 239: 5b pop %ebx + 23a: 5e pop %esi + 23b: 5d pop %ebp + 23c: c3 ret + 23d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 240: be ff ff ff ff mov $0xffffffff,%esi + 245: eb ed jmp 234 + 247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 24e: 66 90 xchg %ax,%ax + +00000250 : + +int atoi(const char *s) { + 250: 55 push %ebp + 251: 89 e5 mov %esp,%ebp + 253: 53 push %ebx + 254: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 257: 0f be 02 movsbl (%edx),%eax + 25a: 8d 48 d0 lea -0x30(%eax),%ecx + 25d: 80 f9 09 cmp $0x9,%cl + n = 0; + 260: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 265: 77 1e ja 285 + 267: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 270: 83 c2 01 add $0x1,%edx + 273: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 276: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 27a: 0f be 02 movsbl (%edx),%eax + 27d: 8d 58 d0 lea -0x30(%eax),%ebx + 280: 80 fb 09 cmp $0x9,%bl + 283: 76 eb jbe 270 + } + return n; +} + 285: 8b 5d fc mov -0x4(%ebp),%ebx + 288: 89 c8 mov %ecx,%eax + 28a: c9 leave + 28b: c3 ret + 28c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000290 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 290: 55 push %ebp + 291: 89 e5 mov %esp,%ebp + 293: 57 push %edi + 294: 8b 45 10 mov 0x10(%ebp),%eax + 297: 8b 55 08 mov 0x8(%ebp),%edx + 29a: 56 push %esi + 29b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 29e: 85 c0 test %eax,%eax + 2a0: 7e 13 jle 2b5 + 2a2: 01 d0 add %edx,%eax + dst = vdst; + 2a4: 89 d7 mov %edx,%edi + 2a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2ad: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2b0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2b1: 39 f8 cmp %edi,%eax + 2b3: 75 fb jne 2b0 + } + return vdst; +} + 2b5: 5e pop %esi + 2b6: 89 d0 mov %edx,%eax + 2b8: 5f pop %edi + 2b9: 5d pop %ebp + 2ba: c3 ret + +000002bb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2bb: b8 01 00 00 00 mov $0x1,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(exit) + 2c3: b8 02 00 00 00 mov $0x2,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(wait) + 2cb: b8 03 00 00 00 mov $0x3,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(pipe) + 2d3: b8 04 00 00 00 mov $0x4,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(read) + 2db: b8 05 00 00 00 mov $0x5,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(kill) + 2e3: b8 06 00 00 00 mov $0x6,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(exec) + 2eb: b8 07 00 00 00 mov $0x7,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(fstat) + 2f3: b8 08 00 00 00 mov $0x8,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(chdir) + 2fb: b8 09 00 00 00 mov $0x9,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(dup) + 303: b8 0a 00 00 00 mov $0xa,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(getpid) + 30b: b8 0b 00 00 00 mov $0xb,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(sbrk) + 313: b8 0c 00 00 00 mov $0xc,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(sleep) + 31b: b8 0d 00 00 00 mov $0xd,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(uptime) + 323: b8 0e 00 00 00 mov $0xe,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(open) + 32b: b8 0f 00 00 00 mov $0xf,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(write) + 333: b8 10 00 00 00 mov $0x10,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(mknod) + 33b: b8 11 00 00 00 mov $0x11,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(unlink) + 343: b8 12 00 00 00 mov $0x12,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(link) + 34b: b8 13 00 00 00 mov $0x13,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(mkdir) + 353: b8 14 00 00 00 mov $0x14,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(close) + 35b: b8 15 00 00 00 mov $0x15,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(getch) + 363: b8 16 00 00 00 mov $0x16,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(greeting) + 36b: b8 17 00 00 00 mov $0x17,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(shutdown) + 373: b8 18 00 00 00 mov $0x18,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(screen) + 37b: b8 19 00 00 00 mov $0x19,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(cls) + 383: b8 1a 00 00 00 mov $0x1a,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + 38b: 66 90 xchg %ax,%ax + 38d: 66 90 xchg %ax,%ax + 38f: 90 nop + +00000390 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 390: 55 push %ebp + 391: 89 e5 mov %esp,%ebp + 393: 57 push %edi + 394: 56 push %esi + 395: 53 push %ebx + 396: 83 ec 3c sub $0x3c,%esp + 399: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 39c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 39e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 3a1: 85 d2 test %edx,%edx + 3a3: 0f 89 7f 00 00 00 jns 428 + 3a9: f6 45 08 01 testb $0x1,0x8(%ebp) + 3ad: 74 79 je 428 + neg = 1; + 3af: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3b6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3b8: 31 db xor %ebx,%ebx + 3ba: 8d 75 d7 lea -0x29(%ebp),%esi + 3bd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3c0: 89 c8 mov %ecx,%eax + 3c2: 31 d2 xor %edx,%edx + 3c4: 89 cf mov %ecx,%edi + 3c6: f7 75 c4 divl -0x3c(%ebp) + 3c9: 0f b6 92 d0 07 00 00 movzbl 0x7d0(%edx),%edx + 3d0: 89 45 c0 mov %eax,-0x40(%ebp) + 3d3: 89 d8 mov %ebx,%eax + 3d5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3d8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3db: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3de: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3e1: 76 dd jbe 3c0 + if (neg) { + 3e3: 8b 4d bc mov -0x44(%ebp),%ecx + 3e6: 85 c9 test %ecx,%ecx + 3e8: 74 0c je 3f6 + buf[i++] = '-'; + 3ea: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3ef: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3f1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3f6: 8b 7d b8 mov -0x48(%ebp),%edi + 3f9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3fd: eb 07 jmp 406 + 3ff: 90 nop + putc(fd, buf[i]); + 400: 0f b6 13 movzbl (%ebx),%edx + 403: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 406: 83 ec 04 sub $0x4,%esp + 409: 88 55 d7 mov %dl,-0x29(%ebp) + 40c: 6a 01 push $0x1 + 40e: 56 push %esi + 40f: 57 push %edi + 410: e8 1e ff ff ff call 333 + while (--i >= 0) { + 415: 83 c4 10 add $0x10,%esp + 418: 39 de cmp %ebx,%esi + 41a: 75 e4 jne 400 + } +} + 41c: 8d 65 f4 lea -0xc(%ebp),%esp + 41f: 5b pop %ebx + 420: 5e pop %esi + 421: 5f pop %edi + 422: 5d pop %ebp + 423: c3 ret + 424: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 428: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 42f: eb 87 jmp 3b8 + 431: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 438: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 43f: 90 nop + +00000440 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 440: 55 push %ebp + 441: 89 e5 mov %esp,%ebp + 443: 57 push %edi + 444: 56 push %esi + 445: 53 push %ebx + 446: 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++) { + 449: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 44c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 44f: 0f b6 13 movzbl (%ebx),%edx + 452: 84 d2 test %dl,%dl + 454: 74 6a je 4c0 + ap = (uint*)(void*)&fmt + 1; + 456: 8d 45 10 lea 0x10(%ebp),%eax + 459: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 45c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 45f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 461: 89 45 d0 mov %eax,-0x30(%ebp) + 464: eb 36 jmp 49c + 466: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 46d: 8d 76 00 lea 0x0(%esi),%esi + 470: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 473: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 478: 83 f8 25 cmp $0x25,%eax + 47b: 74 15 je 492 + write(fd, &c, 1); + 47d: 83 ec 04 sub $0x4,%esp + 480: 88 55 e7 mov %dl,-0x19(%ebp) + 483: 6a 01 push $0x1 + 485: 57 push %edi + 486: 56 push %esi + 487: e8 a7 fe ff ff call 333 + 48c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 48f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 492: 0f b6 13 movzbl (%ebx),%edx + 495: 83 c3 01 add $0x1,%ebx + 498: 84 d2 test %dl,%dl + 49a: 74 24 je 4c0 + c = fmt[i] & 0xff; + 49c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 49f: 85 c9 test %ecx,%ecx + 4a1: 74 cd je 470 + } + } + else if (state == '%') { + 4a3: 83 f9 25 cmp $0x25,%ecx + 4a6: 75 ea jne 492 + if (c == 'd') { + 4a8: 83 f8 25 cmp $0x25,%eax + 4ab: 0f 84 07 01 00 00 je 5b8 + 4b1: 83 e8 63 sub $0x63,%eax + 4b4: 83 f8 15 cmp $0x15,%eax + 4b7: 77 17 ja 4d0 + 4b9: ff 24 85 78 07 00 00 jmp *0x778(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4c0: 8d 65 f4 lea -0xc(%ebp),%esp + 4c3: 5b pop %ebx + 4c4: 5e pop %esi + 4c5: 5f pop %edi + 4c6: 5d pop %ebp + 4c7: c3 ret + 4c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4cf: 90 nop + write(fd, &c, 1); + 4d0: 83 ec 04 sub $0x4,%esp + 4d3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4d6: 6a 01 push $0x1 + 4d8: 57 push %edi + 4d9: 56 push %esi + 4da: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4de: e8 50 fe ff ff call 333 + putc(fd, c); + 4e3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4e7: 83 c4 0c add $0xc,%esp + 4ea: 88 55 e7 mov %dl,-0x19(%ebp) + 4ed: 6a 01 push $0x1 + 4ef: 57 push %edi + 4f0: 56 push %esi + 4f1: e8 3d fe ff ff call 333 + putc(fd, c); + 4f6: 83 c4 10 add $0x10,%esp + state = 0; + 4f9: 31 c9 xor %ecx,%ecx + 4fb: eb 95 jmp 492 + 4fd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 500: 83 ec 0c sub $0xc,%esp + 503: b9 10 00 00 00 mov $0x10,%ecx + 508: 6a 00 push $0x0 + 50a: 8b 45 d0 mov -0x30(%ebp),%eax + 50d: 8b 10 mov (%eax),%edx + 50f: 89 f0 mov %esi,%eax + 511: e8 7a fe ff ff call 390 + ap++; + 516: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 51a: 83 c4 10 add $0x10,%esp + state = 0; + 51d: 31 c9 xor %ecx,%ecx + 51f: e9 6e ff ff ff jmp 492 + 524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 528: 8b 45 d0 mov -0x30(%ebp),%eax + 52b: 8b 10 mov (%eax),%edx + ap++; + 52d: 83 c0 04 add $0x4,%eax + 530: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 533: 85 d2 test %edx,%edx + 535: 0f 84 8d 00 00 00 je 5c8 + while (*s != 0) { + 53b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 53e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 540: 84 c0 test %al,%al + 542: 0f 84 4a ff ff ff je 492 + 548: 89 5d d4 mov %ebx,-0x2c(%ebp) + 54b: 89 d3 mov %edx,%ebx + 54d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 550: 83 ec 04 sub $0x4,%esp + s++; + 553: 83 c3 01 add $0x1,%ebx + 556: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 559: 6a 01 push $0x1 + 55b: 57 push %edi + 55c: 56 push %esi + 55d: e8 d1 fd ff ff call 333 + while (*s != 0) { + 562: 0f b6 03 movzbl (%ebx),%eax + 565: 83 c4 10 add $0x10,%esp + 568: 84 c0 test %al,%al + 56a: 75 e4 jne 550 + state = 0; + 56c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 56f: 31 c9 xor %ecx,%ecx + 571: e9 1c ff ff ff jmp 492 + 576: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 57d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 580: 83 ec 0c sub $0xc,%esp + 583: b9 0a 00 00 00 mov $0xa,%ecx + 588: 6a 01 push $0x1 + 58a: e9 7b ff ff ff jmp 50a + 58f: 90 nop + putc(fd, *ap); + 590: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 593: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 596: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 598: 6a 01 push $0x1 + 59a: 57 push %edi + 59b: 56 push %esi + putc(fd, *ap); + 59c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 59f: e8 8f fd ff ff call 333 + ap++; + 5a4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5a8: 83 c4 10 add $0x10,%esp + state = 0; + 5ab: 31 c9 xor %ecx,%ecx + 5ad: e9 e0 fe ff ff jmp 492 + 5b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5b8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5bb: 83 ec 04 sub $0x4,%esp + 5be: e9 2a ff ff ff jmp 4ed + 5c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5c7: 90 nop + s = "(null)"; + 5c8: ba 71 07 00 00 mov $0x771,%edx + while (*s != 0) { + 5cd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5d0: b8 28 00 00 00 mov $0x28,%eax + 5d5: 89 d3 mov %edx,%ebx + 5d7: e9 74 ff ff ff jmp 550 + 5dc: 66 90 xchg %ax,%ax + 5de: 66 90 xchg %ax,%ax + +000005e0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5e0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5e1: a1 84 0a 00 00 mov 0xa84,%eax +void free(void *ap) { + 5e6: 89 e5 mov %esp,%ebp + 5e8: 57 push %edi + 5e9: 56 push %esi + 5ea: 53 push %ebx + 5eb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5ee: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5f8: 89 c2 mov %eax,%edx + 5fa: 8b 00 mov (%eax),%eax + 5fc: 39 ca cmp %ecx,%edx + 5fe: 73 30 jae 630 + 600: 39 c1 cmp %eax,%ecx + 602: 72 04 jb 608 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 604: 39 c2 cmp %eax,%edx + 606: 72 f0 jb 5f8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 608: 8b 73 fc mov -0x4(%ebx),%esi + 60b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 60e: 39 f8 cmp %edi,%eax + 610: 74 30 je 642 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 612: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 615: 8b 42 04 mov 0x4(%edx),%eax + 618: 8d 34 c2 lea (%edx,%eax,8),%esi + 61b: 39 f1 cmp %esi,%ecx + 61d: 74 3a je 659 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 61f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 621: 5b pop %ebx + freep = p; + 622: 89 15 84 0a 00 00 mov %edx,0xa84 +} + 628: 5e pop %esi + 629: 5f pop %edi + 62a: 5d pop %ebp + 62b: c3 ret + 62c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 630: 39 c2 cmp %eax,%edx + 632: 72 c4 jb 5f8 + 634: 39 c1 cmp %eax,%ecx + 636: 73 c0 jae 5f8 + if (bp + bp->s.size == p->s.ptr) { + 638: 8b 73 fc mov -0x4(%ebx),%esi + 63b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 63e: 39 f8 cmp %edi,%eax + 640: 75 d0 jne 612 + bp->s.size += p->s.ptr->s.size; + 642: 03 70 04 add 0x4(%eax),%esi + 645: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 648: 8b 02 mov (%edx),%eax + 64a: 8b 00 mov (%eax),%eax + 64c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 64f: 8b 42 04 mov 0x4(%edx),%eax + 652: 8d 34 c2 lea (%edx,%eax,8),%esi + 655: 39 f1 cmp %esi,%ecx + 657: 75 c6 jne 61f + p->s.size += bp->s.size; + 659: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 65c: 89 15 84 0a 00 00 mov %edx,0xa84 + p->s.size += bp->s.size; + 662: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 665: 8b 4b f8 mov -0x8(%ebx),%ecx + 668: 89 0a mov %ecx,(%edx) +} + 66a: 5b pop %ebx + 66b: 5e pop %esi + 66c: 5f pop %edi + 66d: 5d pop %ebp + 66e: c3 ret + 66f: 90 nop + +00000670 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 670: 55 push %ebp + 671: 89 e5 mov %esp,%ebp + 673: 57 push %edi + 674: 56 push %esi + 675: 53 push %ebx + 676: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 679: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 67c: 8b 3d 84 0a 00 00 mov 0xa84,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 682: 8d 70 07 lea 0x7(%eax),%esi + 685: c1 ee 03 shr $0x3,%esi + 688: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 68b: 85 ff test %edi,%edi + 68d: 0f 84 9d 00 00 00 je 730 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 693: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 695: 8b 4a 04 mov 0x4(%edx),%ecx + 698: 39 f1 cmp %esi,%ecx + 69a: 73 6a jae 706 + 69c: bb 00 10 00 00 mov $0x1000,%ebx + 6a1: 39 de cmp %ebx,%esi + 6a3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 6a6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 6ad: 89 45 e4 mov %eax,-0x1c(%ebp) + 6b0: eb 17 jmp 6c9 + 6b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6b8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6ba: 8b 48 04 mov 0x4(%eax),%ecx + 6bd: 39 f1 cmp %esi,%ecx + 6bf: 73 4f jae 710 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6c1: 8b 3d 84 0a 00 00 mov 0xa84,%edi + 6c7: 89 c2 mov %eax,%edx + 6c9: 39 d7 cmp %edx,%edi + 6cb: 75 eb jne 6b8 + p = sbrk(nu * sizeof(Header)); + 6cd: 83 ec 0c sub $0xc,%esp + 6d0: ff 75 e4 push -0x1c(%ebp) + 6d3: e8 3b fc ff ff call 313 + if (p == (char*)-1) { + 6d8: 83 c4 10 add $0x10,%esp + 6db: 83 f8 ff cmp $0xffffffff,%eax + 6de: 74 1c je 6fc + hp->s.size = nu; + 6e0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6e3: 83 ec 0c sub $0xc,%esp + 6e6: 83 c0 08 add $0x8,%eax + 6e9: 50 push %eax + 6ea: e8 f1 fe ff ff call 5e0 + return freep; + 6ef: 8b 15 84 0a 00 00 mov 0xa84,%edx + if ((p = morecore(nunits)) == 0) { + 6f5: 83 c4 10 add $0x10,%esp + 6f8: 85 d2 test %edx,%edx + 6fa: 75 bc jne 6b8 + return 0; + } + } + } +} + 6fc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 6ff: 31 c0 xor %eax,%eax +} + 701: 5b pop %ebx + 702: 5e pop %esi + 703: 5f pop %edi + 704: 5d pop %ebp + 705: c3 ret + if (p->s.size >= nunits) { + 706: 89 d0 mov %edx,%eax + 708: 89 fa mov %edi,%edx + 70a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 710: 39 ce cmp %ecx,%esi + 712: 74 4c je 760 + p->s.size -= nunits; + 714: 29 f1 sub %esi,%ecx + 716: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 719: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 71c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 71f: 89 15 84 0a 00 00 mov %edx,0xa84 +} + 725: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 728: 83 c0 08 add $0x8,%eax +} + 72b: 5b pop %ebx + 72c: 5e pop %esi + 72d: 5f pop %edi + 72e: 5d pop %ebp + 72f: c3 ret + base.s.ptr = freep = prevp = &base; + 730: c7 05 84 0a 00 00 88 movl $0xa88,0xa84 + 737: 0a 00 00 + base.s.size = 0; + 73a: bf 88 0a 00 00 mov $0xa88,%edi + base.s.ptr = freep = prevp = &base; + 73f: c7 05 88 0a 00 00 88 movl $0xa88,0xa88 + 746: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 749: 89 fa mov %edi,%edx + base.s.size = 0; + 74b: c7 05 8c 0a 00 00 00 movl $0x0,0xa8c + 752: 00 00 00 + if (p->s.size >= nunits) { + 755: e9 42 ff ff ff jmp 69c + 75a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 760: 8b 08 mov (%eax),%ecx + 762: 89 0a mov %ecx,(%edx) + 764: eb b9 jmp 71f diff --git a/echo.d b/echo.d new file mode 100644 index 0000000..16a6098 --- /dev/null +++ b/echo.d @@ -0,0 +1 @@ +echo.o: echo.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/echo.o b/echo.o new file mode 100644 index 0000000..9e85697 Binary files /dev/null and b/echo.o differ diff --git a/echo.sym b/echo.sym new file mode 100644 index 0000000..555493c --- /dev/null +++ b/echo.sym @@ -0,0 +1,50 @@ +00000000 echo.c +00000000 ulib.c +00000000 printf.c +00000390 printint +000007d0 digits.0 +00000000 umalloc.c +00000a84 freep +00000a88 base +00000070 strcpy +00000440 printf +0000036b greeting +00000290 memmove +0000033b mknod +00000190 gets +0000030b getpid +0000037b screen +00000670 malloc +0000031b sleep +000002d3 pipe +00000363 getch +00000333 write +000002f3 fstat +000002e3 kill +000002fb chdir +000002eb exec +000002cb wait +000002db read +00000343 unlink +000002bb fork +00000313 sbrk +00000323 uptime +00000a84 __bss_start +00000130 memset +00000000 main +000000a0 strcmp +00000373 shutdown +00000303 dup +00000200 stat +00000a84 _edata +00000a90 _end +0000034b link +000002c3 exit +00000250 atoi +00000383 cls +00000100 strlen +0000032b open +00000150 strchr +00000353 mkdir +0000035b close +000005e0 free diff --git a/entry.o b/entry.o new file mode 100644 index 0000000..a61fc4a Binary files /dev/null and b/entry.o differ diff --git a/entryother b/entryother new file mode 100644 index 0000000..0e1f31a Binary files /dev/null and b/entryother differ diff --git a/entryother.asm b/entryother.asm new file mode 100644 index 0000000..656001f --- /dev/null +++ b/entryother.asm @@ -0,0 +1,115 @@ + +bootblockother.o: file format elf32-i386 + + +Disassembly of section .text: + +00007000 : +# This code combines elements of bootasm.S and entry.S. + +.code16 +.globl start +start: + cli + 7000: fa cli + + # Zero data segment registers DS, ES, and SS. + xorw %ax,%ax + 7001: 31 c0 xor %eax,%eax + movw %ax,%ds + 7003: 8e d8 mov %eax,%ds + movw %ax,%es + 7005: 8e c0 mov %eax,%es + movw %ax,%ss + 7007: 8e d0 mov %eax,%ss + + # Switch from real to protected mode. Use a bootstrap GDT that makes + # virtual addresses map directly to physical addresses so that the + # effective memory map doesn't change during the transition. + lgdt gdtdesc + 7009: 0f 01 16 lgdtl (%esi) + 700c: 74 70 je 707e <_end+0x2> + movl %cr0, %eax + 700e: 0f 20 c0 mov %cr0,%eax + orl $CR0_PE, %eax + 7011: 66 83 c8 01 or $0x1,%ax + movl %eax, %cr0 + 7015: 0f 22 c0 mov %eax,%cr0 + + # Complete the transition to 32-bit protected mode by using a long jmp + # to reload %cs and %eip. The segment descriptors are set up with no + # translation, so that the mapping is still the identity mapping. + ljmpl $(SEG_KCODE<<3), $(start32) + 7018: 66 ea 20 70 00 00 ljmpw $0x0,$0x7020 + 701e: 08 00 or %al,(%eax) + +00007020 : + + +.code32 # Tell assembler to generate 32-bit code now. +start32: + # Set up the protected-mode data segment registers + movw $(SEG_KDATA<<3), %ax # Our data segment selector + 7020: 66 b8 10 00 mov $0x10,%ax + movw %ax, %ds # -> DS: Data Segment + 7024: 8e d8 mov %eax,%ds + movw %ax, %es # -> ES: Extra Segment + 7026: 8e c0 mov %eax,%es + movw %ax, %ss # -> SS: Stack Segment + 7028: 8e d0 mov %eax,%ss + movw $0, %ax # Zero segments not ready for use + 702a: 66 b8 00 00 mov $0x0,%ax + movw %ax, %fs # -> FS + 702e: 8e e0 mov %eax,%fs + movw %ax, %gs # -> GS + 7030: 8e e8 mov %eax,%gs + + # Turn on page size extension for 4Mbyte pages + movl %cr4, %eax + 7032: 0f 20 e0 mov %cr4,%eax + orl $(CR4_PSE), %eax + 7035: 83 c8 10 or $0x10,%eax + movl %eax, %cr4 + 7038: 0f 22 e0 mov %eax,%cr4 + # Use entrypgdir as our initial page table + movl (start-12), %eax + 703b: a1 f4 6f 00 00 mov 0x6ff4,%eax + movl %eax, %cr3 + 7040: 0f 22 d8 mov %eax,%cr3 + # Turn on paging. + movl %cr0, %eax + 7043: 0f 20 c0 mov %cr0,%eax + orl $(CR0_PE|CR0_PG|CR0_WP), %eax + 7046: 0d 01 00 01 80 or $0x80010001,%eax + movl %eax, %cr0 + 704b: 0f 22 c0 mov %eax,%cr0 + + # Switch to the stack allocated by startothers() + movl (start-4), %esp + 704e: 8b 25 fc 6f 00 00 mov 0x6ffc,%esp + # Call mpenter() + call *(start-8) + 7054: ff 15 f8 6f 00 00 call *0x6ff8 + +0000705a : + + # We should never return. +spin: + jmp spin + 705a: eb fe jmp 705a + +0000705c : + ... + 7064: ff (bad) + 7065: ff 00 incl (%eax) + 7067: 00 00 add %al,(%eax) + 7069: 9a cf 00 ff ff 00 00 lcall $0x0,$0xffff00cf + 7070: 00 .byte 0x0 + 7071: 92 xchg %eax,%edx + 7072: cf iret + ... + +00007074 : + 7074: 17 pop %ss + 7075: 00 5c 70 00 add %bl,0x0(%eax,%esi,2) + ... diff --git a/entryother.d b/entryother.d new file mode 100644 index 0000000..a140303 --- /dev/null +++ b/entryother.d @@ -0,0 +1 @@ +entryother.o: entryother.S asm.h memlayout.h mmu.h diff --git a/entryother.o b/entryother.o new file mode 100644 index 0000000..ffdaa2e Binary files /dev/null and b/entryother.o differ diff --git a/exec.d b/exec.d new file mode 100644 index 0000000..0400275 --- /dev/null +++ b/exec.d @@ -0,0 +1,2 @@ +exec.o: exec.c /usr/include/stdc-predef.h types.h param.h memlayout.h \ + mmu.h proc.h defs.h x86.h elf.h diff --git a/exec.o b/exec.o new file mode 100644 index 0000000..bd83b06 Binary files /dev/null and b/exec.o differ diff --git a/file.d b/file.d new file mode 100644 index 0000000..fea73d1 --- /dev/null +++ b/file.d @@ -0,0 +1,2 @@ +file.o: file.c /usr/include/stdc-predef.h types.h defs.h param.h fs.h \ + spinlock.h sleeplock.h file.h diff --git a/file.o b/file.o new file mode 100644 index 0000000..c01e7b3 Binary files /dev/null and b/file.o differ diff --git a/forktest.asm b/forktest.asm new file mode 100644 index 0000000..cce18a5 --- /dev/null +++ b/forktest.asm @@ -0,0 +1,685 @@ + +_forktest: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + } + + printf(1, "fork test OK\n"); +} + +int main(void) { + 0: 55 push %ebp + 1: 89 e5 mov %esp,%ebp + 3: 83 e4 f0 and $0xfffffff0,%esp + forktest(); + 6: e8 35 00 00 00 call 40 + exit(); + b: e8 63 03 00 00 call 373 + +00000010 : +void printf(int fd, const char *s, ...) { + 10: 55 push %ebp + 11: 89 e5 mov %esp,%ebp + 13: 53 push %ebx + 14: 83 ec 10 sub $0x10,%esp + 17: 8b 5d 0c mov 0xc(%ebp),%ebx + write(fd, s, strlen(s)); + 1a: 53 push %ebx + 1b: e8 90 01 00 00 call 1b0 + 20: 83 c4 0c add $0xc,%esp + 23: 50 push %eax + 24: 53 push %ebx + 25: ff 75 08 push 0x8(%ebp) + 28: e8 b6 03 00 00 call 3e3 +} + 2d: 8b 5d fc mov -0x4(%ebp),%ebx + 30: 83 c4 10 add $0x10,%esp + 33: c9 leave + 34: c3 ret + 35: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000040 : +void forktest(void) { + 40: 55 push %ebp + 41: 89 e5 mov %esp,%ebp + 43: 53 push %ebx + for (n = 0; n < N; n++) { + 44: 31 db xor %ebx,%ebx +void forktest(void) { + 46: 83 ec 10 sub $0x10,%esp + write(fd, s, strlen(s)); + 49: 68 3c 04 00 00 push $0x43c + 4e: e8 5d 01 00 00 call 1b0 + 53: 83 c4 0c add $0xc,%esp + 56: 50 push %eax + 57: 68 3c 04 00 00 push $0x43c + 5c: 6a 01 push $0x1 + 5e: e8 80 03 00 00 call 3e3 + 63: 83 c4 10 add $0x10,%esp + 66: eb 19 jmp 81 + 68: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 6f: 90 nop + if (pid == 0) { + 70: 74 58 je ca + for (n = 0; n < N; n++) { + 72: 83 c3 01 add $0x1,%ebx + 75: 81 fb e8 03 00 00 cmp $0x3e8,%ebx + 7b: 0f 84 83 00 00 00 je 104 + pid = fork(); + 81: e8 e5 02 00 00 call 36b + if (pid < 0) { + 86: 85 c0 test %eax,%eax + 88: 79 e6 jns 70 + for (; n > 0; n--) { + 8a: 85 db test %ebx,%ebx + 8c: 74 10 je 9e + 8e: 66 90 xchg %ax,%ax + if (wait() < 0) { + 90: e8 e6 02 00 00 call 37b + 95: 85 c0 test %eax,%eax + 97: 78 36 js cf + for (; n > 0; n--) { + 99: 83 eb 01 sub $0x1,%ebx + 9c: 75 f2 jne 90 + if (wait() != -1) { + 9e: e8 d8 02 00 00 call 37b + a3: 83 f8 ff cmp $0xffffffff,%eax + a6: 75 49 jne f1 + write(fd, s, strlen(s)); + a8: 83 ec 0c sub $0xc,%esp + ab: 68 6e 04 00 00 push $0x46e + b0: e8 fb 00 00 00 call 1b0 + b5: 83 c4 0c add $0xc,%esp + b8: 50 push %eax + b9: 68 6e 04 00 00 push $0x46e + be: 6a 01 push $0x1 + c0: e8 1e 03 00 00 call 3e3 +} + c5: 8b 5d fc mov -0x4(%ebp),%ebx + c8: c9 leave + c9: c3 ret + exit(); + ca: e8 a4 02 00 00 call 373 + write(fd, s, strlen(s)); + cf: 83 ec 0c sub $0xc,%esp + d2: 68 47 04 00 00 push $0x447 + d7: e8 d4 00 00 00 call 1b0 + dc: 83 c4 0c add $0xc,%esp + df: 50 push %eax + e0: 68 47 04 00 00 push $0x447 + e5: 6a 01 push $0x1 + e7: e8 f7 02 00 00 call 3e3 + exit(); + ec: e8 82 02 00 00 call 373 + printf(1, "wait got too many\n"); + f1: 52 push %edx + f2: 52 push %edx + f3: 68 5b 04 00 00 push $0x45b + f8: 6a 01 push $0x1 + fa: e8 11 ff ff ff call 10 + exit(); + ff: e8 6f 02 00 00 call 373 + printf(1, "fork claimed to work N times!\n", N); + 104: 50 push %eax + 105: 68 e8 03 00 00 push $0x3e8 + 10a: 68 7c 04 00 00 push $0x47c + 10f: 6a 01 push $0x1 + 111: e8 fa fe ff ff call 10 + exit(); + 116: e8 58 02 00 00 call 373 + 11b: 66 90 xchg %ax,%ax + 11d: 66 90 xchg %ax,%ax + 11f: 90 nop + +00000120 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 120: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 121: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 123: 89 e5 mov %esp,%ebp + 125: 53 push %ebx + 126: 8b 4d 08 mov 0x8(%ebp),%ecx + 129: 8b 5d 0c mov 0xc(%ebp),%ebx + 12c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 130: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 134: 88 14 01 mov %dl,(%ecx,%eax,1) + 137: 83 c0 01 add $0x1,%eax + 13a: 84 d2 test %dl,%dl + 13c: 75 f2 jne 130 + ; + } + return os; +} + 13e: 8b 5d fc mov -0x4(%ebp),%ebx + 141: 89 c8 mov %ecx,%eax + 143: c9 leave + 144: c3 ret + 145: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000150 : + +int strcmp(const char *p, const char *q) { + 150: 55 push %ebp + 151: 89 e5 mov %esp,%ebp + 153: 53 push %ebx + 154: 8b 55 08 mov 0x8(%ebp),%edx + 157: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 15a: 0f b6 02 movzbl (%edx),%eax + 15d: 84 c0 test %al,%al + 15f: 75 17 jne 178 + 161: eb 3a jmp 19d + 163: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 167: 90 nop + 168: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 16c: 83 c2 01 add $0x1,%edx + 16f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 172: 84 c0 test %al,%al + 174: 74 1a je 190 + p++, q++; + 176: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 178: 0f b6 19 movzbl (%ecx),%ebx + 17b: 38 c3 cmp %al,%bl + 17d: 74 e9 je 168 + } + return (uchar) * p - (uchar) * q; + 17f: 29 d8 sub %ebx,%eax +} + 181: 8b 5d fc mov -0x4(%ebp),%ebx + 184: c9 leave + 185: c3 ret + 186: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 18d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 190: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 194: 31 c0 xor %eax,%eax + 196: 29 d8 sub %ebx,%eax +} + 198: 8b 5d fc mov -0x4(%ebp),%ebx + 19b: c9 leave + 19c: c3 ret + return (uchar) * p - (uchar) * q; + 19d: 0f b6 19 movzbl (%ecx),%ebx + 1a0: 31 c0 xor %eax,%eax + 1a2: eb db jmp 17f + 1a4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1af: 90 nop + +000001b0 : + +uint strlen(const char *s) { + 1b0: 55 push %ebp + 1b1: 89 e5 mov %esp,%ebp + 1b3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 1b6: 80 3a 00 cmpb $0x0,(%edx) + 1b9: 74 15 je 1d0 + 1bb: 31 c0 xor %eax,%eax + 1bd: 8d 76 00 lea 0x0(%esi),%esi + 1c0: 83 c0 01 add $0x1,%eax + 1c3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 1c7: 89 c1 mov %eax,%ecx + 1c9: 75 f5 jne 1c0 + ; + } + return n; +} + 1cb: 89 c8 mov %ecx,%eax + 1cd: 5d pop %ebp + 1ce: c3 ret + 1cf: 90 nop + for (n = 0; s[n]; n++) { + 1d0: 31 c9 xor %ecx,%ecx +} + 1d2: 5d pop %ebp + 1d3: 89 c8 mov %ecx,%eax + 1d5: c3 ret + 1d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1dd: 8d 76 00 lea 0x0(%esi),%esi + +000001e0 : + +void* memset(void *dst, int c, uint n) { + 1e0: 55 push %ebp + 1e1: 89 e5 mov %esp,%ebp + 1e3: 57 push %edi + 1e4: 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" : + 1e7: 8b 4d 10 mov 0x10(%ebp),%ecx + 1ea: 8b 45 0c mov 0xc(%ebp),%eax + 1ed: 89 d7 mov %edx,%edi + 1ef: fc cld + 1f0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1f2: 8b 7d fc mov -0x4(%ebp),%edi + 1f5: 89 d0 mov %edx,%eax + 1f7: c9 leave + 1f8: c3 ret + 1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000200 : + +char* strchr(const char *s, char c) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 8b 45 08 mov 0x8(%ebp),%eax + 206: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 20a: 0f b6 10 movzbl (%eax),%edx + 20d: 84 d2 test %dl,%dl + 20f: 75 12 jne 223 + 211: eb 1d jmp 230 + 213: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 217: 90 nop + 218: 0f b6 50 01 movzbl 0x1(%eax),%edx + 21c: 83 c0 01 add $0x1,%eax + 21f: 84 d2 test %dl,%dl + 221: 74 0d je 230 + if (*s == c) { + 223: 38 d1 cmp %dl,%cl + 225: 75 f1 jne 218 + return (char*)s; + } + } + return 0; +} + 227: 5d pop %ebp + 228: c3 ret + 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 230: 31 c0 xor %eax,%eax +} + 232: 5d pop %ebp + 233: c3 ret + 234: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 23b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 23f: 90 nop + +00000240 : + +char* gets(char *buf, int max) { + 240: 55 push %ebp + 241: 89 e5 mov %esp,%ebp + 243: 57 push %edi + 244: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 245: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 248: 53 push %ebx + for (i = 0; i + 1 < max;) { + 249: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 24b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 24e: eb 27 jmp 277 + cc = read(0, &c, 1); + 250: 83 ec 04 sub $0x4,%esp + 253: 6a 01 push $0x1 + 255: 57 push %edi + 256: 6a 00 push $0x0 + 258: e8 2e 01 00 00 call 38b + if (cc < 1) { + 25d: 83 c4 10 add $0x10,%esp + 260: 85 c0 test %eax,%eax + 262: 7e 1d jle 281 + break; + } + buf[i++] = c; + 264: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 268: 8b 55 08 mov 0x8(%ebp),%edx + 26b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 26f: 3c 0a cmp $0xa,%al + 271: 74 1d je 290 + 273: 3c 0d cmp $0xd,%al + 275: 74 19 je 290 + for (i = 0; i + 1 < max;) { + 277: 89 de mov %ebx,%esi + 279: 83 c3 01 add $0x1,%ebx + 27c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 27f: 7c cf jl 250 + break; + } + } + buf[i] = '\0'; + 281: 8b 45 08 mov 0x8(%ebp),%eax + 284: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 288: 8d 65 f4 lea -0xc(%ebp),%esp + 28b: 5b pop %ebx + 28c: 5e pop %esi + 28d: 5f pop %edi + 28e: 5d pop %ebp + 28f: c3 ret + buf[i] = '\0'; + 290: 8b 45 08 mov 0x8(%ebp),%eax + 293: 89 de mov %ebx,%esi + 295: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 299: 8d 65 f4 lea -0xc(%ebp),%esp + 29c: 5b pop %ebx + 29d: 5e pop %esi + 29e: 5f pop %edi + 29f: 5d pop %ebp + 2a0: c3 ret + 2a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2af: 90 nop + +000002b0 : + +int stat(const char *n, struct stat *st) { + 2b0: 55 push %ebp + 2b1: 89 e5 mov %esp,%ebp + 2b3: 56 push %esi + 2b4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 2b5: 83 ec 08 sub $0x8,%esp + 2b8: 6a 00 push $0x0 + 2ba: ff 75 08 push 0x8(%ebp) + 2bd: e8 19 01 00 00 call 3db + if (fd < 0) { + 2c2: 83 c4 10 add $0x10,%esp + 2c5: 85 c0 test %eax,%eax + 2c7: 78 27 js 2f0 + return -1; + } + r = fstat(fd, st); + 2c9: 83 ec 08 sub $0x8,%esp + 2cc: ff 75 0c push 0xc(%ebp) + 2cf: 89 c3 mov %eax,%ebx + 2d1: 50 push %eax + 2d2: e8 cc 00 00 00 call 3a3 + close(fd); + 2d7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 2da: 89 c6 mov %eax,%esi + close(fd); + 2dc: e8 2a 01 00 00 call 40b + return r; + 2e1: 83 c4 10 add $0x10,%esp +} + 2e4: 8d 65 f8 lea -0x8(%ebp),%esp + 2e7: 89 f0 mov %esi,%eax + 2e9: 5b pop %ebx + 2ea: 5e pop %esi + 2eb: 5d pop %ebp + 2ec: c3 ret + 2ed: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 2f0: be ff ff ff ff mov $0xffffffff,%esi + 2f5: eb ed jmp 2e4 + 2f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2fe: 66 90 xchg %ax,%ax + +00000300 : + +int atoi(const char *s) { + 300: 55 push %ebp + 301: 89 e5 mov %esp,%ebp + 303: 53 push %ebx + 304: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 307: 0f be 02 movsbl (%edx),%eax + 30a: 8d 48 d0 lea -0x30(%eax),%ecx + 30d: 80 f9 09 cmp $0x9,%cl + n = 0; + 310: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 315: 77 1e ja 335 + 317: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 31e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 320: 83 c2 01 add $0x1,%edx + 323: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 326: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 32a: 0f be 02 movsbl (%edx),%eax + 32d: 8d 58 d0 lea -0x30(%eax),%ebx + 330: 80 fb 09 cmp $0x9,%bl + 333: 76 eb jbe 320 + } + return n; +} + 335: 8b 5d fc mov -0x4(%ebp),%ebx + 338: 89 c8 mov %ecx,%eax + 33a: c9 leave + 33b: c3 ret + 33c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000340 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 340: 55 push %ebp + 341: 89 e5 mov %esp,%ebp + 343: 57 push %edi + 344: 8b 45 10 mov 0x10(%ebp),%eax + 347: 8b 55 08 mov 0x8(%ebp),%edx + 34a: 56 push %esi + 34b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 34e: 85 c0 test %eax,%eax + 350: 7e 13 jle 365 + 352: 01 d0 add %edx,%eax + dst = vdst; + 354: 89 d7 mov %edx,%edi + 356: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 35d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 360: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 361: 39 f8 cmp %edi,%eax + 363: 75 fb jne 360 + } + return vdst; +} + 365: 5e pop %esi + 366: 89 d0 mov %edx,%eax + 368: 5f pop %edi + 369: 5d pop %ebp + 36a: c3 ret + +0000036b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 36b: b8 01 00 00 00 mov $0x1,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(exit) + 373: b8 02 00 00 00 mov $0x2,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(wait) + 37b: b8 03 00 00 00 mov $0x3,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(pipe) + 383: b8 04 00 00 00 mov $0x4,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + +0000038b : +SYSCALL(read) + 38b: b8 05 00 00 00 mov $0x5,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(kill) + 393: b8 06 00 00 00 mov $0x6,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + +0000039b : +SYSCALL(exec) + 39b: b8 07 00 00 00 mov $0x7,%eax + 3a0: cd 40 int $0x40 + 3a2: c3 ret + +000003a3 : +SYSCALL(fstat) + 3a3: b8 08 00 00 00 mov $0x8,%eax + 3a8: cd 40 int $0x40 + 3aa: c3 ret + +000003ab : +SYSCALL(chdir) + 3ab: b8 09 00 00 00 mov $0x9,%eax + 3b0: cd 40 int $0x40 + 3b2: c3 ret + +000003b3 : +SYSCALL(dup) + 3b3: b8 0a 00 00 00 mov $0xa,%eax + 3b8: cd 40 int $0x40 + 3ba: c3 ret + +000003bb : +SYSCALL(getpid) + 3bb: b8 0b 00 00 00 mov $0xb,%eax + 3c0: cd 40 int $0x40 + 3c2: c3 ret + +000003c3 : +SYSCALL(sbrk) + 3c3: b8 0c 00 00 00 mov $0xc,%eax + 3c8: cd 40 int $0x40 + 3ca: c3 ret + +000003cb : +SYSCALL(sleep) + 3cb: b8 0d 00 00 00 mov $0xd,%eax + 3d0: cd 40 int $0x40 + 3d2: c3 ret + +000003d3 : +SYSCALL(uptime) + 3d3: b8 0e 00 00 00 mov $0xe,%eax + 3d8: cd 40 int $0x40 + 3da: c3 ret + +000003db : +SYSCALL(open) + 3db: b8 0f 00 00 00 mov $0xf,%eax + 3e0: cd 40 int $0x40 + 3e2: c3 ret + +000003e3 : +SYSCALL(write) + 3e3: b8 10 00 00 00 mov $0x10,%eax + 3e8: cd 40 int $0x40 + 3ea: c3 ret + +000003eb : +SYSCALL(mknod) + 3eb: b8 11 00 00 00 mov $0x11,%eax + 3f0: cd 40 int $0x40 + 3f2: c3 ret + +000003f3 : +SYSCALL(unlink) + 3f3: b8 12 00 00 00 mov $0x12,%eax + 3f8: cd 40 int $0x40 + 3fa: c3 ret + +000003fb : +SYSCALL(link) + 3fb: b8 13 00 00 00 mov $0x13,%eax + 400: cd 40 int $0x40 + 402: c3 ret + +00000403 : +SYSCALL(mkdir) + 403: b8 14 00 00 00 mov $0x14,%eax + 408: cd 40 int $0x40 + 40a: c3 ret + +0000040b : +SYSCALL(close) + 40b: b8 15 00 00 00 mov $0x15,%eax + 410: cd 40 int $0x40 + 412: c3 ret + +00000413 : +SYSCALL(getch) + 413: b8 16 00 00 00 mov $0x16,%eax + 418: cd 40 int $0x40 + 41a: c3 ret + +0000041b : +SYSCALL(greeting) + 41b: b8 17 00 00 00 mov $0x17,%eax + 420: cd 40 int $0x40 + 422: c3 ret + +00000423 : +SYSCALL(shutdown) + 423: b8 18 00 00 00 mov $0x18,%eax + 428: cd 40 int $0x40 + 42a: c3 ret + +0000042b : +SYSCALL(screen) + 42b: b8 19 00 00 00 mov $0x19,%eax + 430: cd 40 int $0x40 + 432: c3 ret + +00000433 : +SYSCALL(cls) + 433: b8 1a 00 00 00 mov $0x1a,%eax + 438: cd 40 int $0x40 + 43a: c3 ret diff --git a/forktest.d b/forktest.d new file mode 100644 index 0000000..d31a0c2 --- /dev/null +++ b/forktest.d @@ -0,0 +1 @@ +forktest.o: forktest.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/forktest.o b/forktest.o new file mode 100644 index 0000000..8cf0db7 Binary files /dev/null and b/forktest.o differ diff --git a/fs.d b/fs.d new file mode 100644 index 0000000..a1d05cc --- /dev/null +++ b/fs.d @@ -0,0 +1,2 @@ +fs.o: fs.c /usr/include/stdc-predef.h types.h defs.h param.h stat.h mmu.h \ + proc.h spinlock.h sleeplock.h fs.h buf.h file.h diff --git a/fs.img b/fs.img new file mode 100644 index 0000000..dbeb48f --- /dev/null +++ b/fs.img @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a162f597afbb5a554ac7f7d58d0c9f2b6b0bedb572f62c50ce4a4b5299b879c1 +size 512000 diff --git a/fs.o b/fs.o new file mode 100644 index 0000000..9b77b26 Binary files /dev/null and b/fs.o differ diff --git a/grep.asm b/grep.asm new file mode 100644 index 0000000..45ca54d --- /dev/null +++ b/grep.asm @@ -0,0 +1,1595 @@ + +_grep: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + memmove(buf, p, m); + } + } +} + +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: 51 push %ecx + 11: 83 ec 18 sub $0x18,%esp + 14: 8b 01 mov (%ecx),%eax + 16: 8b 59 04 mov 0x4(%ecx),%ebx + 19: 89 45 e4 mov %eax,-0x1c(%ebp) + int fd, i; + char *pattern; + + if (argc <= 1) { + 1c: 83 f8 01 cmp $0x1,%eax + 1f: 7e 6f jle 90 + printf(2, "usage: grep pattern [file ...]\n"); + exit(); + } + pattern = argv[1]; + 21: 8b 43 04 mov 0x4(%ebx),%eax + 24: 83 c3 08 add $0x8,%ebx + + if (argc <= 2) { + 27: 83 7d e4 02 cmpl $0x2,-0x1c(%ebp) + grep(pattern, 0); + exit(); + } + + for (i = 2; i < argc; i++) { + 2b: be 02 00 00 00 mov $0x2,%esi + pattern = argv[1]; + 30: 89 45 e0 mov %eax,-0x20(%ebp) + if (argc <= 2) { + 33: 75 2d jne 62 + 35: eb 6c jmp a3 + 37: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3e: 66 90 xchg %ax,%ax + if ((fd = open(argv[i], 0)) < 0) { + printf(1, "grep: cannot open %s\n", argv[i]); + exit(); + } + grep(pattern, fd); + 40: 83 ec 08 sub $0x8,%esp + for (i = 2; i < argc; i++) { + 43: 83 c6 01 add $0x1,%esi + 46: 83 c3 04 add $0x4,%ebx + grep(pattern, fd); + 49: 50 push %eax + 4a: ff 75 e0 push -0x20(%ebp) + 4d: e8 7e 01 00 00 call 1d0 + close(fd); + 52: 89 3c 24 mov %edi,(%esp) + 55: e8 01 06 00 00 call 65b + for (i = 2; i < argc; i++) { + 5a: 83 c4 10 add $0x10,%esp + 5d: 39 75 e4 cmp %esi,-0x1c(%ebp) + 60: 7e 29 jle 8b + if ((fd = open(argv[i], 0)) < 0) { + 62: 83 ec 08 sub $0x8,%esp + 65: 6a 00 push $0x0 + 67: ff 33 push (%ebx) + 69: e8 bd 05 00 00 call 62b + 6e: 83 c4 10 add $0x10,%esp + 71: 89 c7 mov %eax,%edi + 73: 85 c0 test %eax,%eax + 75: 79 c9 jns 40 + printf(1, "grep: cannot open %s\n", argv[i]); + 77: 50 push %eax + 78: ff 33 push (%ebx) + 7a: 68 88 0a 00 00 push $0xa88 + 7f: 6a 01 push $0x1 + 81: e8 ba 06 00 00 call 740 + exit(); + 86: e8 38 05 00 00 call 5c3 + } + exit(); + 8b: e8 33 05 00 00 call 5c3 + printf(2, "usage: grep pattern [file ...]\n"); + 90: 51 push %ecx + 91: 51 push %ecx + 92: 68 68 0a 00 00 push $0xa68 + 97: 6a 02 push $0x2 + 99: e8 a2 06 00 00 call 740 + exit(); + 9e: e8 20 05 00 00 call 5c3 + grep(pattern, 0); + a3: 52 push %edx + a4: 52 push %edx + a5: 6a 00 push $0x0 + a7: 50 push %eax + a8: e8 23 01 00 00 call 1d0 + exit(); + ad: e8 11 05 00 00 call 5c3 + b2: 66 90 xchg %ax,%ax + b4: 66 90 xchg %ax,%ax + b6: 66 90 xchg %ax,%ax + b8: 66 90 xchg %ax,%ax + ba: 66 90 xchg %ax,%ax + bc: 66 90 xchg %ax,%ax + be: 66 90 xchg %ax,%ax + +000000c0 : + while (*text++ != '\0'); + return 0; +} + +// matchhere: search for re at beginning of text +int matchhere(char *re, char *text){ + c0: 55 push %ebp + c1: 89 e5 mov %esp,%ebp + c3: 57 push %edi + c4: 56 push %esi + c5: 53 push %ebx + c6: 83 ec 0c sub $0xc,%esp + c9: 8b 75 08 mov 0x8(%ebp),%esi + cc: 8b 7d 0c mov 0xc(%ebp),%edi + if (re[0] == '\0') { + cf: 0f b6 06 movzbl (%esi),%eax + d2: 84 c0 test %al,%al + d4: 75 2d jne 103 + d6: e9 7d 00 00 00 jmp 158 + db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + df: 90 nop + } + if (re[1] == '*') { + return matchstar(re[0], re + 2, text); + } + if (re[0] == '$' && re[1] == '\0') { + return *text == '\0'; + e0: 0f b6 0f movzbl (%edi),%ecx + if (re[0] == '$' && re[1] == '\0') { + e3: 80 fb 24 cmp $0x24,%bl + e6: 75 04 jne ec + e8: 84 c0 test %al,%al + ea: 74 79 je 165 + } + if (*text != '\0' && (re[0] == '.' || re[0] == *text)) { + ec: 84 c9 test %cl,%cl + ee: 74 58 je 148 + f0: 38 d9 cmp %bl,%cl + f2: 74 05 je f9 + f4: 80 fb 2e cmp $0x2e,%bl + f7: 75 4f jne 148 + return matchhere(re + 1, text + 1); + f9: 83 c7 01 add $0x1,%edi + fc: 83 c6 01 add $0x1,%esi + if (re[0] == '\0') { + ff: 84 c0 test %al,%al + 101: 74 55 je 158 + if (re[1] == '*') { + 103: 0f be d8 movsbl %al,%ebx + 106: 0f b6 46 01 movzbl 0x1(%esi),%eax + 10a: 3c 2a cmp $0x2a,%al + 10c: 75 d2 jne e0 + return matchstar(re[0], re + 2, text); + 10e: 83 c6 02 add $0x2,%esi + } + return 0; +} + +// matchstar: search for c*re at beginning of text +int matchstar(int c, char *re, char *text) { + 111: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + do { // a * matches zero or more instances + if (matchhere(re, text)) { + 118: 83 ec 08 sub $0x8,%esp + 11b: 57 push %edi + 11c: 56 push %esi + 11d: e8 9e ff ff ff call c0 + 122: 83 c4 10 add $0x10,%esp + 125: 85 c0 test %eax,%eax + 127: 75 2f jne 158 + return 1; + } + } + while (*text != '\0' && (*text++ == c || c == '.')); + 129: 0f be 17 movsbl (%edi),%edx + 12c: 84 d2 test %dl,%dl + 12e: 74 0c je 13c + 130: 83 c7 01 add $0x1,%edi + 133: 83 fb 2e cmp $0x2e,%ebx + 136: 74 e0 je 118 + 138: 39 da cmp %ebx,%edx + 13a: 74 dc je 118 +} + 13c: 8d 65 f4 lea -0xc(%ebp),%esp + 13f: 5b pop %ebx + 140: 5e pop %esi + 141: 5f pop %edi + 142: 5d pop %ebp + 143: c3 ret + 144: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 148: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 14b: 31 c0 xor %eax,%eax +} + 14d: 5b pop %ebx + 14e: 5e pop %esi + 14f: 5f pop %edi + 150: 5d pop %ebp + 151: c3 ret + 152: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 158: 8d 65 f4 lea -0xc(%ebp),%esp + return 1; + 15b: b8 01 00 00 00 mov $0x1,%eax +} + 160: 5b pop %ebx + 161: 5e pop %esi + 162: 5f pop %edi + 163: 5d pop %ebp + 164: c3 ret + return *text == '\0'; + 165: 31 c0 xor %eax,%eax + 167: 84 c9 test %cl,%cl + 169: 0f 94 c0 sete %al + 16c: eb ce jmp 13c + 16e: 66 90 xchg %ax,%ax + +00000170 : +int match(char *re, char *text) { + 170: 55 push %ebp + 171: 89 e5 mov %esp,%ebp + 173: 56 push %esi + 174: 53 push %ebx + 175: 8b 5d 08 mov 0x8(%ebp),%ebx + 178: 8b 75 0c mov 0xc(%ebp),%esi + if (re[0] == '^') { + 17b: 80 3b 5e cmpb $0x5e,(%ebx) + 17e: 75 11 jne 191 + 180: eb 2e jmp 1b0 + 182: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + while (*text++ != '\0'); + 188: 83 c6 01 add $0x1,%esi + 18b: 80 7e ff 00 cmpb $0x0,-0x1(%esi) + 18f: 74 16 je 1a7 + if (matchhere(re, text)) { + 191: 83 ec 08 sub $0x8,%esp + 194: 56 push %esi + 195: 53 push %ebx + 196: e8 25 ff ff ff call c0 + 19b: 83 c4 10 add $0x10,%esp + 19e: 85 c0 test %eax,%eax + 1a0: 74 e6 je 188 + return 1; + 1a2: b8 01 00 00 00 mov $0x1,%eax +} + 1a7: 8d 65 f8 lea -0x8(%ebp),%esp + 1aa: 5b pop %ebx + 1ab: 5e pop %esi + 1ac: 5d pop %ebp + 1ad: c3 ret + 1ae: 66 90 xchg %ax,%ax + return matchhere(re + 1, text); + 1b0: 83 c3 01 add $0x1,%ebx + 1b3: 89 5d 08 mov %ebx,0x8(%ebp) +} + 1b6: 8d 65 f8 lea -0x8(%ebp),%esp + 1b9: 5b pop %ebx + 1ba: 5e pop %esi + 1bb: 5d pop %ebp + return matchhere(re + 1, text); + 1bc: e9 ff fe ff ff jmp c0 + 1c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1cf: 90 nop + +000001d0 : +void grep(char *pattern, int fd) { + 1d0: 55 push %ebp + 1d1: 89 e5 mov %esp,%ebp + 1d3: 57 push %edi + 1d4: 56 push %esi + 1d5: 53 push %ebx + 1d6: 83 ec 1c sub $0x1c,%esp + 1d9: 8b 7d 08 mov 0x8(%ebp),%edi + m = 0; + 1dc: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + return matchhere(re + 1, text); + 1e3: 8d 47 01 lea 0x1(%edi),%eax + 1e6: 89 45 d8 mov %eax,-0x28(%ebp) + 1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + while ((n = read(fd, buf + m, sizeof(buf) - m - 1)) > 0) { + 1f0: 8b 4d dc mov -0x24(%ebp),%ecx + 1f3: b8 ff 03 00 00 mov $0x3ff,%eax + 1f8: 83 ec 04 sub $0x4,%esp + 1fb: 29 c8 sub %ecx,%eax + 1fd: 50 push %eax + 1fe: 8d 81 a0 0e 00 00 lea 0xea0(%ecx),%eax + 204: 50 push %eax + 205: ff 75 0c push 0xc(%ebp) + 208: e8 ce 03 00 00 call 5db + 20d: 83 c4 10 add $0x10,%esp + 210: 85 c0 test %eax,%eax + 212: 0f 8e e5 00 00 00 jle 2fd + m += n; + 218: 01 45 dc add %eax,-0x24(%ebp) + 21b: 8b 4d dc mov -0x24(%ebp),%ecx + p = buf; + 21e: c7 45 e4 a0 0e 00 00 movl $0xea0,-0x1c(%ebp) + buf[m] = '\0'; + 225: c6 81 a0 0e 00 00 00 movb $0x0,0xea0(%ecx) + while ((q = strchr(p, '\n')) != 0) { + 22c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 230: 83 ec 08 sub $0x8,%esp + 233: 6a 0a push $0xa + 235: ff 75 e4 push -0x1c(%ebp) + 238: e8 13 02 00 00 call 450 + 23d: 83 c4 10 add $0x10,%esp + 240: 89 c3 mov %eax,%ebx + 242: 85 c0 test %eax,%eax + 244: 74 72 je 2b8 + *q = 0; + 246: c6 03 00 movb $0x0,(%ebx) + write(1, p, q + 1 - p); + 249: 8d 43 01 lea 0x1(%ebx),%eax + if (re[0] == '^') { + 24c: 80 3f 5e cmpb $0x5e,(%edi) + write(1, p, q + 1 - p); + 24f: 89 45 e0 mov %eax,-0x20(%ebp) + 252: 8b 75 e4 mov -0x1c(%ebp),%esi + if (re[0] == '^') { + 255: 75 12 jne 269 + 257: eb 47 jmp 2a0 + 259: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + while (*text++ != '\0'); + 260: 83 c6 01 add $0x1,%esi + 263: 80 7e ff 00 cmpb $0x0,-0x1(%esi) + 267: 74 2b je 294 + if (matchhere(re, text)) { + 269: 83 ec 08 sub $0x8,%esp + 26c: 56 push %esi + 26d: 57 push %edi + 26e: e8 4d fe ff ff call c0 + 273: 83 c4 10 add $0x10,%esp + 276: 85 c0 test %eax,%eax + 278: 74 e6 je 260 + write(1, p, q + 1 - p); + 27a: 8b 55 e4 mov -0x1c(%ebp),%edx + 27d: 8b 45 e0 mov -0x20(%ebp),%eax + 280: 83 ec 04 sub $0x4,%esp + *q = '\n'; + 283: c6 03 0a movb $0xa,(%ebx) + write(1, p, q + 1 - p); + 286: 29 d0 sub %edx,%eax + 288: 50 push %eax + 289: 52 push %edx + 28a: 6a 01 push $0x1 + 28c: e8 a2 03 00 00 call 633 + 291: 83 c4 10 add $0x10,%esp + p = q + 1; + 294: 8b 45 e0 mov -0x20(%ebp),%eax + 297: 89 45 e4 mov %eax,-0x1c(%ebp) + 29a: eb 94 jmp 230 + 29c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return matchhere(re + 1, text); + 2a0: 83 ec 08 sub $0x8,%esp + 2a3: 56 push %esi + 2a4: ff 75 d8 push -0x28(%ebp) + 2a7: e8 14 fe ff ff call c0 + 2ac: 83 c4 10 add $0x10,%esp + if (match(pattern, p)) { + 2af: 85 c0 test %eax,%eax + 2b1: 74 e1 je 294 + 2b3: eb c5 jmp 27a + 2b5: 8d 76 00 lea 0x0(%esi),%esi + if (p == buf) { + 2b8: 8b 55 e4 mov -0x1c(%ebp),%edx + 2bb: 81 fa a0 0e 00 00 cmp $0xea0,%edx + 2c1: 74 2e je 2f1 + if (m > 0) { + 2c3: 8b 4d dc mov -0x24(%ebp),%ecx + 2c6: 85 c9 test %ecx,%ecx + 2c8: 0f 8e 22 ff ff ff jle 1f0 + m -= p - buf; + 2ce: 89 d0 mov %edx,%eax + memmove(buf, p, m); + 2d0: 83 ec 04 sub $0x4,%esp + m -= p - buf; + 2d3: 2d a0 0e 00 00 sub $0xea0,%eax + 2d8: 29 c1 sub %eax,%ecx + memmove(buf, p, m); + 2da: 51 push %ecx + 2db: 52 push %edx + 2dc: 68 a0 0e 00 00 push $0xea0 + m -= p - buf; + 2e1: 89 4d dc mov %ecx,-0x24(%ebp) + memmove(buf, p, m); + 2e4: e8 a7 02 00 00 call 590 + 2e9: 83 c4 10 add $0x10,%esp + 2ec: e9 ff fe ff ff jmp 1f0 + m = 0; + 2f1: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + 2f8: e9 f3 fe ff ff jmp 1f0 +} + 2fd: 8d 65 f4 lea -0xc(%ebp),%esp + 300: 5b pop %ebx + 301: 5e pop %esi + 302: 5f pop %edi + 303: 5d pop %ebp + 304: c3 ret + 305: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 30c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000310 : +int matchstar(int c, char *re, char *text) { + 310: 55 push %ebp + 311: 89 e5 mov %esp,%ebp + 313: 57 push %edi + 314: 56 push %esi + 315: 53 push %ebx + 316: 83 ec 0c sub $0xc,%esp + 319: 8b 5d 08 mov 0x8(%ebp),%ebx + 31c: 8b 75 0c mov 0xc(%ebp),%esi + 31f: 8b 7d 10 mov 0x10(%ebp),%edi + 322: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (matchhere(re, text)) { + 328: 83 ec 08 sub $0x8,%esp + 32b: 57 push %edi + 32c: 56 push %esi + 32d: e8 8e fd ff ff call c0 + 332: 83 c4 10 add $0x10,%esp + 335: 85 c0 test %eax,%eax + 337: 75 1f jne 358 + while (*text != '\0' && (*text++ == c || c == '.')); + 339: 0f be 17 movsbl (%edi),%edx + 33c: 84 d2 test %dl,%dl + 33e: 74 0c je 34c + 340: 83 c7 01 add $0x1,%edi + 343: 39 da cmp %ebx,%edx + 345: 74 e1 je 328 + 347: 83 fb 2e cmp $0x2e,%ebx + 34a: 74 dc je 328 +} + 34c: 8d 65 f4 lea -0xc(%ebp),%esp + 34f: 5b pop %ebx + 350: 5e pop %esi + 351: 5f pop %edi + 352: 5d pop %ebp + 353: c3 ret + 354: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 358: 8d 65 f4 lea -0xc(%ebp),%esp + return 1; + 35b: b8 01 00 00 00 mov $0x1,%eax +} + 360: 5b pop %ebx + 361: 5e pop %esi + 362: 5f pop %edi + 363: 5d pop %ebp + 364: c3 ret + 365: 66 90 xchg %ax,%ax + 367: 66 90 xchg %ax,%ax + 369: 66 90 xchg %ax,%ax + 36b: 66 90 xchg %ax,%ax + 36d: 66 90 xchg %ax,%ax + 36f: 90 nop + +00000370 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 370: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 371: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 373: 89 e5 mov %esp,%ebp + 375: 53 push %ebx + 376: 8b 4d 08 mov 0x8(%ebp),%ecx + 379: 8b 5d 0c mov 0xc(%ebp),%ebx + 37c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 380: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 384: 88 14 01 mov %dl,(%ecx,%eax,1) + 387: 83 c0 01 add $0x1,%eax + 38a: 84 d2 test %dl,%dl + 38c: 75 f2 jne 380 + ; + } + return os; +} + 38e: 8b 5d fc mov -0x4(%ebp),%ebx + 391: 89 c8 mov %ecx,%eax + 393: c9 leave + 394: c3 ret + 395: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 39c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000003a0 : + +int strcmp(const char *p, const char *q) { + 3a0: 55 push %ebp + 3a1: 89 e5 mov %esp,%ebp + 3a3: 53 push %ebx + 3a4: 8b 55 08 mov 0x8(%ebp),%edx + 3a7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 3aa: 0f b6 02 movzbl (%edx),%eax + 3ad: 84 c0 test %al,%al + 3af: 75 17 jne 3c8 + 3b1: eb 3a jmp 3ed + 3b3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 3b7: 90 nop + 3b8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 3bc: 83 c2 01 add $0x1,%edx + 3bf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 3c2: 84 c0 test %al,%al + 3c4: 74 1a je 3e0 + p++, q++; + 3c6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 3c8: 0f b6 19 movzbl (%ecx),%ebx + 3cb: 38 c3 cmp %al,%bl + 3cd: 74 e9 je 3b8 + } + return (uchar) * p - (uchar) * q; + 3cf: 29 d8 sub %ebx,%eax +} + 3d1: 8b 5d fc mov -0x4(%ebp),%ebx + 3d4: c9 leave + 3d5: c3 ret + 3d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3dd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 3e0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 3e4: 31 c0 xor %eax,%eax + 3e6: 29 d8 sub %ebx,%eax +} + 3e8: 8b 5d fc mov -0x4(%ebp),%ebx + 3eb: c9 leave + 3ec: c3 ret + return (uchar) * p - (uchar) * q; + 3ed: 0f b6 19 movzbl (%ecx),%ebx + 3f0: 31 c0 xor %eax,%eax + 3f2: eb db jmp 3cf + 3f4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 3ff: 90 nop + +00000400 : + +uint strlen(const char *s) { + 400: 55 push %ebp + 401: 89 e5 mov %esp,%ebp + 403: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 406: 80 3a 00 cmpb $0x0,(%edx) + 409: 74 15 je 420 + 40b: 31 c0 xor %eax,%eax + 40d: 8d 76 00 lea 0x0(%esi),%esi + 410: 83 c0 01 add $0x1,%eax + 413: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 417: 89 c1 mov %eax,%ecx + 419: 75 f5 jne 410 + ; + } + return n; +} + 41b: 89 c8 mov %ecx,%eax + 41d: 5d pop %ebp + 41e: c3 ret + 41f: 90 nop + for (n = 0; s[n]; n++) { + 420: 31 c9 xor %ecx,%ecx +} + 422: 5d pop %ebp + 423: 89 c8 mov %ecx,%eax + 425: c3 ret + 426: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 42d: 8d 76 00 lea 0x0(%esi),%esi + +00000430 : + +void* memset(void *dst, int c, uint n) { + 430: 55 push %ebp + 431: 89 e5 mov %esp,%ebp + 433: 57 push %edi + 434: 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" : + 437: 8b 4d 10 mov 0x10(%ebp),%ecx + 43a: 8b 45 0c mov 0xc(%ebp),%eax + 43d: 89 d7 mov %edx,%edi + 43f: fc cld + 440: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 442: 8b 7d fc mov -0x4(%ebp),%edi + 445: 89 d0 mov %edx,%eax + 447: c9 leave + 448: c3 ret + 449: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000450 : + +char* strchr(const char *s, char c) { + 450: 55 push %ebp + 451: 89 e5 mov %esp,%ebp + 453: 8b 45 08 mov 0x8(%ebp),%eax + 456: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 45a: 0f b6 10 movzbl (%eax),%edx + 45d: 84 d2 test %dl,%dl + 45f: 75 12 jne 473 + 461: eb 1d jmp 480 + 463: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 467: 90 nop + 468: 0f b6 50 01 movzbl 0x1(%eax),%edx + 46c: 83 c0 01 add $0x1,%eax + 46f: 84 d2 test %dl,%dl + 471: 74 0d je 480 + if (*s == c) { + 473: 38 d1 cmp %dl,%cl + 475: 75 f1 jne 468 + return (char*)s; + } + } + return 0; +} + 477: 5d pop %ebp + 478: c3 ret + 479: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 480: 31 c0 xor %eax,%eax +} + 482: 5d pop %ebp + 483: c3 ret + 484: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 48b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 48f: 90 nop + +00000490 : + +char* gets(char *buf, int max) { + 490: 55 push %ebp + 491: 89 e5 mov %esp,%ebp + 493: 57 push %edi + 494: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 495: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 498: 53 push %ebx + for (i = 0; i + 1 < max;) { + 499: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 49b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 49e: eb 27 jmp 4c7 + cc = read(0, &c, 1); + 4a0: 83 ec 04 sub $0x4,%esp + 4a3: 6a 01 push $0x1 + 4a5: 57 push %edi + 4a6: 6a 00 push $0x0 + 4a8: e8 2e 01 00 00 call 5db + if (cc < 1) { + 4ad: 83 c4 10 add $0x10,%esp + 4b0: 85 c0 test %eax,%eax + 4b2: 7e 1d jle 4d1 + break; + } + buf[i++] = c; + 4b4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 4b8: 8b 55 08 mov 0x8(%ebp),%edx + 4bb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 4bf: 3c 0a cmp $0xa,%al + 4c1: 74 1d je 4e0 + 4c3: 3c 0d cmp $0xd,%al + 4c5: 74 19 je 4e0 + for (i = 0; i + 1 < max;) { + 4c7: 89 de mov %ebx,%esi + 4c9: 83 c3 01 add $0x1,%ebx + 4cc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 4cf: 7c cf jl 4a0 + break; + } + } + buf[i] = '\0'; + 4d1: 8b 45 08 mov 0x8(%ebp),%eax + 4d4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 4d8: 8d 65 f4 lea -0xc(%ebp),%esp + 4db: 5b pop %ebx + 4dc: 5e pop %esi + 4dd: 5f pop %edi + 4de: 5d pop %ebp + 4df: c3 ret + buf[i] = '\0'; + 4e0: 8b 45 08 mov 0x8(%ebp),%eax + 4e3: 89 de mov %ebx,%esi + 4e5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 4e9: 8d 65 f4 lea -0xc(%ebp),%esp + 4ec: 5b pop %ebx + 4ed: 5e pop %esi + 4ee: 5f pop %edi + 4ef: 5d pop %ebp + 4f0: c3 ret + 4f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4ff: 90 nop + +00000500 : + +int stat(const char *n, struct stat *st) { + 500: 55 push %ebp + 501: 89 e5 mov %esp,%ebp + 503: 56 push %esi + 504: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 505: 83 ec 08 sub $0x8,%esp + 508: 6a 00 push $0x0 + 50a: ff 75 08 push 0x8(%ebp) + 50d: e8 19 01 00 00 call 62b + if (fd < 0) { + 512: 83 c4 10 add $0x10,%esp + 515: 85 c0 test %eax,%eax + 517: 78 27 js 540 + return -1; + } + r = fstat(fd, st); + 519: 83 ec 08 sub $0x8,%esp + 51c: ff 75 0c push 0xc(%ebp) + 51f: 89 c3 mov %eax,%ebx + 521: 50 push %eax + 522: e8 cc 00 00 00 call 5f3 + close(fd); + 527: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 52a: 89 c6 mov %eax,%esi + close(fd); + 52c: e8 2a 01 00 00 call 65b + return r; + 531: 83 c4 10 add $0x10,%esp +} + 534: 8d 65 f8 lea -0x8(%ebp),%esp + 537: 89 f0 mov %esi,%eax + 539: 5b pop %ebx + 53a: 5e pop %esi + 53b: 5d pop %ebp + 53c: c3 ret + 53d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 540: be ff ff ff ff mov $0xffffffff,%esi + 545: eb ed jmp 534 + 547: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 54e: 66 90 xchg %ax,%ax + +00000550 : + +int atoi(const char *s) { + 550: 55 push %ebp + 551: 89 e5 mov %esp,%ebp + 553: 53 push %ebx + 554: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 557: 0f be 02 movsbl (%edx),%eax + 55a: 8d 48 d0 lea -0x30(%eax),%ecx + 55d: 80 f9 09 cmp $0x9,%cl + n = 0; + 560: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 565: 77 1e ja 585 + 567: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 56e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 570: 83 c2 01 add $0x1,%edx + 573: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 576: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 57a: 0f be 02 movsbl (%edx),%eax + 57d: 8d 58 d0 lea -0x30(%eax),%ebx + 580: 80 fb 09 cmp $0x9,%bl + 583: 76 eb jbe 570 + } + return n; +} + 585: 8b 5d fc mov -0x4(%ebp),%ebx + 588: 89 c8 mov %ecx,%eax + 58a: c9 leave + 58b: c3 ret + 58c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000590 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 590: 55 push %ebp + 591: 89 e5 mov %esp,%ebp + 593: 57 push %edi + 594: 8b 45 10 mov 0x10(%ebp),%eax + 597: 8b 55 08 mov 0x8(%ebp),%edx + 59a: 56 push %esi + 59b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 59e: 85 c0 test %eax,%eax + 5a0: 7e 13 jle 5b5 + 5a2: 01 d0 add %edx,%eax + dst = vdst; + 5a4: 89 d7 mov %edx,%edi + 5a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5ad: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 5b0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 5b1: 39 f8 cmp %edi,%eax + 5b3: 75 fb jne 5b0 + } + return vdst; +} + 5b5: 5e pop %esi + 5b6: 89 d0 mov %edx,%eax + 5b8: 5f pop %edi + 5b9: 5d pop %ebp + 5ba: c3 ret + +000005bb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 5bb: b8 01 00 00 00 mov $0x1,%eax + 5c0: cd 40 int $0x40 + 5c2: c3 ret + +000005c3 : +SYSCALL(exit) + 5c3: b8 02 00 00 00 mov $0x2,%eax + 5c8: cd 40 int $0x40 + 5ca: c3 ret + +000005cb : +SYSCALL(wait) + 5cb: b8 03 00 00 00 mov $0x3,%eax + 5d0: cd 40 int $0x40 + 5d2: c3 ret + +000005d3 : +SYSCALL(pipe) + 5d3: b8 04 00 00 00 mov $0x4,%eax + 5d8: cd 40 int $0x40 + 5da: c3 ret + +000005db : +SYSCALL(read) + 5db: b8 05 00 00 00 mov $0x5,%eax + 5e0: cd 40 int $0x40 + 5e2: c3 ret + +000005e3 : +SYSCALL(kill) + 5e3: b8 06 00 00 00 mov $0x6,%eax + 5e8: cd 40 int $0x40 + 5ea: c3 ret + +000005eb : +SYSCALL(exec) + 5eb: b8 07 00 00 00 mov $0x7,%eax + 5f0: cd 40 int $0x40 + 5f2: c3 ret + +000005f3 : +SYSCALL(fstat) + 5f3: b8 08 00 00 00 mov $0x8,%eax + 5f8: cd 40 int $0x40 + 5fa: c3 ret + +000005fb : +SYSCALL(chdir) + 5fb: b8 09 00 00 00 mov $0x9,%eax + 600: cd 40 int $0x40 + 602: c3 ret + +00000603 : +SYSCALL(dup) + 603: b8 0a 00 00 00 mov $0xa,%eax + 608: cd 40 int $0x40 + 60a: c3 ret + +0000060b : +SYSCALL(getpid) + 60b: b8 0b 00 00 00 mov $0xb,%eax + 610: cd 40 int $0x40 + 612: c3 ret + +00000613 : +SYSCALL(sbrk) + 613: b8 0c 00 00 00 mov $0xc,%eax + 618: cd 40 int $0x40 + 61a: c3 ret + +0000061b : +SYSCALL(sleep) + 61b: b8 0d 00 00 00 mov $0xd,%eax + 620: cd 40 int $0x40 + 622: c3 ret + +00000623 : +SYSCALL(uptime) + 623: b8 0e 00 00 00 mov $0xe,%eax + 628: cd 40 int $0x40 + 62a: c3 ret + +0000062b : +SYSCALL(open) + 62b: b8 0f 00 00 00 mov $0xf,%eax + 630: cd 40 int $0x40 + 632: c3 ret + +00000633 : +SYSCALL(write) + 633: b8 10 00 00 00 mov $0x10,%eax + 638: cd 40 int $0x40 + 63a: c3 ret + +0000063b : +SYSCALL(mknod) + 63b: b8 11 00 00 00 mov $0x11,%eax + 640: cd 40 int $0x40 + 642: c3 ret + +00000643 : +SYSCALL(unlink) + 643: b8 12 00 00 00 mov $0x12,%eax + 648: cd 40 int $0x40 + 64a: c3 ret + +0000064b : +SYSCALL(link) + 64b: b8 13 00 00 00 mov $0x13,%eax + 650: cd 40 int $0x40 + 652: c3 ret + +00000653 : +SYSCALL(mkdir) + 653: b8 14 00 00 00 mov $0x14,%eax + 658: cd 40 int $0x40 + 65a: c3 ret + +0000065b : +SYSCALL(close) + 65b: b8 15 00 00 00 mov $0x15,%eax + 660: cd 40 int $0x40 + 662: c3 ret + +00000663 : +SYSCALL(getch) + 663: b8 16 00 00 00 mov $0x16,%eax + 668: cd 40 int $0x40 + 66a: c3 ret + +0000066b : +SYSCALL(greeting) + 66b: b8 17 00 00 00 mov $0x17,%eax + 670: cd 40 int $0x40 + 672: c3 ret + +00000673 : +SYSCALL(shutdown) + 673: b8 18 00 00 00 mov $0x18,%eax + 678: cd 40 int $0x40 + 67a: c3 ret + +0000067b : +SYSCALL(screen) + 67b: b8 19 00 00 00 mov $0x19,%eax + 680: cd 40 int $0x40 + 682: c3 ret + +00000683 : +SYSCALL(cls) + 683: b8 1a 00 00 00 mov $0x1a,%eax + 688: cd 40 int $0x40 + 68a: c3 ret + 68b: 66 90 xchg %ax,%ax + 68d: 66 90 xchg %ax,%ax + 68f: 90 nop + +00000690 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 690: 55 push %ebp + 691: 89 e5 mov %esp,%ebp + 693: 57 push %edi + 694: 56 push %esi + 695: 53 push %ebx + 696: 83 ec 3c sub $0x3c,%esp + 699: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 69c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 69e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 6a1: 85 d2 test %edx,%edx + 6a3: 0f 89 7f 00 00 00 jns 728 + 6a9: f6 45 08 01 testb $0x1,0x8(%ebp) + 6ad: 74 79 je 728 + neg = 1; + 6af: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 6b6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 6b8: 31 db xor %ebx,%ebx + 6ba: 8d 75 d7 lea -0x29(%ebp),%esi + 6bd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 6c0: 89 c8 mov %ecx,%eax + 6c2: 31 d2 xor %edx,%edx + 6c4: 89 cf mov %ecx,%edi + 6c6: f7 75 c4 divl -0x3c(%ebp) + 6c9: 0f b6 92 00 0b 00 00 movzbl 0xb00(%edx),%edx + 6d0: 89 45 c0 mov %eax,-0x40(%ebp) + 6d3: 89 d8 mov %ebx,%eax + 6d5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 6d8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 6db: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 6de: 39 7d c4 cmp %edi,-0x3c(%ebp) + 6e1: 76 dd jbe 6c0 + if (neg) { + 6e3: 8b 4d bc mov -0x44(%ebp),%ecx + 6e6: 85 c9 test %ecx,%ecx + 6e8: 74 0c je 6f6 + buf[i++] = '-'; + 6ea: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 6ef: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 6f1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 6f6: 8b 7d b8 mov -0x48(%ebp),%edi + 6f9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 6fd: eb 07 jmp 706 + 6ff: 90 nop + putc(fd, buf[i]); + 700: 0f b6 13 movzbl (%ebx),%edx + 703: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 706: 83 ec 04 sub $0x4,%esp + 709: 88 55 d7 mov %dl,-0x29(%ebp) + 70c: 6a 01 push $0x1 + 70e: 56 push %esi + 70f: 57 push %edi + 710: e8 1e ff ff ff call 633 + while (--i >= 0) { + 715: 83 c4 10 add $0x10,%esp + 718: 39 de cmp %ebx,%esi + 71a: 75 e4 jne 700 + } +} + 71c: 8d 65 f4 lea -0xc(%ebp),%esp + 71f: 5b pop %ebx + 720: 5e pop %esi + 721: 5f pop %edi + 722: 5d pop %ebp + 723: c3 ret + 724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 728: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 72f: eb 87 jmp 6b8 + 731: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 738: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 73f: 90 nop + +00000740 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 740: 55 push %ebp + 741: 89 e5 mov %esp,%ebp + 743: 57 push %edi + 744: 56 push %esi + 745: 53 push %ebx + 746: 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++) { + 749: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 74c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 74f: 0f b6 13 movzbl (%ebx),%edx + 752: 84 d2 test %dl,%dl + 754: 74 6a je 7c0 + ap = (uint*)(void*)&fmt + 1; + 756: 8d 45 10 lea 0x10(%ebp),%eax + 759: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 75c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 75f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 761: 89 45 d0 mov %eax,-0x30(%ebp) + 764: eb 36 jmp 79c + 766: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 76d: 8d 76 00 lea 0x0(%esi),%esi + 770: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 773: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 778: 83 f8 25 cmp $0x25,%eax + 77b: 74 15 je 792 + write(fd, &c, 1); + 77d: 83 ec 04 sub $0x4,%esp + 780: 88 55 e7 mov %dl,-0x19(%ebp) + 783: 6a 01 push $0x1 + 785: 57 push %edi + 786: 56 push %esi + 787: e8 a7 fe ff ff call 633 + 78c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 78f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 792: 0f b6 13 movzbl (%ebx),%edx + 795: 83 c3 01 add $0x1,%ebx + 798: 84 d2 test %dl,%dl + 79a: 74 24 je 7c0 + c = fmt[i] & 0xff; + 79c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 79f: 85 c9 test %ecx,%ecx + 7a1: 74 cd je 770 + } + } + else if (state == '%') { + 7a3: 83 f9 25 cmp $0x25,%ecx + 7a6: 75 ea jne 792 + if (c == 'd') { + 7a8: 83 f8 25 cmp $0x25,%eax + 7ab: 0f 84 07 01 00 00 je 8b8 + 7b1: 83 e8 63 sub $0x63,%eax + 7b4: 83 f8 15 cmp $0x15,%eax + 7b7: 77 17 ja 7d0 + 7b9: ff 24 85 a8 0a 00 00 jmp *0xaa8(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 7c0: 8d 65 f4 lea -0xc(%ebp),%esp + 7c3: 5b pop %ebx + 7c4: 5e pop %esi + 7c5: 5f pop %edi + 7c6: 5d pop %ebp + 7c7: c3 ret + 7c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 7cf: 90 nop + write(fd, &c, 1); + 7d0: 83 ec 04 sub $0x4,%esp + 7d3: 88 55 d4 mov %dl,-0x2c(%ebp) + 7d6: 6a 01 push $0x1 + 7d8: 57 push %edi + 7d9: 56 push %esi + 7da: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 7de: e8 50 fe ff ff call 633 + putc(fd, c); + 7e3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 7e7: 83 c4 0c add $0xc,%esp + 7ea: 88 55 e7 mov %dl,-0x19(%ebp) + 7ed: 6a 01 push $0x1 + 7ef: 57 push %edi + 7f0: 56 push %esi + 7f1: e8 3d fe ff ff call 633 + putc(fd, c); + 7f6: 83 c4 10 add $0x10,%esp + state = 0; + 7f9: 31 c9 xor %ecx,%ecx + 7fb: eb 95 jmp 792 + 7fd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 800: 83 ec 0c sub $0xc,%esp + 803: b9 10 00 00 00 mov $0x10,%ecx + 808: 6a 00 push $0x0 + 80a: 8b 45 d0 mov -0x30(%ebp),%eax + 80d: 8b 10 mov (%eax),%edx + 80f: 89 f0 mov %esi,%eax + 811: e8 7a fe ff ff call 690 + ap++; + 816: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 81a: 83 c4 10 add $0x10,%esp + state = 0; + 81d: 31 c9 xor %ecx,%ecx + 81f: e9 6e ff ff ff jmp 792 + 824: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 828: 8b 45 d0 mov -0x30(%ebp),%eax + 82b: 8b 10 mov (%eax),%edx + ap++; + 82d: 83 c0 04 add $0x4,%eax + 830: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 833: 85 d2 test %edx,%edx + 835: 0f 84 8d 00 00 00 je 8c8 + while (*s != 0) { + 83b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 83e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 840: 84 c0 test %al,%al + 842: 0f 84 4a ff ff ff je 792 + 848: 89 5d d4 mov %ebx,-0x2c(%ebp) + 84b: 89 d3 mov %edx,%ebx + 84d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 850: 83 ec 04 sub $0x4,%esp + s++; + 853: 83 c3 01 add $0x1,%ebx + 856: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 859: 6a 01 push $0x1 + 85b: 57 push %edi + 85c: 56 push %esi + 85d: e8 d1 fd ff ff call 633 + while (*s != 0) { + 862: 0f b6 03 movzbl (%ebx),%eax + 865: 83 c4 10 add $0x10,%esp + 868: 84 c0 test %al,%al + 86a: 75 e4 jne 850 + state = 0; + 86c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 86f: 31 c9 xor %ecx,%ecx + 871: e9 1c ff ff ff jmp 792 + 876: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 87d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 880: 83 ec 0c sub $0xc,%esp + 883: b9 0a 00 00 00 mov $0xa,%ecx + 888: 6a 01 push $0x1 + 88a: e9 7b ff ff ff jmp 80a + 88f: 90 nop + putc(fd, *ap); + 890: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 893: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 896: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 898: 6a 01 push $0x1 + 89a: 57 push %edi + 89b: 56 push %esi + putc(fd, *ap); + 89c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 89f: e8 8f fd ff ff call 633 + ap++; + 8a4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 8a8: 83 c4 10 add $0x10,%esp + state = 0; + 8ab: 31 c9 xor %ecx,%ecx + 8ad: e9 e0 fe ff ff jmp 792 + 8b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 8b8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 8bb: 83 ec 04 sub $0x4,%esp + 8be: e9 2a ff ff ff jmp 7ed + 8c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 8c7: 90 nop + s = "(null)"; + 8c8: ba 9e 0a 00 00 mov $0xa9e,%edx + while (*s != 0) { + 8cd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 8d0: b8 28 00 00 00 mov $0x28,%eax + 8d5: 89 d3 mov %edx,%ebx + 8d7: e9 74 ff ff ff jmp 850 + 8dc: 66 90 xchg %ax,%ax + 8de: 66 90 xchg %ax,%ax + +000008e0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 8e0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 8e1: a1 a0 12 00 00 mov 0x12a0,%eax +void free(void *ap) { + 8e6: 89 e5 mov %esp,%ebp + 8e8: 57 push %edi + 8e9: 56 push %esi + 8ea: 53 push %ebx + 8eb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 8ee: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 8f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 8f8: 89 c2 mov %eax,%edx + 8fa: 8b 00 mov (%eax),%eax + 8fc: 39 ca cmp %ecx,%edx + 8fe: 73 30 jae 930 + 900: 39 c1 cmp %eax,%ecx + 902: 72 04 jb 908 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 904: 39 c2 cmp %eax,%edx + 906: 72 f0 jb 8f8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 908: 8b 73 fc mov -0x4(%ebx),%esi + 90b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 90e: 39 f8 cmp %edi,%eax + 910: 74 30 je 942 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 912: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 915: 8b 42 04 mov 0x4(%edx),%eax + 918: 8d 34 c2 lea (%edx,%eax,8),%esi + 91b: 39 f1 cmp %esi,%ecx + 91d: 74 3a je 959 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 91f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 921: 5b pop %ebx + freep = p; + 922: 89 15 a0 12 00 00 mov %edx,0x12a0 +} + 928: 5e pop %esi + 929: 5f pop %edi + 92a: 5d pop %ebp + 92b: c3 ret + 92c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 930: 39 c2 cmp %eax,%edx + 932: 72 c4 jb 8f8 + 934: 39 c1 cmp %eax,%ecx + 936: 73 c0 jae 8f8 + if (bp + bp->s.size == p->s.ptr) { + 938: 8b 73 fc mov -0x4(%ebx),%esi + 93b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 93e: 39 f8 cmp %edi,%eax + 940: 75 d0 jne 912 + bp->s.size += p->s.ptr->s.size; + 942: 03 70 04 add 0x4(%eax),%esi + 945: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 948: 8b 02 mov (%edx),%eax + 94a: 8b 00 mov (%eax),%eax + 94c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 94f: 8b 42 04 mov 0x4(%edx),%eax + 952: 8d 34 c2 lea (%edx,%eax,8),%esi + 955: 39 f1 cmp %esi,%ecx + 957: 75 c6 jne 91f + p->s.size += bp->s.size; + 959: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 95c: 89 15 a0 12 00 00 mov %edx,0x12a0 + p->s.size += bp->s.size; + 962: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 965: 8b 4b f8 mov -0x8(%ebx),%ecx + 968: 89 0a mov %ecx,(%edx) +} + 96a: 5b pop %ebx + 96b: 5e pop %esi + 96c: 5f pop %edi + 96d: 5d pop %ebp + 96e: c3 ret + 96f: 90 nop + +00000970 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 970: 55 push %ebp + 971: 89 e5 mov %esp,%ebp + 973: 57 push %edi + 974: 56 push %esi + 975: 53 push %ebx + 976: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 979: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 97c: 8b 3d a0 12 00 00 mov 0x12a0,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 982: 8d 70 07 lea 0x7(%eax),%esi + 985: c1 ee 03 shr $0x3,%esi + 988: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 98b: 85 ff test %edi,%edi + 98d: 0f 84 9d 00 00 00 je a30 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 993: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 995: 8b 4a 04 mov 0x4(%edx),%ecx + 998: 39 f1 cmp %esi,%ecx + 99a: 73 6a jae a06 + 99c: bb 00 10 00 00 mov $0x1000,%ebx + 9a1: 39 de cmp %ebx,%esi + 9a3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 9a6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 9ad: 89 45 e4 mov %eax,-0x1c(%ebp) + 9b0: eb 17 jmp 9c9 + 9b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 9b8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 9ba: 8b 48 04 mov 0x4(%eax),%ecx + 9bd: 39 f1 cmp %esi,%ecx + 9bf: 73 4f jae a10 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 9c1: 8b 3d a0 12 00 00 mov 0x12a0,%edi + 9c7: 89 c2 mov %eax,%edx + 9c9: 39 d7 cmp %edx,%edi + 9cb: 75 eb jne 9b8 + p = sbrk(nu * sizeof(Header)); + 9cd: 83 ec 0c sub $0xc,%esp + 9d0: ff 75 e4 push -0x1c(%ebp) + 9d3: e8 3b fc ff ff call 613 + if (p == (char*)-1) { + 9d8: 83 c4 10 add $0x10,%esp + 9db: 83 f8 ff cmp $0xffffffff,%eax + 9de: 74 1c je 9fc + hp->s.size = nu; + 9e0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 9e3: 83 ec 0c sub $0xc,%esp + 9e6: 83 c0 08 add $0x8,%eax + 9e9: 50 push %eax + 9ea: e8 f1 fe ff ff call 8e0 + return freep; + 9ef: 8b 15 a0 12 00 00 mov 0x12a0,%edx + if ((p = morecore(nunits)) == 0) { + 9f5: 83 c4 10 add $0x10,%esp + 9f8: 85 d2 test %edx,%edx + 9fa: 75 bc jne 9b8 + return 0; + } + } + } +} + 9fc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 9ff: 31 c0 xor %eax,%eax +} + a01: 5b pop %ebx + a02: 5e pop %esi + a03: 5f pop %edi + a04: 5d pop %ebp + a05: c3 ret + if (p->s.size >= nunits) { + a06: 89 d0 mov %edx,%eax + a08: 89 fa mov %edi,%edx + a0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + a10: 39 ce cmp %ecx,%esi + a12: 74 4c je a60 + p->s.size -= nunits; + a14: 29 f1 sub %esi,%ecx + a16: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + a19: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + a1c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + a1f: 89 15 a0 12 00 00 mov %edx,0x12a0 +} + a25: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + a28: 83 c0 08 add $0x8,%eax +} + a2b: 5b pop %ebx + a2c: 5e pop %esi + a2d: 5f pop %edi + a2e: 5d pop %ebp + a2f: c3 ret + base.s.ptr = freep = prevp = &base; + a30: c7 05 a0 12 00 00 a4 movl $0x12a4,0x12a0 + a37: 12 00 00 + base.s.size = 0; + a3a: bf a4 12 00 00 mov $0x12a4,%edi + base.s.ptr = freep = prevp = &base; + a3f: c7 05 a4 12 00 00 a4 movl $0x12a4,0x12a4 + a46: 12 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + a49: 89 fa mov %edi,%edx + base.s.size = 0; + a4b: c7 05 a8 12 00 00 00 movl $0x0,0x12a8 + a52: 00 00 00 + if (p->s.size >= nunits) { + a55: e9 42 ff ff ff jmp 99c + a5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + a60: 8b 08 mov (%eax),%ecx + a62: 89 0a mov %ecx,(%edx) + a64: eb b9 jmp a1f diff --git a/grep.d b/grep.d new file mode 100644 index 0000000..15fc65b --- /dev/null +++ b/grep.d @@ -0,0 +1 @@ +grep.o: grep.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/grep.o b/grep.o new file mode 100644 index 0000000..33f12c9 Binary files /dev/null and b/grep.o differ diff --git a/grep.sym b/grep.sym new file mode 100644 index 0000000..63f5928 --- /dev/null +++ b/grep.sym @@ -0,0 +1,55 @@ +00000000 grep.c +00000000 ulib.c +00000000 printf.c +00000690 printint +00000b00 digits.0 +00000000 umalloc.c +000012a0 freep +000012a4 base +00000370 strcpy +00000740 printf +0000066b greeting +00000590 memmove +000000c0 matchhere +0000063b mknod +00000490 gets +0000060b getpid +0000067b screen +000001d0 grep +00000970 malloc +0000061b sleep +000005d3 pipe +00000663 getch +00000633 write +000005f3 fstat +000005e3 kill +000005fb chdir +000005eb exec +000005cb wait +000005db read +00000643 unlink +000005bb fork +00000613 sbrk +00000623 uptime +00000ea0 __bss_start +00000430 memset +00000000 main +00000310 matchstar +000003a0 strcmp +00000673 shutdown +00000603 dup +00000ea0 buf +00000500 stat +00000ea0 _edata +000012ac _end +00000170 match +0000064b link +000005c3 exit +00000550 atoi +00000683 cls +00000400 strlen +0000062b open +00000450 strchr +00000653 mkdir +0000065b close +000008e0 free diff --git a/hello.asm b/hello.asm new file mode 100644 index 0000000..d44c5ad --- /dev/null +++ b/hello.asm @@ -0,0 +1,1189 @@ + +_hello: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "user.h" + +// User app that was from one of the tutorial but i have since changed it to provide useful information about the current process and console +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: 51 push %ecx + 11: 83 ec 08 sub $0x8,%esp + 14: 8b 31 mov (%ecx),%esi + 16: 8b 79 04 mov 0x4(%ecx),%edi + + for (int i = 1; i < argc; i++) { + 19: 83 fe 01 cmp $0x1,%esi + 1c: 7e 3b jle 59 + 1e: bb 01 00 00 00 mov $0x1,%ebx + 23: eb 0a jmp 2f + 25: 8d 76 00 lea 0x0(%esi),%esi + 28: 83 c3 01 add $0x1,%ebx + 2b: 39 de cmp %ebx,%esi + 2d: 74 2a je 59 + if (strcmp(argv[i], "-help") == 0) + 2f: 83 ec 08 sub $0x8,%esp + 32: 68 68 07 00 00 push $0x768 + 37: ff 34 9f push (%edi,%ebx,4) + 3a: e8 61 00 00 00 call a0 + 3f: 83 c4 10 add $0x10,%esp + 42: 85 c0 test %eax,%eax + 44: 75 e2 jne 28 + { + printf(1, "Does a system call that returns the current process and console information, used for debugging.\n"); + 46: 50 push %eax + 47: 50 push %eax + 48: 68 70 07 00 00 push $0x770 + 4d: 6a 01 push $0x1 + 4f: e8 ec 03 00 00 call 440 + exit(); + 54: e8 6a 02 00 00 call 2c3 + return 0; + } + } + + greeting(); + 59: e8 0d 03 00 00 call 36b + exit(); + 5e: e8 60 02 00 00 call 2c3 + 63: 66 90 xchg %ax,%ax + 65: 66 90 xchg %ax,%ax + 67: 66 90 xchg %ax,%ax + 69: 66 90 xchg %ax,%ax + 6b: 66 90 xchg %ax,%ax + 6d: 66 90 xchg %ax,%ax + 6f: 90 nop + +00000070 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 70: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 71: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 73: 89 e5 mov %esp,%ebp + 75: 53 push %ebx + 76: 8b 4d 08 mov 0x8(%ebp),%ecx + 79: 8b 5d 0c mov 0xc(%ebp),%ebx + 7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 80: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 84: 88 14 01 mov %dl,(%ecx,%eax,1) + 87: 83 c0 01 add $0x1,%eax + 8a: 84 d2 test %dl,%dl + 8c: 75 f2 jne 80 + ; + } + return os; +} + 8e: 8b 5d fc mov -0x4(%ebp),%ebx + 91: 89 c8 mov %ecx,%eax + 93: c9 leave + 94: c3 ret + 95: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000000a0 : + +int strcmp(const char *p, const char *q) { + a0: 55 push %ebp + a1: 89 e5 mov %esp,%ebp + a3: 53 push %ebx + a4: 8b 55 08 mov 0x8(%ebp),%edx + a7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + aa: 0f b6 02 movzbl (%edx),%eax + ad: 84 c0 test %al,%al + af: 75 17 jne c8 + b1: eb 3a jmp ed + b3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + b7: 90 nop + b8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + bc: 83 c2 01 add $0x1,%edx + bf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + c2: 84 c0 test %al,%al + c4: 74 1a je e0 + p++, q++; + c6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + c8: 0f b6 19 movzbl (%ecx),%ebx + cb: 38 c3 cmp %al,%bl + cd: 74 e9 je b8 + } + return (uchar) * p - (uchar) * q; + cf: 29 d8 sub %ebx,%eax +} + d1: 8b 5d fc mov -0x4(%ebp),%ebx + d4: c9 leave + d5: c3 ret + d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + dd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + e0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + e4: 31 c0 xor %eax,%eax + e6: 29 d8 sub %ebx,%eax +} + e8: 8b 5d fc mov -0x4(%ebp),%ebx + eb: c9 leave + ec: c3 ret + return (uchar) * p - (uchar) * q; + ed: 0f b6 19 movzbl (%ecx),%ebx + f0: 31 c0 xor %eax,%eax + f2: eb db jmp cf + f4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ff: 90 nop + +00000100 : + +uint strlen(const char *s) { + 100: 55 push %ebp + 101: 89 e5 mov %esp,%ebp + 103: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 106: 80 3a 00 cmpb $0x0,(%edx) + 109: 74 15 je 120 + 10b: 31 c0 xor %eax,%eax + 10d: 8d 76 00 lea 0x0(%esi),%esi + 110: 83 c0 01 add $0x1,%eax + 113: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 117: 89 c1 mov %eax,%ecx + 119: 75 f5 jne 110 + ; + } + return n; +} + 11b: 89 c8 mov %ecx,%eax + 11d: 5d pop %ebp + 11e: c3 ret + 11f: 90 nop + for (n = 0; s[n]; n++) { + 120: 31 c9 xor %ecx,%ecx +} + 122: 5d pop %ebp + 123: 89 c8 mov %ecx,%eax + 125: c3 ret + 126: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 12d: 8d 76 00 lea 0x0(%esi),%esi + +00000130 : + +void* memset(void *dst, int c, uint n) { + 130: 55 push %ebp + 131: 89 e5 mov %esp,%ebp + 133: 57 push %edi + 134: 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" : + 137: 8b 4d 10 mov 0x10(%ebp),%ecx + 13a: 8b 45 0c mov 0xc(%ebp),%eax + 13d: 89 d7 mov %edx,%edi + 13f: fc cld + 140: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 142: 8b 7d fc mov -0x4(%ebp),%edi + 145: 89 d0 mov %edx,%eax + 147: c9 leave + 148: c3 ret + 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000150 : + +char* strchr(const char *s, char c) { + 150: 55 push %ebp + 151: 89 e5 mov %esp,%ebp + 153: 8b 45 08 mov 0x8(%ebp),%eax + 156: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 15a: 0f b6 10 movzbl (%eax),%edx + 15d: 84 d2 test %dl,%dl + 15f: 75 12 jne 173 + 161: eb 1d jmp 180 + 163: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 167: 90 nop + 168: 0f b6 50 01 movzbl 0x1(%eax),%edx + 16c: 83 c0 01 add $0x1,%eax + 16f: 84 d2 test %dl,%dl + 171: 74 0d je 180 + if (*s == c) { + 173: 38 d1 cmp %dl,%cl + 175: 75 f1 jne 168 + return (char*)s; + } + } + return 0; +} + 177: 5d pop %ebp + 178: c3 ret + 179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 180: 31 c0 xor %eax,%eax +} + 182: 5d pop %ebp + 183: c3 ret + 184: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 18b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 18f: 90 nop + +00000190 : + +char* gets(char *buf, int max) { + 190: 55 push %ebp + 191: 89 e5 mov %esp,%ebp + 193: 57 push %edi + 194: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 195: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 198: 53 push %ebx + for (i = 0; i + 1 < max;) { + 199: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 19b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 19e: eb 27 jmp 1c7 + cc = read(0, &c, 1); + 1a0: 83 ec 04 sub $0x4,%esp + 1a3: 6a 01 push $0x1 + 1a5: 57 push %edi + 1a6: 6a 00 push $0x0 + 1a8: e8 2e 01 00 00 call 2db + if (cc < 1) { + 1ad: 83 c4 10 add $0x10,%esp + 1b0: 85 c0 test %eax,%eax + 1b2: 7e 1d jle 1d1 + break; + } + buf[i++] = c; + 1b4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1b8: 8b 55 08 mov 0x8(%ebp),%edx + 1bb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1bf: 3c 0a cmp $0xa,%al + 1c1: 74 1d je 1e0 + 1c3: 3c 0d cmp $0xd,%al + 1c5: 74 19 je 1e0 + for (i = 0; i + 1 < max;) { + 1c7: 89 de mov %ebx,%esi + 1c9: 83 c3 01 add $0x1,%ebx + 1cc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1cf: 7c cf jl 1a0 + break; + } + } + buf[i] = '\0'; + 1d1: 8b 45 08 mov 0x8(%ebp),%eax + 1d4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1d8: 8d 65 f4 lea -0xc(%ebp),%esp + 1db: 5b pop %ebx + 1dc: 5e pop %esi + 1dd: 5f pop %edi + 1de: 5d pop %ebp + 1df: c3 ret + buf[i] = '\0'; + 1e0: 8b 45 08 mov 0x8(%ebp),%eax + 1e3: 89 de mov %ebx,%esi + 1e5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1e9: 8d 65 f4 lea -0xc(%ebp),%esp + 1ec: 5b pop %ebx + 1ed: 5e pop %esi + 1ee: 5f pop %edi + 1ef: 5d pop %ebp + 1f0: c3 ret + 1f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ff: 90 nop + +00000200 : + +int stat(const char *n, struct stat *st) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 56 push %esi + 204: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 205: 83 ec 08 sub $0x8,%esp + 208: 6a 00 push $0x0 + 20a: ff 75 08 push 0x8(%ebp) + 20d: e8 19 01 00 00 call 32b + if (fd < 0) { + 212: 83 c4 10 add $0x10,%esp + 215: 85 c0 test %eax,%eax + 217: 78 27 js 240 + return -1; + } + r = fstat(fd, st); + 219: 83 ec 08 sub $0x8,%esp + 21c: ff 75 0c push 0xc(%ebp) + 21f: 89 c3 mov %eax,%ebx + 221: 50 push %eax + 222: e8 cc 00 00 00 call 2f3 + close(fd); + 227: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 22a: 89 c6 mov %eax,%esi + close(fd); + 22c: e8 2a 01 00 00 call 35b + return r; + 231: 83 c4 10 add $0x10,%esp +} + 234: 8d 65 f8 lea -0x8(%ebp),%esp + 237: 89 f0 mov %esi,%eax + 239: 5b pop %ebx + 23a: 5e pop %esi + 23b: 5d pop %ebp + 23c: c3 ret + 23d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 240: be ff ff ff ff mov $0xffffffff,%esi + 245: eb ed jmp 234 + 247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 24e: 66 90 xchg %ax,%ax + +00000250 : + +int atoi(const char *s) { + 250: 55 push %ebp + 251: 89 e5 mov %esp,%ebp + 253: 53 push %ebx + 254: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 257: 0f be 02 movsbl (%edx),%eax + 25a: 8d 48 d0 lea -0x30(%eax),%ecx + 25d: 80 f9 09 cmp $0x9,%cl + n = 0; + 260: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 265: 77 1e ja 285 + 267: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 270: 83 c2 01 add $0x1,%edx + 273: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 276: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 27a: 0f be 02 movsbl (%edx),%eax + 27d: 8d 58 d0 lea -0x30(%eax),%ebx + 280: 80 fb 09 cmp $0x9,%bl + 283: 76 eb jbe 270 + } + return n; +} + 285: 8b 5d fc mov -0x4(%ebp),%ebx + 288: 89 c8 mov %ecx,%eax + 28a: c9 leave + 28b: c3 ret + 28c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000290 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 290: 55 push %ebp + 291: 89 e5 mov %esp,%ebp + 293: 57 push %edi + 294: 8b 45 10 mov 0x10(%ebp),%eax + 297: 8b 55 08 mov 0x8(%ebp),%edx + 29a: 56 push %esi + 29b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 29e: 85 c0 test %eax,%eax + 2a0: 7e 13 jle 2b5 + 2a2: 01 d0 add %edx,%eax + dst = vdst; + 2a4: 89 d7 mov %edx,%edi + 2a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2ad: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2b0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2b1: 39 f8 cmp %edi,%eax + 2b3: 75 fb jne 2b0 + } + return vdst; +} + 2b5: 5e pop %esi + 2b6: 89 d0 mov %edx,%eax + 2b8: 5f pop %edi + 2b9: 5d pop %ebp + 2ba: c3 ret + +000002bb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2bb: b8 01 00 00 00 mov $0x1,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(exit) + 2c3: b8 02 00 00 00 mov $0x2,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(wait) + 2cb: b8 03 00 00 00 mov $0x3,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(pipe) + 2d3: b8 04 00 00 00 mov $0x4,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(read) + 2db: b8 05 00 00 00 mov $0x5,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(kill) + 2e3: b8 06 00 00 00 mov $0x6,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(exec) + 2eb: b8 07 00 00 00 mov $0x7,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(fstat) + 2f3: b8 08 00 00 00 mov $0x8,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(chdir) + 2fb: b8 09 00 00 00 mov $0x9,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(dup) + 303: b8 0a 00 00 00 mov $0xa,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(getpid) + 30b: b8 0b 00 00 00 mov $0xb,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(sbrk) + 313: b8 0c 00 00 00 mov $0xc,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(sleep) + 31b: b8 0d 00 00 00 mov $0xd,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(uptime) + 323: b8 0e 00 00 00 mov $0xe,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(open) + 32b: b8 0f 00 00 00 mov $0xf,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(write) + 333: b8 10 00 00 00 mov $0x10,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(mknod) + 33b: b8 11 00 00 00 mov $0x11,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(unlink) + 343: b8 12 00 00 00 mov $0x12,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(link) + 34b: b8 13 00 00 00 mov $0x13,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(mkdir) + 353: b8 14 00 00 00 mov $0x14,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(close) + 35b: b8 15 00 00 00 mov $0x15,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(getch) + 363: b8 16 00 00 00 mov $0x16,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(greeting) + 36b: b8 17 00 00 00 mov $0x17,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(shutdown) + 373: b8 18 00 00 00 mov $0x18,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(screen) + 37b: b8 19 00 00 00 mov $0x19,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(cls) + 383: b8 1a 00 00 00 mov $0x1a,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + 38b: 66 90 xchg %ax,%ax + 38d: 66 90 xchg %ax,%ax + 38f: 90 nop + +00000390 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 390: 55 push %ebp + 391: 89 e5 mov %esp,%ebp + 393: 57 push %edi + 394: 56 push %esi + 395: 53 push %ebx + 396: 83 ec 3c sub $0x3c,%esp + 399: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 39c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 39e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 3a1: 85 d2 test %edx,%edx + 3a3: 0f 89 7f 00 00 00 jns 428 + 3a9: f6 45 08 01 testb $0x1,0x8(%ebp) + 3ad: 74 79 je 428 + neg = 1; + 3af: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3b6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3b8: 31 db xor %ebx,%ebx + 3ba: 8d 75 d7 lea -0x29(%ebp),%esi + 3bd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3c0: 89 c8 mov %ecx,%eax + 3c2: 31 d2 xor %edx,%edx + 3c4: 89 cf mov %ecx,%edi + 3c6: f7 75 c4 divl -0x3c(%ebp) + 3c9: 0f b6 92 34 08 00 00 movzbl 0x834(%edx),%edx + 3d0: 89 45 c0 mov %eax,-0x40(%ebp) + 3d3: 89 d8 mov %ebx,%eax + 3d5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3d8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3db: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3de: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3e1: 76 dd jbe 3c0 + if (neg) { + 3e3: 8b 4d bc mov -0x44(%ebp),%ecx + 3e6: 85 c9 test %ecx,%ecx + 3e8: 74 0c je 3f6 + buf[i++] = '-'; + 3ea: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3ef: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3f1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3f6: 8b 7d b8 mov -0x48(%ebp),%edi + 3f9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3fd: eb 07 jmp 406 + 3ff: 90 nop + putc(fd, buf[i]); + 400: 0f b6 13 movzbl (%ebx),%edx + 403: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 406: 83 ec 04 sub $0x4,%esp + 409: 88 55 d7 mov %dl,-0x29(%ebp) + 40c: 6a 01 push $0x1 + 40e: 56 push %esi + 40f: 57 push %edi + 410: e8 1e ff ff ff call 333 + while (--i >= 0) { + 415: 83 c4 10 add $0x10,%esp + 418: 39 de cmp %ebx,%esi + 41a: 75 e4 jne 400 + } +} + 41c: 8d 65 f4 lea -0xc(%ebp),%esp + 41f: 5b pop %ebx + 420: 5e pop %esi + 421: 5f pop %edi + 422: 5d pop %ebp + 423: c3 ret + 424: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 428: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 42f: eb 87 jmp 3b8 + 431: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 438: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 43f: 90 nop + +00000440 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 440: 55 push %ebp + 441: 89 e5 mov %esp,%ebp + 443: 57 push %edi + 444: 56 push %esi + 445: 53 push %ebx + 446: 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++) { + 449: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 44c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 44f: 0f b6 13 movzbl (%ebx),%edx + 452: 84 d2 test %dl,%dl + 454: 74 6a je 4c0 + ap = (uint*)(void*)&fmt + 1; + 456: 8d 45 10 lea 0x10(%ebp),%eax + 459: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 45c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 45f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 461: 89 45 d0 mov %eax,-0x30(%ebp) + 464: eb 36 jmp 49c + 466: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 46d: 8d 76 00 lea 0x0(%esi),%esi + 470: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 473: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 478: 83 f8 25 cmp $0x25,%eax + 47b: 74 15 je 492 + write(fd, &c, 1); + 47d: 83 ec 04 sub $0x4,%esp + 480: 88 55 e7 mov %dl,-0x19(%ebp) + 483: 6a 01 push $0x1 + 485: 57 push %edi + 486: 56 push %esi + 487: e8 a7 fe ff ff call 333 + 48c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 48f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 492: 0f b6 13 movzbl (%ebx),%edx + 495: 83 c3 01 add $0x1,%ebx + 498: 84 d2 test %dl,%dl + 49a: 74 24 je 4c0 + c = fmt[i] & 0xff; + 49c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 49f: 85 c9 test %ecx,%ecx + 4a1: 74 cd je 470 + } + } + else if (state == '%') { + 4a3: 83 f9 25 cmp $0x25,%ecx + 4a6: 75 ea jne 492 + if (c == 'd') { + 4a8: 83 f8 25 cmp $0x25,%eax + 4ab: 0f 84 07 01 00 00 je 5b8 + 4b1: 83 e8 63 sub $0x63,%eax + 4b4: 83 f8 15 cmp $0x15,%eax + 4b7: 77 17 ja 4d0 + 4b9: ff 24 85 dc 07 00 00 jmp *0x7dc(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4c0: 8d 65 f4 lea -0xc(%ebp),%esp + 4c3: 5b pop %ebx + 4c4: 5e pop %esi + 4c5: 5f pop %edi + 4c6: 5d pop %ebp + 4c7: c3 ret + 4c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4cf: 90 nop + write(fd, &c, 1); + 4d0: 83 ec 04 sub $0x4,%esp + 4d3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4d6: 6a 01 push $0x1 + 4d8: 57 push %edi + 4d9: 56 push %esi + 4da: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4de: e8 50 fe ff ff call 333 + putc(fd, c); + 4e3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4e7: 83 c4 0c add $0xc,%esp + 4ea: 88 55 e7 mov %dl,-0x19(%ebp) + 4ed: 6a 01 push $0x1 + 4ef: 57 push %edi + 4f0: 56 push %esi + 4f1: e8 3d fe ff ff call 333 + putc(fd, c); + 4f6: 83 c4 10 add $0x10,%esp + state = 0; + 4f9: 31 c9 xor %ecx,%ecx + 4fb: eb 95 jmp 492 + 4fd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 500: 83 ec 0c sub $0xc,%esp + 503: b9 10 00 00 00 mov $0x10,%ecx + 508: 6a 00 push $0x0 + 50a: 8b 45 d0 mov -0x30(%ebp),%eax + 50d: 8b 10 mov (%eax),%edx + 50f: 89 f0 mov %esi,%eax + 511: e8 7a fe ff ff call 390 + ap++; + 516: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 51a: 83 c4 10 add $0x10,%esp + state = 0; + 51d: 31 c9 xor %ecx,%ecx + 51f: e9 6e ff ff ff jmp 492 + 524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 528: 8b 45 d0 mov -0x30(%ebp),%eax + 52b: 8b 10 mov (%eax),%edx + ap++; + 52d: 83 c0 04 add $0x4,%eax + 530: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 533: 85 d2 test %edx,%edx + 535: 0f 84 8d 00 00 00 je 5c8 + while (*s != 0) { + 53b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 53e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 540: 84 c0 test %al,%al + 542: 0f 84 4a ff ff ff je 492 + 548: 89 5d d4 mov %ebx,-0x2c(%ebp) + 54b: 89 d3 mov %edx,%ebx + 54d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 550: 83 ec 04 sub $0x4,%esp + s++; + 553: 83 c3 01 add $0x1,%ebx + 556: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 559: 6a 01 push $0x1 + 55b: 57 push %edi + 55c: 56 push %esi + 55d: e8 d1 fd ff ff call 333 + while (*s != 0) { + 562: 0f b6 03 movzbl (%ebx),%eax + 565: 83 c4 10 add $0x10,%esp + 568: 84 c0 test %al,%al + 56a: 75 e4 jne 550 + state = 0; + 56c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 56f: 31 c9 xor %ecx,%ecx + 571: e9 1c ff ff ff jmp 492 + 576: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 57d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 580: 83 ec 0c sub $0xc,%esp + 583: b9 0a 00 00 00 mov $0xa,%ecx + 588: 6a 01 push $0x1 + 58a: e9 7b ff ff ff jmp 50a + 58f: 90 nop + putc(fd, *ap); + 590: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 593: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 596: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 598: 6a 01 push $0x1 + 59a: 57 push %edi + 59b: 56 push %esi + putc(fd, *ap); + 59c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 59f: e8 8f fd ff ff call 333 + ap++; + 5a4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5a8: 83 c4 10 add $0x10,%esp + state = 0; + 5ab: 31 c9 xor %ecx,%ecx + 5ad: e9 e0 fe ff ff jmp 492 + 5b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5b8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5bb: 83 ec 04 sub $0x4,%esp + 5be: e9 2a ff ff ff jmp 4ed + 5c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5c7: 90 nop + s = "(null)"; + 5c8: ba d2 07 00 00 mov $0x7d2,%edx + while (*s != 0) { + 5cd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5d0: b8 28 00 00 00 mov $0x28,%eax + 5d5: 89 d3 mov %edx,%ebx + 5d7: e9 74 ff ff ff jmp 550 + 5dc: 66 90 xchg %ax,%ax + 5de: 66 90 xchg %ax,%ax + +000005e0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5e0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5e1: a1 e8 0a 00 00 mov 0xae8,%eax +void free(void *ap) { + 5e6: 89 e5 mov %esp,%ebp + 5e8: 57 push %edi + 5e9: 56 push %esi + 5ea: 53 push %ebx + 5eb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5ee: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5f8: 89 c2 mov %eax,%edx + 5fa: 8b 00 mov (%eax),%eax + 5fc: 39 ca cmp %ecx,%edx + 5fe: 73 30 jae 630 + 600: 39 c1 cmp %eax,%ecx + 602: 72 04 jb 608 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 604: 39 c2 cmp %eax,%edx + 606: 72 f0 jb 5f8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 608: 8b 73 fc mov -0x4(%ebx),%esi + 60b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 60e: 39 f8 cmp %edi,%eax + 610: 74 30 je 642 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 612: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 615: 8b 42 04 mov 0x4(%edx),%eax + 618: 8d 34 c2 lea (%edx,%eax,8),%esi + 61b: 39 f1 cmp %esi,%ecx + 61d: 74 3a je 659 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 61f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 621: 5b pop %ebx + freep = p; + 622: 89 15 e8 0a 00 00 mov %edx,0xae8 +} + 628: 5e pop %esi + 629: 5f pop %edi + 62a: 5d pop %ebp + 62b: c3 ret + 62c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 630: 39 c2 cmp %eax,%edx + 632: 72 c4 jb 5f8 + 634: 39 c1 cmp %eax,%ecx + 636: 73 c0 jae 5f8 + if (bp + bp->s.size == p->s.ptr) { + 638: 8b 73 fc mov -0x4(%ebx),%esi + 63b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 63e: 39 f8 cmp %edi,%eax + 640: 75 d0 jne 612 + bp->s.size += p->s.ptr->s.size; + 642: 03 70 04 add 0x4(%eax),%esi + 645: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 648: 8b 02 mov (%edx),%eax + 64a: 8b 00 mov (%eax),%eax + 64c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 64f: 8b 42 04 mov 0x4(%edx),%eax + 652: 8d 34 c2 lea (%edx,%eax,8),%esi + 655: 39 f1 cmp %esi,%ecx + 657: 75 c6 jne 61f + p->s.size += bp->s.size; + 659: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 65c: 89 15 e8 0a 00 00 mov %edx,0xae8 + p->s.size += bp->s.size; + 662: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 665: 8b 4b f8 mov -0x8(%ebx),%ecx + 668: 89 0a mov %ecx,(%edx) +} + 66a: 5b pop %ebx + 66b: 5e pop %esi + 66c: 5f pop %edi + 66d: 5d pop %ebp + 66e: c3 ret + 66f: 90 nop + +00000670 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 670: 55 push %ebp + 671: 89 e5 mov %esp,%ebp + 673: 57 push %edi + 674: 56 push %esi + 675: 53 push %ebx + 676: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 679: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 67c: 8b 3d e8 0a 00 00 mov 0xae8,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 682: 8d 70 07 lea 0x7(%eax),%esi + 685: c1 ee 03 shr $0x3,%esi + 688: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 68b: 85 ff test %edi,%edi + 68d: 0f 84 9d 00 00 00 je 730 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 693: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 695: 8b 4a 04 mov 0x4(%edx),%ecx + 698: 39 f1 cmp %esi,%ecx + 69a: 73 6a jae 706 + 69c: bb 00 10 00 00 mov $0x1000,%ebx + 6a1: 39 de cmp %ebx,%esi + 6a3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 6a6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 6ad: 89 45 e4 mov %eax,-0x1c(%ebp) + 6b0: eb 17 jmp 6c9 + 6b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6b8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6ba: 8b 48 04 mov 0x4(%eax),%ecx + 6bd: 39 f1 cmp %esi,%ecx + 6bf: 73 4f jae 710 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6c1: 8b 3d e8 0a 00 00 mov 0xae8,%edi + 6c7: 89 c2 mov %eax,%edx + 6c9: 39 d7 cmp %edx,%edi + 6cb: 75 eb jne 6b8 + p = sbrk(nu * sizeof(Header)); + 6cd: 83 ec 0c sub $0xc,%esp + 6d0: ff 75 e4 push -0x1c(%ebp) + 6d3: e8 3b fc ff ff call 313 + if (p == (char*)-1) { + 6d8: 83 c4 10 add $0x10,%esp + 6db: 83 f8 ff cmp $0xffffffff,%eax + 6de: 74 1c je 6fc + hp->s.size = nu; + 6e0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6e3: 83 ec 0c sub $0xc,%esp + 6e6: 83 c0 08 add $0x8,%eax + 6e9: 50 push %eax + 6ea: e8 f1 fe ff ff call 5e0 + return freep; + 6ef: 8b 15 e8 0a 00 00 mov 0xae8,%edx + if ((p = morecore(nunits)) == 0) { + 6f5: 83 c4 10 add $0x10,%esp + 6f8: 85 d2 test %edx,%edx + 6fa: 75 bc jne 6b8 + return 0; + } + } + } +} + 6fc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 6ff: 31 c0 xor %eax,%eax +} + 701: 5b pop %ebx + 702: 5e pop %esi + 703: 5f pop %edi + 704: 5d pop %ebp + 705: c3 ret + if (p->s.size >= nunits) { + 706: 89 d0 mov %edx,%eax + 708: 89 fa mov %edi,%edx + 70a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 710: 39 ce cmp %ecx,%esi + 712: 74 4c je 760 + p->s.size -= nunits; + 714: 29 f1 sub %esi,%ecx + 716: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 719: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 71c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 71f: 89 15 e8 0a 00 00 mov %edx,0xae8 +} + 725: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 728: 83 c0 08 add $0x8,%eax +} + 72b: 5b pop %ebx + 72c: 5e pop %esi + 72d: 5f pop %edi + 72e: 5d pop %ebp + 72f: c3 ret + base.s.ptr = freep = prevp = &base; + 730: c7 05 e8 0a 00 00 ec movl $0xaec,0xae8 + 737: 0a 00 00 + base.s.size = 0; + 73a: bf ec 0a 00 00 mov $0xaec,%edi + base.s.ptr = freep = prevp = &base; + 73f: c7 05 ec 0a 00 00 ec movl $0xaec,0xaec + 746: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 749: 89 fa mov %edi,%edx + base.s.size = 0; + 74b: c7 05 f0 0a 00 00 00 movl $0x0,0xaf0 + 752: 00 00 00 + if (p->s.size >= nunits) { + 755: e9 42 ff ff ff jmp 69c + 75a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 760: 8b 08 mov (%eax),%ecx + 762: 89 0a mov %ecx,(%edx) + 764: eb b9 jmp 71f diff --git a/hello.d b/hello.d new file mode 100644 index 0000000..8d6eb56 --- /dev/null +++ b/hello.d @@ -0,0 +1 @@ +hello.o: hello.c /usr/include/stdc-predef.h types.h user.h diff --git a/hello.o b/hello.o new file mode 100644 index 0000000..ecfd49a Binary files /dev/null and b/hello.o differ diff --git a/hello.sym b/hello.sym new file mode 100644 index 0000000..296f7e2 --- /dev/null +++ b/hello.sym @@ -0,0 +1,50 @@ +00000000 hello.c +00000000 ulib.c +00000000 printf.c +00000390 printint +00000834 digits.0 +00000000 umalloc.c +00000ae8 freep +00000aec base +00000070 strcpy +00000440 printf +0000036b greeting +00000290 memmove +0000033b mknod +00000190 gets +0000030b getpid +0000037b screen +00000670 malloc +0000031b sleep +000002d3 pipe +00000363 getch +00000333 write +000002f3 fstat +000002e3 kill +000002fb chdir +000002eb exec +000002cb wait +000002db read +00000343 unlink +000002bb fork +00000313 sbrk +00000323 uptime +00000ae8 __bss_start +00000130 memset +00000000 main +000000a0 strcmp +00000373 shutdown +00000303 dup +00000200 stat +00000ae8 _edata +00000af4 _end +0000034b link +000002c3 exit +00000250 atoi +00000383 cls +00000100 strlen +0000032b open +00000150 strchr +00000353 mkdir +0000035b close +000005e0 free diff --git a/ide.d b/ide.d new file mode 100644 index 0000000..21155b9 --- /dev/null +++ b/ide.d @@ -0,0 +1,2 @@ +ide.o: ide.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h traps.h spinlock.h sleeplock.h fs.h buf.h diff --git a/ide.o b/ide.o new file mode 100644 index 0000000..465d53b Binary files /dev/null and b/ide.o differ diff --git a/init.asm b/init.asm new file mode 100644 index 0000000..3783efa --- /dev/null +++ b/init.asm @@ -0,0 +1,1238 @@ + +_init: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "user.h" +#include "fcntl.h" + +char *argv[] = { "sh", 0 }; + +int main(void) { + 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: 53 push %ebx + e: 51 push %ecx + int pid, wpid; + + if (open("console", O_RDWR) < 0) { + f: 83 ec 08 sub $0x8,%esp + 12: 6a 02 push $0x2 + 14: 68 d8 07 00 00 push $0x7d8 + 19: e8 7d 03 00 00 call 39b + 1e: 83 c4 10 add $0x10,%esp + 21: 85 c0 test %eax,%eax + 23: 0f 88 8d 00 00 00 js b6 + mknod("console", 1, 1); + open("console", O_RDWR); + } + dup(0); // stdout + 29: 83 ec 0c sub $0xc,%esp + 2c: 6a 00 push $0x0 + 2e: e8 40 03 00 00 call 373 + dup(0); // stderr + 33: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 3a: e8 34 03 00 00 call 373 + 3f: 83 c4 10 add $0x10,%esp + 42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + + for (;;) { + printf(1, "init: starting sh\n"); + 48: 83 ec 08 sub $0x8,%esp + 4b: 68 e0 07 00 00 push $0x7e0 + 50: 6a 01 push $0x1 + 52: e8 59 04 00 00 call 4b0 + pid = fork(); + 57: e8 cf 02 00 00 call 32b + if (pid < 0) { + 5c: 83 c4 10 add $0x10,%esp + pid = fork(); + 5f: 89 c3 mov %eax,%ebx + if (pid < 0) { + 61: 85 c0 test %eax,%eax + 63: 78 1a js 7f + printf(1, "init: fork failed\n"); + exit(); + } + if (pid == 0) { + 65: 74 2b je 92 + 67: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 6e: 66 90 xchg %ax,%ax + exec("sh", argv); + printf(1, "init: exec sh failed\n"); + exit(); + } + while ((wpid = wait()) >= 0 && wpid != pid) { + 70: e8 c6 02 00 00 call 33b + 75: 85 c0 test %eax,%eax + 77: 78 cf js 48 + 79: 39 c3 cmp %eax,%ebx + 7b: 75 f3 jne 70 + 7d: eb c9 jmp 48 + printf(1, "init: fork failed\n"); + 7f: 53 push %ebx + 80: 53 push %ebx + 81: 68 f3 07 00 00 push $0x7f3 + 86: 6a 01 push $0x1 + 88: e8 23 04 00 00 call 4b0 + exit(); + 8d: e8 a1 02 00 00 call 333 + exec("sh", argv); + 92: 50 push %eax + 93: 50 push %eax + 94: 68 2c 0b 00 00 push $0xb2c + 99: 68 06 08 00 00 push $0x806 + 9e: e8 b8 02 00 00 call 35b + printf(1, "init: exec sh failed\n"); + a3: 5a pop %edx + a4: 59 pop %ecx + a5: 68 09 08 00 00 push $0x809 + aa: 6a 01 push $0x1 + ac: e8 ff 03 00 00 call 4b0 + exit(); + b1: e8 7d 02 00 00 call 333 + mknod("console", 1, 1); + b6: 50 push %eax + b7: 6a 01 push $0x1 + b9: 6a 01 push $0x1 + bb: 68 d8 07 00 00 push $0x7d8 + c0: e8 e6 02 00 00 call 3ab + open("console", O_RDWR); + c5: 58 pop %eax + c6: 5a pop %edx + c7: 6a 02 push $0x2 + c9: 68 d8 07 00 00 push $0x7d8 + ce: e8 c8 02 00 00 call 39b + d3: 83 c4 10 add $0x10,%esp + d6: e9 4e ff ff ff jmp 29 + db: 66 90 xchg %ax,%ax + dd: 66 90 xchg %ax,%ax + df: 90 nop + +000000e0 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + e0: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + e1: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + e3: 89 e5 mov %esp,%ebp + e5: 53 push %ebx + e6: 8b 4d 08 mov 0x8(%ebp),%ecx + e9: 8b 5d 0c mov 0xc(%ebp),%ebx + ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + f0: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + f4: 88 14 01 mov %dl,(%ecx,%eax,1) + f7: 83 c0 01 add $0x1,%eax + fa: 84 d2 test %dl,%dl + fc: 75 f2 jne f0 + ; + } + return os; +} + fe: 8b 5d fc mov -0x4(%ebp),%ebx + 101: 89 c8 mov %ecx,%eax + 103: c9 leave + 104: c3 ret + 105: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 10c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000110 : + +int strcmp(const char *p, const char *q) { + 110: 55 push %ebp + 111: 89 e5 mov %esp,%ebp + 113: 53 push %ebx + 114: 8b 55 08 mov 0x8(%ebp),%edx + 117: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 11a: 0f b6 02 movzbl (%edx),%eax + 11d: 84 c0 test %al,%al + 11f: 75 17 jne 138 + 121: eb 3a jmp 15d + 123: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 127: 90 nop + 128: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 12c: 83 c2 01 add $0x1,%edx + 12f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 132: 84 c0 test %al,%al + 134: 74 1a je 150 + p++, q++; + 136: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 138: 0f b6 19 movzbl (%ecx),%ebx + 13b: 38 c3 cmp %al,%bl + 13d: 74 e9 je 128 + } + return (uchar) * p - (uchar) * q; + 13f: 29 d8 sub %ebx,%eax +} + 141: 8b 5d fc mov -0x4(%ebp),%ebx + 144: c9 leave + 145: c3 ret + 146: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 14d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 150: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 154: 31 c0 xor %eax,%eax + 156: 29 d8 sub %ebx,%eax +} + 158: 8b 5d fc mov -0x4(%ebp),%ebx + 15b: c9 leave + 15c: c3 ret + return (uchar) * p - (uchar) * q; + 15d: 0f b6 19 movzbl (%ecx),%ebx + 160: 31 c0 xor %eax,%eax + 162: eb db jmp 13f + 164: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 16b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 16f: 90 nop + +00000170 : + +uint strlen(const char *s) { + 170: 55 push %ebp + 171: 89 e5 mov %esp,%ebp + 173: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 176: 80 3a 00 cmpb $0x0,(%edx) + 179: 74 15 je 190 + 17b: 31 c0 xor %eax,%eax + 17d: 8d 76 00 lea 0x0(%esi),%esi + 180: 83 c0 01 add $0x1,%eax + 183: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 187: 89 c1 mov %eax,%ecx + 189: 75 f5 jne 180 + ; + } + return n; +} + 18b: 89 c8 mov %ecx,%eax + 18d: 5d pop %ebp + 18e: c3 ret + 18f: 90 nop + for (n = 0; s[n]; n++) { + 190: 31 c9 xor %ecx,%ecx +} + 192: 5d pop %ebp + 193: 89 c8 mov %ecx,%eax + 195: c3 ret + 196: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 19d: 8d 76 00 lea 0x0(%esi),%esi + +000001a0 : + +void* memset(void *dst, int c, uint n) { + 1a0: 55 push %ebp + 1a1: 89 e5 mov %esp,%ebp + 1a3: 57 push %edi + 1a4: 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" : + 1a7: 8b 4d 10 mov 0x10(%ebp),%ecx + 1aa: 8b 45 0c mov 0xc(%ebp),%eax + 1ad: 89 d7 mov %edx,%edi + 1af: fc cld + 1b0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1b2: 8b 7d fc mov -0x4(%ebp),%edi + 1b5: 89 d0 mov %edx,%eax + 1b7: c9 leave + 1b8: c3 ret + 1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000001c0 : + +char* strchr(const char *s, char c) { + 1c0: 55 push %ebp + 1c1: 89 e5 mov %esp,%ebp + 1c3: 8b 45 08 mov 0x8(%ebp),%eax + 1c6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 1ca: 0f b6 10 movzbl (%eax),%edx + 1cd: 84 d2 test %dl,%dl + 1cf: 75 12 jne 1e3 + 1d1: eb 1d jmp 1f0 + 1d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1d7: 90 nop + 1d8: 0f b6 50 01 movzbl 0x1(%eax),%edx + 1dc: 83 c0 01 add $0x1,%eax + 1df: 84 d2 test %dl,%dl + 1e1: 74 0d je 1f0 + if (*s == c) { + 1e3: 38 d1 cmp %dl,%cl + 1e5: 75 f1 jne 1d8 + return (char*)s; + } + } + return 0; +} + 1e7: 5d pop %ebp + 1e8: c3 ret + 1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 1f0: 31 c0 xor %eax,%eax +} + 1f2: 5d pop %ebp + 1f3: c3 ret + 1f4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1ff: 90 nop + +00000200 : + +char* gets(char *buf, int max) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 57 push %edi + 204: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 205: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 208: 53 push %ebx + for (i = 0; i + 1 < max;) { + 209: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 20b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 20e: eb 27 jmp 237 + cc = read(0, &c, 1); + 210: 83 ec 04 sub $0x4,%esp + 213: 6a 01 push $0x1 + 215: 57 push %edi + 216: 6a 00 push $0x0 + 218: e8 2e 01 00 00 call 34b + if (cc < 1) { + 21d: 83 c4 10 add $0x10,%esp + 220: 85 c0 test %eax,%eax + 222: 7e 1d jle 241 + break; + } + buf[i++] = c; + 224: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 228: 8b 55 08 mov 0x8(%ebp),%edx + 22b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 22f: 3c 0a cmp $0xa,%al + 231: 74 1d je 250 + 233: 3c 0d cmp $0xd,%al + 235: 74 19 je 250 + for (i = 0; i + 1 < max;) { + 237: 89 de mov %ebx,%esi + 239: 83 c3 01 add $0x1,%ebx + 23c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 23f: 7c cf jl 210 + break; + } + } + buf[i] = '\0'; + 241: 8b 45 08 mov 0x8(%ebp),%eax + 244: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 248: 8d 65 f4 lea -0xc(%ebp),%esp + 24b: 5b pop %ebx + 24c: 5e pop %esi + 24d: 5f pop %edi + 24e: 5d pop %ebp + 24f: c3 ret + buf[i] = '\0'; + 250: 8b 45 08 mov 0x8(%ebp),%eax + 253: 89 de mov %ebx,%esi + 255: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 259: 8d 65 f4 lea -0xc(%ebp),%esp + 25c: 5b pop %ebx + 25d: 5e pop %esi + 25e: 5f pop %edi + 25f: 5d pop %ebp + 260: c3 ret + 261: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 268: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26f: 90 nop + +00000270 : + +int stat(const char *n, struct stat *st) { + 270: 55 push %ebp + 271: 89 e5 mov %esp,%ebp + 273: 56 push %esi + 274: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 275: 83 ec 08 sub $0x8,%esp + 278: 6a 00 push $0x0 + 27a: ff 75 08 push 0x8(%ebp) + 27d: e8 19 01 00 00 call 39b + if (fd < 0) { + 282: 83 c4 10 add $0x10,%esp + 285: 85 c0 test %eax,%eax + 287: 78 27 js 2b0 + return -1; + } + r = fstat(fd, st); + 289: 83 ec 08 sub $0x8,%esp + 28c: ff 75 0c push 0xc(%ebp) + 28f: 89 c3 mov %eax,%ebx + 291: 50 push %eax + 292: e8 cc 00 00 00 call 363 + close(fd); + 297: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 29a: 89 c6 mov %eax,%esi + close(fd); + 29c: e8 2a 01 00 00 call 3cb + return r; + 2a1: 83 c4 10 add $0x10,%esp +} + 2a4: 8d 65 f8 lea -0x8(%ebp),%esp + 2a7: 89 f0 mov %esi,%eax + 2a9: 5b pop %ebx + 2aa: 5e pop %esi + 2ab: 5d pop %ebp + 2ac: c3 ret + 2ad: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 2b0: be ff ff ff ff mov $0xffffffff,%esi + 2b5: eb ed jmp 2a4 + 2b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2be: 66 90 xchg %ax,%ax + +000002c0 : + +int atoi(const char *s) { + 2c0: 55 push %ebp + 2c1: 89 e5 mov %esp,%ebp + 2c3: 53 push %ebx + 2c4: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 2c7: 0f be 02 movsbl (%edx),%eax + 2ca: 8d 48 d0 lea -0x30(%eax),%ecx + 2cd: 80 f9 09 cmp $0x9,%cl + n = 0; + 2d0: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 2d5: 77 1e ja 2f5 + 2d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2de: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 2e0: 83 c2 01 add $0x1,%edx + 2e3: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 2e6: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 2ea: 0f be 02 movsbl (%edx),%eax + 2ed: 8d 58 d0 lea -0x30(%eax),%ebx + 2f0: 80 fb 09 cmp $0x9,%bl + 2f3: 76 eb jbe 2e0 + } + return n; +} + 2f5: 8b 5d fc mov -0x4(%ebp),%ebx + 2f8: 89 c8 mov %ecx,%eax + 2fa: c9 leave + 2fb: c3 ret + 2fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000300 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 300: 55 push %ebp + 301: 89 e5 mov %esp,%ebp + 303: 57 push %edi + 304: 8b 45 10 mov 0x10(%ebp),%eax + 307: 8b 55 08 mov 0x8(%ebp),%edx + 30a: 56 push %esi + 30b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 30e: 85 c0 test %eax,%eax + 310: 7e 13 jle 325 + 312: 01 d0 add %edx,%eax + dst = vdst; + 314: 89 d7 mov %edx,%edi + 316: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 31d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 320: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 321: 39 f8 cmp %edi,%eax + 323: 75 fb jne 320 + } + return vdst; +} + 325: 5e pop %esi + 326: 89 d0 mov %edx,%eax + 328: 5f pop %edi + 329: 5d pop %ebp + 32a: c3 ret + +0000032b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 32b: b8 01 00 00 00 mov $0x1,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(exit) + 333: b8 02 00 00 00 mov $0x2,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(wait) + 33b: b8 03 00 00 00 mov $0x3,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(pipe) + 343: b8 04 00 00 00 mov $0x4,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(read) + 34b: b8 05 00 00 00 mov $0x5,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(kill) + 353: b8 06 00 00 00 mov $0x6,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(exec) + 35b: b8 07 00 00 00 mov $0x7,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(fstat) + 363: b8 08 00 00 00 mov $0x8,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(chdir) + 36b: b8 09 00 00 00 mov $0x9,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(dup) + 373: b8 0a 00 00 00 mov $0xa,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(getpid) + 37b: b8 0b 00 00 00 mov $0xb,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(sbrk) + 383: b8 0c 00 00 00 mov $0xc,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + +0000038b : +SYSCALL(sleep) + 38b: b8 0d 00 00 00 mov $0xd,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(uptime) + 393: b8 0e 00 00 00 mov $0xe,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + +0000039b : +SYSCALL(open) + 39b: b8 0f 00 00 00 mov $0xf,%eax + 3a0: cd 40 int $0x40 + 3a2: c3 ret + +000003a3 : +SYSCALL(write) + 3a3: b8 10 00 00 00 mov $0x10,%eax + 3a8: cd 40 int $0x40 + 3aa: c3 ret + +000003ab : +SYSCALL(mknod) + 3ab: b8 11 00 00 00 mov $0x11,%eax + 3b0: cd 40 int $0x40 + 3b2: c3 ret + +000003b3 : +SYSCALL(unlink) + 3b3: b8 12 00 00 00 mov $0x12,%eax + 3b8: cd 40 int $0x40 + 3ba: c3 ret + +000003bb : +SYSCALL(link) + 3bb: b8 13 00 00 00 mov $0x13,%eax + 3c0: cd 40 int $0x40 + 3c2: c3 ret + +000003c3 : +SYSCALL(mkdir) + 3c3: b8 14 00 00 00 mov $0x14,%eax + 3c8: cd 40 int $0x40 + 3ca: c3 ret + +000003cb : +SYSCALL(close) + 3cb: b8 15 00 00 00 mov $0x15,%eax + 3d0: cd 40 int $0x40 + 3d2: c3 ret + +000003d3 : +SYSCALL(getch) + 3d3: b8 16 00 00 00 mov $0x16,%eax + 3d8: cd 40 int $0x40 + 3da: c3 ret + +000003db : +SYSCALL(greeting) + 3db: b8 17 00 00 00 mov $0x17,%eax + 3e0: cd 40 int $0x40 + 3e2: c3 ret + +000003e3 : +SYSCALL(shutdown) + 3e3: b8 18 00 00 00 mov $0x18,%eax + 3e8: cd 40 int $0x40 + 3ea: c3 ret + +000003eb : +SYSCALL(screen) + 3eb: b8 19 00 00 00 mov $0x19,%eax + 3f0: cd 40 int $0x40 + 3f2: c3 ret + +000003f3 : +SYSCALL(cls) + 3f3: b8 1a 00 00 00 mov $0x1a,%eax + 3f8: cd 40 int $0x40 + 3fa: c3 ret + 3fb: 66 90 xchg %ax,%ax + 3fd: 66 90 xchg %ax,%ax + 3ff: 90 nop + +00000400 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 400: 55 push %ebp + 401: 89 e5 mov %esp,%ebp + 403: 57 push %edi + 404: 56 push %esi + 405: 53 push %ebx + 406: 83 ec 3c sub $0x3c,%esp + 409: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 40c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 40e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 411: 85 d2 test %edx,%edx + 413: 0f 89 7f 00 00 00 jns 498 + 419: f6 45 08 01 testb $0x1,0x8(%ebp) + 41d: 74 79 je 498 + neg = 1; + 41f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 426: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 428: 31 db xor %ebx,%ebx + 42a: 8d 75 d7 lea -0x29(%ebp),%esi + 42d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 430: 89 c8 mov %ecx,%eax + 432: 31 d2 xor %edx,%edx + 434: 89 cf mov %ecx,%edi + 436: f7 75 c4 divl -0x3c(%ebp) + 439: 0f b6 92 80 08 00 00 movzbl 0x880(%edx),%edx + 440: 89 45 c0 mov %eax,-0x40(%ebp) + 443: 89 d8 mov %ebx,%eax + 445: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 448: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 44b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 44e: 39 7d c4 cmp %edi,-0x3c(%ebp) + 451: 76 dd jbe 430 + if (neg) { + 453: 8b 4d bc mov -0x44(%ebp),%ecx + 456: 85 c9 test %ecx,%ecx + 458: 74 0c je 466 + buf[i++] = '-'; + 45a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 45f: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 461: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 466: 8b 7d b8 mov -0x48(%ebp),%edi + 469: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 46d: eb 07 jmp 476 + 46f: 90 nop + putc(fd, buf[i]); + 470: 0f b6 13 movzbl (%ebx),%edx + 473: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 476: 83 ec 04 sub $0x4,%esp + 479: 88 55 d7 mov %dl,-0x29(%ebp) + 47c: 6a 01 push $0x1 + 47e: 56 push %esi + 47f: 57 push %edi + 480: e8 1e ff ff ff call 3a3 + while (--i >= 0) { + 485: 83 c4 10 add $0x10,%esp + 488: 39 de cmp %ebx,%esi + 48a: 75 e4 jne 470 + } +} + 48c: 8d 65 f4 lea -0xc(%ebp),%esp + 48f: 5b pop %ebx + 490: 5e pop %esi + 491: 5f pop %edi + 492: 5d pop %ebp + 493: c3 ret + 494: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 498: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 49f: eb 87 jmp 428 + 4a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4af: 90 nop + +000004b0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 4b0: 55 push %ebp + 4b1: 89 e5 mov %esp,%ebp + 4b3: 57 push %edi + 4b4: 56 push %esi + 4b5: 53 push %ebx + 4b6: 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++) { + 4b9: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 4bc: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 4bf: 0f b6 13 movzbl (%ebx),%edx + 4c2: 84 d2 test %dl,%dl + 4c4: 74 6a je 530 + ap = (uint*)(void*)&fmt + 1; + 4c6: 8d 45 10 lea 0x10(%ebp),%eax + 4c9: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 4cc: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 4cf: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 4d1: 89 45 d0 mov %eax,-0x30(%ebp) + 4d4: eb 36 jmp 50c + 4d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4dd: 8d 76 00 lea 0x0(%esi),%esi + 4e0: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 4e3: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 4e8: 83 f8 25 cmp $0x25,%eax + 4eb: 74 15 je 502 + write(fd, &c, 1); + 4ed: 83 ec 04 sub $0x4,%esp + 4f0: 88 55 e7 mov %dl,-0x19(%ebp) + 4f3: 6a 01 push $0x1 + 4f5: 57 push %edi + 4f6: 56 push %esi + 4f7: e8 a7 fe ff ff call 3a3 + 4fc: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 4ff: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 502: 0f b6 13 movzbl (%ebx),%edx + 505: 83 c3 01 add $0x1,%ebx + 508: 84 d2 test %dl,%dl + 50a: 74 24 je 530 + c = fmt[i] & 0xff; + 50c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 50f: 85 c9 test %ecx,%ecx + 511: 74 cd je 4e0 + } + } + else if (state == '%') { + 513: 83 f9 25 cmp $0x25,%ecx + 516: 75 ea jne 502 + if (c == 'd') { + 518: 83 f8 25 cmp $0x25,%eax + 51b: 0f 84 07 01 00 00 je 628 + 521: 83 e8 63 sub $0x63,%eax + 524: 83 f8 15 cmp $0x15,%eax + 527: 77 17 ja 540 + 529: ff 24 85 28 08 00 00 jmp *0x828(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 530: 8d 65 f4 lea -0xc(%ebp),%esp + 533: 5b pop %ebx + 534: 5e pop %esi + 535: 5f pop %edi + 536: 5d pop %ebp + 537: c3 ret + 538: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 53f: 90 nop + write(fd, &c, 1); + 540: 83 ec 04 sub $0x4,%esp + 543: 88 55 d4 mov %dl,-0x2c(%ebp) + 546: 6a 01 push $0x1 + 548: 57 push %edi + 549: 56 push %esi + 54a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 54e: e8 50 fe ff ff call 3a3 + putc(fd, c); + 553: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 557: 83 c4 0c add $0xc,%esp + 55a: 88 55 e7 mov %dl,-0x19(%ebp) + 55d: 6a 01 push $0x1 + 55f: 57 push %edi + 560: 56 push %esi + 561: e8 3d fe ff ff call 3a3 + putc(fd, c); + 566: 83 c4 10 add $0x10,%esp + state = 0; + 569: 31 c9 xor %ecx,%ecx + 56b: eb 95 jmp 502 + 56d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 570: 83 ec 0c sub $0xc,%esp + 573: b9 10 00 00 00 mov $0x10,%ecx + 578: 6a 00 push $0x0 + 57a: 8b 45 d0 mov -0x30(%ebp),%eax + 57d: 8b 10 mov (%eax),%edx + 57f: 89 f0 mov %esi,%eax + 581: e8 7a fe ff ff call 400 + ap++; + 586: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 58a: 83 c4 10 add $0x10,%esp + state = 0; + 58d: 31 c9 xor %ecx,%ecx + 58f: e9 6e ff ff ff jmp 502 + 594: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 598: 8b 45 d0 mov -0x30(%ebp),%eax + 59b: 8b 10 mov (%eax),%edx + ap++; + 59d: 83 c0 04 add $0x4,%eax + 5a0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 5a3: 85 d2 test %edx,%edx + 5a5: 0f 84 8d 00 00 00 je 638 + while (*s != 0) { + 5ab: 0f b6 02 movzbl (%edx),%eax + state = 0; + 5ae: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 5b0: 84 c0 test %al,%al + 5b2: 0f 84 4a ff ff ff je 502 + 5b8: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5bb: 89 d3 mov %edx,%ebx + 5bd: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 5c0: 83 ec 04 sub $0x4,%esp + s++; + 5c3: 83 c3 01 add $0x1,%ebx + 5c6: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 5c9: 6a 01 push $0x1 + 5cb: 57 push %edi + 5cc: 56 push %esi + 5cd: e8 d1 fd ff ff call 3a3 + while (*s != 0) { + 5d2: 0f b6 03 movzbl (%ebx),%eax + 5d5: 83 c4 10 add $0x10,%esp + 5d8: 84 c0 test %al,%al + 5da: 75 e4 jne 5c0 + state = 0; + 5dc: 8b 5d d4 mov -0x2c(%ebp),%ebx + 5df: 31 c9 xor %ecx,%ecx + 5e1: e9 1c ff ff ff jmp 502 + 5e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5ed: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 5f0: 83 ec 0c sub $0xc,%esp + 5f3: b9 0a 00 00 00 mov $0xa,%ecx + 5f8: 6a 01 push $0x1 + 5fa: e9 7b ff ff ff jmp 57a + 5ff: 90 nop + putc(fd, *ap); + 600: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 603: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 606: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 608: 6a 01 push $0x1 + 60a: 57 push %edi + 60b: 56 push %esi + putc(fd, *ap); + 60c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 60f: e8 8f fd ff ff call 3a3 + ap++; + 614: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 618: 83 c4 10 add $0x10,%esp + state = 0; + 61b: 31 c9 xor %ecx,%ecx + 61d: e9 e0 fe ff ff jmp 502 + 622: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 628: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 62b: 83 ec 04 sub $0x4,%esp + 62e: e9 2a ff ff ff jmp 55d + 633: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 637: 90 nop + s = "(null)"; + 638: ba 1f 08 00 00 mov $0x81f,%edx + while (*s != 0) { + 63d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 640: b8 28 00 00 00 mov $0x28,%eax + 645: 89 d3 mov %edx,%ebx + 647: e9 74 ff ff ff jmp 5c0 + 64c: 66 90 xchg %ax,%ax + 64e: 66 90 xchg %ax,%ax + +00000650 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 650: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 651: a1 34 0b 00 00 mov 0xb34,%eax +void free(void *ap) { + 656: 89 e5 mov %esp,%ebp + 658: 57 push %edi + 659: 56 push %esi + 65a: 53 push %ebx + 65b: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 65e: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 661: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 668: 89 c2 mov %eax,%edx + 66a: 8b 00 mov (%eax),%eax + 66c: 39 ca cmp %ecx,%edx + 66e: 73 30 jae 6a0 + 670: 39 c1 cmp %eax,%ecx + 672: 72 04 jb 678 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 674: 39 c2 cmp %eax,%edx + 676: 72 f0 jb 668 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 678: 8b 73 fc mov -0x4(%ebx),%esi + 67b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 67e: 39 f8 cmp %edi,%eax + 680: 74 30 je 6b2 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 682: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 685: 8b 42 04 mov 0x4(%edx),%eax + 688: 8d 34 c2 lea (%edx,%eax,8),%esi + 68b: 39 f1 cmp %esi,%ecx + 68d: 74 3a je 6c9 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 68f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 691: 5b pop %ebx + freep = p; + 692: 89 15 34 0b 00 00 mov %edx,0xb34 +} + 698: 5e pop %esi + 699: 5f pop %edi + 69a: 5d pop %ebp + 69b: c3 ret + 69c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 6a0: 39 c2 cmp %eax,%edx + 6a2: 72 c4 jb 668 + 6a4: 39 c1 cmp %eax,%ecx + 6a6: 73 c0 jae 668 + if (bp + bp->s.size == p->s.ptr) { + 6a8: 8b 73 fc mov -0x4(%ebx),%esi + 6ab: 8d 3c f1 lea (%ecx,%esi,8),%edi + 6ae: 39 f8 cmp %edi,%eax + 6b0: 75 d0 jne 682 + bp->s.size += p->s.ptr->s.size; + 6b2: 03 70 04 add 0x4(%eax),%esi + 6b5: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 6b8: 8b 02 mov (%edx),%eax + 6ba: 8b 00 mov (%eax),%eax + 6bc: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 6bf: 8b 42 04 mov 0x4(%edx),%eax + 6c2: 8d 34 c2 lea (%edx,%eax,8),%esi + 6c5: 39 f1 cmp %esi,%ecx + 6c7: 75 c6 jne 68f + p->s.size += bp->s.size; + 6c9: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 6cc: 89 15 34 0b 00 00 mov %edx,0xb34 + p->s.size += bp->s.size; + 6d2: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 6d5: 8b 4b f8 mov -0x8(%ebx),%ecx + 6d8: 89 0a mov %ecx,(%edx) +} + 6da: 5b pop %ebx + 6db: 5e pop %esi + 6dc: 5f pop %edi + 6dd: 5d pop %ebp + 6de: c3 ret + 6df: 90 nop + +000006e0 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 6e0: 55 push %ebp + 6e1: 89 e5 mov %esp,%ebp + 6e3: 57 push %edi + 6e4: 56 push %esi + 6e5: 53 push %ebx + 6e6: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 6e9: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 6ec: 8b 3d 34 0b 00 00 mov 0xb34,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 6f2: 8d 70 07 lea 0x7(%eax),%esi + 6f5: c1 ee 03 shr $0x3,%esi + 6f8: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 6fb: 85 ff test %edi,%edi + 6fd: 0f 84 9d 00 00 00 je 7a0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 703: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 705: 8b 4a 04 mov 0x4(%edx),%ecx + 708: 39 f1 cmp %esi,%ecx + 70a: 73 6a jae 776 + 70c: bb 00 10 00 00 mov $0x1000,%ebx + 711: 39 de cmp %ebx,%esi + 713: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 716: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 71d: 89 45 e4 mov %eax,-0x1c(%ebp) + 720: eb 17 jmp 739 + 722: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 728: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 72a: 8b 48 04 mov 0x4(%eax),%ecx + 72d: 39 f1 cmp %esi,%ecx + 72f: 73 4f jae 780 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 731: 8b 3d 34 0b 00 00 mov 0xb34,%edi + 737: 89 c2 mov %eax,%edx + 739: 39 d7 cmp %edx,%edi + 73b: 75 eb jne 728 + p = sbrk(nu * sizeof(Header)); + 73d: 83 ec 0c sub $0xc,%esp + 740: ff 75 e4 push -0x1c(%ebp) + 743: e8 3b fc ff ff call 383 + if (p == (char*)-1) { + 748: 83 c4 10 add $0x10,%esp + 74b: 83 f8 ff cmp $0xffffffff,%eax + 74e: 74 1c je 76c + hp->s.size = nu; + 750: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 753: 83 ec 0c sub $0xc,%esp + 756: 83 c0 08 add $0x8,%eax + 759: 50 push %eax + 75a: e8 f1 fe ff ff call 650 + return freep; + 75f: 8b 15 34 0b 00 00 mov 0xb34,%edx + if ((p = morecore(nunits)) == 0) { + 765: 83 c4 10 add $0x10,%esp + 768: 85 d2 test %edx,%edx + 76a: 75 bc jne 728 + return 0; + } + } + } +} + 76c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 76f: 31 c0 xor %eax,%eax +} + 771: 5b pop %ebx + 772: 5e pop %esi + 773: 5f pop %edi + 774: 5d pop %ebp + 775: c3 ret + if (p->s.size >= nunits) { + 776: 89 d0 mov %edx,%eax + 778: 89 fa mov %edi,%edx + 77a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 780: 39 ce cmp %ecx,%esi + 782: 74 4c je 7d0 + p->s.size -= nunits; + 784: 29 f1 sub %esi,%ecx + 786: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 789: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 78c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 78f: 89 15 34 0b 00 00 mov %edx,0xb34 +} + 795: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 798: 83 c0 08 add $0x8,%eax +} + 79b: 5b pop %ebx + 79c: 5e pop %esi + 79d: 5f pop %edi + 79e: 5d pop %ebp + 79f: c3 ret + base.s.ptr = freep = prevp = &base; + 7a0: c7 05 34 0b 00 00 38 movl $0xb38,0xb34 + 7a7: 0b 00 00 + base.s.size = 0; + 7aa: bf 38 0b 00 00 mov $0xb38,%edi + base.s.ptr = freep = prevp = &base; + 7af: c7 05 38 0b 00 00 38 movl $0xb38,0xb38 + 7b6: 0b 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 7b9: 89 fa mov %edi,%edx + base.s.size = 0; + 7bb: c7 05 3c 0b 00 00 00 movl $0x0,0xb3c + 7c2: 00 00 00 + if (p->s.size >= nunits) { + 7c5: e9 42 ff ff ff jmp 70c + 7ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 7d0: 8b 08 mov (%eax),%ecx + 7d2: 89 0a mov %ecx,(%edx) + 7d4: eb b9 jmp 78f diff --git a/init.d b/init.d new file mode 100644 index 0000000..ee304c8 --- /dev/null +++ b/init.d @@ -0,0 +1 @@ +init.o: init.c /usr/include/stdc-predef.h types.h stat.h user.h fcntl.h diff --git a/init.o b/init.o new file mode 100644 index 0000000..144d129 Binary files /dev/null and b/init.o differ diff --git a/init.sym b/init.sym new file mode 100644 index 0000000..0e40a4d --- /dev/null +++ b/init.sym @@ -0,0 +1,51 @@ +00000000 init.c +00000000 ulib.c +00000000 printf.c +00000400 printint +00000880 digits.0 +00000000 umalloc.c +00000b34 freep +00000b38 base +000000e0 strcpy +000004b0 printf +000003db greeting +00000b2c argv +00000300 memmove +000003ab mknod +00000200 gets +0000037b getpid +000003eb screen +000006e0 malloc +0000038b sleep +00000343 pipe +000003d3 getch +000003a3 write +00000363 fstat +00000353 kill +0000036b chdir +0000035b exec +0000033b wait +0000034b read +000003b3 unlink +0000032b fork +00000383 sbrk +00000393 uptime +00000b34 __bss_start +000001a0 memset +00000000 main +00000110 strcmp +000003e3 shutdown +00000373 dup +00000270 stat +00000b34 _edata +00000b40 _end +000003bb link +00000333 exit +000002c0 atoi +000003f3 cls +00000170 strlen +0000039b open +000001c0 strchr +000003c3 mkdir +000003cb close +00000650 free diff --git a/initcode b/initcode new file mode 100644 index 0000000..773d26c Binary files /dev/null and b/initcode differ diff --git a/initcode.asm b/initcode.asm new file mode 100644 index 0000000..030ab5b --- /dev/null +++ b/initcode.asm @@ -0,0 +1,43 @@ + +initcode.o: file format elf32-i386 + + +Disassembly of section .text: + +00000000 : + + +# exec(init, argv) +.globl start +start: + pushl $argv + 0: 68 24 00 00 00 push $0x24 + pushl $init + 5: 68 1c 00 00 00 push $0x1c + pushl $0 // where caller pc would be + a: 6a 00 push $0x0 + movl $SYS_exec, %eax + c: b8 07 00 00 00 mov $0x7,%eax + int $T_SYSCALL + 11: cd 40 int $0x40 + +00000013 : + +# for(;;) exit(); +exit: + movl $SYS_exit, %eax + 13: b8 02 00 00 00 mov $0x2,%eax + int $T_SYSCALL + 18: cd 40 int $0x40 + jmp exit + 1a: eb f7 jmp 13 + +0000001c : + 1c: 2f das + 1d: 69 6e 69 74 00 00 90 imul $0x90000074,0x69(%esi),%ebp + +00000024 : + 24: 1c 00 sbb $0x0,%al + 26: 00 00 add %al,(%eax) + 28: 00 00 add %al,(%eax) + ... diff --git a/initcode.d b/initcode.d new file mode 100644 index 0000000..ab1af4d --- /dev/null +++ b/initcode.d @@ -0,0 +1 @@ +initcode.o: initcode.S syscall.h traps.h diff --git a/initcode.o b/initcode.o new file mode 100644 index 0000000..0e6fa21 Binary files /dev/null and b/initcode.o differ diff --git a/initcode.out b/initcode.out new file mode 100644 index 0000000..ee27f9d Binary files /dev/null and b/initcode.out differ diff --git a/ioapic.d b/ioapic.d new file mode 100644 index 0000000..997e68a --- /dev/null +++ b/ioapic.d @@ -0,0 +1 @@ +ioapic.o: ioapic.c /usr/include/stdc-predef.h types.h defs.h traps.h diff --git a/ioapic.o b/ioapic.o new file mode 100644 index 0000000..9ed5690 Binary files /dev/null and b/ioapic.o differ diff --git a/kalloc.d b/kalloc.d new file mode 100644 index 0000000..512c5db --- /dev/null +++ b/kalloc.d @@ -0,0 +1,2 @@ +kalloc.o: kalloc.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h spinlock.h diff --git a/kalloc.o b/kalloc.o new file mode 100644 index 0000000..ad9293f Binary files /dev/null and b/kalloc.o differ diff --git a/kbd.d b/kbd.d new file mode 100644 index 0000000..92532ba --- /dev/null +++ b/kbd.d @@ -0,0 +1 @@ +kbd.o: kbd.c /usr/include/stdc-predef.h types.h x86.h defs.h kbd.h diff --git a/kbd.o b/kbd.o new file mode 100644 index 0000000..fffe14c Binary files /dev/null and b/kbd.o differ diff --git a/kernel b/kernel new file mode 100644 index 0000000..9f946d6 Binary files /dev/null and b/kernel differ diff --git a/kernel.asm b/kernel.asm new file mode 100644 index 0000000..30b987d --- /dev/null +++ b/kernel.asm @@ -0,0 +1,18368 @@ + +kernel: file format elf32-i386 + + +Disassembly of section .text: + +80100000 : +80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh +80100006: 00 00 add %al,(%eax) +80100008: fe 4f 52 decb 0x52(%edi) +8010000b: e4 .byte 0xe4 + +8010000c : + +# Entering xv6 on boot processor, with paging off. +.globl entry +entry: + # Turn on page size extension for 4Mbyte pages + movl %cr4, %eax +8010000c: 0f 20 e0 mov %cr4,%eax + orl $(CR4_PSE), %eax +8010000f: 83 c8 10 or $0x10,%eax + movl %eax, %cr4 +80100012: 0f 22 e0 mov %eax,%cr4 + # Set page directory + movl $(V2P_WO(entrypgdir)), %eax +80100015: b8 00 b0 10 00 mov $0x10b000,%eax + movl %eax, %cr3 +8010001a: 0f 22 d8 mov %eax,%cr3 + # Turn on paging. + movl %cr0, %eax +8010001d: 0f 20 c0 mov %cr0,%eax + orl $(CR0_PG|CR0_WP), %eax +80100020: 0d 00 00 01 80 or $0x80010000,%eax + movl %eax, %cr0 +80100025: 0f 22 c0 mov %eax,%cr0 + + # Set up the stack pointer. + movl $(stack + KSTACKSIZE), %esp +80100028: bc 50 22 12 80 mov $0x80122250,%esp + + # Jump to main(), and switch to executing at + # high addresses. The indirect call is needed because + # the assembler produces a PC-relative instruction + # for a direct jump. + mov $main, %eax +8010002d: b8 50 45 10 80 mov $0x80104550,%eax + jmp *%eax +80100032: ff e0 jmp *%eax +80100034: 66 90 xchg %ax,%ax +80100036: 66 90 xchg %ax,%ax +80100038: 66 90 xchg %ax,%ax +8010003a: 66 90 xchg %ax,%ax +8010003c: 66 90 xchg %ax,%ax +8010003e: 66 90 xchg %ax,%ax + +80100040 : + // Linked list of all buffers, through prev/next. + // head.next is most recently used. + struct buf head; +} bcache; + +void binit(void) { +80100040: 55 push %ebp +80100041: 89 e5 mov %esp,%ebp +80100043: 53 push %ebx + initlock(&bcache.lock, "bcache"); + + // Create linked list of buffers + bcache.head.prev = &bcache.head; + bcache.head.next = &bcache.head; + for (b = bcache.buf; b < bcache.buf + NBUF; b++) { +80100044: bb 54 c5 10 80 mov $0x8010c554,%ebx +void binit(void) { +80100049: 83 ec 0c sub $0xc,%esp + initlock(&bcache.lock, "bcache"); +8010004c: 68 60 89 10 80 push $0x80108960 +80100051: 68 20 c5 10 80 push $0x8010c520 +80100056: e8 55 59 00 00 call 801059b0 + bcache.head.next = &bcache.head; +8010005b: 83 c4 10 add $0x10,%esp +8010005e: b8 1c 0c 11 80 mov $0x80110c1c,%eax + bcache.head.prev = &bcache.head; +80100063: c7 05 6c 0c 11 80 1c movl $0x80110c1c,0x80110c6c +8010006a: 0c 11 80 + bcache.head.next = &bcache.head; +8010006d: c7 05 70 0c 11 80 1c movl $0x80110c1c,0x80110c70 +80100074: 0c 11 80 + for (b = bcache.buf; b < bcache.buf + NBUF; b++) { +80100077: eb 09 jmp 80100082 +80100079: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100080: 89 d3 mov %edx,%ebx + b->next = bcache.head.next; +80100082: 89 43 54 mov %eax,0x54(%ebx) + b->prev = &bcache.head; + initsleeplock(&b->lock, "buffer"); +80100085: 83 ec 08 sub $0x8,%esp +80100088: 8d 43 0c lea 0xc(%ebx),%eax + b->prev = &bcache.head; +8010008b: c7 43 50 1c 0c 11 80 movl $0x80110c1c,0x50(%ebx) + initsleeplock(&b->lock, "buffer"); +80100092: 68 67 89 10 80 push $0x80108967 +80100097: 50 push %eax +80100098: e8 e3 57 00 00 call 80105880 + bcache.head.next->prev = b; +8010009d: a1 70 0c 11 80 mov 0x80110c70,%eax + for (b = bcache.buf; b < bcache.buf + NBUF; b++) { +801000a2: 8d 93 5c 02 00 00 lea 0x25c(%ebx),%edx +801000a8: 83 c4 10 add $0x10,%esp + bcache.head.next->prev = b; +801000ab: 89 58 50 mov %ebx,0x50(%eax) + bcache.head.next = b; +801000ae: 89 d8 mov %ebx,%eax +801000b0: 89 1d 70 0c 11 80 mov %ebx,0x80110c70 + for (b = bcache.buf; b < bcache.buf + NBUF; b++) { +801000b6: 81 fb c0 09 11 80 cmp $0x801109c0,%ebx +801000bc: 75 c2 jne 80100080 + } +} +801000be: 8b 5d fc mov -0x4(%ebp),%ebx +801000c1: c9 leave +801000c2: c3 ret +801000c3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801000ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +801000d0 : + panic("bget: no buffers"); +} + +// Return a locked buf with the contents of the indicated block. + +struct buf*bread(uint dev, uint blockno) { +801000d0: 55 push %ebp +801000d1: 89 e5 mov %esp,%ebp +801000d3: 57 push %edi +801000d4: 56 push %esi +801000d5: 53 push %ebx +801000d6: 83 ec 18 sub $0x18,%esp +801000d9: 8b 75 08 mov 0x8(%ebp),%esi +801000dc: 8b 7d 0c mov 0xc(%ebp),%edi + acquire(&bcache.lock); +801000df: 68 20 c5 10 80 push $0x8010c520 +801000e4: e8 97 5a 00 00 call 80105b80 + for (b = bcache.head.next; b != &bcache.head; b = b->next) { +801000e9: 8b 1d 70 0c 11 80 mov 0x80110c70,%ebx +801000ef: 83 c4 10 add $0x10,%esp +801000f2: 81 fb 1c 0c 11 80 cmp $0x80110c1c,%ebx +801000f8: 75 11 jne 8010010b +801000fa: eb 24 jmp 80100120 +801000fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80100100: 8b 5b 54 mov 0x54(%ebx),%ebx +80100103: 81 fb 1c 0c 11 80 cmp $0x80110c1c,%ebx +80100109: 74 15 je 80100120 + if (b->dev == dev && b->blockno == blockno) { +8010010b: 3b 73 04 cmp 0x4(%ebx),%esi +8010010e: 75 f0 jne 80100100 +80100110: 3b 7b 08 cmp 0x8(%ebx),%edi +80100113: 75 eb jne 80100100 + b->refcnt++; +80100115: 83 43 4c 01 addl $0x1,0x4c(%ebx) + release(&bcache.lock); +80100119: eb 3f jmp 8010015a +8010011b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010011f: 90 nop + for (b = bcache.head.prev; b != &bcache.head; b = b->prev) { +80100120: 8b 1d 6c 0c 11 80 mov 0x80110c6c,%ebx +80100126: 81 fb 1c 0c 11 80 cmp $0x80110c1c,%ebx +8010012c: 75 0d jne 8010013b +8010012e: eb 6e jmp 8010019e +80100130: 8b 5b 50 mov 0x50(%ebx),%ebx +80100133: 81 fb 1c 0c 11 80 cmp $0x80110c1c,%ebx +80100139: 74 63 je 8010019e + if (b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { +8010013b: 8b 43 4c mov 0x4c(%ebx),%eax +8010013e: 85 c0 test %eax,%eax +80100140: 75 ee jne 80100130 +80100142: f6 03 04 testb $0x4,(%ebx) +80100145: 75 e9 jne 80100130 + b->dev = dev; +80100147: 89 73 04 mov %esi,0x4(%ebx) + b->blockno = blockno; +8010014a: 89 7b 08 mov %edi,0x8(%ebx) + b->flags = 0; +8010014d: c7 03 00 00 00 00 movl $0x0,(%ebx) + b->refcnt = 1; +80100153: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) + release(&bcache.lock); +8010015a: 83 ec 0c sub $0xc,%esp +8010015d: 68 20 c5 10 80 push $0x8010c520 +80100162: e8 b9 59 00 00 call 80105b20 + acquiresleep(&b->lock); +80100167: 8d 43 0c lea 0xc(%ebx),%eax +8010016a: 89 04 24 mov %eax,(%esp) +8010016d: e8 4e 57 00 00 call 801058c0 + return b; +80100172: 83 c4 10 add $0x10,%esp + struct buf *b; + + b = bget(dev, blockno); + if ((b->flags & B_VALID) == 0) { +80100175: f6 03 02 testb $0x2,(%ebx) +80100178: 74 0e je 80100188 + iderw(b); + } + return b; +} +8010017a: 8d 65 f4 lea -0xc(%ebp),%esp +8010017d: 89 d8 mov %ebx,%eax +8010017f: 5b pop %ebx +80100180: 5e pop %esi +80100181: 5f pop %edi +80100182: 5d pop %ebp +80100183: c3 ret +80100184: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + iderw(b); +80100188: 83 ec 0c sub $0xc,%esp +8010018b: 53 push %ebx +8010018c: e8 3f 36 00 00 call 801037d0 +80100191: 83 c4 10 add $0x10,%esp +} +80100194: 8d 65 f4 lea -0xc(%ebp),%esp +80100197: 89 d8 mov %ebx,%eax +80100199: 5b pop %ebx +8010019a: 5e pop %esi +8010019b: 5f pop %edi +8010019c: 5d pop %ebp +8010019d: c3 ret + panic("bget: no buffers"); +8010019e: 83 ec 0c sub $0xc,%esp +801001a1: 68 6e 89 10 80 push $0x8010896e +801001a6: e8 d5 02 00 00 call 80100480 +801001ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801001af: 90 nop + +801001b0 : + +// Write b's contents to disk. Must be locked. + +void bwrite(struct buf *b) { +801001b0: 55 push %ebp +801001b1: 89 e5 mov %esp,%ebp +801001b3: 53 push %ebx +801001b4: 83 ec 10 sub $0x10,%esp +801001b7: 8b 5d 08 mov 0x8(%ebp),%ebx + if (!holdingsleep(&b->lock)) { +801001ba: 8d 43 0c lea 0xc(%ebx),%eax +801001bd: 50 push %eax +801001be: e8 9d 57 00 00 call 80105960 +801001c3: 83 c4 10 add $0x10,%esp +801001c6: 85 c0 test %eax,%eax +801001c8: 74 0f je 801001d9 + panic("bwrite"); + } + b->flags |= B_DIRTY; +801001ca: 83 0b 04 orl $0x4,(%ebx) + iderw(b); +801001cd: 89 5d 08 mov %ebx,0x8(%ebp) +} +801001d0: 8b 5d fc mov -0x4(%ebp),%ebx +801001d3: c9 leave + iderw(b); +801001d4: e9 f7 35 00 00 jmp 801037d0 + panic("bwrite"); +801001d9: 83 ec 0c sub $0xc,%esp +801001dc: 68 7f 89 10 80 push $0x8010897f +801001e1: e8 9a 02 00 00 call 80100480 +801001e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801001ed: 8d 76 00 lea 0x0(%esi),%esi + +801001f0 : + +// Release a locked buffer. +// Move to the head of the MRU list. + +void brelse(struct buf *b) { +801001f0: 55 push %ebp +801001f1: 89 e5 mov %esp,%ebp +801001f3: 56 push %esi +801001f4: 53 push %ebx +801001f5: 8b 5d 08 mov 0x8(%ebp),%ebx + if (!holdingsleep(&b->lock)) { +801001f8: 8d 73 0c lea 0xc(%ebx),%esi +801001fb: 83 ec 0c sub $0xc,%esp +801001fe: 56 push %esi +801001ff: e8 5c 57 00 00 call 80105960 +80100204: 83 c4 10 add $0x10,%esp +80100207: 85 c0 test %eax,%eax +80100209: 74 66 je 80100271 + panic("brelse"); + } + + releasesleep(&b->lock); +8010020b: 83 ec 0c sub $0xc,%esp +8010020e: 56 push %esi +8010020f: e8 0c 57 00 00 call 80105920 + + acquire(&bcache.lock); +80100214: c7 04 24 20 c5 10 80 movl $0x8010c520,(%esp) +8010021b: e8 60 59 00 00 call 80105b80 + b->refcnt--; +80100220: 8b 43 4c mov 0x4c(%ebx),%eax + if (b->refcnt == 0) { +80100223: 83 c4 10 add $0x10,%esp + b->refcnt--; +80100226: 83 e8 01 sub $0x1,%eax +80100229: 89 43 4c mov %eax,0x4c(%ebx) + if (b->refcnt == 0) { +8010022c: 85 c0 test %eax,%eax +8010022e: 75 2f jne 8010025f + // no one is waiting for it. + b->next->prev = b->prev; +80100230: 8b 43 54 mov 0x54(%ebx),%eax +80100233: 8b 53 50 mov 0x50(%ebx),%edx +80100236: 89 50 50 mov %edx,0x50(%eax) + b->prev->next = b->next; +80100239: 8b 43 50 mov 0x50(%ebx),%eax +8010023c: 8b 53 54 mov 0x54(%ebx),%edx +8010023f: 89 50 54 mov %edx,0x54(%eax) + b->next = bcache.head.next; +80100242: a1 70 0c 11 80 mov 0x80110c70,%eax + b->prev = &bcache.head; +80100247: c7 43 50 1c 0c 11 80 movl $0x80110c1c,0x50(%ebx) + b->next = bcache.head.next; +8010024e: 89 43 54 mov %eax,0x54(%ebx) + bcache.head.next->prev = b; +80100251: a1 70 0c 11 80 mov 0x80110c70,%eax +80100256: 89 58 50 mov %ebx,0x50(%eax) + bcache.head.next = b; +80100259: 89 1d 70 0c 11 80 mov %ebx,0x80110c70 + } + + release(&bcache.lock); +8010025f: c7 45 08 20 c5 10 80 movl $0x8010c520,0x8(%ebp) +} +80100266: 8d 65 f8 lea -0x8(%ebp),%esp +80100269: 5b pop %ebx +8010026a: 5e pop %esi +8010026b: 5d pop %ebp + release(&bcache.lock); +8010026c: e9 af 58 00 00 jmp 80105b20 + panic("brelse"); +80100271: 83 ec 0c sub $0xc,%esp +80100274: 68 86 89 10 80 push $0x80108986 +80100279: e8 02 02 00 00 call 80100480 +8010027e: 66 90 xchg %ax,%ax + +80100280 : + menuactive = 1; +} + +// Function that handles the moving of the highlight bar for the menu +static void navigatemenu(int dir) +{ +80100280: 55 push %ebp + int resultcount = 0; +80100281: 31 d2 xor %edx,%edx +{ +80100283: 89 e5 mov %esp,%ebp +80100285: 53 push %ebx + int pos = 0; + int newindex = currentmenuitem + dir; +80100286: 8b 1d c0 b6 11 80 mov 0x8011b6c0,%ebx +8010028c: 8d 0c 03 lea (%ebx,%eax,1),%ecx + for (int i = 0; i < MAXVCONSOLES; i++) +8010028f: b8 0c 1f 11 80 mov $0x80111f0c,%eax +80100294: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + resultcount++; +80100298: 83 38 01 cmpl $0x1,(%eax) +8010029b: 83 da ff sbb $0xffffffff,%edx + for (int i = 0; i < MAXVCONSOLES; i++) +8010029e: 05 b0 10 00 00 add $0x10b0,%eax +801002a3: 3d ec c5 11 80 cmp $0x8011c5ec,%eax +801002a8: 75 ee jne 80100298 + int totalactiveconsoles = getcurrentactiveconsolecount(); + + if (newindex < 0) +801002aa: 85 c9 test %ecx,%ecx +801002ac: 78 62 js 80100310 + { + newindex = 0; + } + else if (newindex >= totalactiveconsoles) + { + newindex = totalactiveconsoles - 1; +801002ae: 8d 42 ff lea -0x1(%edx),%eax +801002b1: 39 d1 cmp %edx,%ecx +801002b3: 0f 4d c8 cmovge %eax,%ecx + } + + // make sure the new index isnt just the same as the current selected menu item, we then change the background bits around + // which saves us from redrawing the menu every time the selected item changes + if (newindex != currentmenuitem) +801002b6: 39 cb cmp %ecx,%ebx +801002b8: 74 48 je 80100302 + { + // change the background bits of the last selected item to black + pos = TITLEOFF + ((currentmenuitem + 1) * SCRWIDTH); +801002ba: 8d 54 9b 0a lea 0xa(%ebx,%ebx,4),%edx +801002be: c1 e2 04 shl $0x4,%edx + for (int x = 2; x < MENUWIDTH - 2; x++) +801002c1: 8d 84 12 04 80 0b 80 lea -0x7ff47ffc(%edx,%edx,1),%eax +801002c8: 8d 94 12 32 80 0b 80 lea -0x7ff47fce(%edx,%edx,1),%edx +801002cf: 90 nop + { + crt[pos + x] = (crt[pos + x] & 0x00FF) | 0x0700; +801002d0: c6 40 01 07 movb $0x7,0x1(%eax) + for (int x = 2; x < MENUWIDTH - 2; x++) +801002d4: 83 c0 02 add $0x2,%eax +801002d7: 39 d0 cmp %edx,%eax +801002d9: 75 f5 jne 801002d0 + } + + // change the background bits of the new selected item to the highlight color + pos = TITLEOFF + ((newindex + 1) * SCRWIDTH); +801002db: 8d 54 89 0a lea 0xa(%ecx,%ecx,4),%edx +801002df: c1 e2 04 shl $0x4,%edx + for (int x = 2; x < MENUWIDTH - 2; x++) +801002e2: 8d 84 12 04 80 0b 80 lea -0x7ff47ffc(%edx,%edx,1),%eax +801002e9: 8d 94 12 32 80 0b 80 lea -0x7ff47fce(%edx,%edx,1),%edx + { + crt[pos + x] = crt[pos + x] | 0xCF00; +801002f0: 66 81 08 00 cf orw $0xcf00,(%eax) + for (int x = 2; x < MENUWIDTH - 2; x++) +801002f5: 83 c0 02 add $0x2,%eax +801002f8: 39 c2 cmp %eax,%edx +801002fa: 75 f4 jne 801002f0 + } + + currentmenuitem = newindex; +801002fc: 89 0d c0 b6 11 80 mov %ecx,0x8011b6c0 + } +} +80100302: 8b 5d fc mov -0x4(%ebp),%ebx +80100305: c9 leave +80100306: c3 ret +80100307: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010030e: 66 90 xchg %ax,%ax + newindex = 0; +80100310: 31 c9 xor %ecx,%ecx +80100312: eb a2 jmp 801002b6 +80100314: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010031b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010031f: 90 nop + +80100320 : + } + } +} + +int consoleread(struct inode *ip, char *dst, int n) +{ +80100320: 55 push %ebp +80100321: 89 e5 mov %esp,%ebp +80100323: 57 push %edi +80100324: 56 push %esi +80100325: 53 push %ebx +80100326: 83 ec 1c sub $0x1c,%esp + if (myproc() == 0x0) +80100329: e8 82 4b 00 00 call 80104eb0 +8010032e: 85 c0 test %eax,%eax +80100330: 0f 84 aa 00 00 00 je 801003e0 + inconsoleptr = myproc()->consoleptr; +80100336: e8 75 4b 00 00 call 80104eb0 +8010033b: 8b 58 7c mov 0x7c(%eax),%ebx + if (inconsoleptr == 0) +8010033e: 85 db test %ebx,%ebx +80100340: 0f 84 9a 00 00 00 je 801003e0 + uint target; + int c; + struct vconsole* inconsoleptr = getvalidprocessconsoleptr(); + struct kbdbuffer* consolekbdbuffer = &inconsoleptr->keybuffer; + + iunlock(ip); +80100346: 83 ec 0c sub $0xc,%esp +80100349: ff 75 08 push 0x8(%ebp) + target = n; + acquire(&inconsoleptr->lock); +8010034c: 8d 73 04 lea 0x4(%ebx),%esi + { + release(&inconsoleptr->lock); + ilock(ip); + return -1; + } + sleep(&(consolekbdbuffer->r), &inconsoleptr->lock); +8010034f: 8d bb 5c 10 00 00 lea 0x105c(%ebx),%edi + iunlock(ip); +80100355: e8 f6 29 00 00 call 80102d50 + target = n; +8010035a: 8b 45 10 mov 0x10(%ebp),%eax + acquire(&inconsoleptr->lock); +8010035d: 89 34 24 mov %esi,(%esp) + target = n; +80100360: 89 45 e4 mov %eax,-0x1c(%ebp) + acquire(&inconsoleptr->lock); +80100363: e8 18 58 00 00 call 80105b80 + while (n > 0) +80100368: 83 c4 10 add $0x10,%esp +8010036b: 8b 55 10 mov 0x10(%ebp),%edx +8010036e: 85 d2 test %edx,%edx +80100370: 0f 8e bc 00 00 00 jle 80100432 + while (consolekbdbuffer->r == consolekbdbuffer->w) +80100376: 8b 83 5c 10 00 00 mov 0x105c(%ebx),%eax +8010037c: 3b 83 60 10 00 00 cmp 0x1060(%ebx),%eax +80100382: 74 27 je 801003ab +80100384: eb 7a jmp 80100400 +80100386: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010038d: 8d 76 00 lea 0x0(%esi),%esi + sleep(&(consolekbdbuffer->r), &inconsoleptr->lock); +80100390: 83 ec 08 sub $0x8,%esp +80100393: 56 push %esi +80100394: 57 push %edi +80100395: e8 46 52 00 00 call 801055e0 + while (consolekbdbuffer->r == consolekbdbuffer->w) +8010039a: 8b 83 5c 10 00 00 mov 0x105c(%ebx),%eax +801003a0: 83 c4 10 add $0x10,%esp +801003a3: 3b 83 60 10 00 00 cmp 0x1060(%ebx),%eax +801003a9: 75 55 jne 80100400 + if (myproc()->killed) +801003ab: e8 00 4b 00 00 call 80104eb0 +801003b0: 8b 40 24 mov 0x24(%eax),%eax +801003b3: 85 c0 test %eax,%eax +801003b5: 74 d9 je 80100390 + release(&inconsoleptr->lock); +801003b7: 83 ec 0c sub $0xc,%esp +801003ba: 56 push %esi +801003bb: e8 60 57 00 00 call 80105b20 + ilock(ip); +801003c0: 59 pop %ecx +801003c1: ff 75 08 push 0x8(%ebp) +801003c4: e8 a7 28 00 00 call 80102c70 + return -1; +801003c9: 83 c4 10 add $0x10,%esp + } + release(&inconsoleptr->lock); + ilock(ip); + + return target - n; +} +801003cc: 8d 65 f4 lea -0xc(%ebp),%esp + return -1; +801003cf: b8 ff ff ff ff mov $0xffffffff,%eax +} +801003d4: 5b pop %ebx +801003d5: 5e pop %esi +801003d6: 5f pop %edi +801003d7: 5d pop %ebp +801003d8: c3 ret +801003d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + inconsoleptr = currentconsole; +801003e0: 8b 1d 80 0e 11 80 mov 0x80110e80,%ebx + if (inconsoleptr == 0) +801003e6: 85 db test %ebx,%ebx +801003e8: 0f 85 58 ff ff ff jne 80100346 + inconsoleptr = &consoles[0]; +801003ee: bb a0 0e 11 80 mov $0x80110ea0,%ebx +801003f3: e9 4e ff ff ff jmp 80100346 +801003f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801003ff: 90 nop + c = consolekbdbuffer->buf[consolekbdbuffer->r++ % INPUT_BUF]; +80100400: 8d 50 01 lea 0x1(%eax),%edx +80100403: 89 93 5c 10 00 00 mov %edx,0x105c(%ebx) +80100409: 89 c2 mov %eax,%edx +8010040b: 83 e2 7f and $0x7f,%edx +8010040e: 0f be 8c 13 dc 0f 00 movsbl 0xfdc(%ebx,%edx,1),%ecx +80100415: 00 + if (c == C('D')) +80100416: 80 f9 04 cmp $0x4,%cl +80100419: 74 3a je 80100455 + *dst++ = c; +8010041b: 83 45 0c 01 addl $0x1,0xc(%ebp) +8010041f: 8b 45 0c mov 0xc(%ebp),%eax + --n; +80100422: 83 6d 10 01 subl $0x1,0x10(%ebp) + *dst++ = c; +80100426: 88 48 ff mov %cl,-0x1(%eax) + if (c == '\n') +80100429: 83 f9 0a cmp $0xa,%ecx +8010042c: 0f 85 39 ff ff ff jne 8010036b + release(&inconsoleptr->lock); +80100432: 83 ec 0c sub $0xc,%esp +80100435: 56 push %esi +80100436: e8 e5 56 00 00 call 80105b20 + ilock(ip); +8010043b: 58 pop %eax +8010043c: ff 75 08 push 0x8(%ebp) +8010043f: e8 2c 28 00 00 call 80102c70 + return target - n; +80100444: 8b 45 e4 mov -0x1c(%ebp),%eax +80100447: 83 c4 10 add $0x10,%esp +8010044a: 2b 45 10 sub 0x10(%ebp),%eax +} +8010044d: 8d 65 f4 lea -0xc(%ebp),%esp +80100450: 5b pop %ebx +80100451: 5e pop %esi +80100452: 5f pop %edi +80100453: 5d pop %ebp +80100454: c3 ret + if (n < target) +80100455: 8b 4d e4 mov -0x1c(%ebp),%ecx +80100458: 39 4d 10 cmp %ecx,0x10(%ebp) +8010045b: 73 d5 jae 80100432 + consolekbdbuffer->r--; +8010045d: 89 83 5c 10 00 00 mov %eax,0x105c(%ebx) +80100463: eb cd jmp 80100432 +80100465: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010046c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80100470 : +{ +80100470: 55 push %ebp +80100471: 89 e5 mov %esp,%ebp + return consolein->consoleindex; +80100473: 8b 45 08 mov 0x8(%ebp),%eax +} +80100476: 5d pop %ebp + return consolein->consoleindex; +80100477: 8b 00 mov (%eax),%eax +} +80100479: c3 ret +8010047a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80100480 : +{ +80100480: 55 push %ebp +80100481: 89 e5 mov %esp,%ebp +80100483: 56 push %esi +80100484: 53 push %ebx +80100485: 83 ec 30 sub $0x30,%esp +static inline void loadgs(ushort v) { + asm volatile ("movw %0, %%gs" : : "r" (v)); +} + +static inline void cli(void) { + asm volatile ("cli"); +80100488: fa cli + cons.locking = 0; +80100489: c7 05 b4 b6 11 80 00 movl $0x0,0x8011b6b4 +80100490: 00 00 00 + getcallerpcs(&s, pcs); +80100493: 8d 5d d0 lea -0x30(%ebp),%ebx +80100496: 8d 75 f8 lea -0x8(%ebp),%esi + cprintf("lapicid %d: panic: ", lapicid()); +80100499: e8 42 39 00 00 call 80103de0 +8010049e: 83 ec 08 sub $0x8,%esp +801004a1: 50 push %eax +801004a2: 68 8d 89 10 80 push $0x8010898d +801004a7: e8 e4 03 00 00 call 80100890 + cprintf(s); +801004ac: 58 pop %eax +801004ad: ff 75 08 push 0x8(%ebp) +801004b0: e8 db 03 00 00 call 80100890 + cprintf("\n"); +801004b5: c7 04 24 b3 94 10 80 movl $0x801094b3,(%esp) +801004bc: e8 cf 03 00 00 call 80100890 + getcallerpcs(&s, pcs); +801004c1: 8d 45 08 lea 0x8(%ebp),%eax +801004c4: 5a pop %edx +801004c5: 59 pop %ecx +801004c6: 53 push %ebx +801004c7: 50 push %eax +801004c8: e8 03 55 00 00 call 801059d0 + for (i = 0; i < 10; i++) +801004cd: 83 c4 10 add $0x10,%esp + cprintf(" %p", pcs[i]); +801004d0: 83 ec 08 sub $0x8,%esp +801004d3: ff 33 push (%ebx) + for (i = 0; i < 10; i++) +801004d5: 83 c3 04 add $0x4,%ebx + cprintf(" %p", pcs[i]); +801004d8: 68 a1 89 10 80 push $0x801089a1 +801004dd: e8 ae 03 00 00 call 80100890 + for (i = 0; i < 10; i++) +801004e2: 83 c4 10 add $0x10,%esp +801004e5: 39 f3 cmp %esi,%ebx +801004e7: 75 e7 jne 801004d0 + panicked = 1; // freeze other CPU +801004e9: c7 05 b8 b6 11 80 01 movl $0x1,0x8011b6b8 +801004f0: 00 00 00 + for (;;) +801004f3: eb fe jmp 801004f3 +801004f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801004fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80100500 : +{ +80100500: 55 push %ebp +80100501: 89 e5 mov %esp,%ebp +80100503: 57 push %edi +80100504: 56 push %esi +80100505: 89 c6 mov %eax,%esi +80100507: 53 push %ebx +80100508: 83 ec 2c sub $0x2c,%esp + if (myproc() == 0x0) +8010050b: e8 a0 49 00 00 call 80104eb0 +80100510: 85 c0 test %eax,%eax +80100512: 0f 84 f8 00 00 00 je 80100610 + inconsoleptr = myproc()->consoleptr; +80100518: e8 93 49 00 00 call 80104eb0 +8010051d: 8b 78 7c mov 0x7c(%eax),%edi + if (inconsoleptr == 0) +80100520: 85 ff test %edi,%edi +80100522: 0f 84 e8 00 00 00 je 80100610 + if (inconsoleptr->inuse) +80100528: 8b 8f 70 10 00 00 mov 0x1070(%edi),%ecx + ushort *currentbuffer = inconsoleptr->screenbuffer; +8010052e: 8d 47 3c lea 0x3c(%edi),%eax +80100531: 89 45 e4 mov %eax,-0x1c(%ebp) + if (inconsoleptr->inuse) +80100534: 85 c9 test %ecx,%ecx +80100536: 0f 84 04 01 00 00 je 80100640 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +8010053c: bb d4 03 00 00 mov $0x3d4,%ebx +80100541: b8 0e 00 00 00 mov $0xe,%eax +80100546: 89 da mov %ebx,%edx +80100548: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80100549: ba d5 03 00 00 mov $0x3d5,%edx +8010054e: ec in (%dx),%al + pos = inb(CRTPORT + 1) << 8; +8010054f: 0f b6 c0 movzbl %al,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80100552: 89 da mov %ebx,%edx +80100554: c1 e0 08 shl $0x8,%eax +80100557: 89 45 e0 mov %eax,-0x20(%ebp) +8010055a: b8 0f 00 00 00 mov $0xf,%eax +8010055f: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80100560: ba d5 03 00 00 mov $0x3d5,%edx +80100565: ec in (%dx),%al + pos |= inb(CRTPORT + 1); +80100566: 0f b6 d8 movzbl %al,%ebx +80100569: 0b 5d e0 or -0x20(%ebp),%ebx + if (c == '\n') +8010056c: 83 fe 0a cmp $0xa,%esi +8010056f: 0f 84 da 00 00 00 je 8010064f + else if (c == BACKSPACE) +80100575: 81 fe 00 01 00 00 cmp $0x100,%esi +8010057b: 0f 84 ef 00 00 00 je 80100670 + crt[pos] = (c & 0xff) | 0x0700; // black on white +80100581: 89 f2 mov %esi,%edx + currentbuffer[pos] = 0; // Clear the character from the buffer +80100583: 8d 04 1b lea (%ebx,%ebx,1),%eax + crt[pos] = (c & 0xff) | 0x0700; // black on white +80100586: 0f b6 f2 movzbl %dl,%esi +80100589: 66 81 ce 00 07 or $0x700,%si + if (inconsoleptr->inuse) +8010058e: 85 c9 test %ecx,%ecx +80100590: 74 07 je 80100599 + crt[pos] = (c & 0xff) | 0x0700; // black on white +80100592: 66 89 b0 00 80 0b 80 mov %si,-0x7ff48000(%eax) + currentbuffer[pos] = (c & 0xff) | 0x0700; // black on white +80100599: 8b 4d e4 mov -0x1c(%ebp),%ecx + pos++; +8010059c: 83 c3 01 add $0x1,%ebx + currentbuffer[pos] = (c & 0xff) | 0x0700; // black on white +8010059f: 66 89 34 01 mov %si,(%ecx,%eax,1) + if (pos < TITLEOFF || pos > SCRHEIGHT * SCRWIDTH) +801005a3: 8d 73 b0 lea -0x50(%ebx),%esi +801005a6: 81 fe 80 07 00 00 cmp $0x780,%esi +801005ac: 0f 87 1f 02 00 00 ja 801007d1 + if ((pos / 80) >= 24) +801005b2: 81 fb 7f 07 00 00 cmp $0x77f,%ebx +801005b8: 0f 8f d2 00 00 00 jg 80100690 + if (inconsoleptr->inuse) +801005be: 8b 87 70 10 00 00 mov 0x1070(%edi),%eax + inconsoleptr->pos = pos; +801005c4: 89 9f 68 10 00 00 mov %ebx,0x1068(%edi) + if (inconsoleptr->inuse) +801005ca: 85 c0 test %eax,%eax +801005cc: 74 34 je 80100602 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +801005ce: be d4 03 00 00 mov $0x3d4,%esi +801005d3: b8 0e 00 00 00 mov $0xe,%eax +801005d8: 89 f2 mov %esi,%edx +801005da: ee out %al,(%dx) +801005db: b9 d5 03 00 00 mov $0x3d5,%ecx + outb(CRTPORT + 1, pos >> 8); +801005e0: 89 d8 mov %ebx,%eax +801005e2: c1 f8 08 sar $0x8,%eax +801005e5: 89 ca mov %ecx,%edx +801005e7: ee out %al,(%dx) +801005e8: b8 0f 00 00 00 mov $0xf,%eax +801005ed: 89 f2 mov %esi,%edx +801005ef: ee out %al,(%dx) +801005f0: 89 d8 mov %ebx,%eax +801005f2: 89 ca mov %ecx,%edx +801005f4: ee out %al,(%dx) + crt[pos] = ' ' | 0x0700; +801005f5: b8 20 07 00 00 mov $0x720,%eax +801005fa: 66 89 84 1b 00 80 0b mov %ax,-0x7ff48000(%ebx,%ebx,1) +80100601: 80 +} +80100602: 8d 65 f4 lea -0xc(%ebp),%esp +80100605: 5b pop %ebx +80100606: 5e pop %esi +80100607: 5f pop %edi +80100608: 5d pop %ebp +80100609: c3 ret +8010060a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + inconsoleptr = currentconsole; +80100610: 8b 3d 80 0e 11 80 mov 0x80110e80,%edi + if (inconsoleptr == 0) +80100616: 85 ff test %edi,%edi +80100618: 0f 85 0a ff ff ff jne 80100528 + inconsoleptr = &consoles[0]; +8010061e: bf a0 0e 11 80 mov $0x80110ea0,%edi + if (inconsoleptr->inuse) +80100623: 8b 8f 70 10 00 00 mov 0x1070(%edi),%ecx + ushort *currentbuffer = inconsoleptr->screenbuffer; +80100629: 8d 47 3c lea 0x3c(%edi),%eax +8010062c: 89 45 e4 mov %eax,-0x1c(%ebp) + if (inconsoleptr->inuse) +8010062f: 85 c9 test %ecx,%ecx +80100631: 0f 85 05 ff ff ff jne 8010053c +80100637: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010063e: 66 90 xchg %ax,%ax + pos = inconsoleptr->pos; +80100640: 8b 9f 68 10 00 00 mov 0x1068(%edi),%ebx + if (c == '\n') +80100646: 83 fe 0a cmp $0xa,%esi +80100649: 0f 85 26 ff ff ff jne 80100575 + pos += SCRWIDTH - pos % SCRWIDTH; +8010064f: 89 d8 mov %ebx,%eax +80100651: ba 67 66 66 66 mov $0x66666667,%edx +80100656: c1 fb 1f sar $0x1f,%ebx +80100659: f7 ea imul %edx +8010065b: c1 fa 05 sar $0x5,%edx +8010065e: 29 da sub %ebx,%edx +80100660: 8d 04 92 lea (%edx,%edx,4),%eax +80100663: c1 e0 04 shl $0x4,%eax +80100666: 8d 58 50 lea 0x50(%eax),%ebx +80100669: e9 35 ff ff ff jmp 801005a3 +8010066e: 66 90 xchg %ax,%ax + if (pos > (TITLEOFF)) +80100670: 83 fb 50 cmp $0x50,%ebx +80100673: 0f 8e 2a ff ff ff jle 801005a3 + currentbuffer[pos] = 0; // Clear the character from the buffer +80100679: 8b 45 e4 mov -0x1c(%ebp),%eax +8010067c: 31 f6 xor %esi,%esi +8010067e: 66 89 34 58 mov %si,(%eax,%ebx,2) + --pos; +80100682: 83 eb 01 sub $0x1,%ebx +80100685: e9 19 ff ff ff jmp 801005a3 +8010068a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + memmove(currentbuffer + TITLEOFF, currentbuffer + (SCRWIDTH + TITLEOFF), sizeof(crt[0]) * (SCRHEIGHT - 1) * SCRWIDTH); +80100690: 83 ec 04 sub $0x4,%esp +80100693: 8d 87 7c 01 00 00 lea 0x17c(%edi),%eax + pos -= 80; +80100699: 89 f3 mov %esi,%ebx + memmove(currentbuffer + TITLEOFF, currentbuffer + (SCRWIDTH + TITLEOFF), sizeof(crt[0]) * (SCRHEIGHT - 1) * SCRWIDTH); +8010069b: 68 00 0f 00 00 push $0xf00 +801006a0: 50 push %eax +801006a1: 8d 87 dc 00 00 00 lea 0xdc(%edi),%eax +801006a7: 50 push %eax +801006a8: e8 33 56 00 00 call 80105ce0 + memset(currentbuffer + pos, 0, sizeof(crt[0]) * (SCRHEIGHT * SCRWIDTH - pos)); +801006ad: b8 d0 07 00 00 mov $0x7d0,%eax +801006b2: 83 c4 0c add $0xc,%esp +801006b5: 8d 0c 36 lea (%esi,%esi,1),%ecx +801006b8: 29 f0 sub %esi,%eax +801006ba: 89 4d dc mov %ecx,-0x24(%ebp) +801006bd: 01 c0 add %eax,%eax +801006bf: 50 push %eax +801006c0: 89 45 e0 mov %eax,-0x20(%ebp) +801006c3: 8b 45 e4 mov -0x1c(%ebp),%eax +801006c6: 6a 00 push $0x0 +801006c8: 01 c8 add %ecx,%eax +801006ca: 50 push %eax +801006cb: e8 70 55 00 00 call 80105c40 + if (inconsoleptr->inuse) +801006d0: 8b 8f 70 10 00 00 mov 0x1070(%edi),%ecx +801006d6: 83 c4 10 add $0x10,%esp +801006d9: 85 c9 test %ecx,%ecx +801006db: 0f 84 c7 00 00 00 je 801007a8 + if (menuactive) +801006e1: 8b 15 bc b6 11 80 mov 0x8011b6bc,%edx +801006e7: 85 d2 test %edx,%edx +801006e9: 0f 84 d1 00 00 00 je 801007c0 +801006ef: b8 0c 1f 11 80 mov $0x80111f0c,%eax + int resultcount = 0; +801006f4: 31 d2 xor %edx,%edx +801006f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801006fd: 8d 76 00 lea 0x0(%esi),%esi + resultcount++; +80100700: 83 38 01 cmpl $0x1,(%eax) +80100703: 83 da ff sbb $0xffffffff,%edx + for (int i = 0; i < MAXVCONSOLES; i++) +80100706: 05 b0 10 00 00 add $0x10b0,%eax +8010070b: 3d ec c5 11 80 cmp $0x8011c5ec,%eax +80100710: 75 ee jne 80100700 + for (int y = 0; y < menuitems; y++) +80100712: 89 55 d8 mov %edx,-0x28(%ebp) + int menuitems = getcurrentactiveconsolecount() + 3; +80100715: be d6 80 0b 80 mov $0x800b80d6,%esi +8010071a: 8d 42 03 lea 0x3(%edx),%eax + for (int y = 0; y < menuitems; y++) +8010071d: 31 c9 xor %ecx,%ecx +8010071f: 89 5d e4 mov %ebx,-0x1c(%ebp) +80100722: 89 cb mov %ecx,%ebx +80100724: 89 7d d4 mov %edi,-0x2c(%ebp) +80100727: 89 f7 mov %esi,%edi +80100729: 89 c6 mov %eax,%esi +8010072b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010072f: 90 nop + memmove(crt + menuoffset + TITLEOFF + MENUWIDTH, crt + menuoffset + (SCRWIDTH + TITLEOFF) + MENUWIDTH, sizeof(crt[0]) * (SCRWIDTH - MENUWIDTH)); +80100730: 83 ec 04 sub $0x4,%esp +80100733: 89 f8 mov %edi,%eax +80100735: 81 c7 a0 00 00 00 add $0xa0,%edi + for (int y = 0; y < menuitems; y++) +8010073b: 83 c3 01 add $0x1,%ebx + memmove(crt + menuoffset + TITLEOFF + MENUWIDTH, crt + menuoffset + (SCRWIDTH + TITLEOFF) + MENUWIDTH, sizeof(crt[0]) * (SCRWIDTH - MENUWIDTH)); +8010073e: 6a 6a push $0x6a +80100740: 57 push %edi +80100741: 50 push %eax +80100742: e8 99 55 00 00 call 80105ce0 + for (int y = 0; y < menuitems; y++) +80100747: 83 c4 10 add $0x10,%esp +8010074a: 39 de cmp %ebx,%esi +8010074c: 75 e2 jne 80100730 +8010074e: 8b 55 d8 mov -0x28(%ebp),%edx +80100751: 8b 5d e4 mov -0x1c(%ebp),%ebx +80100754: 8b 7d d4 mov -0x2c(%ebp),%edi +80100757: 8d 04 92 lea (%edx,%edx,4),%eax + memmove(crt + TITLEOFF + menuoffset, crt + (SCRWIDTH + TITLEOFF) + menuoffset, (sizeof(crt[0]) * (SCRHEIGHT - 1) * SCRWIDTH) - menuoffset); +8010075a: ba 10 0e 00 00 mov $0xe10,%edx +8010075f: c1 e0 04 shl $0x4,%eax +80100762: 29 c2 sub %eax,%edx +80100764: 8d 84 00 20 03 00 00 lea 0x320(%eax,%eax,1),%eax +8010076b: 8d 88 00 80 0b 80 lea -0x7ff48000(%eax),%ecx +80100771: 2d a0 80 f4 7f sub $0x7ff480a0,%eax +80100776: 83 ec 04 sub $0x4,%esp +80100779: 52 push %edx +8010077a: 51 push %ecx +8010077b: 50 push %eax +8010077c: e8 5f 55 00 00 call 80105ce0 + memset(crt + pos, 0, sizeof(crt[0]) * (SCRHEIGHT * SCRWIDTH - pos)); +80100781: 8b 45 dc mov -0x24(%ebp),%eax +80100784: 83 c4 0c add $0xc,%esp +80100787: ff 75 e0 push -0x20(%ebp) +8010078a: 6a 00 push $0x0 +8010078c: 2d 00 80 f4 7f sub $0x7ff48000,%eax +80100791: 50 push %eax +80100792: e8 a9 54 00 00 call 80105c40 + if (inconsoleptr->inuse) +80100797: 8b 87 70 10 00 00 mov 0x1070(%edi),%eax +8010079d: 83 c4 10 add $0x10,%esp +801007a0: e9 1f fe ff ff jmp 801005c4 +801007a5: 8d 76 00 lea 0x0(%esi),%esi + inconsoleptr->pos = pos; +801007a8: 89 b7 68 10 00 00 mov %esi,0x1068(%edi) +} +801007ae: 8d 65 f4 lea -0xc(%ebp),%esp +801007b1: 5b pop %ebx +801007b2: 5e pop %esi +801007b3: 5f pop %edi +801007b4: 5d pop %ebp +801007b5: c3 ret +801007b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801007bd: 8d 76 00 lea 0x0(%esi),%esi +801007c0: b8 a0 80 0b 80 mov $0x800b80a0,%eax +801007c5: b9 40 81 0b 80 mov $0x800b8140,%ecx +801007ca: ba 00 0f 00 00 mov $0xf00,%edx +801007cf: eb a5 jmp 80100776 + panic("pos under/overflow"); +801007d1: 83 ec 0c sub $0xc,%esp +801007d4: 68 a5 89 10 80 push $0x801089a5 +801007d9: e8 a2 fc ff ff call 80100480 +801007de: 66 90 xchg %ax,%ax + +801007e0 : + +int consolewrite(struct inode *ip, char *buf, int n) +{ +801007e0: 55 push %ebp +801007e1: 89 e5 mov %esp,%ebp +801007e3: 57 push %edi +801007e4: 56 push %esi +801007e5: 53 push %ebx +801007e6: 83 ec 1c sub $0x1c,%esp + if (myproc() == 0x0) +801007e9: e8 c2 46 00 00 call 80104eb0 +801007ee: 85 c0 test %eax,%eax +801007f0: 74 4e je 80100840 + inconsoleptr = myproc()->consoleptr; +801007f2: e8 b9 46 00 00 call 80104eb0 +801007f7: 8b 58 7c mov 0x7c(%eax),%ebx + if (inconsoleptr == 0) +801007fa: 85 db test %ebx,%ebx +801007fc: 74 42 je 80100840 + int i; + struct vconsole* inconsoleptr = getvalidprocessconsoleptr(); + + iunlock(ip); +801007fe: 83 ec 0c sub $0xc,%esp +80100801: ff 75 08 push 0x8(%ebp) + acquire(&inconsoleptr->lock); +80100804: 83 c3 04 add $0x4,%ebx + iunlock(ip); +80100807: e8 44 25 00 00 call 80102d50 + acquire(&inconsoleptr->lock); +8010080c: 89 1c 24 mov %ebx,(%esp) +8010080f: e8 6c 53 00 00 call 80105b80 + for (i = 0; i < n; i++) +80100814: 8b 4d 10 mov 0x10(%ebp),%ecx +80100817: 83 c4 10 add $0x10,%esp +8010081a: 85 c9 test %ecx,%ecx +8010081c: 7e 51 jle 8010086f +8010081e: 8b 75 0c mov 0xc(%ebp),%esi +80100821: 8b 7d 10 mov 0x10(%ebp),%edi +80100824: 01 f7 add %esi,%edi + if (panicked) +80100826: 8b 15 b8 b6 11 80 mov 0x8011b6b8,%edx + { + consputc(buf[i] & 0xff); +8010082c: 0f b6 06 movzbl (%esi),%eax + if (panicked) +8010082f: 85 d2 test %edx,%edx +80100831: 74 1e je 80100851 + asm volatile ("cli"); +80100833: fa cli + for (;;) +80100834: eb fe jmp 80100834 +80100836: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010083d: 8d 76 00 lea 0x0(%esi),%esi + inconsoleptr = currentconsole; +80100840: 8b 1d 80 0e 11 80 mov 0x80110e80,%ebx + if (inconsoleptr == 0) +80100846: 85 db test %ebx,%ebx +80100848: 75 b4 jne 801007fe + inconsoleptr = &consoles[0]; +8010084a: bb a0 0e 11 80 mov $0x80110ea0,%ebx +8010084f: eb ad jmp 801007fe + uartputc(c); +80100851: 83 ec 0c sub $0xc,%esp +80100854: 89 45 e4 mov %eax,-0x1c(%ebp) + for (i = 0; i < n; i++) +80100857: 83 c6 01 add $0x1,%esi + uartputc(c); +8010085a: 50 push %eax +8010085b: e8 f0 6b 00 00 call 80107450 + cgaputc(c); +80100860: 8b 45 e4 mov -0x1c(%ebp),%eax +80100863: e8 98 fc ff ff call 80100500 + for (i = 0; i < n; i++) +80100868: 83 c4 10 add $0x10,%esp +8010086b: 39 f7 cmp %esi,%edi +8010086d: 75 b7 jne 80100826 + } + release(&inconsoleptr->lock); +8010086f: 83 ec 0c sub $0xc,%esp +80100872: 53 push %ebx +80100873: e8 a8 52 00 00 call 80105b20 + ilock(ip); +80100878: 58 pop %eax +80100879: ff 75 08 push 0x8(%ebp) +8010087c: e8 ef 23 00 00 call 80102c70 + + return n; +} +80100881: 8b 45 10 mov 0x10(%ebp),%eax +80100884: 8d 65 f4 lea -0xc(%ebp),%esp +80100887: 5b pop %ebx +80100888: 5e pop %esi +80100889: 5f pop %edi +8010088a: 5d pop %ebp +8010088b: c3 ret +8010088c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80100890 : +{ +80100890: 55 push %ebp +80100891: 89 e5 mov %esp,%ebp +80100893: 57 push %edi +80100894: 56 push %esi +80100895: 53 push %ebx +80100896: 83 ec 3c sub $0x3c,%esp + if (myproc() == 0x0) +80100899: e8 12 46 00 00 call 80104eb0 +8010089e: 85 c0 test %eax,%eax +801008a0: 0f 84 7a 01 00 00 je 80100a20 + inconsoleptr = myproc()->consoleptr; +801008a6: e8 05 46 00 00 call 80104eb0 +801008ab: 8b 40 7c mov 0x7c(%eax),%eax +801008ae: 89 45 cc mov %eax,-0x34(%ebp) + if (inconsoleptr == 0) +801008b1: 85 c0 test %eax,%eax +801008b3: 0f 84 67 01 00 00 je 80100a20 + locking = cons.locking; +801008b9: a1 b4 b6 11 80 mov 0x8011b6b4,%eax +801008be: 89 45 c4 mov %eax,-0x3c(%ebp) + if (locking) +801008c1: 85 c0 test %eax,%eax +801008c3: 0f 85 87 01 00 00 jne 80100a50 + if (fmt == 0) +801008c9: 8b 45 08 mov 0x8(%ebp),%eax +801008cc: 89 45 d0 mov %eax,-0x30(%ebp) +801008cf: 85 c0 test %eax,%eax +801008d1: 0f 84 10 03 00 00 je 80100be7 + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +801008d7: 0f b6 18 movzbl (%eax),%ebx + argp = (uint *)(void *)(&fmt + 1); +801008da: 8d 45 0c lea 0xc(%ebp),%eax + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +801008dd: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) + argp = (uint *)(void *)(&fmt + 1); +801008e4: 89 45 c8 mov %eax,-0x38(%ebp) + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +801008e7: 85 db test %ebx,%ebx +801008e9: 0f 84 e2 01 00 00 je 80100ad1 + if (c != '%') +801008ef: 83 fb 25 cmp $0x25,%ebx +801008f2: 0f 85 78 01 00 00 jne 80100a70 + c = fmt[++i] & 0xff; +801008f8: 83 45 d4 01 addl $0x1,-0x2c(%ebp) +801008fc: 8b 75 d0 mov -0x30(%ebp),%esi +801008ff: 8b 45 d4 mov -0x2c(%ebp),%eax +80100902: 0f b6 1c 06 movzbl (%esi,%eax,1),%ebx + if (c == 0) +80100906: 85 db test %ebx,%ebx +80100908: 0f 84 c3 01 00 00 je 80100ad1 + switch (c) +8010090e: 83 fb 70 cmp $0x70,%ebx +80100911: 0f 84 c2 00 00 00 je 801009d9 +80100917: 7f 7f jg 80100998 +80100919: 83 fb 25 cmp $0x25,%ebx +8010091c: 0f 84 c6 01 00 00 je 80100ae8 +80100922: 83 fb 64 cmp $0x64,%ebx +80100925: 0f 85 d5 01 00 00 jne 80100b00 + printint(*argp++, 10, 1); +8010092b: 8b 45 c8 mov -0x38(%ebp),%eax +8010092e: 8b 08 mov (%eax),%ecx + x = -xx; +80100930: 89 c8 mov %ecx,%eax + printint(*argp++, 10, 1); +80100932: 89 4d c0 mov %ecx,-0x40(%ebp) + x = -xx; +80100935: f7 d8 neg %eax +80100937: 0f 49 c8 cmovns %eax,%ecx + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +8010093a: 31 db xor %ebx,%ebx +8010093c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + buf[i++] = digits[x % base]; +80100940: b8 cd cc cc cc mov $0xcccccccd,%eax +80100945: 89 cf mov %ecx,%edi +80100947: 89 de mov %ebx,%esi +80100949: f7 e1 mul %ecx +8010094b: 8d 5b 01 lea 0x1(%ebx),%ebx +8010094e: c1 ea 03 shr $0x3,%edx +80100951: 8d 04 92 lea (%edx,%edx,4),%eax +80100954: 01 c0 add %eax,%eax +80100956: 29 c7 sub %eax,%edi +80100958: 0f b6 87 90 8a 10 80 movzbl -0x7fef7570(%edi),%eax +8010095f: 88 44 1d d7 mov %al,-0x29(%ebp,%ebx,1) + } while ((x /= base) != 0); +80100963: 89 c8 mov %ecx,%eax +80100965: 89 d1 mov %edx,%ecx +80100967: 83 f8 09 cmp $0x9,%eax +8010096a: 77 d4 ja 80100940 + if (sign) +8010096c: 8b 7d c0 mov -0x40(%ebp),%edi +8010096f: 85 ff test %edi,%edi +80100971: 79 07 jns 8010097a + buf[i++] = '-'; +80100973: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; +80100978: 89 de mov %ebx,%esi + while (--i >= 0) +8010097a: 8d 45 d8 lea -0x28(%ebp),%eax +8010097d: 01 c6 add %eax,%esi + if (panicked) +8010097f: 8b 0d b8 b6 11 80 mov 0x8011b6b8,%ecx + consputc(buf[i]); +80100985: 0f be 1e movsbl (%esi),%ebx + if (panicked) +80100988: 85 c9 test %ecx,%ecx +8010098a: 0f 84 88 01 00 00 je 80100b18 +80100990: fa cli + for (;;) +80100991: eb fe jmp 80100991 +80100993: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80100997: 90 nop + switch (c) +80100998: 83 fb 73 cmp $0x73,%ebx +8010099b: 75 33 jne 801009d0 + if ((s = (char *)*argp++) == 0) +8010099d: 8b 45 c8 mov -0x38(%ebp),%eax +801009a0: 8b 30 mov (%eax),%esi +801009a2: 8d 58 04 lea 0x4(%eax),%ebx +801009a5: 85 f6 test %esi,%esi +801009a7: 0f 84 02 02 00 00 je 80100baf + for (; *s; s++) +801009ad: 0f b6 06 movzbl (%esi),%eax +801009b0: 84 c0 test %al,%al +801009b2: 0f 84 ac 01 00 00 je 80100b64 + if (panicked) +801009b8: 8b 3d b8 b6 11 80 mov 0x8011b6b8,%edi +801009be: 85 ff test %edi,%edi +801009c0: 0f 84 7a 01 00 00 je 80100b40 +801009c6: fa cli + for (;;) +801009c7: eb fe jmp 801009c7 +801009c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + switch (c) +801009d0: 83 fb 78 cmp $0x78,%ebx +801009d3: 0f 85 27 01 00 00 jne 80100b00 + printint(*argp++, 16, 0); +801009d9: 8b 45 c8 mov -0x38(%ebp),%eax +801009dc: 8b 08 mov (%eax),%ecx + i = 0; +801009de: 31 c0 xor %eax,%eax + buf[i++] = digits[x % base]; +801009e0: 89 ca mov %ecx,%edx +801009e2: 89 c3 mov %eax,%ebx +801009e4: 83 c0 01 add $0x1,%eax +801009e7: 83 e2 0f and $0xf,%edx +801009ea: 0f b6 92 90 8a 10 80 movzbl -0x7fef7570(%edx),%edx +801009f1: 88 54 05 d7 mov %dl,-0x29(%ebp,%eax,1) + } while ((x /= base) != 0); +801009f5: 89 ca mov %ecx,%edx +801009f7: c1 e9 04 shr $0x4,%ecx +801009fa: 83 fa 0f cmp $0xf,%edx +801009fd: 77 e1 ja 801009e0 +801009ff: 8d 45 d8 lea -0x28(%ebp),%eax +80100a02: 01 c3 add %eax,%ebx + if (panicked) +80100a04: 8b 15 b8 b6 11 80 mov 0x8011b6b8,%edx + consputc(buf[i]); +80100a0a: 0f b6 03 movzbl (%ebx),%eax + if (panicked) +80100a0d: 85 d2 test %edx,%edx +80100a0f: 0f 84 57 01 00 00 je 80100b6c +80100a15: fa cli + for (;;) +80100a16: eb fe jmp 80100a16 +80100a18: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100a1f: 90 nop + inconsoleptr = currentconsole; +80100a20: a1 80 0e 11 80 mov 0x80110e80,%eax +80100a25: 89 45 cc mov %eax,-0x34(%ebp) + if (inconsoleptr == 0) +80100a28: 85 c0 test %eax,%eax +80100a2a: 0f 85 89 fe ff ff jne 801008b9 + locking = cons.locking; +80100a30: a1 b4 b6 11 80 mov 0x8011b6b4,%eax + inconsoleptr = &consoles[0]; +80100a35: c7 45 cc a0 0e 11 80 movl $0x80110ea0,-0x34(%ebp) + locking = cons.locking; +80100a3c: 89 45 c4 mov %eax,-0x3c(%ebp) + if (locking) +80100a3f: 85 c0 test %eax,%eax +80100a41: 0f 84 82 fe ff ff je 801008c9 +80100a47: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100a4e: 66 90 xchg %ax,%ax + acquire(&inconsoleptr->lock); +80100a50: 8b 45 cc mov -0x34(%ebp),%eax +80100a53: 83 ec 0c sub $0xc,%esp +80100a56: 83 c0 04 add $0x4,%eax +80100a59: 50 push %eax +80100a5a: e8 21 51 00 00 call 80105b80 +80100a5f: 83 c4 10 add $0x10,%esp +80100a62: e9 62 fe ff ff jmp 801008c9 +80100a67: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100a6e: 66 90 xchg %ax,%ax + if (panicked) +80100a70: a1 b8 b6 11 80 mov 0x8011b6b8,%eax +80100a75: 85 c0 test %eax,%eax +80100a77: 74 2f je 80100aa8 +80100a79: fa cli + for (;;) +80100a7a: eb fe jmp 80100a7a +80100a7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + uartputc(c); +80100a80: 83 ec 0c sub $0xc,%esp +80100a83: 6a 25 push $0x25 +80100a85: e8 c6 69 00 00 call 80107450 + cgaputc(c); +80100a8a: b8 25 00 00 00 mov $0x25,%eax +80100a8f: e8 6c fa ff ff call 80100500 + if (panicked) +80100a94: a1 b8 b6 11 80 mov 0x8011b6b8,%eax +80100a99: 83 c4 10 add $0x10,%esp +80100a9c: 85 c0 test %eax,%eax +80100a9e: 0f 85 23 01 00 00 jne 80100bc7 +80100aa4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + uartputc(c); +80100aa8: 83 ec 0c sub $0xc,%esp +80100aab: 53 push %ebx +80100aac: e8 9f 69 00 00 call 80107450 + cgaputc(c); +80100ab1: 89 d8 mov %ebx,%eax +80100ab3: e8 48 fa ff ff call 80100500 +} +80100ab8: 83 c4 10 add $0x10,%esp + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100abb: 83 45 d4 01 addl $0x1,-0x2c(%ebp) +80100abf: 8b 75 d0 mov -0x30(%ebp),%esi +80100ac2: 8b 45 d4 mov -0x2c(%ebp),%eax +80100ac5: 0f b6 1c 06 movzbl (%esi,%eax,1),%ebx +80100ac9: 85 db test %ebx,%ebx +80100acb: 0f 85 1e fe ff ff jne 801008ef + if (locking) +80100ad1: 8b 45 c4 mov -0x3c(%ebp),%eax +80100ad4: 85 c0 test %eax,%eax +80100ad6: 0f 85 f4 00 00 00 jne 80100bd0 +} +80100adc: 8d 65 f4 lea -0xc(%ebp),%esp +80100adf: 5b pop %ebx +80100ae0: 5e pop %esi +80100ae1: 5f pop %edi +80100ae2: 5d pop %ebp +80100ae3: c3 ret +80100ae4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (panicked) +80100ae8: 8b 0d b8 b6 11 80 mov 0x8011b6b8,%ecx +80100aee: 85 c9 test %ecx,%ecx +80100af0: 0f 84 9d 00 00 00 je 80100b93 +80100af6: fa cli + for (;;) +80100af7: eb fe jmp 80100af7 +80100af9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (panicked) +80100b00: 8b 15 b8 b6 11 80 mov 0x8011b6b8,%edx +80100b06: 85 d2 test %edx,%edx +80100b08: 0f 84 72 ff ff ff je 80100a80 +80100b0e: fa cli + for (;;) +80100b0f: eb fe jmp 80100b0f +80100b11: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + uartputc(c); +80100b18: 83 ec 0c sub $0xc,%esp + while (--i >= 0) +80100b1b: 8d 7d d8 lea -0x28(%ebp),%edi + uartputc(c); +80100b1e: 53 push %ebx +80100b1f: e8 2c 69 00 00 call 80107450 + cgaputc(c); +80100b24: 89 d8 mov %ebx,%eax +80100b26: e8 d5 f9 ff ff call 80100500 + while (--i >= 0) +80100b2b: 8d 46 ff lea -0x1(%esi),%eax +80100b2e: 83 c4 10 add $0x10,%esp +80100b31: 39 f7 cmp %esi,%edi +80100b33: 0f 84 85 00 00 00 je 80100bbe +80100b39: 89 c6 mov %eax,%esi +80100b3b: e9 3f fe ff ff jmp 8010097f + uartputc(c); +80100b40: 83 ec 0c sub $0xc,%esp + consputc(*s); +80100b43: 0f be f8 movsbl %al,%edi + for (; *s; s++) +80100b46: 83 c6 01 add $0x1,%esi + uartputc(c); +80100b49: 57 push %edi +80100b4a: e8 01 69 00 00 call 80107450 + cgaputc(c); +80100b4f: 89 f8 mov %edi,%eax +80100b51: e8 aa f9 ff ff call 80100500 + for (; *s; s++) +80100b56: 0f b6 06 movzbl (%esi),%eax +80100b59: 83 c4 10 add $0x10,%esp +80100b5c: 84 c0 test %al,%al +80100b5e: 0f 85 54 fe ff ff jne 801009b8 + if ((s = (char *)*argp++) == 0) +80100b64: 89 5d c8 mov %ebx,-0x38(%ebp) +80100b67: e9 4f ff ff ff jmp 80100abb + uartputc(c); +80100b6c: 83 ec 0c sub $0xc,%esp + consputc(buf[i]); +80100b6f: 0f be f0 movsbl %al,%esi + while (--i >= 0) +80100b72: 8d 7d d8 lea -0x28(%ebp),%edi + uartputc(c); +80100b75: 56 push %esi +80100b76: e8 d5 68 00 00 call 80107450 + cgaputc(c); +80100b7b: 89 f0 mov %esi,%eax +80100b7d: e8 7e f9 ff ff call 80100500 + while (--i >= 0) +80100b82: 8d 43 ff lea -0x1(%ebx),%eax +80100b85: 83 c4 10 add $0x10,%esp +80100b88: 39 df cmp %ebx,%edi +80100b8a: 74 32 je 80100bbe +80100b8c: 89 c3 mov %eax,%ebx +80100b8e: e9 71 fe ff ff jmp 80100a04 + uartputc(c); +80100b93: 83 ec 0c sub $0xc,%esp +80100b96: 6a 25 push $0x25 +80100b98: e8 b3 68 00 00 call 80107450 + cgaputc(c); +80100b9d: b8 25 00 00 00 mov $0x25,%eax +80100ba2: e8 59 f9 ff ff call 80100500 +} +80100ba7: 83 c4 10 add $0x10,%esp +80100baa: e9 0c ff ff ff jmp 80100abb + s = "(null)"; +80100baf: be b8 89 10 80 mov $0x801089b8,%esi + for (; *s; s++) +80100bb4: b8 28 00 00 00 mov $0x28,%eax +80100bb9: e9 fa fd ff ff jmp 801009b8 + printint(*argp++, 16, 0); +80100bbe: 83 45 c8 04 addl $0x4,-0x38(%ebp) +} +80100bc2: e9 f4 fe ff ff jmp 80100abb +80100bc7: fa cli + for (;;) +80100bc8: eb fe jmp 80100bc8 +80100bca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + release(&inconsoleptr->lock); +80100bd0: 8b 45 cc mov -0x34(%ebp),%eax +80100bd3: 83 ec 0c sub $0xc,%esp +80100bd6: 83 c0 04 add $0x4,%eax +80100bd9: 50 push %eax +80100bda: e8 41 4f 00 00 call 80105b20 +80100bdf: 83 c4 10 add $0x10,%esp +} +80100be2: e9 f5 fe ff ff jmp 80100adc + panic("null fmt"); +80100be7: 83 ec 0c sub $0xc,%esp +80100bea: 68 bf 89 10 80 push $0x801089bf +80100bef: e8 8c f8 ff ff call 80100480 +80100bf4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100bfb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80100bff: 90 nop + +80100c00 : +{ +80100c00: 55 push %ebp +80100c01: 89 e5 mov %esp,%ebp +80100c03: 57 push %edi +80100c04: 56 push %esi +80100c05: 53 push %ebx +80100c06: 83 ec 3c sub $0x3c,%esp + if (fmt == 0) +80100c09: 8b 45 0c mov 0xc(%ebp),%eax +80100c0c: 89 45 d0 mov %eax,-0x30(%ebp) +80100c0f: 85 c0 test %eax,%eax +80100c11: 0f 84 69 02 00 00 je 80100e80 + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100c17: 0f b6 00 movzbl (%eax),%eax + argp = (uint *)(void *)(&fmt + 1); +80100c1a: 8d 75 10 lea 0x10(%ebp),%esi + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100c1d: 31 ff xor %edi,%edi + si = 0; +80100c1f: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) +80100c26: 89 f3 mov %esi,%ebx +80100c28: 89 fe mov %edi,%esi + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100c2a: 89 c2 mov %eax,%edx +80100c2c: 85 c0 test %eax,%eax +80100c2e: 75 2b jne 80100c5b +80100c30: e9 21 01 00 00 jmp 80100d56 +80100c35: 8d 76 00 lea 0x0(%esi),%esi + strbuffer[si] = c; +80100c38: 8b 45 d4 mov -0x2c(%ebp),%eax +80100c3b: 8b 7d 08 mov 0x8(%ebp),%edi +80100c3e: 88 14 07 mov %dl,(%edi,%eax,1) + si++; +80100c41: 83 c0 01 add $0x1,%eax +80100c44: 89 45 d4 mov %eax,-0x2c(%ebp) + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100c47: 8b 45 d0 mov -0x30(%ebp),%eax +80100c4a: 83 c6 01 add $0x1,%esi +80100c4d: 0f b6 04 30 movzbl (%eax,%esi,1),%eax +80100c51: 89 c2 mov %eax,%edx +80100c53: 85 c0 test %eax,%eax +80100c55: 0f 84 f5 00 00 00 je 80100d50 + if (c != '%') +80100c5b: 83 f8 25 cmp $0x25,%eax +80100c5e: 75 d8 jne 80100c38 + c = fmt[++i] & 0xff; +80100c60: 8b 45 d0 mov -0x30(%ebp),%eax +80100c63: 83 c6 01 add $0x1,%esi +80100c66: 0f b6 04 30 movzbl (%eax,%esi,1),%eax +80100c6a: 89 c2 mov %eax,%edx + if (c == 0) +80100c6c: 85 c0 test %eax,%eax +80100c6e: 0f 84 dc 00 00 00 je 80100d50 + switch (c) +80100c74: 83 f8 70 cmp $0x70,%eax +80100c77: 0f 84 58 01 00 00 je 80100dd5 +80100c7d: 0f 8f e5 00 00 00 jg 80100d68 +80100c83: 83 f8 25 cmp $0x25,%eax +80100c86: 0f 84 e4 01 00 00 je 80100e70 +80100c8c: 83 f8 64 cmp $0x64,%eax +80100c8f: 0f 85 ba 01 00 00 jne 80100e4f + memset(buf, 0, sizeof buf); +80100c95: 83 ec 04 sub $0x4,%esp +80100c98: 8d 45 d8 lea -0x28(%ebp),%eax +80100c9b: 6a 10 push $0x10 +80100c9d: 6a 00 push $0x0 +80100c9f: 50 push %eax +80100ca0: e8 9b 4f 00 00 call 80105c40 + x = itoa(*argp++, 10, 1, buf); +80100ca5: 8b 0b mov (%ebx),%ecx +80100ca7: 8d 43 04 lea 0x4(%ebx),%eax + buf[i++] = digits[x % base]; +80100caa: 89 75 c4 mov %esi,-0x3c(%ebp) + x = itoa(*argp++, 10, 1, buf); +80100cad: 89 45 c0 mov %eax,-0x40(%ebp) + if (sign && (sign = xx < 0)) +80100cb0: 83 c4 10 add $0x10,%esp + x = -xx; +80100cb3: 89 c8 mov %ecx,%eax + x = itoa(*argp++, 10, 1, buf); +80100cb5: 89 4d c8 mov %ecx,-0x38(%ebp) + x = -xx; +80100cb8: f7 d8 neg %eax +80100cba: 0f 49 c8 cmovns %eax,%ecx + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100cbd: 31 db xor %ebx,%ebx +80100cbf: 90 nop + buf[i++] = digits[x % base]; +80100cc0: b8 cd cc cc cc mov $0xcccccccd,%eax +80100cc5: 89 cf mov %ecx,%edi +80100cc7: 89 de mov %ebx,%esi +80100cc9: f7 e1 mul %ecx +80100ccb: 8d 5b 01 lea 0x1(%ebx),%ebx +80100cce: c1 ea 03 shr $0x3,%edx +80100cd1: 8d 04 92 lea (%edx,%edx,4),%eax +80100cd4: 01 c0 add %eax,%eax +80100cd6: 29 c7 sub %eax,%edi +80100cd8: 0f b6 87 90 8a 10 80 movzbl -0x7fef7570(%edi),%eax +80100cdf: 88 44 1d d7 mov %al,-0x29(%ebp,%ebx,1) + } while ((x /= base) != 0); +80100ce3: 89 c8 mov %ecx,%eax +80100ce5: 89 d1 mov %edx,%ecx +80100ce7: 83 f8 09 cmp $0x9,%eax +80100cea: 77 d4 ja 80100cc0 + if (sign) +80100cec: 8b 45 c8 mov -0x38(%ebp),%eax +80100cef: 89 75 cc mov %esi,-0x34(%ebp) +80100cf2: 8b 75 c4 mov -0x3c(%ebp),%esi +80100cf5: 85 c0 test %eax,%eax +80100cf7: 79 08 jns 80100d01 + buf[i++] = '-'; +80100cf9: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; +80100cfe: 89 5d cc mov %ebx,-0x34(%ebp) + while (--x >= 0) +80100d01: 8b 55 d4 mov -0x2c(%ebp),%edx +80100d04: 8d 45 d8 lea -0x28(%ebp),%eax +80100d07: 03 55 08 add 0x8(%ebp),%edx +80100d0a: 03 45 cc add -0x34(%ebp),%eax +80100d0d: 8d 76 00 lea 0x0(%esi),%esi + strbuffer[si] = buf[x]; +80100d10: 0f b6 08 movzbl (%eax),%ecx + while (--x >= 0) +80100d13: 8d 7d d8 lea -0x28(%ebp),%edi +80100d16: 83 c2 01 add $0x1,%edx + strbuffer[si] = buf[x]; +80100d19: 88 4a ff mov %cl,-0x1(%edx) + while (--x >= 0) +80100d1c: 89 c1 mov %eax,%ecx +80100d1e: 83 e8 01 sub $0x1,%eax +80100d21: 39 cf cmp %ecx,%edi +80100d23: 75 eb jne 80100d10 + si++; +80100d25: 8b 45 d4 mov -0x2c(%ebp),%eax +80100d28: 8b 7d cc mov -0x34(%ebp),%edi + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100d2b: 83 c6 01 add $0x1,%esi + x = itoa(*argp++, 10, 1, buf); +80100d2e: 8b 5d c0 mov -0x40(%ebp),%ebx + si++; +80100d31: 8d 44 38 01 lea 0x1(%eax,%edi,1),%eax +80100d35: 89 45 d4 mov %eax,-0x2c(%ebp) + for (i = 0; (c = fmt[i] & 0xff) != 0; i++) +80100d38: 8b 45 d0 mov -0x30(%ebp),%eax +80100d3b: 0f b6 04 30 movzbl (%eax,%esi,1),%eax +80100d3f: 89 c2 mov %eax,%edx +80100d41: 85 c0 test %eax,%eax +80100d43: 0f 85 12 ff ff ff jne 80100c5b +80100d49: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + strbuffer[si] = '\0'; +80100d50: 8b 45 d4 mov -0x2c(%ebp),%eax +80100d53: 01 45 08 add %eax,0x8(%ebp) +80100d56: 8b 45 08 mov 0x8(%ebp),%eax +80100d59: c6 00 00 movb $0x0,(%eax) +} +80100d5c: 8d 65 f4 lea -0xc(%ebp),%esp +80100d5f: 5b pop %ebx +80100d60: 5e pop %esi +80100d61: 5f pop %edi +80100d62: 5d pop %ebp +80100d63: c3 ret +80100d64: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + switch (c) +80100d68: 83 f8 73 cmp $0x73,%eax +80100d6b: 75 63 jne 80100dd0 + if ((s = (char *)*argp++) == 0) +80100d6d: 8b 13 mov (%ebx),%edx +80100d6f: 8d 43 04 lea 0x4(%ebx),%eax + strbuffer[si] = s[sli]; +80100d72: 8b 4d 08 mov 0x8(%ebp),%ecx +80100d75: 89 75 c4 mov %esi,-0x3c(%ebp) + if ((s = (char *)*argp++) == 0) +80100d78: 89 45 c8 mov %eax,-0x38(%ebp) +80100d7b: b8 b8 89 10 80 mov $0x801089b8,%eax +80100d80: 85 d2 test %edx,%edx +80100d82: 0f 45 c2 cmovne %edx,%eax + for (int sli = 0; sli < strlen(s); sli++) +80100d85: 31 ff xor %edi,%edi + if ((s = (char *)*argp++) == 0) +80100d87: 89 c3 mov %eax,%ebx + strbuffer[si] = s[sli]; +80100d89: 8b 45 d4 mov -0x2c(%ebp),%eax +80100d8c: 01 c1 add %eax,%ecx +80100d8e: 89 c6 mov %eax,%esi +80100d90: 89 f8 mov %edi,%eax +80100d92: 89 df mov %ebx,%edi +80100d94: 89 4d cc mov %ecx,-0x34(%ebp) +80100d97: 89 c3 mov %eax,%ebx + for (int sli = 0; sli < strlen(s); sli++) +80100d99: eb 12 jmp 80100dad +80100d9b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80100d9f: 90 nop + strbuffer[si] = s[sli]; +80100da0: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax +80100da4: 8b 4d cc mov -0x34(%ebp),%ecx +80100da7: 88 04 19 mov %al,(%ecx,%ebx,1) + for (int sli = 0; sli < strlen(s); sli++) +80100daa: 83 c3 01 add $0x1,%ebx +80100dad: 83 ec 0c sub $0xc,%esp +80100db0: 8d 04 33 lea (%ebx,%esi,1),%eax +80100db3: 57 push %edi +80100db4: 89 45 d4 mov %eax,-0x2c(%ebp) +80100db7: e8 84 50 00 00 call 80105e40 +80100dbc: 83 c4 10 add $0x10,%esp +80100dbf: 39 d8 cmp %ebx,%eax +80100dc1: 7f dd jg 80100da0 + if ((s = (char *)*argp++) == 0) +80100dc3: 8b 75 c4 mov -0x3c(%ebp),%esi +80100dc6: 8b 5d c8 mov -0x38(%ebp),%ebx +80100dc9: e9 79 fe ff ff jmp 80100c47 +80100dce: 66 90 xchg %ax,%ax + switch (c) +80100dd0: 83 f8 78 cmp $0x78,%eax +80100dd3: 75 7a jne 80100e4f + memset(buf, 0, sizeof buf); +80100dd5: 83 ec 04 sub $0x4,%esp +80100dd8: 8d 45 d8 lea -0x28(%ebp),%eax +80100ddb: 6a 10 push $0x10 +80100ddd: 6a 00 push $0x0 +80100ddf: 50 push %eax +80100de0: e8 5b 4e 00 00 call 80105c40 + x = itoa(*argp++, 16, 0, buf); +80100de5: 8d 43 04 lea 0x4(%ebx),%eax +80100de8: 83 c4 10 add $0x10,%esp + i = 0; +80100deb: 31 d2 xor %edx,%edx + x = itoa(*argp++, 16, 0, buf); +80100ded: 89 45 cc mov %eax,-0x34(%ebp) +80100df0: 8b 03 mov (%ebx),%eax + i = 0; +80100df2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + buf[i++] = digits[x % base]; +80100df8: 89 c3 mov %eax,%ebx +80100dfa: 89 d1 mov %edx,%ecx +80100dfc: 8d 52 01 lea 0x1(%edx),%edx +80100dff: 83 e3 0f and $0xf,%ebx +80100e02: 0f b6 9b 90 8a 10 80 movzbl -0x7fef7570(%ebx),%ebx +80100e09: 88 5c 15 d7 mov %bl,-0x29(%ebp,%edx,1) + } while ((x /= base) != 0); +80100e0d: 89 c3 mov %eax,%ebx +80100e0f: c1 e8 04 shr $0x4,%eax +80100e12: 83 fb 0f cmp $0xf,%ebx +80100e15: 77 e1 ja 80100df8 +80100e17: 8d 45 d8 lea -0x28(%ebp),%eax +80100e1a: 8b 55 d4 mov -0x2c(%ebp),%edx +80100e1d: 03 55 08 add 0x8(%ebp),%edx +80100e20: 01 c8 add %ecx,%eax +80100e22: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + strbuffer[si] = buf[x]; +80100e28: 0f b6 18 movzbl (%eax),%ebx + while (--x >= 0) +80100e2b: 8d 7d d8 lea -0x28(%ebp),%edi +80100e2e: 83 c2 01 add $0x1,%edx + strbuffer[si] = buf[x]; +80100e31: 88 5a ff mov %bl,-0x1(%edx) + while (--x >= 0) +80100e34: 89 c3 mov %eax,%ebx +80100e36: 83 e8 01 sub $0x1,%eax +80100e39: 39 df cmp %ebx,%edi +80100e3b: 75 eb jne 80100e28 + si++; +80100e3d: 8b 45 d4 mov -0x2c(%ebp),%eax + x = itoa(*argp++, 16, 0, buf); +80100e40: 8b 5d cc mov -0x34(%ebp),%ebx + si++; +80100e43: 8d 44 01 01 lea 0x1(%ecx,%eax,1),%eax +80100e47: 89 45 d4 mov %eax,-0x2c(%ebp) +80100e4a: e9 f8 fd ff ff jmp 80100c47 + strbuffer[si] = '%'; +80100e4f: 8b 45 d4 mov -0x2c(%ebp),%eax +80100e52: 8b 7d 08 mov 0x8(%ebp),%edi +80100e55: c6 04 07 25 movb $0x25,(%edi,%eax,1) + strbuffer[si] = c; +80100e59: 88 54 07 01 mov %dl,0x1(%edi,%eax,1) + si++; +80100e5d: 83 c0 02 add $0x2,%eax +80100e60: 89 45 d4 mov %eax,-0x2c(%ebp) + break; +80100e63: e9 df fd ff ff jmp 80100c47 +80100e68: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100e6f: 90 nop + strbuffer[i] = '%'; +80100e70: 8b 45 08 mov 0x8(%ebp),%eax + si++; +80100e73: 83 45 d4 01 addl $0x1,-0x2c(%ebp) + strbuffer[i] = '%'; +80100e77: c6 04 30 25 movb $0x25,(%eax,%esi,1) + break; +80100e7b: e9 c7 fd ff ff jmp 80100c47 + panic("null fmt"); +80100e80: 83 ec 0c sub $0xc,%esp +80100e83: 68 bf 89 10 80 push $0x801089bf +80100e88: e8 f3 f5 ff ff call 80100480 +80100e8d: 8d 76 00 lea 0x0(%esi),%esi + +80100e90 : +{ +80100e90: 55 push %ebp +80100e91: 89 e5 mov %esp,%ebp +80100e93: 53 push %ebx +80100e94: 83 ec 24 sub $0x24,%esp + if (myproc() == 0x0) +80100e97: e8 14 40 00 00 call 80104eb0 +80100e9c: 85 c0 test %eax,%eax +80100e9e: 0f 84 9d 00 00 00 je 80100f41 + inconsoleptr = myproc()->consoleptr; +80100ea4: e8 07 40 00 00 call 80104eb0 +80100ea9: 8b 58 7c mov 0x7c(%eax),%ebx + if (inconsoleptr == 0) +80100eac: 85 db test %ebx,%ebx +80100eae: 0f 84 8d 00 00 00 je 80100f41 + char menutext[] = "(M)enu"; +80100eb4: b8 6e 75 00 00 mov $0x756e,%eax + sprintf(consoletitletext, "Console %d", inconsoleptr->consoleindex); +80100eb9: 83 ec 04 sub $0x4,%esp +80100ebc: ff 33 push (%ebx) + char menutext[] = "(M)enu"; +80100ebe: 66 89 45 eb mov %ax,-0x15(%ebp) + sprintf(consoletitletext, "Console %d", inconsoleptr->consoleindex); +80100ec2: 8d 45 ee lea -0x12(%ebp),%eax +80100ec5: 68 c8 89 10 80 push $0x801089c8 +80100eca: 50 push %eax + char menutext[] = "(M)enu"; +80100ecb: c7 45 e7 28 4d 29 65 movl $0x65294d28,-0x19(%ebp) +80100ed2: c6 45 ed 00 movb $0x0,-0x13(%ebp) + sprintf(consoletitletext, "Console %d", inconsoleptr->consoleindex); +80100ed6: e8 25 fd ff ff call 80100c00 + crt[pos] = (c & 0xff) | inconsoleptr->titlebgcol; +80100edb: 8b 8b 74 10 00 00 mov 0x1074(%ebx),%ecx +80100ee1: 83 c4 10 add $0x10,%esp + for (pos = 0; pos < SCRWIDTH; pos++) +80100ee4: 31 c0 xor %eax,%eax +80100ee6: eb 4d jmp 80100f35 +80100ee8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100eef: 90 nop + else if (pos >= 10 && pos < 20) +80100ef0: 8d 50 f6 lea -0xa(%eax),%edx +80100ef3: 83 fa 09 cmp $0x9,%edx +80100ef6: 76 6d jbe 80100f65 + else if (pos >= 25 && pos < 45) +80100ef8: 8d 50 e7 lea -0x19(%eax),%edx +80100efb: 83 fa 13 cmp $0x13,%edx +80100efe: 76 76 jbe 80100f76 + else if (pos >= 50 && pos < 80) +80100f00: 8d 50 ce lea -0x32(%eax),%edx +80100f03: 83 fa 1d cmp $0x1d,%edx +80100f06: 76 64 jbe 80100f6c +80100f08: ba 20 00 00 00 mov $0x20,%edx + if (inconsoleptr->inuse) +80100f0d: 83 bb 70 10 00 00 00 cmpl $0x0,0x1070(%ebx) +80100f14: 74 10 je 80100f26 + crt[pos] = (c & 0xff) | inconsoleptr->titlebgcol; +80100f16: 09 d1 or %edx,%ecx +80100f18: 66 89 8c 00 00 80 0b mov %cx,-0x7ff48000(%eax,%eax,1) +80100f1f: 80 + inconsoleptr->screenbuffer[pos] = (c & 0xff) | inconsoleptr->titlebgcol; +80100f20: 8b 8b 74 10 00 00 mov 0x1074(%ebx),%ecx +80100f26: 09 ca or %ecx,%edx +80100f28: 66 89 54 43 3c mov %dx,0x3c(%ebx,%eax,2) + for (pos = 0; pos < SCRWIDTH; pos++) +80100f2d: 83 c0 01 add $0x1,%eax +80100f30: 83 f8 50 cmp $0x50,%eax +80100f33: 74 2b je 80100f60 + if (pos < 6) { +80100f35: 83 f8 05 cmp $0x5,%eax +80100f38: 7f b6 jg 80100ef0 + crt[pos] = (c & 0xff) | inconsoleptr->titlebgcol; +80100f3a: 0f b6 54 05 e7 movzbl -0x19(%ebp,%eax,1),%edx +80100f3f: eb cc jmp 80100f0d + inconsoleptr = currentconsole; +80100f41: 8b 1d 80 0e 11 80 mov 0x80110e80,%ebx + if (inconsoleptr == 0) +80100f47: 85 db test %ebx,%ebx +80100f49: 0f 85 65 ff ff ff jne 80100eb4 + inconsoleptr = &consoles[0]; +80100f4f: bb a0 0e 11 80 mov $0x80110ea0,%ebx +80100f54: e9 5b ff ff ff jmp 80100eb4 +80100f59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +} +80100f60: 8b 5d fc mov -0x4(%ebp),%ebx +80100f63: c9 leave +80100f64: c3 ret + crt[pos] = (c & 0xff) | inconsoleptr->titlebgcol; +80100f65: 0f b6 54 05 e4 movzbl -0x1c(%ebp,%eax,1),%edx +80100f6a: eb a1 jmp 80100f0d +80100f6c: 0f b6 94 03 5e 10 00 movzbl 0x105e(%ebx,%eax,1),%edx +80100f73: 00 +80100f74: eb 97 jmp 80100f0d +80100f76: 0f b6 94 03 5f 10 00 movzbl 0x105f(%ebx,%eax,1),%edx +80100f7d: 00 +80100f7e: eb 8d jmp 80100f0d + +80100f80 : +{ +80100f80: 55 push %ebp +80100f81: 89 e5 mov %esp,%ebp +80100f83: 83 ec 08 sub $0x8,%esp + if (myproc() == 0x0) +80100f86: e8 25 3f 00 00 call 80104eb0 +80100f8b: 85 c0 test %eax,%eax +80100f8d: 74 11 je 80100fa0 + inconsoleptr = myproc()->consoleptr; +80100f8f: e8 1c 3f 00 00 call 80104eb0 +80100f94: 8b 40 7c mov 0x7c(%eax),%eax + if (inconsoleptr == 0) +80100f97: 85 c0 test %eax,%eax +80100f99: 74 05 je 80100fa0 +} +80100f9b: c9 leave +80100f9c: c3 ret +80100f9d: 8d 76 00 lea 0x0(%esi),%esi + inconsoleptr = currentconsole; +80100fa0: a1 80 0e 11 80 mov 0x80110e80,%eax + if (inconsoleptr == 0) +80100fa5: 85 c0 test %eax,%eax +80100fa7: 75 f2 jne 80100f9b +} +80100fa9: c9 leave + inconsoleptr = &consoles[0]; +80100faa: b8 a0 0e 11 80 mov $0x80110ea0,%eax +} +80100faf: c3 ret + +80100fb0 : +{ +80100fb0: 55 push %ebp +80100fb1: 89 e5 mov %esp,%ebp +80100fb3: 83 ec 24 sub $0x24,%esp + acquire(&cons.lock); +80100fb6: 68 80 b6 11 80 push $0x8011b680 +80100fbb: e8 c0 4b 00 00 call 80105b80 + while ((c = kbdgetc()) <= 0) +80100fc0: 83 c4 10 add $0x10,%esp +80100fc3: eb 05 jmp 80100fca +80100fc5: 8d 76 00 lea 0x0(%esi),%esi + if (c == 0) +80100fc8: 74 26 je 80100ff0 + while ((c = kbdgetc()) <= 0) +80100fca: e8 11 2c 00 00 call 80103be0 +80100fcf: 85 c0 test %eax,%eax +80100fd1: 7e f5 jle 80100fc8 + release(&cons.lock); +80100fd3: 83 ec 0c sub $0xc,%esp +80100fd6: 89 45 f4 mov %eax,-0xc(%ebp) +80100fd9: 68 80 b6 11 80 push $0x8011b680 +80100fde: e8 3d 4b 00 00 call 80105b20 +} +80100fe3: 8b 45 f4 mov -0xc(%ebp),%eax +80100fe6: c9 leave +80100fe7: c3 ret +80100fe8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100fef: 90 nop + c = kbdgetc(); +80100ff0: e8 eb 2b 00 00 call 80103be0 +80100ff5: eb d3 jmp 80100fca +80100ff7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100ffe: 66 90 xchg %ax,%ax + +80101000 : + +// Function to flood a buffer with A-Z characters looping (for testing initially) +void testfillbuffer(ushort *bufferin) +{ +80101000: 55 push %ebp + ushort firstchar = 65; + ushort lastchar = 90; + ushort currentchar = firstchar; +80101001: ba 41 00 00 00 mov $0x41,%edx +{ +80101006: 89 e5 mov %esp,%ebp +80101008: 53 push %ebx +80101009: 8b 45 08 mov 0x8(%ebp),%eax +8010100c: 8d 98 a0 0f 00 00 lea 0xfa0(%eax),%ebx +80101012: eb 17 jmp 8010102b +80101014: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (currentchar > lastchar) + { + currentchar = firstchar; + } + + bufferin[i] = (currentchar & 0xff) | 0x0700; +80101018: 89 d1 mov %edx,%ecx + for (int i = 0; i < (SCRHEIGHT * SCRWIDTH); i++) +8010101a: 83 c0 02 add $0x2,%eax + + currentchar++; +8010101d: 83 c2 01 add $0x1,%edx + bufferin[i] = (currentchar & 0xff) | 0x0700; +80101020: 80 cd 07 or $0x7,%ch +80101023: 66 89 48 fe mov %cx,-0x2(%eax) + for (int i = 0; i < (SCRHEIGHT * SCRWIDTH); i++) +80101027: 39 c3 cmp %eax,%ebx +80101029: 74 1b je 80101046 + if (currentchar > lastchar) +8010102b: 66 83 fa 5b cmp $0x5b,%dx +8010102f: 75 e7 jne 80101018 +80101031: b9 41 07 00 00 mov $0x741,%ecx + for (int i = 0; i < (SCRHEIGHT * SCRWIDTH); i++) +80101036: 83 c0 02 add $0x2,%eax +80101039: ba 42 00 00 00 mov $0x42,%edx + bufferin[i] = (currentchar & 0xff) | 0x0700; +8010103e: 66 89 48 fe mov %cx,-0x2(%eax) + for (int i = 0; i < (SCRHEIGHT * SCRWIDTH); i++) +80101042: 39 c3 cmp %eax,%ebx +80101044: 75 e5 jne 8010102b + } +} +80101046: 8b 5d fc mov -0x4(%ebp),%ebx +80101049: c9 leave +8010104a: c3 ret +8010104b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010104f: 90 nop + +80101050 : + +// Function to get a pointer to the base console +struct vconsole* getbaseconsoleptr(void) +{ + return &consoles[0]; +} +80101050: b8 a0 0e 11 80 mov $0x80110ea0,%eax +80101055: c3 ret +80101056: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010105d: 8d 76 00 lea 0x0(%esi),%esi + +80101060 : + +// Function to clear a given buffer using its pointer/address +void clearconsole(ushort *bufferin) +{ +80101060: 55 push %ebp +80101061: 89 e5 mov %esp,%ebp +80101063: 83 ec 0c sub $0xc,%esp + // Flood the screen buffer with blank spaces + memset(bufferin, 0, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101066: 68 a0 0f 00 00 push $0xfa0 +8010106b: 6a 00 push $0x0 +8010106d: ff 75 08 push 0x8(%ebp) +80101070: e8 cb 4b 00 00 call 80105c40 +} +80101075: 83 c4 10 add $0x10,%esp +80101078: c9 leave +80101079: c3 ret +8010107a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80101080 : + +// Function for loading an entire buffer into the screen memory using its pointer/address +void loadscreenbuffer(ushort *bufferin) +{ +80101080: 55 push %ebp +80101081: 89 e5 mov %esp,%ebp +80101083: 83 ec 0c sub $0xc,%esp + // Copy the memory from the console buffer to the crt buffer + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101086: 68 a0 0f 00 00 push $0xfa0 +8010108b: ff 75 08 push 0x8(%ebp) +8010108e: 68 00 80 0b 80 push $0x800b8000 +80101093: e8 48 4c 00 00 call 80105ce0 +} +80101098: 83 c4 10 add $0x10,%esp +8010109b: c9 leave +8010109c: c3 ret +8010109d: 8d 76 00 lea 0x0(%esi),%esi + +801010a0 : + +// Function for saving the current screen memory into a given buffer +void savescreenbuffer(ushort *bufferin) +{ +801010a0: 55 push %ebp +801010a1: 89 e5 mov %esp,%ebp +801010a3: 83 ec 0c sub $0xc,%esp + // Copy the memory from the console buffer to the crt buffer + memmove(bufferin, crt, sizeof(crt[0]) * SCRHEIGHT * SCRWIDTH); +801010a6: 68 a0 0f 00 00 push $0xfa0 +801010ab: 68 00 80 0b 80 push $0x800b8000 +801010b0: ff 75 08 push 0x8(%ebp) +801010b3: e8 28 4c 00 00 call 80105ce0 +} +801010b8: 83 c4 10 add $0x10,%esp +801010bb: c9 leave +801010bc: c3 ret +801010bd: 8d 76 00 lea 0x0(%esi),%esi + +801010c0 : + +// Function for clearing the current screen/buffer +void clearscreen(int prelocked) +{ +801010c0: 55 push %ebp +801010c1: 89 e5 mov %esp,%ebp +801010c3: 57 push %edi +801010c4: 56 push %esi +801010c5: 53 push %ebx +801010c6: 83 ec 0c sub $0xc,%esp +801010c9: 8b 7d 08 mov 0x8(%ebp),%edi + if (myproc() == 0x0) +801010cc: e8 df 3d 00 00 call 80104eb0 +801010d1: 85 c0 test %eax,%eax +801010d3: 74 4b je 80101120 + inconsoleptr = myproc()->consoleptr; +801010d5: e8 d6 3d 00 00 call 80104eb0 +801010da: 8b 58 7c mov 0x7c(%eax),%ebx + if (inconsoleptr == 0) +801010dd: 85 db test %ebx,%ebx +801010df: 74 3f je 80101120 + if (!prelocked) + { + acquire(&cons.lock); + } + int pos = TITLEOFF; + clearconsole(inconsoleptr->screenbuffer); +801010e1: 8d 73 3c lea 0x3c(%ebx),%esi + if (!prelocked) +801010e4: 85 ff test %edi,%edi +801010e6: 74 58 je 80101140 + memset(bufferin, 0, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +801010e8: 83 ec 04 sub $0x4,%esp +801010eb: 68 a0 0f 00 00 push $0xfa0 +801010f0: 6a 00 push $0x0 +801010f2: 56 push %esi +801010f3: e8 48 4b 00 00 call 80105c40 + inconsoleptr->pos = pos; + + // If the console is in use load the blank buffer into screen memory and set the cursor position + if (inconsoleptr->inuse) +801010f8: 8b 83 70 10 00 00 mov 0x1070(%ebx),%eax +801010fe: 83 c4 10 add $0x10,%esp + inconsoleptr->pos = pos; +80101101: c7 83 68 10 00 00 50 movl $0x50,0x1068(%ebx) +80101108: 00 00 00 + if (inconsoleptr->inuse) +8010110b: 85 c0 test %eax,%eax +8010110d: 0f 85 7d 00 00 00 jne 80101190 + drawtitle(); + if (!prelocked) + { + release(&cons.lock); + } +} +80101113: 8d 65 f4 lea -0xc(%ebp),%esp +80101116: 5b pop %ebx +80101117: 5e pop %esi +80101118: 5f pop %edi +80101119: 5d pop %ebp + drawtitle(); +8010111a: e9 71 fd ff ff jmp 80100e90 +8010111f: 90 nop + inconsoleptr = currentconsole; +80101120: 8b 1d 80 0e 11 80 mov 0x80110e80,%ebx + if (inconsoleptr == 0) +80101126: 85 db test %ebx,%ebx +80101128: 75 b7 jne 801010e1 + inconsoleptr = &consoles[0]; +8010112a: bb a0 0e 11 80 mov $0x80110ea0,%ebx + clearconsole(inconsoleptr->screenbuffer); +8010112f: 8d 73 3c lea 0x3c(%ebx),%esi + if (!prelocked) +80101132: 85 ff test %edi,%edi +80101134: 75 b2 jne 801010e8 +80101136: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010113d: 8d 76 00 lea 0x0(%esi),%esi + acquire(&cons.lock); +80101140: 83 ec 0c sub $0xc,%esp +80101143: 68 80 b6 11 80 push $0x8011b680 +80101148: e8 33 4a 00 00 call 80105b80 + memset(bufferin, 0, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +8010114d: 83 c4 0c add $0xc,%esp +80101150: 68 a0 0f 00 00 push $0xfa0 +80101155: 6a 00 push $0x0 +80101157: 56 push %esi +80101158: e8 e3 4a 00 00 call 80105c40 + if (inconsoleptr->inuse) +8010115d: 8b 93 70 10 00 00 mov 0x1070(%ebx),%edx +80101163: 83 c4 10 add $0x10,%esp + inconsoleptr->pos = pos; +80101166: c7 83 68 10 00 00 50 movl $0x50,0x1068(%ebx) +8010116d: 00 00 00 + if (inconsoleptr->inuse) +80101170: 85 d2 test %edx,%edx +80101172: 75 1c jne 80101190 + drawtitle(); +80101174: e8 17 fd ff ff call 80100e90 + release(&cons.lock); +80101179: c7 45 08 80 b6 11 80 movl $0x8011b680,0x8(%ebp) +} +80101180: 8d 65 f4 lea -0xc(%ebp),%esp +80101183: 5b pop %ebx +80101184: 5e pop %esi +80101185: 5f pop %edi +80101186: 5d pop %ebp + release(&cons.lock); +80101187: e9 94 49 00 00 jmp 80105b20 +8010118c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101190: 83 ec 04 sub $0x4,%esp + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80101193: bb d4 03 00 00 mov $0x3d4,%ebx +80101198: 68 a0 0f 00 00 push $0xfa0 +8010119d: 56 push %esi +8010119e: 68 00 80 0b 80 push $0x800b8000 +801011a3: e8 38 4b 00 00 call 80105ce0 +801011a8: b8 0e 00 00 00 mov $0xe,%eax +801011ad: 89 da mov %ebx,%edx +801011af: ee out %al,(%dx) +801011b0: b9 d5 03 00 00 mov $0x3d5,%ecx +801011b5: 31 c0 xor %eax,%eax +801011b7: 89 ca mov %ecx,%edx +801011b9: ee out %al,(%dx) +801011ba: b8 0f 00 00 00 mov $0xf,%eax +801011bf: 89 da mov %ebx,%edx +801011c1: ee out %al,(%dx) +801011c2: b8 50 00 00 00 mov $0x50,%eax +801011c7: 89 ca mov %ecx,%edx +801011c9: ee out %al,(%dx) + drawtitle(); +801011ca: e8 c1 fc ff ff call 80100e90 + if (!prelocked) +801011cf: 83 c4 10 add $0x10,%esp +801011d2: 85 ff test %edi,%edi +801011d4: 74 a3 je 80101179 +} +801011d6: 8d 65 f4 lea -0xc(%ebp),%esp +801011d9: 5b pop %ebx +801011da: 5e pop %esi +801011db: 5f pop %edi +801011dc: 5d pop %ebp +801011dd: c3 ret +801011de: 66 90 xchg %ax,%ax + +801011e0 : + +void consoleinit(void) +{ +801011e0: 55 push %ebp +801011e1: 89 e5 mov %esp,%ebp +801011e3: 57 push %edi +801011e4: 56 push %esi +801011e5: 8d 7d e0 lea -0x20(%ebp),%edi + initlock(&cons.lock, "console"); + initlock(&vcons.lock, "vconglobal"); + + // Init all of the virtual console buffers + for (int i = 0; i < MAXVCONSOLES; i++) +801011e8: 31 f6 xor %esi,%esi +{ +801011ea: 53 push %ebx +801011eb: bb a4 0e 11 80 mov $0x80110ea4,%ebx +801011f0: 83 ec 24 sub $0x24,%esp + initlock(&cons.lock, "console"); +801011f3: 68 d3 89 10 80 push $0x801089d3 +801011f8: 68 80 b6 11 80 push $0x8011b680 +801011fd: e8 ae 47 00 00 call 801059b0 + initlock(&vcons.lock, "vconglobal"); +80101202: 58 pop %eax +80101203: 5a pop %edx +80101204: 68 db 89 10 80 push $0x801089db +80101209: 68 40 b6 11 80 push $0x8011b640 +8010120e: e8 9d 47 00 00 call 801059b0 + for (int i = 0; i < MAXVCONSOLES; i++) +80101213: 83 c4 10 add $0x10,%esp +80101216: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010121d: 8d 76 00 lea 0x0(%esi),%esi + consoles[i].active = 0; + consoles[i].inuse = 0; + consoles[i].titlebgcol = 0x4F00; + + char lockname[8]; + sprintf(lockname, "vconsole%d", i); +80101220: 83 ec 04 sub $0x4,%esp + consoles[i].consoleindex = i; +80101223: 89 73 fc mov %esi,-0x4(%ebx) + sprintf(lockname, "vconsole%d", i); +80101226: 56 push %esi + for (int i = 0; i < MAXVCONSOLES; i++) +80101227: 83 c6 01 add $0x1,%esi + sprintf(lockname, "vconsole%d", i); +8010122a: 68 e6 89 10 80 push $0x801089e6 +8010122f: 57 push %edi + consoles[i].processowner = 0; +80101230: c7 43 34 00 00 00 00 movl $0x0,0x34(%ebx) + consoles[i].pos = 0; +80101237: c7 83 64 10 00 00 00 movl $0x0,0x1064(%ebx) +8010123e: 00 00 00 + consoles[i].active = 0; +80101241: c7 83 68 10 00 00 00 movl $0x0,0x1068(%ebx) +80101248: 00 00 00 + consoles[i].inuse = 0; +8010124b: c7 83 6c 10 00 00 00 movl $0x0,0x106c(%ebx) +80101252: 00 00 00 + consoles[i].titlebgcol = 0x4F00; +80101255: c7 83 70 10 00 00 00 movl $0x4f00,0x1070(%ebx) +8010125c: 4f 00 00 + sprintf(lockname, "vconsole%d", i); +8010125f: e8 9c f9 ff ff call 80100c00 + initlock(&consoles[i].lock, lockname); +80101264: 59 pop %ecx +80101265: 58 pop %eax +80101266: 57 push %edi +80101267: 53 push %ebx + for (int i = 0; i < MAXVCONSOLES; i++) +80101268: 81 c3 b0 10 00 00 add $0x10b0,%ebx + initlock(&consoles[i].lock, lockname); +8010126e: e8 3d 47 00 00 call 801059b0 + for (int i = 0; i < MAXVCONSOLES; i++) +80101273: 83 c4 10 add $0x10,%esp +80101276: 83 fe 0a cmp $0xa,%esi +80101279: 75 a5 jne 80101220 + } + + // Initialise pointer to point to our console input buffer + currentconsole = &consoles[0]; +8010127b: c7 05 80 0e 11 80 a0 movl $0x80110ea0,0x80110e80 +80101282: 0e 11 80 + devsw[CONSOLE].write = consolewrite; + devsw[CONSOLE].read = consoleread; + cons.locking = 1; + + // Clear the screen and print the welcome message + clearscreen(0); +80101285: 83 ec 0c sub $0xc,%esp +80101288: 6a 00 push $0x0 + currentconsole->active = 1; +8010128a: c7 05 0c 1f 11 80 01 movl $0x1,0x80111f0c +80101291: 00 00 00 + currentconsole->inuse = 1; +80101294: c7 05 10 1f 11 80 01 movl $0x1,0x80111f10 +8010129b: 00 00 00 + input = ¤tconsole->keybuffer; +8010129e: c7 05 80 b5 11 80 7c movl $0x80111e7c,0x8011b580 +801012a5: 1e 11 80 + devsw[CONSOLE].write = consolewrite; +801012a8: c7 05 8c c0 11 80 e0 movl $0x801007e0,0x8011c08c +801012af: 07 10 80 + devsw[CONSOLE].read = consoleread; +801012b2: c7 05 88 c0 11 80 20 movl $0x80100320,0x8011c088 +801012b9: 03 10 80 + cons.locking = 1; +801012bc: c7 05 b4 b6 11 80 01 movl $0x1,0x8011b6b4 +801012c3: 00 00 00 + clearscreen(0); +801012c6: e8 f5 fd ff ff call 801010c0 + cprintf("Welcome! you are currently in the base console\n"); +801012cb: c7 04 24 10 8a 10 80 movl $0x80108a10,(%esp) +801012d2: e8 b9 f5 ff ff call 80100890 + + ioapicenable(IRQ_KBD, 0); +801012d7: 58 pop %eax +801012d8: 5a pop %edx +801012d9: 6a 00 push $0x0 +801012db: 6a 01 push $0x1 +801012dd: e8 8e 26 00 00 call 80103970 +} +801012e2: 83 c4 10 add $0x10,%esp +801012e5: 8d 65 f4 lea -0xc(%ebp),%esp +801012e8: 5b pop %ebx +801012e9: 5e pop %esi +801012ea: 5f pop %edi +801012eb: 5d pop %ebp +801012ec: c3 ret +801012ed: 8d 76 00 lea 0x0(%esi),%esi + +801012f0 : + +// Function for "creating" a new console, in reality it sets the first non active console to active and setups the struct +// if none are free it returns a nullptr/zero for the calling function to handle +struct vconsole* newconsole(char* title, int bgpreset) +{ +801012f0: 55 push %ebp +801012f1: 89 e5 mov %esp,%ebp +801012f3: 57 push %edi +801012f4: 56 push %esi +801012f5: 53 push %ebx + struct vconsole* result = 0; + + acquire(&vcons.lock); + for (int i = 1; i < MAXVCONSOLES; i++) +801012f6: bb 01 00 00 00 mov $0x1,%ebx +{ +801012fb: 83 ec 28 sub $0x28,%esp + acquire(&vcons.lock); +801012fe: 68 40 b6 11 80 push $0x8011b640 +80101303: e8 78 48 00 00 call 80105b80 + for (int i = 1; i < MAXVCONSOLES; i++) +80101308: b8 bc 2f 11 80 mov $0x80112fbc,%eax +8010130d: 83 c4 10 add $0x10,%esp + { + if (!consoles[i].active) +80101310: 8b 30 mov (%eax),%esi +80101312: 85 f6 test %esi,%esi +80101314: 74 2a je 80101340 + for (int i = 1; i < MAXVCONSOLES; i++) +80101316: 83 c3 01 add $0x1,%ebx +80101319: 05 b0 10 00 00 add $0x10b0,%eax +8010131e: 83 fb 0a cmp $0xa,%ebx +80101321: 75 ed jne 80101310 + struct vconsole* result = 0; +80101323: 31 ff xor %edi,%edi + + result = &consoles[i]; + break; + } + } + release(&vcons.lock); +80101325: 83 ec 0c sub $0xc,%esp +80101328: 68 40 b6 11 80 push $0x8011b640 +8010132d: e8 ee 47 00 00 call 80105b20 + + return result; +} +80101332: 8d 65 f4 lea -0xc(%ebp),%esp +80101335: 89 f8 mov %edi,%eax +80101337: 5b pop %ebx +80101338: 5e pop %esi +80101339: 5f pop %edi +8010133a: 5d pop %ebp +8010133b: c3 ret +8010133c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + consoles[i].processowner = myproc(); +80101340: e8 6b 3b 00 00 call 80104eb0 +80101345: 69 d3 b0 10 00 00 imul $0x10b0,%ebx,%edx + if (strlen(title) > 0) +8010134b: 83 ec 0c sub $0xc,%esp + consoles[i].processowner = myproc(); +8010134e: 8d ba a0 0e 11 80 lea -0x7feef160(%edx),%edi +80101354: 89 55 e4 mov %edx,-0x1c(%ebp) +80101357: 89 47 38 mov %eax,0x38(%edi) + consoles[i].titlebgcol = bgpreset; +8010135a: 8b 45 0c mov 0xc(%ebp),%eax +8010135d: 89 87 74 10 00 00 mov %eax,0x1074(%edi) + if (strlen(title) > 0) +80101363: ff 75 08 push 0x8(%ebp) +80101366: e8 d5 4a 00 00 call 80105e40 +8010136b: 83 c4 10 add $0x10,%esp +8010136e: 85 c0 test %eax,%eax +80101370: 7f 0e jg 80101380 + consoles[i].titlelocked = 1; +80101372: 69 db b0 10 00 00 imul $0x10b0,%ebx,%ebx +80101378: 89 b3 2c 1f 11 80 mov %esi,-0x7feee0d4(%ebx) + break; +8010137e: eb a5 jmp 80101325 + memset(consoles[i].proctitle, 0, sizeof(consoles[i].proctitle[0]) * sizeof(consoles[i].proctitle)); +80101380: 8b 55 e4 mov -0x1c(%ebp),%edx +80101383: 83 ec 04 sub $0x4,%esp + consoles[i].titlelocked = 1; +80101386: 69 db b0 10 00 00 imul $0x10b0,%ebx,%ebx + memset(consoles[i].proctitle, 0, sizeof(consoles[i].proctitle[0]) * sizeof(consoles[i].proctitle)); +8010138c: 6a 14 push $0x14 +8010138e: 8d b2 18 1f 11 80 lea -0x7feee0e8(%edx),%esi +80101394: 6a 00 push $0x0 +80101396: 56 push %esi +80101397: e8 a4 48 00 00 call 80105c40 + safestrcpy(consoles[i].proctitle, title, sizeof(consoles[i].proctitle)); +8010139c: 83 c4 0c add $0xc,%esp +8010139f: 6a 14 push $0x14 +801013a1: ff 75 08 push 0x8(%ebp) +801013a4: 56 push %esi +801013a5: be 01 00 00 00 mov $0x1,%esi +801013aa: e8 51 4a 00 00 call 80105e00 + consoles[i].titlelocked = 1; +801013af: 89 b3 2c 1f 11 80 mov %esi,-0x7feee0d4(%ebx) + break; +801013b5: 83 c4 10 add $0x10,%esp +801013b8: e9 68 ff ff ff jmp 80101325 +801013bd: 8d 76 00 lea 0x0(%esi),%esi + +801013c0 : + +// Function to "release" all consoles from inuse, this is to stop the chance of one not clearing and causing an issue with 2 being inuse +void releaseallconsoles(void) +{ + for (int i = 0; i < MAXVCONSOLES; i++) +801013c0: b8 10 1f 11 80 mov $0x80111f10,%eax +801013c5: 8d 76 00 lea 0x0(%esi),%esi + { + consoles[i].inuse = 0; +801013c8: c7 00 00 00 00 00 movl $0x0,(%eax) + for (int i = 0; i < MAXVCONSOLES; i++) +801013ce: 05 b0 10 00 00 add $0x10b0,%eax +801013d3: 3d f0 c5 11 80 cmp $0x8011c5f0,%eax +801013d8: 75 ee jne 801013c8 + } +} +801013da: c3 ret +801013db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801013df: 90 nop + +801013e0 : + +// Function for switching to another console using the given pointer +int switchtoconsole(struct vconsole* consoleptr) +{ +801013e0: 55 push %ebp +801013e1: 89 e5 mov %esp,%ebp +801013e3: 57 push %edi +801013e4: 56 push %esi +801013e5: 53 push %ebx +801013e6: bb a0 0e 11 80 mov $0x80110ea0,%ebx +801013eb: 83 ec 18 sub $0x18,%esp +801013ee: 8b 75 08 mov 0x8(%ebp),%esi + int pos; + + acquire(&vcons.lock); +801013f1: 68 40 b6 11 80 push $0x8011b640 +801013f6: e8 85 47 00 00 call 80105b80 + for (int i = 0; i < MAXVCONSOLES; i++) +801013fb: b8 10 1f 11 80 mov $0x80111f10,%eax +80101400: 83 c4 10 add $0x10,%esp +80101403: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101407: 90 nop + consoles[i].inuse = 0; +80101408: c7 00 00 00 00 00 movl $0x0,(%eax) + for (int i = 0; i < MAXVCONSOLES; i++) +8010140e: 05 b0 10 00 00 add $0x10b0,%eax +80101413: 3d f0 c5 11 80 cmp $0x8011c5f0,%eax +80101418: 75 ee jne 80101408 + // Release all consoles before setting the new one to inuse + releaseallconsoles(); + currentconsole = consoleptr; + currentconsole->inuse = 1; + + acquire(&cons.lock); +8010141a: 83 ec 0c sub $0xc,%esp + currentconsole = consoleptr; +8010141d: 89 35 80 0e 11 80 mov %esi,0x80110e80 + currentconsole->inuse = 1; +80101423: c7 86 70 10 00 00 01 movl $0x1,0x1070(%esi) +8010142a: 00 00 00 + acquire(&cons.lock); +8010142d: 68 80 b6 11 80 push $0x8011b680 +80101432: e8 49 47 00 00 call 80105b80 + // Load the next console into screen memory + loadscreenbuffer(currentconsole->screenbuffer); +80101437: a1 80 0e 11 80 mov 0x80110e80,%eax + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +8010143c: 83 c4 0c add $0xc,%esp +8010143f: 68 a0 0f 00 00 push $0xfa0 + loadscreenbuffer(currentconsole->screenbuffer); +80101444: 83 c0 3c add $0x3c,%eax + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101447: 50 push %eax +80101448: 68 00 80 0b 80 push $0x800b8000 +8010144d: e8 8e 48 00 00 call 80105ce0 + + // Checks if the console was active, if not its most likely the first switch to this so we clear and print the welcome message + if (!currentconsole->active) +80101452: 8b 0d 80 0e 11 80 mov 0x80110e80,%ecx +80101458: 83 c4 10 add $0x10,%esp +8010145b: 8b b9 6c 10 00 00 mov 0x106c(%ecx),%edi +80101461: 85 ff test %edi,%edi +80101463: 0f 84 8f 00 00 00 je 801014f8 +80101469: bf d4 03 00 00 mov $0x3d4,%edi +8010146e: b8 0e 00 00 00 mov $0xe,%eax +80101473: 89 fa mov %edi,%edx +80101475: ee out %al,(%dx) + { + // If it was already active we just set the cursor position to the one saved in the console struct + pos = currentconsole->pos; + + outb(CRTPORT, 14); + outb(CRTPORT + 1, pos >> 8); +80101476: 8b 81 68 10 00 00 mov 0x1068(%ecx),%eax +8010147c: be d5 03 00 00 mov $0x3d5,%esi +80101481: 89 f2 mov %esi,%edx +80101483: c1 f8 08 sar $0x8,%eax +80101486: ee out %al,(%dx) +80101487: b8 0f 00 00 00 mov $0xf,%eax +8010148c: 89 fa mov %edi,%edx +8010148e: ee out %al,(%dx) +8010148f: 0f b6 81 68 10 00 00 movzbl 0x1068(%ecx),%eax +80101496: 89 f2 mov %esi,%edx +80101498: ee out %al,(%dx) + outb(CRTPORT, 15); + outb(CRTPORT + 1, pos); + } + + // Remove the menu if it was active and set the console as the current menu item + menuactive = 0; +80101499: c7 05 bc b6 11 80 00 movl $0x0,0x8011b6bc +801014a0: 00 00 00 + int resultcount = 0; +801014a3: 31 c0 xor %eax,%eax +801014a5: eb 17 jmp 801014be +801014a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801014ae: 66 90 xchg %ax,%ax + resultcount++; +801014b0: 83 c0 01 add $0x1,%eax + for (int i = 0; i < MAXVCONSOLES; i++) +801014b3: 81 c3 b0 10 00 00 add $0x10b0,%ebx +801014b9: 83 f8 0a cmp $0xa,%eax +801014bc: 74 0e je 801014cc + if (&consoles[i] == consolein && consoles[i].active) +801014be: 39 d9 cmp %ebx,%ecx +801014c0: 75 ee jne 801014b0 +801014c2: 8b 91 6c 10 00 00 mov 0x106c(%ecx),%edx +801014c8: 85 d2 test %edx,%edx +801014ca: 74 e4 je 801014b0 + currentmenuitem = getconsolemenuindex(currentconsole); + release(&cons.lock); +801014cc: 83 ec 0c sub $0xc,%esp + currentmenuitem = getconsolemenuindex(currentconsole); +801014cf: a3 c0 b6 11 80 mov %eax,0x8011b6c0 + release(&cons.lock); +801014d4: 68 80 b6 11 80 push $0x8011b680 +801014d9: e8 42 46 00 00 call 80105b20 + release(&vcons.lock); +801014de: c7 04 24 40 b6 11 80 movl $0x8011b640,(%esp) +801014e5: e8 36 46 00 00 call 80105b20 + return 0; +} +801014ea: 8d 65 f4 lea -0xc(%ebp),%esp +801014ed: 31 c0 xor %eax,%eax +801014ef: 5b pop %ebx +801014f0: 5e pop %esi +801014f1: 5f pop %edi +801014f2: 5d pop %ebp +801014f3: c3 ret +801014f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + clearscreen(1); +801014f8: 83 ec 0c sub $0xc,%esp +801014fb: 6a 01 push $0x1 +801014fd: e8 be fb ff ff call 801010c0 + cprintf("Welcome to Console: %d\n", currentconsole->consoleindex); +80101502: a1 80 0e 11 80 mov 0x80110e80,%eax +80101507: 59 pop %ecx +80101508: 5e pop %esi +80101509: ff 30 push (%eax) +8010150b: 68 f1 89 10 80 push $0x801089f1 +80101510: e8 7b f3 ff ff call 80100890 + currentconsole->active = 1; +80101515: 8b 0d 80 0e 11 80 mov 0x80110e80,%ecx +8010151b: 83 c4 10 add $0x10,%esp +8010151e: c7 81 6c 10 00 00 01 movl $0x1,0x106c(%ecx) +80101525: 00 00 00 +80101528: e9 6c ff ff ff jmp 80101499 +8010152d: 8d 76 00 lea 0x0(%esi),%esi + +80101530 : +{ +80101530: 55 push %ebp +80101531: 89 e5 mov %esp,%ebp +80101533: 57 push %edi +80101534: 56 push %esi +80101535: 53 push %ebx +80101536: 81 ec 3c 01 00 00 sub $0x13c,%esp +8010153c: 8b 45 08 mov 0x8(%ebp),%eax +8010153f: 89 85 e8 fe ff ff mov %eax,-0x118(%ebp) + if (myproc() == 0x0) +80101545: e8 66 39 00 00 call 80104eb0 +8010154a: 85 c0 test %eax,%eax +8010154c: 0f 84 8e 00 00 00 je 801015e0 + inconsoleptr = myproc()->consoleptr; +80101552: e8 59 39 00 00 call 80104eb0 +80101557: 8b 40 7c mov 0x7c(%eax),%eax +8010155a: 89 85 c4 fe ff ff mov %eax,-0x13c(%ebp) + if (inconsoleptr == 0) +80101560: 85 c0 test %eax,%eax +80101562: 74 7c je 801015e0 + acquire(&cons.lock); +80101564: 83 ec 0c sub $0xc,%esp +80101567: 68 80 b6 11 80 push $0x8011b680 +8010156c: e8 0f 46 00 00 call 80105b80 + struct kbdbuffer* consolekbdbuffer = ¤tconsole->keybuffer; +80101571: a1 80 0e 11 80 mov 0x80110e80,%eax + while ((c = getc()) >= 0) +80101576: 83 c4 10 add $0x10,%esp + int doconsolehome = 0; +80101579: c7 85 d4 fe ff ff 00 movl $0x0,-0x12c(%ebp) +80101580: 00 00 00 + int switchto = -1; +80101583: c7 85 c0 fe ff ff ff movl $0xffffffff,-0x140(%ebp) +8010158a: ff ff ff + struct kbdbuffer* consolekbdbuffer = ¤tconsole->keybuffer; +8010158d: 89 85 d8 fe ff ff mov %eax,-0x128(%ebp) + int doconsoleswitch = 0; +80101593: c7 85 d0 fe ff ff 00 movl $0x0,-0x130(%ebp) +8010159a: 00 00 00 + int doprocdump = 0; +8010159d: c7 85 cc fe ff ff 00 movl $0x0,-0x134(%ebp) +801015a4: 00 00 00 + while ((c = getc()) >= 0) +801015a7: 8b 85 e8 fe ff ff mov -0x118(%ebp),%eax +801015ad: ff d0 call *%eax +801015af: 89 c3 mov %eax,%ebx +801015b1: 85 c0 test %eax,%eax +801015b3: 0f 88 97 00 00 00 js 80101650 + switch (c) +801015b9: 83 fb 1b cmp $0x1b,%ebx +801015bc: 7f 4a jg 80101608 +801015be: 83 fb 07 cmp $0x7,%ebx +801015c1: 0f 8e 19 01 00 00 jle 801016e0 +801015c7: 8d 43 f8 lea -0x8(%ebx),%eax +801015ca: 83 f8 13 cmp $0x13,%eax +801015cd: 0f 87 0d 01 00 00 ja 801016e0 +801015d3: ff 24 85 40 8a 10 80 jmp *-0x7fef75c0(,%eax,4) +801015da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + inconsoleptr = currentconsole; +801015e0: a1 80 0e 11 80 mov 0x80110e80,%eax +801015e5: 89 85 c4 fe ff ff mov %eax,-0x13c(%ebp) + if (inconsoleptr == 0) +801015eb: 85 c0 test %eax,%eax +801015ed: 0f 85 71 ff ff ff jne 80101564 + inconsoleptr = &consoles[0]; +801015f3: c7 85 c4 fe ff ff a0 movl $0x80110ea0,-0x13c(%ebp) +801015fa: 0e 11 80 +801015fd: e9 62 ff ff ff jmp 80101564 +80101602: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + switch (c) +80101608: 81 fb e2 00 00 00 cmp $0xe2,%ebx +8010160e: 0f 84 a4 04 00 00 je 80101ab8 +80101614: 81 fb e3 00 00 00 cmp $0xe3,%ebx +8010161a: 0f 85 86 00 00 00 jne 801016a6 + if (menuactive) +80101620: 8b 15 bc b6 11 80 mov 0x8011b6bc,%edx +80101626: 85 d2 test %edx,%edx +80101628: 0f 84 79 ff ff ff je 801015a7 + navigatemenu(1); +8010162e: b8 01 00 00 00 mov $0x1,%eax +80101633: e8 48 ec ff ff call 80100280 + while ((c = getc()) >= 0) +80101638: 8b 85 e8 fe ff ff mov -0x118(%ebp),%eax +8010163e: ff d0 call *%eax +80101640: 89 c3 mov %eax,%ebx +80101642: 85 c0 test %eax,%eax +80101644: 0f 89 6f ff ff ff jns 801015b9 +8010164a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + release(&cons.lock); +80101650: 83 ec 0c sub $0xc,%esp +80101653: 68 80 b6 11 80 push $0x8011b680 +80101658: e8 c3 44 00 00 call 80105b20 + if (doprocdump && !menuactive) +8010165d: 8b 85 cc fe ff ff mov -0x134(%ebp),%eax +80101663: 83 c4 10 add $0x10,%esp +80101666: 85 c0 test %eax,%eax +80101668: 74 0d je 80101677 +8010166a: a1 bc b6 11 80 mov 0x8011b6bc,%eax +8010166f: 85 c0 test %eax,%eax +80101671: 0f 84 5a 05 00 00 je 80101bd1 + if (doconsolehome) +80101677: 8b 85 d4 fe ff ff mov -0x12c(%ebp),%eax +8010167d: 85 c0 test %eax,%eax +8010167f: 74 0f je 80101690 + if (currentconsole->consoleindex != 0) +80101681: a1 80 0e 11 80 mov 0x80110e80,%eax +80101686: 8b 00 mov (%eax),%eax +80101688: 85 c0 test %eax,%eax +8010168a: 0f 85 4b 05 00 00 jne 80101bdb + if (doconsoleswitch) +80101690: 8b 85 d0 fe ff ff mov -0x130(%ebp),%eax +80101696: 85 c0 test %eax,%eax +80101698: 0f 85 82 04 00 00 jne 80101b20 +} +8010169e: 8d 65 f4 lea -0xc(%ebp),%esp +801016a1: 5b pop %ebx +801016a2: 5e pop %esi +801016a3: 5f pop %edi +801016a4: 5d pop %ebp +801016a5: c3 ret + switch (c) +801016a6: 83 fb 7f cmp $0x7f,%ebx +801016a9: 75 35 jne 801016e0 + if (consolekbdbuffer->e != consolekbdbuffer->w) +801016ab: 8b bd d8 fe ff ff mov -0x128(%ebp),%edi +801016b1: 8b 87 64 10 00 00 mov 0x1064(%edi),%eax +801016b7: 3b 87 60 10 00 00 cmp 0x1060(%edi),%eax +801016bd: 0f 84 e4 fe ff ff je 801015a7 + consolekbdbuffer->e--; +801016c3: 83 e8 01 sub $0x1,%eax +801016c6: 89 87 64 10 00 00 mov %eax,0x1064(%edi) + if (panicked) +801016cc: a1 b8 b6 11 80 mov 0x8011b6b8,%eax +801016d1: 85 c0 test %eax,%eax +801016d3: 0f 84 17 05 00 00 je 80101bf0 + asm volatile ("cli"); +801016d9: fa cli + for (;;) +801016da: eb fe jmp 801016da +801016dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (!menuactive) +801016e0: 8b 35 bc b6 11 80 mov 0x8011b6bc,%esi +801016e6: 85 f6 test %esi,%esi +801016e8: 0f 85 b9 fe ff ff jne 801015a7 +801016ee: e9 d8 02 00 00 jmp 801019cb + if (menuactive) +801016f3: 8b 1d bc b6 11 80 mov 0x8011b6bc,%ebx +801016f9: 85 db test %ebx,%ebx +801016fb: 0f 84 a6 fe ff ff je 801015a7 + loadscreenbuffer(currentconsole->screenbuffer); +80101701: a1 80 0e 11 80 mov 0x80110e80,%eax + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101706: 83 ec 04 sub $0x4,%esp + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80101709: be d4 03 00 00 mov $0x3d4,%esi +8010170e: 68 a0 0f 00 00 push $0xfa0 + loadscreenbuffer(currentconsole->screenbuffer); +80101713: 83 c0 3c add $0x3c,%eax + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101716: 50 push %eax +80101717: 68 00 80 0b 80 push $0x800b8000 +8010171c: e8 bf 45 00 00 call 80105ce0 + int pos = currentconsole->pos; +80101721: a1 80 0e 11 80 mov 0x80110e80,%eax +80101726: 89 f2 mov %esi,%edx +80101728: 8b 88 68 10 00 00 mov 0x1068(%eax),%ecx +8010172e: b8 0e 00 00 00 mov $0xe,%eax +80101733: ee out %al,(%dx) +80101734: bb d5 03 00 00 mov $0x3d5,%ebx + outb(CRTPORT + 1, pos >> 8); +80101739: 89 c8 mov %ecx,%eax +8010173b: c1 f8 08 sar $0x8,%eax +8010173e: 89 da mov %ebx,%edx +80101740: ee out %al,(%dx) +80101741: b8 0f 00 00 00 mov $0xf,%eax +80101746: 89 f2 mov %esi,%edx +80101748: ee out %al,(%dx) +80101749: 89 c8 mov %ecx,%eax +8010174b: 89 da mov %ebx,%edx +8010174d: ee out %al,(%dx) + menuactive = 0; +8010174e: c7 05 bc b6 11 80 00 movl $0x0,0x8011b6bc +80101755: 00 00 00 +} +80101758: 83 c4 10 add $0x10,%esp +8010175b: e9 47 fe ff ff jmp 801015a7 + while (consolekbdbuffer->e != consolekbdbuffer->w && +80101760: 8b bd d8 fe ff ff mov -0x128(%ebp),%edi +80101766: 8b 9d d8 fe ff ff mov -0x128(%ebp),%ebx +8010176c: 8b 87 64 10 00 00 mov 0x1064(%edi),%eax +80101772: 39 87 60 10 00 00 cmp %eax,0x1060(%edi) +80101778: 0f 84 29 fe ff ff je 801015a7 + consolekbdbuffer->buf[(consolekbdbuffer->e - 1) % INPUT_BUF] != '\n') +8010177e: 83 e8 01 sub $0x1,%eax +80101781: 89 c2 mov %eax,%edx +80101783: 83 e2 7f and $0x7f,%edx + while (consolekbdbuffer->e != consolekbdbuffer->w && +80101786: 80 bc 13 dc 0f 00 00 cmpb $0xa,0xfdc(%ebx,%edx,1) +8010178d: 0a +8010178e: 0f 84 13 fe ff ff je 801015a7 + consolekbdbuffer->e--; +80101794: 89 83 64 10 00 00 mov %eax,0x1064(%ebx) + if (panicked) +8010179a: a1 b8 b6 11 80 mov 0x8011b6b8,%eax +8010179f: 85 c0 test %eax,%eax +801017a1: 0f 84 2e 03 00 00 je 80101ad5 + asm volatile ("cli"); +801017a7: fa cli + for (;;) +801017a8: eb fe jmp 801017a8 +801017aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (!menuactive) +801017b0: a1 bc b6 11 80 mov 0x8011b6bc,%eax +801017b5: 85 c0 test %eax,%eax +801017b7: 0f 85 44 ff ff ff jne 80101701 + if (myproc() == 0x0) +801017bd: e8 ee 36 00 00 call 80104eb0 +801017c2: 85 c0 test %eax,%eax +801017c4: 0f 84 ef 03 00 00 je 80101bb9 + inconsoleptr = myproc()->consoleptr; +801017ca: e8 e1 36 00 00 call 80104eb0 +801017cf: 8b 70 7c mov 0x7c(%eax),%esi + if (inconsoleptr == 0) +801017d2: 85 f6 test %esi,%esi +801017d4: 0f 84 df 03 00 00 je 80101bb9 + for (int i = 0; i < MAXVCONSOLES; i++) +801017da: b8 0c 1f 11 80 mov $0x80111f0c,%eax +801017df: ba ec c5 11 80 mov $0x8011c5ec,%edx + int resultcount = 0; +801017e4: 31 ff xor %edi,%edi +801017e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801017ed: 8d 76 00 lea 0x0(%esi),%esi + resultcount++; +801017f0: 83 38 01 cmpl $0x1,(%eax) +801017f3: 83 df ff sbb $0xffffffff,%edi + for (int i = 0; i < MAXVCONSOLES; i++) +801017f6: 05 b0 10 00 00 add $0x10b0,%eax +801017fb: 39 c2 cmp %eax,%edx +801017fd: 75 f1 jne 801017f0 + int menuindex = 0; +801017ff: 31 d2 xor %edx,%edx +80101801: 89 b5 f0 fe ff ff mov %esi,-0x110(%ebp) +80101807: bb 18 1f 11 80 mov $0x80111f18,%ebx +8010180c: 89 bd f4 fe ff ff mov %edi,-0x10c(%ebp) +80101812: 89 d6 mov %edx,%esi +80101814: eb 18 jmp 8010182e +80101816: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010181d: 8d 76 00 lea 0x0(%esi),%esi + for (int i = 0; i < MAXVCONSOLES; i++) +80101820: 81 c3 b0 10 00 00 add $0x10b0,%ebx +80101826: 81 fb f8 c5 11 80 cmp $0x8011c5f8,%ebx +8010182c: 74 51 je 8010187f + if (consoles[i].active) +8010182e: 8b 43 f4 mov -0xc(%ebx),%eax +80101831: 85 c0 test %eax,%eax +80101833: 74 eb je 80101820 + memset(menulines[menuindex], 0, sizeof(menulines[i][0]) * sizeof(menulines[i])); +80101835: 8d 04 76 lea (%esi,%esi,2),%eax +80101838: 83 ec 04 sub $0x4,%esp +8010183b: 8d bc c5 f8 fe ff ff lea -0x108(%ebp,%eax,8),%edi +80101842: 6a 18 push $0x18 +80101844: 6a 00 push $0x0 +80101846: 57 push %edi +80101847: e8 f4 43 00 00 call 80105c40 + sprintf(menulines[menuindex], "%d: %s", consoles[i].consoleindex, consoles[i].proctitle); +8010184c: 53 push %ebx +8010184d: ff b3 88 ef ff ff push -0x1078(%ebx) +80101853: 68 09 8a 10 80 push $0x80108a09 +80101858: 57 push %edi +80101859: e8 a2 f3 ff ff call 80100c00 + if (consoles[i].inuse) +8010185e: 8b 43 f8 mov -0x8(%ebx),%eax +80101861: 83 c4 20 add $0x20,%esp +80101864: 85 c0 test %eax,%eax +80101866: 74 06 je 8010186e + currentmenuitem = menuindex; +80101868: 89 35 c0 b6 11 80 mov %esi,0x8011b6c0 + for (int i = 0; i < MAXVCONSOLES; i++) +8010186e: 81 c3 b0 10 00 00 add $0x10b0,%ebx + menuindex++; +80101874: 83 c6 01 add $0x1,%esi + for (int i = 0; i < MAXVCONSOLES; i++) +80101877: 81 fb f8 c5 11 80 cmp $0x8011c5f8,%ebx +8010187d: 75 af jne 8010182e + if (currentmenuitem == (y - 1)) +8010187f: a1 c0 b6 11 80 mov 0x8011b6c0,%eax +80101884: 8b bd f4 fe ff ff mov -0x10c(%ebp),%edi +8010188a: 31 db xor %ebx,%ebx +8010188c: c7 85 e0 fe ff ff 50 movl $0x50,-0x120(%ebp) +80101893: 00 00 00 +80101896: 8b b5 f0 fe ff ff mov -0x110(%ebp),%esi +8010189c: 89 85 dc fe ff ff mov %eax,-0x124(%ebp) +801018a2: 8d 85 f8 fe ff ff lea -0x108(%ebp),%eax +801018a8: 89 85 e4 fe ff ff mov %eax,-0x11c(%ebp) +801018ae: 8d 47 03 lea 0x3(%edi),%eax +801018b1: 89 85 c8 fe ff ff mov %eax,-0x138(%ebp) +801018b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801018be: 66 90 xchg %ax,%ax + for (int x = 0; x < MENUWIDTH; x++) +801018c0: 8b 85 e0 fe ff ff mov -0x120(%ebp),%eax +801018c6: 89 b5 f4 fe ff ff mov %esi,-0x10c(%ebp) +801018cc: 8d 8c 00 00 80 0b 80 lea -0x7ff48000(%eax,%eax,1),%ecx +801018d3: 31 c0 xor %eax,%eax +801018d5: eb 77 jmp 8010194e +801018d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801018de: 66 90 xchg %ax,%ax + if (y == 0 || y == (rows - 2)) +801018e0: 8d 57 01 lea 0x1(%edi),%edx +801018e3: 39 da cmp %ebx,%edx +801018e5: 74 6b je 80101952 + else if (y == (rows - 1)) +801018e7: 8d 57 02 lea 0x2(%edi),%edx +801018ea: 39 da cmp %ebx,%edx +801018ec: 74 73 je 80101961 + if (x == 0 || x == (MENUWIDTH - 1)) +801018ee: be 01 00 00 04 mov $0x4000001,%esi +801018f3: 0f a3 c6 bt %eax,%esi +801018f6: 72 69 jb 80101961 + else if (x == 1 || x == (MENUWIDTH - 2)) +801018f8: be 02 00 00 02 mov $0x2000002,%esi +801018fd: ba 20 07 00 00 mov $0x720,%edx +80101902: 0f a3 c6 bt %eax,%esi +80101905: 72 39 jb 80101940 + c = (c & 0xff); +80101907: 8b b5 e4 fe ff ff mov -0x11c(%ebp),%esi +8010190d: 0f b6 54 06 e6 movzbl -0x1a(%esi,%eax,1),%edx + if (currentmenuitem == (y - 1)) +80101912: 8d 73 ff lea -0x1(%ebx),%esi +80101915: 89 b5 f0 fe ff ff mov %esi,-0x110(%ebp) + crt[pos] = c; +8010191b: 89 d6 mov %edx,%esi +8010191d: 80 ce cf or $0xcf,%dh +80101920: 81 ce 00 07 00 00 or $0x700,%esi +80101926: 89 b5 ec fe ff ff mov %esi,-0x114(%ebp) +8010192c: 8b b5 f0 fe ff ff mov -0x110(%ebp),%esi +80101932: 39 b5 dc fe ff ff cmp %esi,-0x124(%ebp) +80101938: 66 0f 45 95 ec fe ff cmovne -0x114(%ebp),%dx +8010193f: ff + for (int x = 0; x < MENUWIDTH; x++) +80101940: 83 c0 01 add $0x1,%eax + crt[pos] = c; +80101943: 66 89 11 mov %dx,(%ecx) + for (int x = 0; x < MENUWIDTH; x++) +80101946: 83 c1 02 add $0x2,%ecx +80101949: 83 f8 1b cmp $0x1b,%eax +8010194c: 74 32 je 80101980 + if (y == 0 || y == (rows - 2)) +8010194e: 85 db test %ebx,%ebx +80101950: 75 8e jne 801018e0 + if (x == 0 || x == (MENUWIDTH - 1)) +80101952: be 01 00 00 04 mov $0x4000001,%esi +80101957: ba 20 07 00 00 mov $0x720,%edx +8010195c: 0f a3 c6 bt %eax,%esi +8010195f: 73 df jae 80101940 + crt[pos] = c; +80101961: 8b b5 f4 fe ff ff mov -0x10c(%ebp),%esi + for (int x = 0; x < MENUWIDTH; x++) +80101967: 83 c0 01 add $0x1,%eax +8010196a: 83 c1 02 add $0x2,%ecx + crt[pos] = c; +8010196d: 0f b7 96 74 10 00 00 movzwl 0x1074(%esi),%edx +80101974: 80 ca b2 or $0xb2,%dl +80101977: 66 89 51 fe mov %dx,-0x2(%ecx) + for (int x = 0; x < MENUWIDTH; x++) +8010197b: 83 f8 1b cmp $0x1b,%eax +8010197e: 75 ce jne 8010194e + for (int y = 0; y < rows; y++) +80101980: 83 85 e0 fe ff ff 50 addl $0x50,-0x120(%ebp) +80101987: 8b b5 f4 fe ff ff mov -0x10c(%ebp),%esi +8010198d: 83 c3 01 add $0x1,%ebx +80101990: 83 85 e4 fe ff ff 18 addl $0x18,-0x11c(%ebp) +80101997: 3b 9d c8 fe ff ff cmp -0x138(%ebp),%ebx +8010199d: 0f 85 1d ff ff ff jne 801018c0 + menuactive = 1; +801019a3: c7 05 bc b6 11 80 01 movl $0x1,0x8011b6bc +801019aa: 00 00 00 +} +801019ad: e9 f5 fb ff ff jmp 801015a7 + doconsolehome = 1; +801019b2: c7 85 d4 fe ff ff 01 movl $0x1,-0x12c(%ebp) +801019b9: 00 00 00 + break; +801019bc: e9 e6 fb ff ff jmp 801015a7 + if (menuactive) +801019c1: 8b 3d bc b6 11 80 mov 0x8011b6bc,%edi +801019c7: 85 ff test %edi,%edi +801019c9: 75 65 jne 80101a30 + if (c != 0 && consolekbdbuffer->e - consolekbdbuffer->r < INPUT_BUF) +801019cb: 8b 85 c4 fe ff ff mov -0x13c(%ebp),%eax +801019d1: 8b 88 70 10 00 00 mov 0x1070(%eax),%ecx +801019d7: 85 c9 test %ecx,%ecx +801019d9: 0f 84 c8 fb ff ff je 801015a7 +801019df: 85 db test %ebx,%ebx +801019e1: 0f 84 c0 fb ff ff je 801015a7 +801019e7: 8b bd d8 fe ff ff mov -0x128(%ebp),%edi +801019ed: 8b 87 64 10 00 00 mov 0x1064(%edi),%eax +801019f3: 89 c2 mov %eax,%edx +801019f5: 2b 97 5c 10 00 00 sub 0x105c(%edi),%edx +801019fb: 83 fa 7f cmp $0x7f,%edx +801019fe: 0f 87 a3 fb ff ff ja 801015a7 + consolekbdbuffer->buf[consolekbdbuffer->e++ % INPUT_BUF] = c; +80101a04: 8d 50 01 lea 0x1(%eax),%edx +80101a07: 83 e0 7f and $0x7f,%eax +80101a0a: 89 97 64 10 00 00 mov %edx,0x1064(%edi) + if (panicked) +80101a10: 8b 15 b8 b6 11 80 mov 0x8011b6b8,%edx + consolekbdbuffer->buf[consolekbdbuffer->e++ % INPUT_BUF] = c; +80101a16: 88 9c 07 dc 0f 00 00 mov %bl,0xfdc(%edi,%eax,1) + if (panicked) +80101a1d: 85 d2 test %edx,%edx +80101a1f: 0f 84 65 02 00 00 je 80101c8a +80101a25: fa cli + for (;;) +80101a26: eb fe jmp 80101a26 +80101a28: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101a2f: 90 nop + loadscreenbuffer(currentconsole->screenbuffer); +80101a30: a1 80 0e 11 80 mov 0x80110e80,%eax + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101a35: 83 ec 04 sub $0x4,%esp + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80101a38: be d4 03 00 00 mov $0x3d4,%esi +80101a3d: 68 a0 0f 00 00 push $0xfa0 + loadscreenbuffer(currentconsole->screenbuffer); +80101a42: 83 c0 3c add $0x3c,%eax + memmove(crt, bufferin, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101a45: 50 push %eax +80101a46: 68 00 80 0b 80 push $0x800b8000 +80101a4b: e8 90 42 00 00 call 80105ce0 + int pos = currentconsole->pos; +80101a50: a1 80 0e 11 80 mov 0x80110e80,%eax +80101a55: 89 f2 mov %esi,%edx +80101a57: 8b 88 68 10 00 00 mov 0x1068(%eax),%ecx +80101a5d: b8 0e 00 00 00 mov $0xe,%eax +80101a62: ee out %al,(%dx) +80101a63: bb d5 03 00 00 mov $0x3d5,%ebx + outb(CRTPORT + 1, pos >> 8); +80101a68: 89 c8 mov %ecx,%eax +80101a6a: c1 f8 08 sar $0x8,%eax +80101a6d: 89 da mov %ebx,%edx +80101a6f: ee out %al,(%dx) +80101a70: b8 0f 00 00 00 mov $0xf,%eax +80101a75: 89 f2 mov %esi,%edx +80101a77: ee out %al,(%dx) +80101a78: 89 c8 mov %ecx,%eax +80101a7a: 89 da mov %ebx,%edx +80101a7c: ee out %al,(%dx) + switchto = currentmenuitem; +80101a7d: a1 c0 b6 11 80 mov 0x8011b6c0,%eax + break; +80101a82: 83 c4 10 add $0x10,%esp + menuactive = 0; +80101a85: c7 05 bc b6 11 80 00 movl $0x0,0x8011b6bc +80101a8c: 00 00 00 + switchto = currentmenuitem; +80101a8f: 89 85 c0 fe ff ff mov %eax,-0x140(%ebp) + doconsoleswitch = 1; +80101a95: c7 85 d0 fe ff ff 01 movl $0x1,-0x130(%ebp) +80101a9c: 00 00 00 + break; +80101a9f: e9 03 fb ff ff jmp 801015a7 + doprocdump = 1; +80101aa4: c7 85 cc fe ff ff 01 movl $0x1,-0x134(%ebp) +80101aab: 00 00 00 +80101aae: e9 f4 fa ff ff jmp 801015a7 +80101ab3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101ab7: 90 nop + if (menuactive) +80101ab8: 8b 0d bc b6 11 80 mov 0x8011b6bc,%ecx +80101abe: 85 c9 test %ecx,%ecx +80101ac0: 0f 84 e1 fa ff ff je 801015a7 + navigatemenu(-1); +80101ac6: b8 ff ff ff ff mov $0xffffffff,%eax +80101acb: e8 b0 e7 ff ff call 80100280 +80101ad0: e9 d2 fa ff ff jmp 801015a7 + uartputc('\b'); +80101ad5: 83 ec 0c sub $0xc,%esp +80101ad8: 6a 08 push $0x8 +80101ada: e8 71 59 00 00 call 80107450 + uartputc(' '); +80101adf: c7 04 24 20 00 00 00 movl $0x20,(%esp) +80101ae6: e8 65 59 00 00 call 80107450 + uartputc('\b'); +80101aeb: c7 04 24 08 00 00 00 movl $0x8,(%esp) +80101af2: e8 59 59 00 00 call 80107450 + cgaputc(c); +80101af7: b8 00 01 00 00 mov $0x100,%eax +80101afc: e8 ff e9 ff ff call 80100500 + while (consolekbdbuffer->e != consolekbdbuffer->w && +80101b01: 8b 83 64 10 00 00 mov 0x1064(%ebx),%eax +80101b07: 83 c4 10 add $0x10,%esp +80101b0a: 3b 83 60 10 00 00 cmp 0x1060(%ebx),%eax +80101b10: 0f 85 68 fc ff ff jne 8010177e +80101b16: e9 8c fa ff ff jmp 801015a7 +80101b1b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101b1f: 90 nop + acquire(&vcons.lock); +80101b20: 83 ec 0c sub $0xc,%esp +80101b23: 68 40 b6 11 80 push $0x8011b640 +80101b28: e8 53 40 00 00 call 80105b80 + acquire(&cons.lock); +80101b2d: c7 04 24 80 b6 11 80 movl $0x8011b680,(%esp) +80101b34: e8 47 40 00 00 call 80105b80 + if (switchto == -1) +80101b39: 83 c4 10 add $0x10,%esp + int resultcount = 0; +80101b3c: 31 c9 xor %ecx,%ecx + for (int i = 0; i < MAXVCONSOLES; i++) +80101b3e: 31 c0 xor %eax,%eax + if (switchto == -1) +80101b40: 83 bd c0 fe ff ff ff cmpl $0xffffffff,-0x140(%ebp) +80101b47: 8b 9d c0 fe ff ff mov -0x140(%ebp),%ebx +80101b4d: 0f 84 d1 00 00 00 je 80101c24 +80101b53: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101b57: 90 nop + if (consoles[i].active) +80101b58: 69 d0 b0 10 00 00 imul $0x10b0,%eax,%edx +80101b5e: 8b b2 0c 1f 11 80 mov -0x7feee0f4(%edx),%esi +80101b64: 85 f6 test %esi,%esi +80101b66: 74 0b je 80101b73 + if (resultcount == menuindex) +80101b68: 39 cb cmp %ecx,%ebx +80101b6a: 0f 84 05 01 00 00 je 80101c75 + resultcount++; +80101b70: 83 c1 01 add $0x1,%ecx + for (int i = 0; i < MAXVCONSOLES; i++) +80101b73: 83 c0 01 add $0x1,%eax +80101b76: 83 f8 0a cmp $0xa,%eax +80101b79: 75 dd jne 80101b58 + toconsole = getbaseconsoleptr(); +80101b7b: bb a0 0e 11 80 mov $0x80110ea0,%ebx + release(&cons.lock); +80101b80: 83 ec 0c sub $0xc,%esp +80101b83: 68 80 b6 11 80 push $0x8011b680 +80101b88: e8 93 3f 00 00 call 80105b20 + release(&vcons.lock); +80101b8d: c7 04 24 40 b6 11 80 movl $0x8011b640,(%esp) +80101b94: e8 87 3f 00 00 call 80105b20 + if (!toconsole->inuse) +80101b99: 8b 83 70 10 00 00 mov 0x1070(%ebx),%eax +80101b9f: 83 c4 10 add $0x10,%esp +80101ba2: 85 c0 test %eax,%eax +80101ba4: 0f 85 f4 fa ff ff jne 8010169e + switchtoconsole(toconsole); +80101baa: 89 5d 08 mov %ebx,0x8(%ebp) +} +80101bad: 8d 65 f4 lea -0xc(%ebp),%esp +80101bb0: 5b pop %ebx +80101bb1: 5e pop %esi +80101bb2: 5f pop %edi +80101bb3: 5d pop %ebp + switchtoconsole(toconsole); +80101bb4: e9 27 f8 ff ff jmp 801013e0 + inconsoleptr = currentconsole; +80101bb9: 8b 35 80 0e 11 80 mov 0x80110e80,%esi + if (inconsoleptr == 0) +80101bbf: 85 f6 test %esi,%esi +80101bc1: 0f 85 13 fc ff ff jne 801017da + inconsoleptr = &consoles[0]; +80101bc7: be a0 0e 11 80 mov $0x80110ea0,%esi +80101bcc: e9 09 fc ff ff jmp 801017da + procdump(); // now call procdump() wo. cons.lock held +80101bd1: e8 aa 3b 00 00 call 80105780 +80101bd6: e9 9c fa ff ff jmp 80101677 + switchtoconsole(getbaseconsoleptr()); +80101bdb: 83 ec 0c sub $0xc,%esp +80101bde: 68 a0 0e 11 80 push $0x80110ea0 +80101be3: e8 f8 f7 ff ff call 801013e0 +80101be8: 83 c4 10 add $0x10,%esp +80101beb: e9 a0 fa ff ff jmp 80101690 + uartputc('\b'); +80101bf0: 83 ec 0c sub $0xc,%esp +80101bf3: 6a 08 push $0x8 +80101bf5: e8 56 58 00 00 call 80107450 + uartputc(' '); +80101bfa: c7 04 24 20 00 00 00 movl $0x20,(%esp) +80101c01: e8 4a 58 00 00 call 80107450 + uartputc('\b'); +80101c06: c7 04 24 08 00 00 00 movl $0x8,(%esp) +80101c0d: e8 3e 58 00 00 call 80107450 + cgaputc(c); +80101c12: b8 00 01 00 00 mov $0x100,%eax +80101c17: e8 e4 e8 ff ff call 80100500 +} +80101c1c: 83 c4 10 add $0x10,%esp +80101c1f: e9 83 f9 ff ff jmp 801015a7 + for (int i = (currentconsole->consoleindex + 1); i < MAXVCONSOLES; i++) +80101c24: a1 80 0e 11 80 mov 0x80110e80,%eax +80101c29: 8b 10 mov (%eax),%edx +80101c2b: 8d 42 01 lea 0x1(%edx),%eax +80101c2e: 83 f8 09 cmp $0x9,%eax +80101c31: 0f 8f 44 ff ff ff jg 80101b7b +80101c37: 69 d2 b0 10 00 00 imul $0x10b0,%edx,%edx +80101c3d: 81 c2 a0 0e 11 80 add $0x80110ea0,%edx +80101c43: eb 15 jmp 80101c5a +80101c45: 8d 76 00 lea 0x0(%esi),%esi +80101c48: 83 c0 01 add $0x1,%eax +80101c4b: 81 c2 b0 10 00 00 add $0x10b0,%edx +80101c51: 83 f8 0a cmp $0xa,%eax +80101c54: 0f 84 21 ff ff ff je 80101b7b + if (consoles[i].active) +80101c5a: 8b ba 1c 21 00 00 mov 0x211c(%edx),%edi +80101c60: 85 ff test %edi,%edi +80101c62: 74 e4 je 80101c48 + toconsole = &consoles[i]; +80101c64: 69 c0 b0 10 00 00 imul $0x10b0,%eax,%eax +80101c6a: 8d 98 a0 0e 11 80 lea -0x7feef160(%eax),%ebx + if (toconsole == 0) +80101c70: e9 0b ff ff ff jmp 80101b80 + toconsole = &consoles[getmenuindexconsole(switchto)]; +80101c75: 69 9a a0 0e 11 80 b0 imul $0x10b0,-0x7feef160(%edx),%ebx +80101c7c: 10 00 00 +80101c7f: 81 c3 a0 0e 11 80 add $0x80110ea0,%ebx + break; +80101c85: e9 f6 fe ff ff jmp 80101b80 + if (c == BACKSPACE) +80101c8a: 81 fb 00 01 00 00 cmp $0x100,%ebx +80101c90: 74 61 je 80101cf3 + uartputc(c); +80101c92: 83 ec 0c sub $0xc,%esp +80101c95: 53 push %ebx +80101c96: e8 b5 57 00 00 call 80107450 + cgaputc(c); +80101c9b: 89 d8 mov %ebx,%eax +80101c9d: e8 5e e8 ff ff call 80100500 + if (c == '\n' || c == C('D') || consolekbdbuffer->e == consolekbdbuffer->r + INPUT_BUF) +80101ca2: 83 c4 10 add $0x10,%esp +80101ca5: 83 fb 0a cmp $0xa,%ebx +80101ca8: 74 7a je 80101d24 +80101caa: 83 fb 04 cmp $0x4,%ebx +80101cad: 74 75 je 80101d24 +80101caf: 8b bd d8 fe ff ff mov -0x128(%ebp),%edi +80101cb5: 8b 87 5c 10 00 00 mov 0x105c(%edi),%eax +80101cbb: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) +80101cc1: 83 e8 80 sub $0xffffff80,%eax +80101cc4: 39 87 64 10 00 00 cmp %eax,0x1064(%edi) +80101cca: 0f 85 d7 f8 ff ff jne 801015a7 + consolekbdbuffer->w = consolekbdbuffer->e; +80101cd0: 8b bd d8 fe ff ff mov -0x128(%ebp),%edi + wakeup(&(consolekbdbuffer->r)); +80101cd6: 83 ec 0c sub $0xc,%esp + consolekbdbuffer->w = consolekbdbuffer->e; +80101cd9: 89 87 60 10 00 00 mov %eax,0x1060(%edi) + wakeup(&(consolekbdbuffer->r)); +80101cdf: 8d 87 5c 10 00 00 lea 0x105c(%edi),%eax +80101ce5: 50 push %eax +80101ce6: e8 b5 39 00 00 call 801056a0 +80101ceb: 83 c4 10 add $0x10,%esp +80101cee: e9 b4 f8 ff ff jmp 801015a7 + uartputc('\b'); +80101cf3: 83 ec 0c sub $0xc,%esp +80101cf6: 6a 08 push $0x8 +80101cf8: e8 53 57 00 00 call 80107450 + uartputc(' '); +80101cfd: c7 04 24 20 00 00 00 movl $0x20,(%esp) +80101d04: e8 47 57 00 00 call 80107450 + uartputc('\b'); +80101d09: c7 04 24 08 00 00 00 movl $0x8,(%esp) +80101d10: e8 3b 57 00 00 call 80107450 + cgaputc(c); +80101d15: b8 00 01 00 00 mov $0x100,%eax +80101d1a: e8 e1 e7 ff ff call 80100500 +80101d1f: 83 c4 10 add $0x10,%esp +80101d22: eb 8b jmp 80101caf + consolekbdbuffer->w = consolekbdbuffer->e; +80101d24: 8b 85 d8 fe ff ff mov -0x128(%ebp),%eax +80101d2a: 8b 80 64 10 00 00 mov 0x1064(%eax),%eax +80101d30: eb 9e jmp 80101cd0 +80101d32: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101d39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80101d40 : + +// Function for closing the current console +int closeconsole(void) +{ +80101d40: 55 push %ebp +80101d41: 89 e5 mov %esp,%ebp +80101d43: 53 push %ebx +80101d44: 83 ec 04 sub $0x4,%esp + struct vconsole* consoleptr = myproc()->consoleptr; +80101d47: e8 64 31 00 00 call 80104eb0 + + acquire(&vcons.lock); +80101d4c: 83 ec 0c sub $0xc,%esp + struct vconsole* consoleptr = myproc()->consoleptr; +80101d4f: 8b 58 7c mov 0x7c(%eax),%ebx + acquire(&vcons.lock); +80101d52: 68 40 b6 11 80 push $0x8011b640 +80101d57: e8 24 3e 00 00 call 80105b80 + // Check if the process exiting is the consoles parent process we clear the buffer and set the active to 0 + if (myproc() == consoleptr->processowner) +80101d5c: e8 4f 31 00 00 call 80104eb0 +80101d61: 83 c4 10 add $0x10,%esp +80101d64: 39 43 38 cmp %eax,0x38(%ebx) +80101d67: 74 17 je 80101d80 + release(&vcons.lock); + switchtoconsole(&consoles[0]); + return 1; + } + } + release(&vcons.lock); +80101d69: 83 ec 0c sub $0xc,%esp +80101d6c: 68 40 b6 11 80 push $0x8011b640 +80101d71: e8 aa 3d 00 00 call 80105b20 + return 0; +80101d76: 83 c4 10 add $0x10,%esp +80101d79: 31 c0 xor %eax,%eax +} +80101d7b: 8b 5d fc mov -0x4(%ebp),%ebx +80101d7e: c9 leave +80101d7f: c3 ret + memset(bufferin, 0, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101d80: 83 ec 04 sub $0x4,%esp + clearconsole(consoleptr->screenbuffer); +80101d83: 8d 43 3c lea 0x3c(%ebx),%eax + memset(bufferin, 0, sizeof(bufferin[0]) * SCRHEIGHT * SCRWIDTH); +80101d86: 68 a0 0f 00 00 push $0xfa0 +80101d8b: 6a 00 push $0x0 +80101d8d: 50 push %eax +80101d8e: e8 ad 3e 00 00 call 80105c40 + if (consoleptr->inuse) +80101d93: 8b 83 70 10 00 00 mov 0x1070(%ebx),%eax +80101d99: 83 c4 10 add $0x10,%esp + consoleptr->active = 0; +80101d9c: c7 83 6c 10 00 00 00 movl $0x0,0x106c(%ebx) +80101da3: 00 00 00 + if (consoleptr->inuse) +80101da6: 85 c0 test %eax,%eax +80101da8: 74 bf je 80101d69 + consoleptr->inuse = 0; +80101daa: c7 83 70 10 00 00 00 movl $0x0,0x1070(%ebx) +80101db1: 00 00 00 + release(&vcons.lock); +80101db4: 83 ec 0c sub $0xc,%esp +80101db7: 68 40 b6 11 80 push $0x8011b640 +80101dbc: e8 5f 3d 00 00 call 80105b20 + switchtoconsole(&consoles[0]); +80101dc1: c7 04 24 a0 0e 11 80 movl $0x80110ea0,(%esp) +80101dc8: e8 13 f6 ff ff call 801013e0 + return 1; +80101dcd: 83 c4 10 add $0x10,%esp +80101dd0: b8 01 00 00 00 mov $0x1,%eax +80101dd5: eb a4 jmp 80101d7b +80101dd7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101dde: 66 90 xchg %ax,%ax + +80101de0 : + +// Function for getting the console index of the current inuse console +int getcurrentconsoleindex(void) +{ +80101de0: 55 push %ebp +80101de1: 89 e5 mov %esp,%ebp +80101de3: 53 push %ebx + acquire(&vcons.lock); + for (int i = 0; i < MAXVCONSOLES; i++) +80101de4: 31 db xor %ebx,%ebx +{ +80101de6: 83 ec 10 sub $0x10,%esp + acquire(&vcons.lock); +80101de9: 68 40 b6 11 80 push $0x8011b640 +80101dee: e8 8d 3d 00 00 call 80105b80 + for (int i = 0; i < MAXVCONSOLES; i++) +80101df3: b8 10 1f 11 80 mov $0x80111f10,%eax +80101df8: 83 c4 10 add $0x10,%esp +80101dfb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101dff: 90 nop + { + if (consoles[i].inuse) +80101e00: 8b 10 mov (%eax),%edx +80101e02: 85 d2 test %edx,%edx +80101e04: 75 2a jne 80101e30 + for (int i = 0; i < MAXVCONSOLES; i++) +80101e06: 83 c3 01 add $0x1,%ebx +80101e09: 05 b0 10 00 00 add $0x10b0,%eax +80101e0e: 83 fb 0a cmp $0xa,%ebx +80101e11: 75 ed jne 80101e00 + { + release(&vcons.lock); + return consoles[i].consoleindex; + } + } + release(&vcons.lock); +80101e13: 83 ec 0c sub $0xc,%esp +80101e16: 68 40 b6 11 80 push $0x8011b640 +80101e1b: e8 00 3d 00 00 call 80105b20 + return -1; +} +80101e20: 8b 5d fc mov -0x4(%ebp),%ebx + return -1; +80101e23: 83 c4 10 add $0x10,%esp +80101e26: b8 ff ff ff ff mov $0xffffffff,%eax +} +80101e2b: c9 leave +80101e2c: c3 ret +80101e2d: 8d 76 00 lea 0x0(%esi),%esi + release(&vcons.lock); +80101e30: 83 ec 0c sub $0xc,%esp + return consoles[i].consoleindex; +80101e33: 69 db b0 10 00 00 imul $0x10b0,%ebx,%ebx + release(&vcons.lock); +80101e39: 68 40 b6 11 80 push $0x8011b640 +80101e3e: e8 dd 3c 00 00 call 80105b20 + return consoles[i].consoleindex; +80101e43: 8b 83 a0 0e 11 80 mov -0x7feef160(%ebx),%eax +80101e49: 83 c4 10 add $0x10,%esp +} +80101e4c: 8b 5d fc mov -0x4(%ebp),%ebx +80101e4f: c9 leave +80101e50: c3 ret +80101e51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101e58: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101e5f: 90 nop + +80101e60 : + +// Function for setting the title of a console for the title bar and menu +void setconsoleproctitle(struct vconsole* consoleptr, char* newtitle) +{ +80101e60: 55 push %ebp +80101e61: 89 e5 mov %esp,%ebp +80101e63: 56 push %esi +80101e64: 53 push %ebx +80101e65: 8b 5d 08 mov 0x8(%ebp),%ebx +80101e68: 8b 75 0c mov 0xc(%ebp),%esi + if (!consoleptr->titlelocked) +80101e6b: 8b 83 8c 10 00 00 mov 0x108c(%ebx),%eax +80101e71: 85 c0 test %eax,%eax +80101e73: 74 0b je 80101e80 + //Redraw the title since its been updated now + drawtitle(); + + release(&vcons.lock); + } +80101e75: 8d 65 f8 lea -0x8(%ebp),%esp +80101e78: 5b pop %ebx +80101e79: 5e pop %esi +80101e7a: 5d pop %ebp +80101e7b: c3 ret +80101e7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + acquire(&vcons.lock); +80101e80: 83 ec 0c sub $0xc,%esp + memset(consoleptr->proctitle, 0, sizeof(consoleptr->proctitle[0]) * sizeof(consoleptr->proctitle)); +80101e83: 81 c3 78 10 00 00 add $0x1078,%ebx + acquire(&vcons.lock); +80101e89: 68 40 b6 11 80 push $0x8011b640 +80101e8e: e8 ed 3c 00 00 call 80105b80 + memset(consoleptr->proctitle, 0, sizeof(consoleptr->proctitle[0]) * sizeof(consoleptr->proctitle)); +80101e93: 83 c4 0c add $0xc,%esp +80101e96: 6a 14 push $0x14 +80101e98: 6a 00 push $0x0 +80101e9a: 53 push %ebx +80101e9b: e8 a0 3d 00 00 call 80105c40 + safestrcpy(consoleptr->proctitle, newtitle, sizeof(consoleptr->proctitle)); +80101ea0: 83 c4 0c add $0xc,%esp +80101ea3: 6a 14 push $0x14 +80101ea5: 56 push %esi +80101ea6: 53 push %ebx +80101ea7: e8 54 3f 00 00 call 80105e00 + drawtitle(); +80101eac: e8 df ef ff ff call 80100e90 + release(&vcons.lock); +80101eb1: c7 45 08 40 b6 11 80 movl $0x8011b640,0x8(%ebp) +80101eb8: 83 c4 10 add $0x10,%esp +80101ebb: 8d 65 f8 lea -0x8(%ebp),%esp +80101ebe: 5b pop %ebx +80101ebf: 5e pop %esi +80101ec0: 5d pop %ebp + release(&vcons.lock); +80101ec1: e9 5a 3c 00 00 jmp 80105b20 +80101ec6: 66 90 xchg %ax,%ax +80101ec8: 66 90 xchg %ax,%ax +80101eca: 66 90 xchg %ax,%ax +80101ecc: 66 90 xchg %ax,%ax +80101ece: 66 90 xchg %ax,%ax + +80101ed0 : +#include "proc.h" +#include "defs.h" +#include "x86.h" +#include "elf.h" + +void cleanupexec(pde_t * pgdir, struct inode *ip) { +80101ed0: 55 push %ebp +80101ed1: 89 e5 mov %esp,%ebp +80101ed3: 53 push %ebx +80101ed4: 83 ec 04 sub $0x4,%esp +80101ed7: 8b 45 08 mov 0x8(%ebp),%eax +80101eda: 8b 5d 0c mov 0xc(%ebp),%ebx + if (pgdir) { +80101edd: 85 c0 test %eax,%eax +80101edf: 74 0c je 80101eed + freevm(pgdir); +80101ee1: 83 ec 0c sub $0xc,%esp +80101ee4: 50 push %eax +80101ee5: e8 76 66 00 00 call 80108560 +80101eea: 83 c4 10 add $0x10,%esp + } + if (ip) { +80101eed: 85 db test %ebx,%ebx +80101eef: 74 1f je 80101f10 + iunlockput(ip); +80101ef1: 83 ec 0c sub $0xc,%esp +80101ef4: 53 push %ebx +80101ef5: e8 06 10 00 00 call 80102f00 + end_op(); + } +} +80101efa: 8b 5d fc mov -0x4(%ebp),%ebx + end_op(); +80101efd: 83 c4 10 add $0x10,%esp +} +80101f00: c9 leave + end_op(); +80101f01: e9 ba 23 00 00 jmp 801042c0 +80101f06: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101f0d: 8d 76 00 lea 0x0(%esi),%esi +} +80101f10: 8b 5d fc mov -0x4(%ebp),%ebx +80101f13: c9 leave +80101f14: c3 ret +80101f15: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101f1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80101f20 : + +int exec(char *path, char **argv) { +80101f20: 55 push %ebp +80101f21: 89 e5 mov %esp,%ebp +80101f23: 57 push %edi +80101f24: 56 push %esi +80101f25: 53 push %ebx +80101f26: 81 ec 0c 01 00 00 sub $0x10c,%esp + uint argc, sz, sp, ustack[3 + MAXARG + 1]; + struct elfhdr elf; + struct inode *ip; + struct proghdr ph; + pde_t *pgdir, *oldpgdir; + struct proc *curproc = myproc(); +80101f2c: e8 7f 2f 00 00 call 80104eb0 +80101f31: 89 85 ec fe ff ff mov %eax,-0x114(%ebp) + + begin_op(); +80101f37: e8 14 23 00 00 call 80104250 + + if ((ip = namei(path)) == 0) { +80101f3c: 83 ec 0c sub $0xc,%esp +80101f3f: ff 75 08 push 0x8(%ebp) +80101f42: e8 49 16 00 00 call 80103590 +80101f47: 83 c4 10 add $0x10,%esp +80101f4a: 85 c0 test %eax,%eax +80101f4c: 0f 84 6b 03 00 00 je 801022bd + end_op(); + cprintf("exec: fail\n"); + return -1; + } + ilock(ip); +80101f52: 83 ec 0c sub $0xc,%esp +80101f55: 89 c7 mov %eax,%edi +80101f57: 50 push %eax +80101f58: e8 13 0d 00 00 call 80102c70 + pgdir = 0; + + // Check ELF header + if (readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) { +80101f5d: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax +80101f63: 6a 34 push $0x34 +80101f65: 6a 00 push $0x0 +80101f67: 50 push %eax +80101f68: 57 push %edi +80101f69: e8 12 10 00 00 call 80102f80 +80101f6e: 83 c4 20 add $0x20,%esp +80101f71: 83 f8 34 cmp $0x34,%eax +80101f74: 0f 85 f8 02 00 00 jne 80102272 + cleanupexec(pgdir, ip); + return -1; + } + if (elf.magic != ELF_MAGIC) { +80101f7a: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp) +80101f81: 45 4c 46 +80101f84: 0f 85 e8 02 00 00 jne 80102272 + cleanupexec(pgdir, ip); + return -1; + } + + if ((pgdir = setupkvm()) == 0) { +80101f8a: e8 51 66 00 00 call 801085e0 +80101f8f: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) +80101f95: 85 c0 test %eax,%eax +80101f97: 0f 84 d5 02 00 00 je 80102272 + return -1; + } + + // Load program into memory. + sz = 0; + for (i = 0, off = elf.phoff; i < elf.phnum; i++, off += sizeof(ph)) { +80101f9d: 66 83 bd 50 ff ff ff cmpw $0x0,-0xb0(%ebp) +80101fa4: 00 +80101fa5: 8b 9d 40 ff ff ff mov -0xc0(%ebp),%ebx +80101fab: 0f 84 dc 02 00 00 je 8010228d + sz = 0; +80101fb1: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp) +80101fb8: 00 00 00 + for (i = 0, off = elf.phoff; i < elf.phnum; i++, off += sizeof(ph)) { +80101fbb: 31 f6 xor %esi,%esi +80101fbd: e9 8c 00 00 00 jmp 8010204e +80101fc2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) { + cleanupexec(pgdir, ip); + return -1; + } + if (ph.type != ELF_PROG_LOAD) { +80101fc8: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp) +80101fcf: 75 6c jne 8010203d + continue; + } + if (ph.memsz < ph.filesz) { +80101fd1: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax +80101fd7: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax +80101fdd: 0f 82 87 00 00 00 jb 8010206a + cleanupexec(pgdir, ip); + return -1; + } + if (ph.vaddr + ph.memsz < ph.vaddr) { +80101fe3: 03 85 0c ff ff ff add -0xf4(%ebp),%eax +80101fe9: 72 7f jb 8010206a + cleanupexec(pgdir, ip); + return -1; + } + if ((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) { +80101feb: 83 ec 04 sub $0x4,%esp +80101fee: 50 push %eax +80101fef: ff b5 f0 fe ff ff push -0x110(%ebp) +80101ff5: ff b5 f4 fe ff ff push -0x10c(%ebp) +80101ffb: e8 00 64 00 00 call 80108400 +80102000: 83 c4 10 add $0x10,%esp +80102003: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) +80102009: 85 c0 test %eax,%eax +8010200b: 74 5d je 8010206a + cleanupexec(pgdir, ip); + return -1; + } + if (ph.vaddr % PGSIZE != 0) { +8010200d: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax +80102013: a9 ff 0f 00 00 test $0xfff,%eax +80102018: 75 50 jne 8010206a + cleanupexec(pgdir, ip); + return -1; + } + if (loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) { +8010201a: 83 ec 0c sub $0xc,%esp +8010201d: ff b5 14 ff ff ff push -0xec(%ebp) +80102023: ff b5 08 ff ff ff push -0xf8(%ebp) +80102029: 57 push %edi +8010202a: 50 push %eax +8010202b: ff b5 f4 fe ff ff push -0x10c(%ebp) +80102031: e8 da 62 00 00 call 80108310 +80102036: 83 c4 20 add $0x20,%esp +80102039: 85 c0 test %eax,%eax +8010203b: 78 2d js 8010206a + for (i = 0, off = elf.phoff; i < elf.phnum; i++, off += sizeof(ph)) { +8010203d: 0f b7 85 50 ff ff ff movzwl -0xb0(%ebp),%eax +80102044: 83 c6 01 add $0x1,%esi +80102047: 83 c3 20 add $0x20,%ebx +8010204a: 39 f0 cmp %esi,%eax +8010204c: 7e 4a jle 80102098 + if (readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) { +8010204e: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax +80102054: 6a 20 push $0x20 +80102056: 53 push %ebx +80102057: 50 push %eax +80102058: 57 push %edi +80102059: e8 22 0f 00 00 call 80102f80 +8010205e: 83 c4 10 add $0x10,%esp +80102061: 83 f8 20 cmp $0x20,%eax +80102064: 0f 84 5e ff ff ff je 80101fc8 + freevm(pgdir); +8010206a: 83 ec 0c sub $0xc,%esp +8010206d: ff b5 f4 fe ff ff push -0x10c(%ebp) +80102073: e8 e8 64 00 00 call 80108560 + iunlockput(ip); +80102078: 89 3c 24 mov %edi,(%esp) +8010207b: e8 80 0e 00 00 call 80102f00 + end_op(); +80102080: e8 3b 22 00 00 call 801042c0 +} +80102085: 83 c4 10 add $0x10,%esp + cleanupexec(pgdir, ip); + return -1; +80102088: b8 ff ff ff ff mov $0xffffffff,%eax + curproc->tf->eip = elf.entry; // main + curproc->tf->esp = sp; + switchuvm(curproc); + freevm(oldpgdir); + return 0; +} +8010208d: 8d 65 f4 lea -0xc(%ebp),%esp +80102090: 5b pop %ebx +80102091: 5e pop %esi +80102092: 5f pop %edi +80102093: 5d pop %ebp +80102094: c3 ret +80102095: 8d 76 00 lea 0x0(%esi),%esi + sz = PGROUNDUP(sz); +80102098: 8b b5 f0 fe ff ff mov -0x110(%ebp),%esi +8010209e: 81 c6 ff 0f 00 00 add $0xfff,%esi +801020a4: 81 e6 00 f0 ff ff and $0xfffff000,%esi + if ((sz = allocuvm(pgdir, sz, sz + 2 * PGSIZE)) == 0) { +801020aa: 8d 9e 00 20 00 00 lea 0x2000(%esi),%ebx + iunlockput(ip); +801020b0: 83 ec 0c sub $0xc,%esp +801020b3: 57 push %edi +801020b4: e8 47 0e 00 00 call 80102f00 + end_op(); +801020b9: e8 02 22 00 00 call 801042c0 + if ((sz = allocuvm(pgdir, sz, sz + 2 * PGSIZE)) == 0) { +801020be: 83 c4 0c add $0xc,%esp +801020c1: 53 push %ebx +801020c2: 56 push %esi +801020c3: ff b5 f4 fe ff ff push -0x10c(%ebp) +801020c9: e8 32 63 00 00 call 80108400 +801020ce: 83 c4 10 add $0x10,%esp +801020d1: 89 c7 mov %eax,%edi +801020d3: 85 c0 test %eax,%eax +801020d5: 0f 84 87 00 00 00 je 80102162 + clearpteu(pgdir, (char*)(sz - 2 * PGSIZE)); +801020db: 83 ec 08 sub $0x8,%esp +801020de: 8d 80 00 e0 ff ff lea -0x2000(%eax),%eax + for (argc = 0; argv[argc]; argc++) { +801020e4: 89 fb mov %edi,%ebx +801020e6: 31 f6 xor %esi,%esi + clearpteu(pgdir, (char*)(sz - 2 * PGSIZE)); +801020e8: 50 push %eax +801020e9: ff b5 f4 fe ff ff push -0x10c(%ebp) +801020ef: e8 8c 65 00 00 call 80108680 + for (argc = 0; argv[argc]; argc++) { +801020f4: 8b 45 0c mov 0xc(%ebp),%eax +801020f7: 83 c4 10 add $0x10,%esp +801020fa: 8b 08 mov (%eax),%ecx +801020fc: 85 c9 test %ecx,%ecx +801020fe: 0f 84 95 01 00 00 je 80102299 +80102104: 89 bd f0 fe ff ff mov %edi,-0x110(%ebp) +8010210a: 8b 7d 0c mov 0xc(%ebp),%edi +8010210d: eb 1f jmp 8010212e +8010210f: 90 nop +80102110: 8d 46 01 lea 0x1(%esi),%eax + ustack[3 + argc] = sp; +80102113: 89 9c b5 64 ff ff ff mov %ebx,-0x9c(%ebp,%esi,4) +8010211a: 8d 95 58 ff ff ff lea -0xa8(%ebp),%edx + for (argc = 0; argv[argc]; argc++) { +80102120: 8b 0c 87 mov (%edi,%eax,4),%ecx +80102123: 85 c9 test %ecx,%ecx +80102125: 74 59 je 80102180 + if (argc >= MAXARG) { +80102127: 83 f8 20 cmp $0x20,%eax +8010212a: 74 36 je 80102162 +8010212c: 89 c6 mov %eax,%esi + sp = (sp - (strlen(argv[argc]) + 1)) & ~3; +8010212e: 83 ec 0c sub $0xc,%esp +80102131: 51 push %ecx +80102132: e8 09 3d 00 00 call 80105e40 + if (copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) { +80102137: 5a pop %edx +80102138: ff 34 b7 push (%edi,%esi,4) + sp = (sp - (strlen(argv[argc]) + 1)) & ~3; +8010213b: 29 c3 sub %eax,%ebx +8010213d: 83 eb 01 sub $0x1,%ebx + if (copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) { +80102140: e8 fb 3c 00 00 call 80105e40 + sp = (sp - (strlen(argv[argc]) + 1)) & ~3; +80102145: 83 e3 fc and $0xfffffffc,%ebx + if (copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) { +80102148: 83 c0 01 add $0x1,%eax +8010214b: 50 push %eax +8010214c: ff 34 b7 push (%edi,%esi,4) +8010214f: 53 push %ebx +80102150: ff b5 f4 fe ff ff push -0x10c(%ebp) +80102156: e8 15 67 00 00 call 80108870 +8010215b: 83 c4 20 add $0x20,%esp +8010215e: 85 c0 test %eax,%eax +80102160: 79 ae jns 80102110 + freevm(pgdir); +80102162: 83 ec 0c sub $0xc,%esp +80102165: ff b5 f4 fe ff ff push -0x10c(%ebp) +8010216b: e8 f0 63 00 00 call 80108560 +} +80102170: 83 c4 10 add $0x10,%esp +} +80102173: 8d 65 f4 lea -0xc(%ebp),%esp + return -1; +80102176: b8 ff ff ff ff mov $0xffffffff,%eax +} +8010217b: 5b pop %ebx +8010217c: 5e pop %esi +8010217d: 5f pop %edi +8010217e: 5d pop %ebp +8010217f: c3 ret + ustack[2] = sp - (argc + 1) * 4; // argv pointer +80102180: 8d 0c b5 08 00 00 00 lea 0x8(,%esi,4),%ecx + ustack[3 + argc] = 0; +80102187: 8b bd f0 fe ff ff mov -0x110(%ebp),%edi +8010218d: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) +80102193: 8d 46 04 lea 0x4(%esi),%eax + sp -= (3 + argc + 1) * 4; +80102196: 8d 71 0c lea 0xc(%ecx),%esi + ustack[3 + argc] = 0; +80102199: c7 84 85 58 ff ff ff movl $0x0,-0xa8(%ebp,%eax,4) +801021a0: 00 00 00 00 + ustack[1] = argc; +801021a4: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax + if (copyout(pgdir, sp, ustack, (3 + argc + 1) * 4) < 0) { +801021aa: 56 push %esi + ustack[1] = argc; +801021ab: 89 85 5c ff ff ff mov %eax,-0xa4(%ebp) + ustack[2] = sp - (argc + 1) * 4; // argv pointer +801021b1: 89 d8 mov %ebx,%eax + sp -= (3 + argc + 1) * 4; +801021b3: 29 f3 sub %esi,%ebx + if (copyout(pgdir, sp, ustack, (3 + argc + 1) * 4) < 0) { +801021b5: 52 push %edx + ustack[2] = sp - (argc + 1) * 4; // argv pointer +801021b6: 29 c8 sub %ecx,%eax + if (copyout(pgdir, sp, ustack, (3 + argc + 1) * 4) < 0) { +801021b8: 53 push %ebx +801021b9: ff b5 f4 fe ff ff push -0x10c(%ebp) + ustack[0] = 0xffffffff; // fake return PC +801021bf: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) +801021c6: ff ff ff + ustack[2] = sp - (argc + 1) * 4; // argv pointer +801021c9: 89 85 60 ff ff ff mov %eax,-0xa0(%ebp) + if (copyout(pgdir, sp, ustack, (3 + argc + 1) * 4) < 0) { +801021cf: e8 9c 66 00 00 call 80108870 +801021d4: 83 c4 10 add $0x10,%esp +801021d7: 85 c0 test %eax,%eax +801021d9: 0f 88 fd 00 00 00 js 801022dc + for (last = s = path; *s; s++) { +801021df: 8b 45 08 mov 0x8(%ebp),%eax +801021e2: 8b 55 08 mov 0x8(%ebp),%edx +801021e5: 8b 4d 08 mov 0x8(%ebp),%ecx +801021e8: 0f b6 00 movzbl (%eax),%eax +801021eb: 84 c0 test %al,%al +801021ed: 74 10 je 801021ff +801021ef: 90 nop + last = s + 1; +801021f0: 83 c1 01 add $0x1,%ecx +801021f3: 3c 2f cmp $0x2f,%al + for (last = s = path; *s; s++) { +801021f5: 0f b6 01 movzbl (%ecx),%eax + last = s + 1; +801021f8: 0f 44 d1 cmove %ecx,%edx + for (last = s = path; *s; s++) { +801021fb: 84 c0 test %al,%al +801021fd: 75 f1 jne 801021f0 + safestrcpy(curproc->name, last, sizeof(curproc->name)); +801021ff: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax +80102205: 83 ec 04 sub $0x4,%esp +80102208: 6a 10 push $0x10 +8010220a: 8d 70 6c lea 0x6c(%eax),%esi +8010220d: 52 push %edx +8010220e: 56 push %esi +8010220f: e8 ec 3b 00 00 call 80105e00 + if (curproc->consoleptr != 0) +80102214: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax +8010221a: 83 c4 10 add $0x10,%esp +8010221d: 8b 40 7c mov 0x7c(%eax),%eax +80102220: 85 c0 test %eax,%eax +80102222: 74 0d je 80102231 + setconsoleproctitle(curproc->consoleptr, curproc->name); +80102224: 83 ec 08 sub $0x8,%esp +80102227: 56 push %esi +80102228: 50 push %eax +80102229: e8 32 fc ff ff call 80101e60 +8010222e: 83 c4 10 add $0x10,%esp + oldpgdir = curproc->pgdir; +80102231: 8b 8d ec fe ff ff mov -0x114(%ebp),%ecx + curproc->pgdir = pgdir; +80102237: 8b 95 f4 fe ff ff mov -0x10c(%ebp),%edx + switchuvm(curproc); +8010223d: 83 ec 0c sub $0xc,%esp + oldpgdir = curproc->pgdir; +80102240: 8b 71 04 mov 0x4(%ecx),%esi + curproc->tf->eip = elf.entry; // main +80102243: 8b 41 18 mov 0x18(%ecx),%eax + curproc->pgdir = pgdir; +80102246: 89 51 04 mov %edx,0x4(%ecx) + curproc->sz = sz; +80102249: 89 39 mov %edi,(%ecx) + curproc->tf->eip = elf.entry; // main +8010224b: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx +80102251: 89 50 38 mov %edx,0x38(%eax) + curproc->tf->esp = sp; +80102254: 8b 41 18 mov 0x18(%ecx),%eax +80102257: 89 58 44 mov %ebx,0x44(%eax) + switchuvm(curproc); +8010225a: 51 push %ecx +8010225b: e8 20 5f 00 00 call 80108180 + freevm(oldpgdir); +80102260: 89 34 24 mov %esi,(%esp) +80102263: e8 f8 62 00 00 call 80108560 + return 0; +80102268: 83 c4 10 add $0x10,%esp +8010226b: 31 c0 xor %eax,%eax +8010226d: e9 1b fe ff ff jmp 8010208d + iunlockput(ip); +80102272: 83 ec 0c sub $0xc,%esp +80102275: 57 push %edi +80102276: e8 85 0c 00 00 call 80102f00 + end_op(); +8010227b: e8 40 20 00 00 call 801042c0 +} +80102280: 83 c4 10 add $0x10,%esp + return -1; +80102283: b8 ff ff ff ff mov $0xffffffff,%eax +} +80102288: e9 00 fe ff ff jmp 8010208d + for (i = 0, off = elf.phoff; i < elf.phnum; i++, off += sizeof(ph)) { +8010228d: bb 00 20 00 00 mov $0x2000,%ebx +80102292: 31 f6 xor %esi,%esi +80102294: e9 17 fe ff ff jmp 801020b0 + for (argc = 0; argv[argc]; argc++) { +80102299: be 10 00 00 00 mov $0x10,%esi +8010229e: b9 04 00 00 00 mov $0x4,%ecx +801022a3: b8 03 00 00 00 mov $0x3,%eax +801022a8: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp) +801022af: 00 00 00 +801022b2: 8d 95 58 ff ff ff lea -0xa8(%ebp),%edx +801022b8: e9 dc fe ff ff jmp 80102199 + end_op(); +801022bd: e8 fe 1f 00 00 call 801042c0 + cprintf("exec: fail\n"); +801022c2: 83 ec 0c sub $0xc,%esp +801022c5: 68 a1 8a 10 80 push $0x80108aa1 +801022ca: e8 c1 e5 ff ff call 80100890 + return -1; +801022cf: 83 c4 10 add $0x10,%esp +801022d2: b8 ff ff ff ff mov $0xffffffff,%eax +801022d7: e9 b1 fd ff ff jmp 8010208d + cleanupexec(pgdir, ip); +801022dc: 50 push %eax +801022dd: 50 push %eax +801022de: 6a 00 push $0x0 +801022e0: ff b5 f4 fe ff ff push -0x10c(%ebp) +801022e6: e8 e5 fb ff ff call 80101ed0 + return -1; +801022eb: 83 c4 10 add $0x10,%esp +801022ee: 83 c8 ff or $0xffffffff,%eax +801022f1: e9 97 fd ff ff jmp 8010208d +801022f6: 66 90 xchg %ax,%ax +801022f8: 66 90 xchg %ax,%ax +801022fa: 66 90 xchg %ax,%ax +801022fc: 66 90 xchg %ax,%ax +801022fe: 66 90 xchg %ax,%ax + +80102300 : +struct { + struct spinlock lock; + struct file file[NFILE]; +} ftable; + +void fileinit(void) { +80102300: 55 push %ebp +80102301: 89 e5 mov %esp,%ebp +80102303: 83 ec 10 sub $0x10,%esp + initlock(&ftable.lock, "ftable"); +80102306: 68 ad 8a 10 80 push $0x80108aad +8010230b: 68 e0 b6 11 80 push $0x8011b6e0 +80102310: e8 9b 36 00 00 call 801059b0 +} +80102315: 83 c4 10 add $0x10,%esp +80102318: c9 leave +80102319: c3 ret +8010231a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80102320 : + +// Allocate a file structure. +struct file* filealloc(void) { +80102320: 55 push %ebp +80102321: 89 e5 mov %esp,%ebp +80102323: 53 push %ebx + struct file *f; + + acquire(&ftable.lock); + for (f = ftable.file; f < ftable.file + NFILE; f++) { +80102324: bb 14 b7 11 80 mov $0x8011b714,%ebx +struct file* filealloc(void) { +80102329: 83 ec 10 sub $0x10,%esp + acquire(&ftable.lock); +8010232c: 68 e0 b6 11 80 push $0x8011b6e0 +80102331: e8 4a 38 00 00 call 80105b80 +80102336: 83 c4 10 add $0x10,%esp +80102339: eb 10 jmp 8010234b +8010233b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010233f: 90 nop + for (f = ftable.file; f < ftable.file + NFILE; f++) { +80102340: 83 c3 18 add $0x18,%ebx +80102343: 81 fb 74 c0 11 80 cmp $0x8011c074,%ebx +80102349: 74 25 je 80102370 + if (f->ref == 0) { +8010234b: 8b 43 04 mov 0x4(%ebx),%eax +8010234e: 85 c0 test %eax,%eax +80102350: 75 ee jne 80102340 + f->ref = 1; + release(&ftable.lock); +80102352: 83 ec 0c sub $0xc,%esp + f->ref = 1; +80102355: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) + release(&ftable.lock); +8010235c: 68 e0 b6 11 80 push $0x8011b6e0 +80102361: e8 ba 37 00 00 call 80105b20 + return f; + } + } + release(&ftable.lock); + return 0; +} +80102366: 89 d8 mov %ebx,%eax + return f; +80102368: 83 c4 10 add $0x10,%esp +} +8010236b: 8b 5d fc mov -0x4(%ebp),%ebx +8010236e: c9 leave +8010236f: c3 ret + release(&ftable.lock); +80102370: 83 ec 0c sub $0xc,%esp + return 0; +80102373: 31 db xor %ebx,%ebx + release(&ftable.lock); +80102375: 68 e0 b6 11 80 push $0x8011b6e0 +8010237a: e8 a1 37 00 00 call 80105b20 +} +8010237f: 89 d8 mov %ebx,%eax + return 0; +80102381: 83 c4 10 add $0x10,%esp +} +80102384: 8b 5d fc mov -0x4(%ebp),%ebx +80102387: c9 leave +80102388: c3 ret +80102389: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80102390 : + +// Increment ref count for file f. +struct file* filedup(struct file *f) { +80102390: 55 push %ebp +80102391: 89 e5 mov %esp,%ebp +80102393: 53 push %ebx +80102394: 83 ec 10 sub $0x10,%esp +80102397: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&ftable.lock); +8010239a: 68 e0 b6 11 80 push $0x8011b6e0 +8010239f: e8 dc 37 00 00 call 80105b80 + if (f->ref < 1) { +801023a4: 8b 43 04 mov 0x4(%ebx),%eax +801023a7: 83 c4 10 add $0x10,%esp +801023aa: 85 c0 test %eax,%eax +801023ac: 7e 1a jle 801023c8 + panic("filedup"); + } + f->ref++; +801023ae: 83 c0 01 add $0x1,%eax + release(&ftable.lock); +801023b1: 83 ec 0c sub $0xc,%esp + f->ref++; +801023b4: 89 43 04 mov %eax,0x4(%ebx) + release(&ftable.lock); +801023b7: 68 e0 b6 11 80 push $0x8011b6e0 +801023bc: e8 5f 37 00 00 call 80105b20 + return f; +} +801023c1: 89 d8 mov %ebx,%eax +801023c3: 8b 5d fc mov -0x4(%ebp),%ebx +801023c6: c9 leave +801023c7: c3 ret + panic("filedup"); +801023c8: 83 ec 0c sub $0xc,%esp +801023cb: 68 b4 8a 10 80 push $0x80108ab4 +801023d0: e8 ab e0 ff ff call 80100480 +801023d5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801023dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801023e0 : + +// Close file f. (Decrement ref count, close when reaches 0.) +void fileclose(struct file *f) { +801023e0: 55 push %ebp +801023e1: 89 e5 mov %esp,%ebp +801023e3: 57 push %edi +801023e4: 56 push %esi +801023e5: 53 push %ebx +801023e6: 83 ec 28 sub $0x28,%esp +801023e9: 8b 5d 08 mov 0x8(%ebp),%ebx + struct file ff; + + acquire(&ftable.lock); +801023ec: 68 e0 b6 11 80 push $0x8011b6e0 +801023f1: e8 8a 37 00 00 call 80105b80 + if (f->ref < 1) { +801023f6: 8b 53 04 mov 0x4(%ebx),%edx +801023f9: 83 c4 10 add $0x10,%esp +801023fc: 85 d2 test %edx,%edx +801023fe: 0f 8e a5 00 00 00 jle 801024a9 + panic("fileclose"); + } + if (--f->ref > 0) { +80102404: 83 ea 01 sub $0x1,%edx +80102407: 89 53 04 mov %edx,0x4(%ebx) +8010240a: 75 44 jne 80102450 + release(&ftable.lock); + return; + } + ff = *f; +8010240c: 0f b6 43 09 movzbl 0x9(%ebx),%eax + f->ref = 0; + f->type = FD_NONE; + release(&ftable.lock); +80102410: 83 ec 0c sub $0xc,%esp + ff = *f; +80102413: 8b 3b mov (%ebx),%edi + f->type = FD_NONE; +80102415: c7 03 00 00 00 00 movl $0x0,(%ebx) + ff = *f; +8010241b: 8b 73 0c mov 0xc(%ebx),%esi +8010241e: 88 45 e7 mov %al,-0x19(%ebp) +80102421: 8b 43 10 mov 0x10(%ebx),%eax + release(&ftable.lock); +80102424: 68 e0 b6 11 80 push $0x8011b6e0 + ff = *f; +80102429: 89 45 e0 mov %eax,-0x20(%ebp) + release(&ftable.lock); +8010242c: e8 ef 36 00 00 call 80105b20 + + if (ff.type == FD_PIPE) { +80102431: 83 c4 10 add $0x10,%esp +80102434: 83 ff 01 cmp $0x1,%edi +80102437: 74 57 je 80102490 + pipeclose(ff.pipe, ff.writable); + } + else if (ff.type == FD_INODE) { +80102439: 83 ff 02 cmp $0x2,%edi +8010243c: 74 2a je 80102468 + begin_op(); + iput(ff.ip); + end_op(); + } +} +8010243e: 8d 65 f4 lea -0xc(%ebp),%esp +80102441: 5b pop %ebx +80102442: 5e pop %esi +80102443: 5f pop %edi +80102444: 5d pop %ebp +80102445: c3 ret +80102446: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010244d: 8d 76 00 lea 0x0(%esi),%esi + release(&ftable.lock); +80102450: c7 45 08 e0 b6 11 80 movl $0x8011b6e0,0x8(%ebp) +} +80102457: 8d 65 f4 lea -0xc(%ebp),%esp +8010245a: 5b pop %ebx +8010245b: 5e pop %esi +8010245c: 5f pop %edi +8010245d: 5d pop %ebp + release(&ftable.lock); +8010245e: e9 bd 36 00 00 jmp 80105b20 +80102463: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102467: 90 nop + begin_op(); +80102468: e8 e3 1d 00 00 call 80104250 + iput(ff.ip); +8010246d: 83 ec 0c sub $0xc,%esp +80102470: ff 75 e0 push -0x20(%ebp) +80102473: e8 28 09 00 00 call 80102da0 + end_op(); +80102478: 83 c4 10 add $0x10,%esp +} +8010247b: 8d 65 f4 lea -0xc(%ebp),%esp +8010247e: 5b pop %ebx +8010247f: 5e pop %esi +80102480: 5f pop %edi +80102481: 5d pop %ebp + end_op(); +80102482: e9 39 1e 00 00 jmp 801042c0 +80102487: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010248e: 66 90 xchg %ax,%ax + pipeclose(ff.pipe, ff.writable); +80102490: 0f be 5d e7 movsbl -0x19(%ebp),%ebx +80102494: 83 ec 08 sub $0x8,%esp +80102497: 53 push %ebx +80102498: 56 push %esi +80102499: e8 c2 25 00 00 call 80104a60 +8010249e: 83 c4 10 add $0x10,%esp +} +801024a1: 8d 65 f4 lea -0xc(%ebp),%esp +801024a4: 5b pop %ebx +801024a5: 5e pop %esi +801024a6: 5f pop %edi +801024a7: 5d pop %ebp +801024a8: c3 ret + panic("fileclose"); +801024a9: 83 ec 0c sub $0xc,%esp +801024ac: 68 bc 8a 10 80 push $0x80108abc +801024b1: e8 ca df ff ff call 80100480 +801024b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801024bd: 8d 76 00 lea 0x0(%esi),%esi + +801024c0 : + +// Get metadata about file f. +int filestat(struct file *f, struct stat *st) { +801024c0: 55 push %ebp +801024c1: 89 e5 mov %esp,%ebp +801024c3: 53 push %ebx +801024c4: 83 ec 04 sub $0x4,%esp +801024c7: 8b 5d 08 mov 0x8(%ebp),%ebx + if (f->type == FD_INODE) { +801024ca: 83 3b 02 cmpl $0x2,(%ebx) +801024cd: 75 31 jne 80102500 + ilock(f->ip); +801024cf: 83 ec 0c sub $0xc,%esp +801024d2: ff 73 10 push 0x10(%ebx) +801024d5: e8 96 07 00 00 call 80102c70 + stati(f->ip, st); +801024da: 58 pop %eax +801024db: 5a pop %edx +801024dc: ff 75 0c push 0xc(%ebp) +801024df: ff 73 10 push 0x10(%ebx) +801024e2: e8 69 0a 00 00 call 80102f50 + iunlock(f->ip); +801024e7: 59 pop %ecx +801024e8: ff 73 10 push 0x10(%ebx) +801024eb: e8 60 08 00 00 call 80102d50 + return 0; + } + return -1; +} +801024f0: 8b 5d fc mov -0x4(%ebp),%ebx + return 0; +801024f3: 83 c4 10 add $0x10,%esp +801024f6: 31 c0 xor %eax,%eax +} +801024f8: c9 leave +801024f9: c3 ret +801024fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80102500: 8b 5d fc mov -0x4(%ebp),%ebx + return -1; +80102503: b8 ff ff ff ff mov $0xffffffff,%eax +} +80102508: c9 leave +80102509: c3 ret +8010250a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80102510 : + +// Read from file f. +int fileread(struct file *f, char *addr, int n) { +80102510: 55 push %ebp +80102511: 89 e5 mov %esp,%ebp +80102513: 57 push %edi +80102514: 56 push %esi +80102515: 53 push %ebx +80102516: 83 ec 0c sub $0xc,%esp +80102519: 8b 5d 08 mov 0x8(%ebp),%ebx +8010251c: 8b 75 0c mov 0xc(%ebp),%esi +8010251f: 8b 7d 10 mov 0x10(%ebp),%edi + int r; + + if (f->readable == 0) { +80102522: 80 7b 08 00 cmpb $0x0,0x8(%ebx) +80102526: 74 60 je 80102588 + return -1; + } + if (f->type == FD_PIPE) { +80102528: 8b 03 mov (%ebx),%eax +8010252a: 83 f8 01 cmp $0x1,%eax +8010252d: 74 41 je 80102570 + return piperead(f->pipe, addr, n); + } + if (f->type == FD_INODE) { +8010252f: 83 f8 02 cmp $0x2,%eax +80102532: 75 5b jne 8010258f + ilock(f->ip); +80102534: 83 ec 0c sub $0xc,%esp +80102537: ff 73 10 push 0x10(%ebx) +8010253a: e8 31 07 00 00 call 80102c70 + if ((r = readi(f->ip, addr, f->off, n)) > 0) { +8010253f: 57 push %edi +80102540: ff 73 14 push 0x14(%ebx) +80102543: 56 push %esi +80102544: ff 73 10 push 0x10(%ebx) +80102547: e8 34 0a 00 00 call 80102f80 +8010254c: 83 c4 20 add $0x20,%esp +8010254f: 89 c6 mov %eax,%esi +80102551: 85 c0 test %eax,%eax +80102553: 7e 03 jle 80102558 + f->off += r; +80102555: 01 43 14 add %eax,0x14(%ebx) + } + iunlock(f->ip); +80102558: 83 ec 0c sub $0xc,%esp +8010255b: ff 73 10 push 0x10(%ebx) +8010255e: e8 ed 07 00 00 call 80102d50 + return r; +80102563: 83 c4 10 add $0x10,%esp + } + panic("fileread"); +} +80102566: 8d 65 f4 lea -0xc(%ebp),%esp +80102569: 89 f0 mov %esi,%eax +8010256b: 5b pop %ebx +8010256c: 5e pop %esi +8010256d: 5f pop %edi +8010256e: 5d pop %ebp +8010256f: c3 ret + return piperead(f->pipe, addr, n); +80102570: 8b 43 0c mov 0xc(%ebx),%eax +80102573: 89 45 08 mov %eax,0x8(%ebp) +} +80102576: 8d 65 f4 lea -0xc(%ebp),%esp +80102579: 5b pop %ebx +8010257a: 5e pop %esi +8010257b: 5f pop %edi +8010257c: 5d pop %ebp + return piperead(f->pipe, addr, n); +8010257d: e9 7e 26 00 00 jmp 80104c00 +80102582: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +80102588: be ff ff ff ff mov $0xffffffff,%esi +8010258d: eb d7 jmp 80102566 + panic("fileread"); +8010258f: 83 ec 0c sub $0xc,%esp +80102592: 68 c6 8a 10 80 push $0x80108ac6 +80102597: e8 e4 de ff ff call 80100480 +8010259c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801025a0 : + + +// Write to file f. +int filewrite(struct file *f, char *addr, int n) { +801025a0: 55 push %ebp +801025a1: 89 e5 mov %esp,%ebp +801025a3: 57 push %edi +801025a4: 56 push %esi +801025a5: 53 push %ebx +801025a6: 83 ec 1c sub $0x1c,%esp +801025a9: 8b 45 0c mov 0xc(%ebp),%eax +801025ac: 8b 5d 08 mov 0x8(%ebp),%ebx +801025af: 89 45 dc mov %eax,-0x24(%ebp) +801025b2: 8b 45 10 mov 0x10(%ebp),%eax + int r; + + if (f->writable == 0) { +801025b5: 80 7b 09 00 cmpb $0x0,0x9(%ebx) +int filewrite(struct file *f, char *addr, int n) { +801025b9: 89 45 e4 mov %eax,-0x1c(%ebp) + if (f->writable == 0) { +801025bc: 0f 84 bd 00 00 00 je 8010267f + return -1; + } + if (f->type == FD_PIPE) { +801025c2: 8b 03 mov (%ebx),%eax +801025c4: 83 f8 01 cmp $0x1,%eax +801025c7: 0f 84 bf 00 00 00 je 8010268c + return pipewrite(f->pipe, addr, n); + } + if (f->type == FD_INODE) { +801025cd: 83 f8 02 cmp $0x2,%eax +801025d0: 0f 85 c8 00 00 00 jne 8010269e + // and 2 blocks of slop for non-aligned writes. + // this really belongs lower down, since writei() + // might be writing a device like the console. + int max = ((MAXOPBLOCKS - 1 - 1 - 2) / 2) * 512; + int i = 0; + while (i < n) { +801025d6: 8b 45 e4 mov -0x1c(%ebp),%eax + int i = 0; +801025d9: 31 f6 xor %esi,%esi + while (i < n) { +801025db: 85 c0 test %eax,%eax +801025dd: 7f 30 jg 8010260f +801025df: e9 94 00 00 00 jmp 80102678 +801025e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + + begin_op(); + ilock(f->ip); + if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) { + f->off += r; +801025e8: 01 43 14 add %eax,0x14(%ebx) + } + iunlock(f->ip); +801025eb: 83 ec 0c sub $0xc,%esp +801025ee: ff 73 10 push 0x10(%ebx) + f->off += r; +801025f1: 89 45 e0 mov %eax,-0x20(%ebp) + iunlock(f->ip); +801025f4: e8 57 07 00 00 call 80102d50 + end_op(); +801025f9: e8 c2 1c 00 00 call 801042c0 + + if (r < 0) { + break; + } + if (r != n1) { +801025fe: 8b 45 e0 mov -0x20(%ebp),%eax +80102601: 83 c4 10 add $0x10,%esp +80102604: 39 c7 cmp %eax,%edi +80102606: 75 5c jne 80102664 + panic("short filewrite"); + } + i += r; +80102608: 01 fe add %edi,%esi + while (i < n) { +8010260a: 39 75 e4 cmp %esi,-0x1c(%ebp) +8010260d: 7e 69 jle 80102678 + int n1 = n - i; +8010260f: 8b 7d e4 mov -0x1c(%ebp),%edi +80102612: b8 00 06 00 00 mov $0x600,%eax +80102617: 29 f7 sub %esi,%edi +80102619: 39 c7 cmp %eax,%edi +8010261b: 0f 4f f8 cmovg %eax,%edi + begin_op(); +8010261e: e8 2d 1c 00 00 call 80104250 + ilock(f->ip); +80102623: 83 ec 0c sub $0xc,%esp +80102626: ff 73 10 push 0x10(%ebx) +80102629: e8 42 06 00 00 call 80102c70 + if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) { +8010262e: 8b 45 dc mov -0x24(%ebp),%eax +80102631: 57 push %edi +80102632: ff 73 14 push 0x14(%ebx) +80102635: 01 f0 add %esi,%eax +80102637: 50 push %eax +80102638: ff 73 10 push 0x10(%ebx) +8010263b: e8 40 0a 00 00 call 80103080 +80102640: 83 c4 20 add $0x20,%esp +80102643: 85 c0 test %eax,%eax +80102645: 7f a1 jg 801025e8 + iunlock(f->ip); +80102647: 83 ec 0c sub $0xc,%esp +8010264a: ff 73 10 push 0x10(%ebx) +8010264d: 89 45 e4 mov %eax,-0x1c(%ebp) +80102650: e8 fb 06 00 00 call 80102d50 + end_op(); +80102655: e8 66 1c 00 00 call 801042c0 + if (r < 0) { +8010265a: 8b 45 e4 mov -0x1c(%ebp),%eax +8010265d: 83 c4 10 add $0x10,%esp +80102660: 85 c0 test %eax,%eax +80102662: 75 1b jne 8010267f + panic("short filewrite"); +80102664: 83 ec 0c sub $0xc,%esp +80102667: 68 cf 8a 10 80 push $0x80108acf +8010266c: e8 0f de ff ff call 80100480 +80102671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + } + return i == n ? n : -1; +80102678: 89 f0 mov %esi,%eax +8010267a: 3b 75 e4 cmp -0x1c(%ebp),%esi +8010267d: 74 05 je 80102684 +8010267f: b8 ff ff ff ff mov $0xffffffff,%eax + } + panic("filewrite"); +} +80102684: 8d 65 f4 lea -0xc(%ebp),%esp +80102687: 5b pop %ebx +80102688: 5e pop %esi +80102689: 5f pop %edi +8010268a: 5d pop %ebp +8010268b: c3 ret + return pipewrite(f->pipe, addr, n); +8010268c: 8b 43 0c mov 0xc(%ebx),%eax +8010268f: 89 45 08 mov %eax,0x8(%ebp) +} +80102692: 8d 65 f4 lea -0xc(%ebp),%esp +80102695: 5b pop %ebx +80102696: 5e pop %esi +80102697: 5f pop %edi +80102698: 5d pop %ebp + return pipewrite(f->pipe, addr, n); +80102699: e9 62 24 00 00 jmp 80104b00 + panic("filewrite"); +8010269e: 83 ec 0c sub $0xc,%esp +801026a1: 68 d5 8a 10 80 push $0x80108ad5 +801026a6: e8 d5 dd ff ff call 80100480 +801026ab: 66 90 xchg %ax,%ax +801026ad: 66 90 xchg %ax,%ax +801026af: 90 nop + +801026b0 : + } + panic("balloc: out of blocks"); +} + +// Free a disk block. +static void bfree(int dev, uint b) { +801026b0: 55 push %ebp +801026b1: 89 c1 mov %eax,%ecx + struct buf *bp; + int bi, m; + + bp = bread(dev, BBLOCK(b, sb)); +801026b3: 89 d0 mov %edx,%eax +801026b5: c1 e8 0c shr $0xc,%eax +801026b8: 03 05 4c dd 11 80 add 0x8011dd4c,%eax +static void bfree(int dev, uint b) { +801026be: 89 e5 mov %esp,%ebp +801026c0: 56 push %esi +801026c1: 53 push %ebx +801026c2: 89 d3 mov %edx,%ebx + bp = bread(dev, BBLOCK(b, sb)); +801026c4: 83 ec 08 sub $0x8,%esp +801026c7: 50 push %eax +801026c8: 51 push %ecx +801026c9: e8 02 da ff ff call 801000d0 + bi = b % BPB; + m = 1 << (bi % 8); +801026ce: 89 d9 mov %ebx,%ecx + if ((bp->data[bi / 8] & m) == 0) { +801026d0: c1 fb 03 sar $0x3,%ebx +801026d3: 83 c4 10 add $0x10,%esp + bp = bread(dev, BBLOCK(b, sb)); +801026d6: 89 c6 mov %eax,%esi + m = 1 << (bi % 8); +801026d8: 83 e1 07 and $0x7,%ecx +801026db: b8 01 00 00 00 mov $0x1,%eax + if ((bp->data[bi / 8] & m) == 0) { +801026e0: 81 e3 ff 01 00 00 and $0x1ff,%ebx + m = 1 << (bi % 8); +801026e6: d3 e0 shl %cl,%eax + if ((bp->data[bi / 8] & m) == 0) { +801026e8: 0f b6 4c 1e 5c movzbl 0x5c(%esi,%ebx,1),%ecx +801026ed: 85 c1 test %eax,%ecx +801026ef: 74 23 je 80102714 + panic("freeing free block"); + } + bp->data[bi / 8] &= ~m; +801026f1: f7 d0 not %eax + log_write(bp); +801026f3: 83 ec 0c sub $0xc,%esp + bp->data[bi / 8] &= ~m; +801026f6: 21 c8 and %ecx,%eax +801026f8: 88 44 1e 5c mov %al,0x5c(%esi,%ebx,1) + log_write(bp); +801026fc: 56 push %esi +801026fd: e8 2e 1d 00 00 call 80104430 + brelse(bp); +80102702: 89 34 24 mov %esi,(%esp) +80102705: e8 e6 da ff ff call 801001f0 +} +8010270a: 83 c4 10 add $0x10,%esp +8010270d: 8d 65 f8 lea -0x8(%ebp),%esp +80102710: 5b pop %ebx +80102711: 5e pop %esi +80102712: 5d pop %ebp +80102713: c3 ret + panic("freeing free block"); +80102714: 83 ec 0c sub $0xc,%esp +80102717: 68 df 8a 10 80 push $0x80108adf +8010271c: e8 5f dd ff ff call 80100480 +80102721: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102728: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010272f: 90 nop + +80102730 : +static uint balloc(uint dev) { +80102730: 55 push %ebp +80102731: 89 e5 mov %esp,%ebp +80102733: 57 push %edi +80102734: 56 push %esi +80102735: 53 push %ebx +80102736: 83 ec 1c sub $0x1c,%esp + for (b = 0; b < sb.size; b += BPB) { +80102739: 8b 0d 34 dd 11 80 mov 0x8011dd34,%ecx +static uint balloc(uint dev) { +8010273f: 89 45 d8 mov %eax,-0x28(%ebp) + for (b = 0; b < sb.size; b += BPB) { +80102742: 85 c9 test %ecx,%ecx +80102744: 0f 84 87 00 00 00 je 801027d1 +8010274a: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + bp = bread(dev, BBLOCK(b, sb)); +80102751: 8b 75 dc mov -0x24(%ebp),%esi +80102754: 83 ec 08 sub $0x8,%esp +80102757: 89 f0 mov %esi,%eax +80102759: c1 f8 0c sar $0xc,%eax +8010275c: 03 05 4c dd 11 80 add 0x8011dd4c,%eax +80102762: 50 push %eax +80102763: ff 75 d8 push -0x28(%ebp) +80102766: e8 65 d9 ff ff call 801000d0 +8010276b: 83 c4 10 add $0x10,%esp +8010276e: 89 45 e4 mov %eax,-0x1c(%ebp) + for (bi = 0; bi < BPB && b + bi < sb.size; bi++) { +80102771: a1 34 dd 11 80 mov 0x8011dd34,%eax +80102776: 89 45 e0 mov %eax,-0x20(%ebp) +80102779: 31 c0 xor %eax,%eax +8010277b: eb 2f jmp 801027ac +8010277d: 8d 76 00 lea 0x0(%esi),%esi + m = 1 << (bi % 8); +80102780: 89 c1 mov %eax,%ecx +80102782: bb 01 00 00 00 mov $0x1,%ebx + if ((bp->data[bi / 8] & m) == 0) { // Is block free? +80102787: 8b 55 e4 mov -0x1c(%ebp),%edx + m = 1 << (bi % 8); +8010278a: 83 e1 07 and $0x7,%ecx +8010278d: d3 e3 shl %cl,%ebx + if ((bp->data[bi / 8] & m) == 0) { // Is block free? +8010278f: 89 c1 mov %eax,%ecx +80102791: c1 f9 03 sar $0x3,%ecx +80102794: 0f b6 7c 0a 5c movzbl 0x5c(%edx,%ecx,1),%edi +80102799: 89 fa mov %edi,%edx +8010279b: 85 df test %ebx,%edi +8010279d: 74 41 je 801027e0 + for (bi = 0; bi < BPB && b + bi < sb.size; bi++) { +8010279f: 83 c0 01 add $0x1,%eax +801027a2: 83 c6 01 add $0x1,%esi +801027a5: 3d 00 10 00 00 cmp $0x1000,%eax +801027aa: 74 05 je 801027b1 +801027ac: 39 75 e0 cmp %esi,-0x20(%ebp) +801027af: 77 cf ja 80102780 + brelse(bp); +801027b1: 83 ec 0c sub $0xc,%esp +801027b4: ff 75 e4 push -0x1c(%ebp) +801027b7: e8 34 da ff ff call 801001f0 + for (b = 0; b < sb.size; b += BPB) { +801027bc: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) +801027c3: 83 c4 10 add $0x10,%esp +801027c6: 8b 45 dc mov -0x24(%ebp),%eax +801027c9: 39 05 34 dd 11 80 cmp %eax,0x8011dd34 +801027cf: 77 80 ja 80102751 + panic("balloc: out of blocks"); +801027d1: 83 ec 0c sub $0xc,%esp +801027d4: 68 f2 8a 10 80 push $0x80108af2 +801027d9: e8 a2 dc ff ff call 80100480 +801027de: 66 90 xchg %ax,%ax + bp->data[bi / 8] |= m; // Mark block in use. +801027e0: 8b 7d e4 mov -0x1c(%ebp),%edi + log_write(bp); +801027e3: 83 ec 0c sub $0xc,%esp + bp->data[bi / 8] |= m; // Mark block in use. +801027e6: 09 da or %ebx,%edx +801027e8: 88 54 0f 5c mov %dl,0x5c(%edi,%ecx,1) + log_write(bp); +801027ec: 57 push %edi +801027ed: e8 3e 1c 00 00 call 80104430 + brelse(bp); +801027f2: 89 3c 24 mov %edi,(%esp) +801027f5: e8 f6 d9 ff ff call 801001f0 + bp = bread(dev, bno); +801027fa: 58 pop %eax +801027fb: 5a pop %edx +801027fc: 56 push %esi +801027fd: ff 75 d8 push -0x28(%ebp) +80102800: e8 cb d8 ff ff call 801000d0 + memset(bp->data, 0, BSIZE); +80102805: 83 c4 0c add $0xc,%esp + bp = bread(dev, bno); +80102808: 89 c3 mov %eax,%ebx + memset(bp->data, 0, BSIZE); +8010280a: 8d 40 5c lea 0x5c(%eax),%eax +8010280d: 68 00 02 00 00 push $0x200 +80102812: 6a 00 push $0x0 +80102814: 50 push %eax +80102815: e8 26 34 00 00 call 80105c40 + log_write(bp); +8010281a: 89 1c 24 mov %ebx,(%esp) +8010281d: e8 0e 1c 00 00 call 80104430 + brelse(bp); +80102822: 89 1c 24 mov %ebx,(%esp) +80102825: e8 c6 d9 ff ff call 801001f0 +} +8010282a: 8d 65 f4 lea -0xc(%ebp),%esp +8010282d: 89 f0 mov %esi,%eax +8010282f: 5b pop %ebx +80102830: 5e pop %esi +80102831: 5f pop %edi +80102832: 5d pop %ebp +80102833: c3 ret +80102834: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010283b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010283f: 90 nop + +80102840 : +} + +// Find the inode with number inum on device dev +// and return the in-memory copy. Does not lock +// the inode and does not read it from disk. +static struct inode* iget(uint dev, uint inum) { +80102840: 55 push %ebp +80102841: 89 e5 mov %esp,%ebp +80102843: 57 push %edi +80102844: 89 c7 mov %eax,%edi +80102846: 56 push %esi + struct inode *ip, *empty; + + acquire(&icache.lock); + + // Is the inode already cached? + empty = 0; +80102847: 31 f6 xor %esi,%esi +static struct inode* iget(uint dev, uint inum) { +80102849: 53 push %ebx + for (ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++) { +8010284a: bb 14 c1 11 80 mov $0x8011c114,%ebx +static struct inode* iget(uint dev, uint inum) { +8010284f: 83 ec 28 sub $0x28,%esp +80102852: 89 55 e4 mov %edx,-0x1c(%ebp) + acquire(&icache.lock); +80102855: 68 e0 c0 11 80 push $0x8011c0e0 +8010285a: e8 21 33 00 00 call 80105b80 + for (ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++) { +8010285f: 8b 55 e4 mov -0x1c(%ebp),%edx + acquire(&icache.lock); +80102862: 83 c4 10 add $0x10,%esp +80102865: eb 1b jmp 80102882 +80102867: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010286e: 66 90 xchg %ax,%ax + if (ip->ref > 0 && ip->dev == dev && ip->inum == inum) { +80102870: 39 3b cmp %edi,(%ebx) +80102872: 74 6c je 801028e0 + for (ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++) { +80102874: 81 c3 90 00 00 00 add $0x90,%ebx +8010287a: 81 fb 34 dd 11 80 cmp $0x8011dd34,%ebx +80102880: 73 26 jae 801028a8 + if (ip->ref > 0 && ip->dev == dev && ip->inum == inum) { +80102882: 8b 43 08 mov 0x8(%ebx),%eax +80102885: 85 c0 test %eax,%eax +80102887: 7f e7 jg 80102870 + ip->ref++; + release(&icache.lock); + return ip; + } + if (empty == 0 && ip->ref == 0) { // Remember empty slot. +80102889: 85 f6 test %esi,%esi +8010288b: 75 e7 jne 80102874 +8010288d: 85 c0 test %eax,%eax +8010288f: 75 76 jne 80102907 +80102891: 89 de mov %ebx,%esi + for (ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++) { +80102893: 81 c3 90 00 00 00 add $0x90,%ebx +80102899: 81 fb 34 dd 11 80 cmp $0x8011dd34,%ebx +8010289f: 72 e1 jb 80102882 +801028a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + empty = ip; + } + } + + // Recycle an inode cache entry. + if (empty == 0) { +801028a8: 85 f6 test %esi,%esi +801028aa: 74 79 je 80102925 + ip = empty; + ip->dev = dev; + ip->inum = inum; + ip->ref = 1; + ip->valid = 0; + release(&icache.lock); +801028ac: 83 ec 0c sub $0xc,%esp + ip->dev = dev; +801028af: 89 3e mov %edi,(%esi) + ip->inum = inum; +801028b1: 89 56 04 mov %edx,0x4(%esi) + ip->ref = 1; +801028b4: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) + ip->valid = 0; +801028bb: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) + release(&icache.lock); +801028c2: 68 e0 c0 11 80 push $0x8011c0e0 +801028c7: e8 54 32 00 00 call 80105b20 + + return ip; +801028cc: 83 c4 10 add $0x10,%esp +} +801028cf: 8d 65 f4 lea -0xc(%ebp),%esp +801028d2: 89 f0 mov %esi,%eax +801028d4: 5b pop %ebx +801028d5: 5e pop %esi +801028d6: 5f pop %edi +801028d7: 5d pop %ebp +801028d8: c3 ret +801028d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (ip->ref > 0 && ip->dev == dev && ip->inum == inum) { +801028e0: 39 53 04 cmp %edx,0x4(%ebx) +801028e3: 75 8f jne 80102874 + release(&icache.lock); +801028e5: 83 ec 0c sub $0xc,%esp + ip->ref++; +801028e8: 83 c0 01 add $0x1,%eax + return ip; +801028eb: 89 de mov %ebx,%esi + release(&icache.lock); +801028ed: 68 e0 c0 11 80 push $0x8011c0e0 + ip->ref++; +801028f2: 89 43 08 mov %eax,0x8(%ebx) + release(&icache.lock); +801028f5: e8 26 32 00 00 call 80105b20 + return ip; +801028fa: 83 c4 10 add $0x10,%esp +} +801028fd: 8d 65 f4 lea -0xc(%ebp),%esp +80102900: 89 f0 mov %esi,%eax +80102902: 5b pop %ebx +80102903: 5e pop %esi +80102904: 5f pop %edi +80102905: 5d pop %ebp +80102906: c3 ret + for (ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++) { +80102907: 81 c3 90 00 00 00 add $0x90,%ebx +8010290d: 81 fb 34 dd 11 80 cmp $0x8011dd34,%ebx +80102913: 73 10 jae 80102925 + if (ip->ref > 0 && ip->dev == dev && ip->inum == inum) { +80102915: 8b 43 08 mov 0x8(%ebx),%eax +80102918: 85 c0 test %eax,%eax +8010291a: 0f 8f 50 ff ff ff jg 80102870 +80102920: e9 68 ff ff ff jmp 8010288d + panic("iget: no inodes"); +80102925: 83 ec 0c sub $0xc,%esp +80102928: 68 08 8b 10 80 push $0x80108b08 +8010292d: e8 4e db ff ff call 80100480 +80102932: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102939: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80102940 : +// are listed in ip->addrs[]. The next NINDIRECT blocks are +// listed in block ip->addrs[NDIRECT]. + +// Return the disk block address of the nth block in inode ip. +// If there is no such block, bmap allocates one. +static uint bmap(struct inode *ip, uint bn) { +80102940: 55 push %ebp +80102941: 89 e5 mov %esp,%ebp +80102943: 57 push %edi +80102944: 56 push %esi +80102945: 89 c6 mov %eax,%esi +80102947: 53 push %ebx +80102948: 83 ec 1c sub $0x1c,%esp + uint addr, *a; + struct buf *bp; + + if (bn < NDIRECT) { +8010294b: 83 fa 0b cmp $0xb,%edx +8010294e: 0f 86 8c 00 00 00 jbe 801029e0 + if ((addr = ip->addrs[bn]) == 0) { + ip->addrs[bn] = addr = balloc(ip->dev); + } + return addr; + } + bn -= NDIRECT; +80102954: 8d 5a f4 lea -0xc(%edx),%ebx + + if (bn < NINDIRECT) { +80102957: 83 fb 7f cmp $0x7f,%ebx +8010295a: 0f 87 a2 00 00 00 ja 80102a02 + // Load indirect block, allocating if necessary. + if ((addr = ip->addrs[NDIRECT]) == 0) { +80102960: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax +80102966: 85 c0 test %eax,%eax +80102968: 74 5e je 801029c8 + ip->addrs[NDIRECT] = addr = balloc(ip->dev); + } + bp = bread(ip->dev, addr); +8010296a: 83 ec 08 sub $0x8,%esp +8010296d: 50 push %eax +8010296e: ff 36 push (%esi) +80102970: e8 5b d7 ff ff call 801000d0 + a = (uint*)bp->data; + if ((addr = a[bn]) == 0) { +80102975: 83 c4 10 add $0x10,%esp +80102978: 8d 5c 98 5c lea 0x5c(%eax,%ebx,4),%ebx + bp = bread(ip->dev, addr); +8010297c: 89 c2 mov %eax,%edx + if ((addr = a[bn]) == 0) { +8010297e: 8b 3b mov (%ebx),%edi +80102980: 85 ff test %edi,%edi +80102982: 74 1c je 801029a0 + a[bn] = addr = balloc(ip->dev); + log_write(bp); + } + brelse(bp); +80102984: 83 ec 0c sub $0xc,%esp +80102987: 52 push %edx +80102988: e8 63 d8 ff ff call 801001f0 +8010298d: 83 c4 10 add $0x10,%esp + return addr; + } + + panic("bmap: out of range"); +} +80102990: 8d 65 f4 lea -0xc(%ebp),%esp +80102993: 89 f8 mov %edi,%eax +80102995: 5b pop %ebx +80102996: 5e pop %esi +80102997: 5f pop %edi +80102998: 5d pop %ebp +80102999: c3 ret +8010299a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801029a0: 89 45 e4 mov %eax,-0x1c(%ebp) + a[bn] = addr = balloc(ip->dev); +801029a3: 8b 06 mov (%esi),%eax +801029a5: e8 86 fd ff ff call 80102730 + log_write(bp); +801029aa: 8b 55 e4 mov -0x1c(%ebp),%edx +801029ad: 83 ec 0c sub $0xc,%esp + a[bn] = addr = balloc(ip->dev); +801029b0: 89 03 mov %eax,(%ebx) +801029b2: 89 c7 mov %eax,%edi + log_write(bp); +801029b4: 52 push %edx +801029b5: e8 76 1a 00 00 call 80104430 +801029ba: 8b 55 e4 mov -0x1c(%ebp),%edx +801029bd: 83 c4 10 add $0x10,%esp +801029c0: eb c2 jmp 80102984 +801029c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + ip->addrs[NDIRECT] = addr = balloc(ip->dev); +801029c8: 8b 06 mov (%esi),%eax +801029ca: e8 61 fd ff ff call 80102730 +801029cf: 89 86 8c 00 00 00 mov %eax,0x8c(%esi) +801029d5: eb 93 jmp 8010296a +801029d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801029de: 66 90 xchg %ax,%ax + if ((addr = ip->addrs[bn]) == 0) { +801029e0: 8d 5a 14 lea 0x14(%edx),%ebx +801029e3: 8b 7c 98 0c mov 0xc(%eax,%ebx,4),%edi +801029e7: 85 ff test %edi,%edi +801029e9: 75 a5 jne 80102990 + ip->addrs[bn] = addr = balloc(ip->dev); +801029eb: 8b 00 mov (%eax),%eax +801029ed: e8 3e fd ff ff call 80102730 +801029f2: 89 44 9e 0c mov %eax,0xc(%esi,%ebx,4) +801029f6: 89 c7 mov %eax,%edi +} +801029f8: 8d 65 f4 lea -0xc(%ebp),%esp +801029fb: 5b pop %ebx +801029fc: 89 f8 mov %edi,%eax +801029fe: 5e pop %esi +801029ff: 5f pop %edi +80102a00: 5d pop %ebp +80102a01: c3 ret + panic("bmap: out of range"); +80102a02: 83 ec 0c sub $0xc,%esp +80102a05: 68 18 8b 10 80 push $0x80108b18 +80102a0a: e8 71 da ff ff call 80100480 +80102a0f: 90 nop + +80102a10 : +void readsb(int dev, struct superblock *sb) { +80102a10: 55 push %ebp +80102a11: 89 e5 mov %esp,%ebp +80102a13: 56 push %esi +80102a14: 53 push %ebx +80102a15: 8b 75 0c mov 0xc(%ebp),%esi + bp = bread(dev, 1); +80102a18: 83 ec 08 sub $0x8,%esp +80102a1b: 6a 01 push $0x1 +80102a1d: ff 75 08 push 0x8(%ebp) +80102a20: e8 ab d6 ff ff call 801000d0 + memmove(sb, bp->data, sizeof(*sb)); +80102a25: 83 c4 0c add $0xc,%esp + bp = bread(dev, 1); +80102a28: 89 c3 mov %eax,%ebx + memmove(sb, bp->data, sizeof(*sb)); +80102a2a: 8d 40 5c lea 0x5c(%eax),%eax +80102a2d: 6a 1c push $0x1c +80102a2f: 50 push %eax +80102a30: 56 push %esi +80102a31: e8 aa 32 00 00 call 80105ce0 + brelse(bp); +80102a36: 89 5d 08 mov %ebx,0x8(%ebp) +80102a39: 83 c4 10 add $0x10,%esp +} +80102a3c: 8d 65 f8 lea -0x8(%ebp),%esp +80102a3f: 5b pop %ebx +80102a40: 5e pop %esi +80102a41: 5d pop %ebp + brelse(bp); +80102a42: e9 a9 d7 ff ff jmp 801001f0 +80102a47: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102a4e: 66 90 xchg %ax,%ax + +80102a50 : +void iinit(int dev) { +80102a50: 55 push %ebp +80102a51: 89 e5 mov %esp,%ebp +80102a53: 53 push %ebx +80102a54: bb 20 c1 11 80 mov $0x8011c120,%ebx +80102a59: 83 ec 0c sub $0xc,%esp + initlock(&icache.lock, "icache"); +80102a5c: 68 2b 8b 10 80 push $0x80108b2b +80102a61: 68 e0 c0 11 80 push $0x8011c0e0 +80102a66: e8 45 2f 00 00 call 801059b0 + for (i = 0; i < NINODE; i++) { +80102a6b: 83 c4 10 add $0x10,%esp +80102a6e: 66 90 xchg %ax,%ax + initsleeplock(&icache.inode[i].lock, "inode"); +80102a70: 83 ec 08 sub $0x8,%esp +80102a73: 68 32 8b 10 80 push $0x80108b32 +80102a78: 53 push %ebx + for (i = 0; i < NINODE; i++) { +80102a79: 81 c3 90 00 00 00 add $0x90,%ebx + initsleeplock(&icache.inode[i].lock, "inode"); +80102a7f: e8 fc 2d 00 00 call 80105880 + for (i = 0; i < NINODE; i++) { +80102a84: 83 c4 10 add $0x10,%esp +80102a87: 81 fb 40 dd 11 80 cmp $0x8011dd40,%ebx +80102a8d: 75 e1 jne 80102a70 + bp = bread(dev, 1); +80102a8f: 83 ec 08 sub $0x8,%esp +80102a92: 6a 01 push $0x1 +80102a94: ff 75 08 push 0x8(%ebp) +80102a97: e8 34 d6 ff ff call 801000d0 + memmove(sb, bp->data, sizeof(*sb)); +80102a9c: 83 c4 0c add $0xc,%esp + bp = bread(dev, 1); +80102a9f: 89 c3 mov %eax,%ebx + memmove(sb, bp->data, sizeof(*sb)); +80102aa1: 8d 40 5c lea 0x5c(%eax),%eax +80102aa4: 6a 1c push $0x1c +80102aa6: 50 push %eax +80102aa7: 68 34 dd 11 80 push $0x8011dd34 +80102aac: e8 2f 32 00 00 call 80105ce0 + brelse(bp); +80102ab1: 89 1c 24 mov %ebx,(%esp) +80102ab4: e8 37 d7 ff ff call 801001f0 + cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ +80102ab9: ff 35 4c dd 11 80 push 0x8011dd4c +80102abf: ff 35 48 dd 11 80 push 0x8011dd48 +80102ac5: ff 35 44 dd 11 80 push 0x8011dd44 +80102acb: ff 35 40 dd 11 80 push 0x8011dd40 +80102ad1: ff 35 3c dd 11 80 push 0x8011dd3c +80102ad7: ff 35 38 dd 11 80 push 0x8011dd38 +80102add: ff 35 34 dd 11 80 push 0x8011dd34 +80102ae3: 68 98 8b 10 80 push $0x80108b98 +80102ae8: e8 a3 dd ff ff call 80100890 +} +80102aed: 8b 5d fc mov -0x4(%ebp),%ebx +80102af0: 83 c4 30 add $0x30,%esp +80102af3: c9 leave +80102af4: c3 ret +80102af5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102afc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80102b00 : +struct inode* ialloc(uint dev, short type) { +80102b00: 55 push %ebp +80102b01: 89 e5 mov %esp,%ebp +80102b03: 57 push %edi +80102b04: 56 push %esi +80102b05: 53 push %ebx +80102b06: 83 ec 1c sub $0x1c,%esp +80102b09: 8b 45 0c mov 0xc(%ebp),%eax + for (inum = 1; inum < sb.ninodes; inum++) { +80102b0c: 83 3d 3c dd 11 80 01 cmpl $0x1,0x8011dd3c +struct inode* ialloc(uint dev, short type) { +80102b13: 8b 75 08 mov 0x8(%ebp),%esi +80102b16: 89 45 e4 mov %eax,-0x1c(%ebp) + for (inum = 1; inum < sb.ninodes; inum++) { +80102b19: 0f 86 91 00 00 00 jbe 80102bb0 +80102b1f: bf 01 00 00 00 mov $0x1,%edi +80102b24: eb 21 jmp 80102b47 +80102b26: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102b2d: 8d 76 00 lea 0x0(%esi),%esi + brelse(bp); +80102b30: 83 ec 0c sub $0xc,%esp + for (inum = 1; inum < sb.ninodes; inum++) { +80102b33: 83 c7 01 add $0x1,%edi + brelse(bp); +80102b36: 53 push %ebx +80102b37: e8 b4 d6 ff ff call 801001f0 + for (inum = 1; inum < sb.ninodes; inum++) { +80102b3c: 83 c4 10 add $0x10,%esp +80102b3f: 3b 3d 3c dd 11 80 cmp 0x8011dd3c,%edi +80102b45: 73 69 jae 80102bb0 + bp = bread(dev, IBLOCK(inum, sb)); +80102b47: 89 f8 mov %edi,%eax +80102b49: 83 ec 08 sub $0x8,%esp +80102b4c: c1 e8 03 shr $0x3,%eax +80102b4f: 03 05 48 dd 11 80 add 0x8011dd48,%eax +80102b55: 50 push %eax +80102b56: 56 push %esi +80102b57: e8 74 d5 ff ff call 801000d0 + if (dip->type == 0) { // a free inode +80102b5c: 83 c4 10 add $0x10,%esp + bp = bread(dev, IBLOCK(inum, sb)); +80102b5f: 89 c3 mov %eax,%ebx + dip = (struct dinode*)bp->data + inum % IPB; +80102b61: 89 f8 mov %edi,%eax +80102b63: 83 e0 07 and $0x7,%eax +80102b66: c1 e0 06 shl $0x6,%eax +80102b69: 8d 4c 03 5c lea 0x5c(%ebx,%eax,1),%ecx + if (dip->type == 0) { // a free inode +80102b6d: 66 83 39 00 cmpw $0x0,(%ecx) +80102b71: 75 bd jne 80102b30 + memset(dip, 0, sizeof(*dip)); +80102b73: 83 ec 04 sub $0x4,%esp +80102b76: 89 4d e0 mov %ecx,-0x20(%ebp) +80102b79: 6a 40 push $0x40 +80102b7b: 6a 00 push $0x0 +80102b7d: 51 push %ecx +80102b7e: e8 bd 30 00 00 call 80105c40 + dip->type = type; +80102b83: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax +80102b87: 8b 4d e0 mov -0x20(%ebp),%ecx +80102b8a: 66 89 01 mov %ax,(%ecx) + log_write(bp); // mark it allocated on the disk +80102b8d: 89 1c 24 mov %ebx,(%esp) +80102b90: e8 9b 18 00 00 call 80104430 + brelse(bp); +80102b95: 89 1c 24 mov %ebx,(%esp) +80102b98: e8 53 d6 ff ff call 801001f0 + return iget(dev, inum); +80102b9d: 83 c4 10 add $0x10,%esp +} +80102ba0: 8d 65 f4 lea -0xc(%ebp),%esp + return iget(dev, inum); +80102ba3: 89 fa mov %edi,%edx +} +80102ba5: 5b pop %ebx + return iget(dev, inum); +80102ba6: 89 f0 mov %esi,%eax +} +80102ba8: 5e pop %esi +80102ba9: 5f pop %edi +80102baa: 5d pop %ebp + return iget(dev, inum); +80102bab: e9 90 fc ff ff jmp 80102840 + panic("ialloc: no inodes"); +80102bb0: 83 ec 0c sub $0xc,%esp +80102bb3: 68 38 8b 10 80 push $0x80108b38 +80102bb8: e8 c3 d8 ff ff call 80100480 +80102bbd: 8d 76 00 lea 0x0(%esi),%esi + +80102bc0 : +void iupdate(struct inode *ip) { +80102bc0: 55 push %ebp +80102bc1: 89 e5 mov %esp,%ebp +80102bc3: 56 push %esi +80102bc4: 53 push %ebx +80102bc5: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80102bc8: 8b 43 04 mov 0x4(%ebx),%eax + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +80102bcb: 83 c3 5c add $0x5c,%ebx + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80102bce: 83 ec 08 sub $0x8,%esp +80102bd1: c1 e8 03 shr $0x3,%eax +80102bd4: 03 05 48 dd 11 80 add 0x8011dd48,%eax +80102bda: 50 push %eax +80102bdb: ff 73 a4 push -0x5c(%ebx) +80102bde: e8 ed d4 ff ff call 801000d0 + dip->type = ip->type; +80102be3: 0f b7 53 f4 movzwl -0xc(%ebx),%edx + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +80102be7: 83 c4 0c add $0xc,%esp + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80102bea: 89 c6 mov %eax,%esi + dip = (struct dinode*)bp->data + ip->inum % IPB; +80102bec: 8b 43 a8 mov -0x58(%ebx),%eax +80102bef: 83 e0 07 and $0x7,%eax +80102bf2: c1 e0 06 shl $0x6,%eax +80102bf5: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax + dip->type = ip->type; +80102bf9: 66 89 10 mov %dx,(%eax) + dip->major = ip->major; +80102bfc: 0f b7 53 f6 movzwl -0xa(%ebx),%edx + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +80102c00: 83 c0 0c add $0xc,%eax + dip->major = ip->major; +80102c03: 66 89 50 f6 mov %dx,-0xa(%eax) + dip->minor = ip->minor; +80102c07: 0f b7 53 f8 movzwl -0x8(%ebx),%edx +80102c0b: 66 89 50 f8 mov %dx,-0x8(%eax) + dip->nlink = ip->nlink; +80102c0f: 0f b7 53 fa movzwl -0x6(%ebx),%edx +80102c13: 66 89 50 fa mov %dx,-0x6(%eax) + dip->size = ip->size; +80102c17: 8b 53 fc mov -0x4(%ebx),%edx +80102c1a: 89 50 fc mov %edx,-0x4(%eax) + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +80102c1d: 6a 34 push $0x34 +80102c1f: 53 push %ebx +80102c20: 50 push %eax +80102c21: e8 ba 30 00 00 call 80105ce0 + log_write(bp); +80102c26: 89 34 24 mov %esi,(%esp) +80102c29: e8 02 18 00 00 call 80104430 + brelse(bp); +80102c2e: 89 75 08 mov %esi,0x8(%ebp) +80102c31: 83 c4 10 add $0x10,%esp +} +80102c34: 8d 65 f8 lea -0x8(%ebp),%esp +80102c37: 5b pop %ebx +80102c38: 5e pop %esi +80102c39: 5d pop %ebp + brelse(bp); +80102c3a: e9 b1 d5 ff ff jmp 801001f0 +80102c3f: 90 nop + +80102c40 : +struct inode* idup(struct inode *ip) { +80102c40: 55 push %ebp +80102c41: 89 e5 mov %esp,%ebp +80102c43: 53 push %ebx +80102c44: 83 ec 10 sub $0x10,%esp +80102c47: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&icache.lock); +80102c4a: 68 e0 c0 11 80 push $0x8011c0e0 +80102c4f: e8 2c 2f 00 00 call 80105b80 + ip->ref++; +80102c54: 83 43 08 01 addl $0x1,0x8(%ebx) + release(&icache.lock); +80102c58: c7 04 24 e0 c0 11 80 movl $0x8011c0e0,(%esp) +80102c5f: e8 bc 2e 00 00 call 80105b20 +} +80102c64: 89 d8 mov %ebx,%eax +80102c66: 8b 5d fc mov -0x4(%ebp),%ebx +80102c69: c9 leave +80102c6a: c3 ret +80102c6b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102c6f: 90 nop + +80102c70 : +void ilock(struct inode *ip) { +80102c70: 55 push %ebp +80102c71: 89 e5 mov %esp,%ebp +80102c73: 56 push %esi +80102c74: 53 push %ebx +80102c75: 8b 5d 08 mov 0x8(%ebp),%ebx + if (ip == 0 || ip->ref < 1) { +80102c78: 85 db test %ebx,%ebx +80102c7a: 0f 84 b7 00 00 00 je 80102d37 +80102c80: 8b 53 08 mov 0x8(%ebx),%edx +80102c83: 85 d2 test %edx,%edx +80102c85: 0f 8e ac 00 00 00 jle 80102d37 + acquiresleep(&ip->lock); +80102c8b: 83 ec 0c sub $0xc,%esp +80102c8e: 8d 43 0c lea 0xc(%ebx),%eax +80102c91: 50 push %eax +80102c92: e8 29 2c 00 00 call 801058c0 + if (ip->valid == 0) { +80102c97: 8b 43 4c mov 0x4c(%ebx),%eax +80102c9a: 83 c4 10 add $0x10,%esp +80102c9d: 85 c0 test %eax,%eax +80102c9f: 74 0f je 80102cb0 +} +80102ca1: 8d 65 f8 lea -0x8(%ebp),%esp +80102ca4: 5b pop %ebx +80102ca5: 5e pop %esi +80102ca6: 5d pop %ebp +80102ca7: c3 ret +80102ca8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102caf: 90 nop + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80102cb0: 8b 43 04 mov 0x4(%ebx),%eax +80102cb3: 83 ec 08 sub $0x8,%esp +80102cb6: c1 e8 03 shr $0x3,%eax +80102cb9: 03 05 48 dd 11 80 add 0x8011dd48,%eax +80102cbf: 50 push %eax +80102cc0: ff 33 push (%ebx) +80102cc2: e8 09 d4 ff ff call 801000d0 + memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); +80102cc7: 83 c4 0c add $0xc,%esp + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80102cca: 89 c6 mov %eax,%esi + dip = (struct dinode*)bp->data + ip->inum % IPB; +80102ccc: 8b 43 04 mov 0x4(%ebx),%eax +80102ccf: 83 e0 07 and $0x7,%eax +80102cd2: c1 e0 06 shl $0x6,%eax +80102cd5: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax + ip->type = dip->type; +80102cd9: 0f b7 10 movzwl (%eax),%edx + memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); +80102cdc: 83 c0 0c add $0xc,%eax + ip->type = dip->type; +80102cdf: 66 89 53 50 mov %dx,0x50(%ebx) + ip->major = dip->major; +80102ce3: 0f b7 50 f6 movzwl -0xa(%eax),%edx +80102ce7: 66 89 53 52 mov %dx,0x52(%ebx) + ip->minor = dip->minor; +80102ceb: 0f b7 50 f8 movzwl -0x8(%eax),%edx +80102cef: 66 89 53 54 mov %dx,0x54(%ebx) + ip->nlink = dip->nlink; +80102cf3: 0f b7 50 fa movzwl -0x6(%eax),%edx +80102cf7: 66 89 53 56 mov %dx,0x56(%ebx) + ip->size = dip->size; +80102cfb: 8b 50 fc mov -0x4(%eax),%edx +80102cfe: 89 53 58 mov %edx,0x58(%ebx) + memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); +80102d01: 6a 34 push $0x34 +80102d03: 50 push %eax +80102d04: 8d 43 5c lea 0x5c(%ebx),%eax +80102d07: 50 push %eax +80102d08: e8 d3 2f 00 00 call 80105ce0 + brelse(bp); +80102d0d: 89 34 24 mov %esi,(%esp) +80102d10: e8 db d4 ff ff call 801001f0 + if (ip->type == 0) { +80102d15: 83 c4 10 add $0x10,%esp +80102d18: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) + ip->valid = 1; +80102d1d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) + if (ip->type == 0) { +80102d24: 0f 85 77 ff ff ff jne 80102ca1 + panic("ilock: no type"); +80102d2a: 83 ec 0c sub $0xc,%esp +80102d2d: 68 50 8b 10 80 push $0x80108b50 +80102d32: e8 49 d7 ff ff call 80100480 + panic("ilock"); +80102d37: 83 ec 0c sub $0xc,%esp +80102d3a: 68 4a 8b 10 80 push $0x80108b4a +80102d3f: e8 3c d7 ff ff call 80100480 +80102d44: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102d4b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102d4f: 90 nop + +80102d50 : +void iunlock(struct inode *ip) { +80102d50: 55 push %ebp +80102d51: 89 e5 mov %esp,%ebp +80102d53: 56 push %esi +80102d54: 53 push %ebx +80102d55: 8b 5d 08 mov 0x8(%ebp),%ebx + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80102d58: 85 db test %ebx,%ebx +80102d5a: 74 28 je 80102d84 +80102d5c: 83 ec 0c sub $0xc,%esp +80102d5f: 8d 73 0c lea 0xc(%ebx),%esi +80102d62: 56 push %esi +80102d63: e8 f8 2b 00 00 call 80105960 +80102d68: 83 c4 10 add $0x10,%esp +80102d6b: 85 c0 test %eax,%eax +80102d6d: 74 15 je 80102d84 +80102d6f: 8b 43 08 mov 0x8(%ebx),%eax +80102d72: 85 c0 test %eax,%eax +80102d74: 7e 0e jle 80102d84 + releasesleep(&ip->lock); +80102d76: 89 75 08 mov %esi,0x8(%ebp) +} +80102d79: 8d 65 f8 lea -0x8(%ebp),%esp +80102d7c: 5b pop %ebx +80102d7d: 5e pop %esi +80102d7e: 5d pop %ebp + releasesleep(&ip->lock); +80102d7f: e9 9c 2b 00 00 jmp 80105920 + panic("iunlock"); +80102d84: 83 ec 0c sub $0xc,%esp +80102d87: 68 5f 8b 10 80 push $0x80108b5f +80102d8c: e8 ef d6 ff ff call 80100480 +80102d91: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102d98: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102d9f: 90 nop + +80102da0 : +void iput(struct inode *ip) { +80102da0: 55 push %ebp +80102da1: 89 e5 mov %esp,%ebp +80102da3: 57 push %edi +80102da4: 56 push %esi +80102da5: 53 push %ebx +80102da6: 83 ec 28 sub $0x28,%esp +80102da9: 8b 5d 08 mov 0x8(%ebp),%ebx + acquiresleep(&ip->lock); +80102dac: 8d 7b 0c lea 0xc(%ebx),%edi +80102daf: 57 push %edi +80102db0: e8 0b 2b 00 00 call 801058c0 + if (ip->valid && ip->nlink == 0) { +80102db5: 8b 53 4c mov 0x4c(%ebx),%edx +80102db8: 83 c4 10 add $0x10,%esp +80102dbb: 85 d2 test %edx,%edx +80102dbd: 74 07 je 80102dc6 +80102dbf: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) +80102dc4: 74 32 je 80102df8 + releasesleep(&ip->lock); +80102dc6: 83 ec 0c sub $0xc,%esp +80102dc9: 57 push %edi +80102dca: e8 51 2b 00 00 call 80105920 + acquire(&icache.lock); +80102dcf: c7 04 24 e0 c0 11 80 movl $0x8011c0e0,(%esp) +80102dd6: e8 a5 2d 00 00 call 80105b80 + ip->ref--; +80102ddb: 83 6b 08 01 subl $0x1,0x8(%ebx) + release(&icache.lock); +80102ddf: 83 c4 10 add $0x10,%esp +80102de2: c7 45 08 e0 c0 11 80 movl $0x8011c0e0,0x8(%ebp) +} +80102de9: 8d 65 f4 lea -0xc(%ebp),%esp +80102dec: 5b pop %ebx +80102ded: 5e pop %esi +80102dee: 5f pop %edi +80102def: 5d pop %ebp + release(&icache.lock); +80102df0: e9 2b 2d 00 00 jmp 80105b20 +80102df5: 8d 76 00 lea 0x0(%esi),%esi + acquire(&icache.lock); +80102df8: 83 ec 0c sub $0xc,%esp +80102dfb: 68 e0 c0 11 80 push $0x8011c0e0 +80102e00: e8 7b 2d 00 00 call 80105b80 + int r = ip->ref; +80102e05: 8b 73 08 mov 0x8(%ebx),%esi + release(&icache.lock); +80102e08: c7 04 24 e0 c0 11 80 movl $0x8011c0e0,(%esp) +80102e0f: e8 0c 2d 00 00 call 80105b20 + if (r == 1) { +80102e14: 83 c4 10 add $0x10,%esp +80102e17: 83 fe 01 cmp $0x1,%esi +80102e1a: 75 aa jne 80102dc6 +80102e1c: 8d 8b 8c 00 00 00 lea 0x8c(%ebx),%ecx +80102e22: 89 7d e4 mov %edi,-0x1c(%ebp) +80102e25: 8d 73 5c lea 0x5c(%ebx),%esi +80102e28: 89 cf mov %ecx,%edi +80102e2a: eb 0b jmp 80102e37 +80102e2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +static void itrunc(struct inode *ip) { + int i, j; + struct buf *bp; + uint *a; + + for (i = 0; i < NDIRECT; i++) { +80102e30: 83 c6 04 add $0x4,%esi +80102e33: 39 fe cmp %edi,%esi +80102e35: 74 19 je 80102e50 + if (ip->addrs[i]) { +80102e37: 8b 16 mov (%esi),%edx +80102e39: 85 d2 test %edx,%edx +80102e3b: 74 f3 je 80102e30 + bfree(ip->dev, ip->addrs[i]); +80102e3d: 8b 03 mov (%ebx),%eax +80102e3f: e8 6c f8 ff ff call 801026b0 + ip->addrs[i] = 0; +80102e44: c7 06 00 00 00 00 movl $0x0,(%esi) +80102e4a: eb e4 jmp 80102e30 +80102e4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } + + if (ip->addrs[NDIRECT]) { +80102e50: 8b 83 8c 00 00 00 mov 0x8c(%ebx),%eax +80102e56: 8b 7d e4 mov -0x1c(%ebp),%edi +80102e59: 85 c0 test %eax,%eax +80102e5b: 75 2d jne 80102e8a + bfree(ip->dev, ip->addrs[NDIRECT]); + ip->addrs[NDIRECT] = 0; + } + + ip->size = 0; + iupdate(ip); +80102e5d: 83 ec 0c sub $0xc,%esp + ip->size = 0; +80102e60: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) + iupdate(ip); +80102e67: 53 push %ebx +80102e68: e8 53 fd ff ff call 80102bc0 + ip->type = 0; +80102e6d: 31 c0 xor %eax,%eax +80102e6f: 66 89 43 50 mov %ax,0x50(%ebx) + iupdate(ip); +80102e73: 89 1c 24 mov %ebx,(%esp) +80102e76: e8 45 fd ff ff call 80102bc0 + ip->valid = 0; +80102e7b: c7 43 4c 00 00 00 00 movl $0x0,0x4c(%ebx) +80102e82: 83 c4 10 add $0x10,%esp +80102e85: e9 3c ff ff ff jmp 80102dc6 + bp = bread(ip->dev, ip->addrs[NDIRECT]); +80102e8a: 83 ec 08 sub $0x8,%esp +80102e8d: 50 push %eax +80102e8e: ff 33 push (%ebx) +80102e90: e8 3b d2 ff ff call 801000d0 +80102e95: 89 7d e0 mov %edi,-0x20(%ebp) +80102e98: 83 c4 10 add $0x10,%esp +80102e9b: 8d 88 5c 02 00 00 lea 0x25c(%eax),%ecx +80102ea1: 89 45 e4 mov %eax,-0x1c(%ebp) + for (j = 0; j < NINDIRECT; j++) { +80102ea4: 8d 70 5c lea 0x5c(%eax),%esi +80102ea7: 89 cf mov %ecx,%edi +80102ea9: eb 0c jmp 80102eb7 +80102eab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102eaf: 90 nop +80102eb0: 83 c6 04 add $0x4,%esi +80102eb3: 39 f7 cmp %esi,%edi +80102eb5: 74 0f je 80102ec6 + if (a[j]) { +80102eb7: 8b 16 mov (%esi),%edx +80102eb9: 85 d2 test %edx,%edx +80102ebb: 74 f3 je 80102eb0 + bfree(ip->dev, a[j]); +80102ebd: 8b 03 mov (%ebx),%eax +80102ebf: e8 ec f7 ff ff call 801026b0 +80102ec4: eb ea jmp 80102eb0 + brelse(bp); +80102ec6: 83 ec 0c sub $0xc,%esp +80102ec9: ff 75 e4 push -0x1c(%ebp) +80102ecc: 8b 7d e0 mov -0x20(%ebp),%edi +80102ecf: e8 1c d3 ff ff call 801001f0 + bfree(ip->dev, ip->addrs[NDIRECT]); +80102ed4: 8b 93 8c 00 00 00 mov 0x8c(%ebx),%edx +80102eda: 8b 03 mov (%ebx),%eax +80102edc: e8 cf f7 ff ff call 801026b0 + ip->addrs[NDIRECT] = 0; +80102ee1: 83 c4 10 add $0x10,%esp +80102ee4: c7 83 8c 00 00 00 00 movl $0x0,0x8c(%ebx) +80102eeb: 00 00 00 +80102eee: e9 6a ff ff ff jmp 80102e5d +80102ef3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102efa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80102f00 : +void iunlockput(struct inode *ip) { +80102f00: 55 push %ebp +80102f01: 89 e5 mov %esp,%ebp +80102f03: 56 push %esi +80102f04: 53 push %ebx +80102f05: 8b 5d 08 mov 0x8(%ebp),%ebx + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80102f08: 85 db test %ebx,%ebx +80102f0a: 74 34 je 80102f40 +80102f0c: 83 ec 0c sub $0xc,%esp +80102f0f: 8d 73 0c lea 0xc(%ebx),%esi +80102f12: 56 push %esi +80102f13: e8 48 2a 00 00 call 80105960 +80102f18: 83 c4 10 add $0x10,%esp +80102f1b: 85 c0 test %eax,%eax +80102f1d: 74 21 je 80102f40 +80102f1f: 8b 43 08 mov 0x8(%ebx),%eax +80102f22: 85 c0 test %eax,%eax +80102f24: 7e 1a jle 80102f40 + releasesleep(&ip->lock); +80102f26: 83 ec 0c sub $0xc,%esp +80102f29: 56 push %esi +80102f2a: e8 f1 29 00 00 call 80105920 + iput(ip); +80102f2f: 89 5d 08 mov %ebx,0x8(%ebp) +80102f32: 83 c4 10 add $0x10,%esp +} +80102f35: 8d 65 f8 lea -0x8(%ebp),%esp +80102f38: 5b pop %ebx +80102f39: 5e pop %esi +80102f3a: 5d pop %ebp + iput(ip); +80102f3b: e9 60 fe ff ff jmp 80102da0 + panic("iunlock"); +80102f40: 83 ec 0c sub $0xc,%esp +80102f43: 68 5f 8b 10 80 push $0x80108b5f +80102f48: e8 33 d5 ff ff call 80100480 +80102f4d: 8d 76 00 lea 0x0(%esi),%esi + +80102f50 : +} + +// Copy stat information from inode. +// Caller must hold ip->lock. +void stati(struct inode *ip, struct stat *st) { +80102f50: 55 push %ebp +80102f51: 89 e5 mov %esp,%ebp +80102f53: 8b 55 08 mov 0x8(%ebp),%edx +80102f56: 8b 45 0c mov 0xc(%ebp),%eax + st->dev = ip->dev; +80102f59: 8b 0a mov (%edx),%ecx +80102f5b: 89 48 04 mov %ecx,0x4(%eax) + st->ino = ip->inum; +80102f5e: 8b 4a 04 mov 0x4(%edx),%ecx +80102f61: 89 48 08 mov %ecx,0x8(%eax) + st->type = ip->type; +80102f64: 0f b7 4a 50 movzwl 0x50(%edx),%ecx +80102f68: 66 89 08 mov %cx,(%eax) + st->nlink = ip->nlink; +80102f6b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx +80102f6f: 66 89 48 0c mov %cx,0xc(%eax) + st->size = ip->size; +80102f73: 8b 52 58 mov 0x58(%edx),%edx +80102f76: 89 50 10 mov %edx,0x10(%eax) +} +80102f79: 5d pop %ebp +80102f7a: c3 ret +80102f7b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102f7f: 90 nop + +80102f80 : + + +// Read data from inode. +// Caller must hold ip->lock. +int readi(struct inode *ip, char *dst, uint off, uint n) { +80102f80: 55 push %ebp +80102f81: 89 e5 mov %esp,%ebp +80102f83: 57 push %edi +80102f84: 56 push %esi +80102f85: 53 push %ebx +80102f86: 83 ec 1c sub $0x1c,%esp +80102f89: 8b 7d 0c mov 0xc(%ebp),%edi +80102f8c: 8b 45 08 mov 0x8(%ebp),%eax +80102f8f: 8b 75 10 mov 0x10(%ebp),%esi +80102f92: 89 7d e0 mov %edi,-0x20(%ebp) +80102f95: 8b 7d 14 mov 0x14(%ebp),%edi + uint tot, m; + struct buf *bp; + + if (ip->type == T_DEV) { +80102f98: 66 83 78 50 03 cmpw $0x3,0x50(%eax) +int readi(struct inode *ip, char *dst, uint off, uint n) { +80102f9d: 89 45 d8 mov %eax,-0x28(%ebp) +80102fa0: 89 7d e4 mov %edi,-0x1c(%ebp) + if (ip->type == T_DEV) { +80102fa3: 0f 84 a7 00 00 00 je 80103050 + return -1; + } + return devsw[ip->major].read(ip, dst, n); + } + + if (off > ip->size || off + n < off) { +80102fa9: 8b 45 d8 mov -0x28(%ebp),%eax +80102fac: 8b 40 58 mov 0x58(%eax),%eax +80102faf: 39 c6 cmp %eax,%esi +80102fb1: 0f 87 ba 00 00 00 ja 80103071 +80102fb7: 8b 5d e4 mov -0x1c(%ebp),%ebx +80102fba: 31 c9 xor %ecx,%ecx +80102fbc: 89 da mov %ebx,%edx +80102fbe: 01 f2 add %esi,%edx +80102fc0: 0f 92 c1 setb %cl +80102fc3: 89 cf mov %ecx,%edi +80102fc5: 0f 82 a6 00 00 00 jb 80103071 + return -1; + } + if (off + n > ip->size) { + n = ip->size - off; +80102fcb: 89 c1 mov %eax,%ecx +80102fcd: 29 f1 sub %esi,%ecx +80102fcf: 39 d0 cmp %edx,%eax +80102fd1: 0f 43 cb cmovae %ebx,%ecx +80102fd4: 89 4d e4 mov %ecx,-0x1c(%ebp) + } + + for (tot = 0; tot < n; tot += m, off += m, dst += m) { +80102fd7: 85 c9 test %ecx,%ecx +80102fd9: 74 67 je 80103042 +80102fdb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102fdf: 90 nop + bp = bread(ip->dev, bmap(ip, off / BSIZE)); +80102fe0: 8b 5d d8 mov -0x28(%ebp),%ebx +80102fe3: 89 f2 mov %esi,%edx +80102fe5: c1 ea 09 shr $0x9,%edx +80102fe8: 89 d8 mov %ebx,%eax +80102fea: e8 51 f9 ff ff call 80102940 +80102fef: 83 ec 08 sub $0x8,%esp +80102ff2: 50 push %eax +80102ff3: ff 33 push (%ebx) +80102ff5: e8 d6 d0 ff ff call 801000d0 + m = min(n - tot, BSIZE - off % BSIZE); +80102ffa: 8b 5d e4 mov -0x1c(%ebp),%ebx +80102ffd: b9 00 02 00 00 mov $0x200,%ecx + bp = bread(ip->dev, bmap(ip, off / BSIZE)); +80103002: 89 c2 mov %eax,%edx + m = min(n - tot, BSIZE - off % BSIZE); +80103004: 89 f0 mov %esi,%eax +80103006: 25 ff 01 00 00 and $0x1ff,%eax +8010300b: 29 fb sub %edi,%ebx + memmove(dst, bp->data + off % BSIZE, m); +8010300d: 89 55 dc mov %edx,-0x24(%ebp) + m = min(n - tot, BSIZE - off % BSIZE); +80103010: 29 c1 sub %eax,%ecx + memmove(dst, bp->data + off % BSIZE, m); +80103012: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax + m = min(n - tot, BSIZE - off % BSIZE); +80103016: 39 d9 cmp %ebx,%ecx +80103018: 0f 46 d9 cmovbe %ecx,%ebx + memmove(dst, bp->data + off % BSIZE, m); +8010301b: 83 c4 0c add $0xc,%esp +8010301e: 53 push %ebx + for (tot = 0; tot < n; tot += m, off += m, dst += m) { +8010301f: 01 df add %ebx,%edi +80103021: 01 de add %ebx,%esi + memmove(dst, bp->data + off % BSIZE, m); +80103023: 50 push %eax +80103024: ff 75 e0 push -0x20(%ebp) +80103027: e8 b4 2c 00 00 call 80105ce0 + brelse(bp); +8010302c: 8b 55 dc mov -0x24(%ebp),%edx +8010302f: 89 14 24 mov %edx,(%esp) +80103032: e8 b9 d1 ff ff call 801001f0 + for (tot = 0; tot < n; tot += m, off += m, dst += m) { +80103037: 01 5d e0 add %ebx,-0x20(%ebp) +8010303a: 83 c4 10 add $0x10,%esp +8010303d: 39 7d e4 cmp %edi,-0x1c(%ebp) +80103040: 77 9e ja 80102fe0 + } + return n; +80103042: 8b 45 e4 mov -0x1c(%ebp),%eax +} +80103045: 8d 65 f4 lea -0xc(%ebp),%esp +80103048: 5b pop %ebx +80103049: 5e pop %esi +8010304a: 5f pop %edi +8010304b: 5d pop %ebp +8010304c: c3 ret +8010304d: 8d 76 00 lea 0x0(%esi),%esi + if (ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) { +80103050: 0f bf 40 52 movswl 0x52(%eax),%eax +80103054: 66 83 f8 09 cmp $0x9,%ax +80103058: 77 17 ja 80103071 +8010305a: 8b 04 c5 80 c0 11 80 mov -0x7fee3f80(,%eax,8),%eax +80103061: 85 c0 test %eax,%eax +80103063: 74 0c je 80103071 + return devsw[ip->major].read(ip, dst, n); +80103065: 89 7d 10 mov %edi,0x10(%ebp) +} +80103068: 8d 65 f4 lea -0xc(%ebp),%esp +8010306b: 5b pop %ebx +8010306c: 5e pop %esi +8010306d: 5f pop %edi +8010306e: 5d pop %ebp + return devsw[ip->major].read(ip, dst, n); +8010306f: ff e0 jmp *%eax + return -1; +80103071: b8 ff ff ff ff mov $0xffffffff,%eax +80103076: eb cd jmp 80103045 +80103078: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010307f: 90 nop + +80103080 : + +// Write data to inode. +// Caller must hold ip->lock. +int writei(struct inode *ip, char *src, uint off, uint n) { +80103080: 55 push %ebp +80103081: 89 e5 mov %esp,%ebp +80103083: 57 push %edi +80103084: 56 push %esi +80103085: 53 push %ebx +80103086: 83 ec 1c sub $0x1c,%esp +80103089: 8b 45 08 mov 0x8(%ebp),%eax +8010308c: 8b 75 0c mov 0xc(%ebp),%esi +8010308f: 8b 55 14 mov 0x14(%ebp),%edx + uint tot, m; + struct buf *bp; + + if (ip->type == T_DEV) { +80103092: 66 83 78 50 03 cmpw $0x3,0x50(%eax) +int writei(struct inode *ip, char *src, uint off, uint n) { +80103097: 89 75 dc mov %esi,-0x24(%ebp) +8010309a: 89 45 d8 mov %eax,-0x28(%ebp) +8010309d: 8b 75 10 mov 0x10(%ebp),%esi +801030a0: 89 55 e0 mov %edx,-0x20(%ebp) + if (ip->type == T_DEV) { +801030a3: 0f 84 b7 00 00 00 je 80103160 + return -1; + } + return devsw[ip->major].write(ip, src, n); + } + + if (off > ip->size || off + n < off) { +801030a9: 8b 45 d8 mov -0x28(%ebp),%eax +801030ac: 3b 70 58 cmp 0x58(%eax),%esi +801030af: 0f 87 e7 00 00 00 ja 8010319c +801030b5: 8b 7d e0 mov -0x20(%ebp),%edi +801030b8: 31 d2 xor %edx,%edx +801030ba: 89 f8 mov %edi,%eax +801030bc: 01 f0 add %esi,%eax +801030be: 0f 92 c2 setb %dl + return -1; + } + if (off + n > MAXFILE * BSIZE) { +801030c1: 3d 00 18 01 00 cmp $0x11800,%eax +801030c6: 0f 87 d0 00 00 00 ja 8010319c +801030cc: 85 d2 test %edx,%edx +801030ce: 0f 85 c8 00 00 00 jne 8010319c + return -1; + } + + for (tot = 0; tot < n; tot += m, off += m, src += m) { +801030d4: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +801030db: 85 ff test %edi,%edi +801030dd: 74 72 je 80103151 +801030df: 90 nop + bp = bread(ip->dev, bmap(ip, off / BSIZE)); +801030e0: 8b 7d d8 mov -0x28(%ebp),%edi +801030e3: 89 f2 mov %esi,%edx +801030e5: c1 ea 09 shr $0x9,%edx +801030e8: 89 f8 mov %edi,%eax +801030ea: e8 51 f8 ff ff call 80102940 +801030ef: 83 ec 08 sub $0x8,%esp +801030f2: 50 push %eax +801030f3: ff 37 push (%edi) +801030f5: e8 d6 cf ff ff call 801000d0 + m = min(n - tot, BSIZE - off % BSIZE); +801030fa: b9 00 02 00 00 mov $0x200,%ecx +801030ff: 8b 5d e0 mov -0x20(%ebp),%ebx +80103102: 2b 5d e4 sub -0x1c(%ebp),%ebx + bp = bread(ip->dev, bmap(ip, off / BSIZE)); +80103105: 89 c7 mov %eax,%edi + m = min(n - tot, BSIZE - off % BSIZE); +80103107: 89 f0 mov %esi,%eax +80103109: 25 ff 01 00 00 and $0x1ff,%eax +8010310e: 29 c1 sub %eax,%ecx + memmove(bp->data + off % BSIZE, src, m); +80103110: 8d 44 07 5c lea 0x5c(%edi,%eax,1),%eax + m = min(n - tot, BSIZE - off % BSIZE); +80103114: 39 d9 cmp %ebx,%ecx +80103116: 0f 46 d9 cmovbe %ecx,%ebx + memmove(bp->data + off % BSIZE, src, m); +80103119: 83 c4 0c add $0xc,%esp +8010311c: 53 push %ebx + for (tot = 0; tot < n; tot += m, off += m, src += m) { +8010311d: 01 de add %ebx,%esi + memmove(bp->data + off % BSIZE, src, m); +8010311f: ff 75 dc push -0x24(%ebp) +80103122: 50 push %eax +80103123: e8 b8 2b 00 00 call 80105ce0 + log_write(bp); +80103128: 89 3c 24 mov %edi,(%esp) +8010312b: e8 00 13 00 00 call 80104430 + brelse(bp); +80103130: 89 3c 24 mov %edi,(%esp) +80103133: e8 b8 d0 ff ff call 801001f0 + for (tot = 0; tot < n; tot += m, off += m, src += m) { +80103138: 01 5d e4 add %ebx,-0x1c(%ebp) +8010313b: 83 c4 10 add $0x10,%esp +8010313e: 8b 45 e4 mov -0x1c(%ebp),%eax +80103141: 01 5d dc add %ebx,-0x24(%ebp) +80103144: 39 45 e0 cmp %eax,-0x20(%ebp) +80103147: 77 97 ja 801030e0 + } + + if (n > 0 && off > ip->size) { +80103149: 8b 45 d8 mov -0x28(%ebp),%eax +8010314c: 3b 70 58 cmp 0x58(%eax),%esi +8010314f: 77 37 ja 80103188 + ip->size = off; + iupdate(ip); + } + return n; +80103151: 8b 45 e0 mov -0x20(%ebp),%eax +} +80103154: 8d 65 f4 lea -0xc(%ebp),%esp +80103157: 5b pop %ebx +80103158: 5e pop %esi +80103159: 5f pop %edi +8010315a: 5d pop %ebp +8010315b: c3 ret +8010315c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) { +80103160: 0f bf 40 52 movswl 0x52(%eax),%eax +80103164: 66 83 f8 09 cmp $0x9,%ax +80103168: 77 32 ja 8010319c +8010316a: 8b 04 c5 84 c0 11 80 mov -0x7fee3f7c(,%eax,8),%eax +80103171: 85 c0 test %eax,%eax +80103173: 74 27 je 8010319c + return devsw[ip->major].write(ip, src, n); +80103175: 89 55 10 mov %edx,0x10(%ebp) +} +80103178: 8d 65 f4 lea -0xc(%ebp),%esp +8010317b: 5b pop %ebx +8010317c: 5e pop %esi +8010317d: 5f pop %edi +8010317e: 5d pop %ebp + return devsw[ip->major].write(ip, src, n); +8010317f: ff e0 jmp *%eax +80103181: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ip->size = off; +80103188: 8b 45 d8 mov -0x28(%ebp),%eax + iupdate(ip); +8010318b: 83 ec 0c sub $0xc,%esp + ip->size = off; +8010318e: 89 70 58 mov %esi,0x58(%eax) + iupdate(ip); +80103191: 50 push %eax +80103192: e8 29 fa ff ff call 80102bc0 +80103197: 83 c4 10 add $0x10,%esp +8010319a: eb b5 jmp 80103151 + return -1; +8010319c: b8 ff ff ff ff mov $0xffffffff,%eax +801031a1: eb b1 jmp 80103154 +801031a3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801031aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +801031b0 : + + +// Directories + +int namecmp(const char *s, const char *t) { +801031b0: 55 push %ebp +801031b1: 89 e5 mov %esp,%ebp +801031b3: 83 ec 0c sub $0xc,%esp + return strncmp(s, t, DIRSIZ); +801031b6: 6a 0e push $0xe +801031b8: ff 75 0c push 0xc(%ebp) +801031bb: ff 75 08 push 0x8(%ebp) +801031be: e8 8d 2b 00 00 call 80105d50 +} +801031c3: c9 leave +801031c4: c3 ret +801031c5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801031cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801031d0 : + +// Look for a directory entry in a directory. +// If found, set *poff to byte offset of entry. +struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { +801031d0: 55 push %ebp +801031d1: 89 e5 mov %esp,%ebp +801031d3: 57 push %edi +801031d4: 56 push %esi +801031d5: 53 push %ebx +801031d6: 83 ec 1c sub $0x1c,%esp +801031d9: 8b 5d 08 mov 0x8(%ebp),%ebx + uint off, inum; + struct dirent de; + + if (dp->type != T_DIR) { +801031dc: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +801031e1: 0f 85 85 00 00 00 jne 8010326c + panic("dirlookup not DIR"); + } + + for (off = 0; off < dp->size; off += sizeof(de)) { +801031e7: 8b 53 58 mov 0x58(%ebx),%edx +801031ea: 31 ff xor %edi,%edi +801031ec: 8d 75 d8 lea -0x28(%ebp),%esi +801031ef: 85 d2 test %edx,%edx +801031f1: 74 3e je 80103231 +801031f3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801031f7: 90 nop + if (readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +801031f8: 6a 10 push $0x10 +801031fa: 57 push %edi +801031fb: 56 push %esi +801031fc: 53 push %ebx +801031fd: e8 7e fd ff ff call 80102f80 +80103202: 83 c4 10 add $0x10,%esp +80103205: 83 f8 10 cmp $0x10,%eax +80103208: 75 55 jne 8010325f + panic("dirlookup read"); + } + if (de.inum == 0) { +8010320a: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) +8010320f: 74 18 je 80103229 + return strncmp(s, t, DIRSIZ); +80103211: 83 ec 04 sub $0x4,%esp +80103214: 8d 45 da lea -0x26(%ebp),%eax +80103217: 6a 0e push $0xe +80103219: 50 push %eax +8010321a: ff 75 0c push 0xc(%ebp) +8010321d: e8 2e 2b 00 00 call 80105d50 + continue; + } + if (namecmp(name, de.name) == 0) { +80103222: 83 c4 10 add $0x10,%esp +80103225: 85 c0 test %eax,%eax +80103227: 74 17 je 80103240 + for (off = 0; off < dp->size; off += sizeof(de)) { +80103229: 83 c7 10 add $0x10,%edi +8010322c: 3b 7b 58 cmp 0x58(%ebx),%edi +8010322f: 72 c7 jb 801031f8 + return iget(dp->dev, inum); + } + } + + return 0; +} +80103231: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; +80103234: 31 c0 xor %eax,%eax +} +80103236: 5b pop %ebx +80103237: 5e pop %esi +80103238: 5f pop %edi +80103239: 5d pop %ebp +8010323a: c3 ret +8010323b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010323f: 90 nop + if (poff) { +80103240: 8b 45 10 mov 0x10(%ebp),%eax +80103243: 85 c0 test %eax,%eax +80103245: 74 05 je 8010324c + *poff = off; +80103247: 8b 45 10 mov 0x10(%ebp),%eax +8010324a: 89 38 mov %edi,(%eax) + inum = de.inum; +8010324c: 0f b7 55 d8 movzwl -0x28(%ebp),%edx + return iget(dp->dev, inum); +80103250: 8b 03 mov (%ebx),%eax +80103252: e8 e9 f5 ff ff call 80102840 +} +80103257: 8d 65 f4 lea -0xc(%ebp),%esp +8010325a: 5b pop %ebx +8010325b: 5e pop %esi +8010325c: 5f pop %edi +8010325d: 5d pop %ebp +8010325e: c3 ret + panic("dirlookup read"); +8010325f: 83 ec 0c sub $0xc,%esp +80103262: 68 79 8b 10 80 push $0x80108b79 +80103267: e8 14 d2 ff ff call 80100480 + panic("dirlookup not DIR"); +8010326c: 83 ec 0c sub $0xc,%esp +8010326f: 68 67 8b 10 80 push $0x80108b67 +80103274: e8 07 d2 ff ff call 80100480 +80103279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80103280 : + +// Look up and return the inode for a path name. +// If parent != 0, return the inode for the parent and copy the final +// path element into name, which must have room for DIRSIZ bytes. +// Must be called inside a transaction since it calls iput(). +static struct inode* namex(char *path, int nameiparent, char *name) { +80103280: 55 push %ebp +80103281: 89 e5 mov %esp,%ebp +80103283: 57 push %edi +80103284: 56 push %esi +80103285: 53 push %ebx +80103286: 89 c3 mov %eax,%ebx +80103288: 83 ec 1c sub $0x1c,%esp + struct inode *ip, *next; + + if (*path == '/') { +8010328b: 80 38 2f cmpb $0x2f,(%eax) +static struct inode* namex(char *path, int nameiparent, char *name) { +8010328e: 89 55 dc mov %edx,-0x24(%ebp) +80103291: 89 4d e4 mov %ecx,-0x1c(%ebp) + if (*path == '/') { +80103294: 0f 84 64 01 00 00 je 801033fe + ip = iget(ROOTDEV, ROOTINO); + } + else { + ip = idup(myproc()->cwd); +8010329a: e8 11 1c 00 00 call 80104eb0 + acquire(&icache.lock); +8010329f: 83 ec 0c sub $0xc,%esp + ip = idup(myproc()->cwd); +801032a2: 8b 70 68 mov 0x68(%eax),%esi + acquire(&icache.lock); +801032a5: 68 e0 c0 11 80 push $0x8011c0e0 +801032aa: e8 d1 28 00 00 call 80105b80 + ip->ref++; +801032af: 83 46 08 01 addl $0x1,0x8(%esi) + release(&icache.lock); +801032b3: c7 04 24 e0 c0 11 80 movl $0x8011c0e0,(%esp) +801032ba: e8 61 28 00 00 call 80105b20 +801032bf: 83 c4 10 add $0x10,%esp +801032c2: eb 07 jmp 801032cb +801032c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + path++; +801032c8: 83 c3 01 add $0x1,%ebx + while (*path == '/') { +801032cb: 0f b6 03 movzbl (%ebx),%eax +801032ce: 3c 2f cmp $0x2f,%al +801032d0: 74 f6 je 801032c8 + if (*path == 0) { +801032d2: 84 c0 test %al,%al +801032d4: 0f 84 06 01 00 00 je 801033e0 + while (*path != '/' && *path != 0) { +801032da: 0f b6 03 movzbl (%ebx),%eax +801032dd: 84 c0 test %al,%al +801032df: 0f 84 10 01 00 00 je 801033f5 +801032e5: 89 df mov %ebx,%edi +801032e7: 3c 2f cmp $0x2f,%al +801032e9: 0f 84 06 01 00 00 je 801033f5 +801032ef: 90 nop +801032f0: 0f b6 47 01 movzbl 0x1(%edi),%eax + path++; +801032f4: 83 c7 01 add $0x1,%edi + while (*path != '/' && *path != 0) { +801032f7: 3c 2f cmp $0x2f,%al +801032f9: 74 04 je 801032ff +801032fb: 84 c0 test %al,%al +801032fd: 75 f1 jne 801032f0 + len = path - s; +801032ff: 89 f8 mov %edi,%eax +80103301: 29 d8 sub %ebx,%eax + if (len >= DIRSIZ) { +80103303: 83 f8 0d cmp $0xd,%eax +80103306: 0f 8e ac 00 00 00 jle 801033b8 + memmove(name, s, DIRSIZ); +8010330c: 83 ec 04 sub $0x4,%esp +8010330f: 6a 0e push $0xe +80103311: 53 push %ebx + path++; +80103312: 89 fb mov %edi,%ebx + memmove(name, s, DIRSIZ); +80103314: ff 75 e4 push -0x1c(%ebp) +80103317: e8 c4 29 00 00 call 80105ce0 +8010331c: 83 c4 10 add $0x10,%esp + while (*path == '/') { +8010331f: 80 3f 2f cmpb $0x2f,(%edi) +80103322: 75 0c jne 80103330 +80103324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + path++; +80103328: 83 c3 01 add $0x1,%ebx + while (*path == '/') { +8010332b: 80 3b 2f cmpb $0x2f,(%ebx) +8010332e: 74 f8 je 80103328 + } + + while ((path = skipelem(path, name)) != 0) { + ilock(ip); +80103330: 83 ec 0c sub $0xc,%esp +80103333: 56 push %esi +80103334: e8 37 f9 ff ff call 80102c70 + if (ip->type != T_DIR) { +80103339: 83 c4 10 add $0x10,%esp +8010333c: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) +80103341: 0f 85 cd 00 00 00 jne 80103414 + iunlockput(ip); + return 0; + } + if (nameiparent && *path == '\0') { +80103347: 8b 45 dc mov -0x24(%ebp),%eax +8010334a: 85 c0 test %eax,%eax +8010334c: 74 09 je 80103357 +8010334e: 80 3b 00 cmpb $0x0,(%ebx) +80103351: 0f 84 22 01 00 00 je 80103479 + // Stop one level early. + iunlock(ip); + return ip; + } + if ((next = dirlookup(ip, name, 0)) == 0) { +80103357: 83 ec 04 sub $0x4,%esp +8010335a: 6a 00 push $0x0 +8010335c: ff 75 e4 push -0x1c(%ebp) +8010335f: 56 push %esi +80103360: e8 6b fe ff ff call 801031d0 + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80103365: 8d 56 0c lea 0xc(%esi),%edx + if ((next = dirlookup(ip, name, 0)) == 0) { +80103368: 83 c4 10 add $0x10,%esp +8010336b: 89 c7 mov %eax,%edi +8010336d: 85 c0 test %eax,%eax +8010336f: 0f 84 e1 00 00 00 je 80103456 + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80103375: 83 ec 0c sub $0xc,%esp +80103378: 89 55 e0 mov %edx,-0x20(%ebp) +8010337b: 52 push %edx +8010337c: e8 df 25 00 00 call 80105960 +80103381: 83 c4 10 add $0x10,%esp +80103384: 85 c0 test %eax,%eax +80103386: 0f 84 30 01 00 00 je 801034bc +8010338c: 8b 56 08 mov 0x8(%esi),%edx +8010338f: 85 d2 test %edx,%edx +80103391: 0f 8e 25 01 00 00 jle 801034bc + releasesleep(&ip->lock); +80103397: 8b 55 e0 mov -0x20(%ebp),%edx +8010339a: 83 ec 0c sub $0xc,%esp +8010339d: 52 push %edx +8010339e: e8 7d 25 00 00 call 80105920 + iput(ip); +801033a3: 89 34 24 mov %esi,(%esp) +801033a6: 89 fe mov %edi,%esi +801033a8: e8 f3 f9 ff ff call 80102da0 +801033ad: 83 c4 10 add $0x10,%esp +801033b0: e9 16 ff ff ff jmp 801032cb +801033b5: 8d 76 00 lea 0x0(%esi),%esi + name[len] = 0; +801033b8: 8b 4d e4 mov -0x1c(%ebp),%ecx +801033bb: 8d 14 01 lea (%ecx,%eax,1),%edx + memmove(name, s, len); +801033be: 83 ec 04 sub $0x4,%esp +801033c1: 89 55 e0 mov %edx,-0x20(%ebp) +801033c4: 50 push %eax +801033c5: 53 push %ebx + name[len] = 0; +801033c6: 89 fb mov %edi,%ebx + memmove(name, s, len); +801033c8: ff 75 e4 push -0x1c(%ebp) +801033cb: e8 10 29 00 00 call 80105ce0 + name[len] = 0; +801033d0: 8b 55 e0 mov -0x20(%ebp),%edx +801033d3: 83 c4 10 add $0x10,%esp +801033d6: c6 02 00 movb $0x0,(%edx) +801033d9: e9 41 ff ff ff jmp 8010331f +801033de: 66 90 xchg %ax,%ax + return 0; + } + iunlockput(ip); + ip = next; + } + if (nameiparent) { +801033e0: 8b 45 dc mov -0x24(%ebp),%eax +801033e3: 85 c0 test %eax,%eax +801033e5: 0f 85 be 00 00 00 jne 801034a9 + iput(ip); + return 0; + } + return ip; +} +801033eb: 8d 65 f4 lea -0xc(%ebp),%esp +801033ee: 89 f0 mov %esi,%eax +801033f0: 5b pop %ebx +801033f1: 5e pop %esi +801033f2: 5f pop %edi +801033f3: 5d pop %ebp +801033f4: c3 ret + while (*path != '/' && *path != 0) { +801033f5: 8b 55 e4 mov -0x1c(%ebp),%edx +801033f8: 89 df mov %ebx,%edi +801033fa: 31 c0 xor %eax,%eax +801033fc: eb c0 jmp 801033be + ip = iget(ROOTDEV, ROOTINO); +801033fe: ba 01 00 00 00 mov $0x1,%edx +80103403: b8 01 00 00 00 mov $0x1,%eax +80103408: e8 33 f4 ff ff call 80102840 +8010340d: 89 c6 mov %eax,%esi +8010340f: e9 b7 fe ff ff jmp 801032cb + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80103414: 83 ec 0c sub $0xc,%esp +80103417: 8d 5e 0c lea 0xc(%esi),%ebx +8010341a: 53 push %ebx +8010341b: e8 40 25 00 00 call 80105960 +80103420: 83 c4 10 add $0x10,%esp +80103423: 85 c0 test %eax,%eax +80103425: 0f 84 91 00 00 00 je 801034bc +8010342b: 8b 46 08 mov 0x8(%esi),%eax +8010342e: 85 c0 test %eax,%eax +80103430: 0f 8e 86 00 00 00 jle 801034bc + releasesleep(&ip->lock); +80103436: 83 ec 0c sub $0xc,%esp +80103439: 53 push %ebx +8010343a: e8 e1 24 00 00 call 80105920 + iput(ip); +8010343f: 89 34 24 mov %esi,(%esp) + return 0; +80103442: 31 f6 xor %esi,%esi + iput(ip); +80103444: e8 57 f9 ff ff call 80102da0 + return 0; +80103449: 83 c4 10 add $0x10,%esp +} +8010344c: 8d 65 f4 lea -0xc(%ebp),%esp +8010344f: 89 f0 mov %esi,%eax +80103451: 5b pop %ebx +80103452: 5e pop %esi +80103453: 5f pop %edi +80103454: 5d pop %ebp +80103455: c3 ret + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80103456: 83 ec 0c sub $0xc,%esp +80103459: 89 55 e4 mov %edx,-0x1c(%ebp) +8010345c: 52 push %edx +8010345d: e8 fe 24 00 00 call 80105960 +80103462: 83 c4 10 add $0x10,%esp +80103465: 85 c0 test %eax,%eax +80103467: 74 53 je 801034bc +80103469: 8b 4e 08 mov 0x8(%esi),%ecx +8010346c: 85 c9 test %ecx,%ecx +8010346e: 7e 4c jle 801034bc + releasesleep(&ip->lock); +80103470: 8b 55 e4 mov -0x1c(%ebp),%edx +80103473: 83 ec 0c sub $0xc,%esp +80103476: 52 push %edx +80103477: eb c1 jmp 8010343a + if (ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) { +80103479: 83 ec 0c sub $0xc,%esp +8010347c: 8d 5e 0c lea 0xc(%esi),%ebx +8010347f: 53 push %ebx +80103480: e8 db 24 00 00 call 80105960 +80103485: 83 c4 10 add $0x10,%esp +80103488: 85 c0 test %eax,%eax +8010348a: 74 30 je 801034bc +8010348c: 8b 7e 08 mov 0x8(%esi),%edi +8010348f: 85 ff test %edi,%edi +80103491: 7e 29 jle 801034bc + releasesleep(&ip->lock); +80103493: 83 ec 0c sub $0xc,%esp +80103496: 53 push %ebx +80103497: e8 84 24 00 00 call 80105920 +} +8010349c: 83 c4 10 add $0x10,%esp +} +8010349f: 8d 65 f4 lea -0xc(%ebp),%esp +801034a2: 89 f0 mov %esi,%eax +801034a4: 5b pop %ebx +801034a5: 5e pop %esi +801034a6: 5f pop %edi +801034a7: 5d pop %ebp +801034a8: c3 ret + iput(ip); +801034a9: 83 ec 0c sub $0xc,%esp +801034ac: 56 push %esi + return 0; +801034ad: 31 f6 xor %esi,%esi + iput(ip); +801034af: e8 ec f8 ff ff call 80102da0 + return 0; +801034b4: 83 c4 10 add $0x10,%esp +801034b7: e9 2f ff ff ff jmp 801033eb + panic("iunlock"); +801034bc: 83 ec 0c sub $0xc,%esp +801034bf: 68 5f 8b 10 80 push $0x80108b5f +801034c4: e8 b7 cf ff ff call 80100480 +801034c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +801034d0 : +int dirlink(struct inode *dp, char *name, uint inum) { +801034d0: 55 push %ebp +801034d1: 89 e5 mov %esp,%ebp +801034d3: 57 push %edi +801034d4: 56 push %esi +801034d5: 53 push %ebx +801034d6: 83 ec 20 sub $0x20,%esp +801034d9: 8b 5d 08 mov 0x8(%ebp),%ebx + if ((ip = dirlookup(dp, name, 0)) != 0) { +801034dc: 6a 00 push $0x0 +801034de: ff 75 0c push 0xc(%ebp) +801034e1: 53 push %ebx +801034e2: e8 e9 fc ff ff call 801031d0 +801034e7: 83 c4 10 add $0x10,%esp +801034ea: 85 c0 test %eax,%eax +801034ec: 75 67 jne 80103555 + for (off = 0; off < dp->size; off += sizeof(de)) { +801034ee: 8b 7b 58 mov 0x58(%ebx),%edi +801034f1: 8d 75 d8 lea -0x28(%ebp),%esi +801034f4: 85 ff test %edi,%edi +801034f6: 74 29 je 80103521 +801034f8: 31 ff xor %edi,%edi +801034fa: 8d 75 d8 lea -0x28(%ebp),%esi +801034fd: eb 09 jmp 80103508 +801034ff: 90 nop +80103500: 83 c7 10 add $0x10,%edi +80103503: 3b 7b 58 cmp 0x58(%ebx),%edi +80103506: 73 19 jae 80103521 + if (readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +80103508: 6a 10 push $0x10 +8010350a: 57 push %edi +8010350b: 56 push %esi +8010350c: 53 push %ebx +8010350d: e8 6e fa ff ff call 80102f80 +80103512: 83 c4 10 add $0x10,%esp +80103515: 83 f8 10 cmp $0x10,%eax +80103518: 75 4e jne 80103568 + if (de.inum == 0) { +8010351a: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) +8010351f: 75 df jne 80103500 + strncpy(de.name, name, DIRSIZ); +80103521: 83 ec 04 sub $0x4,%esp +80103524: 8d 45 da lea -0x26(%ebp),%eax +80103527: 6a 0e push $0xe +80103529: ff 75 0c push 0xc(%ebp) +8010352c: 50 push %eax +8010352d: e8 6e 28 00 00 call 80105da0 + if (writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +80103532: 6a 10 push $0x10 + de.inum = inum; +80103534: 8b 45 10 mov 0x10(%ebp),%eax + if (writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +80103537: 57 push %edi +80103538: 56 push %esi +80103539: 53 push %ebx + de.inum = inum; +8010353a: 66 89 45 d8 mov %ax,-0x28(%ebp) + if (writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +8010353e: e8 3d fb ff ff call 80103080 +80103543: 83 c4 20 add $0x20,%esp +80103546: 83 f8 10 cmp $0x10,%eax +80103549: 75 2a jne 80103575 + return 0; +8010354b: 31 c0 xor %eax,%eax +} +8010354d: 8d 65 f4 lea -0xc(%ebp),%esp +80103550: 5b pop %ebx +80103551: 5e pop %esi +80103552: 5f pop %edi +80103553: 5d pop %ebp +80103554: c3 ret + iput(ip); +80103555: 83 ec 0c sub $0xc,%esp +80103558: 50 push %eax +80103559: e8 42 f8 ff ff call 80102da0 + return -1; +8010355e: 83 c4 10 add $0x10,%esp +80103561: b8 ff ff ff ff mov $0xffffffff,%eax +80103566: eb e5 jmp 8010354d + panic("dirlink read"); +80103568: 83 ec 0c sub $0xc,%esp +8010356b: 68 88 8b 10 80 push $0x80108b88 +80103570: e8 0b cf ff ff call 80100480 + panic("dirlink"); +80103575: 83 ec 0c sub $0xc,%esp +80103578: 68 f2 91 10 80 push $0x801091f2 +8010357d: e8 fe ce ff ff call 80100480 +80103582: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103589: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80103590 : + +struct inode* namei(char *path) { +80103590: 55 push %ebp + char name[DIRSIZ]; + return namex(path, 0, name); +80103591: 31 d2 xor %edx,%edx +struct inode* namei(char *path) { +80103593: 89 e5 mov %esp,%ebp +80103595: 83 ec 18 sub $0x18,%esp + return namex(path, 0, name); +80103598: 8b 45 08 mov 0x8(%ebp),%eax +8010359b: 8d 4d ea lea -0x16(%ebp),%ecx +8010359e: e8 dd fc ff ff call 80103280 +} +801035a3: c9 leave +801035a4: c3 ret +801035a5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801035ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801035b0 : + +struct inode*nameiparent(char *path, char *name) { +801035b0: 55 push %ebp + return namex(path, 1, name); +801035b1: ba 01 00 00 00 mov $0x1,%edx +struct inode*nameiparent(char *path, char *name) { +801035b6: 89 e5 mov %esp,%ebp + return namex(path, 1, name); +801035b8: 8b 4d 0c mov 0xc(%ebp),%ecx +801035bb: 8b 45 08 mov 0x8(%ebp),%eax +} +801035be: 5d pop %ebp + return namex(path, 1, name); +801035bf: e9 bc fc ff ff jmp 80103280 +801035c4: 66 90 xchg %ax,%ax +801035c6: 66 90 xchg %ax,%ax +801035c8: 66 90 xchg %ax,%ax +801035ca: 66 90 xchg %ax,%ax +801035cc: 66 90 xchg %ax,%ax +801035ce: 66 90 xchg %ax,%ax + +801035d0 : + // Switch back to disk 0. + outb(0x1f6, 0xe0 | (0 << 4)); +} + +// Start the request for b. Caller must hold idelock. +static void idestart(struct buf *b) { +801035d0: 55 push %ebp +801035d1: 89 e5 mov %esp,%ebp +801035d3: 57 push %edi +801035d4: 56 push %esi +801035d5: 53 push %ebx +801035d6: 83 ec 0c sub $0xc,%esp + if (b == 0) { +801035d9: 85 c0 test %eax,%eax +801035db: 0f 84 b4 00 00 00 je 80103695 + panic("idestart"); + } + if (b->blockno >= FSSIZE) { +801035e1: 8b 70 08 mov 0x8(%eax),%esi +801035e4: 89 c3 mov %eax,%ebx +801035e6: 81 fe e7 03 00 00 cmp $0x3e7,%esi +801035ec: 0f 87 96 00 00 00 ja 80103688 + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +801035f2: b9 f7 01 00 00 mov $0x1f7,%ecx +801035f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801035fe: 66 90 xchg %ax,%ax +80103600: 89 ca mov %ecx,%edx +80103602: ec in (%dx),%al + while (((r = inb(0x1f7)) & (IDE_BSY | IDE_DRDY)) != IDE_DRDY) { +80103603: 83 e0 c0 and $0xffffffc0,%eax +80103606: 3c 40 cmp $0x40,%al +80103608: 75 f6 jne 80103600 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +8010360a: 31 ff xor %edi,%edi +8010360c: ba f6 03 00 00 mov $0x3f6,%edx +80103611: 89 f8 mov %edi,%eax +80103613: ee out %al,(%dx) +80103614: b8 01 00 00 00 mov $0x1,%eax +80103619: ba f2 01 00 00 mov $0x1f2,%edx +8010361e: ee out %al,(%dx) +8010361f: ba f3 01 00 00 mov $0x1f3,%edx +80103624: 89 f0 mov %esi,%eax +80103626: ee out %al,(%dx) + + idewait(0); + outb(0x3f6, 0); // generate interrupt + outb(0x1f2, sector_per_block); // number of sectors + outb(0x1f3, sector & 0xff); + outb(0x1f4, (sector >> 8) & 0xff); +80103627: 89 f0 mov %esi,%eax +80103629: ba f4 01 00 00 mov $0x1f4,%edx +8010362e: c1 f8 08 sar $0x8,%eax +80103631: ee out %al,(%dx) +80103632: ba f5 01 00 00 mov $0x1f5,%edx +80103637: 89 f8 mov %edi,%eax +80103639: ee out %al,(%dx) + outb(0x1f5, (sector >> 16) & 0xff); + outb(0x1f6, 0xe0 | ((b->dev & 1) << 4) | ((sector >> 24) & 0x0f)); +8010363a: 0f b6 43 04 movzbl 0x4(%ebx),%eax +8010363e: ba f6 01 00 00 mov $0x1f6,%edx +80103643: c1 e0 04 shl $0x4,%eax +80103646: 83 e0 10 and $0x10,%eax +80103649: 83 c8 e0 or $0xffffffe0,%eax +8010364c: ee out %al,(%dx) + if (b->flags & B_DIRTY) { +8010364d: f6 03 04 testb $0x4,(%ebx) +80103650: 75 16 jne 80103668 +80103652: b8 20 00 00 00 mov $0x20,%eax +80103657: 89 ca mov %ecx,%edx +80103659: ee out %al,(%dx) + outsl(0x1f0, b->data, BSIZE / 4); + } + else { + outb(0x1f7, read_cmd); + } +} +8010365a: 8d 65 f4 lea -0xc(%ebp),%esp +8010365d: 5b pop %ebx +8010365e: 5e pop %esi +8010365f: 5f pop %edi +80103660: 5d pop %ebp +80103661: c3 ret +80103662: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80103668: b8 30 00 00 00 mov $0x30,%eax +8010366d: 89 ca mov %ecx,%edx +8010366f: ee out %al,(%dx) + asm volatile ("cld; rep outsl" : +80103670: b9 80 00 00 00 mov $0x80,%ecx + outsl(0x1f0, b->data, BSIZE / 4); +80103675: 8d 73 5c lea 0x5c(%ebx),%esi +80103678: ba f0 01 00 00 mov $0x1f0,%edx +8010367d: fc cld +8010367e: f3 6f rep outsl %ds:(%esi),(%dx) +} +80103680: 8d 65 f4 lea -0xc(%ebp),%esp +80103683: 5b pop %ebx +80103684: 5e pop %esi +80103685: 5f pop %edi +80103686: 5d pop %ebp +80103687: c3 ret + panic("incorrect blockno"); +80103688: 83 ec 0c sub $0xc,%esp +8010368b: 68 f4 8b 10 80 push $0x80108bf4 +80103690: e8 eb cd ff ff call 80100480 + panic("idestart"); +80103695: 83 ec 0c sub $0xc,%esp +80103698: 68 eb 8b 10 80 push $0x80108beb +8010369d: e8 de cd ff ff call 80100480 +801036a2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801036a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +801036b0 : +void ideinit(void) { +801036b0: 55 push %ebp +801036b1: 89 e5 mov %esp,%ebp +801036b3: 83 ec 10 sub $0x10,%esp + initlock(&idelock, "ide"); +801036b6: 68 06 8c 10 80 push $0x80108c06 +801036bb: 68 80 dd 11 80 push $0x8011dd80 +801036c0: e8 eb 22 00 00 call 801059b0 + ioapicenable(IRQ_IDE, ncpu - 1); +801036c5: 58 pop %eax +801036c6: a1 04 df 11 80 mov 0x8011df04,%eax +801036cb: 5a pop %edx +801036cc: 83 e8 01 sub $0x1,%eax +801036cf: 50 push %eax +801036d0: 6a 0e push $0xe +801036d2: e8 99 02 00 00 call 80103970 + while (((r = inb(0x1f7)) & (IDE_BSY | IDE_DRDY)) != IDE_DRDY) { +801036d7: 83 c4 10 add $0x10,%esp + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +801036da: ba f7 01 00 00 mov $0x1f7,%edx +801036df: 90 nop +801036e0: ec in (%dx),%al +801036e1: 83 e0 c0 and $0xffffffc0,%eax +801036e4: 3c 40 cmp $0x40,%al +801036e6: 75 f8 jne 801036e0 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +801036e8: b8 f0 ff ff ff mov $0xfffffff0,%eax +801036ed: ba f6 01 00 00 mov $0x1f6,%edx +801036f2: ee out %al,(%dx) +801036f3: b9 e8 03 00 00 mov $0x3e8,%ecx + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +801036f8: ba f7 01 00 00 mov $0x1f7,%edx +801036fd: eb 06 jmp 80103705 +801036ff: 90 nop + for (i = 0; i < 1000; i++) { +80103700: 83 e9 01 sub $0x1,%ecx +80103703: 74 0f je 80103714 +80103705: ec in (%dx),%al + if (inb(0x1f7) != 0) { +80103706: 84 c0 test %al,%al +80103708: 74 f6 je 80103700 + havedisk1 = 1; +8010370a: c7 05 60 dd 11 80 01 movl $0x1,0x8011dd60 +80103711: 00 00 00 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103714: b8 e0 ff ff ff mov $0xffffffe0,%eax +80103719: ba f6 01 00 00 mov $0x1f6,%edx +8010371e: ee out %al,(%dx) +} +8010371f: c9 leave +80103720: c3 ret +80103721: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103728: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010372f: 90 nop + +80103730 : + +// Interrupt handler. +void ideintr(void) { +80103730: 55 push %ebp +80103731: 89 e5 mov %esp,%ebp +80103733: 57 push %edi +80103734: 56 push %esi +80103735: 53 push %ebx +80103736: 83 ec 18 sub $0x18,%esp + struct buf *b; + + // First queued buffer is the active request. + acquire(&idelock); +80103739: 68 80 dd 11 80 push $0x8011dd80 +8010373e: e8 3d 24 00 00 call 80105b80 + + if ((b = idequeue) == 0) { +80103743: 8b 1d 64 dd 11 80 mov 0x8011dd64,%ebx +80103749: 83 c4 10 add $0x10,%esp +8010374c: 85 db test %ebx,%ebx +8010374e: 74 63 je 801037b3 + release(&idelock); + return; + } + idequeue = b->qnext; +80103750: 8b 43 58 mov 0x58(%ebx),%eax +80103753: a3 64 dd 11 80 mov %eax,0x8011dd64 + + // Read data if needed. + if (!(b->flags & B_DIRTY) && idewait(1) >= 0) { +80103758: 8b 33 mov (%ebx),%esi +8010375a: f7 c6 04 00 00 00 test $0x4,%esi +80103760: 75 2f jne 80103791 + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103762: ba f7 01 00 00 mov $0x1f7,%edx +80103767: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010376e: 66 90 xchg %ax,%ax +80103770: ec in (%dx),%al + while (((r = inb(0x1f7)) & (IDE_BSY | IDE_DRDY)) != IDE_DRDY) { +80103771: 89 c1 mov %eax,%ecx +80103773: 83 e1 c0 and $0xffffffc0,%ecx +80103776: 80 f9 40 cmp $0x40,%cl +80103779: 75 f5 jne 80103770 + if (checkerr && (r & (IDE_DF | IDE_ERR)) != 0) { +8010377b: a8 21 test $0x21,%al +8010377d: 75 12 jne 80103791 + insl(0x1f0, b->data, BSIZE / 4); +8010377f: 8d 7b 5c lea 0x5c(%ebx),%edi + asm volatile ("cld; rep insl" : +80103782: b9 80 00 00 00 mov $0x80,%ecx +80103787: ba f0 01 00 00 mov $0x1f0,%edx +8010378c: fc cld +8010378d: f3 6d rep insl (%dx),%es:(%edi) + } + + // Wake process waiting for this buf. + b->flags |= B_VALID; +8010378f: 8b 33 mov (%ebx),%esi + b->flags &= ~B_DIRTY; +80103791: 83 e6 fb and $0xfffffffb,%esi + wakeup(b); +80103794: 83 ec 0c sub $0xc,%esp + b->flags &= ~B_DIRTY; +80103797: 83 ce 02 or $0x2,%esi +8010379a: 89 33 mov %esi,(%ebx) + wakeup(b); +8010379c: 53 push %ebx +8010379d: e8 fe 1e 00 00 call 801056a0 + + // Start disk on next buf in queue. + if (idequeue != 0) { +801037a2: a1 64 dd 11 80 mov 0x8011dd64,%eax +801037a7: 83 c4 10 add $0x10,%esp +801037aa: 85 c0 test %eax,%eax +801037ac: 74 05 je 801037b3 + idestart(idequeue); +801037ae: e8 1d fe ff ff call 801035d0 + release(&idelock); +801037b3: 83 ec 0c sub $0xc,%esp +801037b6: 68 80 dd 11 80 push $0x8011dd80 +801037bb: e8 60 23 00 00 call 80105b20 + } + + release(&idelock); +} +801037c0: 8d 65 f4 lea -0xc(%ebp),%esp +801037c3: 5b pop %ebx +801037c4: 5e pop %esi +801037c5: 5f pop %edi +801037c6: 5d pop %ebp +801037c7: c3 ret +801037c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801037cf: 90 nop + +801037d0 : + + +// Sync buf with disk. +// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. +// Else if B_VALID is not set, read buf from disk, set B_VALID. +void iderw(struct buf *b) { +801037d0: 55 push %ebp +801037d1: 89 e5 mov %esp,%ebp +801037d3: 53 push %ebx +801037d4: 83 ec 10 sub $0x10,%esp +801037d7: 8b 5d 08 mov 0x8(%ebp),%ebx + struct buf **pp; + + if (!holdingsleep(&b->lock)) { +801037da: 8d 43 0c lea 0xc(%ebx),%eax +801037dd: 50 push %eax +801037de: e8 7d 21 00 00 call 80105960 +801037e3: 83 c4 10 add $0x10,%esp +801037e6: 85 c0 test %eax,%eax +801037e8: 0f 84 c3 00 00 00 je 801038b1 + panic("iderw: buf not locked"); + } + if ((b->flags & (B_VALID | B_DIRTY)) == B_VALID) { +801037ee: 8b 03 mov (%ebx),%eax +801037f0: 83 e0 06 and $0x6,%eax +801037f3: 83 f8 02 cmp $0x2,%eax +801037f6: 0f 84 a8 00 00 00 je 801038a4 + panic("iderw: nothing to do"); + } + if (b->dev != 0 && !havedisk1) { +801037fc: 8b 53 04 mov 0x4(%ebx),%edx +801037ff: 85 d2 test %edx,%edx +80103801: 74 0d je 80103810 +80103803: a1 60 dd 11 80 mov 0x8011dd60,%eax +80103808: 85 c0 test %eax,%eax +8010380a: 0f 84 87 00 00 00 je 80103897 + panic("iderw: ide disk 1 not present"); + } + + acquire(&idelock); //DOC:acquire-lock +80103810: 83 ec 0c sub $0xc,%esp +80103813: 68 80 dd 11 80 push $0x8011dd80 +80103818: e8 63 23 00 00 call 80105b80 + + // Append b to idequeue. + b->qnext = 0; + for (pp = &idequeue; *pp; pp = &(*pp)->qnext) { //DOC:insert-queue +8010381d: a1 64 dd 11 80 mov 0x8011dd64,%eax + b->qnext = 0; +80103822: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) + for (pp = &idequeue; *pp; pp = &(*pp)->qnext) { //DOC:insert-queue +80103829: 83 c4 10 add $0x10,%esp +8010382c: 85 c0 test %eax,%eax +8010382e: 74 60 je 80103890 +80103830: 89 c2 mov %eax,%edx +80103832: 8b 40 58 mov 0x58(%eax),%eax +80103835: 85 c0 test %eax,%eax +80103837: 75 f7 jne 80103830 +80103839: 83 c2 58 add $0x58,%edx + ; + } + *pp = b; +8010383c: 89 1a mov %ebx,(%edx) + + // Start disk if necessary. + if (idequeue == b) { +8010383e: 39 1d 64 dd 11 80 cmp %ebx,0x8011dd64 +80103844: 74 3a je 80103880 + idestart(b); + } + + // Wait for request to finish. + while ((b->flags & (B_VALID | B_DIRTY)) != B_VALID) { +80103846: 8b 03 mov (%ebx),%eax +80103848: 83 e0 06 and $0x6,%eax +8010384b: 83 f8 02 cmp $0x2,%eax +8010384e: 74 1b je 8010386b + sleep(b, &idelock); +80103850: 83 ec 08 sub $0x8,%esp +80103853: 68 80 dd 11 80 push $0x8011dd80 +80103858: 53 push %ebx +80103859: e8 82 1d 00 00 call 801055e0 + while ((b->flags & (B_VALID | B_DIRTY)) != B_VALID) { +8010385e: 8b 03 mov (%ebx),%eax +80103860: 83 c4 10 add $0x10,%esp +80103863: 83 e0 06 and $0x6,%eax +80103866: 83 f8 02 cmp $0x2,%eax +80103869: 75 e5 jne 80103850 + } + + release(&idelock); +8010386b: c7 45 08 80 dd 11 80 movl $0x8011dd80,0x8(%ebp) +} +80103872: 8b 5d fc mov -0x4(%ebp),%ebx +80103875: c9 leave + release(&idelock); +80103876: e9 a5 22 00 00 jmp 80105b20 +8010387b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010387f: 90 nop + idestart(b); +80103880: 89 d8 mov %ebx,%eax +80103882: e8 49 fd ff ff call 801035d0 +80103887: eb bd jmp 80103846 +80103889: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + for (pp = &idequeue; *pp; pp = &(*pp)->qnext) { //DOC:insert-queue +80103890: ba 64 dd 11 80 mov $0x8011dd64,%edx +80103895: eb a5 jmp 8010383c + panic("iderw: ide disk 1 not present"); +80103897: 83 ec 0c sub $0xc,%esp +8010389a: 68 35 8c 10 80 push $0x80108c35 +8010389f: e8 dc cb ff ff call 80100480 + panic("iderw: nothing to do"); +801038a4: 83 ec 0c sub $0xc,%esp +801038a7: 68 20 8c 10 80 push $0x80108c20 +801038ac: e8 cf cb ff ff call 80100480 + panic("iderw: buf not locked"); +801038b1: 83 ec 0c sub $0xc,%esp +801038b4: 68 0a 8c 10 80 push $0x80108c0a +801038b9: e8 c2 cb ff ff call 80100480 +801038be: 66 90 xchg %ax,%ax + +801038c0 : +static void ioapicwrite(int reg, uint data) { + ioapic->reg = reg; + ioapic->data = data; +} + +void ioapicinit(void) { +801038c0: 55 push %ebp + int i, id, maxintr; + + ioapic = (volatile struct ioapic*)IOAPIC; +801038c1: c7 05 b4 dd 11 80 00 movl $0xfec00000,0x8011ddb4 +801038c8: 00 c0 fe +void ioapicinit(void) { +801038cb: 89 e5 mov %esp,%ebp +801038cd: 56 push %esi +801038ce: 53 push %ebx + ioapic->reg = reg; +801038cf: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 +801038d6: 00 00 00 + return ioapic->data; +801038d9: 8b 15 b4 dd 11 80 mov 0x8011ddb4,%edx +801038df: 8b 72 10 mov 0x10(%edx),%esi + ioapic->reg = reg; +801038e2: c7 02 00 00 00 00 movl $0x0,(%edx) + return ioapic->data; +801038e8: 8b 0d b4 dd 11 80 mov 0x8011ddb4,%ecx + maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; + id = ioapicread(REG_ID) >> 24; + if (id != ioapicid) { +801038ee: 0f b6 15 00 df 11 80 movzbl 0x8011df00,%edx + maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; +801038f5: c1 ee 10 shr $0x10,%esi +801038f8: 89 f0 mov %esi,%eax +801038fa: 0f b6 f0 movzbl %al,%esi + return ioapic->data; +801038fd: 8b 41 10 mov 0x10(%ecx),%eax + id = ioapicread(REG_ID) >> 24; +80103900: c1 e8 18 shr $0x18,%eax + if (id != ioapicid) { +80103903: 39 c2 cmp %eax,%edx +80103905: 74 16 je 8010391d + cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); +80103907: 83 ec 0c sub $0xc,%esp +8010390a: 68 54 8c 10 80 push $0x80108c54 +8010390f: e8 7c cf ff ff call 80100890 + ioapic->reg = reg; +80103914: 8b 0d b4 dd 11 80 mov 0x8011ddb4,%ecx +8010391a: 83 c4 10 add $0x10,%esp +8010391d: 83 c6 21 add $0x21,%esi +void ioapicinit(void) { +80103920: ba 10 00 00 00 mov $0x10,%edx +80103925: b8 20 00 00 00 mov $0x20,%eax +8010392a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + ioapic->reg = reg; +80103930: 89 11 mov %edx,(%ecx) + } + + // Mark all interrupts edge-triggered, active high, disabled, + // and not routed to any CPUs. + for (i = 0; i <= maxintr; i++) { + ioapicwrite(REG_TABLE + 2 * i, INT_DISABLED | (T_IRQ0 + i)); +80103932: 89 c3 mov %eax,%ebx + ioapic->data = data; +80103934: 8b 0d b4 dd 11 80 mov 0x8011ddb4,%ecx + for (i = 0; i <= maxintr; i++) { +8010393a: 83 c0 01 add $0x1,%eax + ioapicwrite(REG_TABLE + 2 * i, INT_DISABLED | (T_IRQ0 + i)); +8010393d: 81 cb 00 00 01 00 or $0x10000,%ebx + ioapic->data = data; +80103943: 89 59 10 mov %ebx,0x10(%ecx) + ioapic->reg = reg; +80103946: 8d 5a 01 lea 0x1(%edx),%ebx + for (i = 0; i <= maxintr; i++) { +80103949: 83 c2 02 add $0x2,%edx + ioapic->reg = reg; +8010394c: 89 19 mov %ebx,(%ecx) + ioapic->data = data; +8010394e: 8b 0d b4 dd 11 80 mov 0x8011ddb4,%ecx +80103954: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) + for (i = 0; i <= maxintr; i++) { +8010395b: 39 f0 cmp %esi,%eax +8010395d: 75 d1 jne 80103930 + ioapicwrite(REG_TABLE + 2 * i + 1, 0); + } +} +8010395f: 8d 65 f8 lea -0x8(%ebp),%esp +80103962: 5b pop %ebx +80103963: 5e pop %esi +80103964: 5d pop %ebp +80103965: c3 ret +80103966: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010396d: 8d 76 00 lea 0x0(%esi),%esi + +80103970 : + +void ioapicenable(int irq, int cpunum) { +80103970: 55 push %ebp + ioapic->reg = reg; +80103971: 8b 0d b4 dd 11 80 mov 0x8011ddb4,%ecx +void ioapicenable(int irq, int cpunum) { +80103977: 89 e5 mov %esp,%ebp +80103979: 8b 45 08 mov 0x8(%ebp),%eax + // Mark interrupt edge-triggered, active high, + // enabled, and routed to the given cpunum, + // which happens to be that cpu's APIC ID. + ioapicwrite(REG_TABLE + 2 * irq, T_IRQ0 + irq); +8010397c: 8d 50 20 lea 0x20(%eax),%edx +8010397f: 8d 44 00 10 lea 0x10(%eax,%eax,1),%eax + ioapic->reg = reg; +80103983: 89 01 mov %eax,(%ecx) + ioapic->data = data; +80103985: 8b 0d b4 dd 11 80 mov 0x8011ddb4,%ecx + ioapicwrite(REG_TABLE + 2 * irq + 1, cpunum << 24); +8010398b: 83 c0 01 add $0x1,%eax + ioapic->data = data; +8010398e: 89 51 10 mov %edx,0x10(%ecx) + ioapicwrite(REG_TABLE + 2 * irq + 1, cpunum << 24); +80103991: 8b 55 0c mov 0xc(%ebp),%edx + ioapic->reg = reg; +80103994: 89 01 mov %eax,(%ecx) + ioapic->data = data; +80103996: a1 b4 dd 11 80 mov 0x8011ddb4,%eax + ioapicwrite(REG_TABLE + 2 * irq + 1, cpunum << 24); +8010399b: c1 e2 18 shl $0x18,%edx + ioapic->data = data; +8010399e: 89 50 10 mov %edx,0x10(%eax) +} +801039a1: 5d pop %ebp +801039a2: c3 ret +801039a3: 66 90 xchg %ax,%ax +801039a5: 66 90 xchg %ax,%ax +801039a7: 66 90 xchg %ax,%ax +801039a9: 66 90 xchg %ax,%ax +801039ab: 66 90 xchg %ax,%ax +801039ad: 66 90 xchg %ax,%ax +801039af: 90 nop + +801039b0 : + +// Free the page of physical memory pointed at by v, +// which normally should have been returned by a +// call to kalloc(). (The exception is when +// initializing the allocator; see kinit above.) +void kfree(char *v) { +801039b0: 55 push %ebp +801039b1: 89 e5 mov %esp,%ebp +801039b3: 53 push %ebx +801039b4: 83 ec 04 sub $0x4,%esp +801039b7: 8b 5d 08 mov 0x8(%ebp),%ebx + struct run *r; + + if ((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) { +801039ba: f7 c3 ff 0f 00 00 test $0xfff,%ebx +801039c0: 75 76 jne 80103a38 +801039c2: 81 fb 50 22 12 80 cmp $0x80122250,%ebx +801039c8: 72 6e jb 80103a38 +801039ca: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +801039d0: 3d ff ff ff 0d cmp $0xdffffff,%eax +801039d5: 77 61 ja 80103a38 + panic("kfree"); + } + + // Fill with junk to catch dangling refs. + memset(v, 1, PGSIZE); +801039d7: 83 ec 04 sub $0x4,%esp +801039da: 68 00 10 00 00 push $0x1000 +801039df: 6a 01 push $0x1 +801039e1: 53 push %ebx +801039e2: e8 59 22 00 00 call 80105c40 + + if (kmem.use_lock) { +801039e7: 8b 15 f4 dd 11 80 mov 0x8011ddf4,%edx +801039ed: 83 c4 10 add $0x10,%esp +801039f0: 85 d2 test %edx,%edx +801039f2: 75 1c jne 80103a10 + acquire(&kmem.lock); + } + r = (struct run*)v; + r->next = kmem.freelist; +801039f4: a1 f8 dd 11 80 mov 0x8011ddf8,%eax +801039f9: 89 03 mov %eax,(%ebx) + kmem.freelist = r; + if (kmem.use_lock) { +801039fb: a1 f4 dd 11 80 mov 0x8011ddf4,%eax + kmem.freelist = r; +80103a00: 89 1d f8 dd 11 80 mov %ebx,0x8011ddf8 + if (kmem.use_lock) { +80103a06: 85 c0 test %eax,%eax +80103a08: 75 1e jne 80103a28 + release(&kmem.lock); + } +} +80103a0a: 8b 5d fc mov -0x4(%ebp),%ebx +80103a0d: c9 leave +80103a0e: c3 ret +80103a0f: 90 nop + acquire(&kmem.lock); +80103a10: 83 ec 0c sub $0xc,%esp +80103a13: 68 c0 dd 11 80 push $0x8011ddc0 +80103a18: e8 63 21 00 00 call 80105b80 +80103a1d: 83 c4 10 add $0x10,%esp +80103a20: eb d2 jmp 801039f4 +80103a22: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + release(&kmem.lock); +80103a28: c7 45 08 c0 dd 11 80 movl $0x8011ddc0,0x8(%ebp) +} +80103a2f: 8b 5d fc mov -0x4(%ebp),%ebx +80103a32: c9 leave + release(&kmem.lock); +80103a33: e9 e8 20 00 00 jmp 80105b20 + panic("kfree"); +80103a38: 83 ec 0c sub $0xc,%esp +80103a3b: 68 86 8c 10 80 push $0x80108c86 +80103a40: e8 3b ca ff ff call 80100480 +80103a45: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103a4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80103a50 : +void freerange(void *vstart, void *vend) { +80103a50: 55 push %ebp +80103a51: 89 e5 mov %esp,%ebp +80103a53: 56 push %esi + p = (char*)PGROUNDUP((uint)vstart); +80103a54: 8b 45 08 mov 0x8(%ebp),%eax +void freerange(void *vstart, void *vend) { +80103a57: 8b 75 0c mov 0xc(%ebp),%esi +80103a5a: 53 push %ebx + p = (char*)PGROUNDUP((uint)vstart); +80103a5b: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx +80103a61: 81 e3 00 f0 ff ff and $0xfffff000,%ebx + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103a67: 81 c3 00 10 00 00 add $0x1000,%ebx +80103a6d: 39 de cmp %ebx,%esi +80103a6f: 72 23 jb 80103a94 +80103a71: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + kfree(p); +80103a78: 83 ec 0c sub $0xc,%esp +80103a7b: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103a81: 81 c3 00 10 00 00 add $0x1000,%ebx + kfree(p); +80103a87: 50 push %eax +80103a88: e8 23 ff ff ff call 801039b0 + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103a8d: 83 c4 10 add $0x10,%esp +80103a90: 39 f3 cmp %esi,%ebx +80103a92: 76 e4 jbe 80103a78 +} +80103a94: 8d 65 f8 lea -0x8(%ebp),%esp +80103a97: 5b pop %ebx +80103a98: 5e pop %esi +80103a99: 5d pop %ebp +80103a9a: c3 ret +80103a9b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80103a9f: 90 nop + +80103aa0 : +void kinit2(void *vstart, void *vend) { +80103aa0: 55 push %ebp +80103aa1: 89 e5 mov %esp,%ebp +80103aa3: 56 push %esi + p = (char*)PGROUNDUP((uint)vstart); +80103aa4: 8b 45 08 mov 0x8(%ebp),%eax +void kinit2(void *vstart, void *vend) { +80103aa7: 8b 75 0c mov 0xc(%ebp),%esi +80103aaa: 53 push %ebx + p = (char*)PGROUNDUP((uint)vstart); +80103aab: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx +80103ab1: 81 e3 00 f0 ff ff and $0xfffff000,%ebx + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103ab7: 81 c3 00 10 00 00 add $0x1000,%ebx +80103abd: 39 de cmp %ebx,%esi +80103abf: 72 23 jb 80103ae4 +80103ac1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + kfree(p); +80103ac8: 83 ec 0c sub $0xc,%esp +80103acb: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103ad1: 81 c3 00 10 00 00 add $0x1000,%ebx + kfree(p); +80103ad7: 50 push %eax +80103ad8: e8 d3 fe ff ff call 801039b0 + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103add: 83 c4 10 add $0x10,%esp +80103ae0: 39 de cmp %ebx,%esi +80103ae2: 73 e4 jae 80103ac8 + kmem.use_lock = 1; +80103ae4: c7 05 f4 dd 11 80 01 movl $0x1,0x8011ddf4 +80103aeb: 00 00 00 +} +80103aee: 8d 65 f8 lea -0x8(%ebp),%esp +80103af1: 5b pop %ebx +80103af2: 5e pop %esi +80103af3: 5d pop %ebp +80103af4: c3 ret +80103af5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103afc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80103b00 : +void kinit1(void *vstart, void *vend) { +80103b00: 55 push %ebp +80103b01: 89 e5 mov %esp,%ebp +80103b03: 56 push %esi +80103b04: 53 push %ebx +80103b05: 8b 75 0c mov 0xc(%ebp),%esi + initlock(&kmem.lock, "kmem"); +80103b08: 83 ec 08 sub $0x8,%esp +80103b0b: 68 8c 8c 10 80 push $0x80108c8c +80103b10: 68 c0 dd 11 80 push $0x8011ddc0 +80103b15: e8 96 1e 00 00 call 801059b0 + p = (char*)PGROUNDUP((uint)vstart); +80103b1a: 8b 45 08 mov 0x8(%ebp),%eax + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103b1d: 83 c4 10 add $0x10,%esp + kmem.use_lock = 0; +80103b20: c7 05 f4 dd 11 80 00 movl $0x0,0x8011ddf4 +80103b27: 00 00 00 + p = (char*)PGROUNDUP((uint)vstart); +80103b2a: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx +80103b30: 81 e3 00 f0 ff ff and $0xfffff000,%ebx + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103b36: 81 c3 00 10 00 00 add $0x1000,%ebx +80103b3c: 39 de cmp %ebx,%esi +80103b3e: 72 1c jb 80103b5c + kfree(p); +80103b40: 83 ec 0c sub $0xc,%esp +80103b43: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103b49: 81 c3 00 10 00 00 add $0x1000,%ebx + kfree(p); +80103b4f: 50 push %eax +80103b50: e8 5b fe ff ff call 801039b0 + for (; p + PGSIZE <= (char*)vend; p += PGSIZE) { +80103b55: 83 c4 10 add $0x10,%esp +80103b58: 39 de cmp %ebx,%esi +80103b5a: 73 e4 jae 80103b40 +} +80103b5c: 8d 65 f8 lea -0x8(%ebp),%esp +80103b5f: 5b pop %ebx +80103b60: 5e pop %esi +80103b61: 5d pop %ebp +80103b62: c3 ret +80103b63: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103b6a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80103b70 : +// Returns a pointer that the kernel can use. +// Returns 0 if the memory cannot be allocated. +char* kalloc(void) { + struct run *r; + + if (kmem.use_lock) { +80103b70: a1 f4 dd 11 80 mov 0x8011ddf4,%eax +80103b75: 85 c0 test %eax,%eax +80103b77: 75 1f jne 80103b98 + acquire(&kmem.lock); + } + r = kmem.freelist; +80103b79: a1 f8 dd 11 80 mov 0x8011ddf8,%eax + if (r) { +80103b7e: 85 c0 test %eax,%eax +80103b80: 74 0e je 80103b90 + kmem.freelist = r->next; +80103b82: 8b 10 mov (%eax),%edx +80103b84: 89 15 f8 dd 11 80 mov %edx,0x8011ddf8 + } + if (kmem.use_lock) { +80103b8a: c3 ret +80103b8b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80103b8f: 90 nop + release(&kmem.lock); + } + return (char*)r; +} +80103b90: c3 ret +80103b91: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +char* kalloc(void) { +80103b98: 55 push %ebp +80103b99: 89 e5 mov %esp,%ebp +80103b9b: 83 ec 24 sub $0x24,%esp + acquire(&kmem.lock); +80103b9e: 68 c0 dd 11 80 push $0x8011ddc0 +80103ba3: e8 d8 1f 00 00 call 80105b80 + r = kmem.freelist; +80103ba8: a1 f8 dd 11 80 mov 0x8011ddf8,%eax + if (kmem.use_lock) { +80103bad: 8b 15 f4 dd 11 80 mov 0x8011ddf4,%edx + if (r) { +80103bb3: 83 c4 10 add $0x10,%esp +80103bb6: 85 c0 test %eax,%eax +80103bb8: 74 08 je 80103bc2 + kmem.freelist = r->next; +80103bba: 8b 08 mov (%eax),%ecx +80103bbc: 89 0d f8 dd 11 80 mov %ecx,0x8011ddf8 + if (kmem.use_lock) { +80103bc2: 85 d2 test %edx,%edx +80103bc4: 74 16 je 80103bdc + release(&kmem.lock); +80103bc6: 83 ec 0c sub $0xc,%esp +80103bc9: 89 45 f4 mov %eax,-0xc(%ebp) +80103bcc: 68 c0 dd 11 80 push $0x8011ddc0 +80103bd1: e8 4a 1f 00 00 call 80105b20 + return (char*)r; +80103bd6: 8b 45 f4 mov -0xc(%ebp),%eax + release(&kmem.lock); +80103bd9: 83 c4 10 add $0x10,%esp +} +80103bdc: c9 leave +80103bdd: c3 ret +80103bde: 66 90 xchg %ax,%ax + +80103be0 : + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103be0: ba 64 00 00 00 mov $0x64,%edx +80103be5: ec in (%dx),%al + normalmap, shiftmap, ctlmap, ctlmap + }; + uint st, data, c; + + st = inb(KBSTATP); + if ((st & KBS_DIB) == 0) { +80103be6: a8 01 test $0x1,%al +80103be8: 0f 84 c2 00 00 00 je 80103cb0 +int kbdgetc(void) { +80103bee: 55 push %ebp +80103bef: ba 60 00 00 00 mov $0x60,%edx +80103bf4: 89 e5 mov %esp,%ebp +80103bf6: 53 push %ebx +80103bf7: ec in (%dx),%al + return -1; + } + data = inb(KBDATAP); + + if (data == 0xE0) { + shift |= E0ESC; +80103bf8: 8b 1d fc dd 11 80 mov 0x8011ddfc,%ebx + data = inb(KBDATAP); +80103bfe: 0f b6 c8 movzbl %al,%ecx + if (data == 0xE0) { +80103c01: 3c e0 cmp $0xe0,%al +80103c03: 74 5b je 80103c60 + return 0; + } + else if (data & 0x80) { + // Key released + data = (shift & E0ESC ? data : data & 0x7F); +80103c05: 89 da mov %ebx,%edx +80103c07: 83 e2 40 and $0x40,%edx + else if (data & 0x80) { +80103c0a: 84 c0 test %al,%al +80103c0c: 78 62 js 80103c70 + shift &= ~(shiftcode[data] | E0ESC); + return 0; + } + else if (shift & E0ESC) { +80103c0e: 85 d2 test %edx,%edx +80103c10: 74 09 je 80103c1b + // Last character was an E0 escape; or with 0x80 + data |= 0x80; +80103c12: 83 c8 80 or $0xffffff80,%eax + shift &= ~E0ESC; +80103c15: 83 e3 bf and $0xffffffbf,%ebx + data |= 0x80; +80103c18: 0f b6 c8 movzbl %al,%ecx + } + + shift |= shiftcode[data]; +80103c1b: 0f b6 91 c0 8d 10 80 movzbl -0x7fef7240(%ecx),%edx + shift ^= togglecode[data]; +80103c22: 0f b6 81 c0 8c 10 80 movzbl -0x7fef7340(%ecx),%eax + shift |= shiftcode[data]; +80103c29: 09 da or %ebx,%edx + shift ^= togglecode[data]; +80103c2b: 31 c2 xor %eax,%edx + c = charcode[shift & (CTL | SHIFT)][data]; +80103c2d: 89 d0 mov %edx,%eax + shift ^= togglecode[data]; +80103c2f: 89 15 fc dd 11 80 mov %edx,0x8011ddfc + c = charcode[shift & (CTL | SHIFT)][data]; +80103c35: 83 e0 03 and $0x3,%eax + if (shift & CAPSLOCK) { +80103c38: 83 e2 08 and $0x8,%edx + c = charcode[shift & (CTL | SHIFT)][data]; +80103c3b: 8b 04 85 a0 8c 10 80 mov -0x7fef7360(,%eax,4),%eax +80103c42: 0f b6 04 08 movzbl (%eax,%ecx,1),%eax + if (shift & CAPSLOCK) { +80103c46: 74 0b je 80103c53 + if ('a' <= c && c <= 'z') { +80103c48: 8d 50 9f lea -0x61(%eax),%edx +80103c4b: 83 fa 19 cmp $0x19,%edx +80103c4e: 77 48 ja 80103c98 + c += 'A' - 'a'; +80103c50: 83 e8 20 sub $0x20,%eax + else if ('A' <= c && c <= 'Z') { + c += 'a' - 'A'; + } + } + return c; +} +80103c53: 8b 5d fc mov -0x4(%ebp),%ebx +80103c56: c9 leave +80103c57: c3 ret +80103c58: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103c5f: 90 nop + shift |= E0ESC; +80103c60: 83 cb 40 or $0x40,%ebx + return 0; +80103c63: 31 c0 xor %eax,%eax + shift |= E0ESC; +80103c65: 89 1d fc dd 11 80 mov %ebx,0x8011ddfc +} +80103c6b: 8b 5d fc mov -0x4(%ebp),%ebx +80103c6e: c9 leave +80103c6f: c3 ret + data = (shift & E0ESC ? data : data & 0x7F); +80103c70: 83 e0 7f and $0x7f,%eax +80103c73: 85 d2 test %edx,%edx +80103c75: 0f 44 c8 cmove %eax,%ecx + shift &= ~(shiftcode[data] | E0ESC); +80103c78: 0f b6 81 c0 8d 10 80 movzbl -0x7fef7240(%ecx),%eax +80103c7f: 83 c8 40 or $0x40,%eax +80103c82: 0f b6 c0 movzbl %al,%eax +80103c85: f7 d0 not %eax +80103c87: 21 d8 and %ebx,%eax +} +80103c89: 8b 5d fc mov -0x4(%ebp),%ebx + shift &= ~(shiftcode[data] | E0ESC); +80103c8c: a3 fc dd 11 80 mov %eax,0x8011ddfc + return 0; +80103c91: 31 c0 xor %eax,%eax +} +80103c93: c9 leave +80103c94: c3 ret +80103c95: 8d 76 00 lea 0x0(%esi),%esi + else if ('A' <= c && c <= 'Z') { +80103c98: 8d 48 bf lea -0x41(%eax),%ecx + c += 'a' - 'A'; +80103c9b: 8d 50 20 lea 0x20(%eax),%edx +} +80103c9e: 8b 5d fc mov -0x4(%ebp),%ebx +80103ca1: c9 leave + c += 'a' - 'A'; +80103ca2: 83 f9 1a cmp $0x1a,%ecx +80103ca5: 0f 42 c2 cmovb %edx,%eax +} +80103ca8: c3 ret +80103ca9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80103cb0: b8 ff ff ff ff mov $0xffffffff,%eax +} +80103cb5: c3 ret +80103cb6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103cbd: 8d 76 00 lea 0x0(%esi),%esi + +80103cc0 : + +void kbdintr(void) { +80103cc0: 55 push %ebp +80103cc1: 89 e5 mov %esp,%ebp +80103cc3: 83 ec 14 sub $0x14,%esp + consoleintr(kbdgetc); +80103cc6: 68 e0 3b 10 80 push $0x80103be0 +80103ccb: e8 60 d8 ff ff call 80101530 +} +80103cd0: 83 c4 10 add $0x10,%esp +80103cd3: c9 leave +80103cd4: c3 ret +80103cd5: 66 90 xchg %ax,%ax +80103cd7: 66 90 xchg %ax,%ax +80103cd9: 66 90 xchg %ax,%ax +80103cdb: 66 90 xchg %ax,%ax +80103cdd: 66 90 xchg %ax,%ax +80103cdf: 90 nop + +80103ce0 : + lapic[index] = value; + lapic[ID]; // wait for write to finish, by reading +} + +void lapicinit(void) { + if (!lapic) { +80103ce0: a1 00 de 11 80 mov 0x8011de00,%eax +80103ce5: 85 c0 test %eax,%eax +80103ce7: 0f 84 cb 00 00 00 je 80103db8 + lapic[index] = value; +80103ced: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) +80103cf4: 01 00 00 + lapic[ID]; // wait for write to finish, by reading +80103cf7: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103cfa: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) +80103d01: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103d04: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d07: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) +80103d0e: 00 02 00 + lapic[ID]; // wait for write to finish, by reading +80103d11: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d14: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) +80103d1b: 96 98 00 + lapic[ID]; // wait for write to finish, by reading +80103d1e: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d21: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) +80103d28: 00 01 00 + lapic[ID]; // wait for write to finish, by reading +80103d2b: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d2e: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) +80103d35: 00 01 00 + lapic[ID]; // wait for write to finish, by reading +80103d38: 8b 50 20 mov 0x20(%eax),%edx + lapicw(LINT0, MASKED); + lapicw(LINT1, MASKED); + + // Disable performance counter overflow interrupts + // on machines that provide that interrupt entry. + if (((lapic[VER] >> 16) & 0xFF) >= 4) { +80103d3b: 8b 50 30 mov 0x30(%eax),%edx +80103d3e: c1 ea 10 shr $0x10,%edx +80103d41: 81 e2 fc 00 00 00 and $0xfc,%edx +80103d47: 75 77 jne 80103dc0 + lapic[index] = value; +80103d49: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) +80103d50: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103d53: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d56: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) +80103d5d: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103d60: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d63: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) +80103d6a: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103d6d: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d70: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) +80103d77: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103d7a: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d7d: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) +80103d84: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103d87: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103d8a: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) +80103d91: 85 08 00 + lapic[ID]; // wait for write to finish, by reading +80103d94: 8b 50 20 mov 0x20(%eax),%edx +80103d97: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103d9e: 66 90 xchg %ax,%ax + lapicw(EOI, 0); + + // Send an Init Level De-Assert to synchronise arbitration ID's. + lapicw(ICRHI, 0); + lapicw(ICRLO, BCAST | INIT | LEVEL); + while (lapic[ICRLO] & DELIVS) { +80103da0: 8b 90 00 03 00 00 mov 0x300(%eax),%edx +80103da6: 80 e6 10 and $0x10,%dh +80103da9: 75 f5 jne 80103da0 + lapic[index] = value; +80103dab: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) +80103db2: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103db5: 8b 40 20 mov 0x20(%eax),%eax + ; + } + + // Enable interrupts on the APIC (but not on the processor). + lapicw(TPR, 0); +} +80103db8: c3 ret +80103db9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + lapic[index] = value; +80103dc0: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) +80103dc7: 00 01 00 + lapic[ID]; // wait for write to finish, by reading +80103dca: 8b 50 20 mov 0x20(%eax),%edx +} +80103dcd: e9 77 ff ff ff jmp 80103d49 +80103dd2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103dd9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80103de0 : + +int lapicid(void) { + if (!lapic) { +80103de0: a1 00 de 11 80 mov 0x8011de00,%eax +80103de5: 85 c0 test %eax,%eax +80103de7: 74 07 je 80103df0 + return 0; + } + return lapic[ID] >> 24; +80103de9: 8b 40 20 mov 0x20(%eax),%eax +80103dec: c1 e8 18 shr $0x18,%eax +80103def: c3 ret + return 0; +80103df0: 31 c0 xor %eax,%eax +} +80103df2: c3 ret +80103df3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103dfa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80103e00 : + +// Acknowledge interrupt. +void lapiceoi(void) { + if (lapic) { +80103e00: a1 00 de 11 80 mov 0x8011de00,%eax +80103e05: 85 c0 test %eax,%eax +80103e07: 74 0d je 80103e16 + lapic[index] = value; +80103e09: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) +80103e10: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80103e13: 8b 40 20 mov 0x20(%eax),%eax + lapicw(EOI, 0); + } +} +80103e16: c3 ret +80103e17: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103e1e: 66 90 xchg %ax,%ax + +80103e20 : + +// Spin for a given number of microseconds. +// On real hardware would want to tune this dynamically. +void microdelay(int us) { +} +80103e20: c3 ret +80103e21: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103e28: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103e2f: 90 nop + +80103e30 : +#define CMOS_PORT 0x70 +#define CMOS_RETURN 0x71 + +// Start additional processor running entry code at addr. +// See Appendix B of MultiProcessor Specification. +void lapicstartap(uchar apicid, uint addr) { +80103e30: 55 push %ebp + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103e31: b8 0f 00 00 00 mov $0xf,%eax +80103e36: ba 70 00 00 00 mov $0x70,%edx +80103e3b: 89 e5 mov %esp,%ebp +80103e3d: 53 push %ebx +80103e3e: 8b 4d 0c mov 0xc(%ebp),%ecx +80103e41: 8b 5d 08 mov 0x8(%ebp),%ebx +80103e44: ee out %al,(%dx) +80103e45: b8 0a 00 00 00 mov $0xa,%eax +80103e4a: ba 71 00 00 00 mov $0x71,%edx +80103e4f: ee out %al,(%dx) + // and the warm reset vector (DWORD based at 40:67) to point at + // the AP startup code prior to the [universal startup algorithm]." + outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code + outb(CMOS_PORT + 1, 0x0A); + wrv = (ushort*)P2V((0x40 << 4 | 0x67)); // Warm reset vector + wrv[0] = 0; +80103e50: 31 c0 xor %eax,%eax + wrv[1] = addr >> 4; + + // "Universal startup algorithm." + // Send INIT (level-triggered) interrupt to reset other CPU. + lapicw(ICRHI, apicid << 24); +80103e52: c1 e3 18 shl $0x18,%ebx + wrv[0] = 0; +80103e55: 66 a3 67 04 00 80 mov %ax,0x80000467 + wrv[1] = addr >> 4; +80103e5b: 89 c8 mov %ecx,%eax + // when it is in the halted state due to an INIT. So the second + // should be ignored, but it is part of the official Intel algorithm. + // Bochs complains about the second one. Too bad for Bochs. + for (i = 0; i < 2; i++) { + lapicw(ICRHI, apicid << 24); + lapicw(ICRLO, STARTUP | (addr >> 12)); +80103e5d: c1 e9 0c shr $0xc,%ecx + lapicw(ICRHI, apicid << 24); +80103e60: 89 da mov %ebx,%edx + wrv[1] = addr >> 4; +80103e62: c1 e8 04 shr $0x4,%eax + lapicw(ICRLO, STARTUP | (addr >> 12)); +80103e65: 80 cd 06 or $0x6,%ch + wrv[1] = addr >> 4; +80103e68: 66 a3 69 04 00 80 mov %ax,0x80000469 + lapic[index] = value; +80103e6e: a1 00 de 11 80 mov 0x8011de00,%eax +80103e73: 89 98 10 03 00 00 mov %ebx,0x310(%eax) + lapic[ID]; // wait for write to finish, by reading +80103e79: 8b 58 20 mov 0x20(%eax),%ebx + lapic[index] = value; +80103e7c: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) +80103e83: c5 00 00 + lapic[ID]; // wait for write to finish, by reading +80103e86: 8b 58 20 mov 0x20(%eax),%ebx + lapic[index] = value; +80103e89: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) +80103e90: 85 00 00 + lapic[ID]; // wait for write to finish, by reading +80103e93: 8b 58 20 mov 0x20(%eax),%ebx + lapic[index] = value; +80103e96: 89 90 10 03 00 00 mov %edx,0x310(%eax) + lapic[ID]; // wait for write to finish, by reading +80103e9c: 8b 58 20 mov 0x20(%eax),%ebx + lapic[index] = value; +80103e9f: 89 88 00 03 00 00 mov %ecx,0x300(%eax) + lapic[ID]; // wait for write to finish, by reading +80103ea5: 8b 58 20 mov 0x20(%eax),%ebx + lapic[index] = value; +80103ea8: 89 90 10 03 00 00 mov %edx,0x310(%eax) + lapic[ID]; // wait for write to finish, by reading +80103eae: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80103eb1: 89 88 00 03 00 00 mov %ecx,0x300(%eax) + lapic[ID]; // wait for write to finish, by reading +80103eb7: 8b 40 20 mov 0x20(%eax),%eax + microdelay(200); + } +} +80103eba: 8b 5d fc mov -0x4(%ebp),%ebx +80103ebd: c9 leave +80103ebe: c3 ret +80103ebf: 90 nop + +80103ec0 : + r->month = cmos_read(MONTH); + r->year = cmos_read(YEAR); +} + +// qemu seems to use 24-hour GWT and the values are BCD encoded +void cmostime(struct rtcdate *r) { +80103ec0: 55 push %ebp +80103ec1: b8 0b 00 00 00 mov $0xb,%eax +80103ec6: ba 70 00 00 00 mov $0x70,%edx +80103ecb: 89 e5 mov %esp,%ebp +80103ecd: 57 push %edi +80103ece: 56 push %esi +80103ecf: 53 push %ebx +80103ed0: 83 ec 4c sub $0x4c,%esp +80103ed3: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103ed4: ba 71 00 00 00 mov $0x71,%edx +80103ed9: ec in (%dx),%al + struct rtcdate t1, t2; + int sb, bcd; + + sb = cmos_read(CMOS_STATB); + + bcd = (sb & (1 << 2)) == 0; +80103eda: 83 e0 04 and $0x4,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103edd: bb 70 00 00 00 mov $0x70,%ebx +80103ee2: 88 45 b3 mov %al,-0x4d(%ebp) +80103ee5: 8d 76 00 lea 0x0(%esi),%esi +80103ee8: 31 c0 xor %eax,%eax +80103eea: 89 da mov %ebx,%edx +80103eec: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103eed: b9 71 00 00 00 mov $0x71,%ecx +80103ef2: 89 ca mov %ecx,%edx +80103ef4: ec in (%dx),%al +80103ef5: 88 45 b7 mov %al,-0x49(%ebp) + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103ef8: 89 da mov %ebx,%edx +80103efa: b8 02 00 00 00 mov $0x2,%eax +80103eff: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f00: 89 ca mov %ecx,%edx +80103f02: ec in (%dx),%al +80103f03: 88 45 b6 mov %al,-0x4a(%ebp) + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f06: 89 da mov %ebx,%edx +80103f08: b8 04 00 00 00 mov $0x4,%eax +80103f0d: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f0e: 89 ca mov %ecx,%edx +80103f10: ec in (%dx),%al +80103f11: 88 45 b5 mov %al,-0x4b(%ebp) + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f14: 89 da mov %ebx,%edx +80103f16: b8 07 00 00 00 mov $0x7,%eax +80103f1b: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f1c: 89 ca mov %ecx,%edx +80103f1e: ec in (%dx),%al +80103f1f: 88 45 b4 mov %al,-0x4c(%ebp) + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f22: 89 da mov %ebx,%edx +80103f24: b8 08 00 00 00 mov $0x8,%eax +80103f29: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f2a: 89 ca mov %ecx,%edx +80103f2c: ec in (%dx),%al +80103f2d: 89 c7 mov %eax,%edi + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f2f: 89 da mov %ebx,%edx +80103f31: b8 09 00 00 00 mov $0x9,%eax +80103f36: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f37: 89 ca mov %ecx,%edx +80103f39: ec in (%dx),%al +80103f3a: 89 c6 mov %eax,%esi + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f3c: 89 da mov %ebx,%edx +80103f3e: b8 0a 00 00 00 mov $0xa,%eax +80103f43: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f44: 89 ca mov %ecx,%edx +80103f46: ec in (%dx),%al + + // make sure CMOS doesn't modify time while we read it + for (;;) { + fill_rtcdate(&t1); + if (cmos_read(CMOS_STATA) & CMOS_UIP) { +80103f47: 84 c0 test %al,%al +80103f49: 78 9d js 80103ee8 + return inb(CMOS_RETURN); +80103f4b: 0f b6 45 b7 movzbl -0x49(%ebp),%eax +80103f4f: 89 fa mov %edi,%edx +80103f51: 0f b6 fa movzbl %dl,%edi +80103f54: 89 f2 mov %esi,%edx +80103f56: 89 45 b8 mov %eax,-0x48(%ebp) +80103f59: 0f b6 45 b6 movzbl -0x4a(%ebp),%eax +80103f5d: 0f b6 f2 movzbl %dl,%esi + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f60: 89 da mov %ebx,%edx +80103f62: 89 7d c8 mov %edi,-0x38(%ebp) +80103f65: 89 45 bc mov %eax,-0x44(%ebp) +80103f68: 0f b6 45 b5 movzbl -0x4b(%ebp),%eax +80103f6c: 89 75 cc mov %esi,-0x34(%ebp) +80103f6f: 89 45 c0 mov %eax,-0x40(%ebp) +80103f72: 0f b6 45 b4 movzbl -0x4c(%ebp),%eax +80103f76: 89 45 c4 mov %eax,-0x3c(%ebp) +80103f79: 31 c0 xor %eax,%eax +80103f7b: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f7c: 89 ca mov %ecx,%edx +80103f7e: ec in (%dx),%al +80103f7f: 0f b6 c0 movzbl %al,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f82: 89 da mov %ebx,%edx +80103f84: 89 45 d0 mov %eax,-0x30(%ebp) +80103f87: b8 02 00 00 00 mov $0x2,%eax +80103f8c: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f8d: 89 ca mov %ecx,%edx +80103f8f: ec in (%dx),%al +80103f90: 0f b6 c0 movzbl %al,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103f93: 89 da mov %ebx,%edx +80103f95: 89 45 d4 mov %eax,-0x2c(%ebp) +80103f98: b8 04 00 00 00 mov $0x4,%eax +80103f9d: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103f9e: 89 ca mov %ecx,%edx +80103fa0: ec in (%dx),%al +80103fa1: 0f b6 c0 movzbl %al,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103fa4: 89 da mov %ebx,%edx +80103fa6: 89 45 d8 mov %eax,-0x28(%ebp) +80103fa9: b8 07 00 00 00 mov $0x7,%eax +80103fae: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103faf: 89 ca mov %ecx,%edx +80103fb1: ec in (%dx),%al +80103fb2: 0f b6 c0 movzbl %al,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103fb5: 89 da mov %ebx,%edx +80103fb7: 89 45 dc mov %eax,-0x24(%ebp) +80103fba: b8 08 00 00 00 mov $0x8,%eax +80103fbf: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103fc0: 89 ca mov %ecx,%edx +80103fc2: ec in (%dx),%al +80103fc3: 0f b6 c0 movzbl %al,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80103fc6: 89 da mov %ebx,%edx +80103fc8: 89 45 e0 mov %eax,-0x20(%ebp) +80103fcb: b8 09 00 00 00 mov $0x9,%eax +80103fd0: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80103fd1: 89 ca mov %ecx,%edx +80103fd3: ec in (%dx),%al +80103fd4: 0f b6 c0 movzbl %al,%eax + continue; + } + fill_rtcdate(&t2); + if (memcmp(&t1, &t2, sizeof(t1)) == 0) { +80103fd7: 83 ec 04 sub $0x4,%esp + return inb(CMOS_RETURN); +80103fda: 89 45 e4 mov %eax,-0x1c(%ebp) + if (memcmp(&t1, &t2, sizeof(t1)) == 0) { +80103fdd: 8d 45 d0 lea -0x30(%ebp),%eax +80103fe0: 6a 18 push $0x18 +80103fe2: 50 push %eax +80103fe3: 8d 45 b8 lea -0x48(%ebp),%eax +80103fe6: 50 push %eax +80103fe7: e8 a4 1c 00 00 call 80105c90 +80103fec: 83 c4 10 add $0x10,%esp +80103fef: 85 c0 test %eax,%eax +80103ff1: 0f 85 f1 fe ff ff jne 80103ee8 + break; + } + } + + // convert + if (bcd) { +80103ff7: 80 7d b3 00 cmpb $0x0,-0x4d(%ebp) +80103ffb: 75 78 jne 80104075 +#define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) + CONV(second); +80103ffd: 8b 45 b8 mov -0x48(%ebp),%eax +80104000: 89 c2 mov %eax,%edx +80104002: 83 e0 0f and $0xf,%eax +80104005: c1 ea 04 shr $0x4,%edx +80104008: 8d 14 92 lea (%edx,%edx,4),%edx +8010400b: 8d 04 50 lea (%eax,%edx,2),%eax +8010400e: 89 45 b8 mov %eax,-0x48(%ebp) + CONV(minute); +80104011: 8b 45 bc mov -0x44(%ebp),%eax +80104014: 89 c2 mov %eax,%edx +80104016: 83 e0 0f and $0xf,%eax +80104019: c1 ea 04 shr $0x4,%edx +8010401c: 8d 14 92 lea (%edx,%edx,4),%edx +8010401f: 8d 04 50 lea (%eax,%edx,2),%eax +80104022: 89 45 bc mov %eax,-0x44(%ebp) + CONV(hour ); +80104025: 8b 45 c0 mov -0x40(%ebp),%eax +80104028: 89 c2 mov %eax,%edx +8010402a: 83 e0 0f and $0xf,%eax +8010402d: c1 ea 04 shr $0x4,%edx +80104030: 8d 14 92 lea (%edx,%edx,4),%edx +80104033: 8d 04 50 lea (%eax,%edx,2),%eax +80104036: 89 45 c0 mov %eax,-0x40(%ebp) + CONV(day ); +80104039: 8b 45 c4 mov -0x3c(%ebp),%eax +8010403c: 89 c2 mov %eax,%edx +8010403e: 83 e0 0f and $0xf,%eax +80104041: c1 ea 04 shr $0x4,%edx +80104044: 8d 14 92 lea (%edx,%edx,4),%edx +80104047: 8d 04 50 lea (%eax,%edx,2),%eax +8010404a: 89 45 c4 mov %eax,-0x3c(%ebp) + CONV(month ); +8010404d: 8b 45 c8 mov -0x38(%ebp),%eax +80104050: 89 c2 mov %eax,%edx +80104052: 83 e0 0f and $0xf,%eax +80104055: c1 ea 04 shr $0x4,%edx +80104058: 8d 14 92 lea (%edx,%edx,4),%edx +8010405b: 8d 04 50 lea (%eax,%edx,2),%eax +8010405e: 89 45 c8 mov %eax,-0x38(%ebp) + CONV(year ); +80104061: 8b 45 cc mov -0x34(%ebp),%eax +80104064: 89 c2 mov %eax,%edx +80104066: 83 e0 0f and $0xf,%eax +80104069: c1 ea 04 shr $0x4,%edx +8010406c: 8d 14 92 lea (%edx,%edx,4),%edx +8010406f: 8d 04 50 lea (%eax,%edx,2),%eax +80104072: 89 45 cc mov %eax,-0x34(%ebp) +#undef CONV + } + + *r = t1; +80104075: 8b 75 08 mov 0x8(%ebp),%esi +80104078: 8b 45 b8 mov -0x48(%ebp),%eax +8010407b: 89 06 mov %eax,(%esi) +8010407d: 8b 45 bc mov -0x44(%ebp),%eax +80104080: 89 46 04 mov %eax,0x4(%esi) +80104083: 8b 45 c0 mov -0x40(%ebp),%eax +80104086: 89 46 08 mov %eax,0x8(%esi) +80104089: 8b 45 c4 mov -0x3c(%ebp),%eax +8010408c: 89 46 0c mov %eax,0xc(%esi) +8010408f: 8b 45 c8 mov -0x38(%ebp),%eax +80104092: 89 46 10 mov %eax,0x10(%esi) +80104095: 8b 45 cc mov -0x34(%ebp),%eax +80104098: 89 46 14 mov %eax,0x14(%esi) + r->year += 2000; +8010409b: 81 46 14 d0 07 00 00 addl $0x7d0,0x14(%esi) +} +801040a2: 8d 65 f4 lea -0xc(%ebp),%esp +801040a5: 5b pop %ebx +801040a6: 5e pop %esi +801040a7: 5f pop %edi +801040a8: 5d pop %ebp +801040a9: c3 ret +801040aa: 66 90 xchg %ax,%ax +801040ac: 66 90 xchg %ax,%ax +801040ae: 66 90 xchg %ax,%ax + +801040b0 : +static void +install_trans(void) +{ + int tail; + + for (tail = 0; tail < log.lh.n; tail++) { +801040b0: 8b 0d 68 de 11 80 mov 0x8011de68,%ecx +801040b6: 85 c9 test %ecx,%ecx +801040b8: 0f 8e 8a 00 00 00 jle 80104148 +{ +801040be: 55 push %ebp +801040bf: 89 e5 mov %esp,%ebp +801040c1: 57 push %edi + for (tail = 0; tail < log.lh.n; tail++) { +801040c2: 31 ff xor %edi,%edi +{ +801040c4: 56 push %esi +801040c5: 53 push %ebx +801040c6: 83 ec 0c sub $0xc,%esp +801040c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block +801040d0: a1 54 de 11 80 mov 0x8011de54,%eax +801040d5: 83 ec 08 sub $0x8,%esp +801040d8: 01 f8 add %edi,%eax +801040da: 83 c0 01 add $0x1,%eax +801040dd: 50 push %eax +801040de: ff 35 64 de 11 80 push 0x8011de64 +801040e4: e8 e7 bf ff ff call 801000d0 +801040e9: 89 c6 mov %eax,%esi + struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst +801040eb: 58 pop %eax +801040ec: 5a pop %edx +801040ed: ff 34 bd 6c de 11 80 push -0x7fee2194(,%edi,4) +801040f4: ff 35 64 de 11 80 push 0x8011de64 + for (tail = 0; tail < log.lh.n; tail++) { +801040fa: 83 c7 01 add $0x1,%edi + struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst +801040fd: e8 ce bf ff ff call 801000d0 + memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst +80104102: 83 c4 0c add $0xc,%esp + struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst +80104105: 89 c3 mov %eax,%ebx + memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst +80104107: 8d 46 5c lea 0x5c(%esi),%eax +8010410a: 68 00 02 00 00 push $0x200 +8010410f: 50 push %eax +80104110: 8d 43 5c lea 0x5c(%ebx),%eax +80104113: 50 push %eax +80104114: e8 c7 1b 00 00 call 80105ce0 + bwrite(dbuf); // write dst to disk +80104119: 89 1c 24 mov %ebx,(%esp) +8010411c: e8 8f c0 ff ff call 801001b0 + brelse(lbuf); +80104121: 89 34 24 mov %esi,(%esp) +80104124: e8 c7 c0 ff ff call 801001f0 + brelse(dbuf); +80104129: 89 1c 24 mov %ebx,(%esp) +8010412c: e8 bf c0 ff ff call 801001f0 + for (tail = 0; tail < log.lh.n; tail++) { +80104131: 83 c4 10 add $0x10,%esp +80104134: 39 3d 68 de 11 80 cmp %edi,0x8011de68 +8010413a: 7f 94 jg 801040d0 + } +} +8010413c: 8d 65 f4 lea -0xc(%ebp),%esp +8010413f: 5b pop %ebx +80104140: 5e pop %esi +80104141: 5f pop %edi +80104142: 5d pop %ebp +80104143: c3 ret +80104144: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104148: c3 ret +80104149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80104150 : +// Write in-memory log header to disk. +// This is the true point at which the +// current transaction commits. +static void +write_head(void) +{ +80104150: 55 push %ebp +80104151: 89 e5 mov %esp,%ebp +80104153: 53 push %ebx +80104154: 83 ec 0c sub $0xc,%esp + struct buf *buf = bread(log.dev, log.start); +80104157: ff 35 54 de 11 80 push 0x8011de54 +8010415d: ff 35 64 de 11 80 push 0x8011de64 +80104163: e8 68 bf ff ff call 801000d0 + struct logheader *hb = (struct logheader *) (buf->data); + int i; + hb->n = log.lh.n; + for (i = 0; i < log.lh.n; i++) { +80104168: 83 c4 10 add $0x10,%esp + struct buf *buf = bread(log.dev, log.start); +8010416b: 89 c3 mov %eax,%ebx + hb->n = log.lh.n; +8010416d: a1 68 de 11 80 mov 0x8011de68,%eax +80104172: 89 43 5c mov %eax,0x5c(%ebx) + for (i = 0; i < log.lh.n; i++) { +80104175: 85 c0 test %eax,%eax +80104177: 7e 19 jle 80104192 +80104179: 31 d2 xor %edx,%edx +8010417b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010417f: 90 nop + hb->block[i] = log.lh.block[i]; +80104180: 8b 0c 95 6c de 11 80 mov -0x7fee2194(,%edx,4),%ecx +80104187: 89 4c 93 60 mov %ecx,0x60(%ebx,%edx,4) + for (i = 0; i < log.lh.n; i++) { +8010418b: 83 c2 01 add $0x1,%edx +8010418e: 39 d0 cmp %edx,%eax +80104190: 75 ee jne 80104180 + } + bwrite(buf); +80104192: 83 ec 0c sub $0xc,%esp +80104195: 53 push %ebx +80104196: e8 15 c0 ff ff call 801001b0 + brelse(buf); +8010419b: 89 1c 24 mov %ebx,(%esp) +8010419e: e8 4d c0 ff ff call 801001f0 +} +801041a3: 8b 5d fc mov -0x4(%ebp),%ebx +801041a6: 83 c4 10 add $0x10,%esp +801041a9: c9 leave +801041aa: c3 ret +801041ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801041af: 90 nop + +801041b0 : +{ +801041b0: 55 push %ebp +801041b1: 89 e5 mov %esp,%ebp +801041b3: 53 push %ebx +801041b4: 83 ec 2c sub $0x2c,%esp +801041b7: 8b 5d 08 mov 0x8(%ebp),%ebx + initlock(&log.lock, "log"); +801041ba: 68 c0 8e 10 80 push $0x80108ec0 +801041bf: 68 20 de 11 80 push $0x8011de20 +801041c4: e8 e7 17 00 00 call 801059b0 + readsb(dev, &sb); +801041c9: 58 pop %eax +801041ca: 8d 45 dc lea -0x24(%ebp),%eax +801041cd: 5a pop %edx +801041ce: 50 push %eax +801041cf: 53 push %ebx +801041d0: e8 3b e8 ff ff call 80102a10 + log.start = sb.logstart; +801041d5: 8b 45 ec mov -0x14(%ebp),%eax + struct buf *buf = bread(log.dev, log.start); +801041d8: 59 pop %ecx + log.dev = dev; +801041d9: 89 1d 64 de 11 80 mov %ebx,0x8011de64 + log.size = sb.nlog; +801041df: 8b 55 e8 mov -0x18(%ebp),%edx + log.start = sb.logstart; +801041e2: a3 54 de 11 80 mov %eax,0x8011de54 + log.size = sb.nlog; +801041e7: 89 15 58 de 11 80 mov %edx,0x8011de58 + struct buf *buf = bread(log.dev, log.start); +801041ed: 5a pop %edx +801041ee: 50 push %eax +801041ef: 53 push %ebx +801041f0: e8 db be ff ff call 801000d0 + for (i = 0; i < log.lh.n; i++) { +801041f5: 83 c4 10 add $0x10,%esp + log.lh.n = lh->n; +801041f8: 8b 58 5c mov 0x5c(%eax),%ebx +801041fb: 89 1d 68 de 11 80 mov %ebx,0x8011de68 + for (i = 0; i < log.lh.n; i++) { +80104201: 85 db test %ebx,%ebx +80104203: 7e 1d jle 80104222 +80104205: 31 d2 xor %edx,%edx +80104207: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010420e: 66 90 xchg %ax,%ax + log.lh.block[i] = lh->block[i]; +80104210: 8b 4c 90 60 mov 0x60(%eax,%edx,4),%ecx +80104214: 89 0c 95 6c de 11 80 mov %ecx,-0x7fee2194(,%edx,4) + for (i = 0; i < log.lh.n; i++) { +8010421b: 83 c2 01 add $0x1,%edx +8010421e: 39 d3 cmp %edx,%ebx +80104220: 75 ee jne 80104210 + brelse(buf); +80104222: 83 ec 0c sub $0xc,%esp +80104225: 50 push %eax +80104226: e8 c5 bf ff ff call 801001f0 + +static void +recover_from_log(void) +{ + read_head(); + install_trans(); // if committed, copy from log to disk +8010422b: e8 80 fe ff ff call 801040b0 + log.lh.n = 0; +80104230: c7 05 68 de 11 80 00 movl $0x0,0x8011de68 +80104237: 00 00 00 + write_head(); // clear the log +8010423a: e8 11 ff ff ff call 80104150 +} +8010423f: 8b 5d fc mov -0x4(%ebp),%ebx +80104242: 83 c4 10 add $0x10,%esp +80104245: c9 leave +80104246: c3 ret +80104247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010424e: 66 90 xchg %ax,%ax + +80104250 : +} + +// called at the start of each FS system call. +void +begin_op(void) +{ +80104250: 55 push %ebp +80104251: 89 e5 mov %esp,%ebp +80104253: 83 ec 14 sub $0x14,%esp + acquire(&log.lock); +80104256: 68 20 de 11 80 push $0x8011de20 +8010425b: e8 20 19 00 00 call 80105b80 +80104260: 83 c4 10 add $0x10,%esp +80104263: eb 18 jmp 8010427d +80104265: 8d 76 00 lea 0x0(%esi),%esi + while(1){ + if(log.committing){ + sleep(&log, &log.lock); +80104268: 83 ec 08 sub $0x8,%esp +8010426b: 68 20 de 11 80 push $0x8011de20 +80104270: 68 20 de 11 80 push $0x8011de20 +80104275: e8 66 13 00 00 call 801055e0 +8010427a: 83 c4 10 add $0x10,%esp + if(log.committing){ +8010427d: a1 60 de 11 80 mov 0x8011de60,%eax +80104282: 85 c0 test %eax,%eax +80104284: 75 e2 jne 80104268 + } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ +80104286: a1 5c de 11 80 mov 0x8011de5c,%eax +8010428b: 8b 15 68 de 11 80 mov 0x8011de68,%edx +80104291: 83 c0 01 add $0x1,%eax +80104294: 8d 0c 80 lea (%eax,%eax,4),%ecx +80104297: 8d 14 4a lea (%edx,%ecx,2),%edx +8010429a: 83 fa 1e cmp $0x1e,%edx +8010429d: 7f c9 jg 80104268 + // this op might exhaust log space; wait for commit. + sleep(&log, &log.lock); + } else { + log.outstanding += 1; + release(&log.lock); +8010429f: 83 ec 0c sub $0xc,%esp + log.outstanding += 1; +801042a2: a3 5c de 11 80 mov %eax,0x8011de5c + release(&log.lock); +801042a7: 68 20 de 11 80 push $0x8011de20 +801042ac: e8 6f 18 00 00 call 80105b20 + break; + } + } +} +801042b1: 83 c4 10 add $0x10,%esp +801042b4: c9 leave +801042b5: c3 ret +801042b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801042bd: 8d 76 00 lea 0x0(%esi),%esi + +801042c0 : + +// called at the end of each FS system call. +// commits if this was the last outstanding operation. +void +end_op(void) +{ +801042c0: 55 push %ebp +801042c1: 89 e5 mov %esp,%ebp +801042c3: 57 push %edi +801042c4: 56 push %esi +801042c5: 53 push %ebx +801042c6: 83 ec 18 sub $0x18,%esp + int do_commit = 0; + + acquire(&log.lock); +801042c9: 68 20 de 11 80 push $0x8011de20 +801042ce: e8 ad 18 00 00 call 80105b80 + log.outstanding -= 1; +801042d3: a1 5c de 11 80 mov 0x8011de5c,%eax + if(log.committing) +801042d8: 8b 35 60 de 11 80 mov 0x8011de60,%esi +801042de: 83 c4 10 add $0x10,%esp + log.outstanding -= 1; +801042e1: 8d 58 ff lea -0x1(%eax),%ebx +801042e4: 89 1d 5c de 11 80 mov %ebx,0x8011de5c + if(log.committing) +801042ea: 85 f6 test %esi,%esi +801042ec: 0f 85 22 01 00 00 jne 80104414 + panic("log.committing"); + if(log.outstanding == 0){ +801042f2: 85 db test %ebx,%ebx +801042f4: 0f 85 f6 00 00 00 jne 801043f0 + do_commit = 1; + log.committing = 1; +801042fa: c7 05 60 de 11 80 01 movl $0x1,0x8011de60 +80104301: 00 00 00 + // begin_op() may be waiting for log space, + // and decrementing log.outstanding has decreased + // the amount of reserved space. + wakeup(&log); + } + release(&log.lock); +80104304: 83 ec 0c sub $0xc,%esp +80104307: 68 20 de 11 80 push $0x8011de20 +8010430c: e8 0f 18 00 00 call 80105b20 +} + +static void +commit() +{ + if (log.lh.n > 0) { +80104311: 8b 0d 68 de 11 80 mov 0x8011de68,%ecx +80104317: 83 c4 10 add $0x10,%esp +8010431a: 85 c9 test %ecx,%ecx +8010431c: 7f 42 jg 80104360 + acquire(&log.lock); +8010431e: 83 ec 0c sub $0xc,%esp +80104321: 68 20 de 11 80 push $0x8011de20 +80104326: e8 55 18 00 00 call 80105b80 + wakeup(&log); +8010432b: c7 04 24 20 de 11 80 movl $0x8011de20,(%esp) + log.committing = 0; +80104332: c7 05 60 de 11 80 00 movl $0x0,0x8011de60 +80104339: 00 00 00 + wakeup(&log); +8010433c: e8 5f 13 00 00 call 801056a0 + release(&log.lock); +80104341: c7 04 24 20 de 11 80 movl $0x8011de20,(%esp) +80104348: e8 d3 17 00 00 call 80105b20 +8010434d: 83 c4 10 add $0x10,%esp +} +80104350: 8d 65 f4 lea -0xc(%ebp),%esp +80104353: 5b pop %ebx +80104354: 5e pop %esi +80104355: 5f pop %edi +80104356: 5d pop %ebp +80104357: c3 ret +80104358: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010435f: 90 nop + struct buf *to = bread(log.dev, log.start+tail+1); // log block +80104360: a1 54 de 11 80 mov 0x8011de54,%eax +80104365: 83 ec 08 sub $0x8,%esp +80104368: 01 d8 add %ebx,%eax +8010436a: 83 c0 01 add $0x1,%eax +8010436d: 50 push %eax +8010436e: ff 35 64 de 11 80 push 0x8011de64 +80104374: e8 57 bd ff ff call 801000d0 +80104379: 89 c6 mov %eax,%esi + struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block +8010437b: 58 pop %eax +8010437c: 5a pop %edx +8010437d: ff 34 9d 6c de 11 80 push -0x7fee2194(,%ebx,4) +80104384: ff 35 64 de 11 80 push 0x8011de64 + for (tail = 0; tail < log.lh.n; tail++) { +8010438a: 83 c3 01 add $0x1,%ebx + struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block +8010438d: e8 3e bd ff ff call 801000d0 + memmove(to->data, from->data, BSIZE); +80104392: 83 c4 0c add $0xc,%esp + struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block +80104395: 89 c7 mov %eax,%edi + memmove(to->data, from->data, BSIZE); +80104397: 8d 40 5c lea 0x5c(%eax),%eax +8010439a: 68 00 02 00 00 push $0x200 +8010439f: 50 push %eax +801043a0: 8d 46 5c lea 0x5c(%esi),%eax +801043a3: 50 push %eax +801043a4: e8 37 19 00 00 call 80105ce0 + bwrite(to); // write the log +801043a9: 89 34 24 mov %esi,(%esp) +801043ac: e8 ff bd ff ff call 801001b0 + brelse(from); +801043b1: 89 3c 24 mov %edi,(%esp) +801043b4: e8 37 be ff ff call 801001f0 + brelse(to); +801043b9: 89 34 24 mov %esi,(%esp) +801043bc: e8 2f be ff ff call 801001f0 + for (tail = 0; tail < log.lh.n; tail++) { +801043c1: 83 c4 10 add $0x10,%esp +801043c4: 3b 1d 68 de 11 80 cmp 0x8011de68,%ebx +801043ca: 7c 94 jl 80104360 + write_log(); // Write modified blocks from cache to log + write_head(); // Write header to disk -- the real commit +801043cc: e8 7f fd ff ff call 80104150 + install_trans(); // Now install writes to home locations +801043d1: e8 da fc ff ff call 801040b0 + log.lh.n = 0; +801043d6: c7 05 68 de 11 80 00 movl $0x0,0x8011de68 +801043dd: 00 00 00 + write_head(); // Erase the transaction from the log +801043e0: e8 6b fd ff ff call 80104150 +801043e5: e9 34 ff ff ff jmp 8010431e +801043ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + wakeup(&log); +801043f0: 83 ec 0c sub $0xc,%esp +801043f3: 68 20 de 11 80 push $0x8011de20 +801043f8: e8 a3 12 00 00 call 801056a0 + release(&log.lock); +801043fd: c7 04 24 20 de 11 80 movl $0x8011de20,(%esp) +80104404: e8 17 17 00 00 call 80105b20 +80104409: 83 c4 10 add $0x10,%esp +} +8010440c: 8d 65 f4 lea -0xc(%ebp),%esp +8010440f: 5b pop %ebx +80104410: 5e pop %esi +80104411: 5f pop %edi +80104412: 5d pop %ebp +80104413: c3 ret + panic("log.committing"); +80104414: 83 ec 0c sub $0xc,%esp +80104417: 68 c4 8e 10 80 push $0x80108ec4 +8010441c: e8 5f c0 ff ff call 80100480 +80104421: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104428: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010442f: 90 nop + +80104430 : +// modify bp->data[] +// log_write(bp) +// brelse(bp) +void +log_write(struct buf *b) +{ +80104430: 55 push %ebp +80104431: 89 e5 mov %esp,%ebp +80104433: 53 push %ebx +80104434: 83 ec 04 sub $0x4,%esp + int i; + + if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) +80104437: 8b 15 68 de 11 80 mov 0x8011de68,%edx +{ +8010443d: 8b 5d 08 mov 0x8(%ebp),%ebx + if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) +80104440: 83 fa 1d cmp $0x1d,%edx +80104443: 0f 8f 85 00 00 00 jg 801044ce +80104449: a1 58 de 11 80 mov 0x8011de58,%eax +8010444e: 83 e8 01 sub $0x1,%eax +80104451: 39 c2 cmp %eax,%edx +80104453: 7d 79 jge 801044ce + panic("too big a transaction"); + if (log.outstanding < 1) +80104455: a1 5c de 11 80 mov 0x8011de5c,%eax +8010445a: 85 c0 test %eax,%eax +8010445c: 7e 7d jle 801044db + panic("log_write outside of trans"); + + acquire(&log.lock); +8010445e: 83 ec 0c sub $0xc,%esp +80104461: 68 20 de 11 80 push $0x8011de20 +80104466: e8 15 17 00 00 call 80105b80 + for (i = 0; i < log.lh.n; i++) { +8010446b: 8b 15 68 de 11 80 mov 0x8011de68,%edx +80104471: 83 c4 10 add $0x10,%esp +80104474: 85 d2 test %edx,%edx +80104476: 7e 4a jle 801044c2 + if (log.lh.block[i] == b->blockno) // log absorbtion +80104478: 8b 4b 08 mov 0x8(%ebx),%ecx + for (i = 0; i < log.lh.n; i++) { +8010447b: 31 c0 xor %eax,%eax +8010447d: eb 08 jmp 80104487 +8010447f: 90 nop +80104480: 83 c0 01 add $0x1,%eax +80104483: 39 c2 cmp %eax,%edx +80104485: 74 29 je 801044b0 + if (log.lh.block[i] == b->blockno) // log absorbtion +80104487: 39 0c 85 6c de 11 80 cmp %ecx,-0x7fee2194(,%eax,4) +8010448e: 75 f0 jne 80104480 + break; + } + log.lh.block[i] = b->blockno; +80104490: 89 0c 85 6c de 11 80 mov %ecx,-0x7fee2194(,%eax,4) + if (i == log.lh.n) + log.lh.n++; + b->flags |= B_DIRTY; // prevent eviction +80104497: 83 0b 04 orl $0x4,(%ebx) + release(&log.lock); +} +8010449a: 8b 5d fc mov -0x4(%ebp),%ebx + release(&log.lock); +8010449d: c7 45 08 20 de 11 80 movl $0x8011de20,0x8(%ebp) +} +801044a4: c9 leave + release(&log.lock); +801044a5: e9 76 16 00 00 jmp 80105b20 +801044aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + log.lh.block[i] = b->blockno; +801044b0: 89 0c 95 6c de 11 80 mov %ecx,-0x7fee2194(,%edx,4) + log.lh.n++; +801044b7: 83 c2 01 add $0x1,%edx +801044ba: 89 15 68 de 11 80 mov %edx,0x8011de68 +801044c0: eb d5 jmp 80104497 + log.lh.block[i] = b->blockno; +801044c2: 8b 43 08 mov 0x8(%ebx),%eax +801044c5: a3 6c de 11 80 mov %eax,0x8011de6c + if (i == log.lh.n) +801044ca: 75 cb jne 80104497 +801044cc: eb e9 jmp 801044b7 + panic("too big a transaction"); +801044ce: 83 ec 0c sub $0xc,%esp +801044d1: 68 d3 8e 10 80 push $0x80108ed3 +801044d6: e8 a5 bf ff ff call 80100480 + panic("log_write outside of trans"); +801044db: 83 ec 0c sub $0xc,%esp +801044de: 68 e9 8e 10 80 push $0x80108ee9 +801044e3: e8 98 bf ff ff call 80100480 +801044e8: 66 90 xchg %ax,%ax +801044ea: 66 90 xchg %ax,%ax +801044ec: 66 90 xchg %ax,%ax +801044ee: 66 90 xchg %ax,%ax + +801044f0 : + lapicinit(); + mpmain(); +} + +// Common CPU setup code. +static void mpmain(void) { +801044f0: 55 push %ebp +801044f1: 89 e5 mov %esp,%ebp +801044f3: 53 push %ebx +801044f4: 83 ec 04 sub $0x4,%esp + cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); +801044f7: e8 94 09 00 00 call 80104e90 +801044fc: 89 c3 mov %eax,%ebx +801044fe: e8 8d 09 00 00 call 80104e90 +80104503: 83 ec 04 sub $0x4,%esp +80104506: 53 push %ebx +80104507: 50 push %eax +80104508: 68 04 8f 10 80 push $0x80108f04 +8010450d: e8 7e c3 ff ff call 80100890 + idtinit(); // load idt register +80104512: e8 69 2b 00 00 call 80107080 + xchg(&(mycpu()->started), 1); // tell startothers() we're up +80104517: e8 14 09 00 00 call 80104e30 +8010451c: 89 c2 mov %eax,%edx + +static inline uint xchg(volatile uint *addr, uint newval) { + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile ("lock; xchgl %0, %1" : +8010451e: b8 01 00 00 00 mov $0x1,%eax +80104523: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) + scheduler(); // start running processes +8010452a: e8 61 0c 00 00 call 80105190 +8010452f: 90 nop + +80104530 : +static void mpenter(void) { +80104530: 55 push %ebp +80104531: 89 e5 mov %esp,%ebp +80104533: 83 ec 08 sub $0x8,%esp + switchkvm(); +80104536: e8 35 3c 00 00 call 80108170 + seginit(); +8010453b: e8 a0 3b 00 00 call 801080e0 + lapicinit(); +80104540: e8 9b f7 ff ff call 80103ce0 + mpmain(); +80104545: e8 a6 ff ff ff call 801044f0 +8010454a: 66 90 xchg %ax,%ax +8010454c: 66 90 xchg %ax,%ax +8010454e: 66 90 xchg %ax,%ax + +80104550
: +int main(void) { +80104550: 8d 4c 24 04 lea 0x4(%esp),%ecx +80104554: 83 e4 f0 and $0xfffffff0,%esp +80104557: ff 71 fc push -0x4(%ecx) +8010455a: 55 push %ebp +8010455b: 89 e5 mov %esp,%ebp +8010455d: 53 push %ebx +8010455e: 51 push %ecx + kinit1(end, P2V(4 * 1024 * 1024)); // phys page allocator +8010455f: 83 ec 08 sub $0x8,%esp +80104562: 68 00 00 40 80 push $0x80400000 +80104567: 68 50 22 12 80 push $0x80122250 +8010456c: e8 8f f5 ff ff call 80103b00 + kvmalloc(); // kernel page table +80104571: e8 ea 40 00 00 call 80108660 + mpinit(); // detect other processors +80104576: e8 85 01 00 00 call 80104700 + lapicinit(); // interrupt controller +8010457b: e8 60 f7 ff ff call 80103ce0 + seginit(); // segment descriptors +80104580: e8 5b 3b 00 00 call 801080e0 + picinit(); // disable pic +80104585: e8 76 03 00 00 call 80104900 + ioapicinit(); // another interrupt controller +8010458a: e8 31 f3 ff ff call 801038c0 + consoleinit(); // console hardware +8010458f: e8 4c cc ff ff call 801011e0 + uartinit(); // serial port +80104594: e8 d7 2d 00 00 call 80107370 + pinit(); // process table +80104599: e8 72 08 00 00 call 80104e10 + tvinit(); // trap vectors +8010459e: e8 5d 2a 00 00 call 80107000 + binit(); // buffer cache +801045a3: e8 98 ba ff ff call 80100040 + fileinit(); // file table +801045a8: e8 53 dd ff ff call 80102300 + ideinit(); // disk +801045ad: e8 fe f0 ff ff call 801036b0 + + // Write entry code to unused memory at 0x7000. + // The linker has placed the image of entryother.S in + // _binary_entryother_start. + code = P2V(0x7000); + memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); +801045b2: 83 c4 0c add $0xc,%esp +801045b5: 68 7a 00 00 00 push $0x7a +801045ba: 68 8c c4 10 80 push $0x8010c48c +801045bf: 68 00 70 00 80 push $0x80007000 +801045c4: e8 17 17 00 00 call 80105ce0 + + for (c = cpus; c < cpus + ncpu; c++) { +801045c9: 83 c4 10 add $0x10,%esp +801045cc: 69 05 04 df 11 80 b0 imul $0xb0,0x8011df04,%eax +801045d3: 00 00 00 +801045d6: 05 20 df 11 80 add $0x8011df20,%eax +801045db: 3d 20 df 11 80 cmp $0x8011df20,%eax +801045e0: 76 7e jbe 80104660 +801045e2: bb 20 df 11 80 mov $0x8011df20,%ebx +801045e7: eb 20 jmp 80104609 +801045e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801045f0: 69 05 04 df 11 80 b0 imul $0xb0,0x8011df04,%eax +801045f7: 00 00 00 +801045fa: 81 c3 b0 00 00 00 add $0xb0,%ebx +80104600: 05 20 df 11 80 add $0x8011df20,%eax +80104605: 39 c3 cmp %eax,%ebx +80104607: 73 57 jae 80104660 + if (c == mycpu()) { // We've started already. +80104609: e8 22 08 00 00 call 80104e30 +8010460e: 39 c3 cmp %eax,%ebx +80104610: 74 de je 801045f0 + } + + // Tell entryother.S what stack to use, where to enter, and what + // pgdir to use. We cannot use kpgdir yet, because the AP processor + // is running in low memory, so we use entrypgdir for the APs too. + stack = kalloc(); +80104612: e8 59 f5 ff ff call 80103b70 + *(void**)(code - 4) = stack + KSTACKSIZE; + *(void(**)(void))(code - 8) = mpenter; + *(int**)(code - 12) = (void *) V2P(entrypgdir); + + lapicstartap(c->apicid, V2P(code)); +80104617: 83 ec 08 sub $0x8,%esp + *(void(**)(void))(code - 8) = mpenter; +8010461a: c7 05 f8 6f 00 80 30 movl $0x80104530,0x80006ff8 +80104621: 45 10 80 + *(int**)(code - 12) = (void *) V2P(entrypgdir); +80104624: c7 05 f4 6f 00 80 00 movl $0x10b000,0x80006ff4 +8010462b: b0 10 00 + *(void**)(code - 4) = stack + KSTACKSIZE; +8010462e: 05 00 10 00 00 add $0x1000,%eax +80104633: a3 fc 6f 00 80 mov %eax,0x80006ffc + lapicstartap(c->apicid, V2P(code)); +80104638: 0f b6 03 movzbl (%ebx),%eax +8010463b: 68 00 70 00 00 push $0x7000 +80104640: 50 push %eax +80104641: e8 ea f7 ff ff call 80103e30 + + // wait for cpu to finish mpmain() + while (c->started == 0) { +80104646: 83 c4 10 add $0x10,%esp +80104649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104650: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax +80104656: 85 c0 test %eax,%eax +80104658: 74 f6 je 80104650 +8010465a: eb 94 jmp 801045f0 +8010465c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + kinit2(P2V(4 * 1024 * 1024), P2V(PHYSTOP)); // must come after startothers() +80104660: 83 ec 08 sub $0x8,%esp +80104663: 68 00 00 00 8e push $0x8e000000 +80104668: 68 00 00 40 80 push $0x80400000 +8010466d: e8 2e f4 ff ff call 80103aa0 + userinit(); // first user process +80104672: e8 69 08 00 00 call 80104ee0 + mpmain(); // finish this processor's setup +80104677: e8 74 fe ff ff call 801044f0 +8010467c: 66 90 xchg %ax,%ax +8010467e: 66 90 xchg %ax,%ax + +80104680 : + } + return sum; +} + +// Look for an MP structure in the len bytes at addr. +static struct mp*mpsearch1(uint a, int len) { +80104680: 55 push %ebp +80104681: 89 e5 mov %esp,%ebp +80104683: 57 push %edi +80104684: 56 push %esi + uchar *e, *p, *addr; + + addr = P2V(a); +80104685: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi +static struct mp*mpsearch1(uint a, int len) { +8010468b: 53 push %ebx + e = addr + len; +8010468c: 8d 1c 16 lea (%esi,%edx,1),%ebx +static struct mp*mpsearch1(uint a, int len) { +8010468f: 83 ec 0c sub $0xc,%esp + for (p = addr; p < e; p += sizeof(struct mp)) { +80104692: 39 de cmp %ebx,%esi +80104694: 72 10 jb 801046a6 +80104696: eb 50 jmp 801046e8 +80104698: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010469f: 90 nop +801046a0: 89 fe mov %edi,%esi +801046a2: 39 fb cmp %edi,%ebx +801046a4: 76 42 jbe 801046e8 + if (memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) { +801046a6: 83 ec 04 sub $0x4,%esp +801046a9: 8d 7e 10 lea 0x10(%esi),%edi +801046ac: 6a 04 push $0x4 +801046ae: 68 18 8f 10 80 push $0x80108f18 +801046b3: 56 push %esi +801046b4: e8 d7 15 00 00 call 80105c90 +801046b9: 83 c4 10 add $0x10,%esp +801046bc: 85 c0 test %eax,%eax +801046be: 75 e0 jne 801046a0 +801046c0: 89 f2 mov %esi,%edx +801046c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + sum += addr[i]; +801046c8: 0f b6 0a movzbl (%edx),%ecx + for (i = 0; i < len; i++) { +801046cb: 83 c2 01 add $0x1,%edx + sum += addr[i]; +801046ce: 01 c8 add %ecx,%eax + for (i = 0; i < len; i++) { +801046d0: 39 fa cmp %edi,%edx +801046d2: 75 f4 jne 801046c8 + if (memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) { +801046d4: 84 c0 test %al,%al +801046d6: 75 c8 jne 801046a0 + return (struct mp*)p; + } + } + return 0; +} +801046d8: 8d 65 f4 lea -0xc(%ebp),%esp +801046db: 89 f0 mov %esi,%eax +801046dd: 5b pop %ebx +801046de: 5e pop %esi +801046df: 5f pop %edi +801046e0: 5d pop %ebp +801046e1: c3 ret +801046e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801046e8: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; +801046eb: 31 f6 xor %esi,%esi +} +801046ed: 5b pop %ebx +801046ee: 89 f0 mov %esi,%eax +801046f0: 5e pop %esi +801046f1: 5f pop %edi +801046f2: 5d pop %ebp +801046f3: c3 ret +801046f4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801046fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801046ff: 90 nop + +80104700 : + } + *pmp = mp; + return conf; +} + +void mpinit(void) { +80104700: 55 push %ebp +80104701: 89 e5 mov %esp,%ebp +80104703: 57 push %edi +80104704: 56 push %esi +80104705: 53 push %ebx +80104706: 83 ec 1c sub $0x1c,%esp + if ((p = ((bda[0x0F] << 8) | bda[0x0E]) << 4)) { +80104709: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax +80104710: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx +80104717: c1 e0 08 shl $0x8,%eax +8010471a: 09 d0 or %edx,%eax +8010471c: c1 e0 04 shl $0x4,%eax +8010471f: 75 1b jne 8010473c + p = ((bda[0x14] << 8) | bda[0x13]) * 1024; +80104721: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax +80104728: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx +8010472f: c1 e0 08 shl $0x8,%eax +80104732: 09 d0 or %edx,%eax +80104734: c1 e0 0a shl $0xa,%eax + if ((mp = mpsearch1(p - 1024, 1024))) { +80104737: 2d 00 04 00 00 sub $0x400,%eax + if ((mp = mpsearch1(p, 1024))) { +8010473c: ba 00 04 00 00 mov $0x400,%edx +80104741: e8 3a ff ff ff call 80104680 +80104746: 89 c3 mov %eax,%ebx +80104748: 85 c0 test %eax,%eax +8010474a: 0f 84 40 01 00 00 je 80104890 + if ((mp = mpsearch()) == 0 || mp->physaddr == 0) { +80104750: 8b 73 04 mov 0x4(%ebx),%esi +80104753: 85 f6 test %esi,%esi +80104755: 0f 84 25 01 00 00 je 80104880 + if (memcmp(conf, "PCMP", 4) != 0) { +8010475b: 83 ec 04 sub $0x4,%esp + conf = (struct mpconf*) P2V((uint) mp->physaddr); +8010475e: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax + if (memcmp(conf, "PCMP", 4) != 0) { +80104764: 6a 04 push $0x4 +80104766: 68 1d 8f 10 80 push $0x80108f1d +8010476b: 50 push %eax + conf = (struct mpconf*) P2V((uint) mp->physaddr); +8010476c: 89 45 e4 mov %eax,-0x1c(%ebp) + if (memcmp(conf, "PCMP", 4) != 0) { +8010476f: e8 1c 15 00 00 call 80105c90 +80104774: 83 c4 10 add $0x10,%esp +80104777: 85 c0 test %eax,%eax +80104779: 0f 85 01 01 00 00 jne 80104880 + if (conf->version != 1 && conf->version != 4) { +8010477f: 0f b6 86 06 00 00 80 movzbl -0x7ffffffa(%esi),%eax +80104786: 3c 01 cmp $0x1,%al +80104788: 74 08 je 80104792 +8010478a: 3c 04 cmp $0x4,%al +8010478c: 0f 85 ee 00 00 00 jne 80104880 + if (sum((uchar*)conf, conf->length) != 0) { +80104792: 0f b7 96 04 00 00 80 movzwl -0x7ffffffc(%esi),%edx + for (i = 0; i < len; i++) { +80104799: 66 85 d2 test %dx,%dx +8010479c: 74 22 je 801047c0 +8010479e: 8d 3c 32 lea (%edx,%esi,1),%edi +801047a1: 89 f0 mov %esi,%eax + sum = 0; +801047a3: 31 d2 xor %edx,%edx +801047a5: 8d 76 00 lea 0x0(%esi),%esi + sum += addr[i]; +801047a8: 0f b6 88 00 00 00 80 movzbl -0x80000000(%eax),%ecx + for (i = 0; i < len; i++) { +801047af: 83 c0 01 add $0x1,%eax + sum += addr[i]; +801047b2: 01 ca add %ecx,%edx + for (i = 0; i < len; i++) { +801047b4: 39 c7 cmp %eax,%edi +801047b6: 75 f0 jne 801047a8 + if (sum((uchar*)conf, conf->length) != 0) { +801047b8: 84 d2 test %dl,%dl +801047ba: 0f 85 c0 00 00 00 jne 80104880 + + if ((conf = mpconfig(&mp)) == 0) { + panic("Expect to run on an SMP"); + } + ismp = 1; + lapic = (uint*)conf->lapicaddr; +801047c0: 8b 86 24 00 00 80 mov -0x7fffffdc(%esi),%eax +801047c6: a3 00 de 11 80 mov %eax,0x8011de00 + for (p = (uchar*)(conf + 1), e = (uchar*)conf + conf->length; p < e;) { +801047cb: 0f b7 96 04 00 00 80 movzwl -0x7ffffffc(%esi),%edx +801047d2: 8d 86 2c 00 00 80 lea -0x7fffffd4(%esi),%eax + ismp = 1; +801047d8: be 01 00 00 00 mov $0x1,%esi + for (p = (uchar*)(conf + 1), e = (uchar*)conf + conf->length; p < e;) { +801047dd: 03 55 e4 add -0x1c(%ebp),%edx +801047e0: 89 5d e4 mov %ebx,-0x1c(%ebp) +801047e3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801047e7: 90 nop +801047e8: 39 d0 cmp %edx,%eax +801047ea: 73 15 jae 80104801 + switch (*p) { +801047ec: 0f b6 08 movzbl (%eax),%ecx +801047ef: 80 f9 02 cmp $0x2,%cl +801047f2: 74 4c je 80104840 +801047f4: 77 3a ja 80104830 +801047f6: 84 c9 test %cl,%cl +801047f8: 74 56 je 80104850 + p += sizeof(struct mpioapic); + continue; + case MPBUS: + case MPIOINTR: + case MPLINTR: + p += 8; +801047fa: 83 c0 08 add $0x8,%eax + for (p = (uchar*)(conf + 1), e = (uchar*)conf + conf->length; p < e;) { +801047fd: 39 d0 cmp %edx,%eax +801047ff: 72 eb jb 801047ec + default: + ismp = 0; + break; + } + } + if (!ismp) { +80104801: 8b 5d e4 mov -0x1c(%ebp),%ebx +80104804: 85 f6 test %esi,%esi +80104806: 0f 84 d9 00 00 00 je 801048e5 + panic("Didn't find a suitable machine"); + } + + if (mp->imcrp) { +8010480c: 80 7b 0c 00 cmpb $0x0,0xc(%ebx) +80104810: 74 15 je 80104827 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80104812: b8 70 00 00 00 mov $0x70,%eax +80104817: ba 22 00 00 00 mov $0x22,%edx +8010481c: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +8010481d: ba 23 00 00 00 mov $0x23,%edx +80104822: ec in (%dx),%al + // Bochs doesn't support IMCR, so this doesn't run on Bochs. + // But it would on real hardware. + outb(0x22, 0x70); // Select IMCR + outb(0x23, inb(0x23) | 1); // Mask external interrupts. +80104823: 83 c8 01 or $0x1,%eax + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80104826: ee out %al,(%dx) + } +} +80104827: 8d 65 f4 lea -0xc(%ebp),%esp +8010482a: 5b pop %ebx +8010482b: 5e pop %esi +8010482c: 5f pop %edi +8010482d: 5d pop %ebp +8010482e: c3 ret +8010482f: 90 nop + switch (*p) { +80104830: 83 e9 03 sub $0x3,%ecx +80104833: 80 f9 01 cmp $0x1,%cl +80104836: 76 c2 jbe 801047fa +80104838: 31 f6 xor %esi,%esi +8010483a: eb ac jmp 801047e8 +8010483c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ioapicid = ioapic->apicno; +80104840: 0f b6 48 01 movzbl 0x1(%eax),%ecx + p += sizeof(struct mpioapic); +80104844: 83 c0 08 add $0x8,%eax + ioapicid = ioapic->apicno; +80104847: 88 0d 00 df 11 80 mov %cl,0x8011df00 + continue; +8010484d: eb 99 jmp 801047e8 +8010484f: 90 nop + if (ncpu < NCPU) { +80104850: 8b 0d 04 df 11 80 mov 0x8011df04,%ecx +80104856: 83 f9 07 cmp $0x7,%ecx +80104859: 7f 19 jg 80104874 + cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu +8010485b: 69 f9 b0 00 00 00 imul $0xb0,%ecx,%edi +80104861: 0f b6 58 01 movzbl 0x1(%eax),%ebx + ncpu++; +80104865: 83 c1 01 add $0x1,%ecx +80104868: 89 0d 04 df 11 80 mov %ecx,0x8011df04 + cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu +8010486e: 88 9f 20 df 11 80 mov %bl,-0x7fee20e0(%edi) + p += sizeof(struct mpproc); +80104874: 83 c0 14 add $0x14,%eax + continue; +80104877: e9 6c ff ff ff jmp 801047e8 +8010487c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + panic("Expect to run on an SMP"); +80104880: 83 ec 0c sub $0xc,%esp +80104883: 68 22 8f 10 80 push $0x80108f22 +80104888: e8 f3 bb ff ff call 80100480 +8010488d: 8d 76 00 lea 0x0(%esi),%esi +void mpinit(void) { +80104890: bb 00 00 0f 80 mov $0x800f0000,%ebx +80104895: eb 13 jmp 801048aa +80104897: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010489e: 66 90 xchg %ax,%ax + for (p = addr; p < e; p += sizeof(struct mp)) { +801048a0: 89 f3 mov %esi,%ebx +801048a2: 81 fe 00 00 10 80 cmp $0x80100000,%esi +801048a8: 74 d6 je 80104880 + if (memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) { +801048aa: 83 ec 04 sub $0x4,%esp +801048ad: 8d 73 10 lea 0x10(%ebx),%esi +801048b0: 6a 04 push $0x4 +801048b2: 68 18 8f 10 80 push $0x80108f18 +801048b7: 53 push %ebx +801048b8: e8 d3 13 00 00 call 80105c90 +801048bd: 83 c4 10 add $0x10,%esp +801048c0: 85 c0 test %eax,%eax +801048c2: 75 dc jne 801048a0 +801048c4: 89 da mov %ebx,%edx +801048c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801048cd: 8d 76 00 lea 0x0(%esi),%esi + sum += addr[i]; +801048d0: 0f b6 0a movzbl (%edx),%ecx + for (i = 0; i < len; i++) { +801048d3: 83 c2 01 add $0x1,%edx + sum += addr[i]; +801048d6: 01 c8 add %ecx,%eax + for (i = 0; i < len; i++) { +801048d8: 39 d6 cmp %edx,%esi +801048da: 75 f4 jne 801048d0 + if (memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) { +801048dc: 84 c0 test %al,%al +801048de: 75 c0 jne 801048a0 +801048e0: e9 6b fe ff ff jmp 80104750 + panic("Didn't find a suitable machine"); +801048e5: 83 ec 0c sub $0xc,%esp +801048e8: 68 3c 8f 10 80 push $0x80108f3c +801048ed: e8 8e bb ff ff call 80100480 +801048f2: 66 90 xchg %ax,%ax +801048f4: 66 90 xchg %ax,%ax +801048f6: 66 90 xchg %ax,%ax +801048f8: 66 90 xchg %ax,%ax +801048fa: 66 90 xchg %ax,%ax +801048fc: 66 90 xchg %ax,%ax +801048fe: 66 90 xchg %ax,%ax + +80104900 : +80104900: b8 ff ff ff ff mov $0xffffffff,%eax +80104905: ba 21 00 00 00 mov $0x21,%edx +8010490a: ee out %al,(%dx) +8010490b: ba a1 00 00 00 mov $0xa1,%edx +80104910: ee out %al,(%dx) +// Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. +void picinit(void) { + // mask all interrupts + outb(IO_PIC1 + 1, 0xFF); + outb(IO_PIC2 + 1, 0xFF); +} +80104911: c3 ret +80104912: 66 90 xchg %ax,%ax +80104914: 66 90 xchg %ax,%ax +80104916: 66 90 xchg %ax,%ax +80104918: 66 90 xchg %ax,%ax +8010491a: 66 90 xchg %ax,%ax +8010491c: 66 90 xchg %ax,%ax +8010491e: 66 90 xchg %ax,%ax + +80104920 : + uint nwrite; // number of bytes written + int readopen; // read fd is still open + int writeopen; // write fd is still open +}; + +void cleanuppipealloc(struct pipe *p, struct file **f0, struct file **f1) { +80104920: 55 push %ebp +80104921: 89 e5 mov %esp,%ebp +80104923: 56 push %esi +80104924: 8b 45 08 mov 0x8(%ebp),%eax +80104927: 8b 75 0c mov 0xc(%ebp),%esi +8010492a: 53 push %ebx +8010492b: 8b 5d 10 mov 0x10(%ebp),%ebx + if (p) { +8010492e: 85 c0 test %eax,%eax +80104930: 74 0c je 8010493e + kfree((char*)p); +80104932: 83 ec 0c sub $0xc,%esp +80104935: 50 push %eax +80104936: e8 75 f0 ff ff call 801039b0 +8010493b: 83 c4 10 add $0x10,%esp + } + if (*f0) { +8010493e: 8b 06 mov (%esi),%eax +80104940: 85 c0 test %eax,%eax +80104942: 74 0c je 80104950 + fileclose(*f0); +80104944: 83 ec 0c sub $0xc,%esp +80104947: 50 push %eax +80104948: e8 93 da ff ff call 801023e0 +8010494d: 83 c4 10 add $0x10,%esp + } + if (*f1) { +80104950: 8b 03 mov (%ebx),%eax +80104952: 85 c0 test %eax,%eax +80104954: 74 12 je 80104968 + fileclose(*f1); +80104956: 89 45 08 mov %eax,0x8(%ebp) + } +} +80104959: 8d 65 f8 lea -0x8(%ebp),%esp +8010495c: 5b pop %ebx +8010495d: 5e pop %esi +8010495e: 5d pop %ebp + fileclose(*f1); +8010495f: e9 7c da ff ff jmp 801023e0 +80104964: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +} +80104968: 8d 65 f8 lea -0x8(%ebp),%esp +8010496b: 5b pop %ebx +8010496c: 5e pop %esi +8010496d: 5d pop %ebp +8010496e: c3 ret +8010496f: 90 nop + +80104970 : + +int pipealloc(struct file **f0, struct file **f1) { +80104970: 55 push %ebp +80104971: 89 e5 mov %esp,%ebp +80104973: 57 push %edi +80104974: 56 push %esi +80104975: 53 push %ebx +80104976: 83 ec 0c sub $0xc,%esp +80104979: 8b 75 08 mov 0x8(%ebp),%esi +8010497c: 8b 7d 0c mov 0xc(%ebp),%edi + struct pipe *p; + + p = 0; + *f0 = *f1 = 0; +8010497f: c7 07 00 00 00 00 movl $0x0,(%edi) +80104985: c7 06 00 00 00 00 movl $0x0,(%esi) + if ((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) { +8010498b: e8 90 d9 ff ff call 80102320 +80104990: 89 06 mov %eax,(%esi) +80104992: 85 c0 test %eax,%eax +80104994: 0f 84 a5 00 00 00 je 80104a3f +8010499a: e8 81 d9 ff ff call 80102320 +8010499f: 89 07 mov %eax,(%edi) +801049a1: 85 c0 test %eax,%eax +801049a3: 0f 84 84 00 00 00 je 80104a2d + cleanuppipealloc(p, f0, f1); + return -1; + } + if ((p = (struct pipe*)kalloc()) == 0) { +801049a9: e8 c2 f1 ff ff call 80103b70 +801049ae: 89 c3 mov %eax,%ebx +801049b0: 85 c0 test %eax,%eax +801049b2: 0f 84 a0 00 00 00 je 80104a58 + cleanuppipealloc(p, f0, f1); + return -1; + } + p->readopen = 1; +801049b8: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) +801049bf: 00 00 00 + p->writeopen = 1; + p->nwrite = 0; + p->nread = 0; + initlock(&p->lock, "pipe"); +801049c2: 83 ec 08 sub $0x8,%esp + p->writeopen = 1; +801049c5: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) +801049cc: 00 00 00 + p->nwrite = 0; +801049cf: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) +801049d6: 00 00 00 + p->nread = 0; +801049d9: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) +801049e0: 00 00 00 + initlock(&p->lock, "pipe"); +801049e3: 68 5b 8f 10 80 push $0x80108f5b +801049e8: 50 push %eax +801049e9: e8 c2 0f 00 00 call 801059b0 + (*f0)->type = FD_PIPE; +801049ee: 8b 06 mov (%esi),%eax + (*f0)->pipe = p; + (*f1)->type = FD_PIPE; + (*f1)->readable = 0; + (*f1)->writable = 1; + (*f1)->pipe = p; + return 0; +801049f0: 83 c4 10 add $0x10,%esp + (*f0)->type = FD_PIPE; +801049f3: c7 00 01 00 00 00 movl $0x1,(%eax) + (*f0)->readable = 1; +801049f9: 8b 06 mov (%esi),%eax +801049fb: c6 40 08 01 movb $0x1,0x8(%eax) + (*f0)->writable = 0; +801049ff: 8b 06 mov (%esi),%eax +80104a01: c6 40 09 00 movb $0x0,0x9(%eax) + (*f0)->pipe = p; +80104a05: 8b 06 mov (%esi),%eax +80104a07: 89 58 0c mov %ebx,0xc(%eax) + (*f1)->type = FD_PIPE; +80104a0a: 8b 07 mov (%edi),%eax +80104a0c: c7 00 01 00 00 00 movl $0x1,(%eax) + (*f1)->readable = 0; +80104a12: 8b 07 mov (%edi),%eax +80104a14: c6 40 08 00 movb $0x0,0x8(%eax) + (*f1)->writable = 1; +80104a18: 8b 07 mov (%edi),%eax +80104a1a: c6 40 09 01 movb $0x1,0x9(%eax) + (*f1)->pipe = p; +80104a1e: 8b 07 mov (%edi),%eax +80104a20: 89 58 0c mov %ebx,0xc(%eax) + return 0; +80104a23: 31 c0 xor %eax,%eax +} +80104a25: 8d 65 f4 lea -0xc(%ebp),%esp +80104a28: 5b pop %ebx +80104a29: 5e pop %esi +80104a2a: 5f pop %edi +80104a2b: 5d pop %ebp +80104a2c: c3 ret + if (*f0) { +80104a2d: 8b 06 mov (%esi),%eax +80104a2f: 85 c0 test %eax,%eax +80104a31: 74 1e je 80104a51 + fileclose(*f0); +80104a33: 83 ec 0c sub $0xc,%esp +80104a36: 50 push %eax +80104a37: e8 a4 d9 ff ff call 801023e0 +80104a3c: 83 c4 10 add $0x10,%esp + if (*f1) { +80104a3f: 8b 07 mov (%edi),%eax +80104a41: 85 c0 test %eax,%eax +80104a43: 74 0c je 80104a51 + fileclose(*f1); +80104a45: 83 ec 0c sub $0xc,%esp +80104a48: 50 push %eax +80104a49: e8 92 d9 ff ff call 801023e0 +80104a4e: 83 c4 10 add $0x10,%esp + return -1; +80104a51: b8 ff ff ff ff mov $0xffffffff,%eax +80104a56: eb cd jmp 80104a25 + if (*f0) { +80104a58: 8b 06 mov (%esi),%eax +80104a5a: 85 c0 test %eax,%eax +80104a5c: 75 d5 jne 80104a33 +80104a5e: eb df jmp 80104a3f + +80104a60 : + +void pipeclose(struct pipe *p, int writable) { +80104a60: 55 push %ebp +80104a61: 89 e5 mov %esp,%ebp +80104a63: 56 push %esi +80104a64: 53 push %ebx +80104a65: 8b 5d 08 mov 0x8(%ebp),%ebx +80104a68: 8b 75 0c mov 0xc(%ebp),%esi + acquire(&p->lock); +80104a6b: 83 ec 0c sub $0xc,%esp +80104a6e: 53 push %ebx +80104a6f: e8 0c 11 00 00 call 80105b80 + if (writable) { +80104a74: 83 c4 10 add $0x10,%esp +80104a77: 85 f6 test %esi,%esi +80104a79: 74 65 je 80104ae0 + p->writeopen = 0; + wakeup(&p->nread); +80104a7b: 83 ec 0c sub $0xc,%esp +80104a7e: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax + p->writeopen = 0; +80104a84: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) +80104a8b: 00 00 00 + wakeup(&p->nread); +80104a8e: 50 push %eax +80104a8f: e8 0c 0c 00 00 call 801056a0 +80104a94: 83 c4 10 add $0x10,%esp + } + else { + p->readopen = 0; + wakeup(&p->nwrite); + } + if (p->readopen == 0 && p->writeopen == 0) { +80104a97: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx +80104a9d: 85 d2 test %edx,%edx +80104a9f: 75 0a jne 80104aab +80104aa1: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax +80104aa7: 85 c0 test %eax,%eax +80104aa9: 74 15 je 80104ac0 + release(&p->lock); + kfree((char*)p); + } + else { + release(&p->lock); +80104aab: 89 5d 08 mov %ebx,0x8(%ebp) + } +} +80104aae: 8d 65 f8 lea -0x8(%ebp),%esp +80104ab1: 5b pop %ebx +80104ab2: 5e pop %esi +80104ab3: 5d pop %ebp + release(&p->lock); +80104ab4: e9 67 10 00 00 jmp 80105b20 +80104ab9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + release(&p->lock); +80104ac0: 83 ec 0c sub $0xc,%esp +80104ac3: 53 push %ebx +80104ac4: e8 57 10 00 00 call 80105b20 + kfree((char*)p); +80104ac9: 89 5d 08 mov %ebx,0x8(%ebp) +80104acc: 83 c4 10 add $0x10,%esp +} +80104acf: 8d 65 f8 lea -0x8(%ebp),%esp +80104ad2: 5b pop %ebx +80104ad3: 5e pop %esi +80104ad4: 5d pop %ebp + kfree((char*)p); +80104ad5: e9 d6 ee ff ff jmp 801039b0 +80104ada: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + wakeup(&p->nwrite); +80104ae0: 83 ec 0c sub $0xc,%esp +80104ae3: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax + p->readopen = 0; +80104ae9: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) +80104af0: 00 00 00 + wakeup(&p->nwrite); +80104af3: 50 push %eax +80104af4: e8 a7 0b 00 00 call 801056a0 +80104af9: 83 c4 10 add $0x10,%esp +80104afc: eb 99 jmp 80104a97 +80104afe: 66 90 xchg %ax,%ax + +80104b00 : + +int pipewrite(struct pipe *p, char *addr, int n) { +80104b00: 55 push %ebp +80104b01: 89 e5 mov %esp,%ebp +80104b03: 57 push %edi +80104b04: 56 push %esi +80104b05: 53 push %ebx +80104b06: 83 ec 28 sub $0x28,%esp +80104b09: 8b 5d 08 mov 0x8(%ebp),%ebx + int i; + + acquire(&p->lock); +80104b0c: 53 push %ebx +80104b0d: e8 6e 10 00 00 call 80105b80 + for (i = 0; i < n; i++) { +80104b12: 8b 45 10 mov 0x10(%ebp),%eax +80104b15: 83 c4 10 add $0x10,%esp +80104b18: 85 c0 test %eax,%eax +80104b1a: 0f 8e c0 00 00 00 jle 80104be0 +80104b20: 8b 45 0c mov 0xc(%ebp),%eax + while (p->nwrite == p->nread + PIPESIZE) { //DOC: pipewrite-full +80104b23: 8b 8b 38 02 00 00 mov 0x238(%ebx),%ecx + if (p->readopen == 0 || myproc()->killed) { + release(&p->lock); + return -1; + } + wakeup(&p->nread); +80104b29: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi +80104b2f: 89 45 e4 mov %eax,-0x1c(%ebp) +80104b32: 03 45 10 add 0x10(%ebp),%eax +80104b35: 89 45 e0 mov %eax,-0x20(%ebp) + while (p->nwrite == p->nread + PIPESIZE) { //DOC: pipewrite-full +80104b38: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax + sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep +80104b3e: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi + while (p->nwrite == p->nread + PIPESIZE) { //DOC: pipewrite-full +80104b44: 89 ca mov %ecx,%edx +80104b46: 05 00 02 00 00 add $0x200,%eax +80104b4b: 39 c1 cmp %eax,%ecx +80104b4d: 74 3f je 80104b8e +80104b4f: eb 67 jmp 80104bb8 +80104b51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (p->readopen == 0 || myproc()->killed) { +80104b58: e8 53 03 00 00 call 80104eb0 +80104b5d: 8b 48 24 mov 0x24(%eax),%ecx +80104b60: 85 c9 test %ecx,%ecx +80104b62: 75 34 jne 80104b98 + wakeup(&p->nread); +80104b64: 83 ec 0c sub $0xc,%esp +80104b67: 57 push %edi +80104b68: e8 33 0b 00 00 call 801056a0 + sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep +80104b6d: 58 pop %eax +80104b6e: 5a pop %edx +80104b6f: 53 push %ebx +80104b70: 56 push %esi +80104b71: e8 6a 0a 00 00 call 801055e0 + while (p->nwrite == p->nread + PIPESIZE) { //DOC: pipewrite-full +80104b76: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax +80104b7c: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx +80104b82: 83 c4 10 add $0x10,%esp +80104b85: 05 00 02 00 00 add $0x200,%eax +80104b8a: 39 c2 cmp %eax,%edx +80104b8c: 75 2a jne 80104bb8 + if (p->readopen == 0 || myproc()->killed) { +80104b8e: 8b 83 3c 02 00 00 mov 0x23c(%ebx),%eax +80104b94: 85 c0 test %eax,%eax +80104b96: 75 c0 jne 80104b58 + release(&p->lock); +80104b98: 83 ec 0c sub $0xc,%esp +80104b9b: 53 push %ebx +80104b9c: e8 7f 0f 00 00 call 80105b20 + return -1; +80104ba1: 83 c4 10 add $0x10,%esp +80104ba4: b8 ff ff ff ff mov $0xffffffff,%eax + p->data[p->nwrite++ % PIPESIZE] = addr[i]; + } + wakeup(&p->nread); //DOC: pipewrite-wakeup1 + release(&p->lock); + return n; +} +80104ba9: 8d 65 f4 lea -0xc(%ebp),%esp +80104bac: 5b pop %ebx +80104bad: 5e pop %esi +80104bae: 5f pop %edi +80104baf: 5d pop %ebp +80104bb0: c3 ret +80104bb1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + p->data[p->nwrite++ % PIPESIZE] = addr[i]; +80104bb8: 8b 75 e4 mov -0x1c(%ebp),%esi +80104bbb: 8d 4a 01 lea 0x1(%edx),%ecx +80104bbe: 81 e2 ff 01 00 00 and $0x1ff,%edx +80104bc4: 89 8b 38 02 00 00 mov %ecx,0x238(%ebx) +80104bca: 0f b6 06 movzbl (%esi),%eax + for (i = 0; i < n; i++) { +80104bcd: 83 c6 01 add $0x1,%esi +80104bd0: 89 75 e4 mov %esi,-0x1c(%ebp) + p->data[p->nwrite++ % PIPESIZE] = addr[i]; +80104bd3: 88 44 13 34 mov %al,0x34(%ebx,%edx,1) + for (i = 0; i < n; i++) { +80104bd7: 3b 75 e0 cmp -0x20(%ebp),%esi +80104bda: 0f 85 58 ff ff ff jne 80104b38 + wakeup(&p->nread); //DOC: pipewrite-wakeup1 +80104be0: 83 ec 0c sub $0xc,%esp +80104be3: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax +80104be9: 50 push %eax +80104bea: e8 b1 0a 00 00 call 801056a0 + release(&p->lock); +80104bef: 89 1c 24 mov %ebx,(%esp) +80104bf2: e8 29 0f 00 00 call 80105b20 + return n; +80104bf7: 8b 45 10 mov 0x10(%ebp),%eax +80104bfa: 83 c4 10 add $0x10,%esp +80104bfd: eb aa jmp 80104ba9 +80104bff: 90 nop + +80104c00 : + +int piperead(struct pipe *p, char *addr, int n) { +80104c00: 55 push %ebp +80104c01: 89 e5 mov %esp,%ebp +80104c03: 57 push %edi +80104c04: 56 push %esi +80104c05: 53 push %ebx +80104c06: 83 ec 18 sub $0x18,%esp +80104c09: 8b 75 08 mov 0x8(%ebp),%esi +80104c0c: 8b 7d 0c mov 0xc(%ebp),%edi + int i; + + acquire(&p->lock); +80104c0f: 56 push %esi +80104c10: 8d 9e 34 02 00 00 lea 0x234(%esi),%ebx +80104c16: e8 65 0f 00 00 call 80105b80 + while (p->nread == p->nwrite && p->writeopen) { //DOC: pipe-empty +80104c1b: 8b 86 34 02 00 00 mov 0x234(%esi),%eax +80104c21: 83 c4 10 add $0x10,%esp +80104c24: 39 86 38 02 00 00 cmp %eax,0x238(%esi) +80104c2a: 74 2f je 80104c5b +80104c2c: eb 37 jmp 80104c65 +80104c2e: 66 90 xchg %ax,%ax + if (myproc()->killed) { +80104c30: e8 7b 02 00 00 call 80104eb0 +80104c35: 8b 48 24 mov 0x24(%eax),%ecx +80104c38: 85 c9 test %ecx,%ecx +80104c3a: 0f 85 80 00 00 00 jne 80104cc0 + release(&p->lock); + return -1; + } + sleep(&p->nread, &p->lock); //DOC: piperead-sleep +80104c40: 83 ec 08 sub $0x8,%esp +80104c43: 56 push %esi +80104c44: 53 push %ebx +80104c45: e8 96 09 00 00 call 801055e0 + while (p->nread == p->nwrite && p->writeopen) { //DOC: pipe-empty +80104c4a: 8b 86 38 02 00 00 mov 0x238(%esi),%eax +80104c50: 83 c4 10 add $0x10,%esp +80104c53: 39 86 34 02 00 00 cmp %eax,0x234(%esi) +80104c59: 75 0a jne 80104c65 +80104c5b: 8b 86 40 02 00 00 mov 0x240(%esi),%eax +80104c61: 85 c0 test %eax,%eax +80104c63: 75 cb jne 80104c30 + } + for (i = 0; i < n; i++) { //DOC: piperead-copy +80104c65: 8b 55 10 mov 0x10(%ebp),%edx +80104c68: 31 db xor %ebx,%ebx +80104c6a: 85 d2 test %edx,%edx +80104c6c: 7f 20 jg 80104c8e +80104c6e: eb 2c jmp 80104c9c + if (p->nread == p->nwrite) { + break; + } + addr[i] = p->data[p->nread++ % PIPESIZE]; +80104c70: 8d 48 01 lea 0x1(%eax),%ecx +80104c73: 25 ff 01 00 00 and $0x1ff,%eax +80104c78: 89 8e 34 02 00 00 mov %ecx,0x234(%esi) +80104c7e: 0f b6 44 06 34 movzbl 0x34(%esi,%eax,1),%eax +80104c83: 88 04 1f mov %al,(%edi,%ebx,1) + for (i = 0; i < n; i++) { //DOC: piperead-copy +80104c86: 83 c3 01 add $0x1,%ebx +80104c89: 39 5d 10 cmp %ebx,0x10(%ebp) +80104c8c: 74 0e je 80104c9c + if (p->nread == p->nwrite) { +80104c8e: 8b 86 34 02 00 00 mov 0x234(%esi),%eax +80104c94: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax +80104c9a: 75 d4 jne 80104c70 + } + wakeup(&p->nwrite); //DOC: piperead-wakeup +80104c9c: 83 ec 0c sub $0xc,%esp +80104c9f: 8d 86 38 02 00 00 lea 0x238(%esi),%eax +80104ca5: 50 push %eax +80104ca6: e8 f5 09 00 00 call 801056a0 + release(&p->lock); +80104cab: 89 34 24 mov %esi,(%esp) +80104cae: e8 6d 0e 00 00 call 80105b20 + return i; +80104cb3: 83 c4 10 add $0x10,%esp +} +80104cb6: 8d 65 f4 lea -0xc(%ebp),%esp +80104cb9: 89 d8 mov %ebx,%eax +80104cbb: 5b pop %ebx +80104cbc: 5e pop %esi +80104cbd: 5f pop %edi +80104cbe: 5d pop %ebp +80104cbf: c3 ret + release(&p->lock); +80104cc0: 83 ec 0c sub $0xc,%esp + return -1; +80104cc3: bb ff ff ff ff mov $0xffffffff,%ebx + release(&p->lock); +80104cc8: 56 push %esi +80104cc9: e8 52 0e 00 00 call 80105b20 + return -1; +80104cce: 83 c4 10 add $0x10,%esp +} +80104cd1: 8d 65 f4 lea -0xc(%ebp),%esp +80104cd4: 89 d8 mov %ebx,%eax +80104cd6: 5b pop %ebx +80104cd7: 5e pop %esi +80104cd8: 5f pop %edi +80104cd9: 5d pop %ebp +80104cda: c3 ret +80104cdb: 66 90 xchg %ax,%ax +80104cdd: 66 90 xchg %ax,%ax +80104cdf: 90 nop + +80104ce0 : + +// Look in the process table for an UNUSED proc. +// If found, change state to EMBRYO and initialize +// state required to run in the kernel. +// Otherwise return 0. +static struct proc* allocproc(void) { +80104ce0: 55 push %ebp +80104ce1: 89 e5 mov %esp,%ebp +80104ce3: 53 push %ebx + char *sp; + int found = 0; + + acquire(&ptable.lock); + + p = ptable.proc; +80104ce4: bb d4 e4 11 80 mov $0x8011e4d4,%ebx +static struct proc* allocproc(void) { +80104ce9: 83 ec 10 sub $0x10,%esp + acquire(&ptable.lock); +80104cec: 68 a0 e4 11 80 push $0x8011e4a0 +80104cf1: e8 8a 0e 00 00 call 80105b80 +80104cf6: 83 c4 10 add $0x10,%esp + while (p < &ptable.proc[NPROC] && !found) { + if (p->state == UNUSED) { +80104cf9: 8b 43 0c mov 0xc(%ebx),%eax +80104cfc: 85 c0 test %eax,%eax +80104cfe: 74 30 je 80104d30 + found = 1; + } + else { + p++; +80104d00: 81 c3 94 00 00 00 add $0x94,%ebx + while (p < &ptable.proc[NPROC] && !found) { +80104d06: 81 fb d4 09 12 80 cmp $0x801209d4,%ebx +80104d0c: 75 eb jne 80104cf9 + } + + } + if (!found) { + release(&ptable.lock); +80104d0e: 83 ec 0c sub $0xc,%esp + return 0; +80104d11: 31 db xor %ebx,%ebx + release(&ptable.lock); +80104d13: 68 a0 e4 11 80 push $0x8011e4a0 +80104d18: e8 03 0e 00 00 call 80105b20 + memset(p->context, 0, sizeof *p->context); + p->context->eip = (uint)forkret; + p->consoleptr = getbaseconsoleptr(); + + return p; +} +80104d1d: 89 d8 mov %ebx,%eax + return 0; +80104d1f: 83 c4 10 add $0x10,%esp +} +80104d22: 8b 5d fc mov -0x4(%ebp),%ebx +80104d25: c9 leave +80104d26: c3 ret +80104d27: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104d2e: 66 90 xchg %ax,%ax + p->pid = nextpid++; +80104d30: a1 04 c0 10 80 mov 0x8010c004,%eax + release(&ptable.lock); +80104d35: 83 ec 0c sub $0xc,%esp + p->state = EMBRYO; +80104d38: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) + p->pid = nextpid++; +80104d3f: 89 43 10 mov %eax,0x10(%ebx) +80104d42: 8d 50 01 lea 0x1(%eax),%edx + release(&ptable.lock); +80104d45: 68 a0 e4 11 80 push $0x8011e4a0 + p->pid = nextpid++; +80104d4a: 89 15 04 c0 10 80 mov %edx,0x8010c004 + release(&ptable.lock); +80104d50: e8 cb 0d 00 00 call 80105b20 + if ((p->kstack = kalloc()) == 0) { +80104d55: e8 16 ee ff ff call 80103b70 +80104d5a: 83 c4 10 add $0x10,%esp +80104d5d: 89 43 08 mov %eax,0x8(%ebx) +80104d60: 85 c0 test %eax,%eax +80104d62: 74 44 je 80104da8 + sp -= sizeof *p->tf; +80104d64: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx + memset(p->context, 0, sizeof *p->context); +80104d6a: 83 ec 04 sub $0x4,%esp + sp -= sizeof *p->context; +80104d6d: 05 9c 0f 00 00 add $0xf9c,%eax + sp -= sizeof *p->tf; +80104d72: 89 53 18 mov %edx,0x18(%ebx) + *(uint*)sp = (uint)trapret; +80104d75: c7 40 14 e9 6f 10 80 movl $0x80106fe9,0x14(%eax) + p->context = (struct context*)sp; +80104d7c: 89 43 1c mov %eax,0x1c(%ebx) + memset(p->context, 0, sizeof *p->context); +80104d7f: 6a 14 push $0x14 +80104d81: 6a 00 push $0x0 +80104d83: 50 push %eax +80104d84: e8 b7 0e 00 00 call 80105c40 + p->context->eip = (uint)forkret; +80104d89: 8b 43 1c mov 0x1c(%ebx),%eax +80104d8c: c7 40 10 c0 4d 10 80 movl $0x80104dc0,0x10(%eax) + p->consoleptr = getbaseconsoleptr(); +80104d93: e8 b8 c2 ff ff call 80101050 + return p; +80104d98: 83 c4 10 add $0x10,%esp + p->consoleptr = getbaseconsoleptr(); +80104d9b: 89 43 7c mov %eax,0x7c(%ebx) +} +80104d9e: 89 d8 mov %ebx,%eax +80104da0: 8b 5d fc mov -0x4(%ebp),%ebx +80104da3: c9 leave +80104da4: c3 ret +80104da5: 8d 76 00 lea 0x0(%esi),%esi + p->state = UNUSED; +80104da8: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) + return 0; +80104daf: 31 db xor %ebx,%ebx +} +80104db1: 89 d8 mov %ebx,%eax +80104db3: 8b 5d fc mov -0x4(%ebp),%ebx +80104db6: c9 leave +80104db7: c3 ret +80104db8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104dbf: 90 nop + +80104dc0 : + release(&ptable.lock); +} + +// A fork child's very first scheduling by scheduler() +// will swtch here. "Return" to user space. +void forkret(void) { +80104dc0: 55 push %ebp +80104dc1: 89 e5 mov %esp,%ebp +80104dc3: 83 ec 14 sub $0x14,%esp + static int first = 1; + // Still holding ptable.lock from scheduler. + release(&ptable.lock); +80104dc6: 68 a0 e4 11 80 push $0x8011e4a0 +80104dcb: e8 50 0d 00 00 call 80105b20 + + if (first) { +80104dd0: a1 00 c0 10 80 mov 0x8010c000,%eax +80104dd5: 83 c4 10 add $0x10,%esp +80104dd8: 85 c0 test %eax,%eax +80104dda: 75 04 jne 80104de0 + iinit(ROOTDEV); + initlog(ROOTDEV); + } + + // Return to "caller", actually trapret (see allocproc). +} +80104ddc: c9 leave +80104ddd: c3 ret +80104dde: 66 90 xchg %ax,%ax + first = 0; +80104de0: c7 05 00 c0 10 80 00 movl $0x0,0x8010c000 +80104de7: 00 00 00 + iinit(ROOTDEV); +80104dea: 83 ec 0c sub $0xc,%esp +80104ded: 6a 01 push $0x1 +80104def: e8 5c dc ff ff call 80102a50 + initlog(ROOTDEV); +80104df4: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80104dfb: e8 b0 f3 ff ff call 801041b0 +} +80104e00: 83 c4 10 add $0x10,%esp +80104e03: c9 leave +80104e04: c3 ret +80104e05: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104e0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80104e10 : +void pinit(void) { +80104e10: 55 push %ebp +80104e11: 89 e5 mov %esp,%ebp +80104e13: 83 ec 10 sub $0x10,%esp + initlock(&ptable.lock, "ptable"); +80104e16: 68 60 8f 10 80 push $0x80108f60 +80104e1b: 68 a0 e4 11 80 push $0x8011e4a0 +80104e20: e8 8b 0b 00 00 call 801059b0 +} +80104e25: 83 c4 10 add $0x10,%esp +80104e28: c9 leave +80104e29: c3 ret +80104e2a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80104e30 : +struct cpu*mycpu(void) { +80104e30: 55 push %ebp +80104e31: 89 e5 mov %esp,%ebp +80104e33: 56 push %esi +80104e34: 53 push %ebx + asm volatile ("pushfl; popl %0" : "=r" (eflags)); +80104e35: 9c pushf +80104e36: 58 pop %eax + if (readeflags() & FL_IF) { +80104e37: f6 c4 02 test $0x2,%ah +80104e3a: 75 46 jne 80104e82 + apicid = lapicid(); +80104e3c: e8 9f ef ff ff call 80103de0 + for (i = 0; i < ncpu; ++i) { +80104e41: 8b 35 04 df 11 80 mov 0x8011df04,%esi +80104e47: 85 f6 test %esi,%esi +80104e49: 7e 2a jle 80104e75 +80104e4b: 31 d2 xor %edx,%edx +80104e4d: eb 08 jmp 80104e57 +80104e4f: 90 nop +80104e50: 83 c2 01 add $0x1,%edx +80104e53: 39 f2 cmp %esi,%edx +80104e55: 74 1e je 80104e75 + if (cpus[i].apicid == apicid) { +80104e57: 69 ca b0 00 00 00 imul $0xb0,%edx,%ecx +80104e5d: 0f b6 99 20 df 11 80 movzbl -0x7fee20e0(%ecx),%ebx +80104e64: 39 c3 cmp %eax,%ebx +80104e66: 75 e8 jne 80104e50 +} +80104e68: 8d 65 f8 lea -0x8(%ebp),%esp + return &cpus[i]; +80104e6b: 8d 81 20 df 11 80 lea -0x7fee20e0(%ecx),%eax +} +80104e71: 5b pop %ebx +80104e72: 5e pop %esi +80104e73: 5d pop %ebp +80104e74: c3 ret + panic("unknown apicid\n"); +80104e75: 83 ec 0c sub $0xc,%esp +80104e78: 68 67 8f 10 80 push $0x80108f67 +80104e7d: e8 fe b5 ff ff call 80100480 + panic("mycpu called with interrupts enabled\n"); +80104e82: 83 ec 0c sub $0xc,%esp +80104e85: 68 58 90 10 80 push $0x80109058 +80104e8a: e8 f1 b5 ff ff call 80100480 +80104e8f: 90 nop + +80104e90 : +int cpuid() { +80104e90: 55 push %ebp +80104e91: 89 e5 mov %esp,%ebp +80104e93: 83 ec 08 sub $0x8,%esp + return mycpu() - cpus; +80104e96: e8 95 ff ff ff call 80104e30 +} +80104e9b: c9 leave + return mycpu() - cpus; +80104e9c: 2d 20 df 11 80 sub $0x8011df20,%eax +80104ea1: c1 f8 04 sar $0x4,%eax +80104ea4: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax +} +80104eaa: c3 ret +80104eab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104eaf: 90 nop + +80104eb0 : +struct proc*myproc(void) { +80104eb0: 55 push %ebp +80104eb1: 89 e5 mov %esp,%ebp +80104eb3: 53 push %ebx +80104eb4: 83 ec 04 sub $0x4,%esp + pushcli(); +80104eb7: e8 74 0b 00 00 call 80105a30 + c = mycpu(); +80104ebc: e8 6f ff ff ff call 80104e30 + p = c->proc; +80104ec1: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +80104ec7: e8 b4 0b 00 00 call 80105a80 +} +80104ecc: 89 d8 mov %ebx,%eax +80104ece: 8b 5d fc mov -0x4(%ebp),%ebx +80104ed1: c9 leave +80104ed2: c3 ret +80104ed3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104eda: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80104ee0 : +void userinit(void) { +80104ee0: 55 push %ebp +80104ee1: 89 e5 mov %esp,%ebp +80104ee3: 53 push %ebx +80104ee4: 83 ec 04 sub $0x4,%esp + p = allocproc(); +80104ee7: e8 f4 fd ff ff call 80104ce0 +80104eec: 89 c3 mov %eax,%ebx + initproc = p; +80104eee: a3 d4 09 12 80 mov %eax,0x801209d4 + if ((p->pgdir = setupkvm()) == 0) { +80104ef3: e8 e8 36 00 00 call 801085e0 +80104ef8: 89 43 04 mov %eax,0x4(%ebx) +80104efb: 85 c0 test %eax,%eax +80104efd: 0f 84 db 00 00 00 je 80104fde + inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); +80104f03: 83 ec 04 sub $0x4,%esp +80104f06: 68 2c 00 00 00 push $0x2c +80104f0b: 68 60 c4 10 80 push $0x8010c460 +80104f10: 50 push %eax +80104f11: e8 7a 33 00 00 call 80108290 + memset(p->tf, 0, sizeof(*p->tf)); +80104f16: 83 c4 0c add $0xc,%esp + p->sz = PGSIZE; +80104f19: c7 03 00 10 00 00 movl $0x1000,(%ebx) + memset(p->tf, 0, sizeof(*p->tf)); +80104f1f: 6a 4c push $0x4c +80104f21: 6a 00 push $0x0 +80104f23: ff 73 18 push 0x18(%ebx) +80104f26: e8 15 0d 00 00 call 80105c40 + p->tf->cs = (SEG_UCODE << 3) | DPL_USER; +80104f2b: 8b 43 18 mov 0x18(%ebx),%eax +80104f2e: ba 1b 00 00 00 mov $0x1b,%edx + safestrcpy(p->name, "initcode", sizeof(p->name)); +80104f33: 83 c4 0c add $0xc,%esp + p->tf->ds = (SEG_UDATA << 3) | DPL_USER; +80104f36: b9 23 00 00 00 mov $0x23,%ecx + p->tf->cs = (SEG_UCODE << 3) | DPL_USER; +80104f3b: 66 89 50 3c mov %dx,0x3c(%eax) + p->tf->ds = (SEG_UDATA << 3) | DPL_USER; +80104f3f: 8b 43 18 mov 0x18(%ebx),%eax +80104f42: 66 89 48 2c mov %cx,0x2c(%eax) + p->tf->es = p->tf->ds; +80104f46: 8b 43 18 mov 0x18(%ebx),%eax +80104f49: 0f b7 50 2c movzwl 0x2c(%eax),%edx +80104f4d: 66 89 50 28 mov %dx,0x28(%eax) + p->tf->ss = p->tf->ds; +80104f51: 8b 43 18 mov 0x18(%ebx),%eax +80104f54: 0f b7 50 2c movzwl 0x2c(%eax),%edx +80104f58: 66 89 50 48 mov %dx,0x48(%eax) + p->tf->eflags = FL_IF; +80104f5c: 8b 43 18 mov 0x18(%ebx),%eax +80104f5f: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) + p->tf->esp = PGSIZE; +80104f66: 8b 43 18 mov 0x18(%ebx),%eax +80104f69: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) + p->tf->eip = 0; // beginning of initcode.S +80104f70: 8b 43 18 mov 0x18(%ebx),%eax +80104f73: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) + safestrcpy(p->name, "initcode", sizeof(p->name)); +80104f7a: 8d 43 6c lea 0x6c(%ebx),%eax +80104f7d: 6a 10 push $0x10 +80104f7f: 68 90 8f 10 80 push $0x80108f90 +80104f84: 50 push %eax +80104f85: e8 76 0e 00 00 call 80105e00 + p->cwd = namei("/"); +80104f8a: c7 04 24 99 8f 10 80 movl $0x80108f99,(%esp) +80104f91: e8 fa e5 ff ff call 80103590 +80104f96: 89 43 68 mov %eax,0x68(%ebx) + p->consoleptr = getbaseconsoleptr(); +80104f99: e8 b2 c0 ff ff call 80101050 + safestrcpy(p->title, "Shell (Root)", sizeof(p->title)); +80104f9e: 83 c4 0c add $0xc,%esp + p->consoleptr = getbaseconsoleptr(); +80104fa1: 89 43 7c mov %eax,0x7c(%ebx) + safestrcpy(p->title, "Shell (Root)", sizeof(p->title)); +80104fa4: 8d 83 80 00 00 00 lea 0x80(%ebx),%eax +80104faa: 6a 14 push $0x14 +80104fac: 68 9b 8f 10 80 push $0x80108f9b +80104fb1: 50 push %eax +80104fb2: e8 49 0e 00 00 call 80105e00 + acquire(&ptable.lock); +80104fb7: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +80104fbe: e8 bd 0b 00 00 call 80105b80 + p->state = RUNNABLE; +80104fc3: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) + release(&ptable.lock); +80104fca: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +80104fd1: e8 4a 0b 00 00 call 80105b20 +} +80104fd6: 8b 5d fc mov -0x4(%ebp),%ebx +80104fd9: 83 c4 10 add $0x10,%esp +80104fdc: c9 leave +80104fdd: c3 ret + panic("userinit: out of memory?"); +80104fde: 83 ec 0c sub $0xc,%esp +80104fe1: 68 77 8f 10 80 push $0x80108f77 +80104fe6: e8 95 b4 ff ff call 80100480 +80104feb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104fef: 90 nop + +80104ff0 : +int growproc(int n) { +80104ff0: 55 push %ebp +80104ff1: 89 e5 mov %esp,%ebp +80104ff3: 56 push %esi +80104ff4: 53 push %ebx +80104ff5: 8b 75 08 mov 0x8(%ebp),%esi + pushcli(); +80104ff8: e8 33 0a 00 00 call 80105a30 + c = mycpu(); +80104ffd: e8 2e fe ff ff call 80104e30 + p = c->proc; +80105002: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +80105008: e8 73 0a 00 00 call 80105a80 + sz = curproc->sz; +8010500d: 8b 03 mov (%ebx),%eax + if (n > 0) { +8010500f: 85 f6 test %esi,%esi +80105011: 7f 1d jg 80105030 + else if (n < 0) { +80105013: 75 3b jne 80105050 + switchuvm(curproc); +80105015: 83 ec 0c sub $0xc,%esp + curproc->sz = sz; +80105018: 89 03 mov %eax,(%ebx) + switchuvm(curproc); +8010501a: 53 push %ebx +8010501b: e8 60 31 00 00 call 80108180 + return 0; +80105020: 83 c4 10 add $0x10,%esp +80105023: 31 c0 xor %eax,%eax +} +80105025: 8d 65 f8 lea -0x8(%ebp),%esp +80105028: 5b pop %ebx +80105029: 5e pop %esi +8010502a: 5d pop %ebp +8010502b: c3 ret +8010502c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if ((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) { +80105030: 83 ec 04 sub $0x4,%esp +80105033: 01 c6 add %eax,%esi +80105035: 56 push %esi +80105036: 50 push %eax +80105037: ff 73 04 push 0x4(%ebx) +8010503a: e8 c1 33 00 00 call 80108400 +8010503f: 83 c4 10 add $0x10,%esp +80105042: 85 c0 test %eax,%eax +80105044: 75 cf jne 80105015 + return -1; +80105046: b8 ff ff ff ff mov $0xffffffff,%eax +8010504b: eb d8 jmp 80105025 +8010504d: 8d 76 00 lea 0x0(%esi),%esi + if ((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) { +80105050: 83 ec 04 sub $0x4,%esp +80105053: 01 c6 add %eax,%esi +80105055: 56 push %esi +80105056: 50 push %eax +80105057: ff 73 04 push 0x4(%ebx) +8010505a: e8 d1 34 00 00 call 80108530 +8010505f: 83 c4 10 add $0x10,%esp +80105062: 85 c0 test %eax,%eax +80105064: 75 af jne 80105015 +80105066: eb de jmp 80105046 +80105068: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010506f: 90 nop + +80105070 : +int fork(void) { +80105070: 55 push %ebp +80105071: 89 e5 mov %esp,%ebp +80105073: 57 push %edi +80105074: 56 push %esi +80105075: 53 push %ebx +80105076: 83 ec 1c sub $0x1c,%esp + pushcli(); +80105079: e8 b2 09 00 00 call 80105a30 + c = mycpu(); +8010507e: e8 ad fd ff ff call 80104e30 + p = c->proc; +80105083: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +80105089: e8 f2 09 00 00 call 80105a80 + if ((np = allocproc()) == 0) { +8010508e: e8 4d fc ff ff call 80104ce0 +80105093: 89 45 e4 mov %eax,-0x1c(%ebp) +80105096: 85 c0 test %eax,%eax +80105098: 0f 84 bd 00 00 00 je 8010515b + if ((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0) { +8010509e: 83 ec 08 sub $0x8,%esp +801050a1: ff 33 push (%ebx) +801050a3: 89 c7 mov %eax,%edi +801050a5: ff 73 04 push 0x4(%ebx) +801050a8: e8 23 36 00 00 call 801086d0 +801050ad: 83 c4 10 add $0x10,%esp +801050b0: 89 47 04 mov %eax,0x4(%edi) +801050b3: 85 c0 test %eax,%eax +801050b5: 0f 84 a7 00 00 00 je 80105162 + np->sz = curproc->sz; +801050bb: 8b 03 mov (%ebx),%eax +801050bd: 8b 4d e4 mov -0x1c(%ebp),%ecx +801050c0: 89 01 mov %eax,(%ecx) + *np->tf = *curproc->tf; +801050c2: 8b 79 18 mov 0x18(%ecx),%edi + np->parent = curproc; +801050c5: 89 c8 mov %ecx,%eax +801050c7: 89 59 14 mov %ebx,0x14(%ecx) + *np->tf = *curproc->tf; +801050ca: b9 13 00 00 00 mov $0x13,%ecx +801050cf: 8b 73 18 mov 0x18(%ebx),%esi +801050d2: f3 a5 rep movsl %ds:(%esi),%es:(%edi) + for (i = 0; i < NOFILE; i++) { +801050d4: 31 f6 xor %esi,%esi + np->tf->eax = 0; +801050d6: 8b 40 18 mov 0x18(%eax),%eax +801050d9: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) + if (curproc->ofile[i]) { +801050e0: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax +801050e4: 85 c0 test %eax,%eax +801050e6: 74 13 je 801050fb + np->ofile[i] = filedup(curproc->ofile[i]); +801050e8: 83 ec 0c sub $0xc,%esp +801050eb: 50 push %eax +801050ec: e8 9f d2 ff ff call 80102390 +801050f1: 8b 55 e4 mov -0x1c(%ebp),%edx +801050f4: 83 c4 10 add $0x10,%esp +801050f7: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4) + for (i = 0; i < NOFILE; i++) { +801050fb: 83 c6 01 add $0x1,%esi +801050fe: 83 fe 10 cmp $0x10,%esi +80105101: 75 dd jne 801050e0 + np->cwd = idup(curproc->cwd); +80105103: 83 ec 0c sub $0xc,%esp +80105106: ff 73 68 push 0x68(%ebx) +80105109: e8 32 db ff ff call 80102c40 +8010510e: 8b 7d e4 mov -0x1c(%ebp),%edi + safestrcpy(np->name, curproc->name, sizeof(curproc->name)); +80105111: 83 c4 0c add $0xc,%esp + np->cwd = idup(curproc->cwd); +80105114: 89 47 68 mov %eax,0x68(%edi) + safestrcpy(np->name, curproc->name, sizeof(curproc->name)); +80105117: 8d 43 6c lea 0x6c(%ebx),%eax +8010511a: 6a 10 push $0x10 +8010511c: 50 push %eax +8010511d: 8d 47 6c lea 0x6c(%edi),%eax +80105120: 50 push %eax +80105121: e8 da 0c 00 00 call 80105e00 + pid = np->pid; +80105126: 8b 77 10 mov 0x10(%edi),%esi + acquire(&ptable.lock); +80105129: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +80105130: e8 4b 0a 00 00 call 80105b80 + np->state = RUNNABLE; +80105135: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi) + np->consoleptr = curproc->consoleptr; +8010513c: 8b 43 7c mov 0x7c(%ebx),%eax +8010513f: 89 47 7c mov %eax,0x7c(%edi) + release(&ptable.lock); +80105142: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +80105149: e8 d2 09 00 00 call 80105b20 + return pid; +8010514e: 83 c4 10 add $0x10,%esp +} +80105151: 8d 65 f4 lea -0xc(%ebp),%esp +80105154: 89 f0 mov %esi,%eax +80105156: 5b pop %ebx +80105157: 5e pop %esi +80105158: 5f pop %edi +80105159: 5d pop %ebp +8010515a: c3 ret + return -1; +8010515b: be ff ff ff ff mov $0xffffffff,%esi +80105160: eb ef jmp 80105151 + kfree(np->kstack); +80105162: 8b 5d e4 mov -0x1c(%ebp),%ebx +80105165: 83 ec 0c sub $0xc,%esp + return -1; +80105168: be ff ff ff ff mov $0xffffffff,%esi + kfree(np->kstack); +8010516d: ff 73 08 push 0x8(%ebx) +80105170: e8 3b e8 ff ff call 801039b0 + np->kstack = 0; +80105175: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) + return -1; +8010517c: 83 c4 10 add $0x10,%esp + np->state = UNUSED; +8010517f: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) + return -1; +80105186: eb c9 jmp 80105151 +80105188: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010518f: 90 nop + +80105190 : +void scheduler(void) { +80105190: 55 push %ebp +80105191: 89 e5 mov %esp,%ebp +80105193: 57 push %edi +80105194: 56 push %esi +80105195: 53 push %ebx +80105196: 83 ec 0c sub $0xc,%esp + struct cpu *c = mycpu(); +80105199: e8 92 fc ff ff call 80104e30 + c->proc = 0; +8010519e: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) +801051a5: 00 00 00 + struct cpu *c = mycpu(); +801051a8: 89 c6 mov %eax,%esi + c->proc = 0; +801051aa: 8d 78 04 lea 0x4(%eax),%edi +801051ad: 8d 76 00 lea 0x0(%esi),%esi + asm volatile ("sti"); +801051b0: fb sti + acquire(&ptable.lock); +801051b1: 83 ec 0c sub $0xc,%esp + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801051b4: bb d4 e4 11 80 mov $0x8011e4d4,%ebx + acquire(&ptable.lock); +801051b9: 68 a0 e4 11 80 push $0x8011e4a0 +801051be: e8 bd 09 00 00 call 80105b80 +801051c3: 83 c4 10 add $0x10,%esp +801051c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801051cd: 8d 76 00 lea 0x0(%esi),%esi + if (p->state != RUNNABLE) { +801051d0: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) +801051d4: 75 33 jne 80105209 + switchuvm(p); +801051d6: 83 ec 0c sub $0xc,%esp + c->proc = p; +801051d9: 89 9e ac 00 00 00 mov %ebx,0xac(%esi) + switchuvm(p); +801051df: 53 push %ebx +801051e0: e8 9b 2f 00 00 call 80108180 + swtch(&(c->scheduler), p->context); +801051e5: 58 pop %eax +801051e6: 5a pop %edx +801051e7: ff 73 1c push 0x1c(%ebx) +801051ea: 57 push %edi + p->state = RUNNING; +801051eb: c7 43 0c 04 00 00 00 movl $0x4,0xc(%ebx) + swtch(&(c->scheduler), p->context); +801051f2: e8 64 0c 00 00 call 80105e5b + switchkvm(); +801051f7: e8 74 2f 00 00 call 80108170 + c->proc = 0; +801051fc: 83 c4 10 add $0x10,%esp +801051ff: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi) +80105206: 00 00 00 + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +80105209: 81 c3 94 00 00 00 add $0x94,%ebx +8010520f: 81 fb d4 09 12 80 cmp $0x801209d4,%ebx +80105215: 75 b9 jne 801051d0 + release(&ptable.lock); +80105217: 83 ec 0c sub $0xc,%esp +8010521a: 68 a0 e4 11 80 push $0x8011e4a0 +8010521f: e8 fc 08 00 00 call 80105b20 + sti(); +80105224: 83 c4 10 add $0x10,%esp +80105227: eb 87 jmp 801051b0 +80105229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80105230 : +void sched(void) { +80105230: 55 push %ebp +80105231: 89 e5 mov %esp,%ebp +80105233: 56 push %esi +80105234: 53 push %ebx + pushcli(); +80105235: e8 f6 07 00 00 call 80105a30 + c = mycpu(); +8010523a: e8 f1 fb ff ff call 80104e30 + p = c->proc; +8010523f: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +80105245: e8 36 08 00 00 call 80105a80 + if (!holding(&ptable.lock)) { +8010524a: 83 ec 0c sub $0xc,%esp +8010524d: 68 a0 e4 11 80 push $0x8011e4a0 +80105252: e8 89 08 00 00 call 80105ae0 +80105257: 83 c4 10 add $0x10,%esp +8010525a: 85 c0 test %eax,%eax +8010525c: 74 4f je 801052ad + if (mycpu()->ncli != 1) { +8010525e: e8 cd fb ff ff call 80104e30 +80105263: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) +8010526a: 75 68 jne 801052d4 + if (p->state == RUNNING) { +8010526c: 83 7b 0c 04 cmpl $0x4,0xc(%ebx) +80105270: 74 55 je 801052c7 + asm volatile ("pushfl; popl %0" : "=r" (eflags)); +80105272: 9c pushf +80105273: 58 pop %eax + if (readeflags() & FL_IF) { +80105274: f6 c4 02 test $0x2,%ah +80105277: 75 41 jne 801052ba + intena = mycpu()->intena; +80105279: e8 b2 fb ff ff call 80104e30 + swtch(&p->context, mycpu()->scheduler); +8010527e: 83 c3 1c add $0x1c,%ebx + intena = mycpu()->intena; +80105281: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi + swtch(&p->context, mycpu()->scheduler); +80105287: e8 a4 fb ff ff call 80104e30 +8010528c: 83 ec 08 sub $0x8,%esp +8010528f: ff 70 04 push 0x4(%eax) +80105292: 53 push %ebx +80105293: e8 c3 0b 00 00 call 80105e5b + mycpu()->intena = intena; +80105298: e8 93 fb ff ff call 80104e30 +} +8010529d: 83 c4 10 add $0x10,%esp + mycpu()->intena = intena; +801052a0: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) +} +801052a6: 8d 65 f8 lea -0x8(%ebp),%esp +801052a9: 5b pop %ebx +801052aa: 5e pop %esi +801052ab: 5d pop %ebp +801052ac: c3 ret + panic("sched ptable.lock"); +801052ad: 83 ec 0c sub $0xc,%esp +801052b0: 68 a8 8f 10 80 push $0x80108fa8 +801052b5: e8 c6 b1 ff ff call 80100480 + panic("sched interruptible"); +801052ba: 83 ec 0c sub $0xc,%esp +801052bd: 68 d4 8f 10 80 push $0x80108fd4 +801052c2: e8 b9 b1 ff ff call 80100480 + panic("sched running"); +801052c7: 83 ec 0c sub $0xc,%esp +801052ca: 68 c6 8f 10 80 push $0x80108fc6 +801052cf: e8 ac b1 ff ff call 80100480 + panic("sched locks"); +801052d4: 83 ec 0c sub $0xc,%esp +801052d7: 68 ba 8f 10 80 push $0x80108fba +801052dc: e8 9f b1 ff ff call 80100480 +801052e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801052e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801052ef: 90 nop + +801052f0 : +void exit(void) { +801052f0: 55 push %ebp +801052f1: 89 e5 mov %esp,%ebp +801052f3: 57 push %edi +801052f4: 56 push %esi +801052f5: 53 push %ebx +801052f6: 83 ec 0c sub $0xc,%esp + struct proc *curproc = myproc(); +801052f9: e8 b2 fb ff ff call 80104eb0 + if (curproc == initproc) { +801052fe: 39 05 d4 09 12 80 cmp %eax,0x801209d4 +80105304: 0f 84 39 01 00 00 je 80105443 +8010530a: 89 c6 mov %eax,%esi +8010530c: 8d 58 28 lea 0x28(%eax),%ebx +8010530f: 8d 78 68 lea 0x68(%eax),%edi +80105312: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (curproc->ofile[fd]) { +80105318: 8b 03 mov (%ebx),%eax +8010531a: 85 c0 test %eax,%eax +8010531c: 74 12 je 80105330 + fileclose(curproc->ofile[fd]); +8010531e: 83 ec 0c sub $0xc,%esp +80105321: 50 push %eax +80105322: e8 b9 d0 ff ff call 801023e0 + curproc->ofile[fd] = 0; +80105327: c7 03 00 00 00 00 movl $0x0,(%ebx) +8010532d: 83 c4 10 add $0x10,%esp + for (fd = 0; fd < NOFILE; fd++) { +80105330: 83 c3 04 add $0x4,%ebx +80105333: 39 df cmp %ebx,%edi +80105335: 75 e1 jne 80105318 + begin_op(); +80105337: e8 14 ef ff ff call 80104250 + iput(curproc->cwd); +8010533c: 83 ec 0c sub $0xc,%esp +8010533f: ff 76 68 push 0x68(%esi) +80105342: e8 59 da ff ff call 80102da0 + end_op(); +80105347: e8 74 ef ff ff call 801042c0 + curproc->cwd = 0; +8010534c: c7 46 68 00 00 00 00 movl $0x0,0x68(%esi) + acquire(&ptable.lock); +80105353: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +8010535a: e8 21 08 00 00 call 80105b80 + wakeup1(curproc->parent); +8010535f: 8b 56 14 mov 0x14(%esi),%edx +80105362: 83 c4 10 add $0x10,%esp +// Wake up all processes sleeping on chan. +// The ptable lock must be held. +static void wakeup1(void *chan) { + struct proc *p; + + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +80105365: b8 d4 e4 11 80 mov $0x8011e4d4,%eax +8010536a: eb 10 jmp 8010537c +8010536c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105370: 05 94 00 00 00 add $0x94,%eax +80105375: 3d d4 09 12 80 cmp $0x801209d4,%eax +8010537a: 74 1e je 8010539a + if (p->state == SLEEPING && p->chan == chan) { +8010537c: 83 78 0c 02 cmpl $0x2,0xc(%eax) +80105380: 75 ee jne 80105370 +80105382: 3b 50 20 cmp 0x20(%eax),%edx +80105385: 75 e9 jne 80105370 + p->state = RUNNABLE; +80105387: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +8010538e: 05 94 00 00 00 add $0x94,%eax +80105393: 3d d4 09 12 80 cmp $0x801209d4,%eax +80105398: 75 e2 jne 8010537c + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +8010539a: bb d4 e4 11 80 mov $0x8011e4d4,%ebx +8010539f: eb 15 jmp 801053b6 +801053a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801053a8: 81 c3 94 00 00 00 add $0x94,%ebx +801053ae: 81 fb d4 09 12 80 cmp $0x801209d4,%ebx +801053b4: 74 4a je 80105400 + if (p->parent == curproc) { +801053b6: 39 73 14 cmp %esi,0x14(%ebx) +801053b9: 75 ed jne 801053a8 + p->parent = initproc; +801053bb: a1 d4 09 12 80 mov 0x801209d4,%eax +801053c0: 89 43 14 mov %eax,0x14(%ebx) + p->consoleptr = getbaseconsoleptr(); +801053c3: e8 88 bc ff ff call 80101050 + if (p->state == ZOMBIE) { +801053c8: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) + p->consoleptr = getbaseconsoleptr(); +801053cc: 89 43 7c mov %eax,0x7c(%ebx) + if (p->state == ZOMBIE) { +801053cf: 75 d7 jne 801053a8 + wakeup1(initproc); +801053d1: 8b 15 d4 09 12 80 mov 0x801209d4,%edx + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801053d7: b8 d4 e4 11 80 mov $0x8011e4d4,%eax +801053dc: eb 0e jmp 801053ec +801053de: 66 90 xchg %ax,%ax +801053e0: 05 94 00 00 00 add $0x94,%eax +801053e5: 3d d4 09 12 80 cmp $0x801209d4,%eax +801053ea: 74 bc je 801053a8 + if (p->state == SLEEPING && p->chan == chan) { +801053ec: 83 78 0c 02 cmpl $0x2,0xc(%eax) +801053f0: 75 ee jne 801053e0 +801053f2: 3b 50 20 cmp 0x20(%eax),%edx +801053f5: 75 e9 jne 801053e0 + p->state = RUNNABLE; +801053f7: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) +801053fe: eb e0 jmp 801053e0 + if (curproc->consoleptr != getbaseconsoleptr()) +80105400: 8b 5e 7c mov 0x7c(%esi),%ebx +80105403: e8 48 bc ff ff call 80101050 +80105408: 39 c3 cmp %eax,%ebx +8010540a: 74 05 je 80105411 + closeconsole(); +8010540c: e8 2f c9 ff ff call 80101d40 + if (curproc->consoleptr != 0) +80105411: 8b 46 7c mov 0x7c(%esi),%eax +80105414: 85 c0 test %eax,%eax +80105416: 74 12 je 8010542a + setconsoleproctitle(curproc->consoleptr, curproc->parent->name); +80105418: 52 push %edx +80105419: 52 push %edx +8010541a: 8b 4e 14 mov 0x14(%esi),%ecx +8010541d: 8d 51 6c lea 0x6c(%ecx),%edx +80105420: 52 push %edx +80105421: 50 push %eax +80105422: e8 39 ca ff ff call 80101e60 +80105427: 83 c4 10 add $0x10,%esp + curproc->state = ZOMBIE; +8010542a: c7 46 0c 05 00 00 00 movl $0x5,0xc(%esi) + sched(); +80105431: e8 fa fd ff ff call 80105230 + panic("zombie exit"); +80105436: 83 ec 0c sub $0xc,%esp +80105439: 68 f5 8f 10 80 push $0x80108ff5 +8010543e: e8 3d b0 ff ff call 80100480 + panic("init exiting"); +80105443: 83 ec 0c sub $0xc,%esp +80105446: 68 e8 8f 10 80 push $0x80108fe8 +8010544b: e8 30 b0 ff ff call 80100480 + +80105450 : +int wait(void) { +80105450: 55 push %ebp +80105451: 89 e5 mov %esp,%ebp +80105453: 56 push %esi +80105454: 53 push %ebx + pushcli(); +80105455: e8 d6 05 00 00 call 80105a30 + c = mycpu(); +8010545a: e8 d1 f9 ff ff call 80104e30 + p = c->proc; +8010545f: 8b b0 ac 00 00 00 mov 0xac(%eax),%esi + popcli(); +80105465: e8 16 06 00 00 call 80105a80 + acquire(&ptable.lock); +8010546a: 83 ec 0c sub $0xc,%esp +8010546d: 68 a0 e4 11 80 push $0x8011e4a0 +80105472: e8 09 07 00 00 call 80105b80 +80105477: 83 c4 10 add $0x10,%esp + havekids = 0; +8010547a: 31 c0 xor %eax,%eax + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +8010547c: bb d4 e4 11 80 mov $0x8011e4d4,%ebx +80105481: eb 13 jmp 80105496 +80105483: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105487: 90 nop +80105488: 81 c3 94 00 00 00 add $0x94,%ebx +8010548e: 81 fb d4 09 12 80 cmp $0x801209d4,%ebx +80105494: 74 1e je 801054b4 + if (p->parent != curproc) { +80105496: 39 73 14 cmp %esi,0x14(%ebx) +80105499: 75 ed jne 80105488 + if (p->state == ZOMBIE) { +8010549b: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) +8010549f: 74 5f je 80105500 + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801054a1: 81 c3 94 00 00 00 add $0x94,%ebx + havekids = 1; +801054a7: b8 01 00 00 00 mov $0x1,%eax + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801054ac: 81 fb d4 09 12 80 cmp $0x801209d4,%ebx +801054b2: 75 e2 jne 80105496 + if (!havekids || curproc->killed) { +801054b4: 85 c0 test %eax,%eax +801054b6: 0f 84 a1 00 00 00 je 8010555d +801054bc: 8b 46 24 mov 0x24(%esi),%eax +801054bf: 85 c0 test %eax,%eax +801054c1: 0f 85 96 00 00 00 jne 8010555d + pushcli(); +801054c7: e8 64 05 00 00 call 80105a30 + c = mycpu(); +801054cc: e8 5f f9 ff ff call 80104e30 + p = c->proc; +801054d1: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +801054d7: e8 a4 05 00 00 call 80105a80 + if (p == 0) { +801054dc: 85 db test %ebx,%ebx +801054de: 0f 84 90 00 00 00 je 80105574 + p->chan = chan; +801054e4: 89 73 20 mov %esi,0x20(%ebx) + p->state = SLEEPING; +801054e7: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) + sched(); +801054ee: e8 3d fd ff ff call 80105230 + p->chan = 0; +801054f3: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) +} +801054fa: e9 7b ff ff ff jmp 8010547a +801054ff: 90 nop + kfree(p->kstack); +80105500: 83 ec 0c sub $0xc,%esp + pid = p->pid; +80105503: 8b 73 10 mov 0x10(%ebx),%esi + kfree(p->kstack); +80105506: ff 73 08 push 0x8(%ebx) +80105509: e8 a2 e4 ff ff call 801039b0 + p->kstack = 0; +8010550e: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) + freevm(p->pgdir); +80105515: 5a pop %edx +80105516: ff 73 04 push 0x4(%ebx) +80105519: e8 42 30 00 00 call 80108560 + p->pid = 0; +8010551e: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) + p->parent = 0; +80105525: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) + p->name[0] = 0; +8010552c: c6 43 6c 00 movb $0x0,0x6c(%ebx) + p->killed = 0; +80105530: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) + p->state = UNUSED; +80105537: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) + p->consoleptr = 0; +8010553e: c7 43 7c 00 00 00 00 movl $0x0,0x7c(%ebx) + release(&ptable.lock); +80105545: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +8010554c: e8 cf 05 00 00 call 80105b20 + return pid; +80105551: 83 c4 10 add $0x10,%esp +} +80105554: 8d 65 f8 lea -0x8(%ebp),%esp +80105557: 89 f0 mov %esi,%eax +80105559: 5b pop %ebx +8010555a: 5e pop %esi +8010555b: 5d pop %ebp +8010555c: c3 ret + release(&ptable.lock); +8010555d: 83 ec 0c sub $0xc,%esp + return -1; +80105560: be ff ff ff ff mov $0xffffffff,%esi + release(&ptable.lock); +80105565: 68 a0 e4 11 80 push $0x8011e4a0 +8010556a: e8 b1 05 00 00 call 80105b20 + return -1; +8010556f: 83 c4 10 add $0x10,%esp +80105572: eb e0 jmp 80105554 + panic("sleep"); +80105574: 83 ec 0c sub $0xc,%esp +80105577: 68 01 90 10 80 push $0x80109001 +8010557c: e8 ff ae ff ff call 80100480 +80105581: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105588: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010558f: 90 nop + +80105590 : +void yield(void) { +80105590: 55 push %ebp +80105591: 89 e5 mov %esp,%ebp +80105593: 53 push %ebx +80105594: 83 ec 10 sub $0x10,%esp + acquire(&ptable.lock); //DOC: yieldlock +80105597: 68 a0 e4 11 80 push $0x8011e4a0 +8010559c: e8 df 05 00 00 call 80105b80 + pushcli(); +801055a1: e8 8a 04 00 00 call 80105a30 + c = mycpu(); +801055a6: e8 85 f8 ff ff call 80104e30 + p = c->proc; +801055ab: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +801055b1: e8 ca 04 00 00 call 80105a80 + myproc()->state = RUNNABLE; +801055b6: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) + sched(); +801055bd: e8 6e fc ff ff call 80105230 + release(&ptable.lock); +801055c2: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +801055c9: e8 52 05 00 00 call 80105b20 +} +801055ce: 8b 5d fc mov -0x4(%ebp),%ebx +801055d1: 83 c4 10 add $0x10,%esp +801055d4: c9 leave +801055d5: c3 ret +801055d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801055dd: 8d 76 00 lea 0x0(%esi),%esi + +801055e0 : +void sleep(void *chan, struct spinlock *lk) { +801055e0: 55 push %ebp +801055e1: 89 e5 mov %esp,%ebp +801055e3: 57 push %edi +801055e4: 56 push %esi +801055e5: 53 push %ebx +801055e6: 83 ec 0c sub $0xc,%esp +801055e9: 8b 7d 08 mov 0x8(%ebp),%edi +801055ec: 8b 75 0c mov 0xc(%ebp),%esi + pushcli(); +801055ef: e8 3c 04 00 00 call 80105a30 + c = mycpu(); +801055f4: e8 37 f8 ff ff call 80104e30 + p = c->proc; +801055f9: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +801055ff: e8 7c 04 00 00 call 80105a80 + if (p == 0) { +80105604: 85 db test %ebx,%ebx +80105606: 0f 84 87 00 00 00 je 80105693 + if (lk == 0) { +8010560c: 85 f6 test %esi,%esi +8010560e: 74 76 je 80105686 + if (lk != &ptable.lock) { //DOC: sleeplock0 +80105610: 81 fe a0 e4 11 80 cmp $0x8011e4a0,%esi +80105616: 74 50 je 80105668 + acquire(&ptable.lock); //DOC: sleeplock1 +80105618: 83 ec 0c sub $0xc,%esp +8010561b: 68 a0 e4 11 80 push $0x8011e4a0 +80105620: e8 5b 05 00 00 call 80105b80 + release(lk); +80105625: 89 34 24 mov %esi,(%esp) +80105628: e8 f3 04 00 00 call 80105b20 + p->chan = chan; +8010562d: 89 7b 20 mov %edi,0x20(%ebx) + p->state = SLEEPING; +80105630: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) + sched(); +80105637: e8 f4 fb ff ff call 80105230 + p->chan = 0; +8010563c: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) + release(&ptable.lock); +80105643: c7 04 24 a0 e4 11 80 movl $0x8011e4a0,(%esp) +8010564a: e8 d1 04 00 00 call 80105b20 + acquire(lk); +8010564f: 89 75 08 mov %esi,0x8(%ebp) +80105652: 83 c4 10 add $0x10,%esp +} +80105655: 8d 65 f4 lea -0xc(%ebp),%esp +80105658: 5b pop %ebx +80105659: 5e pop %esi +8010565a: 5f pop %edi +8010565b: 5d pop %ebp + acquire(lk); +8010565c: e9 1f 05 00 00 jmp 80105b80 +80105661: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + p->chan = chan; +80105668: 89 7b 20 mov %edi,0x20(%ebx) + p->state = SLEEPING; +8010566b: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) + sched(); +80105672: e8 b9 fb ff ff call 80105230 + p->chan = 0; +80105677: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) +} +8010567e: 8d 65 f4 lea -0xc(%ebp),%esp +80105681: 5b pop %ebx +80105682: 5e pop %esi +80105683: 5f pop %edi +80105684: 5d pop %ebp +80105685: c3 ret + panic("sleep without lk"); +80105686: 83 ec 0c sub $0xc,%esp +80105689: 68 07 90 10 80 push $0x80109007 +8010568e: e8 ed ad ff ff call 80100480 + panic("sleep"); +80105693: 83 ec 0c sub $0xc,%esp +80105696: 68 01 90 10 80 push $0x80109001 +8010569b: e8 e0 ad ff ff call 80100480 + +801056a0 : + } + } +} + +// Wake up all processes sleeping on chan. +void wakeup(void *chan) { +801056a0: 55 push %ebp +801056a1: 89 e5 mov %esp,%ebp +801056a3: 53 push %ebx +801056a4: 83 ec 10 sub $0x10,%esp +801056a7: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&ptable.lock); +801056aa: 68 a0 e4 11 80 push $0x8011e4a0 +801056af: e8 cc 04 00 00 call 80105b80 +801056b4: 83 c4 10 add $0x10,%esp + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801056b7: b8 d4 e4 11 80 mov $0x8011e4d4,%eax +801056bc: eb 0e jmp 801056cc +801056be: 66 90 xchg %ax,%ax +801056c0: 05 94 00 00 00 add $0x94,%eax +801056c5: 3d d4 09 12 80 cmp $0x801209d4,%eax +801056ca: 74 1e je 801056ea + if (p->state == SLEEPING && p->chan == chan) { +801056cc: 83 78 0c 02 cmpl $0x2,0xc(%eax) +801056d0: 75 ee jne 801056c0 +801056d2: 3b 58 20 cmp 0x20(%eax),%ebx +801056d5: 75 e9 jne 801056c0 + p->state = RUNNABLE; +801056d7: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801056de: 05 94 00 00 00 add $0x94,%eax +801056e3: 3d d4 09 12 80 cmp $0x801209d4,%eax +801056e8: 75 e2 jne 801056cc + wakeup1(chan); + release(&ptable.lock); +801056ea: c7 45 08 a0 e4 11 80 movl $0x8011e4a0,0x8(%ebp) +} +801056f1: 8b 5d fc mov -0x4(%ebp),%ebx +801056f4: c9 leave + release(&ptable.lock); +801056f5: e9 26 04 00 00 jmp 80105b20 +801056fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105700 : + +// Kill the process with the given pid. +// Process won't exit until it returns +// to user space (see trap in trap.c). +int kill(int pid) { +80105700: 55 push %ebp +80105701: 89 e5 mov %esp,%ebp +80105703: 53 push %ebx +80105704: 83 ec 10 sub $0x10,%esp +80105707: 8b 5d 08 mov 0x8(%ebp),%ebx + struct proc *p; + + acquire(&ptable.lock); +8010570a: 68 a0 e4 11 80 push $0x8011e4a0 +8010570f: e8 6c 04 00 00 call 80105b80 +80105714: 83 c4 10 add $0x10,%esp + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +80105717: b8 d4 e4 11 80 mov $0x8011e4d4,%eax +8010571c: eb 0e jmp 8010572c +8010571e: 66 90 xchg %ax,%ax +80105720: 05 94 00 00 00 add $0x94,%eax +80105725: 3d d4 09 12 80 cmp $0x801209d4,%eax +8010572a: 74 34 je 80105760 + if (p->pid == pid) { +8010572c: 39 58 10 cmp %ebx,0x10(%eax) +8010572f: 75 ef jne 80105720 + p->killed = 1; + // Wake process from sleep if necessary. + if (p->state == SLEEPING) { +80105731: 83 78 0c 02 cmpl $0x2,0xc(%eax) + p->killed = 1; +80105735: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) + if (p->state == SLEEPING) { +8010573c: 75 07 jne 80105745 + p->state = RUNNABLE; +8010573e: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) + } + release(&ptable.lock); +80105745: 83 ec 0c sub $0xc,%esp +80105748: 68 a0 e4 11 80 push $0x8011e4a0 +8010574d: e8 ce 03 00 00 call 80105b20 + return 0; + } + } + release(&ptable.lock); + return -1; +} +80105752: 8b 5d fc mov -0x4(%ebp),%ebx + return 0; +80105755: 83 c4 10 add $0x10,%esp +80105758: 31 c0 xor %eax,%eax +} +8010575a: c9 leave +8010575b: c3 ret +8010575c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + release(&ptable.lock); +80105760: 83 ec 0c sub $0xc,%esp +80105763: 68 a0 e4 11 80 push $0x8011e4a0 +80105768: e8 b3 03 00 00 call 80105b20 +} +8010576d: 8b 5d fc mov -0x4(%ebp),%ebx + return -1; +80105770: 83 c4 10 add $0x10,%esp +80105773: b8 ff ff ff ff mov $0xffffffff,%eax +} +80105778: c9 leave +80105779: c3 ret +8010577a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105780 : + +// Print a process listing to console. For debugging. +// Runs when user types ^P on console. +// No lock to avoid wedging a stuck machine further. +void procdump(void) { +80105780: 55 push %ebp +80105781: 89 e5 mov %esp,%ebp +80105783: 57 push %edi +80105784: 56 push %esi +80105785: 53 push %ebx +80105786: bb 40 e5 11 80 mov $0x8011e540,%ebx +8010578b: 83 ec 48 sub $0x48,%esp + int i; + struct proc *p; + char *state; + uint pc[10]; + + cprintf("Listing Processes\nPid(Parent) State Name(console)\n"); +8010578e: 68 80 90 10 80 push $0x80109080 +80105793: e8 f8 b0 ff ff call 80100890 + cprintf("-------------------------------\n"); +80105798: c7 04 24 b4 90 10 80 movl $0x801090b4,(%esp) +8010579f: e8 ec b0 ff ff call 80100890 + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801057a4: 83 c4 10 add $0x10,%esp +801057a7: eb 29 jmp 801057d2 +801057a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + // was 10 + for (i = 0; i < 5 && pc[i] != 0; i++) { + cprintf(" %p", pc[i]); + } + } + cprintf("\n"); +801057b0: 83 ec 0c sub $0xc,%esp +801057b3: 68 b3 94 10 80 push $0x801094b3 +801057b8: e8 d3 b0 ff ff call 80100890 +801057bd: 83 c4 10 add $0x10,%esp + for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { +801057c0: 81 c3 94 00 00 00 add $0x94,%ebx +801057c6: 81 fb 40 0a 12 80 cmp $0x80120a40,%ebx +801057cc: 0f 84 9e 00 00 00 je 80105870 + if (p->state == UNUSED) { +801057d2: 8b 43 a0 mov -0x60(%ebx),%eax +801057d5: 85 c0 test %eax,%eax +801057d7: 74 e7 je 801057c0 + state = "???"; +801057d9: bf 18 90 10 80 mov $0x80109018,%edi + if (p->state >= 0 && p->state < NELEM(states) && states[p->state]) { +801057de: 83 f8 05 cmp $0x5,%eax +801057e1: 77 11 ja 801057f4 +801057e3: 8b 3c 85 d8 90 10 80 mov -0x7fef6f28(,%eax,4),%edi + state = "???"; +801057ea: b8 18 90 10 80 mov $0x80109018,%eax +801057ef: 85 ff test %edi,%edi +801057f1: 0f 44 f8 cmove %eax,%edi + if (p->parent != 0x0) +801057f4: 8b 43 a8 mov -0x58(%ebx),%eax + int parentpid = 0; +801057f7: 31 f6 xor %esi,%esi + if (p->parent != 0x0) +801057f9: 85 c0 test %eax,%eax +801057fb: 74 03 je 80105800 + parentpid = p->parent->pid; +801057fd: 8b 70 10 mov 0x10(%eax),%esi + cprintf("%d(%d) %s %s(%d)", p->pid, parentpid, state, p->name, getconsoleindex(p->consoleptr)); +80105800: 83 ec 0c sub $0xc,%esp +80105803: ff 73 10 push 0x10(%ebx) +80105806: e8 65 ac ff ff call 80100470 +8010580b: 5a pop %edx +8010580c: 59 pop %ecx +8010580d: 50 push %eax +8010580e: 53 push %ebx +8010580f: 57 push %edi +80105810: 56 push %esi +80105811: ff 73 a4 push -0x5c(%ebx) +80105814: 68 1c 90 10 80 push $0x8010901c +80105819: e8 72 b0 ff ff call 80100890 + if (p->state == SLEEPING) { +8010581e: 83 c4 20 add $0x20,%esp +80105821: 83 7b a0 02 cmpl $0x2,-0x60(%ebx) +80105825: 75 89 jne 801057b0 + getcallerpcs((uint*)p->context->ebp + 2, pc); +80105827: 83 ec 08 sub $0x8,%esp +8010582a: 8d 45 c0 lea -0x40(%ebp),%eax +8010582d: 8d 75 c0 lea -0x40(%ebp),%esi +80105830: 50 push %eax +80105831: 8b 43 b0 mov -0x50(%ebx),%eax +80105834: 8d 7d d4 lea -0x2c(%ebp),%edi +80105837: 8b 40 0c mov 0xc(%eax),%eax +8010583a: 83 c0 08 add $0x8,%eax +8010583d: 50 push %eax +8010583e: e8 8d 01 00 00 call 801059d0 + for (i = 0; i < 5 && pc[i] != 0; i++) { +80105843: 83 c4 10 add $0x10,%esp +80105846: 8b 16 mov (%esi),%edx +80105848: 85 d2 test %edx,%edx +8010584a: 0f 84 60 ff ff ff je 801057b0 + cprintf(" %p", pc[i]); +80105850: 83 ec 08 sub $0x8,%esp + for (i = 0; i < 5 && pc[i] != 0; i++) { +80105853: 83 c6 04 add $0x4,%esi + cprintf(" %p", pc[i]); +80105856: 52 push %edx +80105857: 68 a1 89 10 80 push $0x801089a1 +8010585c: e8 2f b0 ff ff call 80100890 + for (i = 0; i < 5 && pc[i] != 0; i++) { +80105861: 83 c4 10 add $0x10,%esp +80105864: 39 f7 cmp %esi,%edi +80105866: 75 de jne 80105846 +80105868: e9 43 ff ff ff jmp 801057b0 +8010586d: 8d 76 00 lea 0x0(%esi),%esi + } +} +80105870: 8d 65 f4 lea -0xc(%ebp),%esp +80105873: 5b pop %ebx +80105874: 5e pop %esi +80105875: 5f pop %edi +80105876: 5d pop %ebp +80105877: c3 ret +80105878: 66 90 xchg %ax,%ax +8010587a: 66 90 xchg %ax,%ax +8010587c: 66 90 xchg %ax,%ax +8010587e: 66 90 xchg %ax,%ax + +80105880 : +#include "mmu.h" +#include "proc.h" +#include "spinlock.h" +#include "sleeplock.h" + +void initsleeplock(struct sleeplock *lk, char *name) { +80105880: 55 push %ebp +80105881: 89 e5 mov %esp,%ebp +80105883: 53 push %ebx +80105884: 83 ec 0c sub $0xc,%esp +80105887: 8b 5d 08 mov 0x8(%ebp),%ebx + initlock(&lk->lk, "sleep lock"); +8010588a: 68 f0 90 10 80 push $0x801090f0 +8010588f: 8d 43 04 lea 0x4(%ebx),%eax +80105892: 50 push %eax +80105893: e8 18 01 00 00 call 801059b0 + lk->name = name; +80105898: 8b 45 0c mov 0xc(%ebp),%eax + lk->locked = 0; +8010589b: c7 03 00 00 00 00 movl $0x0,(%ebx) + lk->pid = 0; +} +801058a1: 83 c4 10 add $0x10,%esp + lk->pid = 0; +801058a4: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) + lk->name = name; +801058ab: 89 43 38 mov %eax,0x38(%ebx) +} +801058ae: 8b 5d fc mov -0x4(%ebp),%ebx +801058b1: c9 leave +801058b2: c3 ret +801058b3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801058ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +801058c0 : + +void acquiresleep(struct sleeplock *lk) { +801058c0: 55 push %ebp +801058c1: 89 e5 mov %esp,%ebp +801058c3: 56 push %esi +801058c4: 53 push %ebx +801058c5: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&lk->lk); +801058c8: 8d 73 04 lea 0x4(%ebx),%esi +801058cb: 83 ec 0c sub $0xc,%esp +801058ce: 56 push %esi +801058cf: e8 ac 02 00 00 call 80105b80 + while (lk->locked) { +801058d4: 8b 13 mov (%ebx),%edx +801058d6: 83 c4 10 add $0x10,%esp +801058d9: 85 d2 test %edx,%edx +801058db: 74 16 je 801058f3 +801058dd: 8d 76 00 lea 0x0(%esi),%esi + sleep(lk, &lk->lk); +801058e0: 83 ec 08 sub $0x8,%esp +801058e3: 56 push %esi +801058e4: 53 push %ebx +801058e5: e8 f6 fc ff ff call 801055e0 + while (lk->locked) { +801058ea: 8b 03 mov (%ebx),%eax +801058ec: 83 c4 10 add $0x10,%esp +801058ef: 85 c0 test %eax,%eax +801058f1: 75 ed jne 801058e0 + } + lk->locked = 1; +801058f3: c7 03 01 00 00 00 movl $0x1,(%ebx) + lk->pid = myproc()->pid; +801058f9: e8 b2 f5 ff ff call 80104eb0 +801058fe: 8b 40 10 mov 0x10(%eax),%eax +80105901: 89 43 3c mov %eax,0x3c(%ebx) + release(&lk->lk); +80105904: 89 75 08 mov %esi,0x8(%ebp) +} +80105907: 8d 65 f8 lea -0x8(%ebp),%esp +8010590a: 5b pop %ebx +8010590b: 5e pop %esi +8010590c: 5d pop %ebp + release(&lk->lk); +8010590d: e9 0e 02 00 00 jmp 80105b20 +80105912: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105919: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80105920 : + +void releasesleep(struct sleeplock *lk) { +80105920: 55 push %ebp +80105921: 89 e5 mov %esp,%ebp +80105923: 56 push %esi +80105924: 53 push %ebx +80105925: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&lk->lk); +80105928: 8d 73 04 lea 0x4(%ebx),%esi +8010592b: 83 ec 0c sub $0xc,%esp +8010592e: 56 push %esi +8010592f: e8 4c 02 00 00 call 80105b80 + lk->locked = 0; +80105934: c7 03 00 00 00 00 movl $0x0,(%ebx) + lk->pid = 0; +8010593a: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) + wakeup(lk); +80105941: 89 1c 24 mov %ebx,(%esp) +80105944: e8 57 fd ff ff call 801056a0 + release(&lk->lk); +80105949: 89 75 08 mov %esi,0x8(%ebp) +8010594c: 83 c4 10 add $0x10,%esp +} +8010594f: 8d 65 f8 lea -0x8(%ebp),%esp +80105952: 5b pop %ebx +80105953: 5e pop %esi +80105954: 5d pop %ebp + release(&lk->lk); +80105955: e9 c6 01 00 00 jmp 80105b20 +8010595a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105960 : + +int holdingsleep(struct sleeplock *lk) { +80105960: 55 push %ebp +80105961: 89 e5 mov %esp,%ebp +80105963: 57 push %edi +80105964: 31 ff xor %edi,%edi +80105966: 56 push %esi +80105967: 53 push %ebx +80105968: 83 ec 18 sub $0x18,%esp +8010596b: 8b 5d 08 mov 0x8(%ebp),%ebx + int r; + + acquire(&lk->lk); +8010596e: 8d 73 04 lea 0x4(%ebx),%esi +80105971: 56 push %esi +80105972: e8 09 02 00 00 call 80105b80 + r = lk->locked && (lk->pid == myproc()->pid); +80105977: 8b 03 mov (%ebx),%eax +80105979: 83 c4 10 add $0x10,%esp +8010597c: 85 c0 test %eax,%eax +8010597e: 75 18 jne 80105998 + release(&lk->lk); +80105980: 83 ec 0c sub $0xc,%esp +80105983: 56 push %esi +80105984: e8 97 01 00 00 call 80105b20 + return r; +} +80105989: 8d 65 f4 lea -0xc(%ebp),%esp +8010598c: 89 f8 mov %edi,%eax +8010598e: 5b pop %ebx +8010598f: 5e pop %esi +80105990: 5f pop %edi +80105991: 5d pop %ebp +80105992: c3 ret +80105993: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105997: 90 nop + r = lk->locked && (lk->pid == myproc()->pid); +80105998: 8b 5b 3c mov 0x3c(%ebx),%ebx +8010599b: e8 10 f5 ff ff call 80104eb0 +801059a0: 39 58 10 cmp %ebx,0x10(%eax) +801059a3: 0f 94 c0 sete %al +801059a6: 0f b6 c0 movzbl %al,%eax +801059a9: 89 c7 mov %eax,%edi +801059ab: eb d3 jmp 80105980 +801059ad: 66 90 xchg %ax,%ax +801059af: 90 nop + +801059b0 : +#include "memlayout.h" +#include "mmu.h" +#include "proc.h" +#include "spinlock.h" + +void initlock(struct spinlock *lk, char *name) { +801059b0: 55 push %ebp +801059b1: 89 e5 mov %esp,%ebp +801059b3: 8b 45 08 mov 0x8(%ebp),%eax + lk->name = name; +801059b6: 8b 55 0c mov 0xc(%ebp),%edx + lk->locked = 0; +801059b9: c7 00 00 00 00 00 movl $0x0,(%eax) + lk->name = name; +801059bf: 89 50 04 mov %edx,0x4(%eax) + lk->cpu = 0; +801059c2: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) +} +801059c9: 5d pop %ebp +801059ca: c3 ret +801059cb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801059cf: 90 nop + +801059d0 : + + popcli(); +} + +// Record the current call stack in pcs[] by following the %ebp chain. +void getcallerpcs(void *v, uint pcs[]) { +801059d0: 55 push %ebp + uint *ebp; + int i; + + ebp = (uint*)v - 2; + for (i = 0; i < 10; i++) { +801059d1: 31 d2 xor %edx,%edx +void getcallerpcs(void *v, uint pcs[]) { +801059d3: 89 e5 mov %esp,%ebp +801059d5: 53 push %ebx + ebp = (uint*)v - 2; +801059d6: 8b 45 08 mov 0x8(%ebp),%eax +void getcallerpcs(void *v, uint pcs[]) { +801059d9: 8b 4d 0c mov 0xc(%ebp),%ecx + ebp = (uint*)v - 2; +801059dc: 83 e8 08 sub $0x8,%eax + for (i = 0; i < 10; i++) { +801059df: 90 nop + if (ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) { +801059e0: 8d 98 00 00 00 80 lea -0x80000000(%eax),%ebx +801059e6: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx +801059ec: 77 1a ja 80105a08 + break; + } + pcs[i] = ebp[1]; // saved %eip +801059ee: 8b 58 04 mov 0x4(%eax),%ebx +801059f1: 89 1c 91 mov %ebx,(%ecx,%edx,4) + for (i = 0; i < 10; i++) { +801059f4: 83 c2 01 add $0x1,%edx + ebp = (uint*)ebp[0]; // saved %ebp +801059f7: 8b 00 mov (%eax),%eax + for (i = 0; i < 10; i++) { +801059f9: 83 fa 0a cmp $0xa,%edx +801059fc: 75 e2 jne 801059e0 + } + for (; i < 10; i++) { + pcs[i] = 0; + } +} +801059fe: 8b 5d fc mov -0x4(%ebp),%ebx +80105a01: c9 leave +80105a02: c3 ret +80105a03: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105a07: 90 nop + for (; i < 10; i++) { +80105a08: 8d 04 91 lea (%ecx,%edx,4),%eax +80105a0b: 8d 51 28 lea 0x28(%ecx),%edx +80105a0e: 66 90 xchg %ax,%ax + pcs[i] = 0; +80105a10: c7 00 00 00 00 00 movl $0x0,(%eax) + for (; i < 10; i++) { +80105a16: 83 c0 04 add $0x4,%eax +80105a19: 39 d0 cmp %edx,%eax +80105a1b: 75 f3 jne 80105a10 +} +80105a1d: 8b 5d fc mov -0x4(%ebp),%ebx +80105a20: c9 leave +80105a21: c3 ret +80105a22: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105a29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80105a30 : + +// Pushcli/popcli are like cli/sti except that they are matched: +// it takes two popcli to undo two pushcli. Also, if interrupts +// are off, then pushcli, popcli leaves them off. + +void pushcli(void) { +80105a30: 55 push %ebp +80105a31: 89 e5 mov %esp,%ebp +80105a33: 53 push %ebx +80105a34: 83 ec 04 sub $0x4,%esp +80105a37: 9c pushf +80105a38: 5b pop %ebx + asm volatile ("cli"); +80105a39: fa cli + int eflags; + + eflags = readeflags(); + cli(); + if (mycpu()->ncli == 0) { +80105a3a: e8 f1 f3 ff ff call 80104e30 +80105a3f: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax +80105a45: 85 c0 test %eax,%eax +80105a47: 74 17 je 80105a60 + mycpu()->intena = eflags & FL_IF; + } + mycpu()->ncli += 1; +80105a49: e8 e2 f3 ff ff call 80104e30 +80105a4e: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) +} +80105a55: 8b 5d fc mov -0x4(%ebp),%ebx +80105a58: c9 leave +80105a59: c3 ret +80105a5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + mycpu()->intena = eflags & FL_IF; +80105a60: e8 cb f3 ff ff call 80104e30 +80105a65: 81 e3 00 02 00 00 and $0x200,%ebx +80105a6b: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) +80105a71: eb d6 jmp 80105a49 +80105a73: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105a7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105a80 : + +void popcli(void) { +80105a80: 55 push %ebp +80105a81: 89 e5 mov %esp,%ebp +80105a83: 83 ec 08 sub $0x8,%esp + asm volatile ("pushfl; popl %0" : "=r" (eflags)); +80105a86: 9c pushf +80105a87: 58 pop %eax + if (readeflags() & FL_IF) { +80105a88: f6 c4 02 test $0x2,%ah +80105a8b: 75 35 jne 80105ac2 + panic("popcli - interruptible"); + } + if (--mycpu()->ncli < 0) { +80105a8d: e8 9e f3 ff ff call 80104e30 +80105a92: 83 a8 a4 00 00 00 01 subl $0x1,0xa4(%eax) +80105a99: 78 34 js 80105acf + panic("popcli"); + } + if (mycpu()->ncli == 0 && mycpu()->intena) { +80105a9b: e8 90 f3 ff ff call 80104e30 +80105aa0: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx +80105aa6: 85 d2 test %edx,%edx +80105aa8: 74 06 je 80105ab0 + sti(); + } +} +80105aaa: c9 leave +80105aab: c3 ret +80105aac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (mycpu()->ncli == 0 && mycpu()->intena) { +80105ab0: e8 7b f3 ff ff call 80104e30 +80105ab5: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax +80105abb: 85 c0 test %eax,%eax +80105abd: 74 eb je 80105aaa + asm volatile ("sti"); +80105abf: fb sti +} +80105ac0: c9 leave +80105ac1: c3 ret + panic("popcli - interruptible"); +80105ac2: 83 ec 0c sub $0xc,%esp +80105ac5: 68 fb 90 10 80 push $0x801090fb +80105aca: e8 b1 a9 ff ff call 80100480 + panic("popcli"); +80105acf: 83 ec 0c sub $0xc,%esp +80105ad2: 68 12 91 10 80 push $0x80109112 +80105ad7: e8 a4 a9 ff ff call 80100480 +80105adc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80105ae0 : +int holding(struct spinlock *lock) { +80105ae0: 55 push %ebp +80105ae1: 89 e5 mov %esp,%ebp +80105ae3: 56 push %esi +80105ae4: 53 push %ebx +80105ae5: 8b 75 08 mov 0x8(%ebp),%esi +80105ae8: 31 db xor %ebx,%ebx + pushcli(); +80105aea: e8 41 ff ff ff call 80105a30 + r = lock->locked && lock->cpu == mycpu(); +80105aef: 8b 06 mov (%esi),%eax +80105af1: 85 c0 test %eax,%eax +80105af3: 75 0b jne 80105b00 + popcli(); +80105af5: e8 86 ff ff ff call 80105a80 +} +80105afa: 89 d8 mov %ebx,%eax +80105afc: 5b pop %ebx +80105afd: 5e pop %esi +80105afe: 5d pop %ebp +80105aff: c3 ret + r = lock->locked && lock->cpu == mycpu(); +80105b00: 8b 5e 08 mov 0x8(%esi),%ebx +80105b03: e8 28 f3 ff ff call 80104e30 +80105b08: 39 c3 cmp %eax,%ebx +80105b0a: 0f 94 c3 sete %bl + popcli(); +80105b0d: e8 6e ff ff ff call 80105a80 + r = lock->locked && lock->cpu == mycpu(); +80105b12: 0f b6 db movzbl %bl,%ebx +} +80105b15: 89 d8 mov %ebx,%eax +80105b17: 5b pop %ebx +80105b18: 5e pop %esi +80105b19: 5d pop %ebp +80105b1a: c3 ret +80105b1b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105b1f: 90 nop + +80105b20 : +void release(struct spinlock *lk) { +80105b20: 55 push %ebp +80105b21: 89 e5 mov %esp,%ebp +80105b23: 56 push %esi +80105b24: 53 push %ebx +80105b25: 8b 5d 08 mov 0x8(%ebp),%ebx + pushcli(); +80105b28: e8 03 ff ff ff call 80105a30 + r = lock->locked && lock->cpu == mycpu(); +80105b2d: 8b 03 mov (%ebx),%eax +80105b2f: 85 c0 test %eax,%eax +80105b31: 75 15 jne 80105b48 + popcli(); +80105b33: e8 48 ff ff ff call 80105a80 + panic("release"); +80105b38: 83 ec 0c sub $0xc,%esp +80105b3b: 68 19 91 10 80 push $0x80109119 +80105b40: e8 3b a9 ff ff call 80100480 +80105b45: 8d 76 00 lea 0x0(%esi),%esi + r = lock->locked && lock->cpu == mycpu(); +80105b48: 8b 73 08 mov 0x8(%ebx),%esi +80105b4b: e8 e0 f2 ff ff call 80104e30 +80105b50: 39 c6 cmp %eax,%esi +80105b52: 75 df jne 80105b33 + popcli(); +80105b54: e8 27 ff ff ff call 80105a80 + lk->pcs[0] = 0; +80105b59: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) + lk->cpu = 0; +80105b60: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) + __sync_synchronize(); +80105b67: f0 83 0c 24 00 lock orl $0x0,(%esp) + asm volatile ("movl $0, %0" : "+m" (lk->locked) :); +80105b6c: c7 03 00 00 00 00 movl $0x0,(%ebx) +} +80105b72: 8d 65 f8 lea -0x8(%ebp),%esp +80105b75: 5b pop %ebx +80105b76: 5e pop %esi +80105b77: 5d pop %ebp + popcli(); +80105b78: e9 03 ff ff ff jmp 80105a80 +80105b7d: 8d 76 00 lea 0x0(%esi),%esi + +80105b80 : +void acquire(struct spinlock *lk) { +80105b80: 55 push %ebp +80105b81: 89 e5 mov %esp,%ebp +80105b83: 53 push %ebx +80105b84: 83 ec 04 sub $0x4,%esp + pushcli(); // disable interrupts to avoid deadlock. +80105b87: e8 a4 fe ff ff call 80105a30 + if (holding(lk)) { +80105b8c: 8b 5d 08 mov 0x8(%ebp),%ebx + pushcli(); +80105b8f: e8 9c fe ff ff call 80105a30 + r = lock->locked && lock->cpu == mycpu(); +80105b94: 8b 03 mov (%ebx),%eax +80105b96: 85 c0 test %eax,%eax +80105b98: 75 7e jne 80105c18 + popcli(); +80105b9a: e8 e1 fe ff ff call 80105a80 + asm volatile ("lock; xchgl %0, %1" : +80105b9f: b9 01 00 00 00 mov $0x1,%ecx +80105ba4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while (xchg(&lk->locked, 1) != 0) { +80105ba8: 8b 55 08 mov 0x8(%ebp),%edx +80105bab: 89 c8 mov %ecx,%eax +80105bad: f0 87 02 lock xchg %eax,(%edx) +80105bb0: 85 c0 test %eax,%eax +80105bb2: 75 f4 jne 80105ba8 + __sync_synchronize(); +80105bb4: f0 83 0c 24 00 lock orl $0x0,(%esp) + lk->cpu = mycpu(); +80105bb9: 8b 5d 08 mov 0x8(%ebp),%ebx +80105bbc: e8 6f f2 ff ff call 80104e30 + getcallerpcs(&lk, lk->pcs); +80105bc1: 8b 4d 08 mov 0x8(%ebp),%ecx + ebp = (uint*)v - 2; +80105bc4: 89 ea mov %ebp,%edx + lk->cpu = mycpu(); +80105bc6: 89 43 08 mov %eax,0x8(%ebx) + for (i = 0; i < 10; i++) { +80105bc9: 31 c0 xor %eax,%eax +80105bcb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105bcf: 90 nop + if (ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) { +80105bd0: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx +80105bd6: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx +80105bdc: 77 1a ja 80105bf8 + pcs[i] = ebp[1]; // saved %eip +80105bde: 8b 5a 04 mov 0x4(%edx),%ebx +80105be1: 89 5c 81 0c mov %ebx,0xc(%ecx,%eax,4) + for (i = 0; i < 10; i++) { +80105be5: 83 c0 01 add $0x1,%eax + ebp = (uint*)ebp[0]; // saved %ebp +80105be8: 8b 12 mov (%edx),%edx + for (i = 0; i < 10; i++) { +80105bea: 83 f8 0a cmp $0xa,%eax +80105bed: 75 e1 jne 80105bd0 +} +80105bef: 8b 5d fc mov -0x4(%ebp),%ebx +80105bf2: c9 leave +80105bf3: c3 ret +80105bf4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for (; i < 10; i++) { +80105bf8: 8d 44 81 0c lea 0xc(%ecx,%eax,4),%eax +80105bfc: 8d 51 34 lea 0x34(%ecx),%edx +80105bff: 90 nop + pcs[i] = 0; +80105c00: c7 00 00 00 00 00 movl $0x0,(%eax) + for (; i < 10; i++) { +80105c06: 83 c0 04 add $0x4,%eax +80105c09: 39 c2 cmp %eax,%edx +80105c0b: 75 f3 jne 80105c00 +} +80105c0d: 8b 5d fc mov -0x4(%ebp),%ebx +80105c10: c9 leave +80105c11: c3 ret +80105c12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + r = lock->locked && lock->cpu == mycpu(); +80105c18: 8b 5b 08 mov 0x8(%ebx),%ebx +80105c1b: e8 10 f2 ff ff call 80104e30 +80105c20: 39 c3 cmp %eax,%ebx +80105c22: 0f 85 72 ff ff ff jne 80105b9a + popcli(); +80105c28: e8 53 fe ff ff call 80105a80 + panic("acquire"); +80105c2d: 83 ec 0c sub $0xc,%esp +80105c30: 68 21 91 10 80 push $0x80109121 +80105c35: e8 46 a8 ff ff call 80100480 +80105c3a: 66 90 xchg %ax,%ax +80105c3c: 66 90 xchg %ax,%ax +80105c3e: 66 90 xchg %ax,%ax + +80105c40 : +#include "types.h" +#include "x86.h" + +void* memset(void *dst, int c, uint n) { +80105c40: 55 push %ebp +80105c41: 89 e5 mov %esp,%ebp +80105c43: 57 push %edi +80105c44: 8b 55 08 mov 0x8(%ebp),%edx +80105c47: 8b 4d 10 mov 0x10(%ebp),%ecx +80105c4a: 53 push %ebx +80105c4b: 8b 45 0c mov 0xc(%ebp),%eax + if ((int)dst % 4 == 0 && n % 4 == 0) { +80105c4e: 89 d7 mov %edx,%edi +80105c50: 09 cf or %ecx,%edi +80105c52: 83 e7 03 and $0x3,%edi +80105c55: 75 29 jne 80105c80 + c &= 0xFF; +80105c57: 0f b6 f8 movzbl %al,%edi + stosl(dst, (c << 24) | (c << 16) | (c << 8) | c, n / 4); +80105c5a: c1 e0 18 shl $0x18,%eax +80105c5d: 89 fb mov %edi,%ebx +80105c5f: c1 e9 02 shr $0x2,%ecx +80105c62: c1 e3 10 shl $0x10,%ebx +80105c65: 09 d8 or %ebx,%eax +80105c67: 09 f8 or %edi,%eax +80105c69: c1 e7 08 shl $0x8,%edi +80105c6c: 09 f8 or %edi,%eax + asm volatile ("cld; rep stosl" : +80105c6e: 89 d7 mov %edx,%edi +80105c70: fc cld +80105c71: f3 ab rep stos %eax,%es:(%edi) + } + else { + stosb(dst, c, n); + } + return dst; +} +80105c73: 5b pop %ebx +80105c74: 89 d0 mov %edx,%eax +80105c76: 5f pop %edi +80105c77: 5d pop %ebp +80105c78: c3 ret +80105c79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + asm volatile ("cld; rep stosb" : +80105c80: 89 d7 mov %edx,%edi +80105c82: fc cld +80105c83: f3 aa rep stos %al,%es:(%edi) +80105c85: 5b pop %ebx +80105c86: 89 d0 mov %edx,%eax +80105c88: 5f pop %edi +80105c89: 5d pop %ebp +80105c8a: c3 ret +80105c8b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105c8f: 90 nop + +80105c90 : + +int memcmp(const void *v1, const void *v2, uint n) { +80105c90: 55 push %ebp +80105c91: 89 e5 mov %esp,%ebp +80105c93: 56 push %esi +80105c94: 8b 75 10 mov 0x10(%ebp),%esi +80105c97: 8b 55 08 mov 0x8(%ebp),%edx +80105c9a: 53 push %ebx +80105c9b: 8b 45 0c mov 0xc(%ebp),%eax + const uchar *s1, *s2; + + s1 = v1; + s2 = v2; + while (n-- > 0) { +80105c9e: 85 f6 test %esi,%esi +80105ca0: 74 2e je 80105cd0 +80105ca2: 01 c6 add %eax,%esi +80105ca4: eb 14 jmp 80105cba +80105ca6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105cad: 8d 76 00 lea 0x0(%esi),%esi + if (*s1 != *s2) { + return *s1 - *s2; + } + s1++, s2++; +80105cb0: 83 c0 01 add $0x1,%eax +80105cb3: 83 c2 01 add $0x1,%edx + while (n-- > 0) { +80105cb6: 39 f0 cmp %esi,%eax +80105cb8: 74 16 je 80105cd0 + if (*s1 != *s2) { +80105cba: 0f b6 0a movzbl (%edx),%ecx +80105cbd: 0f b6 18 movzbl (%eax),%ebx +80105cc0: 38 d9 cmp %bl,%cl +80105cc2: 74 ec je 80105cb0 + return *s1 - *s2; +80105cc4: 0f b6 c1 movzbl %cl,%eax +80105cc7: 29 d8 sub %ebx,%eax + } + + return 0; +} +80105cc9: 5b pop %ebx +80105cca: 5e pop %esi +80105ccb: 5d pop %ebp +80105ccc: c3 ret +80105ccd: 8d 76 00 lea 0x0(%esi),%esi +80105cd0: 5b pop %ebx + return 0; +80105cd1: 31 c0 xor %eax,%eax +} +80105cd3: 5e pop %esi +80105cd4: 5d pop %ebp +80105cd5: c3 ret +80105cd6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105cdd: 8d 76 00 lea 0x0(%esi),%esi + +80105ce0 : + +void* memmove(void *dst, const void *src, uint n) { +80105ce0: 55 push %ebp +80105ce1: 89 e5 mov %esp,%ebp +80105ce3: 57 push %edi +80105ce4: 8b 55 08 mov 0x8(%ebp),%edx +80105ce7: 8b 4d 10 mov 0x10(%ebp),%ecx +80105cea: 56 push %esi +80105ceb: 8b 75 0c mov 0xc(%ebp),%esi + const char *s; + char *d; + + s = src; + d = dst; + if (s < d && s + n > d) { +80105cee: 39 d6 cmp %edx,%esi +80105cf0: 73 26 jae 80105d18 +80105cf2: 8d 3c 0e lea (%esi,%ecx,1),%edi +80105cf5: 39 fa cmp %edi,%edx +80105cf7: 73 1f jae 80105d18 +80105cf9: 8d 41 ff lea -0x1(%ecx),%eax + s += n; + d += n; + while (n-- > 0) { +80105cfc: 85 c9 test %ecx,%ecx +80105cfe: 74 0c je 80105d0c + *--d = *--s; +80105d00: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx +80105d04: 88 0c 02 mov %cl,(%edx,%eax,1) + while (n-- > 0) { +80105d07: 83 e8 01 sub $0x1,%eax +80105d0a: 73 f4 jae 80105d00 + *d++ = *s++; + } + } + + return dst; +} +80105d0c: 5e pop %esi +80105d0d: 89 d0 mov %edx,%eax +80105d0f: 5f pop %edi +80105d10: 5d pop %ebp +80105d11: c3 ret +80105d12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + while (n-- > 0) { +80105d18: 8d 04 0e lea (%esi,%ecx,1),%eax +80105d1b: 89 d7 mov %edx,%edi +80105d1d: 85 c9 test %ecx,%ecx +80105d1f: 74 eb je 80105d0c +80105d21: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + *d++ = *s++; +80105d28: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { +80105d29: 39 c6 cmp %eax,%esi +80105d2b: 75 fb jne 80105d28 +} +80105d2d: 5e pop %esi +80105d2e: 89 d0 mov %edx,%eax +80105d30: 5f pop %edi +80105d31: 5d pop %ebp +80105d32: c3 ret +80105d33: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105d3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105d40 : + +// memcpy exists to placate GCC. Use memmove. +void* memcpy(void *dst, const void *src, uint n) { + return memmove(dst, src, n); +80105d40: eb 9e jmp 80105ce0 +80105d42: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105d49: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80105d50 : +} + +int strncmp(const char *p, const char *q, uint n) { +80105d50: 55 push %ebp +80105d51: 89 e5 mov %esp,%ebp +80105d53: 56 push %esi +80105d54: 8b 75 10 mov 0x10(%ebp),%esi +80105d57: 8b 4d 08 mov 0x8(%ebp),%ecx +80105d5a: 53 push %ebx +80105d5b: 8b 55 0c mov 0xc(%ebp),%edx + while (n > 0 && *p && *p == *q) { +80105d5e: 85 f6 test %esi,%esi +80105d60: 74 2e je 80105d90 +80105d62: 01 d6 add %edx,%esi +80105d64: eb 18 jmp 80105d7e +80105d66: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105d6d: 8d 76 00 lea 0x0(%esi),%esi +80105d70: 38 d8 cmp %bl,%al +80105d72: 75 14 jne 80105d88 + n--, p++, q++; +80105d74: 83 c2 01 add $0x1,%edx +80105d77: 83 c1 01 add $0x1,%ecx + while (n > 0 && *p && *p == *q) { +80105d7a: 39 f2 cmp %esi,%edx +80105d7c: 74 12 je 80105d90 +80105d7e: 0f b6 01 movzbl (%ecx),%eax +80105d81: 0f b6 1a movzbl (%edx),%ebx +80105d84: 84 c0 test %al,%al +80105d86: 75 e8 jne 80105d70 + } + if (n == 0) { + return 0; + } + return (uchar) * p - (uchar) * q; +80105d88: 29 d8 sub %ebx,%eax +} +80105d8a: 5b pop %ebx +80105d8b: 5e pop %esi +80105d8c: 5d pop %ebp +80105d8d: c3 ret +80105d8e: 66 90 xchg %ax,%ax +80105d90: 5b pop %ebx + return 0; +80105d91: 31 c0 xor %eax,%eax +} +80105d93: 5e pop %esi +80105d94: 5d pop %ebp +80105d95: c3 ret +80105d96: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105d9d: 8d 76 00 lea 0x0(%esi),%esi + +80105da0 : + +char* strncpy(char *s, const char *t, int n) { +80105da0: 55 push %ebp +80105da1: 89 e5 mov %esp,%ebp +80105da3: 57 push %edi +80105da4: 56 push %esi +80105da5: 8b 75 08 mov 0x8(%ebp),%esi +80105da8: 53 push %ebx +80105da9: 8b 4d 10 mov 0x10(%ebp),%ecx + char *os; + + os = s; + while (n-- > 0 && (*s++ = *t++) != 0) { +80105dac: 89 f0 mov %esi,%eax +80105dae: eb 15 jmp 80105dc5 +80105db0: 83 45 0c 01 addl $0x1,0xc(%ebp) +80105db4: 8b 7d 0c mov 0xc(%ebp),%edi +80105db7: 83 c0 01 add $0x1,%eax +80105dba: 0f b6 57 ff movzbl -0x1(%edi),%edx +80105dbe: 88 50 ff mov %dl,-0x1(%eax) +80105dc1: 84 d2 test %dl,%dl +80105dc3: 74 09 je 80105dce +80105dc5: 89 cb mov %ecx,%ebx +80105dc7: 83 e9 01 sub $0x1,%ecx +80105dca: 85 db test %ebx,%ebx +80105dcc: 7f e2 jg 80105db0 + ; + } + while (n-- > 0) { +80105dce: 89 c2 mov %eax,%edx +80105dd0: 85 c9 test %ecx,%ecx +80105dd2: 7e 17 jle 80105deb +80105dd4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *s++ = 0; +80105dd8: 83 c2 01 add $0x1,%edx +80105ddb: 89 c1 mov %eax,%ecx +80105ddd: c6 42 ff 00 movb $0x0,-0x1(%edx) + while (n-- > 0) { +80105de1: 29 d1 sub %edx,%ecx +80105de3: 8d 4c 0b ff lea -0x1(%ebx,%ecx,1),%ecx +80105de7: 85 c9 test %ecx,%ecx +80105de9: 7f ed jg 80105dd8 + } + return os; +} +80105deb: 5b pop %ebx +80105dec: 89 f0 mov %esi,%eax +80105dee: 5e pop %esi +80105def: 5f pop %edi +80105df0: 5d pop %ebp +80105df1: c3 ret +80105df2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105df9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80105e00 : + +// Like strncpy but guaranteed to NUL-terminate. +char* safestrcpy(char *s, const char *t, int n) { +80105e00: 55 push %ebp +80105e01: 89 e5 mov %esp,%ebp +80105e03: 56 push %esi +80105e04: 8b 55 10 mov 0x10(%ebp),%edx +80105e07: 8b 75 08 mov 0x8(%ebp),%esi +80105e0a: 53 push %ebx +80105e0b: 8b 45 0c mov 0xc(%ebp),%eax + char *os; + + os = s; + if (n <= 0) { +80105e0e: 85 d2 test %edx,%edx +80105e10: 7e 25 jle 80105e37 +80105e12: 8d 5c 10 ff lea -0x1(%eax,%edx,1),%ebx +80105e16: 89 f2 mov %esi,%edx +80105e18: eb 16 jmp 80105e30 +80105e1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return os; + } + while (--n > 0 && (*s++ = *t++) != 0) { +80105e20: 0f b6 08 movzbl (%eax),%ecx +80105e23: 83 c0 01 add $0x1,%eax +80105e26: 83 c2 01 add $0x1,%edx +80105e29: 88 4a ff mov %cl,-0x1(%edx) +80105e2c: 84 c9 test %cl,%cl +80105e2e: 74 04 je 80105e34 +80105e30: 39 d8 cmp %ebx,%eax +80105e32: 75 ec jne 80105e20 + ; + } + *s = 0; +80105e34: c6 02 00 movb $0x0,(%edx) + return os; +} +80105e37: 89 f0 mov %esi,%eax +80105e39: 5b pop %ebx +80105e3a: 5e pop %esi +80105e3b: 5d pop %ebp +80105e3c: c3 ret +80105e3d: 8d 76 00 lea 0x0(%esi),%esi + +80105e40 : + +int strlen(const char *s) { +80105e40: 55 push %ebp + int n; + + for (n = 0; s[n]; n++) { +80105e41: 31 c0 xor %eax,%eax +int strlen(const char *s) { +80105e43: 89 e5 mov %esp,%ebp +80105e45: 8b 55 08 mov 0x8(%ebp),%edx + for (n = 0; s[n]; n++) { +80105e48: 80 3a 00 cmpb $0x0,(%edx) +80105e4b: 74 0c je 80105e59 +80105e4d: 8d 76 00 lea 0x0(%esi),%esi +80105e50: 83 c0 01 add $0x1,%eax +80105e53: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) +80105e57: 75 f7 jne 80105e50 + ; + } + return n; +} +80105e59: 5d pop %ebp +80105e5a: c3 ret + +80105e5b : +# a struct context, and save its address in *old. +# Switch stacks to new and pop previously-saved registers. + +.globl swtch +swtch: + movl 4(%esp), %eax +80105e5b: 8b 44 24 04 mov 0x4(%esp),%eax + movl 8(%esp), %edx +80105e5f: 8b 54 24 08 mov 0x8(%esp),%edx + + # Save old callee-saved registers + pushl %ebp +80105e63: 55 push %ebp + pushl %ebx +80105e64: 53 push %ebx + pushl %esi +80105e65: 56 push %esi + pushl %edi +80105e66: 57 push %edi + + # Switch stacks + movl %esp, (%eax) +80105e67: 89 20 mov %esp,(%eax) + movl %edx, %esp +80105e69: 89 d4 mov %edx,%esp + + # Load new callee-saved registers + popl %edi +80105e6b: 5f pop %edi + popl %esi +80105e6c: 5e pop %esi + popl %ebx +80105e6d: 5b pop %ebx + popl %ebp +80105e6e: 5d pop %ebp + ret +80105e6f: c3 ret + +80105e70 : +// Arguments on the stack, from the user call to the C +// library system call function. The saved user %esp points +// to a saved program counter, and then the first argument. + +// Fetch the int at addr from the current process. +int fetchint(uint addr, int *ip) { +80105e70: 55 push %ebp +80105e71: 89 e5 mov %esp,%ebp +80105e73: 53 push %ebx +80105e74: 83 ec 04 sub $0x4,%esp +80105e77: 8b 5d 08 mov 0x8(%ebp),%ebx + struct proc *curproc = myproc(); +80105e7a: e8 31 f0 ff ff call 80104eb0 + + if (addr >= curproc->sz || addr + 4 > curproc->sz) { +80105e7f: 8b 00 mov (%eax),%eax +80105e81: 39 d8 cmp %ebx,%eax +80105e83: 76 1b jbe 80105ea0 +80105e85: 8d 53 04 lea 0x4(%ebx),%edx +80105e88: 39 d0 cmp %edx,%eax +80105e8a: 72 14 jb 80105ea0 + return -1; + } + *ip = *(int*)(addr); +80105e8c: 8b 45 0c mov 0xc(%ebp),%eax +80105e8f: 8b 13 mov (%ebx),%edx +80105e91: 89 10 mov %edx,(%eax) + return 0; +80105e93: 31 c0 xor %eax,%eax +} +80105e95: 8b 5d fc mov -0x4(%ebp),%ebx +80105e98: c9 leave +80105e99: c3 ret +80105e9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +80105ea0: b8 ff ff ff ff mov $0xffffffff,%eax +80105ea5: eb ee jmp 80105e95 +80105ea7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105eae: 66 90 xchg %ax,%ax + +80105eb0 : + +// Fetch the nul-terminated string at addr from the current process. +// Doesn't actually copy the string - just sets *pp to point at it. +// Returns length of string, not including nul. +int fetchstr(uint addr, char **pp) { +80105eb0: 55 push %ebp +80105eb1: 89 e5 mov %esp,%ebp +80105eb3: 53 push %ebx +80105eb4: 83 ec 04 sub $0x4,%esp +80105eb7: 8b 5d 08 mov 0x8(%ebp),%ebx + char *s, *ep; + struct proc *curproc = myproc(); +80105eba: e8 f1 ef ff ff call 80104eb0 + + if (addr >= curproc->sz) { +80105ebf: 39 18 cmp %ebx,(%eax) +80105ec1: 76 2d jbe 80105ef0 + return -1; + } + *pp = (char*)addr; +80105ec3: 8b 55 0c mov 0xc(%ebp),%edx +80105ec6: 89 1a mov %ebx,(%edx) + ep = (char*)curproc->sz; +80105ec8: 8b 10 mov (%eax),%edx + for (s = *pp; s < ep; s++) { +80105eca: 39 d3 cmp %edx,%ebx +80105ecc: 73 22 jae 80105ef0 +80105ece: 89 d8 mov %ebx,%eax +80105ed0: eb 0d jmp 80105edf +80105ed2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80105ed8: 83 c0 01 add $0x1,%eax +80105edb: 39 c2 cmp %eax,%edx +80105edd: 76 11 jbe 80105ef0 + if (*s == 0) { +80105edf: 80 38 00 cmpb $0x0,(%eax) +80105ee2: 75 f4 jne 80105ed8 + return s - *pp; +80105ee4: 29 d8 sub %ebx,%eax + } + } + return -1; +} +80105ee6: 8b 5d fc mov -0x4(%ebp),%ebx +80105ee9: c9 leave +80105eea: c3 ret +80105eeb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105eef: 90 nop +80105ef0: 8b 5d fc mov -0x4(%ebp),%ebx + return -1; +80105ef3: b8 ff ff ff ff mov $0xffffffff,%eax +} +80105ef8: c9 leave +80105ef9: c3 ret +80105efa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105f00 : + +// Fetch the nth 32-bit system call argument. +int argint(int n, int *ip) { +80105f00: 55 push %ebp +80105f01: 89 e5 mov %esp,%ebp +80105f03: 56 push %esi +80105f04: 53 push %ebx + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105f05: e8 a6 ef ff ff call 80104eb0 +80105f0a: 8b 55 08 mov 0x8(%ebp),%edx +80105f0d: 8b 40 18 mov 0x18(%eax),%eax +80105f10: 8b 40 44 mov 0x44(%eax),%eax +80105f13: 8d 1c 90 lea (%eax,%edx,4),%ebx + struct proc *curproc = myproc(); +80105f16: e8 95 ef ff ff call 80104eb0 + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105f1b: 8d 73 04 lea 0x4(%ebx),%esi + if (addr >= curproc->sz || addr + 4 > curproc->sz) { +80105f1e: 8b 00 mov (%eax),%eax +80105f20: 39 c6 cmp %eax,%esi +80105f22: 73 1c jae 80105f40 +80105f24: 8d 53 08 lea 0x8(%ebx),%edx +80105f27: 39 d0 cmp %edx,%eax +80105f29: 72 15 jb 80105f40 + *ip = *(int*)(addr); +80105f2b: 8b 45 0c mov 0xc(%ebp),%eax +80105f2e: 8b 53 04 mov 0x4(%ebx),%edx +80105f31: 89 10 mov %edx,(%eax) + return 0; +80105f33: 31 c0 xor %eax,%eax +} +80105f35: 5b pop %ebx +80105f36: 5e pop %esi +80105f37: 5d pop %ebp +80105f38: c3 ret +80105f39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80105f40: b8 ff ff ff ff mov $0xffffffff,%eax + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105f45: eb ee jmp 80105f35 +80105f47: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105f4e: 66 90 xchg %ax,%ax + +80105f50 : + +// Fetch the nth word-sized system call argument as a pointer +// to a block of memory of size bytes. Check that the pointer +// lies within the process address space. +int argptr(int n, char **pp, int size) { +80105f50: 55 push %ebp +80105f51: 89 e5 mov %esp,%ebp +80105f53: 57 push %edi +80105f54: 56 push %esi +80105f55: 53 push %ebx +80105f56: 83 ec 0c sub $0xc,%esp + int i; + struct proc *curproc = myproc(); +80105f59: e8 52 ef ff ff call 80104eb0 +80105f5e: 89 c6 mov %eax,%esi + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105f60: e8 4b ef ff ff call 80104eb0 +80105f65: 8b 55 08 mov 0x8(%ebp),%edx +80105f68: 8b 40 18 mov 0x18(%eax),%eax +80105f6b: 8b 40 44 mov 0x44(%eax),%eax +80105f6e: 8d 1c 90 lea (%eax,%edx,4),%ebx + struct proc *curproc = myproc(); +80105f71: e8 3a ef ff ff call 80104eb0 + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105f76: 8d 7b 04 lea 0x4(%ebx),%edi + if (addr >= curproc->sz || addr + 4 > curproc->sz) { +80105f79: 8b 00 mov (%eax),%eax +80105f7b: 39 c7 cmp %eax,%edi +80105f7d: 73 31 jae 80105fb0 +80105f7f: 8d 4b 08 lea 0x8(%ebx),%ecx +80105f82: 39 c8 cmp %ecx,%eax +80105f84: 72 2a jb 80105fb0 + + if (argint(n, &i) < 0) { + return -1; + } + if (size < 0 || (uint)i >= curproc->sz || (uint)i + size > curproc->sz) { +80105f86: 8b 55 10 mov 0x10(%ebp),%edx + *ip = *(int*)(addr); +80105f89: 8b 43 04 mov 0x4(%ebx),%eax + if (size < 0 || (uint)i >= curproc->sz || (uint)i + size > curproc->sz) { +80105f8c: 85 d2 test %edx,%edx +80105f8e: 78 20 js 80105fb0 +80105f90: 8b 16 mov (%esi),%edx +80105f92: 39 c2 cmp %eax,%edx +80105f94: 76 1a jbe 80105fb0 +80105f96: 8b 5d 10 mov 0x10(%ebp),%ebx +80105f99: 01 c3 add %eax,%ebx +80105f9b: 39 da cmp %ebx,%edx +80105f9d: 72 11 jb 80105fb0 + return -1; + } + *pp = (char*)i; +80105f9f: 8b 55 0c mov 0xc(%ebp),%edx +80105fa2: 89 02 mov %eax,(%edx) + return 0; +80105fa4: 31 c0 xor %eax,%eax +} +80105fa6: 83 c4 0c add $0xc,%esp +80105fa9: 5b pop %ebx +80105faa: 5e pop %esi +80105fab: 5f pop %edi +80105fac: 5d pop %ebp +80105fad: c3 ret +80105fae: 66 90 xchg %ax,%ax + return -1; +80105fb0: b8 ff ff ff ff mov $0xffffffff,%eax +80105fb5: eb ef jmp 80105fa6 +80105fb7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105fbe: 66 90 xchg %ax,%ax + +80105fc0 : + +// Fetch the nth word-sized system call argument as a string pointer. +// Check that the pointer is valid and the string is nul-terminated. +// (There is no shared writable memory, so the string can't change +// between this check and being used by the kernel.) +int argstr(int n, char **pp) { +80105fc0: 55 push %ebp +80105fc1: 89 e5 mov %esp,%ebp +80105fc3: 56 push %esi +80105fc4: 53 push %ebx + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105fc5: e8 e6 ee ff ff call 80104eb0 +80105fca: 8b 55 08 mov 0x8(%ebp),%edx +80105fcd: 8b 40 18 mov 0x18(%eax),%eax +80105fd0: 8b 40 44 mov 0x44(%eax),%eax +80105fd3: 8d 1c 90 lea (%eax,%edx,4),%ebx + struct proc *curproc = myproc(); +80105fd6: e8 d5 ee ff ff call 80104eb0 + return fetchint((myproc()->tf->esp) + 4 + 4 * n, ip); +80105fdb: 8d 73 04 lea 0x4(%ebx),%esi + if (addr >= curproc->sz || addr + 4 > curproc->sz) { +80105fde: 8b 00 mov (%eax),%eax +80105fe0: 39 c6 cmp %eax,%esi +80105fe2: 73 44 jae 80106028 +80105fe4: 8d 53 08 lea 0x8(%ebx),%edx +80105fe7: 39 d0 cmp %edx,%eax +80105fe9: 72 3d jb 80106028 + *ip = *(int*)(addr); +80105feb: 8b 5b 04 mov 0x4(%ebx),%ebx + struct proc *curproc = myproc(); +80105fee: e8 bd ee ff ff call 80104eb0 + if (addr >= curproc->sz) { +80105ff3: 3b 18 cmp (%eax),%ebx +80105ff5: 73 31 jae 80106028 + *pp = (char*)addr; +80105ff7: 8b 55 0c mov 0xc(%ebp),%edx +80105ffa: 89 1a mov %ebx,(%edx) + ep = (char*)curproc->sz; +80105ffc: 8b 10 mov (%eax),%edx + for (s = *pp; s < ep; s++) { +80105ffe: 39 d3 cmp %edx,%ebx +80106000: 73 26 jae 80106028 +80106002: 89 d8 mov %ebx,%eax +80106004: eb 11 jmp 80106017 +80106006: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010600d: 8d 76 00 lea 0x0(%esi),%esi +80106010: 83 c0 01 add $0x1,%eax +80106013: 39 c2 cmp %eax,%edx +80106015: 76 11 jbe 80106028 + if (*s == 0) { +80106017: 80 38 00 cmpb $0x0,(%eax) +8010601a: 75 f4 jne 80106010 + return s - *pp; +8010601c: 29 d8 sub %ebx,%eax + int addr; + if (argint(n, &addr) < 0) { + return -1; + } + return fetchstr(addr, pp); +} +8010601e: 5b pop %ebx +8010601f: 5e pop %esi +80106020: 5d pop %ebp +80106021: c3 ret +80106022: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80106028: 5b pop %ebx + return -1; +80106029: b8 ff ff ff ff mov $0xffffffff,%eax +} +8010602e: 5e pop %esi +8010602f: 5d pop %ebp +80106030: c3 ret +80106031: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106038: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010603f: 90 nop + +80106040 : + +void syscall(void) { +80106040: 55 push %ebp +80106041: 89 e5 mov %esp,%ebp +80106043: 53 push %ebx +80106044: 83 ec 04 sub $0x4,%esp + int num; + struct proc *curproc = myproc(); +80106047: e8 64 ee ff ff call 80104eb0 +8010604c: 89 c3 mov %eax,%ebx + + num = curproc->tf->eax; +8010604e: 8b 40 18 mov 0x18(%eax),%eax +80106051: 8b 40 1c mov 0x1c(%eax),%eax + if (num > 0 && num < NELEM(syscalls) && syscalls[num]) { +80106054: 8d 50 ff lea -0x1(%eax),%edx +80106057: 83 fa 19 cmp $0x19,%edx +8010605a: 77 24 ja 80106080 +8010605c: 8b 14 85 60 91 10 80 mov -0x7fef6ea0(,%eax,4),%edx +80106063: 85 d2 test %edx,%edx +80106065: 74 19 je 80106080 + curproc->tf->eax = syscalls[num](); +80106067: ff d2 call *%edx +80106069: 89 c2 mov %eax,%edx +8010606b: 8b 43 18 mov 0x18(%ebx),%eax +8010606e: 89 50 1c mov %edx,0x1c(%eax) + else { + cprintf("%d %s: unknown sys call %d\n", + curproc->pid, curproc->name, num); + curproc->tf->eax = -1; + } +} +80106071: 8b 5d fc mov -0x4(%ebp),%ebx +80106074: c9 leave +80106075: c3 ret +80106076: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010607d: 8d 76 00 lea 0x0(%esi),%esi + cprintf("%d %s: unknown sys call %d\n", +80106080: 50 push %eax + curproc->pid, curproc->name, num); +80106081: 8d 43 6c lea 0x6c(%ebx),%eax + cprintf("%d %s: unknown sys call %d\n", +80106084: 50 push %eax +80106085: ff 73 10 push 0x10(%ebx) +80106088: 68 29 91 10 80 push $0x80109129 +8010608d: e8 fe a7 ff ff call 80100890 + curproc->tf->eax = -1; +80106092: 8b 43 18 mov 0x18(%ebx),%eax +80106095: 83 c4 10 add $0x10,%esp +80106098: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) +} +8010609f: 8b 5d fc mov -0x4(%ebp),%ebx +801060a2: c9 leave +801060a3: c3 ret +801060a4: 66 90 xchg %ax,%ax +801060a6: 66 90 xchg %ax,%ax +801060a8: 66 90 xchg %ax,%ax +801060aa: 66 90 xchg %ax,%ax +801060ac: 66 90 xchg %ax,%ax +801060ae: 66 90 xchg %ax,%ax + +801060b0 : + end_op(); + + return 0; +} + +static struct inode* create(char *path, short type, short major, short minor) { +801060b0: 55 push %ebp +801060b1: 89 e5 mov %esp,%ebp +801060b3: 57 push %edi +801060b4: 56 push %esi + struct inode *ip, *dp; + char name[DIRSIZ]; + + if ((dp = nameiparent(path, name)) == 0) { +801060b5: 8d 7d da lea -0x26(%ebp),%edi +static struct inode* create(char *path, short type, short major, short minor) { +801060b8: 53 push %ebx +801060b9: 83 ec 34 sub $0x34,%esp +801060bc: 89 4d d0 mov %ecx,-0x30(%ebp) +801060bf: 8b 4d 08 mov 0x8(%ebp),%ecx + if ((dp = nameiparent(path, name)) == 0) { +801060c2: 57 push %edi +801060c3: 50 push %eax +static struct inode* create(char *path, short type, short major, short minor) { +801060c4: 89 55 d4 mov %edx,-0x2c(%ebp) +801060c7: 89 4d cc mov %ecx,-0x34(%ebp) + if ((dp = nameiparent(path, name)) == 0) { +801060ca: e8 e1 d4 ff ff call 801035b0 +801060cf: 83 c4 10 add $0x10,%esp +801060d2: 85 c0 test %eax,%eax +801060d4: 0f 84 46 01 00 00 je 80106220 + return 0; + } + ilock(dp); +801060da: 83 ec 0c sub $0xc,%esp +801060dd: 89 c3 mov %eax,%ebx +801060df: 50 push %eax +801060e0: e8 8b cb ff ff call 80102c70 + + if ((ip = dirlookup(dp, name, 0)) != 0) { +801060e5: 83 c4 0c add $0xc,%esp +801060e8: 6a 00 push $0x0 +801060ea: 57 push %edi +801060eb: 53 push %ebx +801060ec: e8 df d0 ff ff call 801031d0 +801060f1: 83 c4 10 add $0x10,%esp +801060f4: 89 c6 mov %eax,%esi +801060f6: 85 c0 test %eax,%eax +801060f8: 74 56 je 80106150 + iunlockput(dp); +801060fa: 83 ec 0c sub $0xc,%esp +801060fd: 53 push %ebx +801060fe: e8 fd cd ff ff call 80102f00 + ilock(ip); +80106103: 89 34 24 mov %esi,(%esp) +80106106: e8 65 cb ff ff call 80102c70 + if (type == T_FILE && ip->type == T_FILE) { +8010610b: 83 c4 10 add $0x10,%esp +8010610e: 66 83 7d d4 02 cmpw $0x2,-0x2c(%ebp) +80106113: 75 1b jne 80106130 +80106115: 66 83 7e 50 02 cmpw $0x2,0x50(%esi) +8010611a: 75 14 jne 80106130 + } + + iunlockput(dp); + + return ip; +} +8010611c: 8d 65 f4 lea -0xc(%ebp),%esp +8010611f: 89 f0 mov %esi,%eax +80106121: 5b pop %ebx +80106122: 5e pop %esi +80106123: 5f pop %edi +80106124: 5d pop %ebp +80106125: c3 ret +80106126: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010612d: 8d 76 00 lea 0x0(%esi),%esi + iunlockput(ip); +80106130: 83 ec 0c sub $0xc,%esp +80106133: 56 push %esi + return 0; +80106134: 31 f6 xor %esi,%esi + iunlockput(ip); +80106136: e8 c5 cd ff ff call 80102f00 + return 0; +8010613b: 83 c4 10 add $0x10,%esp +} +8010613e: 8d 65 f4 lea -0xc(%ebp),%esp +80106141: 89 f0 mov %esi,%eax +80106143: 5b pop %ebx +80106144: 5e pop %esi +80106145: 5f pop %edi +80106146: 5d pop %ebp +80106147: c3 ret +80106148: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010614f: 90 nop + if ((ip = ialloc(dp->dev, type)) == 0) { +80106150: 0f bf 45 d4 movswl -0x2c(%ebp),%eax +80106154: 83 ec 08 sub $0x8,%esp +80106157: 50 push %eax +80106158: ff 33 push (%ebx) +8010615a: e8 a1 c9 ff ff call 80102b00 +8010615f: 83 c4 10 add $0x10,%esp +80106162: 89 c6 mov %eax,%esi +80106164: 85 c0 test %eax,%eax +80106166: 0f 84 cd 00 00 00 je 80106239 + ilock(ip); +8010616c: 83 ec 0c sub $0xc,%esp +8010616f: 50 push %eax +80106170: e8 fb ca ff ff call 80102c70 + ip->major = major; +80106175: 0f b7 45 d0 movzwl -0x30(%ebp),%eax +80106179: 66 89 46 52 mov %ax,0x52(%esi) + ip->minor = minor; +8010617d: 0f b7 45 cc movzwl -0x34(%ebp),%eax +80106181: 66 89 46 54 mov %ax,0x54(%esi) + ip->nlink = 1; +80106185: b8 01 00 00 00 mov $0x1,%eax +8010618a: 66 89 46 56 mov %ax,0x56(%esi) + iupdate(ip); +8010618e: 89 34 24 mov %esi,(%esp) +80106191: e8 2a ca ff ff call 80102bc0 + if (type == T_DIR) { // Create . and .. entries. +80106196: 83 c4 10 add $0x10,%esp +80106199: 66 83 7d d4 01 cmpw $0x1,-0x2c(%ebp) +8010619e: 74 30 je 801061d0 + if (dirlink(dp, name, ip->inum) < 0) { +801061a0: 83 ec 04 sub $0x4,%esp +801061a3: ff 76 04 push 0x4(%esi) +801061a6: 57 push %edi +801061a7: 53 push %ebx +801061a8: e8 23 d3 ff ff call 801034d0 +801061ad: 83 c4 10 add $0x10,%esp +801061b0: 85 c0 test %eax,%eax +801061b2: 78 78 js 8010622c + iunlockput(dp); +801061b4: 83 ec 0c sub $0xc,%esp +801061b7: 53 push %ebx +801061b8: e8 43 cd ff ff call 80102f00 + return ip; +801061bd: 83 c4 10 add $0x10,%esp +} +801061c0: 8d 65 f4 lea -0xc(%ebp),%esp +801061c3: 89 f0 mov %esi,%eax +801061c5: 5b pop %ebx +801061c6: 5e pop %esi +801061c7: 5f pop %edi +801061c8: 5d pop %ebp +801061c9: c3 ret +801061ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + iupdate(dp); +801061d0: 83 ec 0c sub $0xc,%esp + dp->nlink++; // for ".." +801061d3: 66 83 43 56 01 addw $0x1,0x56(%ebx) + iupdate(dp); +801061d8: 53 push %ebx +801061d9: e8 e2 c9 ff ff call 80102bc0 + if (dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) { +801061de: 83 c4 0c add $0xc,%esp +801061e1: ff 76 04 push 0x4(%esi) +801061e4: 68 e8 91 10 80 push $0x801091e8 +801061e9: 56 push %esi +801061ea: e8 e1 d2 ff ff call 801034d0 +801061ef: 83 c4 10 add $0x10,%esp +801061f2: 85 c0 test %eax,%eax +801061f4: 78 18 js 8010620e +801061f6: 83 ec 04 sub $0x4,%esp +801061f9: ff 73 04 push 0x4(%ebx) +801061fc: 68 e7 91 10 80 push $0x801091e7 +80106201: 56 push %esi +80106202: e8 c9 d2 ff ff call 801034d0 +80106207: 83 c4 10 add $0x10,%esp +8010620a: 85 c0 test %eax,%eax +8010620c: 79 92 jns 801061a0 + panic("create dots"); +8010620e: 83 ec 0c sub $0xc,%esp +80106211: 68 db 91 10 80 push $0x801091db +80106216: e8 65 a2 ff ff call 80100480 +8010621b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010621f: 90 nop +} +80106220: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; +80106223: 31 f6 xor %esi,%esi +} +80106225: 5b pop %ebx +80106226: 89 f0 mov %esi,%eax +80106228: 5e pop %esi +80106229: 5f pop %edi +8010622a: 5d pop %ebp +8010622b: c3 ret + panic("create: dirlink"); +8010622c: 83 ec 0c sub $0xc,%esp +8010622f: 68 ea 91 10 80 push $0x801091ea +80106234: e8 47 a2 ff ff call 80100480 + panic("create: ialloc"); +80106239: 83 ec 0c sub $0xc,%esp +8010623c: 68 cc 91 10 80 push $0x801091cc +80106241: e8 3a a2 ff ff call 80100480 +80106246: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010624d: 8d 76 00 lea 0x0(%esi),%esi + +80106250 : +int sys_dup(void) { +80106250: 55 push %ebp +80106251: 89 e5 mov %esp,%ebp +80106253: 56 push %esi +80106254: 53 push %ebx + if (argint(n, &fd) < 0) { +80106255: 8d 45 f4 lea -0xc(%ebp),%eax +int sys_dup(void) { +80106258: 83 ec 18 sub $0x18,%esp + if (argint(n, &fd) < 0) { +8010625b: 50 push %eax +8010625c: 6a 00 push $0x0 +8010625e: e8 9d fc ff ff call 80105f00 +80106263: 83 c4 10 add $0x10,%esp +80106266: 85 c0 test %eax,%eax +80106268: 78 36 js 801062a0 + if (fd < 0 || fd >= NOFILE || (f = myproc()->ofile[fd]) == 0) { +8010626a: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +8010626e: 77 30 ja 801062a0 +80106270: e8 3b ec ff ff call 80104eb0 +80106275: 8b 55 f4 mov -0xc(%ebp),%edx +80106278: 8b 74 90 28 mov 0x28(%eax,%edx,4),%esi +8010627c: 85 f6 test %esi,%esi +8010627e: 74 20 je 801062a0 + struct proc *curproc = myproc(); +80106280: e8 2b ec ff ff call 80104eb0 + for (fd = 0; fd < NOFILE; fd++) { +80106285: 31 db xor %ebx,%ebx +80106287: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010628e: 66 90 xchg %ax,%ax + if (curproc->ofile[fd] == 0) { +80106290: 8b 54 98 28 mov 0x28(%eax,%ebx,4),%edx +80106294: 85 d2 test %edx,%edx +80106296: 74 18 je 801062b0 + for (fd = 0; fd < NOFILE; fd++) { +80106298: 83 c3 01 add $0x1,%ebx +8010629b: 83 fb 10 cmp $0x10,%ebx +8010629e: 75 f0 jne 80106290 +} +801062a0: 8d 65 f8 lea -0x8(%ebp),%esp + return -1; +801062a3: bb ff ff ff ff mov $0xffffffff,%ebx +} +801062a8: 89 d8 mov %ebx,%eax +801062aa: 5b pop %ebx +801062ab: 5e pop %esi +801062ac: 5d pop %ebp +801062ad: c3 ret +801062ae: 66 90 xchg %ax,%ax + filedup(f); +801062b0: 83 ec 0c sub $0xc,%esp + curproc->ofile[fd] = f; +801062b3: 89 74 98 28 mov %esi,0x28(%eax,%ebx,4) + filedup(f); +801062b7: 56 push %esi +801062b8: e8 d3 c0 ff ff call 80102390 + return fd; +801062bd: 83 c4 10 add $0x10,%esp +} +801062c0: 8d 65 f8 lea -0x8(%ebp),%esp +801062c3: 89 d8 mov %ebx,%eax +801062c5: 5b pop %ebx +801062c6: 5e pop %esi +801062c7: 5d pop %ebp +801062c8: c3 ret +801062c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +801062d0 : +int sys_read(void) { +801062d0: 55 push %ebp +801062d1: 89 e5 mov %esp,%ebp +801062d3: 56 push %esi +801062d4: 53 push %ebx + if (argint(n, &fd) < 0) { +801062d5: 8d 5d f4 lea -0xc(%ebp),%ebx +int sys_read(void) { +801062d8: 83 ec 18 sub $0x18,%esp + if (argint(n, &fd) < 0) { +801062db: 53 push %ebx +801062dc: 6a 00 push $0x0 +801062de: e8 1d fc ff ff call 80105f00 +801062e3: 83 c4 10 add $0x10,%esp +801062e6: 85 c0 test %eax,%eax +801062e8: 78 5e js 80106348 + if (fd < 0 || fd >= NOFILE || (f = myproc()->ofile[fd]) == 0) { +801062ea: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +801062ee: 77 58 ja 80106348 +801062f0: e8 bb eb ff ff call 80104eb0 +801062f5: 8b 55 f4 mov -0xc(%ebp),%edx +801062f8: 8b 74 90 28 mov 0x28(%eax,%edx,4),%esi +801062fc: 85 f6 test %esi,%esi +801062fe: 74 48 je 80106348 + if (argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { +80106300: 83 ec 08 sub $0x8,%esp +80106303: 8d 45 f0 lea -0x10(%ebp),%eax +80106306: 50 push %eax +80106307: 6a 02 push $0x2 +80106309: e8 f2 fb ff ff call 80105f00 +8010630e: 83 c4 10 add $0x10,%esp +80106311: 85 c0 test %eax,%eax +80106313: 78 33 js 80106348 +80106315: 83 ec 04 sub $0x4,%esp +80106318: ff 75 f0 push -0x10(%ebp) +8010631b: 53 push %ebx +8010631c: 6a 01 push $0x1 +8010631e: e8 2d fc ff ff call 80105f50 +80106323: 83 c4 10 add $0x10,%esp +80106326: 85 c0 test %eax,%eax +80106328: 78 1e js 80106348 + return fileread(f, p, n); +8010632a: 83 ec 04 sub $0x4,%esp +8010632d: ff 75 f0 push -0x10(%ebp) +80106330: ff 75 f4 push -0xc(%ebp) +80106333: 56 push %esi +80106334: e8 d7 c1 ff ff call 80102510 +80106339: 83 c4 10 add $0x10,%esp +} +8010633c: 8d 65 f8 lea -0x8(%ebp),%esp +8010633f: 5b pop %ebx +80106340: 5e pop %esi +80106341: 5d pop %ebp +80106342: c3 ret +80106343: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80106347: 90 nop + return -1; +80106348: b8 ff ff ff ff mov $0xffffffff,%eax +8010634d: eb ed jmp 8010633c +8010634f: 90 nop + +80106350 : +int sys_write(void) { +80106350: 55 push %ebp +80106351: 89 e5 mov %esp,%ebp +80106353: 56 push %esi +80106354: 53 push %ebx + if (argint(n, &fd) < 0) { +80106355: 8d 5d f4 lea -0xc(%ebp),%ebx +int sys_write(void) { +80106358: 83 ec 18 sub $0x18,%esp + if (argint(n, &fd) < 0) { +8010635b: 53 push %ebx +8010635c: 6a 00 push $0x0 +8010635e: e8 9d fb ff ff call 80105f00 +80106363: 83 c4 10 add $0x10,%esp +80106366: 85 c0 test %eax,%eax +80106368: 78 5e js 801063c8 + if (fd < 0 || fd >= NOFILE || (f = myproc()->ofile[fd]) == 0) { +8010636a: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +8010636e: 77 58 ja 801063c8 +80106370: e8 3b eb ff ff call 80104eb0 +80106375: 8b 55 f4 mov -0xc(%ebp),%edx +80106378: 8b 74 90 28 mov 0x28(%eax,%edx,4),%esi +8010637c: 85 f6 test %esi,%esi +8010637e: 74 48 je 801063c8 + if (argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { +80106380: 83 ec 08 sub $0x8,%esp +80106383: 8d 45 f0 lea -0x10(%ebp),%eax +80106386: 50 push %eax +80106387: 6a 02 push $0x2 +80106389: e8 72 fb ff ff call 80105f00 +8010638e: 83 c4 10 add $0x10,%esp +80106391: 85 c0 test %eax,%eax +80106393: 78 33 js 801063c8 +80106395: 83 ec 04 sub $0x4,%esp +80106398: ff 75 f0 push -0x10(%ebp) +8010639b: 53 push %ebx +8010639c: 6a 01 push $0x1 +8010639e: e8 ad fb ff ff call 80105f50 +801063a3: 83 c4 10 add $0x10,%esp +801063a6: 85 c0 test %eax,%eax +801063a8: 78 1e js 801063c8 + return filewrite(f, p, n); +801063aa: 83 ec 04 sub $0x4,%esp +801063ad: ff 75 f0 push -0x10(%ebp) +801063b0: ff 75 f4 push -0xc(%ebp) +801063b3: 56 push %esi +801063b4: e8 e7 c1 ff ff call 801025a0 +801063b9: 83 c4 10 add $0x10,%esp +} +801063bc: 8d 65 f8 lea -0x8(%ebp),%esp +801063bf: 5b pop %ebx +801063c0: 5e pop %esi +801063c1: 5d pop %ebp +801063c2: c3 ret +801063c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801063c7: 90 nop + return -1; +801063c8: b8 ff ff ff ff mov $0xffffffff,%eax +801063cd: eb ed jmp 801063bc +801063cf: 90 nop + +801063d0 : +int sys_close(void) { +801063d0: 55 push %ebp +801063d1: 89 e5 mov %esp,%ebp +801063d3: 56 push %esi +801063d4: 53 push %ebx + if (argint(n, &fd) < 0) { +801063d5: 8d 45 f4 lea -0xc(%ebp),%eax +int sys_close(void) { +801063d8: 83 ec 18 sub $0x18,%esp + if (argint(n, &fd) < 0) { +801063db: 50 push %eax +801063dc: 6a 00 push $0x0 +801063de: e8 1d fb ff ff call 80105f00 +801063e3: 83 c4 10 add $0x10,%esp +801063e6: 85 c0 test %eax,%eax +801063e8: 78 3e js 80106428 + if (fd < 0 || fd >= NOFILE || (f = myproc()->ofile[fd]) == 0) { +801063ea: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +801063ee: 77 38 ja 80106428 +801063f0: e8 bb ea ff ff call 80104eb0 +801063f5: 8b 55 f4 mov -0xc(%ebp),%edx +801063f8: 8d 5a 08 lea 0x8(%edx),%ebx +801063fb: 8b 74 98 08 mov 0x8(%eax,%ebx,4),%esi +801063ff: 85 f6 test %esi,%esi +80106401: 74 25 je 80106428 + myproc()->ofile[fd] = 0; +80106403: e8 a8 ea ff ff call 80104eb0 + fileclose(f); +80106408: 83 ec 0c sub $0xc,%esp + myproc()->ofile[fd] = 0; +8010640b: c7 44 98 08 00 00 00 movl $0x0,0x8(%eax,%ebx,4) +80106412: 00 + fileclose(f); +80106413: 56 push %esi +80106414: e8 c7 bf ff ff call 801023e0 + return 0; +80106419: 83 c4 10 add $0x10,%esp +8010641c: 31 c0 xor %eax,%eax +} +8010641e: 8d 65 f8 lea -0x8(%ebp),%esp +80106421: 5b pop %ebx +80106422: 5e pop %esi +80106423: 5d pop %ebp +80106424: c3 ret +80106425: 8d 76 00 lea 0x0(%esi),%esi + return -1; +80106428: b8 ff ff ff ff mov $0xffffffff,%eax +8010642d: eb ef jmp 8010641e +8010642f: 90 nop + +80106430 : +int sys_fstat(void) { +80106430: 55 push %ebp +80106431: 89 e5 mov %esp,%ebp +80106433: 56 push %esi +80106434: 53 push %ebx + if (argint(n, &fd) < 0) { +80106435: 8d 5d f4 lea -0xc(%ebp),%ebx +int sys_fstat(void) { +80106438: 83 ec 18 sub $0x18,%esp + if (argint(n, &fd) < 0) { +8010643b: 53 push %ebx +8010643c: 6a 00 push $0x0 +8010643e: e8 bd fa ff ff call 80105f00 +80106443: 83 c4 10 add $0x10,%esp +80106446: 85 c0 test %eax,%eax +80106448: 78 46 js 80106490 + if (fd < 0 || fd >= NOFILE || (f = myproc()->ofile[fd]) == 0) { +8010644a: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +8010644e: 77 40 ja 80106490 +80106450: e8 5b ea ff ff call 80104eb0 +80106455: 8b 55 f4 mov -0xc(%ebp),%edx +80106458: 8b 74 90 28 mov 0x28(%eax,%edx,4),%esi +8010645c: 85 f6 test %esi,%esi +8010645e: 74 30 je 80106490 + if (argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) { +80106460: 83 ec 04 sub $0x4,%esp +80106463: 6a 14 push $0x14 +80106465: 53 push %ebx +80106466: 6a 01 push $0x1 +80106468: e8 e3 fa ff ff call 80105f50 +8010646d: 83 c4 10 add $0x10,%esp +80106470: 85 c0 test %eax,%eax +80106472: 78 1c js 80106490 + return filestat(f, st); +80106474: 83 ec 08 sub $0x8,%esp +80106477: ff 75 f4 push -0xc(%ebp) +8010647a: 56 push %esi +8010647b: e8 40 c0 ff ff call 801024c0 +80106480: 83 c4 10 add $0x10,%esp +} +80106483: 8d 65 f8 lea -0x8(%ebp),%esp +80106486: 5b pop %ebx +80106487: 5e pop %esi +80106488: 5d pop %ebp +80106489: c3 ret +8010648a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +80106490: b8 ff ff ff ff mov $0xffffffff,%eax +80106495: eb ec jmp 80106483 +80106497: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010649e: 66 90 xchg %ax,%ax + +801064a0 : +void cleanupsyslink(struct inode * ip) { +801064a0: 55 push %ebp +801064a1: 89 e5 mov %esp,%ebp +801064a3: 53 push %ebx +801064a4: 83 ec 10 sub $0x10,%esp +801064a7: 8b 5d 08 mov 0x8(%ebp),%ebx + ilock(ip); +801064aa: 53 push %ebx +801064ab: e8 c0 c7 ff ff call 80102c70 + ip->nlink--; +801064b0: 66 83 6b 56 01 subw $0x1,0x56(%ebx) + iupdate(ip); +801064b5: 89 1c 24 mov %ebx,(%esp) +801064b8: e8 03 c7 ff ff call 80102bc0 + iunlockput(ip); +801064bd: 89 1c 24 mov %ebx,(%esp) +801064c0: e8 3b ca ff ff call 80102f00 +} +801064c5: 8b 5d fc mov -0x4(%ebp),%ebx + end_op(); +801064c8: 83 c4 10 add $0x10,%esp +} +801064cb: c9 leave + end_op(); +801064cc: e9 ef dd ff ff jmp 801042c0 +801064d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801064d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801064df: 90 nop + +801064e0 : +int sys_link(void) { +801064e0: 55 push %ebp +801064e1: 89 e5 mov %esp,%ebp +801064e3: 57 push %edi +801064e4: 56 push %esi + if (argstr(0, &old) < 0 || argstr(1, &new) < 0) { +801064e5: 8d 45 d4 lea -0x2c(%ebp),%eax +int sys_link(void) { +801064e8: 53 push %ebx +801064e9: 83 ec 34 sub $0x34,%esp + if (argstr(0, &old) < 0 || argstr(1, &new) < 0) { +801064ec: 50 push %eax +801064ed: 6a 00 push $0x0 +801064ef: e8 cc fa ff ff call 80105fc0 +801064f4: 83 c4 10 add $0x10,%esp +801064f7: 85 c0 test %eax,%eax +801064f9: 0f 88 ff 00 00 00 js 801065fe +801064ff: 83 ec 08 sub $0x8,%esp +80106502: 8d 45 d0 lea -0x30(%ebp),%eax +80106505: 50 push %eax +80106506: 6a 01 push $0x1 +80106508: e8 b3 fa ff ff call 80105fc0 +8010650d: 83 c4 10 add $0x10,%esp +80106510: 85 c0 test %eax,%eax +80106512: 0f 88 e6 00 00 00 js 801065fe + begin_op(); +80106518: e8 33 dd ff ff call 80104250 + if ((ip = namei(old)) == 0) { +8010651d: 83 ec 0c sub $0xc,%esp +80106520: ff 75 d4 push -0x2c(%ebp) +80106523: e8 68 d0 ff ff call 80103590 +80106528: 83 c4 10 add $0x10,%esp +8010652b: 89 c3 mov %eax,%ebx +8010652d: 85 c0 test %eax,%eax +8010652f: 0f 84 e8 00 00 00 je 8010661d + ilock(ip); +80106535: 83 ec 0c sub $0xc,%esp +80106538: 50 push %eax +80106539: e8 32 c7 ff ff call 80102c70 + if (ip->type == T_DIR) { +8010653e: 83 c4 10 add $0x10,%esp +80106541: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80106546: 0f 84 b9 00 00 00 je 80106605 + iupdate(ip); +8010654c: 83 ec 0c sub $0xc,%esp + ip->nlink++; +8010654f: 66 83 43 56 01 addw $0x1,0x56(%ebx) + if ((dp = nameiparent(new, name)) == 0) { +80106554: 8d 7d da lea -0x26(%ebp),%edi + iupdate(ip); +80106557: 53 push %ebx +80106558: e8 63 c6 ff ff call 80102bc0 + iunlock(ip); +8010655d: 89 1c 24 mov %ebx,(%esp) +80106560: e8 eb c7 ff ff call 80102d50 + if ((dp = nameiparent(new, name)) == 0) { +80106565: 58 pop %eax +80106566: 5a pop %edx +80106567: 57 push %edi +80106568: ff 75 d0 push -0x30(%ebp) +8010656b: e8 40 d0 ff ff call 801035b0 +80106570: 83 c4 10 add $0x10,%esp +80106573: 89 c6 mov %eax,%esi +80106575: 85 c0 test %eax,%eax +80106577: 0f 84 ac 00 00 00 je 80106629 + ilock(dp); +8010657d: 83 ec 0c sub $0xc,%esp +80106580: 50 push %eax +80106581: e8 ea c6 ff ff call 80102c70 + if (dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0) { +80106586: 8b 03 mov (%ebx),%eax +80106588: 83 c4 10 add $0x10,%esp +8010658b: 39 06 cmp %eax,(%esi) +8010658d: 75 41 jne 801065d0 +8010658f: 83 ec 04 sub $0x4,%esp +80106592: ff 73 04 push 0x4(%ebx) +80106595: 57 push %edi +80106596: 56 push %esi +80106597: e8 34 cf ff ff call 801034d0 +8010659c: 83 c4 10 add $0x10,%esp +8010659f: 85 c0 test %eax,%eax +801065a1: 78 2d js 801065d0 + iunlockput(dp); +801065a3: 83 ec 0c sub $0xc,%esp +801065a6: 56 push %esi +801065a7: e8 54 c9 ff ff call 80102f00 + iput(ip); +801065ac: 89 1c 24 mov %ebx,(%esp) +801065af: e8 ec c7 ff ff call 80102da0 + end_op(); +801065b4: e8 07 dd ff ff call 801042c0 + return 0; +801065b9: 83 c4 10 add $0x10,%esp +801065bc: 31 c0 xor %eax,%eax +} +801065be: 8d 65 f4 lea -0xc(%ebp),%esp +801065c1: 5b pop %ebx +801065c2: 5e pop %esi +801065c3: 5f pop %edi +801065c4: 5d pop %ebp +801065c5: c3 ret +801065c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801065cd: 8d 76 00 lea 0x0(%esi),%esi + iunlockput(dp); +801065d0: 83 ec 0c sub $0xc,%esp +801065d3: 56 push %esi +801065d4: e8 27 c9 ff ff call 80102f00 + ilock(ip); +801065d9: 89 1c 24 mov %ebx,(%esp) +801065dc: e8 8f c6 ff ff call 80102c70 + ip->nlink--; +801065e1: 66 83 6b 56 01 subw $0x1,0x56(%ebx) + iupdate(ip); +801065e6: 89 1c 24 mov %ebx,(%esp) +801065e9: e8 d2 c5 ff ff call 80102bc0 + iunlockput(ip); +801065ee: 89 1c 24 mov %ebx,(%esp) +801065f1: e8 0a c9 ff ff call 80102f00 + end_op(); +801065f6: e8 c5 dc ff ff call 801042c0 +} +801065fb: 83 c4 10 add $0x10,%esp + return -1; +801065fe: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106603: eb b9 jmp 801065be + iunlockput(ip); +80106605: 83 ec 0c sub $0xc,%esp +80106608: 53 push %ebx +80106609: e8 f2 c8 ff ff call 80102f00 + end_op(); +8010660e: e8 ad dc ff ff call 801042c0 + return -1; +80106613: 83 c4 10 add $0x10,%esp +80106616: b8 ff ff ff ff mov $0xffffffff,%eax +8010661b: eb a1 jmp 801065be + end_op(); +8010661d: e8 9e dc ff ff call 801042c0 + return -1; +80106622: b8 ff ff ff ff mov $0xffffffff,%eax +80106627: eb 95 jmp 801065be + ilock(ip); +80106629: 83 ec 0c sub $0xc,%esp +8010662c: 53 push %ebx +8010662d: eb ad jmp 801065dc +8010662f: 90 nop + +80106630 : +int sys_unlink(void) { +80106630: 55 push %ebp +80106631: 89 e5 mov %esp,%ebp +80106633: 57 push %edi +80106634: 56 push %esi + if (argstr(0, &path) < 0) { +80106635: 8d 45 c0 lea -0x40(%ebp),%eax +int sys_unlink(void) { +80106638: 53 push %ebx +80106639: 83 ec 54 sub $0x54,%esp + if (argstr(0, &path) < 0) { +8010663c: 50 push %eax +8010663d: 6a 00 push $0x0 +8010663f: e8 7c f9 ff ff call 80105fc0 +80106644: 83 c4 10 add $0x10,%esp +80106647: 85 c0 test %eax,%eax +80106649: 0f 88 4c 01 00 00 js 8010679b + begin_op(); +8010664f: e8 fc db ff ff call 80104250 + if ((dp = nameiparent(path, name)) == 0) { +80106654: 8d 5d ca lea -0x36(%ebp),%ebx +80106657: 83 ec 08 sub $0x8,%esp +8010665a: 53 push %ebx +8010665b: ff 75 c0 push -0x40(%ebp) +8010665e: e8 4d cf ff ff call 801035b0 +80106663: 83 c4 10 add $0x10,%esp +80106666: 89 45 b4 mov %eax,-0x4c(%ebp) +80106669: 85 c0 test %eax,%eax +8010666b: 0f 84 55 01 00 00 je 801067c6 + ilock(dp); +80106671: 83 ec 0c sub $0xc,%esp +80106674: ff 75 b4 push -0x4c(%ebp) +80106677: e8 f4 c5 ff ff call 80102c70 + if (namecmp(name, ".") == 0 || namecmp(name, "..") == 0) { +8010667c: 5a pop %edx +8010667d: 59 pop %ecx +8010667e: 68 e8 91 10 80 push $0x801091e8 +80106683: 53 push %ebx +80106684: e8 27 cb ff ff call 801031b0 +80106689: 83 c4 10 add $0x10,%esp +8010668c: 85 c0 test %eax,%eax +8010668e: 0f 84 2d 01 00 00 je 801067c1 +80106694: 83 ec 08 sub $0x8,%esp +80106697: 68 e7 91 10 80 push $0x801091e7 +8010669c: 53 push %ebx +8010669d: e8 0e cb ff ff call 801031b0 +801066a2: 83 c4 10 add $0x10,%esp +801066a5: 85 c0 test %eax,%eax +801066a7: 0f 84 14 01 00 00 je 801067c1 + if ((ip = dirlookup(dp, name, &off)) == 0) { +801066ad: 83 ec 04 sub $0x4,%esp +801066b0: 8d 45 c4 lea -0x3c(%ebp),%eax +801066b3: 50 push %eax +801066b4: 53 push %ebx +801066b5: ff 75 b4 push -0x4c(%ebp) +801066b8: e8 13 cb ff ff call 801031d0 +801066bd: 83 c4 10 add $0x10,%esp +801066c0: 89 c3 mov %eax,%ebx +801066c2: 85 c0 test %eax,%eax +801066c4: 0f 84 f7 00 00 00 je 801067c1 + ilock(ip); +801066ca: 83 ec 0c sub $0xc,%esp +801066cd: 50 push %eax +801066ce: e8 9d c5 ff ff call 80102c70 + if (ip->nlink < 1) { +801066d3: 83 c4 10 add $0x10,%esp +801066d6: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) +801066db: 0f 8e 01 01 00 00 jle 801067e2 + if (ip->type == T_DIR && !isdirempty(ip)) { +801066e1: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +801066e6: 8d 7d d8 lea -0x28(%ebp),%edi +801066e9: 74 65 je 80106750 + memset(&de, 0, sizeof(de)); +801066eb: 83 ec 04 sub $0x4,%esp +801066ee: 6a 10 push $0x10 +801066f0: 6a 00 push $0x0 +801066f2: 57 push %edi +801066f3: e8 48 f5 ff ff call 80105c40 + if (writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +801066f8: 6a 10 push $0x10 +801066fa: ff 75 c4 push -0x3c(%ebp) +801066fd: 57 push %edi +801066fe: ff 75 b4 push -0x4c(%ebp) +80106701: e8 7a c9 ff ff call 80103080 +80106706: 83 c4 20 add $0x20,%esp +80106709: 83 f8 10 cmp $0x10,%eax +8010670c: 0f 85 dd 00 00 00 jne 801067ef + if (ip->type == T_DIR) { +80106712: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80106717: 0f 84 8b 00 00 00 je 801067a8 + iunlockput(dp); +8010671d: 83 ec 0c sub $0xc,%esp +80106720: ff 75 b4 push -0x4c(%ebp) +80106723: e8 d8 c7 ff ff call 80102f00 + ip->nlink--; +80106728: 66 83 6b 56 01 subw $0x1,0x56(%ebx) + iupdate(ip); +8010672d: 89 1c 24 mov %ebx,(%esp) +80106730: e8 8b c4 ff ff call 80102bc0 + iunlockput(ip); +80106735: 89 1c 24 mov %ebx,(%esp) +80106738: e8 c3 c7 ff ff call 80102f00 + end_op(); +8010673d: e8 7e db ff ff call 801042c0 + return 0; +80106742: 83 c4 10 add $0x10,%esp +80106745: 31 c0 xor %eax,%eax +} +80106747: 8d 65 f4 lea -0xc(%ebp),%esp +8010674a: 5b pop %ebx +8010674b: 5e pop %esi +8010674c: 5f pop %edi +8010674d: 5d pop %ebp +8010674e: c3 ret +8010674f: 90 nop + for (off = 2 * sizeof(de); off < dp->size; off += sizeof(de)) { +80106750: 83 7b 58 20 cmpl $0x20,0x58(%ebx) +80106754: 76 95 jbe 801066eb +80106756: be 20 00 00 00 mov $0x20,%esi +8010675b: eb 0b jmp 80106768 +8010675d: 8d 76 00 lea 0x0(%esi),%esi +80106760: 83 c6 10 add $0x10,%esi +80106763: 39 73 58 cmp %esi,0x58(%ebx) +80106766: 76 83 jbe 801066eb + if (readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) { +80106768: 6a 10 push $0x10 +8010676a: 56 push %esi +8010676b: 57 push %edi +8010676c: 53 push %ebx +8010676d: e8 0e c8 ff ff call 80102f80 +80106772: 83 c4 10 add $0x10,%esp +80106775: 83 f8 10 cmp $0x10,%eax +80106778: 75 5b jne 801067d5 + if (de.inum != 0) { +8010677a: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) +8010677f: 74 df je 80106760 + iunlockput(ip); +80106781: 83 ec 0c sub $0xc,%esp +80106784: 53 push %ebx +80106785: e8 76 c7 ff ff call 80102f00 + iunlockput(dp); +8010678a: 58 pop %eax +8010678b: ff 75 b4 push -0x4c(%ebp) +8010678e: e8 6d c7 ff ff call 80102f00 + end_op(); +80106793: e8 28 db ff ff call 801042c0 + return -1; +80106798: 83 c4 10 add $0x10,%esp +8010679b: b8 ff ff ff ff mov $0xffffffff,%eax +801067a0: eb a5 jmp 80106747 +801067a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + dp->nlink--; +801067a8: 8b 45 b4 mov -0x4c(%ebp),%eax + iupdate(dp); +801067ab: 83 ec 0c sub $0xc,%esp + dp->nlink--; +801067ae: 66 83 68 56 01 subw $0x1,0x56(%eax) + iupdate(dp); +801067b3: 50 push %eax +801067b4: e8 07 c4 ff ff call 80102bc0 +801067b9: 83 c4 10 add $0x10,%esp +801067bc: e9 5c ff ff ff jmp 8010671d + iunlockput(dp); +801067c1: 83 ec 0c sub $0xc,%esp +801067c4: eb c5 jmp 8010678b + end_op(); +801067c6: e8 f5 da ff ff call 801042c0 + return -1; +801067cb: b8 ff ff ff ff mov $0xffffffff,%eax +801067d0: e9 72 ff ff ff jmp 80106747 + panic("isdirempty: readi"); +801067d5: 83 ec 0c sub $0xc,%esp +801067d8: 68 0c 92 10 80 push $0x8010920c +801067dd: e8 9e 9c ff ff call 80100480 + panic("unlink: nlink < 1"); +801067e2: 83 ec 0c sub $0xc,%esp +801067e5: 68 fa 91 10 80 push $0x801091fa +801067ea: e8 91 9c ff ff call 80100480 + panic("unlink: writei"); +801067ef: 83 ec 0c sub $0xc,%esp +801067f2: 68 1e 92 10 80 push $0x8010921e +801067f7: e8 84 9c ff ff call 80100480 +801067fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106800 : + +int sys_open(void) { +80106800: 55 push %ebp +80106801: 89 e5 mov %esp,%ebp +80106803: 57 push %edi +80106804: 56 push %esi + char *path; + int fd, omode; + struct file *f; + struct inode *ip; + + if (argstr(0, &path) < 0 || argint(1, &omode) < 0) { +80106805: 8d 45 e0 lea -0x20(%ebp),%eax +int sys_open(void) { +80106808: 53 push %ebx +80106809: 83 ec 24 sub $0x24,%esp + if (argstr(0, &path) < 0 || argint(1, &omode) < 0) { +8010680c: 50 push %eax +8010680d: 6a 00 push $0x0 +8010680f: e8 ac f7 ff ff call 80105fc0 +80106814: 83 c4 10 add $0x10,%esp +80106817: 85 c0 test %eax,%eax +80106819: 0f 88 8e 00 00 00 js 801068ad +8010681f: 83 ec 08 sub $0x8,%esp +80106822: 8d 45 e4 lea -0x1c(%ebp),%eax +80106825: 50 push %eax +80106826: 6a 01 push $0x1 +80106828: e8 d3 f6 ff ff call 80105f00 +8010682d: 83 c4 10 add $0x10,%esp +80106830: 85 c0 test %eax,%eax +80106832: 78 79 js 801068ad + return -1; + } + + begin_op(); +80106834: e8 17 da ff ff call 80104250 + + if (omode & O_CREATE) { +80106839: f6 45 e5 02 testb $0x2,-0x1b(%ebp) +8010683d: 75 79 jne 801068b8 + end_op(); + return -1; + } + } + else { + if ((ip = namei(path)) == 0) { +8010683f: 83 ec 0c sub $0xc,%esp +80106842: ff 75 e0 push -0x20(%ebp) +80106845: e8 46 cd ff ff call 80103590 +8010684a: 83 c4 10 add $0x10,%esp +8010684d: 89 c6 mov %eax,%esi +8010684f: 85 c0 test %eax,%eax +80106851: 0f 84 7e 00 00 00 je 801068d5 + end_op(); + return -1; + } + ilock(ip); +80106857: 83 ec 0c sub $0xc,%esp +8010685a: 50 push %eax +8010685b: e8 10 c4 ff ff call 80102c70 + if (ip->type == T_DIR && omode != O_RDONLY) { +80106860: 83 c4 10 add $0x10,%esp +80106863: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) +80106868: 0f 84 c2 00 00 00 je 80106930 + end_op(); + return -1; + } + } + + if ((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0) { +8010686e: e8 ad ba ff ff call 80102320 +80106873: 89 c7 mov %eax,%edi +80106875: 85 c0 test %eax,%eax +80106877: 74 23 je 8010689c + struct proc *curproc = myproc(); +80106879: e8 32 e6 ff ff call 80104eb0 + for (fd = 0; fd < NOFILE; fd++) { +8010687e: 31 db xor %ebx,%ebx + if (curproc->ofile[fd] == 0) { +80106880: 8b 54 98 28 mov 0x28(%eax,%ebx,4),%edx +80106884: 85 d2 test %edx,%edx +80106886: 74 60 je 801068e8 + for (fd = 0; fd < NOFILE; fd++) { +80106888: 83 c3 01 add $0x1,%ebx +8010688b: 83 fb 10 cmp $0x10,%ebx +8010688e: 75 f0 jne 80106880 + if (f) { + fileclose(f); +80106890: 83 ec 0c sub $0xc,%esp +80106893: 57 push %edi +80106894: e8 47 bb ff ff call 801023e0 +80106899: 83 c4 10 add $0x10,%esp + } + iunlockput(ip); +8010689c: 83 ec 0c sub $0xc,%esp +8010689f: 56 push %esi +801068a0: e8 5b c6 ff ff call 80102f00 + end_op(); +801068a5: e8 16 da ff ff call 801042c0 + return -1; +801068aa: 83 c4 10 add $0x10,%esp +801068ad: bb ff ff ff ff mov $0xffffffff,%ebx +801068b2: eb 6d jmp 80106921 +801068b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ip = create(path, T_FILE, 0, 0); +801068b8: 83 ec 0c sub $0xc,%esp +801068bb: 8b 45 e0 mov -0x20(%ebp),%eax +801068be: 31 c9 xor %ecx,%ecx +801068c0: ba 02 00 00 00 mov $0x2,%edx +801068c5: 6a 00 push $0x0 +801068c7: e8 e4 f7 ff ff call 801060b0 + if (ip == 0) { +801068cc: 83 c4 10 add $0x10,%esp + ip = create(path, T_FILE, 0, 0); +801068cf: 89 c6 mov %eax,%esi + if (ip == 0) { +801068d1: 85 c0 test %eax,%eax +801068d3: 75 99 jne 8010686e + end_op(); +801068d5: e8 e6 d9 ff ff call 801042c0 + return -1; +801068da: bb ff ff ff ff mov $0xffffffff,%ebx +801068df: eb 40 jmp 80106921 +801068e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + } + iunlock(ip); +801068e8: 83 ec 0c sub $0xc,%esp + curproc->ofile[fd] = f; +801068eb: 89 7c 98 28 mov %edi,0x28(%eax,%ebx,4) + iunlock(ip); +801068ef: 56 push %esi +801068f0: e8 5b c4 ff ff call 80102d50 + end_op(); +801068f5: e8 c6 d9 ff ff call 801042c0 + + f->type = FD_INODE; +801068fa: c7 07 02 00 00 00 movl $0x2,(%edi) + f->ip = ip; + f->off = 0; + f->readable = !(omode & O_WRONLY); +80106900: 8b 55 e4 mov -0x1c(%ebp),%edx + f->writable = (omode & O_WRONLY) || (omode & O_RDWR); +80106903: 83 c4 10 add $0x10,%esp + f->ip = ip; +80106906: 89 77 10 mov %esi,0x10(%edi) + f->readable = !(omode & O_WRONLY); +80106909: 89 d0 mov %edx,%eax + f->off = 0; +8010690b: c7 47 14 00 00 00 00 movl $0x0,0x14(%edi) + f->readable = !(omode & O_WRONLY); +80106912: f7 d0 not %eax +80106914: 83 e0 01 and $0x1,%eax + f->writable = (omode & O_WRONLY) || (omode & O_RDWR); +80106917: 83 e2 03 and $0x3,%edx + f->readable = !(omode & O_WRONLY); +8010691a: 88 47 08 mov %al,0x8(%edi) + f->writable = (omode & O_WRONLY) || (omode & O_RDWR); +8010691d: 0f 95 47 09 setne 0x9(%edi) + return fd; +} +80106921: 8d 65 f4 lea -0xc(%ebp),%esp +80106924: 89 d8 mov %ebx,%eax +80106926: 5b pop %ebx +80106927: 5e pop %esi +80106928: 5f pop %edi +80106929: 5d pop %ebp +8010692a: c3 ret +8010692b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010692f: 90 nop + if (ip->type == T_DIR && omode != O_RDONLY) { +80106930: 8b 4d e4 mov -0x1c(%ebp),%ecx +80106933: 85 c9 test %ecx,%ecx +80106935: 0f 84 33 ff ff ff je 8010686e +8010693b: e9 5c ff ff ff jmp 8010689c + +80106940 : + +int sys_mkdir(void) { +80106940: 55 push %ebp +80106941: 89 e5 mov %esp,%ebp +80106943: 83 ec 18 sub $0x18,%esp + char *path; + struct inode *ip; + + begin_op(); +80106946: e8 05 d9 ff ff call 80104250 + if (argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0) { +8010694b: 83 ec 08 sub $0x8,%esp +8010694e: 8d 45 f4 lea -0xc(%ebp),%eax +80106951: 50 push %eax +80106952: 6a 00 push $0x0 +80106954: e8 67 f6 ff ff call 80105fc0 +80106959: 83 c4 10 add $0x10,%esp +8010695c: 85 c0 test %eax,%eax +8010695e: 78 30 js 80106990 +80106960: 83 ec 0c sub $0xc,%esp +80106963: 8b 45 f4 mov -0xc(%ebp),%eax +80106966: 31 c9 xor %ecx,%ecx +80106968: ba 01 00 00 00 mov $0x1,%edx +8010696d: 6a 00 push $0x0 +8010696f: e8 3c f7 ff ff call 801060b0 +80106974: 83 c4 10 add $0x10,%esp +80106977: 85 c0 test %eax,%eax +80106979: 74 15 je 80106990 + end_op(); + return -1; + } + iunlockput(ip); +8010697b: 83 ec 0c sub $0xc,%esp +8010697e: 50 push %eax +8010697f: e8 7c c5 ff ff call 80102f00 + end_op(); +80106984: e8 37 d9 ff ff call 801042c0 + return 0; +80106989: 83 c4 10 add $0x10,%esp +8010698c: 31 c0 xor %eax,%eax +} +8010698e: c9 leave +8010698f: c3 ret + end_op(); +80106990: e8 2b d9 ff ff call 801042c0 + return -1; +80106995: b8 ff ff ff ff mov $0xffffffff,%eax +} +8010699a: c9 leave +8010699b: c3 ret +8010699c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801069a0 : + +int sys_mknod(void) { +801069a0: 55 push %ebp +801069a1: 89 e5 mov %esp,%ebp +801069a3: 83 ec 18 sub $0x18,%esp + struct inode *ip; + char *path; + int major, minor; + + begin_op(); +801069a6: e8 a5 d8 ff ff call 80104250 + if ((argstr(0, &path)) < 0 || +801069ab: 83 ec 08 sub $0x8,%esp +801069ae: 8d 45 ec lea -0x14(%ebp),%eax +801069b1: 50 push %eax +801069b2: 6a 00 push $0x0 +801069b4: e8 07 f6 ff ff call 80105fc0 +801069b9: 83 c4 10 add $0x10,%esp +801069bc: 85 c0 test %eax,%eax +801069be: 78 60 js 80106a20 + argint(1, &major) < 0 || +801069c0: 83 ec 08 sub $0x8,%esp +801069c3: 8d 45 f0 lea -0x10(%ebp),%eax +801069c6: 50 push %eax +801069c7: 6a 01 push $0x1 +801069c9: e8 32 f5 ff ff call 80105f00 + if ((argstr(0, &path)) < 0 || +801069ce: 83 c4 10 add $0x10,%esp +801069d1: 85 c0 test %eax,%eax +801069d3: 78 4b js 80106a20 + argint(2, &minor) < 0 || +801069d5: 83 ec 08 sub $0x8,%esp +801069d8: 8d 45 f4 lea -0xc(%ebp),%eax +801069db: 50 push %eax +801069dc: 6a 02 push $0x2 +801069de: e8 1d f5 ff ff call 80105f00 + argint(1, &major) < 0 || +801069e3: 83 c4 10 add $0x10,%esp +801069e6: 85 c0 test %eax,%eax +801069e8: 78 36 js 80106a20 + (ip = create(path, T_DEV, major, minor)) == 0) { +801069ea: 0f bf 45 f4 movswl -0xc(%ebp),%eax +801069ee: 83 ec 0c sub $0xc,%esp +801069f1: 0f bf 4d f0 movswl -0x10(%ebp),%ecx +801069f5: ba 03 00 00 00 mov $0x3,%edx +801069fa: 50 push %eax +801069fb: 8b 45 ec mov -0x14(%ebp),%eax +801069fe: e8 ad f6 ff ff call 801060b0 + argint(2, &minor) < 0 || +80106a03: 83 c4 10 add $0x10,%esp +80106a06: 85 c0 test %eax,%eax +80106a08: 74 16 je 80106a20 + end_op(); + return -1; + } + iunlockput(ip); +80106a0a: 83 ec 0c sub $0xc,%esp +80106a0d: 50 push %eax +80106a0e: e8 ed c4 ff ff call 80102f00 + end_op(); +80106a13: e8 a8 d8 ff ff call 801042c0 + return 0; +80106a18: 83 c4 10 add $0x10,%esp +80106a1b: 31 c0 xor %eax,%eax +} +80106a1d: c9 leave +80106a1e: c3 ret +80106a1f: 90 nop + end_op(); +80106a20: e8 9b d8 ff ff call 801042c0 + return -1; +80106a25: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106a2a: c9 leave +80106a2b: c3 ret +80106a2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106a30 : + +int sys_chdir(void) { +80106a30: 55 push %ebp +80106a31: 89 e5 mov %esp,%ebp +80106a33: 56 push %esi +80106a34: 53 push %ebx +80106a35: 83 ec 10 sub $0x10,%esp + char *path; + struct inode *ip; + struct proc *curproc = myproc(); +80106a38: e8 73 e4 ff ff call 80104eb0 +80106a3d: 89 c6 mov %eax,%esi + + begin_op(); +80106a3f: e8 0c d8 ff ff call 80104250 + if (argstr(0, &path) < 0 || (ip = namei(path)) == 0) { +80106a44: 83 ec 08 sub $0x8,%esp +80106a47: 8d 45 f4 lea -0xc(%ebp),%eax +80106a4a: 50 push %eax +80106a4b: 6a 00 push $0x0 +80106a4d: e8 6e f5 ff ff call 80105fc0 +80106a52: 83 c4 10 add $0x10,%esp +80106a55: 85 c0 test %eax,%eax +80106a57: 78 77 js 80106ad0 +80106a59: 83 ec 0c sub $0xc,%esp +80106a5c: ff 75 f4 push -0xc(%ebp) +80106a5f: e8 2c cb ff ff call 80103590 +80106a64: 83 c4 10 add $0x10,%esp +80106a67: 89 c3 mov %eax,%ebx +80106a69: 85 c0 test %eax,%eax +80106a6b: 74 63 je 80106ad0 + end_op(); + return -1; + } + ilock(ip); +80106a6d: 83 ec 0c sub $0xc,%esp +80106a70: 50 push %eax +80106a71: e8 fa c1 ff ff call 80102c70 + if (ip->type != T_DIR) { +80106a76: 83 c4 10 add $0x10,%esp +80106a79: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80106a7e: 75 30 jne 80106ab0 + iunlockput(ip); + end_op(); + return -1; + } + iunlock(ip); +80106a80: 83 ec 0c sub $0xc,%esp +80106a83: 53 push %ebx +80106a84: e8 c7 c2 ff ff call 80102d50 + iput(curproc->cwd); +80106a89: 58 pop %eax +80106a8a: ff 76 68 push 0x68(%esi) +80106a8d: e8 0e c3 ff ff call 80102da0 + end_op(); +80106a92: e8 29 d8 ff ff call 801042c0 + curproc->cwd = ip; +80106a97: 89 5e 68 mov %ebx,0x68(%esi) + return 0; +80106a9a: 83 c4 10 add $0x10,%esp +80106a9d: 31 c0 xor %eax,%eax +} +80106a9f: 8d 65 f8 lea -0x8(%ebp),%esp +80106aa2: 5b pop %ebx +80106aa3: 5e pop %esi +80106aa4: 5d pop %ebp +80106aa5: c3 ret +80106aa6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106aad: 8d 76 00 lea 0x0(%esi),%esi + iunlockput(ip); +80106ab0: 83 ec 0c sub $0xc,%esp +80106ab3: 53 push %ebx +80106ab4: e8 47 c4 ff ff call 80102f00 + end_op(); +80106ab9: e8 02 d8 ff ff call 801042c0 + return -1; +80106abe: 83 c4 10 add $0x10,%esp +80106ac1: b8 ff ff ff ff mov $0xffffffff,%eax +80106ac6: eb d7 jmp 80106a9f +80106ac8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106acf: 90 nop + end_op(); +80106ad0: e8 eb d7 ff ff call 801042c0 + return -1; +80106ad5: b8 ff ff ff ff mov $0xffffffff,%eax +80106ada: eb c3 jmp 80106a9f +80106adc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106ae0 : + +int sys_exec(void) { +80106ae0: 55 push %ebp +80106ae1: 89 e5 mov %esp,%ebp +80106ae3: 57 push %edi +80106ae4: 56 push %esi + char *path, *argv[MAXARG]; + int i; + uint uargv, uarg; + + if (argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) { +80106ae5: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax +int sys_exec(void) { +80106aeb: 53 push %ebx +80106aec: 81 ec a4 00 00 00 sub $0xa4,%esp + if (argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) { +80106af2: 50 push %eax +80106af3: 6a 00 push $0x0 +80106af5: e8 c6 f4 ff ff call 80105fc0 +80106afa: 83 c4 10 add $0x10,%esp +80106afd: 85 c0 test %eax,%eax +80106aff: 0f 88 87 00 00 00 js 80106b8c +80106b05: 83 ec 08 sub $0x8,%esp +80106b08: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax +80106b0e: 50 push %eax +80106b0f: 6a 01 push $0x1 +80106b11: e8 ea f3 ff ff call 80105f00 +80106b16: 83 c4 10 add $0x10,%esp +80106b19: 85 c0 test %eax,%eax +80106b1b: 78 6f js 80106b8c + return -1; + } + memset(argv, 0, sizeof(argv)); +80106b1d: 83 ec 04 sub $0x4,%esp +80106b20: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi + for (i = 0;; i++) { +80106b26: 31 db xor %ebx,%ebx + memset(argv, 0, sizeof(argv)); +80106b28: 68 80 00 00 00 push $0x80 +80106b2d: 6a 00 push $0x0 +80106b2f: 56 push %esi +80106b30: e8 0b f1 ff ff call 80105c40 +80106b35: 83 c4 10 add $0x10,%esp +80106b38: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106b3f: 90 nop + if (i >= NELEM(argv)) { + return -1; + } + if (fetchint(uargv + 4 * i, (int*)&uarg) < 0) { +80106b40: 83 ec 08 sub $0x8,%esp +80106b43: 8d 85 64 ff ff ff lea -0x9c(%ebp),%eax +80106b49: 8d 3c 9d 00 00 00 00 lea 0x0(,%ebx,4),%edi +80106b50: 50 push %eax +80106b51: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax +80106b57: 01 f8 add %edi,%eax +80106b59: 50 push %eax +80106b5a: e8 11 f3 ff ff call 80105e70 +80106b5f: 83 c4 10 add $0x10,%esp +80106b62: 85 c0 test %eax,%eax +80106b64: 78 26 js 80106b8c + return -1; + } + if (uarg == 0) { +80106b66: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax +80106b6c: 85 c0 test %eax,%eax +80106b6e: 74 30 je 80106ba0 + argv[i] = 0; + break; + } + if (fetchstr(uarg, &argv[i]) < 0) { +80106b70: 83 ec 08 sub $0x8,%esp +80106b73: 8d 14 3e lea (%esi,%edi,1),%edx +80106b76: 52 push %edx +80106b77: 50 push %eax +80106b78: e8 33 f3 ff ff call 80105eb0 +80106b7d: 83 c4 10 add $0x10,%esp +80106b80: 85 c0 test %eax,%eax +80106b82: 78 08 js 80106b8c + for (i = 0;; i++) { +80106b84: 83 c3 01 add $0x1,%ebx + if (i >= NELEM(argv)) { +80106b87: 83 fb 20 cmp $0x20,%ebx +80106b8a: 75 b4 jne 80106b40 + return -1; + } + } + return exec(path, argv); +} +80106b8c: 8d 65 f4 lea -0xc(%ebp),%esp + return -1; +80106b8f: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106b94: 5b pop %ebx +80106b95: 5e pop %esi +80106b96: 5f pop %edi +80106b97: 5d pop %ebp +80106b98: c3 ret +80106b99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + argv[i] = 0; +80106ba0: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) +80106ba7: 00 00 00 00 + return exec(path, argv); +80106bab: 83 ec 08 sub $0x8,%esp +80106bae: 56 push %esi +80106baf: ff b5 5c ff ff ff push -0xa4(%ebp) +80106bb5: e8 66 b3 ff ff call 80101f20 +80106bba: 83 c4 10 add $0x10,%esp +} +80106bbd: 8d 65 f4 lea -0xc(%ebp),%esp +80106bc0: 5b pop %ebx +80106bc1: 5e pop %esi +80106bc2: 5f pop %edi +80106bc3: 5d pop %ebp +80106bc4: c3 ret +80106bc5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106bcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106bd0 : + +int sys_pipe(void) { +80106bd0: 55 push %ebp +80106bd1: 89 e5 mov %esp,%ebp +80106bd3: 57 push %edi +80106bd4: 56 push %esi + int *fd; + struct file *rf, *wf; + int fd0, fd1; + + if (argptr(0, (void*)&fd, 2 * sizeof(fd[0])) < 0) { +80106bd5: 8d 45 dc lea -0x24(%ebp),%eax +int sys_pipe(void) { +80106bd8: 53 push %ebx +80106bd9: 83 ec 20 sub $0x20,%esp + if (argptr(0, (void*)&fd, 2 * sizeof(fd[0])) < 0) { +80106bdc: 6a 08 push $0x8 +80106bde: 50 push %eax +80106bdf: 6a 00 push $0x0 +80106be1: e8 6a f3 ff ff call 80105f50 +80106be6: 83 c4 10 add $0x10,%esp +80106be9: 85 c0 test %eax,%eax +80106beb: 78 4a js 80106c37 + return -1; + } + if (pipealloc(&rf, &wf) < 0) { +80106bed: 83 ec 08 sub $0x8,%esp +80106bf0: 8d 45 e4 lea -0x1c(%ebp),%eax +80106bf3: 50 push %eax +80106bf4: 8d 45 e0 lea -0x20(%ebp),%eax +80106bf7: 50 push %eax +80106bf8: e8 73 dd ff ff call 80104970 +80106bfd: 83 c4 10 add $0x10,%esp +80106c00: 85 c0 test %eax,%eax +80106c02: 78 33 js 80106c37 + return -1; + } + fd0 = -1; + if ((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0) { +80106c04: 8b 7d e0 mov -0x20(%ebp),%edi + for (fd = 0; fd < NOFILE; fd++) { +80106c07: 31 db xor %ebx,%ebx + struct proc *curproc = myproc(); +80106c09: e8 a2 e2 ff ff call 80104eb0 + for (fd = 0; fd < NOFILE; fd++) { +80106c0e: 66 90 xchg %ax,%ax + if (curproc->ofile[fd] == 0) { +80106c10: 8b 74 98 28 mov 0x28(%eax,%ebx,4),%esi +80106c14: 85 f6 test %esi,%esi +80106c16: 74 28 je 80106c40 + for (fd = 0; fd < NOFILE; fd++) { +80106c18: 83 c3 01 add $0x1,%ebx +80106c1b: 83 fb 10 cmp $0x10,%ebx +80106c1e: 75 f0 jne 80106c10 + if (fd0 >= 0) { + myproc()->ofile[fd0] = 0; + } + fileclose(rf); +80106c20: 83 ec 0c sub $0xc,%esp +80106c23: ff 75 e0 push -0x20(%ebp) +80106c26: e8 b5 b7 ff ff call 801023e0 + fileclose(wf); +80106c2b: 58 pop %eax +80106c2c: ff 75 e4 push -0x1c(%ebp) +80106c2f: e8 ac b7 ff ff call 801023e0 + return -1; +80106c34: 83 c4 10 add $0x10,%esp +80106c37: b8 ff ff ff ff mov $0xffffffff,%eax +80106c3c: eb 53 jmp 80106c91 +80106c3e: 66 90 xchg %ax,%ax + curproc->ofile[fd] = f; +80106c40: 8d 73 08 lea 0x8(%ebx),%esi +80106c43: 89 7c b0 08 mov %edi,0x8(%eax,%esi,4) + if ((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0) { +80106c47: 8b 7d e4 mov -0x1c(%ebp),%edi + struct proc *curproc = myproc(); +80106c4a: e8 61 e2 ff ff call 80104eb0 + for (fd = 0; fd < NOFILE; fd++) { +80106c4f: 31 d2 xor %edx,%edx +80106c51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (curproc->ofile[fd] == 0) { +80106c58: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx +80106c5c: 85 c9 test %ecx,%ecx +80106c5e: 74 20 je 80106c80 + for (fd = 0; fd < NOFILE; fd++) { +80106c60: 83 c2 01 add $0x1,%edx +80106c63: 83 fa 10 cmp $0x10,%edx +80106c66: 75 f0 jne 80106c58 + myproc()->ofile[fd0] = 0; +80106c68: e8 43 e2 ff ff call 80104eb0 +80106c6d: c7 44 b0 08 00 00 00 movl $0x0,0x8(%eax,%esi,4) +80106c74: 00 +80106c75: eb a9 jmp 80106c20 +80106c77: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106c7e: 66 90 xchg %ax,%ax + curproc->ofile[fd] = f; +80106c80: 89 7c 90 28 mov %edi,0x28(%eax,%edx,4) + } + fd[0] = fd0; +80106c84: 8b 45 dc mov -0x24(%ebp),%eax +80106c87: 89 18 mov %ebx,(%eax) + fd[1] = fd1; +80106c89: 8b 45 dc mov -0x24(%ebp),%eax +80106c8c: 89 50 04 mov %edx,0x4(%eax) + return 0; +80106c8f: 31 c0 xor %eax,%eax +} +80106c91: 8d 65 f4 lea -0xc(%ebp),%esp +80106c94: 5b pop %ebx +80106c95: 5e pop %esi +80106c96: 5f pop %edi +80106c97: 5d pop %ebp +80106c98: c3 ret +80106c99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80106ca0 : + +int sys_getch(void) { + return consoleget(); +80106ca0: e9 0b a3 ff ff jmp 80100fb0 +80106ca5: 66 90 xchg %ax,%ax +80106ca7: 66 90 xchg %ax,%ax +80106ca9: 66 90 xchg %ax,%ax +80106cab: 66 90 xchg %ax,%ax +80106cad: 66 90 xchg %ax,%ax +80106caf: 90 nop + +80106cb0 : +#include "mmu.h" +#include "proc.h" + +int sys_fork(void) +{ + return fork(); +80106cb0: e9 bb e3 ff ff jmp 80105070 +80106cb5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106cbc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106cc0 : +} + +int sys_exit(void) +{ +80106cc0: 55 push %ebp +80106cc1: 89 e5 mov %esp,%ebp +80106cc3: 83 ec 08 sub $0x8,%esp + exit(); +80106cc6: e8 25 e6 ff ff call 801052f0 + return 0; // not reached +} +80106ccb: 31 c0 xor %eax,%eax +80106ccd: c9 leave +80106cce: c3 ret +80106ccf: 90 nop + +80106cd0 : + +int sys_wait(void) +{ + return wait(); +80106cd0: e9 7b e7 ff ff jmp 80105450 +80106cd5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106cdc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106ce0 : +} + +int sys_kill(void) +{ +80106ce0: 55 push %ebp +80106ce1: 89 e5 mov %esp,%ebp +80106ce3: 83 ec 20 sub $0x20,%esp + int pid; + + if (argint(0, &pid) < 0) +80106ce6: 8d 45 f4 lea -0xc(%ebp),%eax +80106ce9: 50 push %eax +80106cea: 6a 00 push $0x0 +80106cec: e8 0f f2 ff ff call 80105f00 +80106cf1: 83 c4 10 add $0x10,%esp +80106cf4: 85 c0 test %eax,%eax +80106cf6: 78 18 js 80106d10 + { + return -1; + } + return kill(pid); +80106cf8: 83 ec 0c sub $0xc,%esp +80106cfb: ff 75 f4 push -0xc(%ebp) +80106cfe: e8 fd e9 ff ff call 80105700 +80106d03: 83 c4 10 add $0x10,%esp +} +80106d06: c9 leave +80106d07: c3 ret +80106d08: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106d0f: 90 nop +80106d10: c9 leave + return -1; +80106d11: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106d16: c3 ret +80106d17: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106d1e: 66 90 xchg %ax,%ax + +80106d20 : + +int sys_getpid(void) +{ +80106d20: 55 push %ebp +80106d21: 89 e5 mov %esp,%ebp +80106d23: 83 ec 08 sub $0x8,%esp + return myproc()->pid; +80106d26: e8 85 e1 ff ff call 80104eb0 +80106d2b: 8b 40 10 mov 0x10(%eax),%eax +} +80106d2e: c9 leave +80106d2f: c3 ret + +80106d30 : + +int sys_sbrk(void) +{ +80106d30: 55 push %ebp +80106d31: 89 e5 mov %esp,%ebp +80106d33: 53 push %ebx + int addr; + int n; + + if (argint(0, &n) < 0) +80106d34: 8d 45 f4 lea -0xc(%ebp),%eax +{ +80106d37: 83 ec 1c sub $0x1c,%esp + if (argint(0, &n) < 0) +80106d3a: 50 push %eax +80106d3b: 6a 00 push $0x0 +80106d3d: e8 be f1 ff ff call 80105f00 +80106d42: 83 c4 10 add $0x10,%esp +80106d45: 85 c0 test %eax,%eax +80106d47: 78 27 js 80106d70 + { + return -1; + } + addr = myproc()->sz; +80106d49: e8 62 e1 ff ff call 80104eb0 + if (growproc(n) < 0) +80106d4e: 83 ec 0c sub $0xc,%esp + addr = myproc()->sz; +80106d51: 8b 18 mov (%eax),%ebx + if (growproc(n) < 0) +80106d53: ff 75 f4 push -0xc(%ebp) +80106d56: e8 95 e2 ff ff call 80104ff0 +80106d5b: 83 c4 10 add $0x10,%esp +80106d5e: 85 c0 test %eax,%eax +80106d60: 78 0e js 80106d70 + { + return -1; + } + return addr; +} +80106d62: 89 d8 mov %ebx,%eax +80106d64: 8b 5d fc mov -0x4(%ebp),%ebx +80106d67: c9 leave +80106d68: c3 ret +80106d69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80106d70: bb ff ff ff ff mov $0xffffffff,%ebx +80106d75: eb eb jmp 80106d62 +80106d77: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106d7e: 66 90 xchg %ax,%ax + +80106d80 : + +int sys_sleep(void) +{ +80106d80: 55 push %ebp +80106d81: 89 e5 mov %esp,%ebp +80106d83: 53 push %ebx + int n; + uint ticks0; + + if (argint(0, &n) < 0) +80106d84: 8d 45 f4 lea -0xc(%ebp),%eax +{ +80106d87: 83 ec 1c sub $0x1c,%esp + if (argint(0, &n) < 0) +80106d8a: 50 push %eax +80106d8b: 6a 00 push $0x0 +80106d8d: e8 6e f1 ff ff call 80105f00 +80106d92: 83 c4 10 add $0x10,%esp +80106d95: 85 c0 test %eax,%eax +80106d97: 0f 88 8a 00 00 00 js 80106e27 + { + return -1; + } + acquire(&tickslock); +80106d9d: 83 ec 0c sub $0xc,%esp +80106da0: 68 00 0a 12 80 push $0x80120a00 +80106da5: e8 d6 ed ff ff call 80105b80 + ticks0 = ticks; + while (ticks - ticks0 < n) +80106daa: 8b 55 f4 mov -0xc(%ebp),%edx + ticks0 = ticks; +80106dad: 8b 1d e0 09 12 80 mov 0x801209e0,%ebx + while (ticks - ticks0 < n) +80106db3: 83 c4 10 add $0x10,%esp +80106db6: 85 d2 test %edx,%edx +80106db8: 75 27 jne 80106de1 +80106dba: eb 54 jmp 80106e10 +80106dbc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (myproc()->killed) + { + release(&tickslock); + return -1; + } + sleep(&ticks, &tickslock); +80106dc0: 83 ec 08 sub $0x8,%esp +80106dc3: 68 00 0a 12 80 push $0x80120a00 +80106dc8: 68 e0 09 12 80 push $0x801209e0 +80106dcd: e8 0e e8 ff ff call 801055e0 + while (ticks - ticks0 < n) +80106dd2: a1 e0 09 12 80 mov 0x801209e0,%eax +80106dd7: 83 c4 10 add $0x10,%esp +80106dda: 29 d8 sub %ebx,%eax +80106ddc: 3b 45 f4 cmp -0xc(%ebp),%eax +80106ddf: 73 2f jae 80106e10 + if (myproc()->killed) +80106de1: e8 ca e0 ff ff call 80104eb0 +80106de6: 8b 40 24 mov 0x24(%eax),%eax +80106de9: 85 c0 test %eax,%eax +80106deb: 74 d3 je 80106dc0 + release(&tickslock); +80106ded: 83 ec 0c sub $0xc,%esp +80106df0: 68 00 0a 12 80 push $0x80120a00 +80106df5: e8 26 ed ff ff call 80105b20 + } + release(&tickslock); + return 0; +} +80106dfa: 8b 5d fc mov -0x4(%ebp),%ebx + return -1; +80106dfd: 83 c4 10 add $0x10,%esp +80106e00: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106e05: c9 leave +80106e06: c3 ret +80106e07: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106e0e: 66 90 xchg %ax,%ax + release(&tickslock); +80106e10: 83 ec 0c sub $0xc,%esp +80106e13: 68 00 0a 12 80 push $0x80120a00 +80106e18: e8 03 ed ff ff call 80105b20 + return 0; +80106e1d: 83 c4 10 add $0x10,%esp +80106e20: 31 c0 xor %eax,%eax +} +80106e22: 8b 5d fc mov -0x4(%ebp),%ebx +80106e25: c9 leave +80106e26: c3 ret + return -1; +80106e27: b8 ff ff ff ff mov $0xffffffff,%eax +80106e2c: eb f4 jmp 80106e22 +80106e2e: 66 90 xchg %ax,%ax + +80106e30 : + +// return how many clock tick interrupts have occurred +// since start. +int sys_uptime(void) +{ +80106e30: 55 push %ebp +80106e31: 89 e5 mov %esp,%ebp +80106e33: 53 push %ebx +80106e34: 83 ec 10 sub $0x10,%esp + uint xticks; + + acquire(&tickslock); +80106e37: 68 00 0a 12 80 push $0x80120a00 +80106e3c: e8 3f ed ff ff call 80105b80 + xticks = ticks; +80106e41: 8b 1d e0 09 12 80 mov 0x801209e0,%ebx + release(&tickslock); +80106e47: c7 04 24 00 0a 12 80 movl $0x80120a00,(%esp) +80106e4e: e8 cd ec ff ff call 80105b20 + return xticks; +} +80106e53: 89 d8 mov %ebx,%eax +80106e55: 8b 5d fc mov -0x4(%ebp),%ebx +80106e58: c9 leave +80106e59: c3 ret +80106e5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80106e60 : + +// System call i used to debug and test the consoles, it returns useful information in relation to the current console/process +int sys_greeting(void) +{ +80106e60: 55 push %ebp +80106e61: 89 e5 mov %esp,%ebp +80106e63: 83 ec 14 sub $0x14,%esp + cprintf("Hello! here is the info you requested...\n"); +80106e66: 68 30 92 10 80 push $0x80109230 +80106e6b: e8 20 9a ff ff call 80100890 + cprintf("Using Console: %d\n", getcurrentconsoleindex()); +80106e70: e8 6b af ff ff call 80101de0 +80106e75: 5a pop %edx +80106e76: 59 pop %ecx +80106e77: 50 push %eax +80106e78: 68 84 92 10 80 push $0x80109284 +80106e7d: e8 0e 9a ff ff call 80100890 + cprintf("Current PID: %d\n", myproc()->pid); +80106e82: e8 29 e0 ff ff call 80104eb0 +80106e87: 5a pop %edx +80106e88: 59 pop %ecx +80106e89: ff 70 10 push 0x10(%eax) +80106e8c: 68 97 92 10 80 push $0x80109297 +80106e91: e8 fa 99 ff ff call 80100890 + cprintf("Current Parent PID: %d\n", myproc()->parent->pid); +80106e96: e8 15 e0 ff ff call 80104eb0 +80106e9b: 5a pop %edx +80106e9c: 59 pop %ecx +80106e9d: 8b 40 14 mov 0x14(%eax),%eax +80106ea0: ff 70 10 push 0x10(%eax) +80106ea3: 68 a8 92 10 80 push $0x801092a8 +80106ea8: e8 e3 99 ff ff call 80100890 + cprintf("Process Console: %d\n", getconsoleindex(myproc()->consoleptr)); +80106ead: e8 fe df ff ff call 80104eb0 +80106eb2: 5a pop %edx +80106eb3: ff 70 7c push 0x7c(%eax) +80106eb6: e8 b5 95 ff ff call 80100470 +80106ebb: 59 pop %ecx +80106ebc: 5a pop %edx +80106ebd: 50 push %eax +80106ebe: 68 c0 92 10 80 push $0x801092c0 +80106ec3: e8 c8 99 ff ff call 80100890 + return 0; +} +80106ec8: 31 c0 xor %eax,%eax +80106eca: c9 leave +80106ecb: c3 ret +80106ecc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106ed0 : + +// System call to shutdown or restart the OS +int sys_shutdown(void) +{ +80106ed0: 55 push %ebp +80106ed1: 89 e5 mov %esp,%ebp +80106ed3: 83 ec 20 sub $0x20,%esp + int restart; + if (argint(0, &restart) < 0) +80106ed6: 8d 45 f4 lea -0xc(%ebp),%eax +80106ed9: 50 push %eax +80106eda: 6a 00 push $0x0 +80106edc: e8 1f f0 ff ff call 80105f00 +80106ee1: 83 c4 10 add $0x10,%esp +80106ee4: 85 c0 test %eax,%eax +80106ee6: 78 2f js 80106f17 + { + return -1; + } + + if (restart == 1) +80106ee8: 83 7d f4 01 cmpl $0x1,-0xc(%ebp) +80106eec: 74 12 je 80106f00 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80106eee: b8 00 20 00 00 mov $0x2000,%eax +80106ef3: ba 04 06 00 00 mov $0x604,%edx +80106ef8: 66 ef out %ax,(%dx) + else + { + outw(0x604, 0x2000); + } + return 0; +} +80106efa: c9 leave + return 0; +80106efb: 31 c0 xor %eax,%eax +} +80106efd: c3 ret +80106efe: 66 90 xchg %ax,%ax + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80106f00: ba 64 00 00 00 mov $0x64,%edx +80106f05: 8d 76 00 lea 0x0(%esi),%esi +80106f08: ec in (%dx),%al + while (good & 0x02) { +80106f09: a8 02 test $0x2,%al +80106f0b: 75 fb jne 80106f08 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80106f0d: b8 fe ff ff ff mov $0xfffffffe,%eax +80106f12: ee out %al,(%dx) +} +80106f13: c9 leave + return 0; +80106f14: 31 c0 xor %eax,%eax +} +80106f16: c3 ret +80106f17: c9 leave + return -1; +80106f18: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106f1d: c3 ret +80106f1e: 66 90 xchg %ax,%ax + +80106f20 : + +// System call for handling the new screen user app +int sys_screen(void) +{ +80106f20: 55 push %ebp +80106f21: 89 e5 mov %esp,%ebp +80106f23: 53 push %ebx +80106f24: 83 ec 14 sub $0x14,%esp + struct proc *curproc = myproc(); +80106f27: e8 84 df ff ff call 80104eb0 + struct vconsole* consoleptr = 0; + int bgcol; + char *title; + + // Get the background color value + if (argint(1, &bgcol) < 0) +80106f2c: 83 ec 08 sub $0x8,%esp + struct proc *curproc = myproc(); +80106f2f: 89 c3 mov %eax,%ebx + if (argint(1, &bgcol) < 0) +80106f31: 8d 45 f0 lea -0x10(%ebp),%eax +80106f34: 50 push %eax +80106f35: 6a 01 push $0x1 +80106f37: e8 c4 ef ff ff call 80105f00 +80106f3c: 83 c4 10 add $0x10,%esp +80106f3f: 85 c0 test %eax,%eax +80106f41: 78 4d js 80106f90 + { + return -1; + } + + // Get the title arg value + if (argstr(0, &title) < 0) +80106f43: 83 ec 08 sub $0x8,%esp +80106f46: 8d 45 f4 lea -0xc(%ebp),%eax +80106f49: 50 push %eax +80106f4a: 6a 00 push $0x0 +80106f4c: e8 6f f0 ff ff call 80105fc0 +80106f51: 83 c4 10 add $0x10,%esp +80106f54: 85 c0 test %eax,%eax +80106f56: 78 38 js 80106f90 + { + return -1; + } + + // Try to setup an unused console from the pool + if ((consoleptr = newconsole(title, bgcol)) != 0) +80106f58: 83 ec 08 sub $0x8,%esp +80106f5b: ff 75 f0 push -0x10(%ebp) +80106f5e: ff 75 f4 push -0xc(%ebp) +80106f61: e8 8a a3 ff ff call 801012f0 +80106f66: 83 c4 10 add $0x10,%esp +80106f69: 85 c0 test %eax,%eax +80106f6b: 74 33 je 80106fa0 + { + // New console was successful, set the pointer and switch to it + curproc->consoleptr = consoleptr; + switchtoconsole(consoleptr); +80106f6d: 83 ec 0c sub $0xc,%esp + curproc->consoleptr = consoleptr; +80106f70: 89 43 7c mov %eax,0x7c(%ebx) + switchtoconsole(consoleptr); +80106f73: 50 push %eax +80106f74: e8 67 a4 ff ff call 801013e0 + else + { + cprintf("screen: failed to create a new console\n"); + } + return result; +} +80106f79: 8b 5d fc mov -0x4(%ebp),%ebx +80106f7c: 83 c4 10 add $0x10,%esp + result = 1; +80106f7f: b8 01 00 00 00 mov $0x1,%eax +} +80106f84: c9 leave +80106f85: c3 ret +80106f86: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106f8d: 8d 76 00 lea 0x0(%esi),%esi +80106f90: 8b 5d fc mov -0x4(%ebp),%ebx + return -1; +80106f93: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106f98: c9 leave +80106f99: c3 ret +80106f9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + cprintf("screen: failed to create a new console\n"); +80106fa0: 83 ec 0c sub $0xc,%esp +80106fa3: 68 5c 92 10 80 push $0x8010925c +80106fa8: e8 e3 98 ff ff call 80100890 +} +80106fad: 8b 5d fc mov -0x4(%ebp),%ebx + cprintf("screen: failed to create a new console\n"); +80106fb0: 83 c4 10 add $0x10,%esp + int result = 0; +80106fb3: 31 c0 xor %eax,%eax +} +80106fb5: c9 leave +80106fb6: c3 ret +80106fb7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106fbe: 66 90 xchg %ax,%ax + +80106fc0 : + +// System call to clear the screen +int sys_cls(void) +{ +80106fc0: 55 push %ebp +80106fc1: 89 e5 mov %esp,%ebp +80106fc3: 83 ec 14 sub $0x14,%esp + clearscreen(0); +80106fc6: 6a 00 push $0x0 +80106fc8: e8 f3 a0 ff ff call 801010c0 + return 0; +80106fcd: 31 c0 xor %eax,%eax +80106fcf: c9 leave +80106fd0: c3 ret + +80106fd1 : + + # vectors.S sends all traps here. +.globl alltraps +alltraps: + # Build trap frame. + pushl %ds +80106fd1: 1e push %ds + pushl %es +80106fd2: 06 push %es + pushl %fs +80106fd3: 0f a0 push %fs + pushl %gs +80106fd5: 0f a8 push %gs + pushal +80106fd7: 60 pusha + + # Set up data segments. + movw $(SEG_KDATA<<3), %ax +80106fd8: 66 b8 10 00 mov $0x10,%ax + movw %ax, %ds +80106fdc: 8e d8 mov %eax,%ds + movw %ax, %es +80106fde: 8e c0 mov %eax,%es + + # Call trap(tf), where tf=%esp + pushl %esp +80106fe0: 54 push %esp + call trap +80106fe1: e8 ca 00 00 00 call 801070b0 + addl $4, %esp +80106fe6: 83 c4 04 add $0x4,%esp + +80106fe9 : + + # Return falls through to trapret... +.globl trapret +trapret: + popal +80106fe9: 61 popa + popl %gs +80106fea: 0f a9 pop %gs + popl %fs +80106fec: 0f a1 pop %fs + popl %es +80106fee: 07 pop %es + popl %ds +80106fef: 1f pop %ds + addl $0x8, %esp # trapno and errcode +80106ff0: 83 c4 08 add $0x8,%esp + iret +80106ff3: cf iret +80106ff4: 66 90 xchg %ax,%ax +80106ff6: 66 90 xchg %ax,%ax +80106ff8: 66 90 xchg %ax,%ax +80106ffa: 66 90 xchg %ax,%ax +80106ffc: 66 90 xchg %ax,%ax +80106ffe: 66 90 xchg %ax,%ax + +80107000 : +struct gatedesc idt[256]; +extern uint vectors[]; // in vectors.S: array of 256 entry pointers +struct spinlock tickslock; +uint ticks; + +void tvinit(void) { +80107000: 55 push %ebp + int i; + + for (i = 0; i < 256; i++) { +80107001: 31 c0 xor %eax,%eax +void tvinit(void) { +80107003: 89 e5 mov %esp,%ebp +80107005: 83 ec 08 sub $0x8,%esp +80107008: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010700f: 90 nop + SETGATE(idt[i], 0, SEG_KCODE << 3, vectors[i], 0); +80107010: 8b 14 85 08 c0 10 80 mov -0x7fef3ff8(,%eax,4),%edx +80107017: c7 04 c5 42 0a 12 80 movl $0x8e000008,-0x7fedf5be(,%eax,8) +8010701e: 08 00 00 8e +80107022: 66 89 14 c5 40 0a 12 mov %dx,-0x7fedf5c0(,%eax,8) +80107029: 80 +8010702a: c1 ea 10 shr $0x10,%edx +8010702d: 66 89 14 c5 46 0a 12 mov %dx,-0x7fedf5ba(,%eax,8) +80107034: 80 + for (i = 0; i < 256; i++) { +80107035: 83 c0 01 add $0x1,%eax +80107038: 3d 00 01 00 00 cmp $0x100,%eax +8010703d: 75 d1 jne 80107010 + } + SETGATE(idt[T_SYSCALL], 1, SEG_KCODE << 3, vectors[T_SYSCALL], DPL_USER); + + initlock(&tickslock, "time"); +8010703f: 83 ec 08 sub $0x8,%esp + SETGATE(idt[T_SYSCALL], 1, SEG_KCODE << 3, vectors[T_SYSCALL], DPL_USER); +80107042: a1 08 c1 10 80 mov 0x8010c108,%eax +80107047: c7 05 42 0c 12 80 08 movl $0xef000008,0x80120c42 +8010704e: 00 00 ef + initlock(&tickslock, "time"); +80107051: 68 d5 92 10 80 push $0x801092d5 +80107056: 68 00 0a 12 80 push $0x80120a00 + SETGATE(idt[T_SYSCALL], 1, SEG_KCODE << 3, vectors[T_SYSCALL], DPL_USER); +8010705b: 66 a3 40 0c 12 80 mov %ax,0x80120c40 +80107061: c1 e8 10 shr $0x10,%eax +80107064: 66 a3 46 0c 12 80 mov %ax,0x80120c46 + initlock(&tickslock, "time"); +8010706a: e8 41 e9 ff ff call 801059b0 +} +8010706f: 83 c4 10 add $0x10,%esp +80107072: c9 leave +80107073: c3 ret +80107074: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010707b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010707f: 90 nop + +80107080 : + +void idtinit(void) { +80107080: 55 push %ebp + pd[0] = size - 1; +80107081: b8 ff 07 00 00 mov $0x7ff,%eax +80107086: 89 e5 mov %esp,%ebp +80107088: 83 ec 10 sub $0x10,%esp +8010708b: 66 89 45 fa mov %ax,-0x6(%ebp) + pd[1] = (uint)p; +8010708f: b8 40 0a 12 80 mov $0x80120a40,%eax +80107094: 66 89 45 fc mov %ax,-0x4(%ebp) + pd[2] = (uint)p >> 16; +80107098: c1 e8 10 shr $0x10,%eax +8010709b: 66 89 45 fe mov %ax,-0x2(%ebp) + asm volatile ("lidt (%0)" : : "r" (pd)); +8010709f: 8d 45 fa lea -0x6(%ebp),%eax +801070a2: 0f 01 18 lidtl (%eax) + lidt(idt, sizeof(idt)); +} +801070a5: c9 leave +801070a6: c3 ret +801070a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801070ae: 66 90 xchg %ax,%ax + +801070b0 : + +void trap(struct trapframe *tf) { +801070b0: 55 push %ebp +801070b1: 89 e5 mov %esp,%ebp +801070b3: 57 push %edi +801070b4: 56 push %esi +801070b5: 53 push %ebx +801070b6: 83 ec 1c sub $0x1c,%esp +801070b9: 8b 5d 08 mov 0x8(%ebp),%ebx + if (tf->trapno == T_SYSCALL) { +801070bc: 8b 43 30 mov 0x30(%ebx),%eax +801070bf: 83 f8 40 cmp $0x40,%eax +801070c2: 0f 84 68 01 00 00 je 80107230 + exit(); + } + return; + } + + switch (tf->trapno) { +801070c8: 83 e8 20 sub $0x20,%eax +801070cb: 83 f8 1f cmp $0x1f,%eax +801070ce: 0f 87 8c 00 00 00 ja 80107160 +801070d4: ff 24 85 7c 93 10 80 jmp *-0x7fef6c84(,%eax,4) +801070db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801070df: 90 nop + release(&tickslock); + } + lapiceoi(); + break; + case T_IRQ0 + IRQ_IDE: + ideintr(); +801070e0: e8 4b c6 ff ff call 80103730 + lapiceoi(); +801070e5: e8 16 cd ff ff call 80103e00 + } + + // Force process exit if it has been killed and is in user space. + // (If it is still executing in the kernel, let it keep running + // until it gets to the regular system call return.) + if (myproc() && myproc()->killed && (tf->cs & 3) == DPL_USER) { +801070ea: e8 c1 dd ff ff call 80104eb0 +801070ef: 85 c0 test %eax,%eax +801070f1: 74 1d je 80107110 +801070f3: e8 b8 dd ff ff call 80104eb0 +801070f8: 8b 50 24 mov 0x24(%eax),%edx +801070fb: 85 d2 test %edx,%edx +801070fd: 74 11 je 80107110 +801070ff: 0f b7 43 3c movzwl 0x3c(%ebx),%eax +80107103: 83 e0 03 and $0x3,%eax +80107106: 66 83 f8 03 cmp $0x3,%ax +8010710a: 0f 84 e8 01 00 00 je 801072f8 + exit(); + } + + // Force process to give up CPU on clock tick. + // If interrupts were on while locks held, would need to check nlock. + if (myproc() && myproc()->state == RUNNING && +80107110: e8 9b dd ff ff call 80104eb0 +80107115: 85 c0 test %eax,%eax +80107117: 74 0f je 80107128 +80107119: e8 92 dd ff ff call 80104eb0 +8010711e: 83 78 0c 04 cmpl $0x4,0xc(%eax) +80107122: 0f 84 b8 00 00 00 je 801071e0 + tf->trapno == T_IRQ0 + IRQ_TIMER) { + yield(); + } + + // Check if the process has been killed since we yielded + if (myproc() && myproc()->killed && (tf->cs & 3) == DPL_USER) { +80107128: e8 83 dd ff ff call 80104eb0 +8010712d: 85 c0 test %eax,%eax +8010712f: 74 1d je 8010714e +80107131: e8 7a dd ff ff call 80104eb0 +80107136: 8b 40 24 mov 0x24(%eax),%eax +80107139: 85 c0 test %eax,%eax +8010713b: 74 11 je 8010714e +8010713d: 0f b7 43 3c movzwl 0x3c(%ebx),%eax +80107141: 83 e0 03 and $0x3,%eax +80107144: 66 83 f8 03 cmp $0x3,%ax +80107148: 0f 84 0f 01 00 00 je 8010725d + exit(); + } +} +8010714e: 8d 65 f4 lea -0xc(%ebp),%esp +80107151: 5b pop %ebx +80107152: 5e pop %esi +80107153: 5f pop %edi +80107154: 5d pop %ebp +80107155: c3 ret +80107156: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010715d: 8d 76 00 lea 0x0(%esi),%esi + if (myproc() == 0 || (tf->cs & 3) == 0) { +80107160: e8 4b dd ff ff call 80104eb0 +80107165: 8b 7b 38 mov 0x38(%ebx),%edi +80107168: 85 c0 test %eax,%eax +8010716a: 0f 84 a2 01 00 00 je 80107312 +80107170: f6 43 3c 03 testb $0x3,0x3c(%ebx) +80107174: 0f 84 98 01 00 00 je 80107312 + return result; +} + +static inline uint rcr2(void) { + uint val; + asm volatile ("movl %%cr2,%0" : "=r" (val)); +8010717a: 0f 20 d1 mov %cr2,%ecx +8010717d: 89 4d d8 mov %ecx,-0x28(%ebp) + cprintf("pid %d %s: trap %d err %d on cpu %d " +80107180: e8 0b dd ff ff call 80104e90 +80107185: 8b 73 30 mov 0x30(%ebx),%esi +80107188: 89 45 dc mov %eax,-0x24(%ebp) +8010718b: 8b 43 34 mov 0x34(%ebx),%eax +8010718e: 89 45 e4 mov %eax,-0x1c(%ebp) + myproc()->pid, myproc()->name, tf->trapno, +80107191: e8 1a dd ff ff call 80104eb0 +80107196: 89 45 e0 mov %eax,-0x20(%ebp) +80107199: e8 12 dd ff ff call 80104eb0 + cprintf("pid %d %s: trap %d err %d on cpu %d " +8010719e: 8b 4d d8 mov -0x28(%ebp),%ecx +801071a1: 8b 55 dc mov -0x24(%ebp),%edx +801071a4: 51 push %ecx +801071a5: 57 push %edi +801071a6: 52 push %edx +801071a7: ff 75 e4 push -0x1c(%ebp) +801071aa: 56 push %esi + myproc()->pid, myproc()->name, tf->trapno, +801071ab: 8b 75 e0 mov -0x20(%ebp),%esi +801071ae: 83 c6 6c add $0x6c,%esi + cprintf("pid %d %s: trap %d err %d on cpu %d " +801071b1: 56 push %esi +801071b2: ff 70 10 push 0x10(%eax) +801071b5: 68 38 93 10 80 push $0x80109338 +801071ba: e8 d1 96 ff ff call 80100890 + myproc()->killed = 1; +801071bf: 83 c4 20 add $0x20,%esp +801071c2: e8 e9 dc ff ff call 80104eb0 +801071c7: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) + if (myproc() && myproc()->killed && (tf->cs & 3) == DPL_USER) { +801071ce: e8 dd dc ff ff call 80104eb0 +801071d3: 85 c0 test %eax,%eax +801071d5: 0f 85 18 ff ff ff jne 801070f3 +801071db: e9 30 ff ff ff jmp 80107110 + if (myproc() && myproc()->state == RUNNING && +801071e0: 83 7b 30 20 cmpl $0x20,0x30(%ebx) +801071e4: 0f 85 3e ff ff ff jne 80107128 + yield(); +801071ea: e8 a1 e3 ff ff call 80105590 +801071ef: e9 34 ff ff ff jmp 80107128 +801071f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + cprintf("cpu%d: spurious interrupt at %x:%x\n", +801071f8: 8b 7b 38 mov 0x38(%ebx),%edi +801071fb: 0f b7 73 3c movzwl 0x3c(%ebx),%esi +801071ff: e8 8c dc ff ff call 80104e90 +80107204: 57 push %edi +80107205: 56 push %esi +80107206: 50 push %eax +80107207: 68 e0 92 10 80 push $0x801092e0 +8010720c: e8 7f 96 ff ff call 80100890 + lapiceoi(); +80107211: e8 ea cb ff ff call 80103e00 + break; +80107216: 83 c4 10 add $0x10,%esp + if (myproc() && myproc()->killed && (tf->cs & 3) == DPL_USER) { +80107219: e8 92 dc ff ff call 80104eb0 +8010721e: 85 c0 test %eax,%eax +80107220: 0f 85 cd fe ff ff jne 801070f3 +80107226: e9 e5 fe ff ff jmp 80107110 +8010722b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010722f: 90 nop + if (myproc()->killed) { +80107230: e8 7b dc ff ff call 80104eb0 +80107235: 8b 70 24 mov 0x24(%eax),%esi +80107238: 85 f6 test %esi,%esi +8010723a: 0f 85 c8 00 00 00 jne 80107308 + myproc()->tf = tf; +80107240: e8 6b dc ff ff call 80104eb0 +80107245: 89 58 18 mov %ebx,0x18(%eax) + syscall(); +80107248: e8 f3 ed ff ff call 80106040 + if (myproc()->killed) { +8010724d: e8 5e dc ff ff call 80104eb0 +80107252: 8b 48 24 mov 0x24(%eax),%ecx +80107255: 85 c9 test %ecx,%ecx +80107257: 0f 84 f1 fe ff ff je 8010714e +} +8010725d: 8d 65 f4 lea -0xc(%ebp),%esp +80107260: 5b pop %ebx +80107261: 5e pop %esi +80107262: 5f pop %edi +80107263: 5d pop %ebp + exit(); +80107264: e9 87 e0 ff ff jmp 801052f0 +80107269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + uartintr(); +80107270: e8 3b 02 00 00 call 801074b0 + lapiceoi(); +80107275: e8 86 cb ff ff call 80103e00 + if (myproc() && myproc()->killed && (tf->cs & 3) == DPL_USER) { +8010727a: e8 31 dc ff ff call 80104eb0 +8010727f: 85 c0 test %eax,%eax +80107281: 0f 85 6c fe ff ff jne 801070f3 +80107287: e9 84 fe ff ff jmp 80107110 +8010728c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + kbdintr(); +80107290: e8 2b ca ff ff call 80103cc0 + lapiceoi(); +80107295: e8 66 cb ff ff call 80103e00 + if (myproc() && myproc()->killed && (tf->cs & 3) == DPL_USER) { +8010729a: e8 11 dc ff ff call 80104eb0 +8010729f: 85 c0 test %eax,%eax +801072a1: 0f 85 4c fe ff ff jne 801070f3 +801072a7: e9 64 fe ff ff jmp 80107110 +801072ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (cpuid() == 0) { +801072b0: e8 db db ff ff call 80104e90 +801072b5: 85 c0 test %eax,%eax +801072b7: 0f 85 28 fe ff ff jne 801070e5 + acquire(&tickslock); +801072bd: 83 ec 0c sub $0xc,%esp +801072c0: 68 00 0a 12 80 push $0x80120a00 +801072c5: e8 b6 e8 ff ff call 80105b80 + wakeup(&ticks); +801072ca: c7 04 24 e0 09 12 80 movl $0x801209e0,(%esp) + ticks++; +801072d1: 83 05 e0 09 12 80 01 addl $0x1,0x801209e0 + wakeup(&ticks); +801072d8: e8 c3 e3 ff ff call 801056a0 + release(&tickslock); +801072dd: c7 04 24 00 0a 12 80 movl $0x80120a00,(%esp) +801072e4: e8 37 e8 ff ff call 80105b20 +801072e9: 83 c4 10 add $0x10,%esp + lapiceoi(); +801072ec: e9 f4 fd ff ff jmp 801070e5 +801072f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + exit(); +801072f8: e8 f3 df ff ff call 801052f0 +801072fd: e9 0e fe ff ff jmp 80107110 +80107302: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + exit(); +80107308: e8 e3 df ff ff call 801052f0 +8010730d: e9 2e ff ff ff jmp 80107240 +80107312: 0f 20 d6 mov %cr2,%esi + cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", +80107315: e8 76 db ff ff call 80104e90 +8010731a: 83 ec 0c sub $0xc,%esp +8010731d: 56 push %esi +8010731e: 57 push %edi +8010731f: 50 push %eax +80107320: ff 73 30 push 0x30(%ebx) +80107323: 68 04 93 10 80 push $0x80109304 +80107328: e8 63 95 ff ff call 80100890 + panic("trap"); +8010732d: 83 c4 14 add $0x14,%esp +80107330: 68 da 92 10 80 push $0x801092da +80107335: e8 46 91 ff ff call 80100480 +8010733a: 66 90 xchg %ax,%ax +8010733c: 66 90 xchg %ax,%ax +8010733e: 66 90 xchg %ax,%ax + +80107340 : + } + outb(COM1 + 0, c); +} + +static int uartgetc(void) { + if (!uart) { +80107340: a1 40 12 12 80 mov 0x80121240,%eax +80107345: 85 c0 test %eax,%eax +80107347: 74 17 je 80107360 + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +80107349: ba fd 03 00 00 mov $0x3fd,%edx +8010734e: ec in (%dx),%al + return -1; + } + if (!(inb(COM1 + 5) & 0x01)) { +8010734f: a8 01 test $0x1,%al +80107351: 74 0d je 80107360 +80107353: ba f8 03 00 00 mov $0x3f8,%edx +80107358: ec in (%dx),%al + return -1; + } + return inb(COM1 + 0); +80107359: 0f b6 c0 movzbl %al,%eax +8010735c: c3 ret +8010735d: 8d 76 00 lea 0x0(%esi),%esi + return -1; +80107360: b8 ff ff ff ff mov $0xffffffff,%eax +} +80107365: c3 ret +80107366: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010736d: 8d 76 00 lea 0x0(%esi),%esi + +80107370 : +void uartinit(void) { +80107370: 55 push %ebp + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80107371: 31 c9 xor %ecx,%ecx +80107373: 89 c8 mov %ecx,%eax +80107375: 89 e5 mov %esp,%ebp +80107377: 57 push %edi +80107378: bf fa 03 00 00 mov $0x3fa,%edi +8010737d: 56 push %esi +8010737e: 89 fa mov %edi,%edx +80107380: 53 push %ebx +80107381: 83 ec 1c sub $0x1c,%esp +80107384: ee out %al,(%dx) +80107385: be fb 03 00 00 mov $0x3fb,%esi +8010738a: b8 80 ff ff ff mov $0xffffff80,%eax +8010738f: 89 f2 mov %esi,%edx +80107391: ee out %al,(%dx) +80107392: b8 0c 00 00 00 mov $0xc,%eax +80107397: ba f8 03 00 00 mov $0x3f8,%edx +8010739c: ee out %al,(%dx) +8010739d: bb f9 03 00 00 mov $0x3f9,%ebx +801073a2: 89 c8 mov %ecx,%eax +801073a4: 89 da mov %ebx,%edx +801073a6: ee out %al,(%dx) +801073a7: b8 03 00 00 00 mov $0x3,%eax +801073ac: 89 f2 mov %esi,%edx +801073ae: ee out %al,(%dx) +801073af: ba fc 03 00 00 mov $0x3fc,%edx +801073b4: 89 c8 mov %ecx,%eax +801073b6: ee out %al,(%dx) +801073b7: b8 01 00 00 00 mov $0x1,%eax +801073bc: 89 da mov %ebx,%edx +801073be: ee out %al,(%dx) + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +801073bf: ba fd 03 00 00 mov $0x3fd,%edx +801073c4: ec in (%dx),%al + if (inb(COM1 + 5) == 0xFF) { +801073c5: 3c ff cmp $0xff,%al +801073c7: 74 78 je 80107441 + uart = 1; +801073c9: c7 05 40 12 12 80 01 movl $0x1,0x80121240 +801073d0: 00 00 00 +801073d3: 89 fa mov %edi,%edx +801073d5: ec in (%dx),%al +801073d6: ba f8 03 00 00 mov $0x3f8,%edx +801073db: ec in (%dx),%al + ioapicenable(IRQ_COM1, 0); +801073dc: 83 ec 08 sub $0x8,%esp + for (p = "xv6...\n"; *p; p++) { +801073df: bf fc 93 10 80 mov $0x801093fc,%edi +801073e4: be fd 03 00 00 mov $0x3fd,%esi + ioapicenable(IRQ_COM1, 0); +801073e9: 6a 00 push $0x0 +801073eb: 6a 04 push $0x4 +801073ed: e8 7e c5 ff ff call 80103970 + for (p = "xv6...\n"; *p; p++) { +801073f2: c6 45 e7 78 movb $0x78,-0x19(%ebp) + ioapicenable(IRQ_COM1, 0); +801073f6: 83 c4 10 add $0x10,%esp +801073f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (!uart) { +80107400: a1 40 12 12 80 mov 0x80121240,%eax +80107405: bb 80 00 00 00 mov $0x80,%ebx +8010740a: 85 c0 test %eax,%eax +8010740c: 75 14 jne 80107422 +8010740e: eb 23 jmp 80107433 + microdelay(10); +80107410: 83 ec 0c sub $0xc,%esp +80107413: 6a 0a push $0xa +80107415: e8 06 ca ff ff call 80103e20 + for (i = 0; i < 128 && !(inb(COM1 + 5) & 0x20); i++) { +8010741a: 83 c4 10 add $0x10,%esp +8010741d: 83 eb 01 sub $0x1,%ebx +80107420: 74 07 je 80107429 +80107422: 89 f2 mov %esi,%edx +80107424: ec in (%dx),%al +80107425: a8 20 test $0x20,%al +80107427: 74 e7 je 80107410 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80107429: 0f b6 45 e7 movzbl -0x19(%ebp),%eax +8010742d: ba f8 03 00 00 mov $0x3f8,%edx +80107432: ee out %al,(%dx) + for (p = "xv6...\n"; *p; p++) { +80107433: 0f b6 47 01 movzbl 0x1(%edi),%eax +80107437: 83 c7 01 add $0x1,%edi +8010743a: 88 45 e7 mov %al,-0x19(%ebp) +8010743d: 84 c0 test %al,%al +8010743f: 75 bf jne 80107400 +} +80107441: 8d 65 f4 lea -0xc(%ebp),%esp +80107444: 5b pop %ebx +80107445: 5e pop %esi +80107446: 5f pop %edi +80107447: 5d pop %ebp +80107448: c3 ret +80107449: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80107450 : + if (!uart) { +80107450: a1 40 12 12 80 mov 0x80121240,%eax +80107455: 85 c0 test %eax,%eax +80107457: 74 47 je 801074a0 +void uartputc(int c) { +80107459: 55 push %ebp +8010745a: 89 e5 mov %esp,%ebp +8010745c: 56 push %esi + asm volatile ("in %1,%0" : "=a" (data) : "d" (port)); +8010745d: be fd 03 00 00 mov $0x3fd,%esi +80107462: 53 push %ebx +80107463: bb 80 00 00 00 mov $0x80,%ebx +80107468: eb 18 jmp 80107482 +8010746a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + microdelay(10); +80107470: 83 ec 0c sub $0xc,%esp +80107473: 6a 0a push $0xa +80107475: e8 a6 c9 ff ff call 80103e20 + for (i = 0; i < 128 && !(inb(COM1 + 5) & 0x20); i++) { +8010747a: 83 c4 10 add $0x10,%esp +8010747d: 83 eb 01 sub $0x1,%ebx +80107480: 74 07 je 80107489 +80107482: 89 f2 mov %esi,%edx +80107484: ec in (%dx),%al +80107485: a8 20 test $0x20,%al +80107487: 74 e7 je 80107470 + asm volatile ("out %0,%1" : : "a" (data), "d" (port)); +80107489: 8b 45 08 mov 0x8(%ebp),%eax +8010748c: ba f8 03 00 00 mov $0x3f8,%edx +80107491: ee out %al,(%dx) +} +80107492: 8d 65 f8 lea -0x8(%ebp),%esp +80107495: 5b pop %ebx +80107496: 5e pop %esi +80107497: 5d pop %ebp +80107498: c3 ret +80107499: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801074a0: c3 ret +801074a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801074a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801074af: 90 nop + +801074b0 : + +void uartintr(void) { +801074b0: 55 push %ebp +801074b1: 89 e5 mov %esp,%ebp +801074b3: 83 ec 14 sub $0x14,%esp + consoleintr(uartgetc); +801074b6: 68 40 73 10 80 push $0x80107340 +801074bb: e8 70 a0 ff ff call 80101530 +} +801074c0: 83 c4 10 add $0x10,%esp +801074c3: c9 leave +801074c4: c3 ret + +801074c5 : +# generated by vectors.pl - do not edit +# handlers +.globl alltraps +.globl vector0 +vector0: + pushl $0 +801074c5: 6a 00 push $0x0 + pushl $0 +801074c7: 6a 00 push $0x0 + jmp alltraps +801074c9: e9 03 fb ff ff jmp 80106fd1 + +801074ce : +.globl vector1 +vector1: + pushl $0 +801074ce: 6a 00 push $0x0 + pushl $1 +801074d0: 6a 01 push $0x1 + jmp alltraps +801074d2: e9 fa fa ff ff jmp 80106fd1 + +801074d7 : +.globl vector2 +vector2: + pushl $0 +801074d7: 6a 00 push $0x0 + pushl $2 +801074d9: 6a 02 push $0x2 + jmp alltraps +801074db: e9 f1 fa ff ff jmp 80106fd1 + +801074e0 : +.globl vector3 +vector3: + pushl $0 +801074e0: 6a 00 push $0x0 + pushl $3 +801074e2: 6a 03 push $0x3 + jmp alltraps +801074e4: e9 e8 fa ff ff jmp 80106fd1 + +801074e9 : +.globl vector4 +vector4: + pushl $0 +801074e9: 6a 00 push $0x0 + pushl $4 +801074eb: 6a 04 push $0x4 + jmp alltraps +801074ed: e9 df fa ff ff jmp 80106fd1 + +801074f2 : +.globl vector5 +vector5: + pushl $0 +801074f2: 6a 00 push $0x0 + pushl $5 +801074f4: 6a 05 push $0x5 + jmp alltraps +801074f6: e9 d6 fa ff ff jmp 80106fd1 + +801074fb : +.globl vector6 +vector6: + pushl $0 +801074fb: 6a 00 push $0x0 + pushl $6 +801074fd: 6a 06 push $0x6 + jmp alltraps +801074ff: e9 cd fa ff ff jmp 80106fd1 + +80107504 : +.globl vector7 +vector7: + pushl $0 +80107504: 6a 00 push $0x0 + pushl $7 +80107506: 6a 07 push $0x7 + jmp alltraps +80107508: e9 c4 fa ff ff jmp 80106fd1 + +8010750d : +.globl vector8 +vector8: + pushl $8 +8010750d: 6a 08 push $0x8 + jmp alltraps +8010750f: e9 bd fa ff ff jmp 80106fd1 + +80107514 : +.globl vector9 +vector9: + pushl $0 +80107514: 6a 00 push $0x0 + pushl $9 +80107516: 6a 09 push $0x9 + jmp alltraps +80107518: e9 b4 fa ff ff jmp 80106fd1 + +8010751d : +.globl vector10 +vector10: + pushl $10 +8010751d: 6a 0a push $0xa + jmp alltraps +8010751f: e9 ad fa ff ff jmp 80106fd1 + +80107524 : +.globl vector11 +vector11: + pushl $11 +80107524: 6a 0b push $0xb + jmp alltraps +80107526: e9 a6 fa ff ff jmp 80106fd1 + +8010752b : +.globl vector12 +vector12: + pushl $12 +8010752b: 6a 0c push $0xc + jmp alltraps +8010752d: e9 9f fa ff ff jmp 80106fd1 + +80107532 : +.globl vector13 +vector13: + pushl $13 +80107532: 6a 0d push $0xd + jmp alltraps +80107534: e9 98 fa ff ff jmp 80106fd1 + +80107539 : +.globl vector14 +vector14: + pushl $14 +80107539: 6a 0e push $0xe + jmp alltraps +8010753b: e9 91 fa ff ff jmp 80106fd1 + +80107540 : +.globl vector15 +vector15: + pushl $0 +80107540: 6a 00 push $0x0 + pushl $15 +80107542: 6a 0f push $0xf + jmp alltraps +80107544: e9 88 fa ff ff jmp 80106fd1 + +80107549 : +.globl vector16 +vector16: + pushl $0 +80107549: 6a 00 push $0x0 + pushl $16 +8010754b: 6a 10 push $0x10 + jmp alltraps +8010754d: e9 7f fa ff ff jmp 80106fd1 + +80107552 : +.globl vector17 +vector17: + pushl $17 +80107552: 6a 11 push $0x11 + jmp alltraps +80107554: e9 78 fa ff ff jmp 80106fd1 + +80107559 : +.globl vector18 +vector18: + pushl $0 +80107559: 6a 00 push $0x0 + pushl $18 +8010755b: 6a 12 push $0x12 + jmp alltraps +8010755d: e9 6f fa ff ff jmp 80106fd1 + +80107562 : +.globl vector19 +vector19: + pushl $0 +80107562: 6a 00 push $0x0 + pushl $19 +80107564: 6a 13 push $0x13 + jmp alltraps +80107566: e9 66 fa ff ff jmp 80106fd1 + +8010756b : +.globl vector20 +vector20: + pushl $0 +8010756b: 6a 00 push $0x0 + pushl $20 +8010756d: 6a 14 push $0x14 + jmp alltraps +8010756f: e9 5d fa ff ff jmp 80106fd1 + +80107574 : +.globl vector21 +vector21: + pushl $0 +80107574: 6a 00 push $0x0 + pushl $21 +80107576: 6a 15 push $0x15 + jmp alltraps +80107578: e9 54 fa ff ff jmp 80106fd1 + +8010757d : +.globl vector22 +vector22: + pushl $0 +8010757d: 6a 00 push $0x0 + pushl $22 +8010757f: 6a 16 push $0x16 + jmp alltraps +80107581: e9 4b fa ff ff jmp 80106fd1 + +80107586 : +.globl vector23 +vector23: + pushl $0 +80107586: 6a 00 push $0x0 + pushl $23 +80107588: 6a 17 push $0x17 + jmp alltraps +8010758a: e9 42 fa ff ff jmp 80106fd1 + +8010758f : +.globl vector24 +vector24: + pushl $0 +8010758f: 6a 00 push $0x0 + pushl $24 +80107591: 6a 18 push $0x18 + jmp alltraps +80107593: e9 39 fa ff ff jmp 80106fd1 + +80107598 : +.globl vector25 +vector25: + pushl $0 +80107598: 6a 00 push $0x0 + pushl $25 +8010759a: 6a 19 push $0x19 + jmp alltraps +8010759c: e9 30 fa ff ff jmp 80106fd1 + +801075a1 : +.globl vector26 +vector26: + pushl $0 +801075a1: 6a 00 push $0x0 + pushl $26 +801075a3: 6a 1a push $0x1a + jmp alltraps +801075a5: e9 27 fa ff ff jmp 80106fd1 + +801075aa : +.globl vector27 +vector27: + pushl $0 +801075aa: 6a 00 push $0x0 + pushl $27 +801075ac: 6a 1b push $0x1b + jmp alltraps +801075ae: e9 1e fa ff ff jmp 80106fd1 + +801075b3 : +.globl vector28 +vector28: + pushl $0 +801075b3: 6a 00 push $0x0 + pushl $28 +801075b5: 6a 1c push $0x1c + jmp alltraps +801075b7: e9 15 fa ff ff jmp 80106fd1 + +801075bc : +.globl vector29 +vector29: + pushl $0 +801075bc: 6a 00 push $0x0 + pushl $29 +801075be: 6a 1d push $0x1d + jmp alltraps +801075c0: e9 0c fa ff ff jmp 80106fd1 + +801075c5 : +.globl vector30 +vector30: + pushl $0 +801075c5: 6a 00 push $0x0 + pushl $30 +801075c7: 6a 1e push $0x1e + jmp alltraps +801075c9: e9 03 fa ff ff jmp 80106fd1 + +801075ce : +.globl vector31 +vector31: + pushl $0 +801075ce: 6a 00 push $0x0 + pushl $31 +801075d0: 6a 1f push $0x1f + jmp alltraps +801075d2: e9 fa f9 ff ff jmp 80106fd1 + +801075d7 : +.globl vector32 +vector32: + pushl $0 +801075d7: 6a 00 push $0x0 + pushl $32 +801075d9: 6a 20 push $0x20 + jmp alltraps +801075db: e9 f1 f9 ff ff jmp 80106fd1 + +801075e0 : +.globl vector33 +vector33: + pushl $0 +801075e0: 6a 00 push $0x0 + pushl $33 +801075e2: 6a 21 push $0x21 + jmp alltraps +801075e4: e9 e8 f9 ff ff jmp 80106fd1 + +801075e9 : +.globl vector34 +vector34: + pushl $0 +801075e9: 6a 00 push $0x0 + pushl $34 +801075eb: 6a 22 push $0x22 + jmp alltraps +801075ed: e9 df f9 ff ff jmp 80106fd1 + +801075f2 : +.globl vector35 +vector35: + pushl $0 +801075f2: 6a 00 push $0x0 + pushl $35 +801075f4: 6a 23 push $0x23 + jmp alltraps +801075f6: e9 d6 f9 ff ff jmp 80106fd1 + +801075fb : +.globl vector36 +vector36: + pushl $0 +801075fb: 6a 00 push $0x0 + pushl $36 +801075fd: 6a 24 push $0x24 + jmp alltraps +801075ff: e9 cd f9 ff ff jmp 80106fd1 + +80107604 : +.globl vector37 +vector37: + pushl $0 +80107604: 6a 00 push $0x0 + pushl $37 +80107606: 6a 25 push $0x25 + jmp alltraps +80107608: e9 c4 f9 ff ff jmp 80106fd1 + +8010760d : +.globl vector38 +vector38: + pushl $0 +8010760d: 6a 00 push $0x0 + pushl $38 +8010760f: 6a 26 push $0x26 + jmp alltraps +80107611: e9 bb f9 ff ff jmp 80106fd1 + +80107616 : +.globl vector39 +vector39: + pushl $0 +80107616: 6a 00 push $0x0 + pushl $39 +80107618: 6a 27 push $0x27 + jmp alltraps +8010761a: e9 b2 f9 ff ff jmp 80106fd1 + +8010761f : +.globl vector40 +vector40: + pushl $0 +8010761f: 6a 00 push $0x0 + pushl $40 +80107621: 6a 28 push $0x28 + jmp alltraps +80107623: e9 a9 f9 ff ff jmp 80106fd1 + +80107628 : +.globl vector41 +vector41: + pushl $0 +80107628: 6a 00 push $0x0 + pushl $41 +8010762a: 6a 29 push $0x29 + jmp alltraps +8010762c: e9 a0 f9 ff ff jmp 80106fd1 + +80107631 : +.globl vector42 +vector42: + pushl $0 +80107631: 6a 00 push $0x0 + pushl $42 +80107633: 6a 2a push $0x2a + jmp alltraps +80107635: e9 97 f9 ff ff jmp 80106fd1 + +8010763a : +.globl vector43 +vector43: + pushl $0 +8010763a: 6a 00 push $0x0 + pushl $43 +8010763c: 6a 2b push $0x2b + jmp alltraps +8010763e: e9 8e f9 ff ff jmp 80106fd1 + +80107643 : +.globl vector44 +vector44: + pushl $0 +80107643: 6a 00 push $0x0 + pushl $44 +80107645: 6a 2c push $0x2c + jmp alltraps +80107647: e9 85 f9 ff ff jmp 80106fd1 + +8010764c : +.globl vector45 +vector45: + pushl $0 +8010764c: 6a 00 push $0x0 + pushl $45 +8010764e: 6a 2d push $0x2d + jmp alltraps +80107650: e9 7c f9 ff ff jmp 80106fd1 + +80107655 : +.globl vector46 +vector46: + pushl $0 +80107655: 6a 00 push $0x0 + pushl $46 +80107657: 6a 2e push $0x2e + jmp alltraps +80107659: e9 73 f9 ff ff jmp 80106fd1 + +8010765e : +.globl vector47 +vector47: + pushl $0 +8010765e: 6a 00 push $0x0 + pushl $47 +80107660: 6a 2f push $0x2f + jmp alltraps +80107662: e9 6a f9 ff ff jmp 80106fd1 + +80107667 : +.globl vector48 +vector48: + pushl $0 +80107667: 6a 00 push $0x0 + pushl $48 +80107669: 6a 30 push $0x30 + jmp alltraps +8010766b: e9 61 f9 ff ff jmp 80106fd1 + +80107670 : +.globl vector49 +vector49: + pushl $0 +80107670: 6a 00 push $0x0 + pushl $49 +80107672: 6a 31 push $0x31 + jmp alltraps +80107674: e9 58 f9 ff ff jmp 80106fd1 + +80107679 : +.globl vector50 +vector50: + pushl $0 +80107679: 6a 00 push $0x0 + pushl $50 +8010767b: 6a 32 push $0x32 + jmp alltraps +8010767d: e9 4f f9 ff ff jmp 80106fd1 + +80107682 : +.globl vector51 +vector51: + pushl $0 +80107682: 6a 00 push $0x0 + pushl $51 +80107684: 6a 33 push $0x33 + jmp alltraps +80107686: e9 46 f9 ff ff jmp 80106fd1 + +8010768b : +.globl vector52 +vector52: + pushl $0 +8010768b: 6a 00 push $0x0 + pushl $52 +8010768d: 6a 34 push $0x34 + jmp alltraps +8010768f: e9 3d f9 ff ff jmp 80106fd1 + +80107694 : +.globl vector53 +vector53: + pushl $0 +80107694: 6a 00 push $0x0 + pushl $53 +80107696: 6a 35 push $0x35 + jmp alltraps +80107698: e9 34 f9 ff ff jmp 80106fd1 + +8010769d : +.globl vector54 +vector54: + pushl $0 +8010769d: 6a 00 push $0x0 + pushl $54 +8010769f: 6a 36 push $0x36 + jmp alltraps +801076a1: e9 2b f9 ff ff jmp 80106fd1 + +801076a6 : +.globl vector55 +vector55: + pushl $0 +801076a6: 6a 00 push $0x0 + pushl $55 +801076a8: 6a 37 push $0x37 + jmp alltraps +801076aa: e9 22 f9 ff ff jmp 80106fd1 + +801076af : +.globl vector56 +vector56: + pushl $0 +801076af: 6a 00 push $0x0 + pushl $56 +801076b1: 6a 38 push $0x38 + jmp alltraps +801076b3: e9 19 f9 ff ff jmp 80106fd1 + +801076b8 : +.globl vector57 +vector57: + pushl $0 +801076b8: 6a 00 push $0x0 + pushl $57 +801076ba: 6a 39 push $0x39 + jmp alltraps +801076bc: e9 10 f9 ff ff jmp 80106fd1 + +801076c1 : +.globl vector58 +vector58: + pushl $0 +801076c1: 6a 00 push $0x0 + pushl $58 +801076c3: 6a 3a push $0x3a + jmp alltraps +801076c5: e9 07 f9 ff ff jmp 80106fd1 + +801076ca : +.globl vector59 +vector59: + pushl $0 +801076ca: 6a 00 push $0x0 + pushl $59 +801076cc: 6a 3b push $0x3b + jmp alltraps +801076ce: e9 fe f8 ff ff jmp 80106fd1 + +801076d3 : +.globl vector60 +vector60: + pushl $0 +801076d3: 6a 00 push $0x0 + pushl $60 +801076d5: 6a 3c push $0x3c + jmp alltraps +801076d7: e9 f5 f8 ff ff jmp 80106fd1 + +801076dc : +.globl vector61 +vector61: + pushl $0 +801076dc: 6a 00 push $0x0 + pushl $61 +801076de: 6a 3d push $0x3d + jmp alltraps +801076e0: e9 ec f8 ff ff jmp 80106fd1 + +801076e5 : +.globl vector62 +vector62: + pushl $0 +801076e5: 6a 00 push $0x0 + pushl $62 +801076e7: 6a 3e push $0x3e + jmp alltraps +801076e9: e9 e3 f8 ff ff jmp 80106fd1 + +801076ee : +.globl vector63 +vector63: + pushl $0 +801076ee: 6a 00 push $0x0 + pushl $63 +801076f0: 6a 3f push $0x3f + jmp alltraps +801076f2: e9 da f8 ff ff jmp 80106fd1 + +801076f7 : +.globl vector64 +vector64: + pushl $0 +801076f7: 6a 00 push $0x0 + pushl $64 +801076f9: 6a 40 push $0x40 + jmp alltraps +801076fb: e9 d1 f8 ff ff jmp 80106fd1 + +80107700 : +.globl vector65 +vector65: + pushl $0 +80107700: 6a 00 push $0x0 + pushl $65 +80107702: 6a 41 push $0x41 + jmp alltraps +80107704: e9 c8 f8 ff ff jmp 80106fd1 + +80107709 : +.globl vector66 +vector66: + pushl $0 +80107709: 6a 00 push $0x0 + pushl $66 +8010770b: 6a 42 push $0x42 + jmp alltraps +8010770d: e9 bf f8 ff ff jmp 80106fd1 + +80107712 : +.globl vector67 +vector67: + pushl $0 +80107712: 6a 00 push $0x0 + pushl $67 +80107714: 6a 43 push $0x43 + jmp alltraps +80107716: e9 b6 f8 ff ff jmp 80106fd1 + +8010771b : +.globl vector68 +vector68: + pushl $0 +8010771b: 6a 00 push $0x0 + pushl $68 +8010771d: 6a 44 push $0x44 + jmp alltraps +8010771f: e9 ad f8 ff ff jmp 80106fd1 + +80107724 : +.globl vector69 +vector69: + pushl $0 +80107724: 6a 00 push $0x0 + pushl $69 +80107726: 6a 45 push $0x45 + jmp alltraps +80107728: e9 a4 f8 ff ff jmp 80106fd1 + +8010772d : +.globl vector70 +vector70: + pushl $0 +8010772d: 6a 00 push $0x0 + pushl $70 +8010772f: 6a 46 push $0x46 + jmp alltraps +80107731: e9 9b f8 ff ff jmp 80106fd1 + +80107736 : +.globl vector71 +vector71: + pushl $0 +80107736: 6a 00 push $0x0 + pushl $71 +80107738: 6a 47 push $0x47 + jmp alltraps +8010773a: e9 92 f8 ff ff jmp 80106fd1 + +8010773f : +.globl vector72 +vector72: + pushl $0 +8010773f: 6a 00 push $0x0 + pushl $72 +80107741: 6a 48 push $0x48 + jmp alltraps +80107743: e9 89 f8 ff ff jmp 80106fd1 + +80107748 : +.globl vector73 +vector73: + pushl $0 +80107748: 6a 00 push $0x0 + pushl $73 +8010774a: 6a 49 push $0x49 + jmp alltraps +8010774c: e9 80 f8 ff ff jmp 80106fd1 + +80107751 : +.globl vector74 +vector74: + pushl $0 +80107751: 6a 00 push $0x0 + pushl $74 +80107753: 6a 4a push $0x4a + jmp alltraps +80107755: e9 77 f8 ff ff jmp 80106fd1 + +8010775a : +.globl vector75 +vector75: + pushl $0 +8010775a: 6a 00 push $0x0 + pushl $75 +8010775c: 6a 4b push $0x4b + jmp alltraps +8010775e: e9 6e f8 ff ff jmp 80106fd1 + +80107763 : +.globl vector76 +vector76: + pushl $0 +80107763: 6a 00 push $0x0 + pushl $76 +80107765: 6a 4c push $0x4c + jmp alltraps +80107767: e9 65 f8 ff ff jmp 80106fd1 + +8010776c : +.globl vector77 +vector77: + pushl $0 +8010776c: 6a 00 push $0x0 + pushl $77 +8010776e: 6a 4d push $0x4d + jmp alltraps +80107770: e9 5c f8 ff ff jmp 80106fd1 + +80107775 : +.globl vector78 +vector78: + pushl $0 +80107775: 6a 00 push $0x0 + pushl $78 +80107777: 6a 4e push $0x4e + jmp alltraps +80107779: e9 53 f8 ff ff jmp 80106fd1 + +8010777e : +.globl vector79 +vector79: + pushl $0 +8010777e: 6a 00 push $0x0 + pushl $79 +80107780: 6a 4f push $0x4f + jmp alltraps +80107782: e9 4a f8 ff ff jmp 80106fd1 + +80107787 : +.globl vector80 +vector80: + pushl $0 +80107787: 6a 00 push $0x0 + pushl $80 +80107789: 6a 50 push $0x50 + jmp alltraps +8010778b: e9 41 f8 ff ff jmp 80106fd1 + +80107790 : +.globl vector81 +vector81: + pushl $0 +80107790: 6a 00 push $0x0 + pushl $81 +80107792: 6a 51 push $0x51 + jmp alltraps +80107794: e9 38 f8 ff ff jmp 80106fd1 + +80107799 : +.globl vector82 +vector82: + pushl $0 +80107799: 6a 00 push $0x0 + pushl $82 +8010779b: 6a 52 push $0x52 + jmp alltraps +8010779d: e9 2f f8 ff ff jmp 80106fd1 + +801077a2 : +.globl vector83 +vector83: + pushl $0 +801077a2: 6a 00 push $0x0 + pushl $83 +801077a4: 6a 53 push $0x53 + jmp alltraps +801077a6: e9 26 f8 ff ff jmp 80106fd1 + +801077ab : +.globl vector84 +vector84: + pushl $0 +801077ab: 6a 00 push $0x0 + pushl $84 +801077ad: 6a 54 push $0x54 + jmp alltraps +801077af: e9 1d f8 ff ff jmp 80106fd1 + +801077b4 : +.globl vector85 +vector85: + pushl $0 +801077b4: 6a 00 push $0x0 + pushl $85 +801077b6: 6a 55 push $0x55 + jmp alltraps +801077b8: e9 14 f8 ff ff jmp 80106fd1 + +801077bd : +.globl vector86 +vector86: + pushl $0 +801077bd: 6a 00 push $0x0 + pushl $86 +801077bf: 6a 56 push $0x56 + jmp alltraps +801077c1: e9 0b f8 ff ff jmp 80106fd1 + +801077c6 : +.globl vector87 +vector87: + pushl $0 +801077c6: 6a 00 push $0x0 + pushl $87 +801077c8: 6a 57 push $0x57 + jmp alltraps +801077ca: e9 02 f8 ff ff jmp 80106fd1 + +801077cf : +.globl vector88 +vector88: + pushl $0 +801077cf: 6a 00 push $0x0 + pushl $88 +801077d1: 6a 58 push $0x58 + jmp alltraps +801077d3: e9 f9 f7 ff ff jmp 80106fd1 + +801077d8 : +.globl vector89 +vector89: + pushl $0 +801077d8: 6a 00 push $0x0 + pushl $89 +801077da: 6a 59 push $0x59 + jmp alltraps +801077dc: e9 f0 f7 ff ff jmp 80106fd1 + +801077e1 : +.globl vector90 +vector90: + pushl $0 +801077e1: 6a 00 push $0x0 + pushl $90 +801077e3: 6a 5a push $0x5a + jmp alltraps +801077e5: e9 e7 f7 ff ff jmp 80106fd1 + +801077ea : +.globl vector91 +vector91: + pushl $0 +801077ea: 6a 00 push $0x0 + pushl $91 +801077ec: 6a 5b push $0x5b + jmp alltraps +801077ee: e9 de f7 ff ff jmp 80106fd1 + +801077f3 : +.globl vector92 +vector92: + pushl $0 +801077f3: 6a 00 push $0x0 + pushl $92 +801077f5: 6a 5c push $0x5c + jmp alltraps +801077f7: e9 d5 f7 ff ff jmp 80106fd1 + +801077fc : +.globl vector93 +vector93: + pushl $0 +801077fc: 6a 00 push $0x0 + pushl $93 +801077fe: 6a 5d push $0x5d + jmp alltraps +80107800: e9 cc f7 ff ff jmp 80106fd1 + +80107805 : +.globl vector94 +vector94: + pushl $0 +80107805: 6a 00 push $0x0 + pushl $94 +80107807: 6a 5e push $0x5e + jmp alltraps +80107809: e9 c3 f7 ff ff jmp 80106fd1 + +8010780e : +.globl vector95 +vector95: + pushl $0 +8010780e: 6a 00 push $0x0 + pushl $95 +80107810: 6a 5f push $0x5f + jmp alltraps +80107812: e9 ba f7 ff ff jmp 80106fd1 + +80107817 : +.globl vector96 +vector96: + pushl $0 +80107817: 6a 00 push $0x0 + pushl $96 +80107819: 6a 60 push $0x60 + jmp alltraps +8010781b: e9 b1 f7 ff ff jmp 80106fd1 + +80107820 : +.globl vector97 +vector97: + pushl $0 +80107820: 6a 00 push $0x0 + pushl $97 +80107822: 6a 61 push $0x61 + jmp alltraps +80107824: e9 a8 f7 ff ff jmp 80106fd1 + +80107829 : +.globl vector98 +vector98: + pushl $0 +80107829: 6a 00 push $0x0 + pushl $98 +8010782b: 6a 62 push $0x62 + jmp alltraps +8010782d: e9 9f f7 ff ff jmp 80106fd1 + +80107832 : +.globl vector99 +vector99: + pushl $0 +80107832: 6a 00 push $0x0 + pushl $99 +80107834: 6a 63 push $0x63 + jmp alltraps +80107836: e9 96 f7 ff ff jmp 80106fd1 + +8010783b : +.globl vector100 +vector100: + pushl $0 +8010783b: 6a 00 push $0x0 + pushl $100 +8010783d: 6a 64 push $0x64 + jmp alltraps +8010783f: e9 8d f7 ff ff jmp 80106fd1 + +80107844 : +.globl vector101 +vector101: + pushl $0 +80107844: 6a 00 push $0x0 + pushl $101 +80107846: 6a 65 push $0x65 + jmp alltraps +80107848: e9 84 f7 ff ff jmp 80106fd1 + +8010784d : +.globl vector102 +vector102: + pushl $0 +8010784d: 6a 00 push $0x0 + pushl $102 +8010784f: 6a 66 push $0x66 + jmp alltraps +80107851: e9 7b f7 ff ff jmp 80106fd1 + +80107856 : +.globl vector103 +vector103: + pushl $0 +80107856: 6a 00 push $0x0 + pushl $103 +80107858: 6a 67 push $0x67 + jmp alltraps +8010785a: e9 72 f7 ff ff jmp 80106fd1 + +8010785f : +.globl vector104 +vector104: + pushl $0 +8010785f: 6a 00 push $0x0 + pushl $104 +80107861: 6a 68 push $0x68 + jmp alltraps +80107863: e9 69 f7 ff ff jmp 80106fd1 + +80107868 : +.globl vector105 +vector105: + pushl $0 +80107868: 6a 00 push $0x0 + pushl $105 +8010786a: 6a 69 push $0x69 + jmp alltraps +8010786c: e9 60 f7 ff ff jmp 80106fd1 + +80107871 : +.globl vector106 +vector106: + pushl $0 +80107871: 6a 00 push $0x0 + pushl $106 +80107873: 6a 6a push $0x6a + jmp alltraps +80107875: e9 57 f7 ff ff jmp 80106fd1 + +8010787a : +.globl vector107 +vector107: + pushl $0 +8010787a: 6a 00 push $0x0 + pushl $107 +8010787c: 6a 6b push $0x6b + jmp alltraps +8010787e: e9 4e f7 ff ff jmp 80106fd1 + +80107883 : +.globl vector108 +vector108: + pushl $0 +80107883: 6a 00 push $0x0 + pushl $108 +80107885: 6a 6c push $0x6c + jmp alltraps +80107887: e9 45 f7 ff ff jmp 80106fd1 + +8010788c : +.globl vector109 +vector109: + pushl $0 +8010788c: 6a 00 push $0x0 + pushl $109 +8010788e: 6a 6d push $0x6d + jmp alltraps +80107890: e9 3c f7 ff ff jmp 80106fd1 + +80107895 : +.globl vector110 +vector110: + pushl $0 +80107895: 6a 00 push $0x0 + pushl $110 +80107897: 6a 6e push $0x6e + jmp alltraps +80107899: e9 33 f7 ff ff jmp 80106fd1 + +8010789e : +.globl vector111 +vector111: + pushl $0 +8010789e: 6a 00 push $0x0 + pushl $111 +801078a0: 6a 6f push $0x6f + jmp alltraps +801078a2: e9 2a f7 ff ff jmp 80106fd1 + +801078a7 : +.globl vector112 +vector112: + pushl $0 +801078a7: 6a 00 push $0x0 + pushl $112 +801078a9: 6a 70 push $0x70 + jmp alltraps +801078ab: e9 21 f7 ff ff jmp 80106fd1 + +801078b0 : +.globl vector113 +vector113: + pushl $0 +801078b0: 6a 00 push $0x0 + pushl $113 +801078b2: 6a 71 push $0x71 + jmp alltraps +801078b4: e9 18 f7 ff ff jmp 80106fd1 + +801078b9 : +.globl vector114 +vector114: + pushl $0 +801078b9: 6a 00 push $0x0 + pushl $114 +801078bb: 6a 72 push $0x72 + jmp alltraps +801078bd: e9 0f f7 ff ff jmp 80106fd1 + +801078c2 : +.globl vector115 +vector115: + pushl $0 +801078c2: 6a 00 push $0x0 + pushl $115 +801078c4: 6a 73 push $0x73 + jmp alltraps +801078c6: e9 06 f7 ff ff jmp 80106fd1 + +801078cb : +.globl vector116 +vector116: + pushl $0 +801078cb: 6a 00 push $0x0 + pushl $116 +801078cd: 6a 74 push $0x74 + jmp alltraps +801078cf: e9 fd f6 ff ff jmp 80106fd1 + +801078d4 : +.globl vector117 +vector117: + pushl $0 +801078d4: 6a 00 push $0x0 + pushl $117 +801078d6: 6a 75 push $0x75 + jmp alltraps +801078d8: e9 f4 f6 ff ff jmp 80106fd1 + +801078dd : +.globl vector118 +vector118: + pushl $0 +801078dd: 6a 00 push $0x0 + pushl $118 +801078df: 6a 76 push $0x76 + jmp alltraps +801078e1: e9 eb f6 ff ff jmp 80106fd1 + +801078e6 : +.globl vector119 +vector119: + pushl $0 +801078e6: 6a 00 push $0x0 + pushl $119 +801078e8: 6a 77 push $0x77 + jmp alltraps +801078ea: e9 e2 f6 ff ff jmp 80106fd1 + +801078ef : +.globl vector120 +vector120: + pushl $0 +801078ef: 6a 00 push $0x0 + pushl $120 +801078f1: 6a 78 push $0x78 + jmp alltraps +801078f3: e9 d9 f6 ff ff jmp 80106fd1 + +801078f8 : +.globl vector121 +vector121: + pushl $0 +801078f8: 6a 00 push $0x0 + pushl $121 +801078fa: 6a 79 push $0x79 + jmp alltraps +801078fc: e9 d0 f6 ff ff jmp 80106fd1 + +80107901 : +.globl vector122 +vector122: + pushl $0 +80107901: 6a 00 push $0x0 + pushl $122 +80107903: 6a 7a push $0x7a + jmp alltraps +80107905: e9 c7 f6 ff ff jmp 80106fd1 + +8010790a : +.globl vector123 +vector123: + pushl $0 +8010790a: 6a 00 push $0x0 + pushl $123 +8010790c: 6a 7b push $0x7b + jmp alltraps +8010790e: e9 be f6 ff ff jmp 80106fd1 + +80107913 : +.globl vector124 +vector124: + pushl $0 +80107913: 6a 00 push $0x0 + pushl $124 +80107915: 6a 7c push $0x7c + jmp alltraps +80107917: e9 b5 f6 ff ff jmp 80106fd1 + +8010791c : +.globl vector125 +vector125: + pushl $0 +8010791c: 6a 00 push $0x0 + pushl $125 +8010791e: 6a 7d push $0x7d + jmp alltraps +80107920: e9 ac f6 ff ff jmp 80106fd1 + +80107925 : +.globl vector126 +vector126: + pushl $0 +80107925: 6a 00 push $0x0 + pushl $126 +80107927: 6a 7e push $0x7e + jmp alltraps +80107929: e9 a3 f6 ff ff jmp 80106fd1 + +8010792e : +.globl vector127 +vector127: + pushl $0 +8010792e: 6a 00 push $0x0 + pushl $127 +80107930: 6a 7f push $0x7f + jmp alltraps +80107932: e9 9a f6 ff ff jmp 80106fd1 + +80107937 : +.globl vector128 +vector128: + pushl $0 +80107937: 6a 00 push $0x0 + pushl $128 +80107939: 68 80 00 00 00 push $0x80 + jmp alltraps +8010793e: e9 8e f6 ff ff jmp 80106fd1 + +80107943 : +.globl vector129 +vector129: + pushl $0 +80107943: 6a 00 push $0x0 + pushl $129 +80107945: 68 81 00 00 00 push $0x81 + jmp alltraps +8010794a: e9 82 f6 ff ff jmp 80106fd1 + +8010794f : +.globl vector130 +vector130: + pushl $0 +8010794f: 6a 00 push $0x0 + pushl $130 +80107951: 68 82 00 00 00 push $0x82 + jmp alltraps +80107956: e9 76 f6 ff ff jmp 80106fd1 + +8010795b : +.globl vector131 +vector131: + pushl $0 +8010795b: 6a 00 push $0x0 + pushl $131 +8010795d: 68 83 00 00 00 push $0x83 + jmp alltraps +80107962: e9 6a f6 ff ff jmp 80106fd1 + +80107967 : +.globl vector132 +vector132: + pushl $0 +80107967: 6a 00 push $0x0 + pushl $132 +80107969: 68 84 00 00 00 push $0x84 + jmp alltraps +8010796e: e9 5e f6 ff ff jmp 80106fd1 + +80107973 : +.globl vector133 +vector133: + pushl $0 +80107973: 6a 00 push $0x0 + pushl $133 +80107975: 68 85 00 00 00 push $0x85 + jmp alltraps +8010797a: e9 52 f6 ff ff jmp 80106fd1 + +8010797f : +.globl vector134 +vector134: + pushl $0 +8010797f: 6a 00 push $0x0 + pushl $134 +80107981: 68 86 00 00 00 push $0x86 + jmp alltraps +80107986: e9 46 f6 ff ff jmp 80106fd1 + +8010798b : +.globl vector135 +vector135: + pushl $0 +8010798b: 6a 00 push $0x0 + pushl $135 +8010798d: 68 87 00 00 00 push $0x87 + jmp alltraps +80107992: e9 3a f6 ff ff jmp 80106fd1 + +80107997 : +.globl vector136 +vector136: + pushl $0 +80107997: 6a 00 push $0x0 + pushl $136 +80107999: 68 88 00 00 00 push $0x88 + jmp alltraps +8010799e: e9 2e f6 ff ff jmp 80106fd1 + +801079a3 : +.globl vector137 +vector137: + pushl $0 +801079a3: 6a 00 push $0x0 + pushl $137 +801079a5: 68 89 00 00 00 push $0x89 + jmp alltraps +801079aa: e9 22 f6 ff ff jmp 80106fd1 + +801079af : +.globl vector138 +vector138: + pushl $0 +801079af: 6a 00 push $0x0 + pushl $138 +801079b1: 68 8a 00 00 00 push $0x8a + jmp alltraps +801079b6: e9 16 f6 ff ff jmp 80106fd1 + +801079bb : +.globl vector139 +vector139: + pushl $0 +801079bb: 6a 00 push $0x0 + pushl $139 +801079bd: 68 8b 00 00 00 push $0x8b + jmp alltraps +801079c2: e9 0a f6 ff ff jmp 80106fd1 + +801079c7 : +.globl vector140 +vector140: + pushl $0 +801079c7: 6a 00 push $0x0 + pushl $140 +801079c9: 68 8c 00 00 00 push $0x8c + jmp alltraps +801079ce: e9 fe f5 ff ff jmp 80106fd1 + +801079d3 : +.globl vector141 +vector141: + pushl $0 +801079d3: 6a 00 push $0x0 + pushl $141 +801079d5: 68 8d 00 00 00 push $0x8d + jmp alltraps +801079da: e9 f2 f5 ff ff jmp 80106fd1 + +801079df : +.globl vector142 +vector142: + pushl $0 +801079df: 6a 00 push $0x0 + pushl $142 +801079e1: 68 8e 00 00 00 push $0x8e + jmp alltraps +801079e6: e9 e6 f5 ff ff jmp 80106fd1 + +801079eb : +.globl vector143 +vector143: + pushl $0 +801079eb: 6a 00 push $0x0 + pushl $143 +801079ed: 68 8f 00 00 00 push $0x8f + jmp alltraps +801079f2: e9 da f5 ff ff jmp 80106fd1 + +801079f7 : +.globl vector144 +vector144: + pushl $0 +801079f7: 6a 00 push $0x0 + pushl $144 +801079f9: 68 90 00 00 00 push $0x90 + jmp alltraps +801079fe: e9 ce f5 ff ff jmp 80106fd1 + +80107a03 : +.globl vector145 +vector145: + pushl $0 +80107a03: 6a 00 push $0x0 + pushl $145 +80107a05: 68 91 00 00 00 push $0x91 + jmp alltraps +80107a0a: e9 c2 f5 ff ff jmp 80106fd1 + +80107a0f : +.globl vector146 +vector146: + pushl $0 +80107a0f: 6a 00 push $0x0 + pushl $146 +80107a11: 68 92 00 00 00 push $0x92 + jmp alltraps +80107a16: e9 b6 f5 ff ff jmp 80106fd1 + +80107a1b : +.globl vector147 +vector147: + pushl $0 +80107a1b: 6a 00 push $0x0 + pushl $147 +80107a1d: 68 93 00 00 00 push $0x93 + jmp alltraps +80107a22: e9 aa f5 ff ff jmp 80106fd1 + +80107a27 : +.globl vector148 +vector148: + pushl $0 +80107a27: 6a 00 push $0x0 + pushl $148 +80107a29: 68 94 00 00 00 push $0x94 + jmp alltraps +80107a2e: e9 9e f5 ff ff jmp 80106fd1 + +80107a33 : +.globl vector149 +vector149: + pushl $0 +80107a33: 6a 00 push $0x0 + pushl $149 +80107a35: 68 95 00 00 00 push $0x95 + jmp alltraps +80107a3a: e9 92 f5 ff ff jmp 80106fd1 + +80107a3f : +.globl vector150 +vector150: + pushl $0 +80107a3f: 6a 00 push $0x0 + pushl $150 +80107a41: 68 96 00 00 00 push $0x96 + jmp alltraps +80107a46: e9 86 f5 ff ff jmp 80106fd1 + +80107a4b : +.globl vector151 +vector151: + pushl $0 +80107a4b: 6a 00 push $0x0 + pushl $151 +80107a4d: 68 97 00 00 00 push $0x97 + jmp alltraps +80107a52: e9 7a f5 ff ff jmp 80106fd1 + +80107a57 : +.globl vector152 +vector152: + pushl $0 +80107a57: 6a 00 push $0x0 + pushl $152 +80107a59: 68 98 00 00 00 push $0x98 + jmp alltraps +80107a5e: e9 6e f5 ff ff jmp 80106fd1 + +80107a63 : +.globl vector153 +vector153: + pushl $0 +80107a63: 6a 00 push $0x0 + pushl $153 +80107a65: 68 99 00 00 00 push $0x99 + jmp alltraps +80107a6a: e9 62 f5 ff ff jmp 80106fd1 + +80107a6f : +.globl vector154 +vector154: + pushl $0 +80107a6f: 6a 00 push $0x0 + pushl $154 +80107a71: 68 9a 00 00 00 push $0x9a + jmp alltraps +80107a76: e9 56 f5 ff ff jmp 80106fd1 + +80107a7b : +.globl vector155 +vector155: + pushl $0 +80107a7b: 6a 00 push $0x0 + pushl $155 +80107a7d: 68 9b 00 00 00 push $0x9b + jmp alltraps +80107a82: e9 4a f5 ff ff jmp 80106fd1 + +80107a87 : +.globl vector156 +vector156: + pushl $0 +80107a87: 6a 00 push $0x0 + pushl $156 +80107a89: 68 9c 00 00 00 push $0x9c + jmp alltraps +80107a8e: e9 3e f5 ff ff jmp 80106fd1 + +80107a93 : +.globl vector157 +vector157: + pushl $0 +80107a93: 6a 00 push $0x0 + pushl $157 +80107a95: 68 9d 00 00 00 push $0x9d + jmp alltraps +80107a9a: e9 32 f5 ff ff jmp 80106fd1 + +80107a9f : +.globl vector158 +vector158: + pushl $0 +80107a9f: 6a 00 push $0x0 + pushl $158 +80107aa1: 68 9e 00 00 00 push $0x9e + jmp alltraps +80107aa6: e9 26 f5 ff ff jmp 80106fd1 + +80107aab : +.globl vector159 +vector159: + pushl $0 +80107aab: 6a 00 push $0x0 + pushl $159 +80107aad: 68 9f 00 00 00 push $0x9f + jmp alltraps +80107ab2: e9 1a f5 ff ff jmp 80106fd1 + +80107ab7 : +.globl vector160 +vector160: + pushl $0 +80107ab7: 6a 00 push $0x0 + pushl $160 +80107ab9: 68 a0 00 00 00 push $0xa0 + jmp alltraps +80107abe: e9 0e f5 ff ff jmp 80106fd1 + +80107ac3 : +.globl vector161 +vector161: + pushl $0 +80107ac3: 6a 00 push $0x0 + pushl $161 +80107ac5: 68 a1 00 00 00 push $0xa1 + jmp alltraps +80107aca: e9 02 f5 ff ff jmp 80106fd1 + +80107acf : +.globl vector162 +vector162: + pushl $0 +80107acf: 6a 00 push $0x0 + pushl $162 +80107ad1: 68 a2 00 00 00 push $0xa2 + jmp alltraps +80107ad6: e9 f6 f4 ff ff jmp 80106fd1 + +80107adb : +.globl vector163 +vector163: + pushl $0 +80107adb: 6a 00 push $0x0 + pushl $163 +80107add: 68 a3 00 00 00 push $0xa3 + jmp alltraps +80107ae2: e9 ea f4 ff ff jmp 80106fd1 + +80107ae7 : +.globl vector164 +vector164: + pushl $0 +80107ae7: 6a 00 push $0x0 + pushl $164 +80107ae9: 68 a4 00 00 00 push $0xa4 + jmp alltraps +80107aee: e9 de f4 ff ff jmp 80106fd1 + +80107af3 : +.globl vector165 +vector165: + pushl $0 +80107af3: 6a 00 push $0x0 + pushl $165 +80107af5: 68 a5 00 00 00 push $0xa5 + jmp alltraps +80107afa: e9 d2 f4 ff ff jmp 80106fd1 + +80107aff : +.globl vector166 +vector166: + pushl $0 +80107aff: 6a 00 push $0x0 + pushl $166 +80107b01: 68 a6 00 00 00 push $0xa6 + jmp alltraps +80107b06: e9 c6 f4 ff ff jmp 80106fd1 + +80107b0b : +.globl vector167 +vector167: + pushl $0 +80107b0b: 6a 00 push $0x0 + pushl $167 +80107b0d: 68 a7 00 00 00 push $0xa7 + jmp alltraps +80107b12: e9 ba f4 ff ff jmp 80106fd1 + +80107b17 : +.globl vector168 +vector168: + pushl $0 +80107b17: 6a 00 push $0x0 + pushl $168 +80107b19: 68 a8 00 00 00 push $0xa8 + jmp alltraps +80107b1e: e9 ae f4 ff ff jmp 80106fd1 + +80107b23 : +.globl vector169 +vector169: + pushl $0 +80107b23: 6a 00 push $0x0 + pushl $169 +80107b25: 68 a9 00 00 00 push $0xa9 + jmp alltraps +80107b2a: e9 a2 f4 ff ff jmp 80106fd1 + +80107b2f : +.globl vector170 +vector170: + pushl $0 +80107b2f: 6a 00 push $0x0 + pushl $170 +80107b31: 68 aa 00 00 00 push $0xaa + jmp alltraps +80107b36: e9 96 f4 ff ff jmp 80106fd1 + +80107b3b : +.globl vector171 +vector171: + pushl $0 +80107b3b: 6a 00 push $0x0 + pushl $171 +80107b3d: 68 ab 00 00 00 push $0xab + jmp alltraps +80107b42: e9 8a f4 ff ff jmp 80106fd1 + +80107b47 : +.globl vector172 +vector172: + pushl $0 +80107b47: 6a 00 push $0x0 + pushl $172 +80107b49: 68 ac 00 00 00 push $0xac + jmp alltraps +80107b4e: e9 7e f4 ff ff jmp 80106fd1 + +80107b53 : +.globl vector173 +vector173: + pushl $0 +80107b53: 6a 00 push $0x0 + pushl $173 +80107b55: 68 ad 00 00 00 push $0xad + jmp alltraps +80107b5a: e9 72 f4 ff ff jmp 80106fd1 + +80107b5f : +.globl vector174 +vector174: + pushl $0 +80107b5f: 6a 00 push $0x0 + pushl $174 +80107b61: 68 ae 00 00 00 push $0xae + jmp alltraps +80107b66: e9 66 f4 ff ff jmp 80106fd1 + +80107b6b : +.globl vector175 +vector175: + pushl $0 +80107b6b: 6a 00 push $0x0 + pushl $175 +80107b6d: 68 af 00 00 00 push $0xaf + jmp alltraps +80107b72: e9 5a f4 ff ff jmp 80106fd1 + +80107b77 : +.globl vector176 +vector176: + pushl $0 +80107b77: 6a 00 push $0x0 + pushl $176 +80107b79: 68 b0 00 00 00 push $0xb0 + jmp alltraps +80107b7e: e9 4e f4 ff ff jmp 80106fd1 + +80107b83 : +.globl vector177 +vector177: + pushl $0 +80107b83: 6a 00 push $0x0 + pushl $177 +80107b85: 68 b1 00 00 00 push $0xb1 + jmp alltraps +80107b8a: e9 42 f4 ff ff jmp 80106fd1 + +80107b8f : +.globl vector178 +vector178: + pushl $0 +80107b8f: 6a 00 push $0x0 + pushl $178 +80107b91: 68 b2 00 00 00 push $0xb2 + jmp alltraps +80107b96: e9 36 f4 ff ff jmp 80106fd1 + +80107b9b : +.globl vector179 +vector179: + pushl $0 +80107b9b: 6a 00 push $0x0 + pushl $179 +80107b9d: 68 b3 00 00 00 push $0xb3 + jmp alltraps +80107ba2: e9 2a f4 ff ff jmp 80106fd1 + +80107ba7 : +.globl vector180 +vector180: + pushl $0 +80107ba7: 6a 00 push $0x0 + pushl $180 +80107ba9: 68 b4 00 00 00 push $0xb4 + jmp alltraps +80107bae: e9 1e f4 ff ff jmp 80106fd1 + +80107bb3 : +.globl vector181 +vector181: + pushl $0 +80107bb3: 6a 00 push $0x0 + pushl $181 +80107bb5: 68 b5 00 00 00 push $0xb5 + jmp alltraps +80107bba: e9 12 f4 ff ff jmp 80106fd1 + +80107bbf : +.globl vector182 +vector182: + pushl $0 +80107bbf: 6a 00 push $0x0 + pushl $182 +80107bc1: 68 b6 00 00 00 push $0xb6 + jmp alltraps +80107bc6: e9 06 f4 ff ff jmp 80106fd1 + +80107bcb : +.globl vector183 +vector183: + pushl $0 +80107bcb: 6a 00 push $0x0 + pushl $183 +80107bcd: 68 b7 00 00 00 push $0xb7 + jmp alltraps +80107bd2: e9 fa f3 ff ff jmp 80106fd1 + +80107bd7 : +.globl vector184 +vector184: + pushl $0 +80107bd7: 6a 00 push $0x0 + pushl $184 +80107bd9: 68 b8 00 00 00 push $0xb8 + jmp alltraps +80107bde: e9 ee f3 ff ff jmp 80106fd1 + +80107be3 : +.globl vector185 +vector185: + pushl $0 +80107be3: 6a 00 push $0x0 + pushl $185 +80107be5: 68 b9 00 00 00 push $0xb9 + jmp alltraps +80107bea: e9 e2 f3 ff ff jmp 80106fd1 + +80107bef : +.globl vector186 +vector186: + pushl $0 +80107bef: 6a 00 push $0x0 + pushl $186 +80107bf1: 68 ba 00 00 00 push $0xba + jmp alltraps +80107bf6: e9 d6 f3 ff ff jmp 80106fd1 + +80107bfb : +.globl vector187 +vector187: + pushl $0 +80107bfb: 6a 00 push $0x0 + pushl $187 +80107bfd: 68 bb 00 00 00 push $0xbb + jmp alltraps +80107c02: e9 ca f3 ff ff jmp 80106fd1 + +80107c07 : +.globl vector188 +vector188: + pushl $0 +80107c07: 6a 00 push $0x0 + pushl $188 +80107c09: 68 bc 00 00 00 push $0xbc + jmp alltraps +80107c0e: e9 be f3 ff ff jmp 80106fd1 + +80107c13 : +.globl vector189 +vector189: + pushl $0 +80107c13: 6a 00 push $0x0 + pushl $189 +80107c15: 68 bd 00 00 00 push $0xbd + jmp alltraps +80107c1a: e9 b2 f3 ff ff jmp 80106fd1 + +80107c1f : +.globl vector190 +vector190: + pushl $0 +80107c1f: 6a 00 push $0x0 + pushl $190 +80107c21: 68 be 00 00 00 push $0xbe + jmp alltraps +80107c26: e9 a6 f3 ff ff jmp 80106fd1 + +80107c2b : +.globl vector191 +vector191: + pushl $0 +80107c2b: 6a 00 push $0x0 + pushl $191 +80107c2d: 68 bf 00 00 00 push $0xbf + jmp alltraps +80107c32: e9 9a f3 ff ff jmp 80106fd1 + +80107c37 : +.globl vector192 +vector192: + pushl $0 +80107c37: 6a 00 push $0x0 + pushl $192 +80107c39: 68 c0 00 00 00 push $0xc0 + jmp alltraps +80107c3e: e9 8e f3 ff ff jmp 80106fd1 + +80107c43 : +.globl vector193 +vector193: + pushl $0 +80107c43: 6a 00 push $0x0 + pushl $193 +80107c45: 68 c1 00 00 00 push $0xc1 + jmp alltraps +80107c4a: e9 82 f3 ff ff jmp 80106fd1 + +80107c4f : +.globl vector194 +vector194: + pushl $0 +80107c4f: 6a 00 push $0x0 + pushl $194 +80107c51: 68 c2 00 00 00 push $0xc2 + jmp alltraps +80107c56: e9 76 f3 ff ff jmp 80106fd1 + +80107c5b : +.globl vector195 +vector195: + pushl $0 +80107c5b: 6a 00 push $0x0 + pushl $195 +80107c5d: 68 c3 00 00 00 push $0xc3 + jmp alltraps +80107c62: e9 6a f3 ff ff jmp 80106fd1 + +80107c67 : +.globl vector196 +vector196: + pushl $0 +80107c67: 6a 00 push $0x0 + pushl $196 +80107c69: 68 c4 00 00 00 push $0xc4 + jmp alltraps +80107c6e: e9 5e f3 ff ff jmp 80106fd1 + +80107c73 : +.globl vector197 +vector197: + pushl $0 +80107c73: 6a 00 push $0x0 + pushl $197 +80107c75: 68 c5 00 00 00 push $0xc5 + jmp alltraps +80107c7a: e9 52 f3 ff ff jmp 80106fd1 + +80107c7f : +.globl vector198 +vector198: + pushl $0 +80107c7f: 6a 00 push $0x0 + pushl $198 +80107c81: 68 c6 00 00 00 push $0xc6 + jmp alltraps +80107c86: e9 46 f3 ff ff jmp 80106fd1 + +80107c8b : +.globl vector199 +vector199: + pushl $0 +80107c8b: 6a 00 push $0x0 + pushl $199 +80107c8d: 68 c7 00 00 00 push $0xc7 + jmp alltraps +80107c92: e9 3a f3 ff ff jmp 80106fd1 + +80107c97 : +.globl vector200 +vector200: + pushl $0 +80107c97: 6a 00 push $0x0 + pushl $200 +80107c99: 68 c8 00 00 00 push $0xc8 + jmp alltraps +80107c9e: e9 2e f3 ff ff jmp 80106fd1 + +80107ca3 : +.globl vector201 +vector201: + pushl $0 +80107ca3: 6a 00 push $0x0 + pushl $201 +80107ca5: 68 c9 00 00 00 push $0xc9 + jmp alltraps +80107caa: e9 22 f3 ff ff jmp 80106fd1 + +80107caf : +.globl vector202 +vector202: + pushl $0 +80107caf: 6a 00 push $0x0 + pushl $202 +80107cb1: 68 ca 00 00 00 push $0xca + jmp alltraps +80107cb6: e9 16 f3 ff ff jmp 80106fd1 + +80107cbb : +.globl vector203 +vector203: + pushl $0 +80107cbb: 6a 00 push $0x0 + pushl $203 +80107cbd: 68 cb 00 00 00 push $0xcb + jmp alltraps +80107cc2: e9 0a f3 ff ff jmp 80106fd1 + +80107cc7 : +.globl vector204 +vector204: + pushl $0 +80107cc7: 6a 00 push $0x0 + pushl $204 +80107cc9: 68 cc 00 00 00 push $0xcc + jmp alltraps +80107cce: e9 fe f2 ff ff jmp 80106fd1 + +80107cd3 : +.globl vector205 +vector205: + pushl $0 +80107cd3: 6a 00 push $0x0 + pushl $205 +80107cd5: 68 cd 00 00 00 push $0xcd + jmp alltraps +80107cda: e9 f2 f2 ff ff jmp 80106fd1 + +80107cdf : +.globl vector206 +vector206: + pushl $0 +80107cdf: 6a 00 push $0x0 + pushl $206 +80107ce1: 68 ce 00 00 00 push $0xce + jmp alltraps +80107ce6: e9 e6 f2 ff ff jmp 80106fd1 + +80107ceb : +.globl vector207 +vector207: + pushl $0 +80107ceb: 6a 00 push $0x0 + pushl $207 +80107ced: 68 cf 00 00 00 push $0xcf + jmp alltraps +80107cf2: e9 da f2 ff ff jmp 80106fd1 + +80107cf7 : +.globl vector208 +vector208: + pushl $0 +80107cf7: 6a 00 push $0x0 + pushl $208 +80107cf9: 68 d0 00 00 00 push $0xd0 + jmp alltraps +80107cfe: e9 ce f2 ff ff jmp 80106fd1 + +80107d03 : +.globl vector209 +vector209: + pushl $0 +80107d03: 6a 00 push $0x0 + pushl $209 +80107d05: 68 d1 00 00 00 push $0xd1 + jmp alltraps +80107d0a: e9 c2 f2 ff ff jmp 80106fd1 + +80107d0f : +.globl vector210 +vector210: + pushl $0 +80107d0f: 6a 00 push $0x0 + pushl $210 +80107d11: 68 d2 00 00 00 push $0xd2 + jmp alltraps +80107d16: e9 b6 f2 ff ff jmp 80106fd1 + +80107d1b : +.globl vector211 +vector211: + pushl $0 +80107d1b: 6a 00 push $0x0 + pushl $211 +80107d1d: 68 d3 00 00 00 push $0xd3 + jmp alltraps +80107d22: e9 aa f2 ff ff jmp 80106fd1 + +80107d27 : +.globl vector212 +vector212: + pushl $0 +80107d27: 6a 00 push $0x0 + pushl $212 +80107d29: 68 d4 00 00 00 push $0xd4 + jmp alltraps +80107d2e: e9 9e f2 ff ff jmp 80106fd1 + +80107d33 : +.globl vector213 +vector213: + pushl $0 +80107d33: 6a 00 push $0x0 + pushl $213 +80107d35: 68 d5 00 00 00 push $0xd5 + jmp alltraps +80107d3a: e9 92 f2 ff ff jmp 80106fd1 + +80107d3f : +.globl vector214 +vector214: + pushl $0 +80107d3f: 6a 00 push $0x0 + pushl $214 +80107d41: 68 d6 00 00 00 push $0xd6 + jmp alltraps +80107d46: e9 86 f2 ff ff jmp 80106fd1 + +80107d4b : +.globl vector215 +vector215: + pushl $0 +80107d4b: 6a 00 push $0x0 + pushl $215 +80107d4d: 68 d7 00 00 00 push $0xd7 + jmp alltraps +80107d52: e9 7a f2 ff ff jmp 80106fd1 + +80107d57 : +.globl vector216 +vector216: + pushl $0 +80107d57: 6a 00 push $0x0 + pushl $216 +80107d59: 68 d8 00 00 00 push $0xd8 + jmp alltraps +80107d5e: e9 6e f2 ff ff jmp 80106fd1 + +80107d63 : +.globl vector217 +vector217: + pushl $0 +80107d63: 6a 00 push $0x0 + pushl $217 +80107d65: 68 d9 00 00 00 push $0xd9 + jmp alltraps +80107d6a: e9 62 f2 ff ff jmp 80106fd1 + +80107d6f : +.globl vector218 +vector218: + pushl $0 +80107d6f: 6a 00 push $0x0 + pushl $218 +80107d71: 68 da 00 00 00 push $0xda + jmp alltraps +80107d76: e9 56 f2 ff ff jmp 80106fd1 + +80107d7b : +.globl vector219 +vector219: + pushl $0 +80107d7b: 6a 00 push $0x0 + pushl $219 +80107d7d: 68 db 00 00 00 push $0xdb + jmp alltraps +80107d82: e9 4a f2 ff ff jmp 80106fd1 + +80107d87 : +.globl vector220 +vector220: + pushl $0 +80107d87: 6a 00 push $0x0 + pushl $220 +80107d89: 68 dc 00 00 00 push $0xdc + jmp alltraps +80107d8e: e9 3e f2 ff ff jmp 80106fd1 + +80107d93 : +.globl vector221 +vector221: + pushl $0 +80107d93: 6a 00 push $0x0 + pushl $221 +80107d95: 68 dd 00 00 00 push $0xdd + jmp alltraps +80107d9a: e9 32 f2 ff ff jmp 80106fd1 + +80107d9f : +.globl vector222 +vector222: + pushl $0 +80107d9f: 6a 00 push $0x0 + pushl $222 +80107da1: 68 de 00 00 00 push $0xde + jmp alltraps +80107da6: e9 26 f2 ff ff jmp 80106fd1 + +80107dab : +.globl vector223 +vector223: + pushl $0 +80107dab: 6a 00 push $0x0 + pushl $223 +80107dad: 68 df 00 00 00 push $0xdf + jmp alltraps +80107db2: e9 1a f2 ff ff jmp 80106fd1 + +80107db7 : +.globl vector224 +vector224: + pushl $0 +80107db7: 6a 00 push $0x0 + pushl $224 +80107db9: 68 e0 00 00 00 push $0xe0 + jmp alltraps +80107dbe: e9 0e f2 ff ff jmp 80106fd1 + +80107dc3 : +.globl vector225 +vector225: + pushl $0 +80107dc3: 6a 00 push $0x0 + pushl $225 +80107dc5: 68 e1 00 00 00 push $0xe1 + jmp alltraps +80107dca: e9 02 f2 ff ff jmp 80106fd1 + +80107dcf : +.globl vector226 +vector226: + pushl $0 +80107dcf: 6a 00 push $0x0 + pushl $226 +80107dd1: 68 e2 00 00 00 push $0xe2 + jmp alltraps +80107dd6: e9 f6 f1 ff ff jmp 80106fd1 + +80107ddb : +.globl vector227 +vector227: + pushl $0 +80107ddb: 6a 00 push $0x0 + pushl $227 +80107ddd: 68 e3 00 00 00 push $0xe3 + jmp alltraps +80107de2: e9 ea f1 ff ff jmp 80106fd1 + +80107de7 : +.globl vector228 +vector228: + pushl $0 +80107de7: 6a 00 push $0x0 + pushl $228 +80107de9: 68 e4 00 00 00 push $0xe4 + jmp alltraps +80107dee: e9 de f1 ff ff jmp 80106fd1 + +80107df3 : +.globl vector229 +vector229: + pushl $0 +80107df3: 6a 00 push $0x0 + pushl $229 +80107df5: 68 e5 00 00 00 push $0xe5 + jmp alltraps +80107dfa: e9 d2 f1 ff ff jmp 80106fd1 + +80107dff : +.globl vector230 +vector230: + pushl $0 +80107dff: 6a 00 push $0x0 + pushl $230 +80107e01: 68 e6 00 00 00 push $0xe6 + jmp alltraps +80107e06: e9 c6 f1 ff ff jmp 80106fd1 + +80107e0b : +.globl vector231 +vector231: + pushl $0 +80107e0b: 6a 00 push $0x0 + pushl $231 +80107e0d: 68 e7 00 00 00 push $0xe7 + jmp alltraps +80107e12: e9 ba f1 ff ff jmp 80106fd1 + +80107e17 : +.globl vector232 +vector232: + pushl $0 +80107e17: 6a 00 push $0x0 + pushl $232 +80107e19: 68 e8 00 00 00 push $0xe8 + jmp alltraps +80107e1e: e9 ae f1 ff ff jmp 80106fd1 + +80107e23 : +.globl vector233 +vector233: + pushl $0 +80107e23: 6a 00 push $0x0 + pushl $233 +80107e25: 68 e9 00 00 00 push $0xe9 + jmp alltraps +80107e2a: e9 a2 f1 ff ff jmp 80106fd1 + +80107e2f : +.globl vector234 +vector234: + pushl $0 +80107e2f: 6a 00 push $0x0 + pushl $234 +80107e31: 68 ea 00 00 00 push $0xea + jmp alltraps +80107e36: e9 96 f1 ff ff jmp 80106fd1 + +80107e3b : +.globl vector235 +vector235: + pushl $0 +80107e3b: 6a 00 push $0x0 + pushl $235 +80107e3d: 68 eb 00 00 00 push $0xeb + jmp alltraps +80107e42: e9 8a f1 ff ff jmp 80106fd1 + +80107e47 : +.globl vector236 +vector236: + pushl $0 +80107e47: 6a 00 push $0x0 + pushl $236 +80107e49: 68 ec 00 00 00 push $0xec + jmp alltraps +80107e4e: e9 7e f1 ff ff jmp 80106fd1 + +80107e53 : +.globl vector237 +vector237: + pushl $0 +80107e53: 6a 00 push $0x0 + pushl $237 +80107e55: 68 ed 00 00 00 push $0xed + jmp alltraps +80107e5a: e9 72 f1 ff ff jmp 80106fd1 + +80107e5f : +.globl vector238 +vector238: + pushl $0 +80107e5f: 6a 00 push $0x0 + pushl $238 +80107e61: 68 ee 00 00 00 push $0xee + jmp alltraps +80107e66: e9 66 f1 ff ff jmp 80106fd1 + +80107e6b : +.globl vector239 +vector239: + pushl $0 +80107e6b: 6a 00 push $0x0 + pushl $239 +80107e6d: 68 ef 00 00 00 push $0xef + jmp alltraps +80107e72: e9 5a f1 ff ff jmp 80106fd1 + +80107e77 : +.globl vector240 +vector240: + pushl $0 +80107e77: 6a 00 push $0x0 + pushl $240 +80107e79: 68 f0 00 00 00 push $0xf0 + jmp alltraps +80107e7e: e9 4e f1 ff ff jmp 80106fd1 + +80107e83 : +.globl vector241 +vector241: + pushl $0 +80107e83: 6a 00 push $0x0 + pushl $241 +80107e85: 68 f1 00 00 00 push $0xf1 + jmp alltraps +80107e8a: e9 42 f1 ff ff jmp 80106fd1 + +80107e8f : +.globl vector242 +vector242: + pushl $0 +80107e8f: 6a 00 push $0x0 + pushl $242 +80107e91: 68 f2 00 00 00 push $0xf2 + jmp alltraps +80107e96: e9 36 f1 ff ff jmp 80106fd1 + +80107e9b : +.globl vector243 +vector243: + pushl $0 +80107e9b: 6a 00 push $0x0 + pushl $243 +80107e9d: 68 f3 00 00 00 push $0xf3 + jmp alltraps +80107ea2: e9 2a f1 ff ff jmp 80106fd1 + +80107ea7 : +.globl vector244 +vector244: + pushl $0 +80107ea7: 6a 00 push $0x0 + pushl $244 +80107ea9: 68 f4 00 00 00 push $0xf4 + jmp alltraps +80107eae: e9 1e f1 ff ff jmp 80106fd1 + +80107eb3 : +.globl vector245 +vector245: + pushl $0 +80107eb3: 6a 00 push $0x0 + pushl $245 +80107eb5: 68 f5 00 00 00 push $0xf5 + jmp alltraps +80107eba: e9 12 f1 ff ff jmp 80106fd1 + +80107ebf : +.globl vector246 +vector246: + pushl $0 +80107ebf: 6a 00 push $0x0 + pushl $246 +80107ec1: 68 f6 00 00 00 push $0xf6 + jmp alltraps +80107ec6: e9 06 f1 ff ff jmp 80106fd1 + +80107ecb : +.globl vector247 +vector247: + pushl $0 +80107ecb: 6a 00 push $0x0 + pushl $247 +80107ecd: 68 f7 00 00 00 push $0xf7 + jmp alltraps +80107ed2: e9 fa f0 ff ff jmp 80106fd1 + +80107ed7 : +.globl vector248 +vector248: + pushl $0 +80107ed7: 6a 00 push $0x0 + pushl $248 +80107ed9: 68 f8 00 00 00 push $0xf8 + jmp alltraps +80107ede: e9 ee f0 ff ff jmp 80106fd1 + +80107ee3 : +.globl vector249 +vector249: + pushl $0 +80107ee3: 6a 00 push $0x0 + pushl $249 +80107ee5: 68 f9 00 00 00 push $0xf9 + jmp alltraps +80107eea: e9 e2 f0 ff ff jmp 80106fd1 + +80107eef : +.globl vector250 +vector250: + pushl $0 +80107eef: 6a 00 push $0x0 + pushl $250 +80107ef1: 68 fa 00 00 00 push $0xfa + jmp alltraps +80107ef6: e9 d6 f0 ff ff jmp 80106fd1 + +80107efb : +.globl vector251 +vector251: + pushl $0 +80107efb: 6a 00 push $0x0 + pushl $251 +80107efd: 68 fb 00 00 00 push $0xfb + jmp alltraps +80107f02: e9 ca f0 ff ff jmp 80106fd1 + +80107f07 : +.globl vector252 +vector252: + pushl $0 +80107f07: 6a 00 push $0x0 + pushl $252 +80107f09: 68 fc 00 00 00 push $0xfc + jmp alltraps +80107f0e: e9 be f0 ff ff jmp 80106fd1 + +80107f13 : +.globl vector253 +vector253: + pushl $0 +80107f13: 6a 00 push $0x0 + pushl $253 +80107f15: 68 fd 00 00 00 push $0xfd + jmp alltraps +80107f1a: e9 b2 f0 ff ff jmp 80106fd1 + +80107f1f : +.globl vector254 +vector254: + pushl $0 +80107f1f: 6a 00 push $0x0 + pushl $254 +80107f21: 68 fe 00 00 00 push $0xfe + jmp alltraps +80107f26: e9 a6 f0 ff ff jmp 80106fd1 + +80107f2b : +.globl vector255 +vector255: + pushl $0 +80107f2b: 6a 00 push $0x0 + pushl $255 +80107f2d: 68 ff 00 00 00 push $0xff + jmp alltraps +80107f32: e9 9a f0 ff ff jmp 80106fd1 +80107f37: 66 90 xchg %ax,%ax +80107f39: 66 90 xchg %ax,%ax +80107f3b: 66 90 xchg %ax,%ax +80107f3d: 66 90 xchg %ax,%ax +80107f3f: 90 nop + +80107f40 : + +// Deallocate user pages to bring the process size from oldsz to +// newsz. oldsz and newsz need not be page-aligned, nor does newsz +// need to be less than oldsz. oldsz can be larger than the actual +// process size. Returns the new process size. +int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { +80107f40: 55 push %ebp +80107f41: 89 e5 mov %esp,%ebp +80107f43: 57 push %edi +80107f44: 56 push %esi +80107f45: 53 push %ebx + + if (newsz >= oldsz) { + return oldsz; + } + + a = PGROUNDUP(newsz); +80107f46: 8d 99 ff 0f 00 00 lea 0xfff(%ecx),%ebx +80107f4c: 81 e3 00 f0 ff ff and $0xfffff000,%ebx +int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { +80107f52: 83 ec 1c sub $0x1c,%esp +80107f55: 89 4d e0 mov %ecx,-0x20(%ebp) + for (; a < oldsz; a += PGSIZE) { +80107f58: 39 d3 cmp %edx,%ebx +80107f5a: 73 49 jae 80107fa5 +80107f5c: 89 c7 mov %eax,%edi +80107f5e: eb 0c jmp 80107f6c + pte = walkpgdir(pgdir, (char*)a, 0); + if (!pte) { + a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; +80107f60: 83 c0 01 add $0x1,%eax +80107f63: c1 e0 16 shl $0x16,%eax +80107f66: 89 c3 mov %eax,%ebx + for (; a < oldsz; a += PGSIZE) { +80107f68: 39 da cmp %ebx,%edx +80107f6a: 76 39 jbe 80107fa5 + pde = &pgdir[PDX(va)]; +80107f6c: 89 d8 mov %ebx,%eax +80107f6e: c1 e8 16 shr $0x16,%eax + if (*pde & PTE_P) { +80107f71: 8b 0c 87 mov (%edi,%eax,4),%ecx +80107f74: f6 c1 01 test $0x1,%cl +80107f77: 74 e7 je 80107f60 + return &pgtab[PTX(va)]; +80107f79: 89 de mov %ebx,%esi + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +80107f7b: 81 e1 00 f0 ff ff and $0xfffff000,%ecx + return &pgtab[PTX(va)]; +80107f81: c1 ee 0a shr $0xa,%esi +80107f84: 81 e6 fc 0f 00 00 and $0xffc,%esi +80107f8a: 8d b4 31 00 00 00 80 lea -0x80000000(%ecx,%esi,1),%esi + if (!pte) { +80107f91: 85 f6 test %esi,%esi +80107f93: 74 cb je 80107f60 + } + else if ((*pte & PTE_P) != 0) { +80107f95: 8b 06 mov (%esi),%eax +80107f97: a8 01 test $0x1,%al +80107f99: 75 15 jne 80107fb0 + for (; a < oldsz; a += PGSIZE) { +80107f9b: 81 c3 00 10 00 00 add $0x1000,%ebx +80107fa1: 39 da cmp %ebx,%edx +80107fa3: 77 c7 ja 80107f6c + kfree(v); + *pte = 0; + } + } + return newsz; +} +80107fa5: 8b 45 e0 mov -0x20(%ebp),%eax +80107fa8: 8d 65 f4 lea -0xc(%ebp),%esp +80107fab: 5b pop %ebx +80107fac: 5e pop %esi +80107fad: 5f pop %edi +80107fae: 5d pop %ebp +80107faf: c3 ret + if (pa == 0) { +80107fb0: 25 00 f0 ff ff and $0xfffff000,%eax +80107fb5: 74 25 je 80107fdc + kfree(v); +80107fb7: 83 ec 0c sub $0xc,%esp + char *v = P2V(pa); +80107fba: 05 00 00 00 80 add $0x80000000,%eax +80107fbf: 89 55 e4 mov %edx,-0x1c(%ebp) + for (; a < oldsz; a += PGSIZE) { +80107fc2: 81 c3 00 10 00 00 add $0x1000,%ebx + kfree(v); +80107fc8: 50 push %eax +80107fc9: e8 e2 b9 ff ff call 801039b0 + *pte = 0; +80107fce: c7 06 00 00 00 00 movl $0x0,(%esi) + for (; a < oldsz; a += PGSIZE) { +80107fd4: 8b 55 e4 mov -0x1c(%ebp),%edx +80107fd7: 83 c4 10 add $0x10,%esp +80107fda: eb 8c jmp 80107f68 + panic("kfree"); +80107fdc: 83 ec 0c sub $0xc,%esp +80107fdf: 68 86 8c 10 80 push $0x80108c86 +80107fe4: e8 97 84 ff ff call 80100480 +80107fe9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80107ff0 : +static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { +80107ff0: 55 push %ebp +80107ff1: 89 e5 mov %esp,%ebp +80107ff3: 57 push %edi +80107ff4: 56 push %esi +80107ff5: 53 push %ebx + a = (char*)PGROUNDDOWN((uint)va); +80107ff6: 89 d3 mov %edx,%ebx +80107ff8: 81 e3 00 f0 ff ff and $0xfffff000,%ebx +static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { +80107ffe: 83 ec 1c sub $0x1c,%esp +80108001: 89 45 e4 mov %eax,-0x1c(%ebp) + last = (char*)PGROUNDDOWN(((uint)va) + size - 1); +80108004: 8d 44 0a ff lea -0x1(%edx,%ecx,1),%eax +80108008: 25 00 f0 ff ff and $0xfffff000,%eax +8010800d: 89 45 dc mov %eax,-0x24(%ebp) +80108010: 8b 45 08 mov 0x8(%ebp),%eax +80108013: 29 d8 sub %ebx,%eax +80108015: 89 45 e0 mov %eax,-0x20(%ebp) +80108018: eb 3d jmp 80108057 +8010801a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return &pgtab[PTX(va)]; +80108020: 89 da mov %ebx,%edx + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +80108022: 25 00 f0 ff ff and $0xfffff000,%eax + return &pgtab[PTX(va)]; +80108027: c1 ea 0a shr $0xa,%edx +8010802a: 81 e2 fc 0f 00 00 and $0xffc,%edx +80108030: 8d 84 10 00 00 00 80 lea -0x80000000(%eax,%edx,1),%eax + if ((pte = walkpgdir(pgdir, a, 1)) == 0) { +80108037: 85 c0 test %eax,%eax +80108039: 74 75 je 801080b0 + if (*pte & PTE_P) { +8010803b: f6 00 01 testb $0x1,(%eax) +8010803e: 0f 85 86 00 00 00 jne 801080ca + *pte = pa | perm | PTE_P; +80108044: 0b 75 0c or 0xc(%ebp),%esi +80108047: 83 ce 01 or $0x1,%esi +8010804a: 89 30 mov %esi,(%eax) + if (a == last) { +8010804c: 3b 5d dc cmp -0x24(%ebp),%ebx +8010804f: 74 6f je 801080c0 + a += PGSIZE; +80108051: 81 c3 00 10 00 00 add $0x1000,%ebx + for (;;) { +80108057: 8b 45 e0 mov -0x20(%ebp),%eax + pde = &pgdir[PDX(va)]; +8010805a: 8b 4d e4 mov -0x1c(%ebp),%ecx +8010805d: 8d 34 18 lea (%eax,%ebx,1),%esi +80108060: 89 d8 mov %ebx,%eax +80108062: c1 e8 16 shr $0x16,%eax +80108065: 8d 3c 81 lea (%ecx,%eax,4),%edi + if (*pde & PTE_P) { +80108068: 8b 07 mov (%edi),%eax +8010806a: a8 01 test $0x1,%al +8010806c: 75 b2 jne 80108020 + if (!alloc || (pgtab = (pte_t*)kalloc()) == 0) { +8010806e: e8 fd ba ff ff call 80103b70 +80108073: 85 c0 test %eax,%eax +80108075: 74 39 je 801080b0 + memset(pgtab, 0, PGSIZE); +80108077: 83 ec 04 sub $0x4,%esp +8010807a: 89 45 d8 mov %eax,-0x28(%ebp) +8010807d: 68 00 10 00 00 push $0x1000 +80108082: 6a 00 push $0x0 +80108084: 50 push %eax +80108085: e8 b6 db ff ff call 80105c40 + *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; +8010808a: 8b 55 d8 mov -0x28(%ebp),%edx + return &pgtab[PTX(va)]; +8010808d: 83 c4 10 add $0x10,%esp + *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; +80108090: 8d 82 00 00 00 80 lea -0x80000000(%edx),%eax +80108096: 83 c8 07 or $0x7,%eax +80108099: 89 07 mov %eax,(%edi) + return &pgtab[PTX(va)]; +8010809b: 89 d8 mov %ebx,%eax +8010809d: c1 e8 0a shr $0xa,%eax +801080a0: 25 fc 0f 00 00 and $0xffc,%eax +801080a5: 01 d0 add %edx,%eax +801080a7: eb 92 jmp 8010803b +801080a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +} +801080b0: 8d 65 f4 lea -0xc(%ebp),%esp + return -1; +801080b3: b8 ff ff ff ff mov $0xffffffff,%eax +} +801080b8: 5b pop %ebx +801080b9: 5e pop %esi +801080ba: 5f pop %edi +801080bb: 5d pop %ebp +801080bc: c3 ret +801080bd: 8d 76 00 lea 0x0(%esi),%esi +801080c0: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; +801080c3: 31 c0 xor %eax,%eax +} +801080c5: 5b pop %ebx +801080c6: 5e pop %esi +801080c7: 5f pop %edi +801080c8: 5d pop %ebp +801080c9: c3 ret + panic("remap"); +801080ca: 83 ec 0c sub $0xc,%esp +801080cd: 68 04 94 10 80 push $0x80109404 +801080d2: e8 a9 83 ff ff call 80100480 +801080d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801080de: 66 90 xchg %ax,%ax + +801080e0 : +void seginit(void) { +801080e0: 55 push %ebp +801080e1: 89 e5 mov %esp,%ebp +801080e3: 83 ec 18 sub $0x18,%esp + c = &cpus[cpuid()]; +801080e6: e8 a5 cd ff ff call 80104e90 + pd[0] = size - 1; +801080eb: ba 2f 00 00 00 mov $0x2f,%edx +801080f0: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax +801080f6: 66 89 55 f2 mov %dx,-0xe(%ebp) + c->gdt[SEG_KCODE] = SEG(STA_X | STA_R, 0, 0xffffffff, 0); +801080fa: c7 80 98 df 11 80 ff movl $0xffff,-0x7fee2068(%eax) +80108101: ff 00 00 +80108104: c7 80 9c df 11 80 00 movl $0xcf9a00,-0x7fee2064(%eax) +8010810b: 9a cf 00 + c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); +8010810e: c7 80 a0 df 11 80 ff movl $0xffff,-0x7fee2060(%eax) +80108115: ff 00 00 +80108118: c7 80 a4 df 11 80 00 movl $0xcf9200,-0x7fee205c(%eax) +8010811f: 92 cf 00 + c->gdt[SEG_UCODE] = SEG(STA_X | STA_R, 0, 0xffffffff, DPL_USER); +80108122: c7 80 a8 df 11 80 ff movl $0xffff,-0x7fee2058(%eax) +80108129: ff 00 00 +8010812c: c7 80 ac df 11 80 00 movl $0xcffa00,-0x7fee2054(%eax) +80108133: fa cf 00 + c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); +80108136: c7 80 b0 df 11 80 ff movl $0xffff,-0x7fee2050(%eax) +8010813d: ff 00 00 +80108140: c7 80 b4 df 11 80 00 movl $0xcff200,-0x7fee204c(%eax) +80108147: f2 cf 00 + lgdt(c->gdt, sizeof(c->gdt)); +8010814a: 05 90 df 11 80 add $0x8011df90,%eax + pd[1] = (uint)p; +8010814f: 66 89 45 f4 mov %ax,-0xc(%ebp) + pd[2] = (uint)p >> 16; +80108153: c1 e8 10 shr $0x10,%eax +80108156: 66 89 45 f6 mov %ax,-0xa(%ebp) + asm volatile ("lgdt (%0)" : : "r" (pd)); +8010815a: 8d 45 f2 lea -0xe(%ebp),%eax +8010815d: 0f 01 10 lgdtl (%eax) +} +80108160: c9 leave +80108161: c3 ret +80108162: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80108169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80108170 : + lcr3(V2P(kpgdir)); // switch to the kernel page table +80108170: a1 44 12 12 80 mov 0x80121244,%eax +80108175: 05 00 00 00 80 add $0x80000000,%eax + return val; +} + +static inline void lcr3(uint val) { + asm volatile ("movl %0,%%cr3" : : "r" (val)); +8010817a: 0f 22 d8 mov %eax,%cr3 +} +8010817d: c3 ret +8010817e: 66 90 xchg %ax,%ax + +80108180 : +void switchuvm(struct proc *p) { +80108180: 55 push %ebp +80108181: 89 e5 mov %esp,%ebp +80108183: 57 push %edi +80108184: 56 push %esi +80108185: 53 push %ebx +80108186: 83 ec 1c sub $0x1c,%esp +80108189: 8b 75 08 mov 0x8(%ebp),%esi + if (p == 0) { +8010818c: 85 f6 test %esi,%esi +8010818e: 0f 84 cb 00 00 00 je 8010825f + if (p->kstack == 0) { +80108194: 8b 46 08 mov 0x8(%esi),%eax +80108197: 85 c0 test %eax,%eax +80108199: 0f 84 da 00 00 00 je 80108279 + if (p->pgdir == 0) { +8010819f: 8b 46 04 mov 0x4(%esi),%eax +801081a2: 85 c0 test %eax,%eax +801081a4: 0f 84 c2 00 00 00 je 8010826c + pushcli(); +801081aa: e8 81 d8 ff ff call 80105a30 + mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, +801081af: e8 7c cc ff ff call 80104e30 +801081b4: 89 c3 mov %eax,%ebx +801081b6: e8 75 cc ff ff call 80104e30 +801081bb: 89 c7 mov %eax,%edi +801081bd: e8 6e cc ff ff call 80104e30 +801081c2: 83 c7 08 add $0x8,%edi +801081c5: 89 45 e4 mov %eax,-0x1c(%ebp) +801081c8: e8 63 cc ff ff call 80104e30 +801081cd: 8b 4d e4 mov -0x1c(%ebp),%ecx +801081d0: ba 67 00 00 00 mov $0x67,%edx +801081d5: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) +801081dc: 83 c0 08 add $0x8,%eax +801081df: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) + mycpu()->ts.iomb = (ushort) 0xFFFF; +801081e6: bf ff ff ff ff mov $0xffffffff,%edi + mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, +801081eb: 83 c1 08 add $0x8,%ecx +801081ee: c1 e8 18 shr $0x18,%eax +801081f1: c1 e9 10 shr $0x10,%ecx +801081f4: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) +801081fa: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx) +80108200: b9 99 40 00 00 mov $0x4099,%ecx +80108205: 66 89 8b 9d 00 00 00 mov %cx,0x9d(%ebx) + mycpu()->ts.ss0 = SEG_KDATA << 3; +8010820c: bb 10 00 00 00 mov $0x10,%ebx + mycpu()->gdt[SEG_TSS].s = 0; +80108211: e8 1a cc ff ff call 80104e30 +80108216: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) + mycpu()->ts.ss0 = SEG_KDATA << 3; +8010821d: e8 0e cc ff ff call 80104e30 +80108222: 66 89 58 10 mov %bx,0x10(%eax) + mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; +80108226: 8b 5e 08 mov 0x8(%esi),%ebx +80108229: 81 c3 00 10 00 00 add $0x1000,%ebx +8010822f: e8 fc cb ff ff call 80104e30 +80108234: 89 58 0c mov %ebx,0xc(%eax) + mycpu()->ts.iomb = (ushort) 0xFFFF; +80108237: e8 f4 cb ff ff call 80104e30 +8010823c: 66 89 78 6e mov %di,0x6e(%eax) + asm volatile ("ltr %0" : : "r" (sel)); +80108240: b8 28 00 00 00 mov $0x28,%eax +80108245: 0f 00 d8 ltr %ax + lcr3(V2P(p->pgdir)); // switch to process's address space +80108248: 8b 46 04 mov 0x4(%esi),%eax +8010824b: 05 00 00 00 80 add $0x80000000,%eax + asm volatile ("movl %0,%%cr3" : : "r" (val)); +80108250: 0f 22 d8 mov %eax,%cr3 +} +80108253: 8d 65 f4 lea -0xc(%ebp),%esp +80108256: 5b pop %ebx +80108257: 5e pop %esi +80108258: 5f pop %edi +80108259: 5d pop %ebp + popcli(); +8010825a: e9 21 d8 ff ff jmp 80105a80 + panic("switchuvm: no process"); +8010825f: 83 ec 0c sub $0xc,%esp +80108262: 68 0a 94 10 80 push $0x8010940a +80108267: e8 14 82 ff ff call 80100480 + panic("switchuvm: no pgdir"); +8010826c: 83 ec 0c sub $0xc,%esp +8010826f: 68 35 94 10 80 push $0x80109435 +80108274: e8 07 82 ff ff call 80100480 + panic("switchuvm: no kstack"); +80108279: 83 ec 0c sub $0xc,%esp +8010827c: 68 20 94 10 80 push $0x80109420 +80108281: e8 fa 81 ff ff call 80100480 +80108286: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010828d: 8d 76 00 lea 0x0(%esi),%esi + +80108290 : +void inituvm(pde_t *pgdir, char *init, uint sz) { +80108290: 55 push %ebp +80108291: 89 e5 mov %esp,%ebp +80108293: 57 push %edi +80108294: 56 push %esi +80108295: 53 push %ebx +80108296: 83 ec 1c sub $0x1c,%esp +80108299: 8b 45 0c mov 0xc(%ebp),%eax +8010829c: 8b 75 10 mov 0x10(%ebp),%esi +8010829f: 8b 7d 08 mov 0x8(%ebp),%edi +801082a2: 89 45 e4 mov %eax,-0x1c(%ebp) + if (sz >= PGSIZE) { +801082a5: 81 fe ff 0f 00 00 cmp $0xfff,%esi +801082ab: 77 4b ja 801082f8 + mem = kalloc(); +801082ad: e8 be b8 ff ff call 80103b70 + memset(mem, 0, PGSIZE); +801082b2: 83 ec 04 sub $0x4,%esp +801082b5: 68 00 10 00 00 push $0x1000 + mem = kalloc(); +801082ba: 89 c3 mov %eax,%ebx + memset(mem, 0, PGSIZE); +801082bc: 6a 00 push $0x0 +801082be: 50 push %eax +801082bf: e8 7c d9 ff ff call 80105c40 + mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W | PTE_U); +801082c4: 58 pop %eax +801082c5: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +801082cb: 5a pop %edx +801082cc: 6a 06 push $0x6 +801082ce: b9 00 10 00 00 mov $0x1000,%ecx +801082d3: 31 d2 xor %edx,%edx +801082d5: 50 push %eax +801082d6: 89 f8 mov %edi,%eax +801082d8: e8 13 fd ff ff call 80107ff0 + memmove(mem, init, sz); +801082dd: 8b 45 e4 mov -0x1c(%ebp),%eax +801082e0: 89 75 10 mov %esi,0x10(%ebp) +801082e3: 83 c4 10 add $0x10,%esp +801082e6: 89 5d 08 mov %ebx,0x8(%ebp) +801082e9: 89 45 0c mov %eax,0xc(%ebp) +} +801082ec: 8d 65 f4 lea -0xc(%ebp),%esp +801082ef: 5b pop %ebx +801082f0: 5e pop %esi +801082f1: 5f pop %edi +801082f2: 5d pop %ebp + memmove(mem, init, sz); +801082f3: e9 e8 d9 ff ff jmp 80105ce0 + panic("inituvm: more than a page"); +801082f8: 83 ec 0c sub $0xc,%esp +801082fb: 68 49 94 10 80 push $0x80109449 +80108300: e8 7b 81 ff ff call 80100480 +80108305: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010830c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80108310 : +int loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz) { +80108310: 55 push %ebp +80108311: 89 e5 mov %esp,%ebp +80108313: 57 push %edi +80108314: 56 push %esi +80108315: 53 push %ebx +80108316: 83 ec 1c sub $0x1c,%esp +80108319: 8b 45 0c mov 0xc(%ebp),%eax +8010831c: 8b 75 18 mov 0x18(%ebp),%esi + if ((uint) addr % PGSIZE != 0) { +8010831f: a9 ff 0f 00 00 test $0xfff,%eax +80108324: 0f 85 bb 00 00 00 jne 801083e5 + for (i = 0; i < sz; i += PGSIZE) { +8010832a: 01 f0 add %esi,%eax +8010832c: 89 f3 mov %esi,%ebx +8010832e: 89 45 e4 mov %eax,-0x1c(%ebp) + if (readi(ip, P2V(pa), offset + i, n) != n) { +80108331: 8b 45 14 mov 0x14(%ebp),%eax +80108334: 01 f0 add %esi,%eax +80108336: 89 45 e0 mov %eax,-0x20(%ebp) + for (i = 0; i < sz; i += PGSIZE) { +80108339: 85 f6 test %esi,%esi +8010833b: 0f 84 87 00 00 00 je 801083c8 +80108341: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + pde = &pgdir[PDX(va)]; +80108348: 8b 45 e4 mov -0x1c(%ebp),%eax + if (*pde & PTE_P) { +8010834b: 8b 4d 08 mov 0x8(%ebp),%ecx +8010834e: 29 d8 sub %ebx,%eax + pde = &pgdir[PDX(va)]; +80108350: 89 c2 mov %eax,%edx +80108352: c1 ea 16 shr $0x16,%edx + if (*pde & PTE_P) { +80108355: 8b 14 91 mov (%ecx,%edx,4),%edx +80108358: f6 c2 01 test $0x1,%dl +8010835b: 75 13 jne 80108370 + panic("loaduvm: address should exist"); +8010835d: 83 ec 0c sub $0xc,%esp +80108360: 68 63 94 10 80 push $0x80109463 +80108365: e8 16 81 ff ff call 80100480 +8010836a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return &pgtab[PTX(va)]; +80108370: c1 e8 0a shr $0xa,%eax + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +80108373: 81 e2 00 f0 ff ff and $0xfffff000,%edx + return &pgtab[PTX(va)]; +80108379: 25 fc 0f 00 00 and $0xffc,%eax +8010837e: 8d 84 02 00 00 00 80 lea -0x80000000(%edx,%eax,1),%eax + if ((pte = walkpgdir(pgdir, addr + i, 0)) == 0) { +80108385: 85 c0 test %eax,%eax +80108387: 74 d4 je 8010835d + pa = PTE_ADDR(*pte); +80108389: 8b 00 mov (%eax),%eax + if (readi(ip, P2V(pa), offset + i, n) != n) { +8010838b: 8b 4d e0 mov -0x20(%ebp),%ecx + if (sz - i < PGSIZE) { +8010838e: bf 00 10 00 00 mov $0x1000,%edi + pa = PTE_ADDR(*pte); +80108393: 25 00 f0 ff ff and $0xfffff000,%eax + if (sz - i < PGSIZE) { +80108398: 81 fb ff 0f 00 00 cmp $0xfff,%ebx +8010839e: 0f 46 fb cmovbe %ebx,%edi + if (readi(ip, P2V(pa), offset + i, n) != n) { +801083a1: 29 d9 sub %ebx,%ecx +801083a3: 05 00 00 00 80 add $0x80000000,%eax +801083a8: 57 push %edi +801083a9: 51 push %ecx +801083aa: 50 push %eax +801083ab: ff 75 10 push 0x10(%ebp) +801083ae: e8 cd ab ff ff call 80102f80 +801083b3: 83 c4 10 add $0x10,%esp +801083b6: 39 f8 cmp %edi,%eax +801083b8: 75 1e jne 801083d8 + for (i = 0; i < sz; i += PGSIZE) { +801083ba: 81 eb 00 10 00 00 sub $0x1000,%ebx +801083c0: 89 f0 mov %esi,%eax +801083c2: 29 d8 sub %ebx,%eax +801083c4: 39 c6 cmp %eax,%esi +801083c6: 77 80 ja 80108348 +} +801083c8: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; +801083cb: 31 c0 xor %eax,%eax +} +801083cd: 5b pop %ebx +801083ce: 5e pop %esi +801083cf: 5f pop %edi +801083d0: 5d pop %ebp +801083d1: c3 ret +801083d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801083d8: 8d 65 f4 lea -0xc(%ebp),%esp + return -1; +801083db: b8 ff ff ff ff mov $0xffffffff,%eax +} +801083e0: 5b pop %ebx +801083e1: 5e pop %esi +801083e2: 5f pop %edi +801083e3: 5d pop %ebp +801083e4: c3 ret + panic("loaduvm: addr must be page aligned"); +801083e5: 83 ec 0c sub $0xc,%esp +801083e8: 68 04 95 10 80 push $0x80109504 +801083ed: e8 8e 80 ff ff call 80100480 +801083f2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801083f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80108400 : +int allocuvm(pde_t *pgdir, uint oldsz, uint newsz) { +80108400: 55 push %ebp +80108401: 89 e5 mov %esp,%ebp +80108403: 57 push %edi +80108404: 56 push %esi +80108405: 53 push %ebx +80108406: 83 ec 1c sub $0x1c,%esp + if (newsz >= KERNBASE) { +80108409: 8b 45 10 mov 0x10(%ebp),%eax +int allocuvm(pde_t *pgdir, uint oldsz, uint newsz) { +8010840c: 8b 7d 08 mov 0x8(%ebp),%edi + if (newsz >= KERNBASE) { +8010840f: 89 45 e4 mov %eax,-0x1c(%ebp) +80108412: 85 c0 test %eax,%eax +80108414: 0f 88 b6 00 00 00 js 801084d0 + if (newsz < oldsz) { +8010841a: 3b 45 0c cmp 0xc(%ebp),%eax + return oldsz; +8010841d: 8b 45 0c mov 0xc(%ebp),%eax + if (newsz < oldsz) { +80108420: 0f 82 9a 00 00 00 jb 801084c0 + a = PGROUNDUP(oldsz); +80108426: 8d b0 ff 0f 00 00 lea 0xfff(%eax),%esi +8010842c: 81 e6 00 f0 ff ff and $0xfffff000,%esi + for (; a < newsz; a += PGSIZE) { +80108432: 39 75 10 cmp %esi,0x10(%ebp) +80108435: 77 44 ja 8010847b +80108437: e9 87 00 00 00 jmp 801084c3 +8010843c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + memset(mem, 0, PGSIZE); +80108440: 83 ec 04 sub $0x4,%esp +80108443: 68 00 10 00 00 push $0x1000 +80108448: 6a 00 push $0x0 +8010844a: 50 push %eax +8010844b: e8 f0 d7 ff ff call 80105c40 + if (mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W | PTE_U) < 0) { +80108450: 58 pop %eax +80108451: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +80108457: 5a pop %edx +80108458: 6a 06 push $0x6 +8010845a: b9 00 10 00 00 mov $0x1000,%ecx +8010845f: 89 f2 mov %esi,%edx +80108461: 50 push %eax +80108462: 89 f8 mov %edi,%eax +80108464: e8 87 fb ff ff call 80107ff0 +80108469: 83 c4 10 add $0x10,%esp +8010846c: 85 c0 test %eax,%eax +8010846e: 78 78 js 801084e8 + for (; a < newsz; a += PGSIZE) { +80108470: 81 c6 00 10 00 00 add $0x1000,%esi +80108476: 39 75 10 cmp %esi,0x10(%ebp) +80108479: 76 48 jbe 801084c3 + mem = kalloc(); +8010847b: e8 f0 b6 ff ff call 80103b70 +80108480: 89 c3 mov %eax,%ebx + if (mem == 0) { +80108482: 85 c0 test %eax,%eax +80108484: 75 ba jne 80108440 + cprintf("allocuvm out of memory\n"); +80108486: 83 ec 0c sub $0xc,%esp +80108489: 68 81 94 10 80 push $0x80109481 +8010848e: e8 fd 83 ff ff call 80100890 + if (newsz >= oldsz) { +80108493: 8b 45 0c mov 0xc(%ebp),%eax +80108496: 83 c4 10 add $0x10,%esp +80108499: 39 45 10 cmp %eax,0x10(%ebp) +8010849c: 74 32 je 801084d0 +8010849e: 8b 55 10 mov 0x10(%ebp),%edx +801084a1: 89 c1 mov %eax,%ecx +801084a3: 89 f8 mov %edi,%eax +801084a5: e8 96 fa ff ff call 80107f40 + return 0; +801084aa: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +} +801084b1: 8b 45 e4 mov -0x1c(%ebp),%eax +801084b4: 8d 65 f4 lea -0xc(%ebp),%esp +801084b7: 5b pop %ebx +801084b8: 5e pop %esi +801084b9: 5f pop %edi +801084ba: 5d pop %ebp +801084bb: c3 ret +801084bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return oldsz; +801084c0: 89 45 e4 mov %eax,-0x1c(%ebp) +} +801084c3: 8b 45 e4 mov -0x1c(%ebp),%eax +801084c6: 8d 65 f4 lea -0xc(%ebp),%esp +801084c9: 5b pop %ebx +801084ca: 5e pop %esi +801084cb: 5f pop %edi +801084cc: 5d pop %ebp +801084cd: c3 ret +801084ce: 66 90 xchg %ax,%ax + return 0; +801084d0: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +} +801084d7: 8b 45 e4 mov -0x1c(%ebp),%eax +801084da: 8d 65 f4 lea -0xc(%ebp),%esp +801084dd: 5b pop %ebx +801084de: 5e pop %esi +801084df: 5f pop %edi +801084e0: 5d pop %ebp +801084e1: c3 ret +801084e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + cprintf("allocuvm out of memory (2)\n"); +801084e8: 83 ec 0c sub $0xc,%esp +801084eb: 68 99 94 10 80 push $0x80109499 +801084f0: e8 9b 83 ff ff call 80100890 + if (newsz >= oldsz) { +801084f5: 8b 45 0c mov 0xc(%ebp),%eax +801084f8: 83 c4 10 add $0x10,%esp +801084fb: 39 45 10 cmp %eax,0x10(%ebp) +801084fe: 74 0c je 8010850c +80108500: 8b 55 10 mov 0x10(%ebp),%edx +80108503: 89 c1 mov %eax,%ecx +80108505: 89 f8 mov %edi,%eax +80108507: e8 34 fa ff ff call 80107f40 + kfree(mem); +8010850c: 83 ec 0c sub $0xc,%esp +8010850f: 53 push %ebx +80108510: e8 9b b4 ff ff call 801039b0 + return 0; +80108515: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +8010851c: 83 c4 10 add $0x10,%esp +} +8010851f: 8b 45 e4 mov -0x1c(%ebp),%eax +80108522: 8d 65 f4 lea -0xc(%ebp),%esp +80108525: 5b pop %ebx +80108526: 5e pop %esi +80108527: 5f pop %edi +80108528: 5d pop %ebp +80108529: c3 ret +8010852a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80108530 : +int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { +80108530: 55 push %ebp +80108531: 89 e5 mov %esp,%ebp +80108533: 8b 55 0c mov 0xc(%ebp),%edx +80108536: 8b 4d 10 mov 0x10(%ebp),%ecx +80108539: 8b 45 08 mov 0x8(%ebp),%eax + if (newsz >= oldsz) { +8010853c: 39 d1 cmp %edx,%ecx +8010853e: 73 10 jae 80108550 +} +80108540: 5d pop %ebp +80108541: e9 fa f9 ff ff jmp 80107f40 +80108546: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010854d: 8d 76 00 lea 0x0(%esi),%esi +80108550: 89 d0 mov %edx,%eax +80108552: 5d pop %ebp +80108553: c3 ret +80108554: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010855b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010855f: 90 nop + +80108560 : + +// Free a page table and all the physical memory pages +// in the user part. +void freevm(pde_t *pgdir) { +80108560: 55 push %ebp +80108561: 89 e5 mov %esp,%ebp +80108563: 57 push %edi +80108564: 56 push %esi +80108565: 53 push %ebx +80108566: 83 ec 0c sub $0xc,%esp +80108569: 8b 75 08 mov 0x8(%ebp),%esi + uint i; + + if (pgdir == 0) { +8010856c: 85 f6 test %esi,%esi +8010856e: 74 59 je 801085c9 + if (newsz >= oldsz) { +80108570: 31 c9 xor %ecx,%ecx +80108572: ba 00 00 00 80 mov $0x80000000,%edx +80108577: 89 f0 mov %esi,%eax +80108579: 89 f3 mov %esi,%ebx +8010857b: e8 c0 f9 ff ff call 80107f40 + panic("freevm: no pgdir"); + } + deallocuvm(pgdir, KERNBASE, 0); + for (i = 0; i < NPDENTRIES; i++) { +80108580: 8d be 00 10 00 00 lea 0x1000(%esi),%edi +80108586: eb 0f jmp 80108597 +80108588: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010858f: 90 nop +80108590: 83 c3 04 add $0x4,%ebx +80108593: 39 df cmp %ebx,%edi +80108595: 74 23 je 801085ba + if (pgdir[i] & PTE_P) { +80108597: 8b 03 mov (%ebx),%eax +80108599: a8 01 test $0x1,%al +8010859b: 74 f3 je 80108590 + char * v = P2V(PTE_ADDR(pgdir[i])); +8010859d: 25 00 f0 ff ff and $0xfffff000,%eax + kfree(v); +801085a2: 83 ec 0c sub $0xc,%esp + for (i = 0; i < NPDENTRIES; i++) { +801085a5: 83 c3 04 add $0x4,%ebx + char * v = P2V(PTE_ADDR(pgdir[i])); +801085a8: 05 00 00 00 80 add $0x80000000,%eax + kfree(v); +801085ad: 50 push %eax +801085ae: e8 fd b3 ff ff call 801039b0 +801085b3: 83 c4 10 add $0x10,%esp + for (i = 0; i < NPDENTRIES; i++) { +801085b6: 39 df cmp %ebx,%edi +801085b8: 75 dd jne 80108597 + } + } + kfree((char*)pgdir); +801085ba: 89 75 08 mov %esi,0x8(%ebp) +} +801085bd: 8d 65 f4 lea -0xc(%ebp),%esp +801085c0: 5b pop %ebx +801085c1: 5e pop %esi +801085c2: 5f pop %edi +801085c3: 5d pop %ebp + kfree((char*)pgdir); +801085c4: e9 e7 b3 ff ff jmp 801039b0 + panic("freevm: no pgdir"); +801085c9: 83 ec 0c sub $0xc,%esp +801085cc: 68 b5 94 10 80 push $0x801094b5 +801085d1: e8 aa 7e ff ff call 80100480 +801085d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801085dd: 8d 76 00 lea 0x0(%esi),%esi + +801085e0 : +pde_t*setupkvm(void) { +801085e0: 55 push %ebp +801085e1: 89 e5 mov %esp,%ebp +801085e3: 56 push %esi +801085e4: 53 push %ebx + if ((pgdir = (pde_t*)kalloc()) == 0) { +801085e5: e8 86 b5 ff ff call 80103b70 +801085ea: 89 c6 mov %eax,%esi +801085ec: 85 c0 test %eax,%eax +801085ee: 74 42 je 80108632 + memset(pgdir, 0, PGSIZE); +801085f0: 83 ec 04 sub $0x4,%esp + for (k = kmap; k < &kmap[NELEM(kmap)]; k++) { +801085f3: bb 20 c4 10 80 mov $0x8010c420,%ebx + memset(pgdir, 0, PGSIZE); +801085f8: 68 00 10 00 00 push $0x1000 +801085fd: 6a 00 push $0x0 +801085ff: 50 push %eax +80108600: e8 3b d6 ff ff call 80105c40 +80108605: 83 c4 10 add $0x10,%esp + (uint)k->phys_start, k->perm) < 0) { +80108608: 8b 43 04 mov 0x4(%ebx),%eax + if (mappages(pgdir, k->virt, k->phys_end - k->phys_start, +8010860b: 83 ec 08 sub $0x8,%esp +8010860e: 8b 4b 08 mov 0x8(%ebx),%ecx +80108611: ff 73 0c push 0xc(%ebx) +80108614: 8b 13 mov (%ebx),%edx +80108616: 50 push %eax +80108617: 29 c1 sub %eax,%ecx +80108619: 89 f0 mov %esi,%eax +8010861b: e8 d0 f9 ff ff call 80107ff0 +80108620: 83 c4 10 add $0x10,%esp +80108623: 85 c0 test %eax,%eax +80108625: 78 19 js 80108640 + for (k = kmap; k < &kmap[NELEM(kmap)]; k++) { +80108627: 83 c3 10 add $0x10,%ebx +8010862a: 81 fb 60 c4 10 80 cmp $0x8010c460,%ebx +80108630: 75 d6 jne 80108608 +} +80108632: 8d 65 f8 lea -0x8(%ebp),%esp +80108635: 89 f0 mov %esi,%eax +80108637: 5b pop %ebx +80108638: 5e pop %esi +80108639: 5d pop %ebp +8010863a: c3 ret +8010863b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010863f: 90 nop + freevm(pgdir); +80108640: 83 ec 0c sub $0xc,%esp +80108643: 56 push %esi + return 0; +80108644: 31 f6 xor %esi,%esi + freevm(pgdir); +80108646: e8 15 ff ff ff call 80108560 + return 0; +8010864b: 83 c4 10 add $0x10,%esp +} +8010864e: 8d 65 f8 lea -0x8(%ebp),%esp +80108651: 89 f0 mov %esi,%eax +80108653: 5b pop %ebx +80108654: 5e pop %esi +80108655: 5d pop %ebp +80108656: c3 ret +80108657: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010865e: 66 90 xchg %ax,%ax + +80108660 : +void kvmalloc(void) { +80108660: 55 push %ebp +80108661: 89 e5 mov %esp,%ebp +80108663: 83 ec 08 sub $0x8,%esp + kpgdir = setupkvm(); +80108666: e8 75 ff ff ff call 801085e0 +8010866b: a3 44 12 12 80 mov %eax,0x80121244 + lcr3(V2P(kpgdir)); // switch to the kernel page table +80108670: 05 00 00 00 80 add $0x80000000,%eax +80108675: 0f 22 d8 mov %eax,%cr3 +} +80108678: c9 leave +80108679: c3 ret +8010867a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80108680 : + +// Clear PTE_U on a page. Used to create an inaccessible +// page beneath the user stack. +void clearpteu(pde_t *pgdir, char *uva) { +80108680: 55 push %ebp +80108681: 89 e5 mov %esp,%ebp +80108683: 83 ec 08 sub $0x8,%esp +80108686: 8b 45 0c mov 0xc(%ebp),%eax + if (*pde & PTE_P) { +80108689: 8b 55 08 mov 0x8(%ebp),%edx + pde = &pgdir[PDX(va)]; +8010868c: 89 c1 mov %eax,%ecx +8010868e: c1 e9 16 shr $0x16,%ecx + if (*pde & PTE_P) { +80108691: 8b 14 8a mov (%edx,%ecx,4),%edx +80108694: f6 c2 01 test $0x1,%dl +80108697: 75 17 jne 801086b0 + pte_t *pte; + + pte = walkpgdir(pgdir, uva, 0); + if (pte == 0) { + panic("clearpteu"); +80108699: 83 ec 0c sub $0xc,%esp +8010869c: 68 c6 94 10 80 push $0x801094c6 +801086a1: e8 da 7d ff ff call 80100480 +801086a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801086ad: 8d 76 00 lea 0x0(%esi),%esi + return &pgtab[PTX(va)]; +801086b0: c1 e8 0a shr $0xa,%eax + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +801086b3: 81 e2 00 f0 ff ff and $0xfffff000,%edx + return &pgtab[PTX(va)]; +801086b9: 25 fc 0f 00 00 and $0xffc,%eax +801086be: 8d 84 02 00 00 00 80 lea -0x80000000(%edx,%eax,1),%eax + if (pte == 0) { +801086c5: 85 c0 test %eax,%eax +801086c7: 74 d0 je 80108699 + } + *pte &= ~PTE_U; +801086c9: 83 20 fb andl $0xfffffffb,(%eax) +} +801086cc: c9 leave +801086cd: c3 ret +801086ce: 66 90 xchg %ax,%ax + +801086d0 : + +// Given a parent process's page table, create a copy +// of it for a child. +pde_t* copyuvm(pde_t *pgdir, uint sz) { +801086d0: 55 push %ebp +801086d1: 89 e5 mov %esp,%ebp +801086d3: 57 push %edi +801086d4: 56 push %esi +801086d5: 53 push %ebx +801086d6: 83 ec 1c sub $0x1c,%esp + pde_t *d; + pte_t *pte; + uint pa, i, flags; + char *mem; + + if ((d = setupkvm()) == 0) { +801086d9: e8 02 ff ff ff call 801085e0 +801086de: 89 45 e0 mov %eax,-0x20(%ebp) +801086e1: 85 c0 test %eax,%eax +801086e3: 0f 84 bd 00 00 00 je 801087a6 + return 0; + } + for (i = 0; i < sz; i += PGSIZE) { +801086e9: 8b 5d 0c mov 0xc(%ebp),%ebx +801086ec: 85 db test %ebx,%ebx +801086ee: 0f 84 b2 00 00 00 je 801087a6 +801086f4: 31 f6 xor %esi,%esi +801086f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801086fd: 8d 76 00 lea 0x0(%esi),%esi + if (*pde & PTE_P) { +80108700: 8b 4d 08 mov 0x8(%ebp),%ecx + pde = &pgdir[PDX(va)]; +80108703: 89 f0 mov %esi,%eax +80108705: c1 e8 16 shr $0x16,%eax + if (*pde & PTE_P) { +80108708: 8b 04 81 mov (%ecx,%eax,4),%eax +8010870b: a8 01 test $0x1,%al +8010870d: 75 11 jne 80108720 + if ((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) { + panic("copyuvm: pte should exist"); +8010870f: 83 ec 0c sub $0xc,%esp +80108712: 68 d0 94 10 80 push $0x801094d0 +80108717: e8 64 7d ff ff call 80100480 +8010871c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return &pgtab[PTX(va)]; +80108720: 89 f2 mov %esi,%edx + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +80108722: 25 00 f0 ff ff and $0xfffff000,%eax + return &pgtab[PTX(va)]; +80108727: c1 ea 0a shr $0xa,%edx +8010872a: 81 e2 fc 0f 00 00 and $0xffc,%edx +80108730: 8d 84 10 00 00 00 80 lea -0x80000000(%eax,%edx,1),%eax + if ((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) { +80108737: 85 c0 test %eax,%eax +80108739: 74 d4 je 8010870f + } + if (!(*pte & PTE_P)) { +8010873b: 8b 00 mov (%eax),%eax +8010873d: a8 01 test $0x1,%al +8010873f: 0f 84 c2 00 00 00 je 80108807 + panic("copyuvm: page not present"); + } + pa = PTE_ADDR(*pte); +80108745: 89 c7 mov %eax,%edi + flags = PTE_FLAGS(*pte); +80108747: 25 ff 0f 00 00 and $0xfff,%eax +8010874c: 89 45 e4 mov %eax,-0x1c(%ebp) + pa = PTE_ADDR(*pte); +8010874f: 81 e7 00 f0 ff ff and $0xfffff000,%edi + if ((mem = kalloc()) == 0) { +80108755: e8 16 b4 ff ff call 80103b70 +8010875a: 89 c3 mov %eax,%ebx +8010875c: 85 c0 test %eax,%eax +8010875e: 74 58 je 801087b8 + freevm(d); + return 0; + } + memmove(mem, (char*)P2V(pa), PGSIZE); +80108760: 83 ec 04 sub $0x4,%esp +80108763: 81 c7 00 00 00 80 add $0x80000000,%edi +80108769: 68 00 10 00 00 push $0x1000 +8010876e: 57 push %edi +8010876f: 50 push %eax +80108770: e8 6b d5 ff ff call 80105ce0 + if (mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { +80108775: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +8010877b: 5a pop %edx +8010877c: 59 pop %ecx +8010877d: ff 75 e4 push -0x1c(%ebp) +80108780: b9 00 10 00 00 mov $0x1000,%ecx +80108785: 89 f2 mov %esi,%edx +80108787: 50 push %eax +80108788: 8b 45 e0 mov -0x20(%ebp),%eax +8010878b: e8 60 f8 ff ff call 80107ff0 +80108790: 83 c4 10 add $0x10,%esp +80108793: 85 c0 test %eax,%eax +80108795: 78 49 js 801087e0 + for (i = 0; i < sz; i += PGSIZE) { +80108797: 81 c6 00 10 00 00 add $0x1000,%esi +8010879d: 39 75 0c cmp %esi,0xc(%ebp) +801087a0: 0f 87 5a ff ff ff ja 80108700 + freevm(d); + return 0; + } + } + return d; +} +801087a6: 8b 45 e0 mov -0x20(%ebp),%eax +801087a9: 8d 65 f4 lea -0xc(%ebp),%esp +801087ac: 5b pop %ebx +801087ad: 5e pop %esi +801087ae: 5f pop %edi +801087af: 5d pop %ebp +801087b0: c3 ret +801087b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + freevm(d); +801087b8: 83 ec 0c sub $0xc,%esp +801087bb: ff 75 e0 push -0x20(%ebp) +801087be: e8 9d fd ff ff call 80108560 + return 0; +801087c3: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) +801087ca: 83 c4 10 add $0x10,%esp +} +801087cd: 8b 45 e0 mov -0x20(%ebp),%eax +801087d0: 8d 65 f4 lea -0xc(%ebp),%esp +801087d3: 5b pop %ebx +801087d4: 5e pop %esi +801087d5: 5f pop %edi +801087d6: 5d pop %ebp +801087d7: c3 ret +801087d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801087df: 90 nop + kfree(mem); +801087e0: 83 ec 0c sub $0xc,%esp +801087e3: 53 push %ebx +801087e4: e8 c7 b1 ff ff call 801039b0 + freevm(d); +801087e9: 58 pop %eax +801087ea: ff 75 e0 push -0x20(%ebp) +801087ed: e8 6e fd ff ff call 80108560 + return 0; +801087f2: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) +801087f9: 83 c4 10 add $0x10,%esp +} +801087fc: 8b 45 e0 mov -0x20(%ebp),%eax +801087ff: 8d 65 f4 lea -0xc(%ebp),%esp +80108802: 5b pop %ebx +80108803: 5e pop %esi +80108804: 5f pop %edi +80108805: 5d pop %ebp +80108806: c3 ret + panic("copyuvm: page not present"); +80108807: 83 ec 0c sub $0xc,%esp +8010880a: 68 ea 94 10 80 push $0x801094ea +8010880f: e8 6c 7c ff ff call 80100480 +80108814: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010881b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010881f: 90 nop + +80108820 : + + +// Map user virtual address to kernel address. +char*uva2ka(pde_t *pgdir, char *uva) { +80108820: 55 push %ebp +80108821: 89 e5 mov %esp,%ebp +80108823: 8b 45 0c mov 0xc(%ebp),%eax + if (*pde & PTE_P) { +80108826: 8b 55 08 mov 0x8(%ebp),%edx + pde = &pgdir[PDX(va)]; +80108829: 89 c1 mov %eax,%ecx +8010882b: c1 e9 16 shr $0x16,%ecx + if (*pde & PTE_P) { +8010882e: 8b 14 8a mov (%edx,%ecx,4),%edx +80108831: f6 c2 01 test $0x1,%dl +80108834: 0f 84 00 01 00 00 je 8010893a + return &pgtab[PTX(va)]; +8010883a: c1 e8 0c shr $0xc,%eax + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +8010883d: 81 e2 00 f0 ff ff and $0xfffff000,%edx + } + if ((*pte & PTE_U) == 0) { + return 0; + } + return (char*)P2V(PTE_ADDR(*pte)); +} +80108843: 5d pop %ebp + return &pgtab[PTX(va)]; +80108844: 25 ff 03 00 00 and $0x3ff,%eax + if ((*pte & PTE_P) == 0) { +80108849: 8b 84 82 00 00 00 80 mov -0x80000000(%edx,%eax,4),%eax + if ((*pte & PTE_U) == 0) { +80108850: 89 c2 mov %eax,%edx + return (char*)P2V(PTE_ADDR(*pte)); +80108852: 25 00 f0 ff ff and $0xfffff000,%eax + if ((*pte & PTE_U) == 0) { +80108857: 83 e2 05 and $0x5,%edx + return (char*)P2V(PTE_ADDR(*pte)); +8010885a: 05 00 00 00 80 add $0x80000000,%eax +8010885f: 83 fa 05 cmp $0x5,%edx +80108862: ba 00 00 00 00 mov $0x0,%edx +80108867: 0f 45 c2 cmovne %edx,%eax +} +8010886a: c3 ret +8010886b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010886f: 90 nop + +80108870 : + +// Copy len bytes from p to user address va in page table pgdir. +// Most useful when pgdir is not the current page table. +// uva2ka ensures this only works for PTE_U pages. +int copyout(pde_t *pgdir, uint va, void *p, uint len) { +80108870: 55 push %ebp +80108871: 89 e5 mov %esp,%ebp +80108873: 57 push %edi +80108874: 56 push %esi +80108875: 53 push %ebx +80108876: 83 ec 0c sub $0xc,%esp +80108879: 8b 75 14 mov 0x14(%ebp),%esi +8010887c: 8b 45 0c mov 0xc(%ebp),%eax +8010887f: 8b 55 10 mov 0x10(%ebp),%edx + char *buf, *pa0; + uint n, va0; + + buf = (char*)p; + while (len > 0) { +80108882: 85 f6 test %esi,%esi +80108884: 75 51 jne 801088d7 +80108886: e9 a5 00 00 00 jmp 80108930 +8010888b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +8010888f: 90 nop + return (char*)P2V(PTE_ADDR(*pte)); +80108890: 81 e3 00 f0 ff ff and $0xfffff000,%ebx +80108896: 8d 8b 00 00 00 80 lea -0x80000000(%ebx),%ecx + va0 = (uint)PGROUNDDOWN(va); + pa0 = uva2ka(pgdir, (char*)va0); + if (pa0 == 0) { +8010889c: 81 fb 00 00 00 80 cmp $0x80000000,%ebx +801088a2: 74 75 je 80108919 + return -1; + } + n = PGSIZE - (va - va0); +801088a4: 89 fb mov %edi,%ebx + if (n > len) { + n = len; + } + memmove(pa0 + (va - va0), buf, n); +801088a6: 89 55 10 mov %edx,0x10(%ebp) + n = PGSIZE - (va - va0); +801088a9: 29 c3 sub %eax,%ebx +801088ab: 81 c3 00 10 00 00 add $0x1000,%ebx +801088b1: 39 f3 cmp %esi,%ebx +801088b3: 0f 47 de cmova %esi,%ebx + memmove(pa0 + (va - va0), buf, n); +801088b6: 29 f8 sub %edi,%eax +801088b8: 83 ec 04 sub $0x4,%esp +801088bb: 01 c1 add %eax,%ecx +801088bd: 53 push %ebx +801088be: 52 push %edx +801088bf: 51 push %ecx +801088c0: e8 1b d4 ff ff call 80105ce0 + len -= n; + buf += n; +801088c5: 8b 55 10 mov 0x10(%ebp),%edx + va = va0 + PGSIZE; +801088c8: 8d 87 00 10 00 00 lea 0x1000(%edi),%eax + while (len > 0) { +801088ce: 83 c4 10 add $0x10,%esp + buf += n; +801088d1: 01 da add %ebx,%edx + while (len > 0) { +801088d3: 29 de sub %ebx,%esi +801088d5: 74 59 je 80108930 + if (*pde & PTE_P) { +801088d7: 8b 5d 08 mov 0x8(%ebp),%ebx + pde = &pgdir[PDX(va)]; +801088da: 89 c1 mov %eax,%ecx + va0 = (uint)PGROUNDDOWN(va); +801088dc: 89 c7 mov %eax,%edi + pde = &pgdir[PDX(va)]; +801088de: c1 e9 16 shr $0x16,%ecx + va0 = (uint)PGROUNDDOWN(va); +801088e1: 81 e7 00 f0 ff ff and $0xfffff000,%edi + if (*pde & PTE_P) { +801088e7: 8b 0c 8b mov (%ebx,%ecx,4),%ecx +801088ea: f6 c1 01 test $0x1,%cl +801088ed: 0f 84 4e 00 00 00 je 80108941 + return &pgtab[PTX(va)]; +801088f3: 89 fb mov %edi,%ebx + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +801088f5: 81 e1 00 f0 ff ff and $0xfffff000,%ecx + return &pgtab[PTX(va)]; +801088fb: c1 eb 0c shr $0xc,%ebx +801088fe: 81 e3 ff 03 00 00 and $0x3ff,%ebx + if ((*pte & PTE_P) == 0) { +80108904: 8b 9c 99 00 00 00 80 mov -0x80000000(%ecx,%ebx,4),%ebx + if ((*pte & PTE_U) == 0) { +8010890b: 89 d9 mov %ebx,%ecx +8010890d: 83 e1 05 and $0x5,%ecx +80108910: 83 f9 05 cmp $0x5,%ecx +80108913: 0f 84 77 ff ff ff je 80108890 + } + return 0; +} +80108919: 8d 65 f4 lea -0xc(%ebp),%esp + return -1; +8010891c: b8 ff ff ff ff mov $0xffffffff,%eax +} +80108921: 5b pop %ebx +80108922: 5e pop %esi +80108923: 5f pop %edi +80108924: 5d pop %ebp +80108925: c3 ret +80108926: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +8010892d: 8d 76 00 lea 0x0(%esi),%esi +80108930: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; +80108933: 31 c0 xor %eax,%eax +} +80108935: 5b pop %ebx +80108936: 5e pop %esi +80108937: 5f pop %edi +80108938: 5d pop %ebp +80108939: c3 ret + +8010893a : + if ((*pte & PTE_P) == 0) { +8010893a: a1 00 00 00 00 mov 0x0,%eax +8010893f: 0f 0b ud2 + +80108941 : +80108941: a1 00 00 00 00 mov 0x0,%eax +80108946: 0f 0b ud2 diff --git a/kernel.sym b/kernel.sym new file mode 100644 index 0000000..772a28a --- /dev/null +++ b/kernel.sym @@ -0,0 +1,534 @@ +00000000 bio.c +00000000 console.c +80100280 navigatemenu +8011b6c0 currentmenuitem +8011b680 cons +8011b6b8 panicked +80100500 cgaputc +8011b6bc menuactive +80108a90 digits.0 +80100e90 drawtitle +8011b640 vcons +00000000 exec.c +00000000 file.c +00000000 fs.c +801026b0 bfree +80102730 balloc +80102840 iget +80102940 bmap +80103280 namex +00000000 ide.c +801035d0 idestart +8011dd80 idelock +8011dd60 havedisk1 +8011dd64 idequeue +00000000 ioapic.c +00000000 kalloc.c +00000000 kbd.c +8011ddfc shift.1 +80108dc0 shiftcode +80108cc0 togglecode +80108ca0 charcode.0 +8010a200 normalmap +8010a100 shiftmap +8010a000 ctlmap +00000000 lapic.c +00000000 log.c +801040b0 install_trans +80104150 write_head +00000000 main.c +801044f0 mpmain +80104530 mpenter +00000000 mp.c +80104680 mpsearch1 +00000000 picirq.c +00000000 pipe.c +00000000 proc.c +80104ce0 allocproc +8010c000 first.1 +801209d4 initproc +801090d8 states.0 +00000000 sleeplock.c +00000000 spinlock.c +00000000 string.c +00000000 syscall.c +80109160 syscalls +00000000 sysfile.c +801060b0 create +00000000 sysproc.c +00000000 trap.c +00000000 uart.c +80107340 uartgetc +80121240 uart +00000000 vm.c +80107f40 deallocuvm.part.0 +80107ff0 mappages +8010c420 kmap +8010893a uva2ka.cold +80108941 copyout.cold +80100320 consoleread +80107e8f vector242 +801078e6 vector119 +8010000c entry +801077c6 vector87 +801077bd vector86 +80105e00 safestrcpy +801063d0 sys_close +80107efb vector251 +801077ea vector91 +801075e0 vector33 +80107acf vector162 +80105590 yield +8011de20 log +8011ddc0 kmem +80107d33 vector213 +80107883 vector108 +80107370 uartinit +8010763a vector43 +80103e00 lapiceoi +80107af3 vector165 +80107be3 vector185 +801038c0 ioapicinit +801078c2 vector115 +80102510 fileread +80107901 vector122 +80106d30 sys_sbrk +8011df00 ioapicid +80107a87 vector156 +80107eb3 vector245 +8011ddb4 ioapic +80107c13 vector189 +80107504 vector7 +801076dc vector61 +8010758f vector24 +8010789e vector111 +80107c97 vector200 +80107712 vector67 +801079af vector138 +80107751 vector74 +80105230 sched +80105ce0 memmove +801076b8 vector57 +80106040 syscall +80107d3f vector214 +80107832 vector99 +80104e90 cpuid +80103080 writei +801079d3 vector141 +80106cb0 sys_fork +80101ed0 cleanupexec +8010c520 bcache +80107b47 vector172 +80107e83 vector241 +801059d0 getcallerpcs +80106940 sys_mkdir +80107f13 vector253 +801074e0 vector3 +801074d7 vector2 +801031b0 namecmp +80107ddb vector227 +80107d0f vector210 +80105fc0 argstr +80107db7 vector224 +8011b5a0 inputBuffer +80107628 vector41 +80100890 cprintf +80102390 filedup +80101d40 closeconsole +80103590 namei +80107574 vector21 +80100040 binit +80107b83 vector177 +80101e60 setconsoleproctitle +801078dd vector118 +8010772d vector70 +80107724 vector69 +80107e53 vector237 +801076f7 vector64 +801075aa vector27 +80107967 vector132 +80107bef vector186 +801062d0 sys_read +80107d63 vector217 +80105e70 fetchint +801085e0 setupkvm +80105d40 memcpy +80108560 freevm +801074ce vector1 +80107b8f vector178 +8010760d vector38 +801039b0 kfree +80107e5f vector238 +80106e60 sys_greeting +80104e30 mycpu +80102da0 iput +80107973 vector133 +80107748 vector73 +801079f7 vector144 +80107f1f vector254 +80102a10 readsb +8010c004 nextpid +80107844 vector101 +80107d1b vector211 +80104700 mpinit +80107b5f vector174 +80107e9b vector243 +80102300 fileinit +801064a0 cleanupsyslink +801059b0 initlock +80107937 vector128 +80108870 copyout +80107790 vector81 +801055e0 sleep +80103e20 microdelay +80107532 vector13 +80107682 vector51 +80107549 vector16 +8011b580 input +80107e77 vector240 +8010769d vector54 +80107562 vector19 +801077f3 vector92 +80107ea7 vector244 +80102f50 stati +801079c7 vector140 +80106ce0 sys_kill +8010764c vector45 +8010777e vector79 +80104a60 pipeclose +80107df3 vector229 +80107a9f vector158 +80106430 sys_fstat +801007e0 consolewrite +80107616 vector39 +80107b17 vector168 +801042c0 end_op +801075f2 vector35 +801078b0 vector113 +80103a50 freerange +8010791c vector125 +801012f0 newconsole +80108400 allocuvm +80106fe9 trapret +80107d57 vector216 +801076ee vector63 +801075a1 vector26 +80107c43 vector193 +80103ce0 lapicinit +80107c67 vector196 +80107d03 vector209 +801074e9 vector4 +80107b2f vector170 +80121250 stack +80107997 vector136 +8010751d vector10 +80107cdf vector206 +80102d50 iunlock +80106d80 sys_sleep +80107f2b vector255 +80107bb3 vector181 +801076ca vector59 +801077b4 vector85 +801077ab vector84 +80107bcb vector183 +80107aab vector159 +80107d27 vector212 +801064e0 sys_link +8010765e vector47 +80107de7 vector228 +80107631 vector42 +801078b9 vector114 +80108820 uva2ka +80107b6b vector175 +801079eb vector143 +80102320 filealloc +801056a0 wakeup +8010794f vector130 +80107ebf vector246 +80107514 vector9 +801079df vector142 +8010783b vector100 +80107ca3 vector201 +80108680 clearpteu +80104eb0 myproc +80107000 tvinit +801076d3 vector60 +80107586 vector23 +80102c40 idup +80107e47 vector236 +80103cc0 kbdintr +80106800 sys_open +80107e0b vector231 +80107709 vector66 +801075bc vector29 +80102f80 readi +8010798b vector135 +80101530 consoleintr +80105700 kill +8010776c vector77 +80102b00 ialloc +80107ba7 vector180 +80121244 kpgdir +80101de0 getcurrentconsoleindex +80107cf7 vector208 +80103ec0 cmostime +801074b0 uartintr +80107829 vector98 +80107820 vector97 +80107b77 vector176 +80107c4f vector194 +801075d7 vector32 +80122250 end +80107c8b vector199 +80100fb0 consoleget +8010795b vector131 +80107f07 vector252 +801025a0 filewrite +801074c5 vector0 +80105f00 argint +80104920 cleanuppipealloc +80101f20 exec +80107a03 vector145 +80106350 sys_write +80105b20 release +80105eb0 fetchstr +8010787a vector107 +8010761f vector40 +80105450 wait +8010784d vector102 +8010b000 entrypgdir +0010000c _start +801076af vector56 +8010771b vector68 +801074fb vector6 +8010c48c _binary_initcode_end +80100000 multiboot_header +80107943 vector129 +80105190 scheduler +801031d0 dirlookup +80107c73 vector197 +801023e0 fileclose +80104250 begin_op +80101080 loadscreenbuffer +80107a57 vector152 +80108660 kvmalloc +80107dff vector230 +80101000 testfillbuffer +80105d50 strncmp +80107604 vector37 +80107cd3 vector205 +80107ac3 vector161 +80120a00 tickslock +80104b00 pipewrite +80105da0 strncpy +80107736 vector71 +801086d0 copyuvm +8011b6e0 ftable +80107ab7 vector160 +80105f50 argptr +80107d4b vector215 +80107a93 vector157 +80106250 sys_dup +801078a7 vector112 +80100480 panic +80104dc0 forkret +80107bbf vector182 +8010752b vector12 +80105c90 memcmp +80103be0 kbdgetc +8010788c vector109 +8010756b vector20 +80105070 fork +80107694 vector53 +80107559 vector18 +0000007a _binary_entryother_size +8011df20 cpus +80105920 releasesleep +8010780e vector95 +80106ca0 sys_getch +80105ae0 holding +8011dd34 sb +80105b80 acquire +80107dcf vector226 +801035b0 nameiparent +80107670 vector49 +80107643 vector44 +8011de00 lapic +80107775 vector78 +80106fd1 alltraps +80107b53 vector173 +801078d4 vector117 +801010c0 clearscreen +80107799 vector82 +80107d9f vector222 +8010750d vector8 +80107a33 vector149 +80102bc0 iupdate +8010a000 data +80105c40 memset +80107e17 vector232 +80104550 main +80108170 switchkvm +80107871 vector106 +80107d87 vector220 +801077e1 vector90 +80107adb vector163 +80107e2f vector234 +80106f20 sys_screen +80104430 log_write +801058c0 acquiresleep +80106630 sys_unlink +801076e5 vector62 +80107598 vector25 +80107c7f vector198 +801078ef vector120 +8010c48c _binary_entryother_start +80103b00 kinit1 +80107679 vector50 +80107540 vector15 +80107a4b vector151 +801077a2 vector83 +801077d8 vector89 +801077cf vector88 +80106ed0 sys_shutdown +801070b0 trap +80106e30 sys_uptime +80107b9b vector179 +801075e9 vector34 +80107655 vector46 +8010797f vector134 +80107dab vector223 +80120a40 idt +80107d6f vector218 +80104e10 pinit +80100c00 sprintf +80108530 deallocuvm +801013e0 switchtoconsole +80107dc3 vector225 +80103de0 lapicid +80107bfb vector187 +80104ff0 growproc +80105960 holdingsleep +8011df04 ncpu +801075c5 vector30 +80104ee0 userinit +80100470 getconsoleindex +801000d0 bread +8010792e vector127 +80104c00 piperead +801209e0 ticks +80107c37 vector192 +80107aff vector166 +801011e0 consoleinit +80107763 vector76 +8010775a vector75 +80103730 ideintr +80107c5b vector195 +80107a3f vector150 +801076c1 vector58 +80107ed7 vector248 +8010790a vector123 +80107817 vector96 +80110ea0 consoles +801075ce vector31 +80107cbb vector203 +801079bb vector139 +80107a63 vector153 +80107ae7 vector164 +80105780 procdump +801078f8 vector121 +80107450 uartputc +801074f2 vector5 +80107b0b vector167 +80107a7b vector155 +80107ee3 vector249 +801001f0 brelse +801013c0 releaseallconsoles +80107eef vector250 +80107913 vector124 +80107895 vector110 +80107cc7 vector204 +80102c70 ilock +80106ae0 sys_exec +801079a3 vector137 +8010c460 _binary_initcode_start +80105e5b swtch +80107ecb vector247 +8010757d vector22 +80107caf vector202 +801080e0 seginit +80102f00 iunlockput +80110e80 currentconsole +8010773f vector72 +801076a6 vector55 +80107925 vector126 +80107700 vector65 +801075b3 vector28 +8010c506 _binary_entryother_end +80107b23 vector169 +801001b0 bwrite +80107e23 vector233 +801010a0 savescreenbuffer +80107080 idtinit +80101050 getbaseconsoleptr +801052f0 exit +80106cd0 sys_wait +80106cc0 sys_exit +801034d0 dirlink +0000002c _binary_initcode_size +80107a1b vector147 +80105880 initsleeplock +801036b0 ideinit +80108310 loaduvm +8010785f vector104 +801078cb vector116 +8011e4a0 ptable +80103970 ioapicenable +80105a80 popcli +8010c008 vectors +8010768b vector52 +80107552 vector17 +80107bd7 vector184 +80105e40 strlen +80106bd0 sys_pipe +80102a50 iinit +80104900 picinit +80107ceb vector207 +80108290 inituvm +80106fc0 sys_cls +80107c1f vector190 +80107e6b vector239 +80107805 vector94 +801077fc vector93 +801041b0 initlog +80107c07 vector188 +80107667 vector48 +801037d0 iderw +80100f80 getvalidprocessconsoleptr +80107d7b vector219 +80107a27 vector148 +80107d93 vector221 +80103b70 kalloc +8011c080 devsw +80106d20 sys_getpid +80107787 vector80 +80107b3b vector171 +80107a6f vector154 +80101060 clearconsole +801075fb vector36 +80104970 pipealloc +80107e3b vector235 +80107868 vector105 +80106a30 sys_chdir +8011c0e0 icache +80107a0f vector146 +80107c2b vector191 +80107856 vector103 +801069a0 sys_mknod +80103e30 lapicstartap +80108180 switchuvm +80105a30 pushcli +80103aa0 kinit2 +80107524 vector11 +80107539 vector14 +801024c0 filestat diff --git a/kill.asm b/kill.asm new file mode 100644 index 0000000..7a67399 --- /dev/null +++ b/kill.asm @@ -0,0 +1,1185 @@ + +_kill: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "stat.h" +#include "user.h" + +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 27 jle 4a + 23: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 27: 90 nop + printf(2, "usage: kill pid...\n"); + exit(); + } + for (i = 1; i < argc; i++) { + kill(atoi(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 + kill(atoi(argv[i])); + 31: e8 0a 02 00 00 call 240 + 36: 89 04 24 mov %eax,(%esp) + 39: e8 95 02 00 00 call 2d3 + for (i = 1; i < argc; i++) { + 3e: 83 c4 10 add $0x10,%esp + 41: 39 de cmp %ebx,%esi + 43: 75 e3 jne 28 + } + exit(); + 45: e8 69 02 00 00 call 2b3 + printf(2, "usage: kill pid...\n"); + 4a: 50 push %eax + 4b: 50 push %eax + 4c: 68 58 07 00 00 push $0x758 + 51: 6a 02 push $0x2 + 53: e8 d8 03 00 00 call 430 + exit(); + 58: e8 56 02 00 00 call 2b3 + 5d: 66 90 xchg %ax,%ax + 5f: 90 nop + +00000060 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 60: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 61: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 63: 89 e5 mov %esp,%ebp + 65: 53 push %ebx + 66: 8b 4d 08 mov 0x8(%ebp),%ecx + 69: 8b 5d 0c mov 0xc(%ebp),%ebx + 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 70: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 74: 88 14 01 mov %dl,(%ecx,%eax,1) + 77: 83 c0 01 add $0x1,%eax + 7a: 84 d2 test %dl,%dl + 7c: 75 f2 jne 70 + ; + } + return os; +} + 7e: 8b 5d fc mov -0x4(%ebp),%ebx + 81: 89 c8 mov %ecx,%eax + 83: c9 leave + 84: c3 ret + 85: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000090 : + +int strcmp(const char *p, const char *q) { + 90: 55 push %ebp + 91: 89 e5 mov %esp,%ebp + 93: 53 push %ebx + 94: 8b 55 08 mov 0x8(%ebp),%edx + 97: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 9a: 0f b6 02 movzbl (%edx),%eax + 9d: 84 c0 test %al,%al + 9f: 75 17 jne b8 + a1: eb 3a jmp dd + a3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + a7: 90 nop + a8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + ac: 83 c2 01 add $0x1,%edx + af: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + b2: 84 c0 test %al,%al + b4: 74 1a je d0 + p++, q++; + b6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + b8: 0f b6 19 movzbl (%ecx),%ebx + bb: 38 c3 cmp %al,%bl + bd: 74 e9 je a8 + } + return (uchar) * p - (uchar) * q; + bf: 29 d8 sub %ebx,%eax +} + c1: 8b 5d fc mov -0x4(%ebp),%ebx + c4: c9 leave + c5: c3 ret + c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + d0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + d4: 31 c0 xor %eax,%eax + d6: 29 d8 sub %ebx,%eax +} + d8: 8b 5d fc mov -0x4(%ebp),%ebx + db: c9 leave + dc: c3 ret + return (uchar) * p - (uchar) * q; + dd: 0f b6 19 movzbl (%ecx),%ebx + e0: 31 c0 xor %eax,%eax + e2: eb db jmp bf + e4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ef: 90 nop + +000000f0 : + +uint strlen(const char *s) { + f0: 55 push %ebp + f1: 89 e5 mov %esp,%ebp + f3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + f6: 80 3a 00 cmpb $0x0,(%edx) + f9: 74 15 je 110 + fb: 31 c0 xor %eax,%eax + fd: 8d 76 00 lea 0x0(%esi),%esi + 100: 83 c0 01 add $0x1,%eax + 103: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 107: 89 c1 mov %eax,%ecx + 109: 75 f5 jne 100 + ; + } + return n; +} + 10b: 89 c8 mov %ecx,%eax + 10d: 5d pop %ebp + 10e: c3 ret + 10f: 90 nop + for (n = 0; s[n]; n++) { + 110: 31 c9 xor %ecx,%ecx +} + 112: 5d pop %ebp + 113: 89 c8 mov %ecx,%eax + 115: c3 ret + 116: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 11d: 8d 76 00 lea 0x0(%esi),%esi + +00000120 : + +void* memset(void *dst, int c, uint n) { + 120: 55 push %ebp + 121: 89 e5 mov %esp,%ebp + 123: 57 push %edi + 124: 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" : + 127: 8b 4d 10 mov 0x10(%ebp),%ecx + 12a: 8b 45 0c mov 0xc(%ebp),%eax + 12d: 89 d7 mov %edx,%edi + 12f: fc cld + 130: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 132: 8b 7d fc mov -0x4(%ebp),%edi + 135: 89 d0 mov %edx,%eax + 137: c9 leave + 138: c3 ret + 139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000140 : + +char* strchr(const char *s, char c) { + 140: 55 push %ebp + 141: 89 e5 mov %esp,%ebp + 143: 8b 45 08 mov 0x8(%ebp),%eax + 146: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 14a: 0f b6 10 movzbl (%eax),%edx + 14d: 84 d2 test %dl,%dl + 14f: 75 12 jne 163 + 151: eb 1d jmp 170 + 153: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 157: 90 nop + 158: 0f b6 50 01 movzbl 0x1(%eax),%edx + 15c: 83 c0 01 add $0x1,%eax + 15f: 84 d2 test %dl,%dl + 161: 74 0d je 170 + if (*s == c) { + 163: 38 d1 cmp %dl,%cl + 165: 75 f1 jne 158 + return (char*)s; + } + } + return 0; +} + 167: 5d pop %ebp + 168: c3 ret + 169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 170: 31 c0 xor %eax,%eax +} + 172: 5d pop %ebp + 173: c3 ret + 174: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 17b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 17f: 90 nop + +00000180 : + +char* gets(char *buf, int max) { + 180: 55 push %ebp + 181: 89 e5 mov %esp,%ebp + 183: 57 push %edi + 184: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 185: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 188: 53 push %ebx + for (i = 0; i + 1 < max;) { + 189: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 18b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 18e: eb 27 jmp 1b7 + cc = read(0, &c, 1); + 190: 83 ec 04 sub $0x4,%esp + 193: 6a 01 push $0x1 + 195: 57 push %edi + 196: 6a 00 push $0x0 + 198: e8 2e 01 00 00 call 2cb + if (cc < 1) { + 19d: 83 c4 10 add $0x10,%esp + 1a0: 85 c0 test %eax,%eax + 1a2: 7e 1d jle 1c1 + break; + } + buf[i++] = c; + 1a4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1a8: 8b 55 08 mov 0x8(%ebp),%edx + 1ab: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1af: 3c 0a cmp $0xa,%al + 1b1: 74 1d je 1d0 + 1b3: 3c 0d cmp $0xd,%al + 1b5: 74 19 je 1d0 + for (i = 0; i + 1 < max;) { + 1b7: 89 de mov %ebx,%esi + 1b9: 83 c3 01 add $0x1,%ebx + 1bc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1bf: 7c cf jl 190 + break; + } + } + buf[i] = '\0'; + 1c1: 8b 45 08 mov 0x8(%ebp),%eax + 1c4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1c8: 8d 65 f4 lea -0xc(%ebp),%esp + 1cb: 5b pop %ebx + 1cc: 5e pop %esi + 1cd: 5f pop %edi + 1ce: 5d pop %ebp + 1cf: c3 ret + buf[i] = '\0'; + 1d0: 8b 45 08 mov 0x8(%ebp),%eax + 1d3: 89 de mov %ebx,%esi + 1d5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1d9: 8d 65 f4 lea -0xc(%ebp),%esp + 1dc: 5b pop %ebx + 1dd: 5e pop %esi + 1de: 5f pop %edi + 1df: 5d pop %ebp + 1e0: c3 ret + 1e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ef: 90 nop + +000001f0 : + +int stat(const char *n, struct stat *st) { + 1f0: 55 push %ebp + 1f1: 89 e5 mov %esp,%ebp + 1f3: 56 push %esi + 1f4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 1f5: 83 ec 08 sub $0x8,%esp + 1f8: 6a 00 push $0x0 + 1fa: ff 75 08 push 0x8(%ebp) + 1fd: e8 19 01 00 00 call 31b + if (fd < 0) { + 202: 83 c4 10 add $0x10,%esp + 205: 85 c0 test %eax,%eax + 207: 78 27 js 230 + return -1; + } + r = fstat(fd, st); + 209: 83 ec 08 sub $0x8,%esp + 20c: ff 75 0c push 0xc(%ebp) + 20f: 89 c3 mov %eax,%ebx + 211: 50 push %eax + 212: e8 cc 00 00 00 call 2e3 + close(fd); + 217: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 21a: 89 c6 mov %eax,%esi + close(fd); + 21c: e8 2a 01 00 00 call 34b + return r; + 221: 83 c4 10 add $0x10,%esp +} + 224: 8d 65 f8 lea -0x8(%ebp),%esp + 227: 89 f0 mov %esi,%eax + 229: 5b pop %ebx + 22a: 5e pop %esi + 22b: 5d pop %ebp + 22c: c3 ret + 22d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 230: be ff ff ff ff mov $0xffffffff,%esi + 235: eb ed jmp 224 + 237: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 23e: 66 90 xchg %ax,%ax + +00000240 : + +int atoi(const char *s) { + 240: 55 push %ebp + 241: 89 e5 mov %esp,%ebp + 243: 53 push %ebx + 244: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 247: 0f be 02 movsbl (%edx),%eax + 24a: 8d 48 d0 lea -0x30(%eax),%ecx + 24d: 80 f9 09 cmp $0x9,%cl + n = 0; + 250: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 255: 77 1e ja 275 + 257: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 260: 83 c2 01 add $0x1,%edx + 263: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 266: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 26a: 0f be 02 movsbl (%edx),%eax + 26d: 8d 58 d0 lea -0x30(%eax),%ebx + 270: 80 fb 09 cmp $0x9,%bl + 273: 76 eb jbe 260 + } + return n; +} + 275: 8b 5d fc mov -0x4(%ebp),%ebx + 278: 89 c8 mov %ecx,%eax + 27a: c9 leave + 27b: c3 ret + 27c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000280 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 280: 55 push %ebp + 281: 89 e5 mov %esp,%ebp + 283: 57 push %edi + 284: 8b 45 10 mov 0x10(%ebp),%eax + 287: 8b 55 08 mov 0x8(%ebp),%edx + 28a: 56 push %esi + 28b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 28e: 85 c0 test %eax,%eax + 290: 7e 13 jle 2a5 + 292: 01 d0 add %edx,%eax + dst = vdst; + 294: 89 d7 mov %edx,%edi + 296: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 29d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2a0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2a1: 39 f8 cmp %edi,%eax + 2a3: 75 fb jne 2a0 + } + return vdst; +} + 2a5: 5e pop %esi + 2a6: 89 d0 mov %edx,%eax + 2a8: 5f pop %edi + 2a9: 5d pop %ebp + 2aa: c3 ret + +000002ab : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2ab: b8 01 00 00 00 mov $0x1,%eax + 2b0: cd 40 int $0x40 + 2b2: c3 ret + +000002b3 : +SYSCALL(exit) + 2b3: b8 02 00 00 00 mov $0x2,%eax + 2b8: cd 40 int $0x40 + 2ba: c3 ret + +000002bb : +SYSCALL(wait) + 2bb: b8 03 00 00 00 mov $0x3,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(pipe) + 2c3: b8 04 00 00 00 mov $0x4,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(read) + 2cb: b8 05 00 00 00 mov $0x5,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(kill) + 2d3: b8 06 00 00 00 mov $0x6,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(exec) + 2db: b8 07 00 00 00 mov $0x7,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(fstat) + 2e3: b8 08 00 00 00 mov $0x8,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(chdir) + 2eb: b8 09 00 00 00 mov $0x9,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(dup) + 2f3: b8 0a 00 00 00 mov $0xa,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(getpid) + 2fb: b8 0b 00 00 00 mov $0xb,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(sbrk) + 303: b8 0c 00 00 00 mov $0xc,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(sleep) + 30b: b8 0d 00 00 00 mov $0xd,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(uptime) + 313: b8 0e 00 00 00 mov $0xe,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(open) + 31b: b8 0f 00 00 00 mov $0xf,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(write) + 323: b8 10 00 00 00 mov $0x10,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(mknod) + 32b: b8 11 00 00 00 mov $0x11,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(unlink) + 333: b8 12 00 00 00 mov $0x12,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(link) + 33b: b8 13 00 00 00 mov $0x13,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(mkdir) + 343: b8 14 00 00 00 mov $0x14,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(close) + 34b: b8 15 00 00 00 mov $0x15,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(getch) + 353: b8 16 00 00 00 mov $0x16,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(greeting) + 35b: b8 17 00 00 00 mov $0x17,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(shutdown) + 363: b8 18 00 00 00 mov $0x18,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(screen) + 36b: b8 19 00 00 00 mov $0x19,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(cls) + 373: b8 1a 00 00 00 mov $0x1a,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + 37b: 66 90 xchg %ax,%ax + 37d: 66 90 xchg %ax,%ax + 37f: 90 nop + +00000380 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 380: 55 push %ebp + 381: 89 e5 mov %esp,%ebp + 383: 57 push %edi + 384: 56 push %esi + 385: 53 push %ebx + 386: 83 ec 3c sub $0x3c,%esp + 389: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 38c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 38e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 391: 85 d2 test %edx,%edx + 393: 0f 89 7f 00 00 00 jns 418 + 399: f6 45 08 01 testb $0x1,0x8(%ebp) + 39d: 74 79 je 418 + neg = 1; + 39f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3a6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3a8: 31 db xor %ebx,%ebx + 3aa: 8d 75 d7 lea -0x29(%ebp),%esi + 3ad: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3b0: 89 c8 mov %ecx,%eax + 3b2: 31 d2 xor %edx,%edx + 3b4: 89 cf mov %ecx,%edi + 3b6: f7 75 c4 divl -0x3c(%ebp) + 3b9: 0f b6 92 cc 07 00 00 movzbl 0x7cc(%edx),%edx + 3c0: 89 45 c0 mov %eax,-0x40(%ebp) + 3c3: 89 d8 mov %ebx,%eax + 3c5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3c8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3cb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3ce: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3d1: 76 dd jbe 3b0 + if (neg) { + 3d3: 8b 4d bc mov -0x44(%ebp),%ecx + 3d6: 85 c9 test %ecx,%ecx + 3d8: 74 0c je 3e6 + buf[i++] = '-'; + 3da: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3df: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3e1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3e6: 8b 7d b8 mov -0x48(%ebp),%edi + 3e9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3ed: eb 07 jmp 3f6 + 3ef: 90 nop + putc(fd, buf[i]); + 3f0: 0f b6 13 movzbl (%ebx),%edx + 3f3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 3f6: 83 ec 04 sub $0x4,%esp + 3f9: 88 55 d7 mov %dl,-0x29(%ebp) + 3fc: 6a 01 push $0x1 + 3fe: 56 push %esi + 3ff: 57 push %edi + 400: e8 1e ff ff ff call 323 + while (--i >= 0) { + 405: 83 c4 10 add $0x10,%esp + 408: 39 de cmp %ebx,%esi + 40a: 75 e4 jne 3f0 + } +} + 40c: 8d 65 f4 lea -0xc(%ebp),%esp + 40f: 5b pop %ebx + 410: 5e pop %esi + 411: 5f pop %edi + 412: 5d pop %ebp + 413: c3 ret + 414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 418: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 41f: eb 87 jmp 3a8 + 421: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 428: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 42f: 90 nop + +00000430 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 430: 55 push %ebp + 431: 89 e5 mov %esp,%ebp + 433: 57 push %edi + 434: 56 push %esi + 435: 53 push %ebx + 436: 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++) { + 439: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 43c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 43f: 0f b6 13 movzbl (%ebx),%edx + 442: 84 d2 test %dl,%dl + 444: 74 6a je 4b0 + ap = (uint*)(void*)&fmt + 1; + 446: 8d 45 10 lea 0x10(%ebp),%eax + 449: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 44c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 44f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 451: 89 45 d0 mov %eax,-0x30(%ebp) + 454: eb 36 jmp 48c + 456: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 45d: 8d 76 00 lea 0x0(%esi),%esi + 460: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 463: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 468: 83 f8 25 cmp $0x25,%eax + 46b: 74 15 je 482 + write(fd, &c, 1); + 46d: 83 ec 04 sub $0x4,%esp + 470: 88 55 e7 mov %dl,-0x19(%ebp) + 473: 6a 01 push $0x1 + 475: 57 push %edi + 476: 56 push %esi + 477: e8 a7 fe ff ff call 323 + 47c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 47f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 482: 0f b6 13 movzbl (%ebx),%edx + 485: 83 c3 01 add $0x1,%ebx + 488: 84 d2 test %dl,%dl + 48a: 74 24 je 4b0 + c = fmt[i] & 0xff; + 48c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 48f: 85 c9 test %ecx,%ecx + 491: 74 cd je 460 + } + } + else if (state == '%') { + 493: 83 f9 25 cmp $0x25,%ecx + 496: 75 ea jne 482 + if (c == 'd') { + 498: 83 f8 25 cmp $0x25,%eax + 49b: 0f 84 07 01 00 00 je 5a8 + 4a1: 83 e8 63 sub $0x63,%eax + 4a4: 83 f8 15 cmp $0x15,%eax + 4a7: 77 17 ja 4c0 + 4a9: ff 24 85 74 07 00 00 jmp *0x774(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4b0: 8d 65 f4 lea -0xc(%ebp),%esp + 4b3: 5b pop %ebx + 4b4: 5e pop %esi + 4b5: 5f pop %edi + 4b6: 5d pop %ebp + 4b7: c3 ret + 4b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4bf: 90 nop + write(fd, &c, 1); + 4c0: 83 ec 04 sub $0x4,%esp + 4c3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4c6: 6a 01 push $0x1 + 4c8: 57 push %edi + 4c9: 56 push %esi + 4ca: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4ce: e8 50 fe ff ff call 323 + putc(fd, c); + 4d3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4d7: 83 c4 0c add $0xc,%esp + 4da: 88 55 e7 mov %dl,-0x19(%ebp) + 4dd: 6a 01 push $0x1 + 4df: 57 push %edi + 4e0: 56 push %esi + 4e1: e8 3d fe ff ff call 323 + putc(fd, c); + 4e6: 83 c4 10 add $0x10,%esp + state = 0; + 4e9: 31 c9 xor %ecx,%ecx + 4eb: eb 95 jmp 482 + 4ed: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 4f0: 83 ec 0c sub $0xc,%esp + 4f3: b9 10 00 00 00 mov $0x10,%ecx + 4f8: 6a 00 push $0x0 + 4fa: 8b 45 d0 mov -0x30(%ebp),%eax + 4fd: 8b 10 mov (%eax),%edx + 4ff: 89 f0 mov %esi,%eax + 501: e8 7a fe ff ff call 380 + ap++; + 506: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 50a: 83 c4 10 add $0x10,%esp + state = 0; + 50d: 31 c9 xor %ecx,%ecx + 50f: e9 6e ff ff ff jmp 482 + 514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 518: 8b 45 d0 mov -0x30(%ebp),%eax + 51b: 8b 10 mov (%eax),%edx + ap++; + 51d: 83 c0 04 add $0x4,%eax + 520: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 523: 85 d2 test %edx,%edx + 525: 0f 84 8d 00 00 00 je 5b8 + while (*s != 0) { + 52b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 52e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 530: 84 c0 test %al,%al + 532: 0f 84 4a ff ff ff je 482 + 538: 89 5d d4 mov %ebx,-0x2c(%ebp) + 53b: 89 d3 mov %edx,%ebx + 53d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 540: 83 ec 04 sub $0x4,%esp + s++; + 543: 83 c3 01 add $0x1,%ebx + 546: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 549: 6a 01 push $0x1 + 54b: 57 push %edi + 54c: 56 push %esi + 54d: e8 d1 fd ff ff call 323 + while (*s != 0) { + 552: 0f b6 03 movzbl (%ebx),%eax + 555: 83 c4 10 add $0x10,%esp + 558: 84 c0 test %al,%al + 55a: 75 e4 jne 540 + state = 0; + 55c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 55f: 31 c9 xor %ecx,%ecx + 561: e9 1c ff ff ff jmp 482 + 566: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 56d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 570: 83 ec 0c sub $0xc,%esp + 573: b9 0a 00 00 00 mov $0xa,%ecx + 578: 6a 01 push $0x1 + 57a: e9 7b ff ff ff jmp 4fa + 57f: 90 nop + putc(fd, *ap); + 580: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 583: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 586: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 588: 6a 01 push $0x1 + 58a: 57 push %edi + 58b: 56 push %esi + putc(fd, *ap); + 58c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 58f: e8 8f fd ff ff call 323 + ap++; + 594: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 598: 83 c4 10 add $0x10,%esp + state = 0; + 59b: 31 c9 xor %ecx,%ecx + 59d: e9 e0 fe ff ff jmp 482 + 5a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5a8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5ab: 83 ec 04 sub $0x4,%esp + 5ae: e9 2a ff ff ff jmp 4dd + 5b3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5b7: 90 nop + s = "(null)"; + 5b8: ba 6c 07 00 00 mov $0x76c,%edx + while (*s != 0) { + 5bd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5c0: b8 28 00 00 00 mov $0x28,%eax + 5c5: 89 d3 mov %edx,%ebx + 5c7: e9 74 ff ff ff jmp 540 + 5cc: 66 90 xchg %ax,%ax + 5ce: 66 90 xchg %ax,%ax + +000005d0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5d0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5d1: a1 84 0a 00 00 mov 0xa84,%eax +void free(void *ap) { + 5d6: 89 e5 mov %esp,%ebp + 5d8: 57 push %edi + 5d9: 56 push %esi + 5da: 53 push %ebx + 5db: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5de: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5e8: 89 c2 mov %eax,%edx + 5ea: 8b 00 mov (%eax),%eax + 5ec: 39 ca cmp %ecx,%edx + 5ee: 73 30 jae 620 + 5f0: 39 c1 cmp %eax,%ecx + 5f2: 72 04 jb 5f8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5f4: 39 c2 cmp %eax,%edx + 5f6: 72 f0 jb 5e8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 5f8: 8b 73 fc mov -0x4(%ebx),%esi + 5fb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5fe: 39 f8 cmp %edi,%eax + 600: 74 30 je 632 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 602: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 605: 8b 42 04 mov 0x4(%edx),%eax + 608: 8d 34 c2 lea (%edx,%eax,8),%esi + 60b: 39 f1 cmp %esi,%ecx + 60d: 74 3a je 649 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 60f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 611: 5b pop %ebx + freep = p; + 612: 89 15 84 0a 00 00 mov %edx,0xa84 +} + 618: 5e pop %esi + 619: 5f pop %edi + 61a: 5d pop %ebp + 61b: c3 ret + 61c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 620: 39 c2 cmp %eax,%edx + 622: 72 c4 jb 5e8 + 624: 39 c1 cmp %eax,%ecx + 626: 73 c0 jae 5e8 + if (bp + bp->s.size == p->s.ptr) { + 628: 8b 73 fc mov -0x4(%ebx),%esi + 62b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 62e: 39 f8 cmp %edi,%eax + 630: 75 d0 jne 602 + bp->s.size += p->s.ptr->s.size; + 632: 03 70 04 add 0x4(%eax),%esi + 635: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 638: 8b 02 mov (%edx),%eax + 63a: 8b 00 mov (%eax),%eax + 63c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 63f: 8b 42 04 mov 0x4(%edx),%eax + 642: 8d 34 c2 lea (%edx,%eax,8),%esi + 645: 39 f1 cmp %esi,%ecx + 647: 75 c6 jne 60f + p->s.size += bp->s.size; + 649: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 64c: 89 15 84 0a 00 00 mov %edx,0xa84 + p->s.size += bp->s.size; + 652: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 655: 8b 4b f8 mov -0x8(%ebx),%ecx + 658: 89 0a mov %ecx,(%edx) +} + 65a: 5b pop %ebx + 65b: 5e pop %esi + 65c: 5f pop %edi + 65d: 5d pop %ebp + 65e: c3 ret + 65f: 90 nop + +00000660 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 660: 55 push %ebp + 661: 89 e5 mov %esp,%ebp + 663: 57 push %edi + 664: 56 push %esi + 665: 53 push %ebx + 666: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 669: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 66c: 8b 3d 84 0a 00 00 mov 0xa84,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 672: 8d 70 07 lea 0x7(%eax),%esi + 675: c1 ee 03 shr $0x3,%esi + 678: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 67b: 85 ff test %edi,%edi + 67d: 0f 84 9d 00 00 00 je 720 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 683: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 685: 8b 4a 04 mov 0x4(%edx),%ecx + 688: 39 f1 cmp %esi,%ecx + 68a: 73 6a jae 6f6 + 68c: bb 00 10 00 00 mov $0x1000,%ebx + 691: 39 de cmp %ebx,%esi + 693: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 696: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 69d: 89 45 e4 mov %eax,-0x1c(%ebp) + 6a0: eb 17 jmp 6b9 + 6a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6a8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6aa: 8b 48 04 mov 0x4(%eax),%ecx + 6ad: 39 f1 cmp %esi,%ecx + 6af: 73 4f jae 700 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6b1: 8b 3d 84 0a 00 00 mov 0xa84,%edi + 6b7: 89 c2 mov %eax,%edx + 6b9: 39 d7 cmp %edx,%edi + 6bb: 75 eb jne 6a8 + p = sbrk(nu * sizeof(Header)); + 6bd: 83 ec 0c sub $0xc,%esp + 6c0: ff 75 e4 push -0x1c(%ebp) + 6c3: e8 3b fc ff ff call 303 + if (p == (char*)-1) { + 6c8: 83 c4 10 add $0x10,%esp + 6cb: 83 f8 ff cmp $0xffffffff,%eax + 6ce: 74 1c je 6ec + hp->s.size = nu; + 6d0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6d3: 83 ec 0c sub $0xc,%esp + 6d6: 83 c0 08 add $0x8,%eax + 6d9: 50 push %eax + 6da: e8 f1 fe ff ff call 5d0 + return freep; + 6df: 8b 15 84 0a 00 00 mov 0xa84,%edx + if ((p = morecore(nunits)) == 0) { + 6e5: 83 c4 10 add $0x10,%esp + 6e8: 85 d2 test %edx,%edx + 6ea: 75 bc jne 6a8 + return 0; + } + } + } +} + 6ec: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 6ef: 31 c0 xor %eax,%eax +} + 6f1: 5b pop %ebx + 6f2: 5e pop %esi + 6f3: 5f pop %edi + 6f4: 5d pop %ebp + 6f5: c3 ret + if (p->s.size >= nunits) { + 6f6: 89 d0 mov %edx,%eax + 6f8: 89 fa mov %edi,%edx + 6fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 700: 39 ce cmp %ecx,%esi + 702: 74 4c je 750 + p->s.size -= nunits; + 704: 29 f1 sub %esi,%ecx + 706: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 709: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 70c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 70f: 89 15 84 0a 00 00 mov %edx,0xa84 +} + 715: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 718: 83 c0 08 add $0x8,%eax +} + 71b: 5b pop %ebx + 71c: 5e pop %esi + 71d: 5f pop %edi + 71e: 5d pop %ebp + 71f: c3 ret + base.s.ptr = freep = prevp = &base; + 720: c7 05 84 0a 00 00 88 movl $0xa88,0xa84 + 727: 0a 00 00 + base.s.size = 0; + 72a: bf 88 0a 00 00 mov $0xa88,%edi + base.s.ptr = freep = prevp = &base; + 72f: c7 05 88 0a 00 00 88 movl $0xa88,0xa88 + 736: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 739: 89 fa mov %edi,%edx + base.s.size = 0; + 73b: c7 05 8c 0a 00 00 00 movl $0x0,0xa8c + 742: 00 00 00 + if (p->s.size >= nunits) { + 745: e9 42 ff ff ff jmp 68c + 74a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 750: 8b 08 mov (%eax),%ecx + 752: 89 0a mov %ecx,(%edx) + 754: eb b9 jmp 70f diff --git a/kill.d b/kill.d new file mode 100644 index 0000000..078f4f8 --- /dev/null +++ b/kill.d @@ -0,0 +1 @@ +kill.o: kill.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/kill.o b/kill.o new file mode 100644 index 0000000..08b19df Binary files /dev/null and b/kill.o differ diff --git a/kill.sym b/kill.sym new file mode 100644 index 0000000..4056790 --- /dev/null +++ b/kill.sym @@ -0,0 +1,50 @@ +00000000 kill.c +00000000 ulib.c +00000000 printf.c +00000380 printint +000007cc digits.0 +00000000 umalloc.c +00000a84 freep +00000a88 base +00000060 strcpy +00000430 printf +0000035b greeting +00000280 memmove +0000032b mknod +00000180 gets +000002fb getpid +0000036b screen +00000660 malloc +0000030b sleep +000002c3 pipe +00000353 getch +00000323 write +000002e3 fstat +000002d3 kill +000002eb chdir +000002db exec +000002bb wait +000002cb read +00000333 unlink +000002ab fork +00000303 sbrk +00000313 uptime +00000a84 __bss_start +00000120 memset +00000000 main +00000090 strcmp +00000363 shutdown +000002f3 dup +000001f0 stat +00000a84 _edata +00000a90 _end +0000033b link +000002b3 exit +00000240 atoi +00000373 cls +000000f0 strlen +0000031b open +00000140 strchr +00000343 mkdir +0000034b close +000005d0 free diff --git a/lapic.d b/lapic.d new file mode 100644 index 0000000..6e62387 --- /dev/null +++ b/lapic.d @@ -0,0 +1,2 @@ +lapic.o: lapic.c /usr/include/stdc-predef.h param.h types.h defs.h date.h \ + memlayout.h traps.h mmu.h x86.h diff --git a/lapic.o b/lapic.o new file mode 100644 index 0000000..6d26b60 Binary files /dev/null and b/lapic.o differ diff --git a/ln.asm b/ln.asm new file mode 100644 index 0000000..c9194d9 --- /dev/null +++ b/ln.asm @@ -0,0 +1,1181 @@ + +_ln: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "stat.h" +#include "user.h" + +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) + if (argc != 3) { + a: 83 39 03 cmpl $0x3,(%ecx) +int main(int argc, char *argv[]) { + d: 55 push %ebp + e: 89 e5 mov %esp,%ebp + 10: 53 push %ebx + 11: 51 push %ecx + 12: 8b 59 04 mov 0x4(%ecx),%ebx + if (argc != 3) { + 15: 74 13 je 2a + printf(2, "Usage: ln old new\n"); + 17: 52 push %edx + 18: 52 push %edx + 19: 68 58 07 00 00 push $0x758 + 1e: 6a 02 push $0x2 + 20: e8 0b 04 00 00 call 430 + exit(); + 25: e8 89 02 00 00 call 2b3 + } + if (link(argv[1], argv[2]) < 0) { + 2a: 50 push %eax + 2b: 50 push %eax + 2c: ff 73 08 push 0x8(%ebx) + 2f: ff 73 04 push 0x4(%ebx) + 32: e8 04 03 00 00 call 33b + 37: 83 c4 10 add $0x10,%esp + 3a: 85 c0 test %eax,%eax + 3c: 78 05 js 43 + printf(2, "link %s %s: failed\n", argv[1], argv[2]); + } + exit(); + 3e: e8 70 02 00 00 call 2b3 + printf(2, "link %s %s: failed\n", argv[1], argv[2]); + 43: ff 73 08 push 0x8(%ebx) + 46: ff 73 04 push 0x4(%ebx) + 49: 68 6b 07 00 00 push $0x76b + 4e: 6a 02 push $0x2 + 50: e8 db 03 00 00 call 430 + 55: 83 c4 10 add $0x10,%esp + 58: eb e4 jmp 3e + 5a: 66 90 xchg %ax,%ax + 5c: 66 90 xchg %ax,%ax + 5e: 66 90 xchg %ax,%ax + +00000060 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 60: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 61: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 63: 89 e5 mov %esp,%ebp + 65: 53 push %ebx + 66: 8b 4d 08 mov 0x8(%ebp),%ecx + 69: 8b 5d 0c mov 0xc(%ebp),%ebx + 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 70: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 74: 88 14 01 mov %dl,(%ecx,%eax,1) + 77: 83 c0 01 add $0x1,%eax + 7a: 84 d2 test %dl,%dl + 7c: 75 f2 jne 70 + ; + } + return os; +} + 7e: 8b 5d fc mov -0x4(%ebp),%ebx + 81: 89 c8 mov %ecx,%eax + 83: c9 leave + 84: c3 ret + 85: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000090 : + +int strcmp(const char *p, const char *q) { + 90: 55 push %ebp + 91: 89 e5 mov %esp,%ebp + 93: 53 push %ebx + 94: 8b 55 08 mov 0x8(%ebp),%edx + 97: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 9a: 0f b6 02 movzbl (%edx),%eax + 9d: 84 c0 test %al,%al + 9f: 75 17 jne b8 + a1: eb 3a jmp dd + a3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + a7: 90 nop + a8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + ac: 83 c2 01 add $0x1,%edx + af: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + b2: 84 c0 test %al,%al + b4: 74 1a je d0 + p++, q++; + b6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + b8: 0f b6 19 movzbl (%ecx),%ebx + bb: 38 c3 cmp %al,%bl + bd: 74 e9 je a8 + } + return (uchar) * p - (uchar) * q; + bf: 29 d8 sub %ebx,%eax +} + c1: 8b 5d fc mov -0x4(%ebp),%ebx + c4: c9 leave + c5: c3 ret + c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + d0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + d4: 31 c0 xor %eax,%eax + d6: 29 d8 sub %ebx,%eax +} + d8: 8b 5d fc mov -0x4(%ebp),%ebx + db: c9 leave + dc: c3 ret + return (uchar) * p - (uchar) * q; + dd: 0f b6 19 movzbl (%ecx),%ebx + e0: 31 c0 xor %eax,%eax + e2: eb db jmp bf + e4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ef: 90 nop + +000000f0 : + +uint strlen(const char *s) { + f0: 55 push %ebp + f1: 89 e5 mov %esp,%ebp + f3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + f6: 80 3a 00 cmpb $0x0,(%edx) + f9: 74 15 je 110 + fb: 31 c0 xor %eax,%eax + fd: 8d 76 00 lea 0x0(%esi),%esi + 100: 83 c0 01 add $0x1,%eax + 103: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 107: 89 c1 mov %eax,%ecx + 109: 75 f5 jne 100 + ; + } + return n; +} + 10b: 89 c8 mov %ecx,%eax + 10d: 5d pop %ebp + 10e: c3 ret + 10f: 90 nop + for (n = 0; s[n]; n++) { + 110: 31 c9 xor %ecx,%ecx +} + 112: 5d pop %ebp + 113: 89 c8 mov %ecx,%eax + 115: c3 ret + 116: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 11d: 8d 76 00 lea 0x0(%esi),%esi + +00000120 : + +void* memset(void *dst, int c, uint n) { + 120: 55 push %ebp + 121: 89 e5 mov %esp,%ebp + 123: 57 push %edi + 124: 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" : + 127: 8b 4d 10 mov 0x10(%ebp),%ecx + 12a: 8b 45 0c mov 0xc(%ebp),%eax + 12d: 89 d7 mov %edx,%edi + 12f: fc cld + 130: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 132: 8b 7d fc mov -0x4(%ebp),%edi + 135: 89 d0 mov %edx,%eax + 137: c9 leave + 138: c3 ret + 139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000140 : + +char* strchr(const char *s, char c) { + 140: 55 push %ebp + 141: 89 e5 mov %esp,%ebp + 143: 8b 45 08 mov 0x8(%ebp),%eax + 146: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 14a: 0f b6 10 movzbl (%eax),%edx + 14d: 84 d2 test %dl,%dl + 14f: 75 12 jne 163 + 151: eb 1d jmp 170 + 153: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 157: 90 nop + 158: 0f b6 50 01 movzbl 0x1(%eax),%edx + 15c: 83 c0 01 add $0x1,%eax + 15f: 84 d2 test %dl,%dl + 161: 74 0d je 170 + if (*s == c) { + 163: 38 d1 cmp %dl,%cl + 165: 75 f1 jne 158 + return (char*)s; + } + } + return 0; +} + 167: 5d pop %ebp + 168: c3 ret + 169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 170: 31 c0 xor %eax,%eax +} + 172: 5d pop %ebp + 173: c3 ret + 174: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 17b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 17f: 90 nop + +00000180 : + +char* gets(char *buf, int max) { + 180: 55 push %ebp + 181: 89 e5 mov %esp,%ebp + 183: 57 push %edi + 184: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 185: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 188: 53 push %ebx + for (i = 0; i + 1 < max;) { + 189: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 18b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 18e: eb 27 jmp 1b7 + cc = read(0, &c, 1); + 190: 83 ec 04 sub $0x4,%esp + 193: 6a 01 push $0x1 + 195: 57 push %edi + 196: 6a 00 push $0x0 + 198: e8 2e 01 00 00 call 2cb + if (cc < 1) { + 19d: 83 c4 10 add $0x10,%esp + 1a0: 85 c0 test %eax,%eax + 1a2: 7e 1d jle 1c1 + break; + } + buf[i++] = c; + 1a4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1a8: 8b 55 08 mov 0x8(%ebp),%edx + 1ab: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1af: 3c 0a cmp $0xa,%al + 1b1: 74 1d je 1d0 + 1b3: 3c 0d cmp $0xd,%al + 1b5: 74 19 je 1d0 + for (i = 0; i + 1 < max;) { + 1b7: 89 de mov %ebx,%esi + 1b9: 83 c3 01 add $0x1,%ebx + 1bc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1bf: 7c cf jl 190 + break; + } + } + buf[i] = '\0'; + 1c1: 8b 45 08 mov 0x8(%ebp),%eax + 1c4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1c8: 8d 65 f4 lea -0xc(%ebp),%esp + 1cb: 5b pop %ebx + 1cc: 5e pop %esi + 1cd: 5f pop %edi + 1ce: 5d pop %ebp + 1cf: c3 ret + buf[i] = '\0'; + 1d0: 8b 45 08 mov 0x8(%ebp),%eax + 1d3: 89 de mov %ebx,%esi + 1d5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1d9: 8d 65 f4 lea -0xc(%ebp),%esp + 1dc: 5b pop %ebx + 1dd: 5e pop %esi + 1de: 5f pop %edi + 1df: 5d pop %ebp + 1e0: c3 ret + 1e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ef: 90 nop + +000001f0 : + +int stat(const char *n, struct stat *st) { + 1f0: 55 push %ebp + 1f1: 89 e5 mov %esp,%ebp + 1f3: 56 push %esi + 1f4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 1f5: 83 ec 08 sub $0x8,%esp + 1f8: 6a 00 push $0x0 + 1fa: ff 75 08 push 0x8(%ebp) + 1fd: e8 19 01 00 00 call 31b + if (fd < 0) { + 202: 83 c4 10 add $0x10,%esp + 205: 85 c0 test %eax,%eax + 207: 78 27 js 230 + return -1; + } + r = fstat(fd, st); + 209: 83 ec 08 sub $0x8,%esp + 20c: ff 75 0c push 0xc(%ebp) + 20f: 89 c3 mov %eax,%ebx + 211: 50 push %eax + 212: e8 cc 00 00 00 call 2e3 + close(fd); + 217: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 21a: 89 c6 mov %eax,%esi + close(fd); + 21c: e8 2a 01 00 00 call 34b + return r; + 221: 83 c4 10 add $0x10,%esp +} + 224: 8d 65 f8 lea -0x8(%ebp),%esp + 227: 89 f0 mov %esi,%eax + 229: 5b pop %ebx + 22a: 5e pop %esi + 22b: 5d pop %ebp + 22c: c3 ret + 22d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 230: be ff ff ff ff mov $0xffffffff,%esi + 235: eb ed jmp 224 + 237: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 23e: 66 90 xchg %ax,%ax + +00000240 : + +int atoi(const char *s) { + 240: 55 push %ebp + 241: 89 e5 mov %esp,%ebp + 243: 53 push %ebx + 244: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 247: 0f be 02 movsbl (%edx),%eax + 24a: 8d 48 d0 lea -0x30(%eax),%ecx + 24d: 80 f9 09 cmp $0x9,%cl + n = 0; + 250: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 255: 77 1e ja 275 + 257: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 260: 83 c2 01 add $0x1,%edx + 263: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 266: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 26a: 0f be 02 movsbl (%edx),%eax + 26d: 8d 58 d0 lea -0x30(%eax),%ebx + 270: 80 fb 09 cmp $0x9,%bl + 273: 76 eb jbe 260 + } + return n; +} + 275: 8b 5d fc mov -0x4(%ebp),%ebx + 278: 89 c8 mov %ecx,%eax + 27a: c9 leave + 27b: c3 ret + 27c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000280 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 280: 55 push %ebp + 281: 89 e5 mov %esp,%ebp + 283: 57 push %edi + 284: 8b 45 10 mov 0x10(%ebp),%eax + 287: 8b 55 08 mov 0x8(%ebp),%edx + 28a: 56 push %esi + 28b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 28e: 85 c0 test %eax,%eax + 290: 7e 13 jle 2a5 + 292: 01 d0 add %edx,%eax + dst = vdst; + 294: 89 d7 mov %edx,%edi + 296: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 29d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2a0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2a1: 39 f8 cmp %edi,%eax + 2a3: 75 fb jne 2a0 + } + return vdst; +} + 2a5: 5e pop %esi + 2a6: 89 d0 mov %edx,%eax + 2a8: 5f pop %edi + 2a9: 5d pop %ebp + 2aa: c3 ret + +000002ab : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2ab: b8 01 00 00 00 mov $0x1,%eax + 2b0: cd 40 int $0x40 + 2b2: c3 ret + +000002b3 : +SYSCALL(exit) + 2b3: b8 02 00 00 00 mov $0x2,%eax + 2b8: cd 40 int $0x40 + 2ba: c3 ret + +000002bb : +SYSCALL(wait) + 2bb: b8 03 00 00 00 mov $0x3,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(pipe) + 2c3: b8 04 00 00 00 mov $0x4,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(read) + 2cb: b8 05 00 00 00 mov $0x5,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(kill) + 2d3: b8 06 00 00 00 mov $0x6,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(exec) + 2db: b8 07 00 00 00 mov $0x7,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(fstat) + 2e3: b8 08 00 00 00 mov $0x8,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(chdir) + 2eb: b8 09 00 00 00 mov $0x9,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(dup) + 2f3: b8 0a 00 00 00 mov $0xa,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(getpid) + 2fb: b8 0b 00 00 00 mov $0xb,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(sbrk) + 303: b8 0c 00 00 00 mov $0xc,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(sleep) + 30b: b8 0d 00 00 00 mov $0xd,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(uptime) + 313: b8 0e 00 00 00 mov $0xe,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(open) + 31b: b8 0f 00 00 00 mov $0xf,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(write) + 323: b8 10 00 00 00 mov $0x10,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(mknod) + 32b: b8 11 00 00 00 mov $0x11,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(unlink) + 333: b8 12 00 00 00 mov $0x12,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(link) + 33b: b8 13 00 00 00 mov $0x13,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(mkdir) + 343: b8 14 00 00 00 mov $0x14,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(close) + 34b: b8 15 00 00 00 mov $0x15,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(getch) + 353: b8 16 00 00 00 mov $0x16,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(greeting) + 35b: b8 17 00 00 00 mov $0x17,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(shutdown) + 363: b8 18 00 00 00 mov $0x18,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(screen) + 36b: b8 19 00 00 00 mov $0x19,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(cls) + 373: b8 1a 00 00 00 mov $0x1a,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + 37b: 66 90 xchg %ax,%ax + 37d: 66 90 xchg %ax,%ax + 37f: 90 nop + +00000380 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 380: 55 push %ebp + 381: 89 e5 mov %esp,%ebp + 383: 57 push %edi + 384: 56 push %esi + 385: 53 push %ebx + 386: 83 ec 3c sub $0x3c,%esp + 389: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 38c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 38e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 391: 85 d2 test %edx,%edx + 393: 0f 89 7f 00 00 00 jns 418 + 399: f6 45 08 01 testb $0x1,0x8(%ebp) + 39d: 74 79 je 418 + neg = 1; + 39f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3a6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3a8: 31 db xor %ebx,%ebx + 3aa: 8d 75 d7 lea -0x29(%ebp),%esi + 3ad: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3b0: 89 c8 mov %ecx,%eax + 3b2: 31 d2 xor %edx,%edx + 3b4: 89 cf mov %ecx,%edi + 3b6: f7 75 c4 divl -0x3c(%ebp) + 3b9: 0f b6 92 e0 07 00 00 movzbl 0x7e0(%edx),%edx + 3c0: 89 45 c0 mov %eax,-0x40(%ebp) + 3c3: 89 d8 mov %ebx,%eax + 3c5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3c8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3cb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3ce: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3d1: 76 dd jbe 3b0 + if (neg) { + 3d3: 8b 4d bc mov -0x44(%ebp),%ecx + 3d6: 85 c9 test %ecx,%ecx + 3d8: 74 0c je 3e6 + buf[i++] = '-'; + 3da: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3df: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3e1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3e6: 8b 7d b8 mov -0x48(%ebp),%edi + 3e9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3ed: eb 07 jmp 3f6 + 3ef: 90 nop + putc(fd, buf[i]); + 3f0: 0f b6 13 movzbl (%ebx),%edx + 3f3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 3f6: 83 ec 04 sub $0x4,%esp + 3f9: 88 55 d7 mov %dl,-0x29(%ebp) + 3fc: 6a 01 push $0x1 + 3fe: 56 push %esi + 3ff: 57 push %edi + 400: e8 1e ff ff ff call 323 + while (--i >= 0) { + 405: 83 c4 10 add $0x10,%esp + 408: 39 de cmp %ebx,%esi + 40a: 75 e4 jne 3f0 + } +} + 40c: 8d 65 f4 lea -0xc(%ebp),%esp + 40f: 5b pop %ebx + 410: 5e pop %esi + 411: 5f pop %edi + 412: 5d pop %ebp + 413: c3 ret + 414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 418: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 41f: eb 87 jmp 3a8 + 421: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 428: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 42f: 90 nop + +00000430 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 430: 55 push %ebp + 431: 89 e5 mov %esp,%ebp + 433: 57 push %edi + 434: 56 push %esi + 435: 53 push %ebx + 436: 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++) { + 439: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 43c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 43f: 0f b6 13 movzbl (%ebx),%edx + 442: 84 d2 test %dl,%dl + 444: 74 6a je 4b0 + ap = (uint*)(void*)&fmt + 1; + 446: 8d 45 10 lea 0x10(%ebp),%eax + 449: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 44c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 44f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 451: 89 45 d0 mov %eax,-0x30(%ebp) + 454: eb 36 jmp 48c + 456: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 45d: 8d 76 00 lea 0x0(%esi),%esi + 460: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 463: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 468: 83 f8 25 cmp $0x25,%eax + 46b: 74 15 je 482 + write(fd, &c, 1); + 46d: 83 ec 04 sub $0x4,%esp + 470: 88 55 e7 mov %dl,-0x19(%ebp) + 473: 6a 01 push $0x1 + 475: 57 push %edi + 476: 56 push %esi + 477: e8 a7 fe ff ff call 323 + 47c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 47f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 482: 0f b6 13 movzbl (%ebx),%edx + 485: 83 c3 01 add $0x1,%ebx + 488: 84 d2 test %dl,%dl + 48a: 74 24 je 4b0 + c = fmt[i] & 0xff; + 48c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 48f: 85 c9 test %ecx,%ecx + 491: 74 cd je 460 + } + } + else if (state == '%') { + 493: 83 f9 25 cmp $0x25,%ecx + 496: 75 ea jne 482 + if (c == 'd') { + 498: 83 f8 25 cmp $0x25,%eax + 49b: 0f 84 07 01 00 00 je 5a8 + 4a1: 83 e8 63 sub $0x63,%eax + 4a4: 83 f8 15 cmp $0x15,%eax + 4a7: 77 17 ja 4c0 + 4a9: ff 24 85 88 07 00 00 jmp *0x788(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4b0: 8d 65 f4 lea -0xc(%ebp),%esp + 4b3: 5b pop %ebx + 4b4: 5e pop %esi + 4b5: 5f pop %edi + 4b6: 5d pop %ebp + 4b7: c3 ret + 4b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4bf: 90 nop + write(fd, &c, 1); + 4c0: 83 ec 04 sub $0x4,%esp + 4c3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4c6: 6a 01 push $0x1 + 4c8: 57 push %edi + 4c9: 56 push %esi + 4ca: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4ce: e8 50 fe ff ff call 323 + putc(fd, c); + 4d3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4d7: 83 c4 0c add $0xc,%esp + 4da: 88 55 e7 mov %dl,-0x19(%ebp) + 4dd: 6a 01 push $0x1 + 4df: 57 push %edi + 4e0: 56 push %esi + 4e1: e8 3d fe ff ff call 323 + putc(fd, c); + 4e6: 83 c4 10 add $0x10,%esp + state = 0; + 4e9: 31 c9 xor %ecx,%ecx + 4eb: eb 95 jmp 482 + 4ed: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 4f0: 83 ec 0c sub $0xc,%esp + 4f3: b9 10 00 00 00 mov $0x10,%ecx + 4f8: 6a 00 push $0x0 + 4fa: 8b 45 d0 mov -0x30(%ebp),%eax + 4fd: 8b 10 mov (%eax),%edx + 4ff: 89 f0 mov %esi,%eax + 501: e8 7a fe ff ff call 380 + ap++; + 506: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 50a: 83 c4 10 add $0x10,%esp + state = 0; + 50d: 31 c9 xor %ecx,%ecx + 50f: e9 6e ff ff ff jmp 482 + 514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 518: 8b 45 d0 mov -0x30(%ebp),%eax + 51b: 8b 10 mov (%eax),%edx + ap++; + 51d: 83 c0 04 add $0x4,%eax + 520: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 523: 85 d2 test %edx,%edx + 525: 0f 84 8d 00 00 00 je 5b8 + while (*s != 0) { + 52b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 52e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 530: 84 c0 test %al,%al + 532: 0f 84 4a ff ff ff je 482 + 538: 89 5d d4 mov %ebx,-0x2c(%ebp) + 53b: 89 d3 mov %edx,%ebx + 53d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 540: 83 ec 04 sub $0x4,%esp + s++; + 543: 83 c3 01 add $0x1,%ebx + 546: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 549: 6a 01 push $0x1 + 54b: 57 push %edi + 54c: 56 push %esi + 54d: e8 d1 fd ff ff call 323 + while (*s != 0) { + 552: 0f b6 03 movzbl (%ebx),%eax + 555: 83 c4 10 add $0x10,%esp + 558: 84 c0 test %al,%al + 55a: 75 e4 jne 540 + state = 0; + 55c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 55f: 31 c9 xor %ecx,%ecx + 561: e9 1c ff ff ff jmp 482 + 566: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 56d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 570: 83 ec 0c sub $0xc,%esp + 573: b9 0a 00 00 00 mov $0xa,%ecx + 578: 6a 01 push $0x1 + 57a: e9 7b ff ff ff jmp 4fa + 57f: 90 nop + putc(fd, *ap); + 580: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 583: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 586: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 588: 6a 01 push $0x1 + 58a: 57 push %edi + 58b: 56 push %esi + putc(fd, *ap); + 58c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 58f: e8 8f fd ff ff call 323 + ap++; + 594: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 598: 83 c4 10 add $0x10,%esp + state = 0; + 59b: 31 c9 xor %ecx,%ecx + 59d: e9 e0 fe ff ff jmp 482 + 5a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5a8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5ab: 83 ec 04 sub $0x4,%esp + 5ae: e9 2a ff ff ff jmp 4dd + 5b3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5b7: 90 nop + s = "(null)"; + 5b8: ba 7f 07 00 00 mov $0x77f,%edx + while (*s != 0) { + 5bd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5c0: b8 28 00 00 00 mov $0x28,%eax + 5c5: 89 d3 mov %edx,%ebx + 5c7: e9 74 ff ff ff jmp 540 + 5cc: 66 90 xchg %ax,%ax + 5ce: 66 90 xchg %ax,%ax + +000005d0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5d0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5d1: a1 8c 0a 00 00 mov 0xa8c,%eax +void free(void *ap) { + 5d6: 89 e5 mov %esp,%ebp + 5d8: 57 push %edi + 5d9: 56 push %esi + 5da: 53 push %ebx + 5db: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5de: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5e8: 89 c2 mov %eax,%edx + 5ea: 8b 00 mov (%eax),%eax + 5ec: 39 ca cmp %ecx,%edx + 5ee: 73 30 jae 620 + 5f0: 39 c1 cmp %eax,%ecx + 5f2: 72 04 jb 5f8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5f4: 39 c2 cmp %eax,%edx + 5f6: 72 f0 jb 5e8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 5f8: 8b 73 fc mov -0x4(%ebx),%esi + 5fb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5fe: 39 f8 cmp %edi,%eax + 600: 74 30 je 632 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 602: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 605: 8b 42 04 mov 0x4(%edx),%eax + 608: 8d 34 c2 lea (%edx,%eax,8),%esi + 60b: 39 f1 cmp %esi,%ecx + 60d: 74 3a je 649 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 60f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 611: 5b pop %ebx + freep = p; + 612: 89 15 8c 0a 00 00 mov %edx,0xa8c +} + 618: 5e pop %esi + 619: 5f pop %edi + 61a: 5d pop %ebp + 61b: c3 ret + 61c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 620: 39 c2 cmp %eax,%edx + 622: 72 c4 jb 5e8 + 624: 39 c1 cmp %eax,%ecx + 626: 73 c0 jae 5e8 + if (bp + bp->s.size == p->s.ptr) { + 628: 8b 73 fc mov -0x4(%ebx),%esi + 62b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 62e: 39 f8 cmp %edi,%eax + 630: 75 d0 jne 602 + bp->s.size += p->s.ptr->s.size; + 632: 03 70 04 add 0x4(%eax),%esi + 635: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 638: 8b 02 mov (%edx),%eax + 63a: 8b 00 mov (%eax),%eax + 63c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 63f: 8b 42 04 mov 0x4(%edx),%eax + 642: 8d 34 c2 lea (%edx,%eax,8),%esi + 645: 39 f1 cmp %esi,%ecx + 647: 75 c6 jne 60f + p->s.size += bp->s.size; + 649: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 64c: 89 15 8c 0a 00 00 mov %edx,0xa8c + p->s.size += bp->s.size; + 652: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 655: 8b 4b f8 mov -0x8(%ebx),%ecx + 658: 89 0a mov %ecx,(%edx) +} + 65a: 5b pop %ebx + 65b: 5e pop %esi + 65c: 5f pop %edi + 65d: 5d pop %ebp + 65e: c3 ret + 65f: 90 nop + +00000660 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 660: 55 push %ebp + 661: 89 e5 mov %esp,%ebp + 663: 57 push %edi + 664: 56 push %esi + 665: 53 push %ebx + 666: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 669: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 66c: 8b 3d 8c 0a 00 00 mov 0xa8c,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 672: 8d 70 07 lea 0x7(%eax),%esi + 675: c1 ee 03 shr $0x3,%esi + 678: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 67b: 85 ff test %edi,%edi + 67d: 0f 84 9d 00 00 00 je 720 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 683: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 685: 8b 4a 04 mov 0x4(%edx),%ecx + 688: 39 f1 cmp %esi,%ecx + 68a: 73 6a jae 6f6 + 68c: bb 00 10 00 00 mov $0x1000,%ebx + 691: 39 de cmp %ebx,%esi + 693: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 696: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 69d: 89 45 e4 mov %eax,-0x1c(%ebp) + 6a0: eb 17 jmp 6b9 + 6a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6a8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6aa: 8b 48 04 mov 0x4(%eax),%ecx + 6ad: 39 f1 cmp %esi,%ecx + 6af: 73 4f jae 700 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6b1: 8b 3d 8c 0a 00 00 mov 0xa8c,%edi + 6b7: 89 c2 mov %eax,%edx + 6b9: 39 d7 cmp %edx,%edi + 6bb: 75 eb jne 6a8 + p = sbrk(nu * sizeof(Header)); + 6bd: 83 ec 0c sub $0xc,%esp + 6c0: ff 75 e4 push -0x1c(%ebp) + 6c3: e8 3b fc ff ff call 303 + if (p == (char*)-1) { + 6c8: 83 c4 10 add $0x10,%esp + 6cb: 83 f8 ff cmp $0xffffffff,%eax + 6ce: 74 1c je 6ec + hp->s.size = nu; + 6d0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6d3: 83 ec 0c sub $0xc,%esp + 6d6: 83 c0 08 add $0x8,%eax + 6d9: 50 push %eax + 6da: e8 f1 fe ff ff call 5d0 + return freep; + 6df: 8b 15 8c 0a 00 00 mov 0xa8c,%edx + if ((p = morecore(nunits)) == 0) { + 6e5: 83 c4 10 add $0x10,%esp + 6e8: 85 d2 test %edx,%edx + 6ea: 75 bc jne 6a8 + return 0; + } + } + } +} + 6ec: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 6ef: 31 c0 xor %eax,%eax +} + 6f1: 5b pop %ebx + 6f2: 5e pop %esi + 6f3: 5f pop %edi + 6f4: 5d pop %ebp + 6f5: c3 ret + if (p->s.size >= nunits) { + 6f6: 89 d0 mov %edx,%eax + 6f8: 89 fa mov %edi,%edx + 6fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 700: 39 ce cmp %ecx,%esi + 702: 74 4c je 750 + p->s.size -= nunits; + 704: 29 f1 sub %esi,%ecx + 706: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 709: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 70c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 70f: 89 15 8c 0a 00 00 mov %edx,0xa8c +} + 715: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 718: 83 c0 08 add $0x8,%eax +} + 71b: 5b pop %ebx + 71c: 5e pop %esi + 71d: 5f pop %edi + 71e: 5d pop %ebp + 71f: c3 ret + base.s.ptr = freep = prevp = &base; + 720: c7 05 8c 0a 00 00 90 movl $0xa90,0xa8c + 727: 0a 00 00 + base.s.size = 0; + 72a: bf 90 0a 00 00 mov $0xa90,%edi + base.s.ptr = freep = prevp = &base; + 72f: c7 05 90 0a 00 00 90 movl $0xa90,0xa90 + 736: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 739: 89 fa mov %edi,%edx + base.s.size = 0; + 73b: c7 05 94 0a 00 00 00 movl $0x0,0xa94 + 742: 00 00 00 + if (p->s.size >= nunits) { + 745: e9 42 ff ff ff jmp 68c + 74a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 750: 8b 08 mov (%eax),%ecx + 752: 89 0a mov %ecx,(%edx) + 754: eb b9 jmp 70f diff --git a/ln.d b/ln.d new file mode 100644 index 0000000..6728be9 --- /dev/null +++ b/ln.d @@ -0,0 +1 @@ +ln.o: ln.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/ln.o b/ln.o new file mode 100644 index 0000000..a450647 Binary files /dev/null and b/ln.o differ diff --git a/ln.sym b/ln.sym new file mode 100644 index 0000000..b861a73 --- /dev/null +++ b/ln.sym @@ -0,0 +1,50 @@ +00000000 ln.c +00000000 ulib.c +00000000 printf.c +00000380 printint +000007e0 digits.0 +00000000 umalloc.c +00000a8c freep +00000a90 base +00000060 strcpy +00000430 printf +0000035b greeting +00000280 memmove +0000032b mknod +00000180 gets +000002fb getpid +0000036b screen +00000660 malloc +0000030b sleep +000002c3 pipe +00000353 getch +00000323 write +000002e3 fstat +000002d3 kill +000002eb chdir +000002db exec +000002bb wait +000002cb read +00000333 unlink +000002ab fork +00000303 sbrk +00000313 uptime +00000a8c __bss_start +00000120 memset +00000000 main +00000090 strcmp +00000363 shutdown +000002f3 dup +000001f0 stat +00000a8c _edata +00000a98 _end +0000033b link +000002b3 exit +00000240 atoi +00000373 cls +000000f0 strlen +0000031b open +00000140 strchr +00000343 mkdir +0000034b close +000005d0 free diff --git a/log.d b/log.d new file mode 100644 index 0000000..04c8930 --- /dev/null +++ b/log.d @@ -0,0 +1,2 @@ +log.o: log.c /usr/include/stdc-predef.h types.h defs.h param.h spinlock.h \ + sleeplock.h fs.h buf.h diff --git a/log.o b/log.o new file mode 100644 index 0000000..c8fa57c Binary files /dev/null and b/log.o differ diff --git a/ls.asm b/ls.asm new file mode 100644 index 0000000..dc6a484 --- /dev/null +++ b/ls.asm @@ -0,0 +1,1466 @@ + +_ls: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + 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 + 23: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 27: 90 nop + ls("."); + exit(); + } + for(i=1; i + for(i=1; i + exit(); + 3d: e8 51 05 00 00 call 593 + ls("."); + 42: 83 ec 0c sub $0xc,%esp + 45: 68 80 0a 00 00 push $0xa80 + 4a: e8 b1 00 00 00 call 100 + exit(); + 4f: e8 3f 05 00 00 call 593 + 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 : +{ + 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 + 71: 83 c4 10 add $0x10,%esp + 74: 01 f0 add %esi,%eax + 76: 89 c3 mov %eax,%ebx + 78: 73 0f jae 89 + 7a: eb 12 jmp 8e + 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 + 87: 89 c3 mov %eax,%ebx + 89: 80 3b 2f cmpb $0x2f,(%ebx) + 8c: 75 f2 jne 80 + 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 + 9a: 83 c4 10 add $0x10,%esp + 9d: 83 f8 0d cmp $0xd,%eax + a0: 77 4a ja ec + memmove(buf, p, strlen(p)); + a2: 83 ec 0c sub $0xc,%esp + a5: 53 push %ebx + a6: e8 25 03 00 00 call 3d0 + ab: 83 c4 0c add $0xc,%esp + ae: 50 push %eax + af: 53 push %ebx + b0: 68 14 0e 00 00 push $0xe14 + b5: e8 a6 04 00 00 call 560 + memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); + ba: 89 1c 24 mov %ebx,(%esp) + bd: e8 0e 03 00 00 call 3d0 + c2: 89 1c 24 mov %ebx,(%esp) + return buf; + c5: bb 14 0e 00 00 mov $0xe14,%ebx + memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); + ca: 89 c6 mov %eax,%esi + cc: e8 ff 02 00 00 call 3d0 + d1: ba 0e 00 00 00 mov $0xe,%edx + d6: 83 c4 0c add $0xc,%esp + d9: 29 f2 sub %esi,%edx + db: 05 14 0e 00 00 add $0xe14,%eax + e0: 52 push %edx + e1: 6a 20 push $0x20 + e3: 50 push %eax + e4: e8 17 03 00 00 call 400 + 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 : +{ + 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 + 117: 83 c4 10 add $0x10,%esp + 11a: 85 c0 test %eax,%eax + 11c: 0f 88 9e 01 00 00 js 2c0 + 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 + 134: 83 c4 10 add $0x10,%esp + 137: 85 c0 test %eax,%eax + 139: 0f 88 c1 01 00 00 js 300 + 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 + 14c: 66 83 f8 02 cmp $0x2,%ax + 150: 74 1e je 170 + close(fd); + 152: 83 ec 0c sub $0xc,%esp + 155: 53 push %ebx + 156: e8 d0 04 00 00 call 62b + 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 + 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 60 0a 00 00 push $0xa60 + 19d: 6a 01 push $0x1 + 19f: e8 6c 05 00 00 call 710 + break; + 1a4: 83 c4 20 add $0x20,%esp + 1a7: eb a9 jmp 152 + 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 + 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 + 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 + p = buf+strlen(buf); + 1da: 89 3c 24 mov %edi,(%esp) + 1dd: e8 ee 01 00 00 call 3d0 + 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 + 212: 83 c4 10 add $0x10,%esp + 215: 83 f8 10 cmp $0x10,%eax + 218: 0f 85 34 ff ff ff jne 152 + if(de.inum == 0) + 21e: 66 83 bd c4 fd ff ff cmpw $0x0,-0x23c(%ebp) + 225: 00 + 226: 74 d8 je 200 + 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 + 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 + 252: 83 c4 10 add $0x10,%esp + 255: 85 c0 test %eax,%eax + 257: 0f 88 cb 00 00 00 js 328 + 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 + 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 60 0a 00 00 push $0xa60 + 2a7: 6a 01 push $0x1 + 2a9: e8 62 04 00 00 call 710 + 2ae: 83 c4 20 add $0x20,%esp + 2b1: e9 4a ff ff ff jmp 200 + 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 38 0a 00 00 push $0xa38 + 2c9: 6a 02 push $0x2 + 2cb: e8 40 04 00 00 call 710 + 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 6d 0a 00 00 push $0xa6d + 2e8: 6a 01 push $0x1 + 2ea: e8 21 04 00 00 call 710 + break; + 2ef: 83 c4 10 add $0x10,%esp + 2f2: e9 5b fe ff ff jmp 152 + 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 4c 0a 00 00 push $0xa4c + 309: 6a 02 push $0x2 + 30b: e8 00 04 00 00 call 710 + close(fd); + 310: 89 1c 24 mov %ebx,(%esp) + 313: e8 13 03 00 00 call 62b + 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 4c 0a 00 00 push $0xa4c + 331: 6a 01 push $0x1 + 333: e8 d8 03 00 00 call 710 + continue; + 338: 83 c4 10 add $0x10,%esp + 33b: e9 c0 fe ff ff jmp 200 + +00000340 : +#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 + ; + } + 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 : + +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 + 381: eb 3a jmp 3bd + 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 + 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 + } + 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 + 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 : + +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 + 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 + ; + } + 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 : + +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 : + +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 + 431: eb 1d jmp 450 + 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 + if (*s == c) { + 443: 38 d1 cmp %dl,%cl + 445: 75 f1 jne 438 + 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 : + +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 + 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 + if (cc < 1) { + 47d: 83 c4 10 add $0x10,%esp + 480: 85 c0 test %eax,%eax + 482: 7e 1d jle 4a1 + 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 + 493: 3c 0d cmp $0xd,%al + 495: 74 19 je 4b0 + 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 + 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 : + +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 + if (fd < 0) { + 4e2: 83 c4 10 add $0x10,%esp + 4e5: 85 c0 test %eax,%eax + 4e7: 78 27 js 510 + 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 + 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 + 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 + 517: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 51e: 66 90 xchg %ax,%ax + +00000520 : + +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 + 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 + } + 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 : + +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 + 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 + } + return vdst; +} + 585: 5e pop %esi + 586: 89 d0 mov %edx,%eax + 588: 5f pop %edi + 589: 5d pop %ebp + 58a: c3 ret + +0000058b : +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 : +SYSCALL(exit) + 593: b8 02 00 00 00 mov $0x2,%eax + 598: cd 40 int $0x40 + 59a: c3 ret + +0000059b : +SYSCALL(wait) + 59b: b8 03 00 00 00 mov $0x3,%eax + 5a0: cd 40 int $0x40 + 5a2: c3 ret + +000005a3 : +SYSCALL(pipe) + 5a3: b8 04 00 00 00 mov $0x4,%eax + 5a8: cd 40 int $0x40 + 5aa: c3 ret + +000005ab : +SYSCALL(read) + 5ab: b8 05 00 00 00 mov $0x5,%eax + 5b0: cd 40 int $0x40 + 5b2: c3 ret + +000005b3 : +SYSCALL(kill) + 5b3: b8 06 00 00 00 mov $0x6,%eax + 5b8: cd 40 int $0x40 + 5ba: c3 ret + +000005bb : +SYSCALL(exec) + 5bb: b8 07 00 00 00 mov $0x7,%eax + 5c0: cd 40 int $0x40 + 5c2: c3 ret + +000005c3 : +SYSCALL(fstat) + 5c3: b8 08 00 00 00 mov $0x8,%eax + 5c8: cd 40 int $0x40 + 5ca: c3 ret + +000005cb : +SYSCALL(chdir) + 5cb: b8 09 00 00 00 mov $0x9,%eax + 5d0: cd 40 int $0x40 + 5d2: c3 ret + +000005d3 : +SYSCALL(dup) + 5d3: b8 0a 00 00 00 mov $0xa,%eax + 5d8: cd 40 int $0x40 + 5da: c3 ret + +000005db : +SYSCALL(getpid) + 5db: b8 0b 00 00 00 mov $0xb,%eax + 5e0: cd 40 int $0x40 + 5e2: c3 ret + +000005e3 : +SYSCALL(sbrk) + 5e3: b8 0c 00 00 00 mov $0xc,%eax + 5e8: cd 40 int $0x40 + 5ea: c3 ret + +000005eb : +SYSCALL(sleep) + 5eb: b8 0d 00 00 00 mov $0xd,%eax + 5f0: cd 40 int $0x40 + 5f2: c3 ret + +000005f3 : +SYSCALL(uptime) + 5f3: b8 0e 00 00 00 mov $0xe,%eax + 5f8: cd 40 int $0x40 + 5fa: c3 ret + +000005fb : +SYSCALL(open) + 5fb: b8 0f 00 00 00 mov $0xf,%eax + 600: cd 40 int $0x40 + 602: c3 ret + +00000603 : +SYSCALL(write) + 603: b8 10 00 00 00 mov $0x10,%eax + 608: cd 40 int $0x40 + 60a: c3 ret + +0000060b : +SYSCALL(mknod) + 60b: b8 11 00 00 00 mov $0x11,%eax + 610: cd 40 int $0x40 + 612: c3 ret + +00000613 : +SYSCALL(unlink) + 613: b8 12 00 00 00 mov $0x12,%eax + 618: cd 40 int $0x40 + 61a: c3 ret + +0000061b : +SYSCALL(link) + 61b: b8 13 00 00 00 mov $0x13,%eax + 620: cd 40 int $0x40 + 622: c3 ret + +00000623 : +SYSCALL(mkdir) + 623: b8 14 00 00 00 mov $0x14,%eax + 628: cd 40 int $0x40 + 62a: c3 ret + +0000062b : +SYSCALL(close) + 62b: b8 15 00 00 00 mov $0x15,%eax + 630: cd 40 int $0x40 + 632: c3 ret + +00000633 : +SYSCALL(getch) + 633: b8 16 00 00 00 mov $0x16,%eax + 638: cd 40 int $0x40 + 63a: c3 ret + +0000063b : +SYSCALL(greeting) + 63b: b8 17 00 00 00 mov $0x17,%eax + 640: cd 40 int $0x40 + 642: c3 ret + +00000643 : +SYSCALL(shutdown) + 643: b8 18 00 00 00 mov $0x18,%eax + 648: cd 40 int $0x40 + 64a: c3 ret + +0000064b : +SYSCALL(screen) + 64b: b8 19 00 00 00 mov $0x19,%eax + 650: cd 40 int $0x40 + 652: c3 ret + +00000653 : +SYSCALL(cls) + 653: b8 1a 00 00 00 mov $0x1a,%eax + 658: cd 40 int $0x40 + 65a: c3 ret + 65b: 66 90 xchg %ax,%ax + 65d: 66 90 xchg %ax,%ax + 65f: 90 nop + +00000660 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 660: 55 push %ebp + 661: 89 e5 mov %esp,%ebp + 663: 57 push %edi + 664: 56 push %esi + 665: 53 push %ebx + 666: 83 ec 3c sub $0x3c,%esp + 669: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 66c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 66e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 671: 85 d2 test %edx,%edx + 673: 0f 89 7f 00 00 00 jns 6f8 + 679: f6 45 08 01 testb $0x1,0x8(%ebp) + 67d: 74 79 je 6f8 + neg = 1; + 67f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 686: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 688: 31 db xor %ebx,%ebx + 68a: 8d 75 d7 lea -0x29(%ebp),%esi + 68d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 690: 89 c8 mov %ecx,%eax + 692: 31 d2 xor %edx,%edx + 694: 89 cf mov %ecx,%edi + 696: f7 75 c4 divl -0x3c(%ebp) + 699: 0f b6 92 e4 0a 00 00 movzbl 0xae4(%edx),%edx + 6a0: 89 45 c0 mov %eax,-0x40(%ebp) + 6a3: 89 d8 mov %ebx,%eax + 6a5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 6a8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 6ab: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 6ae: 39 7d c4 cmp %edi,-0x3c(%ebp) + 6b1: 76 dd jbe 690 + if (neg) { + 6b3: 8b 4d bc mov -0x44(%ebp),%ecx + 6b6: 85 c9 test %ecx,%ecx + 6b8: 74 0c je 6c6 + buf[i++] = '-'; + 6ba: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 6bf: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 6c1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 6c6: 8b 7d b8 mov -0x48(%ebp),%edi + 6c9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 6cd: eb 07 jmp 6d6 + 6cf: 90 nop + putc(fd, buf[i]); + 6d0: 0f b6 13 movzbl (%ebx),%edx + 6d3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 6d6: 83 ec 04 sub $0x4,%esp + 6d9: 88 55 d7 mov %dl,-0x29(%ebp) + 6dc: 6a 01 push $0x1 + 6de: 56 push %esi + 6df: 57 push %edi + 6e0: e8 1e ff ff ff call 603 + while (--i >= 0) { + 6e5: 83 c4 10 add $0x10,%esp + 6e8: 39 de cmp %ebx,%esi + 6ea: 75 e4 jne 6d0 + } +} + 6ec: 8d 65 f4 lea -0xc(%ebp),%esp + 6ef: 5b pop %ebx + 6f0: 5e pop %esi + 6f1: 5f pop %edi + 6f2: 5d pop %ebp + 6f3: c3 ret + 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 6f8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 6ff: eb 87 jmp 688 + 701: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 708: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 70f: 90 nop + +00000710 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 710: 55 push %ebp + 711: 89 e5 mov %esp,%ebp + 713: 57 push %edi + 714: 56 push %esi + 715: 53 push %ebx + 716: 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++) { + 719: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 71c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 71f: 0f b6 13 movzbl (%ebx),%edx + 722: 84 d2 test %dl,%dl + 724: 74 6a je 790 + ap = (uint*)(void*)&fmt + 1; + 726: 8d 45 10 lea 0x10(%ebp),%eax + 729: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 72c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 72f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 731: 89 45 d0 mov %eax,-0x30(%ebp) + 734: eb 36 jmp 76c + 736: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 73d: 8d 76 00 lea 0x0(%esi),%esi + 740: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 743: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 748: 83 f8 25 cmp $0x25,%eax + 74b: 74 15 je 762 + write(fd, &c, 1); + 74d: 83 ec 04 sub $0x4,%esp + 750: 88 55 e7 mov %dl,-0x19(%ebp) + 753: 6a 01 push $0x1 + 755: 57 push %edi + 756: 56 push %esi + 757: e8 a7 fe ff ff call 603 + 75c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 75f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 762: 0f b6 13 movzbl (%ebx),%edx + 765: 83 c3 01 add $0x1,%ebx + 768: 84 d2 test %dl,%dl + 76a: 74 24 je 790 + c = fmt[i] & 0xff; + 76c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 76f: 85 c9 test %ecx,%ecx + 771: 74 cd je 740 + } + } + else if (state == '%') { + 773: 83 f9 25 cmp $0x25,%ecx + 776: 75 ea jne 762 + if (c == 'd') { + 778: 83 f8 25 cmp $0x25,%eax + 77b: 0f 84 07 01 00 00 je 888 + 781: 83 e8 63 sub $0x63,%eax + 784: 83 f8 15 cmp $0x15,%eax + 787: 77 17 ja 7a0 + 789: ff 24 85 8c 0a 00 00 jmp *0xa8c(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 790: 8d 65 f4 lea -0xc(%ebp),%esp + 793: 5b pop %ebx + 794: 5e pop %esi + 795: 5f pop %edi + 796: 5d pop %ebp + 797: c3 ret + 798: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 79f: 90 nop + write(fd, &c, 1); + 7a0: 83 ec 04 sub $0x4,%esp + 7a3: 88 55 d4 mov %dl,-0x2c(%ebp) + 7a6: 6a 01 push $0x1 + 7a8: 57 push %edi + 7a9: 56 push %esi + 7aa: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 7ae: e8 50 fe ff ff call 603 + putc(fd, c); + 7b3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 7b7: 83 c4 0c add $0xc,%esp + 7ba: 88 55 e7 mov %dl,-0x19(%ebp) + 7bd: 6a 01 push $0x1 + 7bf: 57 push %edi + 7c0: 56 push %esi + 7c1: e8 3d fe ff ff call 603 + putc(fd, c); + 7c6: 83 c4 10 add $0x10,%esp + state = 0; + 7c9: 31 c9 xor %ecx,%ecx + 7cb: eb 95 jmp 762 + 7cd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 7d0: 83 ec 0c sub $0xc,%esp + 7d3: b9 10 00 00 00 mov $0x10,%ecx + 7d8: 6a 00 push $0x0 + 7da: 8b 45 d0 mov -0x30(%ebp),%eax + 7dd: 8b 10 mov (%eax),%edx + 7df: 89 f0 mov %esi,%eax + 7e1: e8 7a fe ff ff call 660 + ap++; + 7e6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 7ea: 83 c4 10 add $0x10,%esp + state = 0; + 7ed: 31 c9 xor %ecx,%ecx + 7ef: e9 6e ff ff ff jmp 762 + 7f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 7f8: 8b 45 d0 mov -0x30(%ebp),%eax + 7fb: 8b 10 mov (%eax),%edx + ap++; + 7fd: 83 c0 04 add $0x4,%eax + 800: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 803: 85 d2 test %edx,%edx + 805: 0f 84 8d 00 00 00 je 898 + while (*s != 0) { + 80b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 80e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 810: 84 c0 test %al,%al + 812: 0f 84 4a ff ff ff je 762 + 818: 89 5d d4 mov %ebx,-0x2c(%ebp) + 81b: 89 d3 mov %edx,%ebx + 81d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 820: 83 ec 04 sub $0x4,%esp + s++; + 823: 83 c3 01 add $0x1,%ebx + 826: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 829: 6a 01 push $0x1 + 82b: 57 push %edi + 82c: 56 push %esi + 82d: e8 d1 fd ff ff call 603 + while (*s != 0) { + 832: 0f b6 03 movzbl (%ebx),%eax + 835: 83 c4 10 add $0x10,%esp + 838: 84 c0 test %al,%al + 83a: 75 e4 jne 820 + state = 0; + 83c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 83f: 31 c9 xor %ecx,%ecx + 841: e9 1c ff ff ff jmp 762 + 846: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 84d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 850: 83 ec 0c sub $0xc,%esp + 853: b9 0a 00 00 00 mov $0xa,%ecx + 858: 6a 01 push $0x1 + 85a: e9 7b ff ff ff jmp 7da + 85f: 90 nop + putc(fd, *ap); + 860: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 863: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 866: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 868: 6a 01 push $0x1 + 86a: 57 push %edi + 86b: 56 push %esi + putc(fd, *ap); + 86c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 86f: e8 8f fd ff ff call 603 + ap++; + 874: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 878: 83 c4 10 add $0x10,%esp + state = 0; + 87b: 31 c9 xor %ecx,%ecx + 87d: e9 e0 fe ff ff jmp 762 + 882: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 888: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 88b: 83 ec 04 sub $0x4,%esp + 88e: e9 2a ff ff ff jmp 7bd + 893: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 897: 90 nop + s = "(null)"; + 898: ba 82 0a 00 00 mov $0xa82,%edx + while (*s != 0) { + 89d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 8a0: b8 28 00 00 00 mov $0x28,%eax + 8a5: 89 d3 mov %edx,%ebx + 8a7: e9 74 ff ff ff jmp 820 + 8ac: 66 90 xchg %ax,%ax + 8ae: 66 90 xchg %ax,%ax + +000008b0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 8b0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 8b1: a1 24 0e 00 00 mov 0xe24,%eax +void free(void *ap) { + 8b6: 89 e5 mov %esp,%ebp + 8b8: 57 push %edi + 8b9: 56 push %esi + 8ba: 53 push %ebx + 8bb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 8be: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 8c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 8c8: 89 c2 mov %eax,%edx + 8ca: 8b 00 mov (%eax),%eax + 8cc: 39 ca cmp %ecx,%edx + 8ce: 73 30 jae 900 + 8d0: 39 c1 cmp %eax,%ecx + 8d2: 72 04 jb 8d8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 8d4: 39 c2 cmp %eax,%edx + 8d6: 72 f0 jb 8c8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 8d8: 8b 73 fc mov -0x4(%ebx),%esi + 8db: 8d 3c f1 lea (%ecx,%esi,8),%edi + 8de: 39 f8 cmp %edi,%eax + 8e0: 74 30 je 912 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 8e2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 8e5: 8b 42 04 mov 0x4(%edx),%eax + 8e8: 8d 34 c2 lea (%edx,%eax,8),%esi + 8eb: 39 f1 cmp %esi,%ecx + 8ed: 74 3a je 929 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 8ef: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 8f1: 5b pop %ebx + freep = p; + 8f2: 89 15 24 0e 00 00 mov %edx,0xe24 +} + 8f8: 5e pop %esi + 8f9: 5f pop %edi + 8fa: 5d pop %ebp + 8fb: c3 ret + 8fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 900: 39 c2 cmp %eax,%edx + 902: 72 c4 jb 8c8 + 904: 39 c1 cmp %eax,%ecx + 906: 73 c0 jae 8c8 + if (bp + bp->s.size == p->s.ptr) { + 908: 8b 73 fc mov -0x4(%ebx),%esi + 90b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 90e: 39 f8 cmp %edi,%eax + 910: 75 d0 jne 8e2 + bp->s.size += p->s.ptr->s.size; + 912: 03 70 04 add 0x4(%eax),%esi + 915: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 918: 8b 02 mov (%edx),%eax + 91a: 8b 00 mov (%eax),%eax + 91c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 91f: 8b 42 04 mov 0x4(%edx),%eax + 922: 8d 34 c2 lea (%edx,%eax,8),%esi + 925: 39 f1 cmp %esi,%ecx + 927: 75 c6 jne 8ef + p->s.size += bp->s.size; + 929: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 92c: 89 15 24 0e 00 00 mov %edx,0xe24 + p->s.size += bp->s.size; + 932: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 935: 8b 4b f8 mov -0x8(%ebx),%ecx + 938: 89 0a mov %ecx,(%edx) +} + 93a: 5b pop %ebx + 93b: 5e pop %esi + 93c: 5f pop %edi + 93d: 5d pop %ebp + 93e: c3 ret + 93f: 90 nop + +00000940 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 940: 55 push %ebp + 941: 89 e5 mov %esp,%ebp + 943: 57 push %edi + 944: 56 push %esi + 945: 53 push %ebx + 946: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 949: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 94c: 8b 3d 24 0e 00 00 mov 0xe24,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 952: 8d 70 07 lea 0x7(%eax),%esi + 955: c1 ee 03 shr $0x3,%esi + 958: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 95b: 85 ff test %edi,%edi + 95d: 0f 84 9d 00 00 00 je a00 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 963: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 965: 8b 4a 04 mov 0x4(%edx),%ecx + 968: 39 f1 cmp %esi,%ecx + 96a: 73 6a jae 9d6 + 96c: bb 00 10 00 00 mov $0x1000,%ebx + 971: 39 de cmp %ebx,%esi + 973: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 976: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 97d: 89 45 e4 mov %eax,-0x1c(%ebp) + 980: eb 17 jmp 999 + 982: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 988: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 98a: 8b 48 04 mov 0x4(%eax),%ecx + 98d: 39 f1 cmp %esi,%ecx + 98f: 73 4f jae 9e0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 991: 8b 3d 24 0e 00 00 mov 0xe24,%edi + 997: 89 c2 mov %eax,%edx + 999: 39 d7 cmp %edx,%edi + 99b: 75 eb jne 988 + p = sbrk(nu * sizeof(Header)); + 99d: 83 ec 0c sub $0xc,%esp + 9a0: ff 75 e4 push -0x1c(%ebp) + 9a3: e8 3b fc ff ff call 5e3 + if (p == (char*)-1) { + 9a8: 83 c4 10 add $0x10,%esp + 9ab: 83 f8 ff cmp $0xffffffff,%eax + 9ae: 74 1c je 9cc + hp->s.size = nu; + 9b0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 9b3: 83 ec 0c sub $0xc,%esp + 9b6: 83 c0 08 add $0x8,%eax + 9b9: 50 push %eax + 9ba: e8 f1 fe ff ff call 8b0 + return freep; + 9bf: 8b 15 24 0e 00 00 mov 0xe24,%edx + if ((p = morecore(nunits)) == 0) { + 9c5: 83 c4 10 add $0x10,%esp + 9c8: 85 d2 test %edx,%edx + 9ca: 75 bc jne 988 + return 0; + } + } + } +} + 9cc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 9cf: 31 c0 xor %eax,%eax +} + 9d1: 5b pop %ebx + 9d2: 5e pop %esi + 9d3: 5f pop %edi + 9d4: 5d pop %ebp + 9d5: c3 ret + if (p->s.size >= nunits) { + 9d6: 89 d0 mov %edx,%eax + 9d8: 89 fa mov %edi,%edx + 9da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 9e0: 39 ce cmp %ecx,%esi + 9e2: 74 4c je a30 + p->s.size -= nunits; + 9e4: 29 f1 sub %esi,%ecx + 9e6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 9e9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 9ec: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 9ef: 89 15 24 0e 00 00 mov %edx,0xe24 +} + 9f5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 9f8: 83 c0 08 add $0x8,%eax +} + 9fb: 5b pop %ebx + 9fc: 5e pop %esi + 9fd: 5f pop %edi + 9fe: 5d pop %ebp + 9ff: c3 ret + base.s.ptr = freep = prevp = &base; + a00: c7 05 24 0e 00 00 28 movl $0xe28,0xe24 + a07: 0e 00 00 + base.s.size = 0; + a0a: bf 28 0e 00 00 mov $0xe28,%edi + base.s.ptr = freep = prevp = &base; + a0f: c7 05 28 0e 00 00 28 movl $0xe28,0xe28 + a16: 0e 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + a19: 89 fa mov %edi,%edx + base.s.size = 0; + a1b: c7 05 2c 0e 00 00 00 movl $0x0,0xe2c + a22: 00 00 00 + if (p->s.size >= nunits) { + a25: e9 42 ff ff ff jmp 96c + a2a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + a30: 8b 08 mov (%eax),%ecx + a32: 89 0a mov %ecx,(%edx) + a34: eb b9 jmp 9ef diff --git a/ls.d b/ls.d new file mode 100644 index 0000000..a55b6d4 --- /dev/null +++ b/ls.d @@ -0,0 +1 @@ +ls.o: ls.c /usr/include/stdc-predef.h types.h stat.h user.h fs.h diff --git a/ls.o b/ls.o new file mode 100644 index 0000000..507e51c Binary files /dev/null and b/ls.o differ diff --git a/ls.sym b/ls.sym new file mode 100644 index 0000000..d66fda2 --- /dev/null +++ b/ls.sym @@ -0,0 +1,53 @@ +00000000 ls.c +00000e14 buf.0 +00000000 ulib.c +00000000 printf.c +00000660 printint +00000ae4 digits.0 +00000000 umalloc.c +00000e24 freep +00000e28 base +00000340 strcpy +00000060 fmtname +00000710 printf +0000063b greeting +00000560 memmove +0000060b mknod +00000460 gets +000005db getpid +0000064b screen +00000940 malloc +000005eb sleep +000005a3 pipe +00000633 getch +00000603 write +000005c3 fstat +000005b3 kill +000005cb chdir +000005bb exec +0000059b wait +000005ab read +00000613 unlink +0000058b fork +000005e3 sbrk +000005f3 uptime +00000e14 __bss_start +00000400 memset +00000000 main +00000370 strcmp +00000643 shutdown +000005d3 dup +000004d0 stat +00000e14 _edata +00000e30 _end +0000061b link +00000100 ls +00000593 exit +00000520 atoi +00000653 cls +000003d0 strlen +000005fb open +00000420 strchr +00000623 mkdir +0000062b close +000008b0 free diff --git a/main.d b/main.d new file mode 100644 index 0000000..354dab4 --- /dev/null +++ b/main.d @@ -0,0 +1,2 @@ +main.o: main.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h diff --git a/main.o b/main.o new file mode 100644 index 0000000..b7206c5 Binary files /dev/null and b/main.o differ diff --git a/maze.asm b/maze.asm new file mode 100644 index 0000000..b62baa7 --- /dev/null +++ b/maze.asm @@ -0,0 +1,1386 @@ + +_maze: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + + int range = end - start + 1; + return (rngnumber() + seed) % (range) + start; +} + +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: 51 push %ecx + 11: 83 ec 08 sub $0x8,%esp + 14: 8b 39 mov (%ecx),%edi + 16: 8b 71 04 mov 0x4(%ecx),%esi + int lines = 1000; + int seed = getpid(); + 19: e8 5d 04 00 00 call 47b + + for (int i = 1; i < argc; i++) { + 1e: 83 ff 01 cmp $0x1,%edi + 21: 7e 6f jle 92 + 23: bb 01 00 00 00 mov $0x1,%ebx + 28: eb 3b jmp 65 + 2a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (strcmp(argv[i], "-l") == 0) + { + lines = atoi(argv[i + 1]); + } + else if (strcmp(argv[i], "-s") == 0) + 30: 83 ec 08 sub $0x8,%esp + 33: 68 db 08 00 00 push $0x8db + 38: ff 34 9e push (%esi,%ebx,4) + 3b: e8 d0 01 00 00 call 210 + 40: 83 c4 10 add $0x10,%esp + 43: 85 c0 test %eax,%eax + 45: 74 35 je 7c + { + seed = atoi(argv[i + 1]); + } + else if (strcmp(argv[i], "-help") == 0) + 47: 83 ec 08 sub $0x8,%esp + 4a: 68 de 08 00 00 push $0x8de + 4f: ff 34 9e push (%esi,%ebx,4) + 52: e8 b9 01 00 00 call 210 + 57: 83 c4 10 add $0x10,%esp + 5a: 85 c0 test %eax,%eax + 5c: 74 69 je c7 + for (int i = 1; i < argc; i++) { + 5e: 83 c3 01 add $0x1,%ebx + 61: 39 df cmp %ebx,%edi + 63: 74 2d je 92 + if (strcmp(argv[i], "-l") == 0) + 65: 83 ec 08 sub $0x8,%esp + 68: 68 d8 08 00 00 push $0x8d8 + 6d: ff 34 9e push (%esi,%ebx,4) + 70: e8 9b 01 00 00 call 210 + 75: 83 c4 10 add $0x10,%esp + 78: 85 c0 test %eax,%eax + 7a: 75 b4 jne 30 + seed = atoi(argv[i + 1]); + 7c: 83 ec 0c sub $0xc,%esp + 7f: ff 74 9e 04 push 0x4(%esi,%ebx,4) + for (int i = 1; i < argc; i++) { + 83: 83 c3 01 add $0x1,%ebx + seed = atoi(argv[i + 1]); + 86: e8 35 03 00 00 call 3c0 + 8b: 83 c4 10 add $0x10,%esp + for (int i = 1; i < argc; i++) { + 8e: 39 df cmp %ebx,%edi + 90: 75 d3 jne 65 + exit(); + return 0; + } + } + + cls(); + 92: e8 5c 04 00 00 call 4f3 + + printf(1, "Start Maze (DISABLED)\n"); + 97: 83 ec 08 sub $0x8,%esp + 9a: 68 ee 08 00 00 push $0x8ee + 9f: 6a 01 push $0x1 + a1: e8 0a 05 00 00 call 5b0 + printf(1, "This does not work on the azure servers, but it would generate a random x lines of characters to look like a maze, similar to the old c64 basic program.\n"); + a6: 58 pop %eax + a7: 5a pop %edx + a8: 68 ac 09 00 00 push $0x9ac + ad: 6a 01 push $0x1 + af: e8 fc 04 00 00 call 5b0 + printf(1, "I could have used the slashes but they look aweful in this font so use the count app instead.\n\n"); + b4: 59 pop %ecx + b5: 5b pop %ebx + b6: 68 48 0a 00 00 push $0xa48 + bb: 6a 01 push $0x1 + bd: e8 ee 04 00 00 call 5b0 + exit(); + c2: e8 6c 03 00 00 call 433 + printf(1, "Generates X lines of random maze.\n"); + c7: 56 push %esi + c8: 56 push %esi + c9: 68 08 09 00 00 push $0x908 + ce: 6a 01 push $0x1 + d0: e8 db 04 00 00 call 5b0 + printf(1, "Options:\n"); + d5: 5f pop %edi + d6: 58 pop %eax + d7: 68 e4 08 00 00 push $0x8e4 + dc: 6a 01 push $0x1 + de: e8 cd 04 00 00 call 5b0 + printf(1, "-l [Number] : Sets number of lines to generate for the maze.\n"); + e3: 58 pop %eax + e4: 5a pop %edx + e5: 68 2c 09 00 00 push $0x92c + ea: 6a 01 push $0x1 + ec: e8 bf 04 00 00 call 5b0 + printf(1, "-s [Number] : Sets the current seed for the random function.\n"); + f1: 59 pop %ecx + f2: 5b pop %ebx + f3: 68 6c 09 00 00 push $0x96c + f8: 6a 01 push $0x1 + fa: e8 b1 04 00 00 call 5b0 + exit(); + ff: e8 2f 03 00 00 call 433 + 104: 66 90 xchg %ax,%ax + 106: 66 90 xchg %ax,%ax + 108: 66 90 xchg %ax,%ax + 10a: 66 90 xchg %ax,%ax + 10c: 66 90 xchg %ax,%ax + 10e: 66 90 xchg %ax,%ax + +00000110 : + b = ((z1 << 6) ^ z1) >> 13; + 110: 8b 0d 1c 0e 00 00 mov 0xe1c,%ecx + b = ((z2 << 2) ^ z2) >> 27; + 116: a1 18 0e 00 00 mov 0xe18,%eax +{ + 11b: 55 push %ebp + b = ((z1 << 6) ^ z1) >> 13; + 11c: 89 ca mov %ecx,%edx + 11e: c1 e2 06 shl $0x6,%edx +{ + 121: 89 e5 mov %esp,%ebp + 123: 56 push %esi + b = ((z4 << 3) ^ z4) >> 12; + 124: 8b 35 10 0e 00 00 mov 0xe10,%esi + b = ((z1 << 6) ^ z1) >> 13; + 12a: 31 ca xor %ecx,%edx + z1 = ((z1 & 4294967294U) << 18) ^ b; + 12c: c1 e1 12 shl $0x12,%ecx +{ + 12f: 53 push %ebx + z1 = ((z1 & 4294967294U) << 18) ^ b; + 130: 81 e1 00 00 f8 ff and $0xfff80000,%ecx + b = ((z1 << 6) ^ z1) >> 13; + 136: c1 ea 0d shr $0xd,%edx + z1 = ((z1 & 4294967294U) << 18) ^ b; + 139: 31 ca xor %ecx,%edx + b = ((z2 << 2) ^ z2) >> 27; + 13b: 8d 0c 85 00 00 00 00 lea 0x0(,%eax,4),%ecx + 142: 31 c8 xor %ecx,%eax + z2 = ((z2 & 4294967288U) << 2) ^ b; + 144: 83 e1 e0 and $0xffffffe0,%ecx + z1 = ((z1 & 4294967294U) << 18) ^ b; + 147: 89 15 1c 0e 00 00 mov %edx,0xe1c + b = ((z2 << 2) ^ z2) >> 27; + 14d: c1 e8 1b shr $0x1b,%eax + z2 = ((z2 & 4294967288U) << 2) ^ b; + 150: 31 c8 xor %ecx,%eax + b = ((z3 << 13) ^ z3) >> 21; + 152: 8b 0d 14 0e 00 00 mov 0xe14,%ecx + z2 = ((z2 & 4294967288U) << 2) ^ b; + 158: a3 18 0e 00 00 mov %eax,0xe18 + return (z1 ^ z2 ^ z3 ^ z4) / 2; + 15d: 31 d0 xor %edx,%eax + b = ((z3 << 13) ^ z3) >> 21; + 15f: 89 cb mov %ecx,%ebx + 161: c1 e3 0d shl $0xd,%ebx + 164: 31 cb xor %ecx,%ebx + z3 = ((z3 & 4294967280U) << 7) ^ b; + 166: c1 e1 07 shl $0x7,%ecx + 169: 81 e1 00 f8 ff ff and $0xfffff800,%ecx + b = ((z3 << 13) ^ z3) >> 21; + 16f: c1 eb 15 shr $0x15,%ebx + z3 = ((z3 & 4294967280U) << 7) ^ b; + 172: 31 cb xor %ecx,%ebx + b = ((z4 << 3) ^ z4) >> 12; + 174: 8d 0c f5 00 00 00 00 lea 0x0(,%esi,8),%ecx + 17b: 31 f1 xor %esi,%ecx + z4 = ((z4 & 4294967168U) << 13) ^ b; + 17d: c1 e6 0d shl $0xd,%esi + return (z1 ^ z2 ^ z3 ^ z4) / 2; + 180: 31 d8 xor %ebx,%eax + z3 = ((z3 & 4294967280U) << 7) ^ b; + 182: 89 1d 14 0e 00 00 mov %ebx,0xe14 + z4 = ((z4 & 4294967168U) << 13) ^ b; + 188: 81 e6 00 00 f0 ff and $0xfff00000,%esi + b = ((z4 << 3) ^ z4) >> 12; + 18e: c1 e9 0c shr $0xc,%ecx +} + 191: 5b pop %ebx + z4 = ((z4 & 4294967168U) << 13) ^ b; + 192: 31 f1 xor %esi,%ecx +} + 194: 5e pop %esi + 195: 5d pop %ebp + return (z1 ^ z2 ^ z3 ^ z4) / 2; + 196: 31 c8 xor %ecx,%eax + z4 = ((z4 & 4294967168U) << 13) ^ b; + 198: 89 0d 10 0e 00 00 mov %ecx,0xe10 + return (z1 ^ z2 ^ z3 ^ z4) / 2; + 19e: d1 e8 shr %eax +} + 1a0: c3 ret + 1a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1af: 90 nop + +000001b0 : +{ + 1b0: 55 push %ebp + 1b1: 89 e5 mov %esp,%ebp + 1b3: 56 push %esi + 1b4: 8b 75 08 mov 0x8(%ebp),%esi + 1b7: 53 push %ebx + 1b8: 8b 5d 0c mov 0xc(%ebp),%ebx + if (end < start) + 1bb: 39 f3 cmp %esi,%ebx + 1bd: 7d 06 jge 1c5 + 1bf: 89 f0 mov %esi,%eax + 1c1: 89 de mov %ebx,%esi + 1c3: 89 c3 mov %eax,%ebx + return (rngnumber() + seed) % (range) + start; + 1c5: e8 46 ff ff ff call 110 + int range = end - start + 1; + 1ca: 29 f3 sub %esi,%ebx + return (rngnumber() + seed) % (range) + start; + 1cc: 03 45 10 add 0x10(%ebp),%eax + 1cf: 31 d2 xor %edx,%edx + int range = end - start + 1; + 1d1: 83 c3 01 add $0x1,%ebx + return (rngnumber() + seed) % (range) + start; + 1d4: f7 f3 div %ebx +} + 1d6: 5b pop %ebx + return (rngnumber() + seed) % (range) + start; + 1d7: 8d 04 32 lea (%edx,%esi,1),%eax +} + 1da: 5e pop %esi + 1db: 5d pop %ebp + 1dc: c3 ret + 1dd: 66 90 xchg %ax,%ax + 1df: 90 nop + +000001e0 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 1e0: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 1e1: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 1e3: 89 e5 mov %esp,%ebp + 1e5: 53 push %ebx + 1e6: 8b 4d 08 mov 0x8(%ebp),%ecx + 1e9: 8b 5d 0c mov 0xc(%ebp),%ebx + 1ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 1f0: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 1f4: 88 14 01 mov %dl,(%ecx,%eax,1) + 1f7: 83 c0 01 add $0x1,%eax + 1fa: 84 d2 test %dl,%dl + 1fc: 75 f2 jne 1f0 + ; + } + return os; +} + 1fe: 8b 5d fc mov -0x4(%ebp),%ebx + 201: 89 c8 mov %ecx,%eax + 203: c9 leave + 204: c3 ret + 205: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 20c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000210 : + +int strcmp(const char *p, const char *q) { + 210: 55 push %ebp + 211: 89 e5 mov %esp,%ebp + 213: 53 push %ebx + 214: 8b 55 08 mov 0x8(%ebp),%edx + 217: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 21a: 0f b6 02 movzbl (%edx),%eax + 21d: 84 c0 test %al,%al + 21f: 75 17 jne 238 + 221: eb 3a jmp 25d + 223: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 227: 90 nop + 228: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 22c: 83 c2 01 add $0x1,%edx + 22f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 232: 84 c0 test %al,%al + 234: 74 1a je 250 + p++, q++; + 236: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 238: 0f b6 19 movzbl (%ecx),%ebx + 23b: 38 c3 cmp %al,%bl + 23d: 74 e9 je 228 + } + return (uchar) * p - (uchar) * q; + 23f: 29 d8 sub %ebx,%eax +} + 241: 8b 5d fc mov -0x4(%ebp),%ebx + 244: c9 leave + 245: c3 ret + 246: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 24d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 250: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 254: 31 c0 xor %eax,%eax + 256: 29 d8 sub %ebx,%eax +} + 258: 8b 5d fc mov -0x4(%ebp),%ebx + 25b: c9 leave + 25c: c3 ret + return (uchar) * p - (uchar) * q; + 25d: 0f b6 19 movzbl (%ecx),%ebx + 260: 31 c0 xor %eax,%eax + 262: eb db jmp 23f + 264: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 26f: 90 nop + +00000270 : + +uint strlen(const char *s) { + 270: 55 push %ebp + 271: 89 e5 mov %esp,%ebp + 273: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 276: 80 3a 00 cmpb $0x0,(%edx) + 279: 74 15 je 290 + 27b: 31 c0 xor %eax,%eax + 27d: 8d 76 00 lea 0x0(%esi),%esi + 280: 83 c0 01 add $0x1,%eax + 283: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 287: 89 c1 mov %eax,%ecx + 289: 75 f5 jne 280 + ; + } + return n; +} + 28b: 89 c8 mov %ecx,%eax + 28d: 5d pop %ebp + 28e: c3 ret + 28f: 90 nop + for (n = 0; s[n]; n++) { + 290: 31 c9 xor %ecx,%ecx +} + 292: 5d pop %ebp + 293: 89 c8 mov %ecx,%eax + 295: c3 ret + 296: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 29d: 8d 76 00 lea 0x0(%esi),%esi + +000002a0 : + +void* memset(void *dst, int c, uint n) { + 2a0: 55 push %ebp + 2a1: 89 e5 mov %esp,%ebp + 2a3: 57 push %edi + 2a4: 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" : + 2a7: 8b 4d 10 mov 0x10(%ebp),%ecx + 2aa: 8b 45 0c mov 0xc(%ebp),%eax + 2ad: 89 d7 mov %edx,%edi + 2af: fc cld + 2b0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 2b2: 8b 7d fc mov -0x4(%ebp),%edi + 2b5: 89 d0 mov %edx,%eax + 2b7: c9 leave + 2b8: c3 ret + 2b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000002c0 : + +char* strchr(const char *s, char c) { + 2c0: 55 push %ebp + 2c1: 89 e5 mov %esp,%ebp + 2c3: 8b 45 08 mov 0x8(%ebp),%eax + 2c6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 2ca: 0f b6 10 movzbl (%eax),%edx + 2cd: 84 d2 test %dl,%dl + 2cf: 75 12 jne 2e3 + 2d1: eb 1d jmp 2f0 + 2d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 2d7: 90 nop + 2d8: 0f b6 50 01 movzbl 0x1(%eax),%edx + 2dc: 83 c0 01 add $0x1,%eax + 2df: 84 d2 test %dl,%dl + 2e1: 74 0d je 2f0 + if (*s == c) { + 2e3: 38 d1 cmp %dl,%cl + 2e5: 75 f1 jne 2d8 + return (char*)s; + } + } + return 0; +} + 2e7: 5d pop %ebp + 2e8: c3 ret + 2e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 2f0: 31 c0 xor %eax,%eax +} + 2f2: 5d pop %ebp + 2f3: c3 ret + 2f4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 2ff: 90 nop + +00000300 : + +char* gets(char *buf, int max) { + 300: 55 push %ebp + 301: 89 e5 mov %esp,%ebp + 303: 57 push %edi + 304: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 305: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 308: 53 push %ebx + for (i = 0; i + 1 < max;) { + 309: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 30b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 30e: eb 27 jmp 337 + cc = read(0, &c, 1); + 310: 83 ec 04 sub $0x4,%esp + 313: 6a 01 push $0x1 + 315: 57 push %edi + 316: 6a 00 push $0x0 + 318: e8 2e 01 00 00 call 44b + if (cc < 1) { + 31d: 83 c4 10 add $0x10,%esp + 320: 85 c0 test %eax,%eax + 322: 7e 1d jle 341 + break; + } + buf[i++] = c; + 324: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 328: 8b 55 08 mov 0x8(%ebp),%edx + 32b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 32f: 3c 0a cmp $0xa,%al + 331: 74 1d je 350 + 333: 3c 0d cmp $0xd,%al + 335: 74 19 je 350 + for (i = 0; i + 1 < max;) { + 337: 89 de mov %ebx,%esi + 339: 83 c3 01 add $0x1,%ebx + 33c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 33f: 7c cf jl 310 + break; + } + } + buf[i] = '\0'; + 341: 8b 45 08 mov 0x8(%ebp),%eax + 344: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 348: 8d 65 f4 lea -0xc(%ebp),%esp + 34b: 5b pop %ebx + 34c: 5e pop %esi + 34d: 5f pop %edi + 34e: 5d pop %ebp + 34f: c3 ret + buf[i] = '\0'; + 350: 8b 45 08 mov 0x8(%ebp),%eax + 353: 89 de mov %ebx,%esi + 355: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 359: 8d 65 f4 lea -0xc(%ebp),%esp + 35c: 5b pop %ebx + 35d: 5e pop %esi + 35e: 5f pop %edi + 35f: 5d pop %ebp + 360: c3 ret + 361: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 368: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 36f: 90 nop + +00000370 : + +int stat(const char *n, struct stat *st) { + 370: 55 push %ebp + 371: 89 e5 mov %esp,%ebp + 373: 56 push %esi + 374: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 375: 83 ec 08 sub $0x8,%esp + 378: 6a 00 push $0x0 + 37a: ff 75 08 push 0x8(%ebp) + 37d: e8 19 01 00 00 call 49b + if (fd < 0) { + 382: 83 c4 10 add $0x10,%esp + 385: 85 c0 test %eax,%eax + 387: 78 27 js 3b0 + return -1; + } + r = fstat(fd, st); + 389: 83 ec 08 sub $0x8,%esp + 38c: ff 75 0c push 0xc(%ebp) + 38f: 89 c3 mov %eax,%ebx + 391: 50 push %eax + 392: e8 cc 00 00 00 call 463 + close(fd); + 397: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 39a: 89 c6 mov %eax,%esi + close(fd); + 39c: e8 2a 01 00 00 call 4cb + return r; + 3a1: 83 c4 10 add $0x10,%esp +} + 3a4: 8d 65 f8 lea -0x8(%ebp),%esp + 3a7: 89 f0 mov %esi,%eax + 3a9: 5b pop %ebx + 3aa: 5e pop %esi + 3ab: 5d pop %ebp + 3ac: c3 ret + 3ad: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 3b0: be ff ff ff ff mov $0xffffffff,%esi + 3b5: eb ed jmp 3a4 + 3b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3be: 66 90 xchg %ax,%ax + +000003c0 : + +int atoi(const char *s) { + 3c0: 55 push %ebp + 3c1: 89 e5 mov %esp,%ebp + 3c3: 53 push %ebx + 3c4: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 3c7: 0f be 02 movsbl (%edx),%eax + 3ca: 8d 48 d0 lea -0x30(%eax),%ecx + 3cd: 80 f9 09 cmp $0x9,%cl + n = 0; + 3d0: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 3d5: 77 1e ja 3f5 + 3d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3de: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 3e0: 83 c2 01 add $0x1,%edx + 3e3: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 3e6: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 3ea: 0f be 02 movsbl (%edx),%eax + 3ed: 8d 58 d0 lea -0x30(%eax),%ebx + 3f0: 80 fb 09 cmp $0x9,%bl + 3f3: 76 eb jbe 3e0 + } + return n; +} + 3f5: 8b 5d fc mov -0x4(%ebp),%ebx + 3f8: 89 c8 mov %ecx,%eax + 3fa: c9 leave + 3fb: c3 ret + 3fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000400 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 400: 55 push %ebp + 401: 89 e5 mov %esp,%ebp + 403: 57 push %edi + 404: 8b 45 10 mov 0x10(%ebp),%eax + 407: 8b 55 08 mov 0x8(%ebp),%edx + 40a: 56 push %esi + 40b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 40e: 85 c0 test %eax,%eax + 410: 7e 13 jle 425 + 412: 01 d0 add %edx,%eax + dst = vdst; + 414: 89 d7 mov %edx,%edi + 416: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 41d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 420: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 421: 39 f8 cmp %edi,%eax + 423: 75 fb jne 420 + } + return vdst; +} + 425: 5e pop %esi + 426: 89 d0 mov %edx,%eax + 428: 5f pop %edi + 429: 5d pop %ebp + 42a: c3 ret + +0000042b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 42b: b8 01 00 00 00 mov $0x1,%eax + 430: cd 40 int $0x40 + 432: c3 ret + +00000433 : +SYSCALL(exit) + 433: b8 02 00 00 00 mov $0x2,%eax + 438: cd 40 int $0x40 + 43a: c3 ret + +0000043b : +SYSCALL(wait) + 43b: b8 03 00 00 00 mov $0x3,%eax + 440: cd 40 int $0x40 + 442: c3 ret + +00000443 : +SYSCALL(pipe) + 443: b8 04 00 00 00 mov $0x4,%eax + 448: cd 40 int $0x40 + 44a: c3 ret + +0000044b : +SYSCALL(read) + 44b: b8 05 00 00 00 mov $0x5,%eax + 450: cd 40 int $0x40 + 452: c3 ret + +00000453 : +SYSCALL(kill) + 453: b8 06 00 00 00 mov $0x6,%eax + 458: cd 40 int $0x40 + 45a: c3 ret + +0000045b : +SYSCALL(exec) + 45b: b8 07 00 00 00 mov $0x7,%eax + 460: cd 40 int $0x40 + 462: c3 ret + +00000463 : +SYSCALL(fstat) + 463: b8 08 00 00 00 mov $0x8,%eax + 468: cd 40 int $0x40 + 46a: c3 ret + +0000046b : +SYSCALL(chdir) + 46b: b8 09 00 00 00 mov $0x9,%eax + 470: cd 40 int $0x40 + 472: c3 ret + +00000473 : +SYSCALL(dup) + 473: b8 0a 00 00 00 mov $0xa,%eax + 478: cd 40 int $0x40 + 47a: c3 ret + +0000047b : +SYSCALL(getpid) + 47b: b8 0b 00 00 00 mov $0xb,%eax + 480: cd 40 int $0x40 + 482: c3 ret + +00000483 : +SYSCALL(sbrk) + 483: b8 0c 00 00 00 mov $0xc,%eax + 488: cd 40 int $0x40 + 48a: c3 ret + +0000048b : +SYSCALL(sleep) + 48b: b8 0d 00 00 00 mov $0xd,%eax + 490: cd 40 int $0x40 + 492: c3 ret + +00000493 : +SYSCALL(uptime) + 493: b8 0e 00 00 00 mov $0xe,%eax + 498: cd 40 int $0x40 + 49a: c3 ret + +0000049b : +SYSCALL(open) + 49b: b8 0f 00 00 00 mov $0xf,%eax + 4a0: cd 40 int $0x40 + 4a2: c3 ret + +000004a3 : +SYSCALL(write) + 4a3: b8 10 00 00 00 mov $0x10,%eax + 4a8: cd 40 int $0x40 + 4aa: c3 ret + +000004ab : +SYSCALL(mknod) + 4ab: b8 11 00 00 00 mov $0x11,%eax + 4b0: cd 40 int $0x40 + 4b2: c3 ret + +000004b3 : +SYSCALL(unlink) + 4b3: b8 12 00 00 00 mov $0x12,%eax + 4b8: cd 40 int $0x40 + 4ba: c3 ret + +000004bb : +SYSCALL(link) + 4bb: b8 13 00 00 00 mov $0x13,%eax + 4c0: cd 40 int $0x40 + 4c2: c3 ret + +000004c3 : +SYSCALL(mkdir) + 4c3: b8 14 00 00 00 mov $0x14,%eax + 4c8: cd 40 int $0x40 + 4ca: c3 ret + +000004cb : +SYSCALL(close) + 4cb: b8 15 00 00 00 mov $0x15,%eax + 4d0: cd 40 int $0x40 + 4d2: c3 ret + +000004d3 : +SYSCALL(getch) + 4d3: b8 16 00 00 00 mov $0x16,%eax + 4d8: cd 40 int $0x40 + 4da: c3 ret + +000004db : +SYSCALL(greeting) + 4db: b8 17 00 00 00 mov $0x17,%eax + 4e0: cd 40 int $0x40 + 4e2: c3 ret + +000004e3 : +SYSCALL(shutdown) + 4e3: b8 18 00 00 00 mov $0x18,%eax + 4e8: cd 40 int $0x40 + 4ea: c3 ret + +000004eb : +SYSCALL(screen) + 4eb: b8 19 00 00 00 mov $0x19,%eax + 4f0: cd 40 int $0x40 + 4f2: c3 ret + +000004f3 : +SYSCALL(cls) + 4f3: b8 1a 00 00 00 mov $0x1a,%eax + 4f8: cd 40 int $0x40 + 4fa: c3 ret + 4fb: 66 90 xchg %ax,%ax + 4fd: 66 90 xchg %ax,%ax + 4ff: 90 nop + +00000500 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 500: 55 push %ebp + 501: 89 e5 mov %esp,%ebp + 503: 57 push %edi + 504: 56 push %esi + 505: 53 push %ebx + 506: 83 ec 3c sub $0x3c,%esp + 509: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 50c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 50e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 511: 85 d2 test %edx,%edx + 513: 0f 89 7f 00 00 00 jns 598 + 519: f6 45 08 01 testb $0x1,0x8(%ebp) + 51d: 74 79 je 598 + neg = 1; + 51f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 526: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 528: 31 db xor %ebx,%ebx + 52a: 8d 75 d7 lea -0x29(%ebp),%esi + 52d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 530: 89 c8 mov %ecx,%eax + 532: 31 d2 xor %edx,%edx + 534: 89 cf mov %ecx,%edi + 536: f7 75 c4 divl -0x3c(%ebp) + 539: 0f b6 92 08 0b 00 00 movzbl 0xb08(%edx),%edx + 540: 89 45 c0 mov %eax,-0x40(%ebp) + 543: 89 d8 mov %ebx,%eax + 545: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 548: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 54b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 54e: 39 7d c4 cmp %edi,-0x3c(%ebp) + 551: 76 dd jbe 530 + if (neg) { + 553: 8b 4d bc mov -0x44(%ebp),%ecx + 556: 85 c9 test %ecx,%ecx + 558: 74 0c je 566 + buf[i++] = '-'; + 55a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 55f: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 561: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 566: 8b 7d b8 mov -0x48(%ebp),%edi + 569: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 56d: eb 07 jmp 576 + 56f: 90 nop + putc(fd, buf[i]); + 570: 0f b6 13 movzbl (%ebx),%edx + 573: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 576: 83 ec 04 sub $0x4,%esp + 579: 88 55 d7 mov %dl,-0x29(%ebp) + 57c: 6a 01 push $0x1 + 57e: 56 push %esi + 57f: 57 push %edi + 580: e8 1e ff ff ff call 4a3 + while (--i >= 0) { + 585: 83 c4 10 add $0x10,%esp + 588: 39 de cmp %ebx,%esi + 58a: 75 e4 jne 570 + } +} + 58c: 8d 65 f4 lea -0xc(%ebp),%esp + 58f: 5b pop %ebx + 590: 5e pop %esi + 591: 5f pop %edi + 592: 5d pop %ebp + 593: c3 ret + 594: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 598: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 59f: eb 87 jmp 528 + 5a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5af: 90 nop + +000005b0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 5b0: 55 push %ebp + 5b1: 89 e5 mov %esp,%ebp + 5b3: 57 push %edi + 5b4: 56 push %esi + 5b5: 53 push %ebx + 5b6: 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++) { + 5b9: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 5bc: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 5bf: 0f b6 13 movzbl (%ebx),%edx + 5c2: 84 d2 test %dl,%dl + 5c4: 74 6a je 630 + ap = (uint*)(void*)&fmt + 1; + 5c6: 8d 45 10 lea 0x10(%ebp),%eax + 5c9: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 5cc: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 5cf: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 5d1: 89 45 d0 mov %eax,-0x30(%ebp) + 5d4: eb 36 jmp 60c + 5d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5dd: 8d 76 00 lea 0x0(%esi),%esi + 5e0: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 5e3: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 5e8: 83 f8 25 cmp $0x25,%eax + 5eb: 74 15 je 602 + write(fd, &c, 1); + 5ed: 83 ec 04 sub $0x4,%esp + 5f0: 88 55 e7 mov %dl,-0x19(%ebp) + 5f3: 6a 01 push $0x1 + 5f5: 57 push %edi + 5f6: 56 push %esi + 5f7: e8 a7 fe ff ff call 4a3 + 5fc: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 5ff: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 602: 0f b6 13 movzbl (%ebx),%edx + 605: 83 c3 01 add $0x1,%ebx + 608: 84 d2 test %dl,%dl + 60a: 74 24 je 630 + c = fmt[i] & 0xff; + 60c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 60f: 85 c9 test %ecx,%ecx + 611: 74 cd je 5e0 + } + } + else if (state == '%') { + 613: 83 f9 25 cmp $0x25,%ecx + 616: 75 ea jne 602 + if (c == 'd') { + 618: 83 f8 25 cmp $0x25,%eax + 61b: 0f 84 07 01 00 00 je 728 + 621: 83 e8 63 sub $0x63,%eax + 624: 83 f8 15 cmp $0x15,%eax + 627: 77 17 ja 640 + 629: ff 24 85 b0 0a 00 00 jmp *0xab0(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 630: 8d 65 f4 lea -0xc(%ebp),%esp + 633: 5b pop %ebx + 634: 5e pop %esi + 635: 5f pop %edi + 636: 5d pop %ebp + 637: c3 ret + 638: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 63f: 90 nop + write(fd, &c, 1); + 640: 83 ec 04 sub $0x4,%esp + 643: 88 55 d4 mov %dl,-0x2c(%ebp) + 646: 6a 01 push $0x1 + 648: 57 push %edi + 649: 56 push %esi + 64a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 64e: e8 50 fe ff ff call 4a3 + putc(fd, c); + 653: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 657: 83 c4 0c add $0xc,%esp + 65a: 88 55 e7 mov %dl,-0x19(%ebp) + 65d: 6a 01 push $0x1 + 65f: 57 push %edi + 660: 56 push %esi + 661: e8 3d fe ff ff call 4a3 + putc(fd, c); + 666: 83 c4 10 add $0x10,%esp + state = 0; + 669: 31 c9 xor %ecx,%ecx + 66b: eb 95 jmp 602 + 66d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 670: 83 ec 0c sub $0xc,%esp + 673: b9 10 00 00 00 mov $0x10,%ecx + 678: 6a 00 push $0x0 + 67a: 8b 45 d0 mov -0x30(%ebp),%eax + 67d: 8b 10 mov (%eax),%edx + 67f: 89 f0 mov %esi,%eax + 681: e8 7a fe ff ff call 500 + ap++; + 686: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 68a: 83 c4 10 add $0x10,%esp + state = 0; + 68d: 31 c9 xor %ecx,%ecx + 68f: e9 6e ff ff ff jmp 602 + 694: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 698: 8b 45 d0 mov -0x30(%ebp),%eax + 69b: 8b 10 mov (%eax),%edx + ap++; + 69d: 83 c0 04 add $0x4,%eax + 6a0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 6a3: 85 d2 test %edx,%edx + 6a5: 0f 84 8d 00 00 00 je 738 + while (*s != 0) { + 6ab: 0f b6 02 movzbl (%edx),%eax + state = 0; + 6ae: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 6b0: 84 c0 test %al,%al + 6b2: 0f 84 4a ff ff ff je 602 + 6b8: 89 5d d4 mov %ebx,-0x2c(%ebp) + 6bb: 89 d3 mov %edx,%ebx + 6bd: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 6c0: 83 ec 04 sub $0x4,%esp + s++; + 6c3: 83 c3 01 add $0x1,%ebx + 6c6: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 6c9: 6a 01 push $0x1 + 6cb: 57 push %edi + 6cc: 56 push %esi + 6cd: e8 d1 fd ff ff call 4a3 + while (*s != 0) { + 6d2: 0f b6 03 movzbl (%ebx),%eax + 6d5: 83 c4 10 add $0x10,%esp + 6d8: 84 c0 test %al,%al + 6da: 75 e4 jne 6c0 + state = 0; + 6dc: 8b 5d d4 mov -0x2c(%ebp),%ebx + 6df: 31 c9 xor %ecx,%ecx + 6e1: e9 1c ff ff ff jmp 602 + 6e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 6ed: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 6f0: 83 ec 0c sub $0xc,%esp + 6f3: b9 0a 00 00 00 mov $0xa,%ecx + 6f8: 6a 01 push $0x1 + 6fa: e9 7b ff ff ff jmp 67a + 6ff: 90 nop + putc(fd, *ap); + 700: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 703: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 706: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 708: 6a 01 push $0x1 + 70a: 57 push %edi + 70b: 56 push %esi + putc(fd, *ap); + 70c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 70f: e8 8f fd ff ff call 4a3 + ap++; + 714: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 718: 83 c4 10 add $0x10,%esp + state = 0; + 71b: 31 c9 xor %ecx,%ecx + 71d: e9 e0 fe ff ff jmp 602 + 722: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 728: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 72b: 83 ec 04 sub $0x4,%esp + 72e: e9 2a ff ff ff jmp 65d + 733: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 737: 90 nop + s = "(null)"; + 738: ba a8 0a 00 00 mov $0xaa8,%edx + while (*s != 0) { + 73d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 740: b8 28 00 00 00 mov $0x28,%eax + 745: 89 d3 mov %edx,%ebx + 747: e9 74 ff ff ff jmp 6c0 + 74c: 66 90 xchg %ax,%ax + 74e: 66 90 xchg %ax,%ax + +00000750 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 750: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 751: a1 20 0e 00 00 mov 0xe20,%eax +void free(void *ap) { + 756: 89 e5 mov %esp,%ebp + 758: 57 push %edi + 759: 56 push %esi + 75a: 53 push %ebx + 75b: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 75e: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 761: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 768: 89 c2 mov %eax,%edx + 76a: 8b 00 mov (%eax),%eax + 76c: 39 ca cmp %ecx,%edx + 76e: 73 30 jae 7a0 + 770: 39 c1 cmp %eax,%ecx + 772: 72 04 jb 778 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 774: 39 c2 cmp %eax,%edx + 776: 72 f0 jb 768 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 778: 8b 73 fc mov -0x4(%ebx),%esi + 77b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 77e: 39 f8 cmp %edi,%eax + 780: 74 30 je 7b2 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 782: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 785: 8b 42 04 mov 0x4(%edx),%eax + 788: 8d 34 c2 lea (%edx,%eax,8),%esi + 78b: 39 f1 cmp %esi,%ecx + 78d: 74 3a je 7c9 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 78f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 791: 5b pop %ebx + freep = p; + 792: 89 15 20 0e 00 00 mov %edx,0xe20 +} + 798: 5e pop %esi + 799: 5f pop %edi + 79a: 5d pop %ebp + 79b: c3 ret + 79c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 7a0: 39 c2 cmp %eax,%edx + 7a2: 72 c4 jb 768 + 7a4: 39 c1 cmp %eax,%ecx + 7a6: 73 c0 jae 768 + if (bp + bp->s.size == p->s.ptr) { + 7a8: 8b 73 fc mov -0x4(%ebx),%esi + 7ab: 8d 3c f1 lea (%ecx,%esi,8),%edi + 7ae: 39 f8 cmp %edi,%eax + 7b0: 75 d0 jne 782 + bp->s.size += p->s.ptr->s.size; + 7b2: 03 70 04 add 0x4(%eax),%esi + 7b5: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 7b8: 8b 02 mov (%edx),%eax + 7ba: 8b 00 mov (%eax),%eax + 7bc: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 7bf: 8b 42 04 mov 0x4(%edx),%eax + 7c2: 8d 34 c2 lea (%edx,%eax,8),%esi + 7c5: 39 f1 cmp %esi,%ecx + 7c7: 75 c6 jne 78f + p->s.size += bp->s.size; + 7c9: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 7cc: 89 15 20 0e 00 00 mov %edx,0xe20 + p->s.size += bp->s.size; + 7d2: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 7d5: 8b 4b f8 mov -0x8(%ebx),%ecx + 7d8: 89 0a mov %ecx,(%edx) +} + 7da: 5b pop %ebx + 7db: 5e pop %esi + 7dc: 5f pop %edi + 7dd: 5d pop %ebp + 7de: c3 ret + 7df: 90 nop + +000007e0 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 7e0: 55 push %ebp + 7e1: 89 e5 mov %esp,%ebp + 7e3: 57 push %edi + 7e4: 56 push %esi + 7e5: 53 push %ebx + 7e6: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 7e9: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 7ec: 8b 3d 20 0e 00 00 mov 0xe20,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 7f2: 8d 70 07 lea 0x7(%eax),%esi + 7f5: c1 ee 03 shr $0x3,%esi + 7f8: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 7fb: 85 ff test %edi,%edi + 7fd: 0f 84 9d 00 00 00 je 8a0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 803: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 805: 8b 4a 04 mov 0x4(%edx),%ecx + 808: 39 f1 cmp %esi,%ecx + 80a: 73 6a jae 876 + 80c: bb 00 10 00 00 mov $0x1000,%ebx + 811: 39 de cmp %ebx,%esi + 813: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 816: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 81d: 89 45 e4 mov %eax,-0x1c(%ebp) + 820: eb 17 jmp 839 + 822: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 828: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 82a: 8b 48 04 mov 0x4(%eax),%ecx + 82d: 39 f1 cmp %esi,%ecx + 82f: 73 4f jae 880 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 831: 8b 3d 20 0e 00 00 mov 0xe20,%edi + 837: 89 c2 mov %eax,%edx + 839: 39 d7 cmp %edx,%edi + 83b: 75 eb jne 828 + p = sbrk(nu * sizeof(Header)); + 83d: 83 ec 0c sub $0xc,%esp + 840: ff 75 e4 push -0x1c(%ebp) + 843: e8 3b fc ff ff call 483 + if (p == (char*)-1) { + 848: 83 c4 10 add $0x10,%esp + 84b: 83 f8 ff cmp $0xffffffff,%eax + 84e: 74 1c je 86c + hp->s.size = nu; + 850: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 853: 83 ec 0c sub $0xc,%esp + 856: 83 c0 08 add $0x8,%eax + 859: 50 push %eax + 85a: e8 f1 fe ff ff call 750 + return freep; + 85f: 8b 15 20 0e 00 00 mov 0xe20,%edx + if ((p = morecore(nunits)) == 0) { + 865: 83 c4 10 add $0x10,%esp + 868: 85 d2 test %edx,%edx + 86a: 75 bc jne 828 + return 0; + } + } + } +} + 86c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 86f: 31 c0 xor %eax,%eax +} + 871: 5b pop %ebx + 872: 5e pop %esi + 873: 5f pop %edi + 874: 5d pop %ebp + 875: c3 ret + if (p->s.size >= nunits) { + 876: 89 d0 mov %edx,%eax + 878: 89 fa mov %edi,%edx + 87a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 880: 39 ce cmp %ecx,%esi + 882: 74 4c je 8d0 + p->s.size -= nunits; + 884: 29 f1 sub %esi,%ecx + 886: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 889: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 88c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 88f: 89 15 20 0e 00 00 mov %edx,0xe20 +} + 895: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 898: 83 c0 08 add $0x8,%eax +} + 89b: 5b pop %ebx + 89c: 5e pop %esi + 89d: 5f pop %edi + 89e: 5d pop %ebp + 89f: c3 ret + base.s.ptr = freep = prevp = &base; + 8a0: c7 05 20 0e 00 00 24 movl $0xe24,0xe20 + 8a7: 0e 00 00 + base.s.size = 0; + 8aa: bf 24 0e 00 00 mov $0xe24,%edi + base.s.ptr = freep = prevp = &base; + 8af: c7 05 24 0e 00 00 24 movl $0xe24,0xe24 + 8b6: 0e 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 8b9: 89 fa mov %edi,%edx + base.s.size = 0; + 8bb: c7 05 28 0e 00 00 00 movl $0x0,0xe28 + 8c2: 00 00 00 + if (p->s.size >= nunits) { + 8c5: e9 42 ff ff ff jmp 80c + 8ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 8d0: 8b 08 mov (%eax),%ecx + 8d2: 89 0a mov %ecx,(%edx) + 8d4: eb b9 jmp 88f diff --git a/maze.d b/maze.d new file mode 100644 index 0000000..92a9724 --- /dev/null +++ b/maze.d @@ -0,0 +1 @@ +maze.o: maze.c /usr/include/stdc-predef.h types.h user.h diff --git a/maze.o b/maze.o new file mode 100644 index 0000000..dd07b2c Binary files /dev/null and b/maze.o differ diff --git a/maze.sym b/maze.sym new file mode 100644 index 0000000..30105d2 --- /dev/null +++ b/maze.sym @@ -0,0 +1,56 @@ +00000000 maze.c +00000e1c z1.3 +00000e18 z2.2 +00000e10 z4.0 +00000e14 z3.1 +00000000 ulib.c +00000000 printf.c +00000500 printint +00000b08 digits.0 +00000000 umalloc.c +00000e20 freep +00000e24 base +000001e0 strcpy +000005b0 printf +000004db greeting +00000400 memmove +000004ab mknod +00000300 gets +0000047b getpid +000004eb screen +000007e0 malloc +0000048b sleep +00000110 rngnumber +00000443 pipe +000004d3 getch +000004a3 write +00000463 fstat +00000453 kill +0000046b chdir +000001b0 rngrange +0000045b exec +0000043b wait +0000044b read +000004b3 unlink +0000042b fork +00000483 sbrk +00000493 uptime +00000e20 __bss_start +000002a0 memset +00000000 main +00000210 strcmp +000004e3 shutdown +00000473 dup +00000370 stat +00000e20 _edata +00000e2c _end +000004bb link +00000433 exit +000003c0 atoi +000004f3 cls +00000270 strlen +0000049b open +000002c0 strchr +000004c3 mkdir +000004cb close +00000750 free diff --git a/mkdir.asm b/mkdir.asm new file mode 100644 index 0000000..22ea349 --- /dev/null +++ b/mkdir.asm @@ -0,0 +1,1202 @@ + +_mkdir: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "stat.h" +#include "user.h" + +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: bf 01 00 00 00 mov $0x1,%edi + 13: 56 push %esi + 14: 53 push %ebx + 15: 51 push %ecx + 16: 83 ec 08 sub $0x8,%esp + 19: 8b 59 04 mov 0x4(%ecx),%ebx + 1c: 8b 31 mov (%ecx),%esi + 1e: 83 c3 04 add $0x4,%ebx + int i; + + if (argc < 2) { + 21: 83 fe 01 cmp $0x1,%esi + 24: 7e 3e jle 64 + 26: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2d: 8d 76 00 lea 0x0(%esi),%esi + printf(2, "Usage: mkdir files...\n"); + exit(); + } + + for (i = 1; i < argc; i++) { + if (mkdir(argv[i]) < 0) { + 30: 83 ec 0c sub $0xc,%esp + 33: ff 33 push (%ebx) + 35: e8 29 03 00 00 call 363 + 3a: 83 c4 10 add $0x10,%esp + 3d: 85 c0 test %eax,%eax + 3f: 78 0f js 50 + for (i = 1; i < argc; i++) { + 41: 83 c7 01 add $0x1,%edi + 44: 83 c3 04 add $0x4,%ebx + 47: 39 fe cmp %edi,%esi + 49: 75 e5 jne 30 + printf(2, "mkdir: %s failed to create\n", argv[i]); + break; + } + } + + exit(); + 4b: e8 83 02 00 00 call 2d3 + printf(2, "mkdir: %s failed to create\n", argv[i]); + 50: 50 push %eax + 51: ff 33 push (%ebx) + 53: 68 8f 07 00 00 push $0x78f + 58: 6a 02 push $0x2 + 5a: e8 f1 03 00 00 call 450 + break; + 5f: 83 c4 10 add $0x10,%esp + 62: eb e7 jmp 4b + printf(2, "Usage: mkdir files...\n"); + 64: 52 push %edx + 65: 52 push %edx + 66: 68 78 07 00 00 push $0x778 + 6b: 6a 02 push $0x2 + 6d: e8 de 03 00 00 call 450 + exit(); + 72: e8 5c 02 00 00 call 2d3 + 77: 66 90 xchg %ax,%ax + 79: 66 90 xchg %ax,%ax + 7b: 66 90 xchg %ax,%ax + 7d: 66 90 xchg %ax,%ax + 7f: 90 nop + +00000080 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 80: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 81: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 83: 89 e5 mov %esp,%ebp + 85: 53 push %ebx + 86: 8b 4d 08 mov 0x8(%ebp),%ecx + 89: 8b 5d 0c mov 0xc(%ebp),%ebx + 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 90: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 94: 88 14 01 mov %dl,(%ecx,%eax,1) + 97: 83 c0 01 add $0x1,%eax + 9a: 84 d2 test %dl,%dl + 9c: 75 f2 jne 90 + ; + } + return os; +} + 9e: 8b 5d fc mov -0x4(%ebp),%ebx + a1: 89 c8 mov %ecx,%eax + a3: c9 leave + a4: c3 ret + a5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000000b0 : + +int strcmp(const char *p, const char *q) { + b0: 55 push %ebp + b1: 89 e5 mov %esp,%ebp + b3: 53 push %ebx + b4: 8b 55 08 mov 0x8(%ebp),%edx + b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + ba: 0f b6 02 movzbl (%edx),%eax + bd: 84 c0 test %al,%al + bf: 75 17 jne d8 + c1: eb 3a jmp fd + c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c7: 90 nop + c8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + cc: 83 c2 01 add $0x1,%edx + cf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + d2: 84 c0 test %al,%al + d4: 74 1a je f0 + p++, q++; + d6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + d8: 0f b6 19 movzbl (%ecx),%ebx + db: 38 c3 cmp %al,%bl + dd: 74 e9 je c8 + } + return (uchar) * p - (uchar) * q; + df: 29 d8 sub %ebx,%eax +} + e1: 8b 5d fc mov -0x4(%ebp),%ebx + e4: c9 leave + e5: c3 ret + e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ed: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + f0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + f4: 31 c0 xor %eax,%eax + f6: 29 d8 sub %ebx,%eax +} + f8: 8b 5d fc mov -0x4(%ebp),%ebx + fb: c9 leave + fc: c3 ret + return (uchar) * p - (uchar) * q; + fd: 0f b6 19 movzbl (%ecx),%ebx + 100: 31 c0 xor %eax,%eax + 102: eb db jmp df + 104: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 10b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 10f: 90 nop + +00000110 : + +uint strlen(const char *s) { + 110: 55 push %ebp + 111: 89 e5 mov %esp,%ebp + 113: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 116: 80 3a 00 cmpb $0x0,(%edx) + 119: 74 15 je 130 + 11b: 31 c0 xor %eax,%eax + 11d: 8d 76 00 lea 0x0(%esi),%esi + 120: 83 c0 01 add $0x1,%eax + 123: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 127: 89 c1 mov %eax,%ecx + 129: 75 f5 jne 120 + ; + } + return n; +} + 12b: 89 c8 mov %ecx,%eax + 12d: 5d pop %ebp + 12e: c3 ret + 12f: 90 nop + for (n = 0; s[n]; n++) { + 130: 31 c9 xor %ecx,%ecx +} + 132: 5d pop %ebp + 133: 89 c8 mov %ecx,%eax + 135: c3 ret + 136: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 13d: 8d 76 00 lea 0x0(%esi),%esi + +00000140 : + +void* memset(void *dst, int c, uint n) { + 140: 55 push %ebp + 141: 89 e5 mov %esp,%ebp + 143: 57 push %edi + 144: 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" : + 147: 8b 4d 10 mov 0x10(%ebp),%ecx + 14a: 8b 45 0c mov 0xc(%ebp),%eax + 14d: 89 d7 mov %edx,%edi + 14f: fc cld + 150: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 152: 8b 7d fc mov -0x4(%ebp),%edi + 155: 89 d0 mov %edx,%eax + 157: c9 leave + 158: c3 ret + 159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000160 : + +char* strchr(const char *s, char c) { + 160: 55 push %ebp + 161: 89 e5 mov %esp,%ebp + 163: 8b 45 08 mov 0x8(%ebp),%eax + 166: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 16a: 0f b6 10 movzbl (%eax),%edx + 16d: 84 d2 test %dl,%dl + 16f: 75 12 jne 183 + 171: eb 1d jmp 190 + 173: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 177: 90 nop + 178: 0f b6 50 01 movzbl 0x1(%eax),%edx + 17c: 83 c0 01 add $0x1,%eax + 17f: 84 d2 test %dl,%dl + 181: 74 0d je 190 + if (*s == c) { + 183: 38 d1 cmp %dl,%cl + 185: 75 f1 jne 178 + return (char*)s; + } + } + return 0; +} + 187: 5d pop %ebp + 188: c3 ret + 189: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 190: 31 c0 xor %eax,%eax +} + 192: 5d pop %ebp + 193: c3 ret + 194: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 19b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 19f: 90 nop + +000001a0 : + +char* gets(char *buf, int max) { + 1a0: 55 push %ebp + 1a1: 89 e5 mov %esp,%ebp + 1a3: 57 push %edi + 1a4: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 1a5: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 1a8: 53 push %ebx + for (i = 0; i + 1 < max;) { + 1a9: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 1ab: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 1ae: eb 27 jmp 1d7 + cc = read(0, &c, 1); + 1b0: 83 ec 04 sub $0x4,%esp + 1b3: 6a 01 push $0x1 + 1b5: 57 push %edi + 1b6: 6a 00 push $0x0 + 1b8: e8 2e 01 00 00 call 2eb + if (cc < 1) { + 1bd: 83 c4 10 add $0x10,%esp + 1c0: 85 c0 test %eax,%eax + 1c2: 7e 1d jle 1e1 + break; + } + buf[i++] = c; + 1c4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1c8: 8b 55 08 mov 0x8(%ebp),%edx + 1cb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1cf: 3c 0a cmp $0xa,%al + 1d1: 74 1d je 1f0 + 1d3: 3c 0d cmp $0xd,%al + 1d5: 74 19 je 1f0 + for (i = 0; i + 1 < max;) { + 1d7: 89 de mov %ebx,%esi + 1d9: 83 c3 01 add $0x1,%ebx + 1dc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1df: 7c cf jl 1b0 + break; + } + } + buf[i] = '\0'; + 1e1: 8b 45 08 mov 0x8(%ebp),%eax + 1e4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1e8: 8d 65 f4 lea -0xc(%ebp),%esp + 1eb: 5b pop %ebx + 1ec: 5e pop %esi + 1ed: 5f pop %edi + 1ee: 5d pop %ebp + 1ef: c3 ret + buf[i] = '\0'; + 1f0: 8b 45 08 mov 0x8(%ebp),%eax + 1f3: 89 de mov %ebx,%esi + 1f5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1f9: 8d 65 f4 lea -0xc(%ebp),%esp + 1fc: 5b pop %ebx + 1fd: 5e pop %esi + 1fe: 5f pop %edi + 1ff: 5d pop %ebp + 200: c3 ret + 201: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 208: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 20f: 90 nop + +00000210 : + +int stat(const char *n, struct stat *st) { + 210: 55 push %ebp + 211: 89 e5 mov %esp,%ebp + 213: 56 push %esi + 214: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 215: 83 ec 08 sub $0x8,%esp + 218: 6a 00 push $0x0 + 21a: ff 75 08 push 0x8(%ebp) + 21d: e8 19 01 00 00 call 33b + if (fd < 0) { + 222: 83 c4 10 add $0x10,%esp + 225: 85 c0 test %eax,%eax + 227: 78 27 js 250 + return -1; + } + r = fstat(fd, st); + 229: 83 ec 08 sub $0x8,%esp + 22c: ff 75 0c push 0xc(%ebp) + 22f: 89 c3 mov %eax,%ebx + 231: 50 push %eax + 232: e8 cc 00 00 00 call 303 + close(fd); + 237: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 23a: 89 c6 mov %eax,%esi + close(fd); + 23c: e8 2a 01 00 00 call 36b + return r; + 241: 83 c4 10 add $0x10,%esp +} + 244: 8d 65 f8 lea -0x8(%ebp),%esp + 247: 89 f0 mov %esi,%eax + 249: 5b pop %ebx + 24a: 5e pop %esi + 24b: 5d pop %ebp + 24c: c3 ret + 24d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 250: be ff ff ff ff mov $0xffffffff,%esi + 255: eb ed jmp 244 + 257: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25e: 66 90 xchg %ax,%ax + +00000260 : + +int atoi(const char *s) { + 260: 55 push %ebp + 261: 89 e5 mov %esp,%ebp + 263: 53 push %ebx + 264: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 267: 0f be 02 movsbl (%edx),%eax + 26a: 8d 48 d0 lea -0x30(%eax),%ecx + 26d: 80 f9 09 cmp $0x9,%cl + n = 0; + 270: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 275: 77 1e ja 295 + 277: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 27e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 280: 83 c2 01 add $0x1,%edx + 283: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 286: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 28a: 0f be 02 movsbl (%edx),%eax + 28d: 8d 58 d0 lea -0x30(%eax),%ebx + 290: 80 fb 09 cmp $0x9,%bl + 293: 76 eb jbe 280 + } + return n; +} + 295: 8b 5d fc mov -0x4(%ebp),%ebx + 298: 89 c8 mov %ecx,%eax + 29a: c9 leave + 29b: c3 ret + 29c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000002a0 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 2a0: 55 push %ebp + 2a1: 89 e5 mov %esp,%ebp + 2a3: 57 push %edi + 2a4: 8b 45 10 mov 0x10(%ebp),%eax + 2a7: 8b 55 08 mov 0x8(%ebp),%edx + 2aa: 56 push %esi + 2ab: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 2ae: 85 c0 test %eax,%eax + 2b0: 7e 13 jle 2c5 + 2b2: 01 d0 add %edx,%eax + dst = vdst; + 2b4: 89 d7 mov %edx,%edi + 2b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2bd: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2c0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2c1: 39 f8 cmp %edi,%eax + 2c3: 75 fb jne 2c0 + } + return vdst; +} + 2c5: 5e pop %esi + 2c6: 89 d0 mov %edx,%eax + 2c8: 5f pop %edi + 2c9: 5d pop %ebp + 2ca: c3 ret + +000002cb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2cb: b8 01 00 00 00 mov $0x1,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(exit) + 2d3: b8 02 00 00 00 mov $0x2,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(wait) + 2db: b8 03 00 00 00 mov $0x3,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(pipe) + 2e3: b8 04 00 00 00 mov $0x4,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(read) + 2eb: b8 05 00 00 00 mov $0x5,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(kill) + 2f3: b8 06 00 00 00 mov $0x6,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(exec) + 2fb: b8 07 00 00 00 mov $0x7,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(fstat) + 303: b8 08 00 00 00 mov $0x8,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(chdir) + 30b: b8 09 00 00 00 mov $0x9,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(dup) + 313: b8 0a 00 00 00 mov $0xa,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(getpid) + 31b: b8 0b 00 00 00 mov $0xb,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(sbrk) + 323: b8 0c 00 00 00 mov $0xc,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(sleep) + 32b: b8 0d 00 00 00 mov $0xd,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(uptime) + 333: b8 0e 00 00 00 mov $0xe,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(open) + 33b: b8 0f 00 00 00 mov $0xf,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(write) + 343: b8 10 00 00 00 mov $0x10,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(mknod) + 34b: b8 11 00 00 00 mov $0x11,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(unlink) + 353: b8 12 00 00 00 mov $0x12,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(link) + 35b: b8 13 00 00 00 mov $0x13,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(mkdir) + 363: b8 14 00 00 00 mov $0x14,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(close) + 36b: b8 15 00 00 00 mov $0x15,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(getch) + 373: b8 16 00 00 00 mov $0x16,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(greeting) + 37b: b8 17 00 00 00 mov $0x17,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(shutdown) + 383: b8 18 00 00 00 mov $0x18,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + +0000038b : +SYSCALL(screen) + 38b: b8 19 00 00 00 mov $0x19,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(cls) + 393: b8 1a 00 00 00 mov $0x1a,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + 39b: 66 90 xchg %ax,%ax + 39d: 66 90 xchg %ax,%ax + 39f: 90 nop + +000003a0 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 3a0: 55 push %ebp + 3a1: 89 e5 mov %esp,%ebp + 3a3: 57 push %edi + 3a4: 56 push %esi + 3a5: 53 push %ebx + 3a6: 83 ec 3c sub $0x3c,%esp + 3a9: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 3ac: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 3ae: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 3b1: 85 d2 test %edx,%edx + 3b3: 0f 89 7f 00 00 00 jns 438 + 3b9: f6 45 08 01 testb $0x1,0x8(%ebp) + 3bd: 74 79 je 438 + neg = 1; + 3bf: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3c6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3c8: 31 db xor %ebx,%ebx + 3ca: 8d 75 d7 lea -0x29(%ebp),%esi + 3cd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3d0: 89 c8 mov %ecx,%eax + 3d2: 31 d2 xor %edx,%edx + 3d4: 89 cf mov %ecx,%edi + 3d6: f7 75 c4 divl -0x3c(%ebp) + 3d9: 0f b6 92 0c 08 00 00 movzbl 0x80c(%edx),%edx + 3e0: 89 45 c0 mov %eax,-0x40(%ebp) + 3e3: 89 d8 mov %ebx,%eax + 3e5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3e8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3eb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3ee: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3f1: 76 dd jbe 3d0 + if (neg) { + 3f3: 8b 4d bc mov -0x44(%ebp),%ecx + 3f6: 85 c9 test %ecx,%ecx + 3f8: 74 0c je 406 + buf[i++] = '-'; + 3fa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3ff: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 401: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 406: 8b 7d b8 mov -0x48(%ebp),%edi + 409: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 40d: eb 07 jmp 416 + 40f: 90 nop + putc(fd, buf[i]); + 410: 0f b6 13 movzbl (%ebx),%edx + 413: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 416: 83 ec 04 sub $0x4,%esp + 419: 88 55 d7 mov %dl,-0x29(%ebp) + 41c: 6a 01 push $0x1 + 41e: 56 push %esi + 41f: 57 push %edi + 420: e8 1e ff ff ff call 343 + while (--i >= 0) { + 425: 83 c4 10 add $0x10,%esp + 428: 39 de cmp %ebx,%esi + 42a: 75 e4 jne 410 + } +} + 42c: 8d 65 f4 lea -0xc(%ebp),%esp + 42f: 5b pop %ebx + 430: 5e pop %esi + 431: 5f pop %edi + 432: 5d pop %ebp + 433: c3 ret + 434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 438: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 43f: eb 87 jmp 3c8 + 441: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 448: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 44f: 90 nop + +00000450 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 450: 55 push %ebp + 451: 89 e5 mov %esp,%ebp + 453: 57 push %edi + 454: 56 push %esi + 455: 53 push %ebx + 456: 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++) { + 459: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 45c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 45f: 0f b6 13 movzbl (%ebx),%edx + 462: 84 d2 test %dl,%dl + 464: 74 6a je 4d0 + ap = (uint*)(void*)&fmt + 1; + 466: 8d 45 10 lea 0x10(%ebp),%eax + 469: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 46c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 46f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 471: 89 45 d0 mov %eax,-0x30(%ebp) + 474: eb 36 jmp 4ac + 476: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 47d: 8d 76 00 lea 0x0(%esi),%esi + 480: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 483: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 488: 83 f8 25 cmp $0x25,%eax + 48b: 74 15 je 4a2 + write(fd, &c, 1); + 48d: 83 ec 04 sub $0x4,%esp + 490: 88 55 e7 mov %dl,-0x19(%ebp) + 493: 6a 01 push $0x1 + 495: 57 push %edi + 496: 56 push %esi + 497: e8 a7 fe ff ff call 343 + 49c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 49f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 4a2: 0f b6 13 movzbl (%ebx),%edx + 4a5: 83 c3 01 add $0x1,%ebx + 4a8: 84 d2 test %dl,%dl + 4aa: 74 24 je 4d0 + c = fmt[i] & 0xff; + 4ac: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 4af: 85 c9 test %ecx,%ecx + 4b1: 74 cd je 480 + } + } + else if (state == '%') { + 4b3: 83 f9 25 cmp $0x25,%ecx + 4b6: 75 ea jne 4a2 + if (c == 'd') { + 4b8: 83 f8 25 cmp $0x25,%eax + 4bb: 0f 84 07 01 00 00 je 5c8 + 4c1: 83 e8 63 sub $0x63,%eax + 4c4: 83 f8 15 cmp $0x15,%eax + 4c7: 77 17 ja 4e0 + 4c9: ff 24 85 b4 07 00 00 jmp *0x7b4(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4d0: 8d 65 f4 lea -0xc(%ebp),%esp + 4d3: 5b pop %ebx + 4d4: 5e pop %esi + 4d5: 5f pop %edi + 4d6: 5d pop %ebp + 4d7: c3 ret + 4d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4df: 90 nop + write(fd, &c, 1); + 4e0: 83 ec 04 sub $0x4,%esp + 4e3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4e6: 6a 01 push $0x1 + 4e8: 57 push %edi + 4e9: 56 push %esi + 4ea: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4ee: e8 50 fe ff ff call 343 + putc(fd, c); + 4f3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4f7: 83 c4 0c add $0xc,%esp + 4fa: 88 55 e7 mov %dl,-0x19(%ebp) + 4fd: 6a 01 push $0x1 + 4ff: 57 push %edi + 500: 56 push %esi + 501: e8 3d fe ff ff call 343 + putc(fd, c); + 506: 83 c4 10 add $0x10,%esp + state = 0; + 509: 31 c9 xor %ecx,%ecx + 50b: eb 95 jmp 4a2 + 50d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 510: 83 ec 0c sub $0xc,%esp + 513: b9 10 00 00 00 mov $0x10,%ecx + 518: 6a 00 push $0x0 + 51a: 8b 45 d0 mov -0x30(%ebp),%eax + 51d: 8b 10 mov (%eax),%edx + 51f: 89 f0 mov %esi,%eax + 521: e8 7a fe ff ff call 3a0 + ap++; + 526: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 52a: 83 c4 10 add $0x10,%esp + state = 0; + 52d: 31 c9 xor %ecx,%ecx + 52f: e9 6e ff ff ff jmp 4a2 + 534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 538: 8b 45 d0 mov -0x30(%ebp),%eax + 53b: 8b 10 mov (%eax),%edx + ap++; + 53d: 83 c0 04 add $0x4,%eax + 540: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 543: 85 d2 test %edx,%edx + 545: 0f 84 8d 00 00 00 je 5d8 + while (*s != 0) { + 54b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 54e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 550: 84 c0 test %al,%al + 552: 0f 84 4a ff ff ff je 4a2 + 558: 89 5d d4 mov %ebx,-0x2c(%ebp) + 55b: 89 d3 mov %edx,%ebx + 55d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 560: 83 ec 04 sub $0x4,%esp + s++; + 563: 83 c3 01 add $0x1,%ebx + 566: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 569: 6a 01 push $0x1 + 56b: 57 push %edi + 56c: 56 push %esi + 56d: e8 d1 fd ff ff call 343 + while (*s != 0) { + 572: 0f b6 03 movzbl (%ebx),%eax + 575: 83 c4 10 add $0x10,%esp + 578: 84 c0 test %al,%al + 57a: 75 e4 jne 560 + state = 0; + 57c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 57f: 31 c9 xor %ecx,%ecx + 581: e9 1c ff ff ff jmp 4a2 + 586: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 58d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 590: 83 ec 0c sub $0xc,%esp + 593: b9 0a 00 00 00 mov $0xa,%ecx + 598: 6a 01 push $0x1 + 59a: e9 7b ff ff ff jmp 51a + 59f: 90 nop + putc(fd, *ap); + 5a0: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 5a3: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 5a6: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 5a8: 6a 01 push $0x1 + 5aa: 57 push %edi + 5ab: 56 push %esi + putc(fd, *ap); + 5ac: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 5af: e8 8f fd ff ff call 343 + ap++; + 5b4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5b8: 83 c4 10 add $0x10,%esp + state = 0; + 5bb: 31 c9 xor %ecx,%ecx + 5bd: e9 e0 fe ff ff jmp 4a2 + 5c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5c8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5cb: 83 ec 04 sub $0x4,%esp + 5ce: e9 2a ff ff ff jmp 4fd + 5d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5d7: 90 nop + s = "(null)"; + 5d8: ba ab 07 00 00 mov $0x7ab,%edx + while (*s != 0) { + 5dd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5e0: b8 28 00 00 00 mov $0x28,%eax + 5e5: 89 d3 mov %edx,%ebx + 5e7: e9 74 ff ff ff jmp 560 + 5ec: 66 90 xchg %ax,%ax + 5ee: 66 90 xchg %ax,%ax + +000005f0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5f1: a1 c4 0a 00 00 mov 0xac4,%eax +void free(void *ap) { + 5f6: 89 e5 mov %esp,%ebp + 5f8: 57 push %edi + 5f9: 56 push %esi + 5fa: 53 push %ebx + 5fb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5fe: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 601: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 608: 89 c2 mov %eax,%edx + 60a: 8b 00 mov (%eax),%eax + 60c: 39 ca cmp %ecx,%edx + 60e: 73 30 jae 640 + 610: 39 c1 cmp %eax,%ecx + 612: 72 04 jb 618 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 614: 39 c2 cmp %eax,%edx + 616: 72 f0 jb 608 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 618: 8b 73 fc mov -0x4(%ebx),%esi + 61b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 61e: 39 f8 cmp %edi,%eax + 620: 74 30 je 652 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 622: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 625: 8b 42 04 mov 0x4(%edx),%eax + 628: 8d 34 c2 lea (%edx,%eax,8),%esi + 62b: 39 f1 cmp %esi,%ecx + 62d: 74 3a je 669 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 62f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 631: 5b pop %ebx + freep = p; + 632: 89 15 c4 0a 00 00 mov %edx,0xac4 +} + 638: 5e pop %esi + 639: 5f pop %edi + 63a: 5d pop %ebp + 63b: c3 ret + 63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 640: 39 c2 cmp %eax,%edx + 642: 72 c4 jb 608 + 644: 39 c1 cmp %eax,%ecx + 646: 73 c0 jae 608 + if (bp + bp->s.size == p->s.ptr) { + 648: 8b 73 fc mov -0x4(%ebx),%esi + 64b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 64e: 39 f8 cmp %edi,%eax + 650: 75 d0 jne 622 + bp->s.size += p->s.ptr->s.size; + 652: 03 70 04 add 0x4(%eax),%esi + 655: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 658: 8b 02 mov (%edx),%eax + 65a: 8b 00 mov (%eax),%eax + 65c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 65f: 8b 42 04 mov 0x4(%edx),%eax + 662: 8d 34 c2 lea (%edx,%eax,8),%esi + 665: 39 f1 cmp %esi,%ecx + 667: 75 c6 jne 62f + p->s.size += bp->s.size; + 669: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 66c: 89 15 c4 0a 00 00 mov %edx,0xac4 + p->s.size += bp->s.size; + 672: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 675: 8b 4b f8 mov -0x8(%ebx),%ecx + 678: 89 0a mov %ecx,(%edx) +} + 67a: 5b pop %ebx + 67b: 5e pop %esi + 67c: 5f pop %edi + 67d: 5d pop %ebp + 67e: c3 ret + 67f: 90 nop + +00000680 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 680: 55 push %ebp + 681: 89 e5 mov %esp,%ebp + 683: 57 push %edi + 684: 56 push %esi + 685: 53 push %ebx + 686: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 689: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 68c: 8b 3d c4 0a 00 00 mov 0xac4,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 692: 8d 70 07 lea 0x7(%eax),%esi + 695: c1 ee 03 shr $0x3,%esi + 698: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 69b: 85 ff test %edi,%edi + 69d: 0f 84 9d 00 00 00 je 740 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6a3: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 6a5: 8b 4a 04 mov 0x4(%edx),%ecx + 6a8: 39 f1 cmp %esi,%ecx + 6aa: 73 6a jae 716 + 6ac: bb 00 10 00 00 mov $0x1000,%ebx + 6b1: 39 de cmp %ebx,%esi + 6b3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 6b6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 6bd: 89 45 e4 mov %eax,-0x1c(%ebp) + 6c0: eb 17 jmp 6d9 + 6c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6c8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6ca: 8b 48 04 mov 0x4(%eax),%ecx + 6cd: 39 f1 cmp %esi,%ecx + 6cf: 73 4f jae 720 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6d1: 8b 3d c4 0a 00 00 mov 0xac4,%edi + 6d7: 89 c2 mov %eax,%edx + 6d9: 39 d7 cmp %edx,%edi + 6db: 75 eb jne 6c8 + p = sbrk(nu * sizeof(Header)); + 6dd: 83 ec 0c sub $0xc,%esp + 6e0: ff 75 e4 push -0x1c(%ebp) + 6e3: e8 3b fc ff ff call 323 + if (p == (char*)-1) { + 6e8: 83 c4 10 add $0x10,%esp + 6eb: 83 f8 ff cmp $0xffffffff,%eax + 6ee: 74 1c je 70c + hp->s.size = nu; + 6f0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6f3: 83 ec 0c sub $0xc,%esp + 6f6: 83 c0 08 add $0x8,%eax + 6f9: 50 push %eax + 6fa: e8 f1 fe ff ff call 5f0 + return freep; + 6ff: 8b 15 c4 0a 00 00 mov 0xac4,%edx + if ((p = morecore(nunits)) == 0) { + 705: 83 c4 10 add $0x10,%esp + 708: 85 d2 test %edx,%edx + 70a: 75 bc jne 6c8 + return 0; + } + } + } +} + 70c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 70f: 31 c0 xor %eax,%eax +} + 711: 5b pop %ebx + 712: 5e pop %esi + 713: 5f pop %edi + 714: 5d pop %ebp + 715: c3 ret + if (p->s.size >= nunits) { + 716: 89 d0 mov %edx,%eax + 718: 89 fa mov %edi,%edx + 71a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 720: 39 ce cmp %ecx,%esi + 722: 74 4c je 770 + p->s.size -= nunits; + 724: 29 f1 sub %esi,%ecx + 726: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 729: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 72c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 72f: 89 15 c4 0a 00 00 mov %edx,0xac4 +} + 735: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 738: 83 c0 08 add $0x8,%eax +} + 73b: 5b pop %ebx + 73c: 5e pop %esi + 73d: 5f pop %edi + 73e: 5d pop %ebp + 73f: c3 ret + base.s.ptr = freep = prevp = &base; + 740: c7 05 c4 0a 00 00 c8 movl $0xac8,0xac4 + 747: 0a 00 00 + base.s.size = 0; + 74a: bf c8 0a 00 00 mov $0xac8,%edi + base.s.ptr = freep = prevp = &base; + 74f: c7 05 c8 0a 00 00 c8 movl $0xac8,0xac8 + 756: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 759: 89 fa mov %edi,%edx + base.s.size = 0; + 75b: c7 05 cc 0a 00 00 00 movl $0x0,0xacc + 762: 00 00 00 + if (p->s.size >= nunits) { + 765: e9 42 ff ff ff jmp 6ac + 76a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 770: 8b 08 mov (%eax),%ecx + 772: 89 0a mov %ecx,(%edx) + 774: eb b9 jmp 72f diff --git a/mkdir.d b/mkdir.d new file mode 100644 index 0000000..0c77808 --- /dev/null +++ b/mkdir.d @@ -0,0 +1 @@ +mkdir.o: mkdir.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/mkdir.o b/mkdir.o new file mode 100644 index 0000000..3a6e6cb Binary files /dev/null and b/mkdir.o differ diff --git a/mkdir.sym b/mkdir.sym new file mode 100644 index 0000000..819228f --- /dev/null +++ b/mkdir.sym @@ -0,0 +1,50 @@ +00000000 mkdir.c +00000000 ulib.c +00000000 printf.c +000003a0 printint +0000080c digits.0 +00000000 umalloc.c +00000ac4 freep +00000ac8 base +00000080 strcpy +00000450 printf +0000037b greeting +000002a0 memmove +0000034b mknod +000001a0 gets +0000031b getpid +0000038b screen +00000680 malloc +0000032b sleep +000002e3 pipe +00000373 getch +00000343 write +00000303 fstat +000002f3 kill +0000030b chdir +000002fb exec +000002db wait +000002eb read +00000353 unlink +000002cb fork +00000323 sbrk +00000333 uptime +00000ac4 __bss_start +00000140 memset +00000000 main +000000b0 strcmp +00000383 shutdown +00000313 dup +00000210 stat +00000ac4 _edata +00000ad0 _end +0000035b link +000002d3 exit +00000260 atoi +00000393 cls +00000110 strlen +0000033b open +00000160 strchr +00000363 mkdir +0000036b close +000005f0 free diff --git a/mkfs b/mkfs new file mode 100644 index 0000000..d536cc4 Binary files /dev/null and b/mkfs differ diff --git a/mp.d b/mp.d new file mode 100644 index 0000000..0714441 --- /dev/null +++ b/mp.d @@ -0,0 +1,2 @@ +mp.o: mp.c /usr/include/stdc-predef.h types.h defs.h param.h memlayout.h \ + mp.h x86.h mmu.h proc.h diff --git a/mp.o b/mp.o new file mode 100644 index 0000000..fdf3583 Binary files /dev/null and b/mp.o differ diff --git a/picirq.d b/picirq.d new file mode 100644 index 0000000..5233e7e --- /dev/null +++ b/picirq.d @@ -0,0 +1 @@ +picirq.o: picirq.c /usr/include/stdc-predef.h types.h x86.h traps.h diff --git a/picirq.o b/picirq.o new file mode 100644 index 0000000..2da8969 Binary files /dev/null and b/picirq.o differ diff --git a/pipe.d b/pipe.d new file mode 100644 index 0000000..3d0eac9 --- /dev/null +++ b/pipe.d @@ -0,0 +1,2 @@ +pipe.o: pipe.c /usr/include/stdc-predef.h types.h defs.h param.h mmu.h \ + proc.h fs.h spinlock.h sleeplock.h file.h diff --git a/pipe.o b/pipe.o new file mode 100644 index 0000000..9cd2608 Binary files /dev/null and b/pipe.o differ diff --git a/printf.d b/printf.d new file mode 100644 index 0000000..ddd3a8d --- /dev/null +++ b/printf.d @@ -0,0 +1 @@ +printf.o: printf.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/printf.o b/printf.o new file mode 100644 index 0000000..940bfcd Binary files /dev/null and b/printf.o differ diff --git a/proc.d b/proc.d new file mode 100644 index 0000000..9396fef --- /dev/null +++ b/proc.d @@ -0,0 +1,2 @@ +proc.o: proc.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h x86.h proc.h spinlock.h diff --git a/proc.o b/proc.o new file mode 100644 index 0000000..7337324 Binary files /dev/null and b/proc.o differ diff --git a/rm.asm b/rm.asm new file mode 100644 index 0000000..54173a1 --- /dev/null +++ b/rm.asm @@ -0,0 +1,1202 @@ + +_rm: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "stat.h" +#include "user.h" + +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: bf 01 00 00 00 mov $0x1,%edi + 13: 56 push %esi + 14: 53 push %ebx + 15: 51 push %ecx + 16: 83 ec 08 sub $0x8,%esp + 19: 8b 59 04 mov 0x4(%ecx),%ebx + 1c: 8b 31 mov (%ecx),%esi + 1e: 83 c3 04 add $0x4,%ebx + int i; + + if (argc < 2) { + 21: 83 fe 01 cmp $0x1,%esi + 24: 7e 3e jle 64 + 26: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2d: 8d 76 00 lea 0x0(%esi),%esi + printf(2, "Usage: rm files...\n"); + exit(); + } + + for (i = 1; i < argc; i++) { + if (unlink(argv[i]) < 0) { + 30: 83 ec 0c sub $0xc,%esp + 33: ff 33 push (%ebx) + 35: e8 19 03 00 00 call 353 + 3a: 83 c4 10 add $0x10,%esp + 3d: 85 c0 test %eax,%eax + 3f: 78 0f js 50 + for (i = 1; i < argc; i++) { + 41: 83 c7 01 add $0x1,%edi + 44: 83 c3 04 add $0x4,%ebx + 47: 39 fe cmp %edi,%esi + 49: 75 e5 jne 30 + printf(2, "rm: %s failed to delete\n", argv[i]); + break; + } + } + + exit(); + 4b: e8 83 02 00 00 call 2d3 + printf(2, "rm: %s failed to delete\n", argv[i]); + 50: 50 push %eax + 51: ff 33 push (%ebx) + 53: 68 8c 07 00 00 push $0x78c + 58: 6a 02 push $0x2 + 5a: e8 f1 03 00 00 call 450 + break; + 5f: 83 c4 10 add $0x10,%esp + 62: eb e7 jmp 4b + printf(2, "Usage: rm files...\n"); + 64: 52 push %edx + 65: 52 push %edx + 66: 68 78 07 00 00 push $0x778 + 6b: 6a 02 push $0x2 + 6d: e8 de 03 00 00 call 450 + exit(); + 72: e8 5c 02 00 00 call 2d3 + 77: 66 90 xchg %ax,%ax + 79: 66 90 xchg %ax,%ax + 7b: 66 90 xchg %ax,%ax + 7d: 66 90 xchg %ax,%ax + 7f: 90 nop + +00000080 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 80: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 81: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 83: 89 e5 mov %esp,%ebp + 85: 53 push %ebx + 86: 8b 4d 08 mov 0x8(%ebp),%ecx + 89: 8b 5d 0c mov 0xc(%ebp),%ebx + 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 90: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 94: 88 14 01 mov %dl,(%ecx,%eax,1) + 97: 83 c0 01 add $0x1,%eax + 9a: 84 d2 test %dl,%dl + 9c: 75 f2 jne 90 + ; + } + return os; +} + 9e: 8b 5d fc mov -0x4(%ebp),%ebx + a1: 89 c8 mov %ecx,%eax + a3: c9 leave + a4: c3 ret + a5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000000b0 : + +int strcmp(const char *p, const char *q) { + b0: 55 push %ebp + b1: 89 e5 mov %esp,%ebp + b3: 53 push %ebx + b4: 8b 55 08 mov 0x8(%ebp),%edx + b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + ba: 0f b6 02 movzbl (%edx),%eax + bd: 84 c0 test %al,%al + bf: 75 17 jne d8 + c1: eb 3a jmp fd + c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c7: 90 nop + c8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + cc: 83 c2 01 add $0x1,%edx + cf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + d2: 84 c0 test %al,%al + d4: 74 1a je f0 + p++, q++; + d6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + d8: 0f b6 19 movzbl (%ecx),%ebx + db: 38 c3 cmp %al,%bl + dd: 74 e9 je c8 + } + return (uchar) * p - (uchar) * q; + df: 29 d8 sub %ebx,%eax +} + e1: 8b 5d fc mov -0x4(%ebp),%ebx + e4: c9 leave + e5: c3 ret + e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ed: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + f0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + f4: 31 c0 xor %eax,%eax + f6: 29 d8 sub %ebx,%eax +} + f8: 8b 5d fc mov -0x4(%ebp),%ebx + fb: c9 leave + fc: c3 ret + return (uchar) * p - (uchar) * q; + fd: 0f b6 19 movzbl (%ecx),%ebx + 100: 31 c0 xor %eax,%eax + 102: eb db jmp df + 104: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 10b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 10f: 90 nop + +00000110 : + +uint strlen(const char *s) { + 110: 55 push %ebp + 111: 89 e5 mov %esp,%ebp + 113: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 116: 80 3a 00 cmpb $0x0,(%edx) + 119: 74 15 je 130 + 11b: 31 c0 xor %eax,%eax + 11d: 8d 76 00 lea 0x0(%esi),%esi + 120: 83 c0 01 add $0x1,%eax + 123: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 127: 89 c1 mov %eax,%ecx + 129: 75 f5 jne 120 + ; + } + return n; +} + 12b: 89 c8 mov %ecx,%eax + 12d: 5d pop %ebp + 12e: c3 ret + 12f: 90 nop + for (n = 0; s[n]; n++) { + 130: 31 c9 xor %ecx,%ecx +} + 132: 5d pop %ebp + 133: 89 c8 mov %ecx,%eax + 135: c3 ret + 136: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 13d: 8d 76 00 lea 0x0(%esi),%esi + +00000140 : + +void* memset(void *dst, int c, uint n) { + 140: 55 push %ebp + 141: 89 e5 mov %esp,%ebp + 143: 57 push %edi + 144: 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" : + 147: 8b 4d 10 mov 0x10(%ebp),%ecx + 14a: 8b 45 0c mov 0xc(%ebp),%eax + 14d: 89 d7 mov %edx,%edi + 14f: fc cld + 150: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 152: 8b 7d fc mov -0x4(%ebp),%edi + 155: 89 d0 mov %edx,%eax + 157: c9 leave + 158: c3 ret + 159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000160 : + +char* strchr(const char *s, char c) { + 160: 55 push %ebp + 161: 89 e5 mov %esp,%ebp + 163: 8b 45 08 mov 0x8(%ebp),%eax + 166: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 16a: 0f b6 10 movzbl (%eax),%edx + 16d: 84 d2 test %dl,%dl + 16f: 75 12 jne 183 + 171: eb 1d jmp 190 + 173: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 177: 90 nop + 178: 0f b6 50 01 movzbl 0x1(%eax),%edx + 17c: 83 c0 01 add $0x1,%eax + 17f: 84 d2 test %dl,%dl + 181: 74 0d je 190 + if (*s == c) { + 183: 38 d1 cmp %dl,%cl + 185: 75 f1 jne 178 + return (char*)s; + } + } + return 0; +} + 187: 5d pop %ebp + 188: c3 ret + 189: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 190: 31 c0 xor %eax,%eax +} + 192: 5d pop %ebp + 193: c3 ret + 194: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 19b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 19f: 90 nop + +000001a0 : + +char* gets(char *buf, int max) { + 1a0: 55 push %ebp + 1a1: 89 e5 mov %esp,%ebp + 1a3: 57 push %edi + 1a4: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 1a5: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 1a8: 53 push %ebx + for (i = 0; i + 1 < max;) { + 1a9: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 1ab: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 1ae: eb 27 jmp 1d7 + cc = read(0, &c, 1); + 1b0: 83 ec 04 sub $0x4,%esp + 1b3: 6a 01 push $0x1 + 1b5: 57 push %edi + 1b6: 6a 00 push $0x0 + 1b8: e8 2e 01 00 00 call 2eb + if (cc < 1) { + 1bd: 83 c4 10 add $0x10,%esp + 1c0: 85 c0 test %eax,%eax + 1c2: 7e 1d jle 1e1 + break; + } + buf[i++] = c; + 1c4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1c8: 8b 55 08 mov 0x8(%ebp),%edx + 1cb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1cf: 3c 0a cmp $0xa,%al + 1d1: 74 1d je 1f0 + 1d3: 3c 0d cmp $0xd,%al + 1d5: 74 19 je 1f0 + for (i = 0; i + 1 < max;) { + 1d7: 89 de mov %ebx,%esi + 1d9: 83 c3 01 add $0x1,%ebx + 1dc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1df: 7c cf jl 1b0 + break; + } + } + buf[i] = '\0'; + 1e1: 8b 45 08 mov 0x8(%ebp),%eax + 1e4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1e8: 8d 65 f4 lea -0xc(%ebp),%esp + 1eb: 5b pop %ebx + 1ec: 5e pop %esi + 1ed: 5f pop %edi + 1ee: 5d pop %ebp + 1ef: c3 ret + buf[i] = '\0'; + 1f0: 8b 45 08 mov 0x8(%ebp),%eax + 1f3: 89 de mov %ebx,%esi + 1f5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1f9: 8d 65 f4 lea -0xc(%ebp),%esp + 1fc: 5b pop %ebx + 1fd: 5e pop %esi + 1fe: 5f pop %edi + 1ff: 5d pop %ebp + 200: c3 ret + 201: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 208: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 20f: 90 nop + +00000210 : + +int stat(const char *n, struct stat *st) { + 210: 55 push %ebp + 211: 89 e5 mov %esp,%ebp + 213: 56 push %esi + 214: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 215: 83 ec 08 sub $0x8,%esp + 218: 6a 00 push $0x0 + 21a: ff 75 08 push 0x8(%ebp) + 21d: e8 19 01 00 00 call 33b + if (fd < 0) { + 222: 83 c4 10 add $0x10,%esp + 225: 85 c0 test %eax,%eax + 227: 78 27 js 250 + return -1; + } + r = fstat(fd, st); + 229: 83 ec 08 sub $0x8,%esp + 22c: ff 75 0c push 0xc(%ebp) + 22f: 89 c3 mov %eax,%ebx + 231: 50 push %eax + 232: e8 cc 00 00 00 call 303 + close(fd); + 237: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 23a: 89 c6 mov %eax,%esi + close(fd); + 23c: e8 2a 01 00 00 call 36b + return r; + 241: 83 c4 10 add $0x10,%esp +} + 244: 8d 65 f8 lea -0x8(%ebp),%esp + 247: 89 f0 mov %esi,%eax + 249: 5b pop %ebx + 24a: 5e pop %esi + 24b: 5d pop %ebp + 24c: c3 ret + 24d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 250: be ff ff ff ff mov $0xffffffff,%esi + 255: eb ed jmp 244 + 257: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25e: 66 90 xchg %ax,%ax + +00000260 : + +int atoi(const char *s) { + 260: 55 push %ebp + 261: 89 e5 mov %esp,%ebp + 263: 53 push %ebx + 264: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 267: 0f be 02 movsbl (%edx),%eax + 26a: 8d 48 d0 lea -0x30(%eax),%ecx + 26d: 80 f9 09 cmp $0x9,%cl + n = 0; + 270: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 275: 77 1e ja 295 + 277: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 27e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 280: 83 c2 01 add $0x1,%edx + 283: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 286: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 28a: 0f be 02 movsbl (%edx),%eax + 28d: 8d 58 d0 lea -0x30(%eax),%ebx + 290: 80 fb 09 cmp $0x9,%bl + 293: 76 eb jbe 280 + } + return n; +} + 295: 8b 5d fc mov -0x4(%ebp),%ebx + 298: 89 c8 mov %ecx,%eax + 29a: c9 leave + 29b: c3 ret + 29c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000002a0 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 2a0: 55 push %ebp + 2a1: 89 e5 mov %esp,%ebp + 2a3: 57 push %edi + 2a4: 8b 45 10 mov 0x10(%ebp),%eax + 2a7: 8b 55 08 mov 0x8(%ebp),%edx + 2aa: 56 push %esi + 2ab: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 2ae: 85 c0 test %eax,%eax + 2b0: 7e 13 jle 2c5 + 2b2: 01 d0 add %edx,%eax + dst = vdst; + 2b4: 89 d7 mov %edx,%edi + 2b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2bd: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2c0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2c1: 39 f8 cmp %edi,%eax + 2c3: 75 fb jne 2c0 + } + return vdst; +} + 2c5: 5e pop %esi + 2c6: 89 d0 mov %edx,%eax + 2c8: 5f pop %edi + 2c9: 5d pop %ebp + 2ca: c3 ret + +000002cb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2cb: b8 01 00 00 00 mov $0x1,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(exit) + 2d3: b8 02 00 00 00 mov $0x2,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(wait) + 2db: b8 03 00 00 00 mov $0x3,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(pipe) + 2e3: b8 04 00 00 00 mov $0x4,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(read) + 2eb: b8 05 00 00 00 mov $0x5,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(kill) + 2f3: b8 06 00 00 00 mov $0x6,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(exec) + 2fb: b8 07 00 00 00 mov $0x7,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(fstat) + 303: b8 08 00 00 00 mov $0x8,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(chdir) + 30b: b8 09 00 00 00 mov $0x9,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(dup) + 313: b8 0a 00 00 00 mov $0xa,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(getpid) + 31b: b8 0b 00 00 00 mov $0xb,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(sbrk) + 323: b8 0c 00 00 00 mov $0xc,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(sleep) + 32b: b8 0d 00 00 00 mov $0xd,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(uptime) + 333: b8 0e 00 00 00 mov $0xe,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(open) + 33b: b8 0f 00 00 00 mov $0xf,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(write) + 343: b8 10 00 00 00 mov $0x10,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(mknod) + 34b: b8 11 00 00 00 mov $0x11,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(unlink) + 353: b8 12 00 00 00 mov $0x12,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(link) + 35b: b8 13 00 00 00 mov $0x13,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(mkdir) + 363: b8 14 00 00 00 mov $0x14,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(close) + 36b: b8 15 00 00 00 mov $0x15,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(getch) + 373: b8 16 00 00 00 mov $0x16,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(greeting) + 37b: b8 17 00 00 00 mov $0x17,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(shutdown) + 383: b8 18 00 00 00 mov $0x18,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + +0000038b : +SYSCALL(screen) + 38b: b8 19 00 00 00 mov $0x19,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(cls) + 393: b8 1a 00 00 00 mov $0x1a,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + 39b: 66 90 xchg %ax,%ax + 39d: 66 90 xchg %ax,%ax + 39f: 90 nop + +000003a0 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 3a0: 55 push %ebp + 3a1: 89 e5 mov %esp,%ebp + 3a3: 57 push %edi + 3a4: 56 push %esi + 3a5: 53 push %ebx + 3a6: 83 ec 3c sub $0x3c,%esp + 3a9: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 3ac: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 3ae: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 3b1: 85 d2 test %edx,%edx + 3b3: 0f 89 7f 00 00 00 jns 438 + 3b9: f6 45 08 01 testb $0x1,0x8(%ebp) + 3bd: 74 79 je 438 + neg = 1; + 3bf: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3c6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3c8: 31 db xor %ebx,%ebx + 3ca: 8d 75 d7 lea -0x29(%ebp),%esi + 3cd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3d0: 89 c8 mov %ecx,%eax + 3d2: 31 d2 xor %edx,%edx + 3d4: 89 cf mov %ecx,%edi + 3d6: f7 75 c4 divl -0x3c(%ebp) + 3d9: 0f b6 92 04 08 00 00 movzbl 0x804(%edx),%edx + 3e0: 89 45 c0 mov %eax,-0x40(%ebp) + 3e3: 89 d8 mov %ebx,%eax + 3e5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3e8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3eb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3ee: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3f1: 76 dd jbe 3d0 + if (neg) { + 3f3: 8b 4d bc mov -0x44(%ebp),%ecx + 3f6: 85 c9 test %ecx,%ecx + 3f8: 74 0c je 406 + buf[i++] = '-'; + 3fa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3ff: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 401: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 406: 8b 7d b8 mov -0x48(%ebp),%edi + 409: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 40d: eb 07 jmp 416 + 40f: 90 nop + putc(fd, buf[i]); + 410: 0f b6 13 movzbl (%ebx),%edx + 413: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 416: 83 ec 04 sub $0x4,%esp + 419: 88 55 d7 mov %dl,-0x29(%ebp) + 41c: 6a 01 push $0x1 + 41e: 56 push %esi + 41f: 57 push %edi + 420: e8 1e ff ff ff call 343 + while (--i >= 0) { + 425: 83 c4 10 add $0x10,%esp + 428: 39 de cmp %ebx,%esi + 42a: 75 e4 jne 410 + } +} + 42c: 8d 65 f4 lea -0xc(%ebp),%esp + 42f: 5b pop %ebx + 430: 5e pop %esi + 431: 5f pop %edi + 432: 5d pop %ebp + 433: c3 ret + 434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 438: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 43f: eb 87 jmp 3c8 + 441: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 448: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 44f: 90 nop + +00000450 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 450: 55 push %ebp + 451: 89 e5 mov %esp,%ebp + 453: 57 push %edi + 454: 56 push %esi + 455: 53 push %ebx + 456: 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++) { + 459: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 45c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 45f: 0f b6 13 movzbl (%ebx),%edx + 462: 84 d2 test %dl,%dl + 464: 74 6a je 4d0 + ap = (uint*)(void*)&fmt + 1; + 466: 8d 45 10 lea 0x10(%ebp),%eax + 469: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 46c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 46f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 471: 89 45 d0 mov %eax,-0x30(%ebp) + 474: eb 36 jmp 4ac + 476: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 47d: 8d 76 00 lea 0x0(%esi),%esi + 480: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 483: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 488: 83 f8 25 cmp $0x25,%eax + 48b: 74 15 je 4a2 + write(fd, &c, 1); + 48d: 83 ec 04 sub $0x4,%esp + 490: 88 55 e7 mov %dl,-0x19(%ebp) + 493: 6a 01 push $0x1 + 495: 57 push %edi + 496: 56 push %esi + 497: e8 a7 fe ff ff call 343 + 49c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 49f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 4a2: 0f b6 13 movzbl (%ebx),%edx + 4a5: 83 c3 01 add $0x1,%ebx + 4a8: 84 d2 test %dl,%dl + 4aa: 74 24 je 4d0 + c = fmt[i] & 0xff; + 4ac: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 4af: 85 c9 test %ecx,%ecx + 4b1: 74 cd je 480 + } + } + else if (state == '%') { + 4b3: 83 f9 25 cmp $0x25,%ecx + 4b6: 75 ea jne 4a2 + if (c == 'd') { + 4b8: 83 f8 25 cmp $0x25,%eax + 4bb: 0f 84 07 01 00 00 je 5c8 + 4c1: 83 e8 63 sub $0x63,%eax + 4c4: 83 f8 15 cmp $0x15,%eax + 4c7: 77 17 ja 4e0 + 4c9: ff 24 85 ac 07 00 00 jmp *0x7ac(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4d0: 8d 65 f4 lea -0xc(%ebp),%esp + 4d3: 5b pop %ebx + 4d4: 5e pop %esi + 4d5: 5f pop %edi + 4d6: 5d pop %ebp + 4d7: c3 ret + 4d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4df: 90 nop + write(fd, &c, 1); + 4e0: 83 ec 04 sub $0x4,%esp + 4e3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4e6: 6a 01 push $0x1 + 4e8: 57 push %edi + 4e9: 56 push %esi + 4ea: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4ee: e8 50 fe ff ff call 343 + putc(fd, c); + 4f3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4f7: 83 c4 0c add $0xc,%esp + 4fa: 88 55 e7 mov %dl,-0x19(%ebp) + 4fd: 6a 01 push $0x1 + 4ff: 57 push %edi + 500: 56 push %esi + 501: e8 3d fe ff ff call 343 + putc(fd, c); + 506: 83 c4 10 add $0x10,%esp + state = 0; + 509: 31 c9 xor %ecx,%ecx + 50b: eb 95 jmp 4a2 + 50d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 510: 83 ec 0c sub $0xc,%esp + 513: b9 10 00 00 00 mov $0x10,%ecx + 518: 6a 00 push $0x0 + 51a: 8b 45 d0 mov -0x30(%ebp),%eax + 51d: 8b 10 mov (%eax),%edx + 51f: 89 f0 mov %esi,%eax + 521: e8 7a fe ff ff call 3a0 + ap++; + 526: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 52a: 83 c4 10 add $0x10,%esp + state = 0; + 52d: 31 c9 xor %ecx,%ecx + 52f: e9 6e ff ff ff jmp 4a2 + 534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 538: 8b 45 d0 mov -0x30(%ebp),%eax + 53b: 8b 10 mov (%eax),%edx + ap++; + 53d: 83 c0 04 add $0x4,%eax + 540: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 543: 85 d2 test %edx,%edx + 545: 0f 84 8d 00 00 00 je 5d8 + while (*s != 0) { + 54b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 54e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 550: 84 c0 test %al,%al + 552: 0f 84 4a ff ff ff je 4a2 + 558: 89 5d d4 mov %ebx,-0x2c(%ebp) + 55b: 89 d3 mov %edx,%ebx + 55d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 560: 83 ec 04 sub $0x4,%esp + s++; + 563: 83 c3 01 add $0x1,%ebx + 566: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 569: 6a 01 push $0x1 + 56b: 57 push %edi + 56c: 56 push %esi + 56d: e8 d1 fd ff ff call 343 + while (*s != 0) { + 572: 0f b6 03 movzbl (%ebx),%eax + 575: 83 c4 10 add $0x10,%esp + 578: 84 c0 test %al,%al + 57a: 75 e4 jne 560 + state = 0; + 57c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 57f: 31 c9 xor %ecx,%ecx + 581: e9 1c ff ff ff jmp 4a2 + 586: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 58d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 590: 83 ec 0c sub $0xc,%esp + 593: b9 0a 00 00 00 mov $0xa,%ecx + 598: 6a 01 push $0x1 + 59a: e9 7b ff ff ff jmp 51a + 59f: 90 nop + putc(fd, *ap); + 5a0: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 5a3: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 5a6: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 5a8: 6a 01 push $0x1 + 5aa: 57 push %edi + 5ab: 56 push %esi + putc(fd, *ap); + 5ac: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 5af: e8 8f fd ff ff call 343 + ap++; + 5b4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5b8: 83 c4 10 add $0x10,%esp + state = 0; + 5bb: 31 c9 xor %ecx,%ecx + 5bd: e9 e0 fe ff ff jmp 4a2 + 5c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5c8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5cb: 83 ec 04 sub $0x4,%esp + 5ce: e9 2a ff ff ff jmp 4fd + 5d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5d7: 90 nop + s = "(null)"; + 5d8: ba a5 07 00 00 mov $0x7a5,%edx + while (*s != 0) { + 5dd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5e0: b8 28 00 00 00 mov $0x28,%eax + 5e5: 89 d3 mov %edx,%ebx + 5e7: e9 74 ff ff ff jmp 560 + 5ec: 66 90 xchg %ax,%ax + 5ee: 66 90 xchg %ax,%ax + +000005f0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5f1: a1 bc 0a 00 00 mov 0xabc,%eax +void free(void *ap) { + 5f6: 89 e5 mov %esp,%ebp + 5f8: 57 push %edi + 5f9: 56 push %esi + 5fa: 53 push %ebx + 5fb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5fe: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 601: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 608: 89 c2 mov %eax,%edx + 60a: 8b 00 mov (%eax),%eax + 60c: 39 ca cmp %ecx,%edx + 60e: 73 30 jae 640 + 610: 39 c1 cmp %eax,%ecx + 612: 72 04 jb 618 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 614: 39 c2 cmp %eax,%edx + 616: 72 f0 jb 608 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 618: 8b 73 fc mov -0x4(%ebx),%esi + 61b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 61e: 39 f8 cmp %edi,%eax + 620: 74 30 je 652 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 622: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 625: 8b 42 04 mov 0x4(%edx),%eax + 628: 8d 34 c2 lea (%edx,%eax,8),%esi + 62b: 39 f1 cmp %esi,%ecx + 62d: 74 3a je 669 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 62f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 631: 5b pop %ebx + freep = p; + 632: 89 15 bc 0a 00 00 mov %edx,0xabc +} + 638: 5e pop %esi + 639: 5f pop %edi + 63a: 5d pop %ebp + 63b: c3 ret + 63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 640: 39 c2 cmp %eax,%edx + 642: 72 c4 jb 608 + 644: 39 c1 cmp %eax,%ecx + 646: 73 c0 jae 608 + if (bp + bp->s.size == p->s.ptr) { + 648: 8b 73 fc mov -0x4(%ebx),%esi + 64b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 64e: 39 f8 cmp %edi,%eax + 650: 75 d0 jne 622 + bp->s.size += p->s.ptr->s.size; + 652: 03 70 04 add 0x4(%eax),%esi + 655: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 658: 8b 02 mov (%edx),%eax + 65a: 8b 00 mov (%eax),%eax + 65c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 65f: 8b 42 04 mov 0x4(%edx),%eax + 662: 8d 34 c2 lea (%edx,%eax,8),%esi + 665: 39 f1 cmp %esi,%ecx + 667: 75 c6 jne 62f + p->s.size += bp->s.size; + 669: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 66c: 89 15 bc 0a 00 00 mov %edx,0xabc + p->s.size += bp->s.size; + 672: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 675: 8b 4b f8 mov -0x8(%ebx),%ecx + 678: 89 0a mov %ecx,(%edx) +} + 67a: 5b pop %ebx + 67b: 5e pop %esi + 67c: 5f pop %edi + 67d: 5d pop %ebp + 67e: c3 ret + 67f: 90 nop + +00000680 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 680: 55 push %ebp + 681: 89 e5 mov %esp,%ebp + 683: 57 push %edi + 684: 56 push %esi + 685: 53 push %ebx + 686: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 689: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 68c: 8b 3d bc 0a 00 00 mov 0xabc,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 692: 8d 70 07 lea 0x7(%eax),%esi + 695: c1 ee 03 shr $0x3,%esi + 698: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 69b: 85 ff test %edi,%edi + 69d: 0f 84 9d 00 00 00 je 740 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6a3: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 6a5: 8b 4a 04 mov 0x4(%edx),%ecx + 6a8: 39 f1 cmp %esi,%ecx + 6aa: 73 6a jae 716 + 6ac: bb 00 10 00 00 mov $0x1000,%ebx + 6b1: 39 de cmp %ebx,%esi + 6b3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 6b6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 6bd: 89 45 e4 mov %eax,-0x1c(%ebp) + 6c0: eb 17 jmp 6d9 + 6c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6c8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6ca: 8b 48 04 mov 0x4(%eax),%ecx + 6cd: 39 f1 cmp %esi,%ecx + 6cf: 73 4f jae 720 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6d1: 8b 3d bc 0a 00 00 mov 0xabc,%edi + 6d7: 89 c2 mov %eax,%edx + 6d9: 39 d7 cmp %edx,%edi + 6db: 75 eb jne 6c8 + p = sbrk(nu * sizeof(Header)); + 6dd: 83 ec 0c sub $0xc,%esp + 6e0: ff 75 e4 push -0x1c(%ebp) + 6e3: e8 3b fc ff ff call 323 + if (p == (char*)-1) { + 6e8: 83 c4 10 add $0x10,%esp + 6eb: 83 f8 ff cmp $0xffffffff,%eax + 6ee: 74 1c je 70c + hp->s.size = nu; + 6f0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6f3: 83 ec 0c sub $0xc,%esp + 6f6: 83 c0 08 add $0x8,%eax + 6f9: 50 push %eax + 6fa: e8 f1 fe ff ff call 5f0 + return freep; + 6ff: 8b 15 bc 0a 00 00 mov 0xabc,%edx + if ((p = morecore(nunits)) == 0) { + 705: 83 c4 10 add $0x10,%esp + 708: 85 d2 test %edx,%edx + 70a: 75 bc jne 6c8 + return 0; + } + } + } +} + 70c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 70f: 31 c0 xor %eax,%eax +} + 711: 5b pop %ebx + 712: 5e pop %esi + 713: 5f pop %edi + 714: 5d pop %ebp + 715: c3 ret + if (p->s.size >= nunits) { + 716: 89 d0 mov %edx,%eax + 718: 89 fa mov %edi,%edx + 71a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 720: 39 ce cmp %ecx,%esi + 722: 74 4c je 770 + p->s.size -= nunits; + 724: 29 f1 sub %esi,%ecx + 726: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 729: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 72c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 72f: 89 15 bc 0a 00 00 mov %edx,0xabc +} + 735: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 738: 83 c0 08 add $0x8,%eax +} + 73b: 5b pop %ebx + 73c: 5e pop %esi + 73d: 5f pop %edi + 73e: 5d pop %ebp + 73f: c3 ret + base.s.ptr = freep = prevp = &base; + 740: c7 05 bc 0a 00 00 c0 movl $0xac0,0xabc + 747: 0a 00 00 + base.s.size = 0; + 74a: bf c0 0a 00 00 mov $0xac0,%edi + base.s.ptr = freep = prevp = &base; + 74f: c7 05 c0 0a 00 00 c0 movl $0xac0,0xac0 + 756: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 759: 89 fa mov %edi,%edx + base.s.size = 0; + 75b: c7 05 c4 0a 00 00 00 movl $0x0,0xac4 + 762: 00 00 00 + if (p->s.size >= nunits) { + 765: e9 42 ff ff ff jmp 6ac + 76a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 770: 8b 08 mov (%eax),%ecx + 772: 89 0a mov %ecx,(%edx) + 774: eb b9 jmp 72f diff --git a/rm.d b/rm.d new file mode 100644 index 0000000..ba50b6b --- /dev/null +++ b/rm.d @@ -0,0 +1 @@ +rm.o: rm.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/rm.o b/rm.o new file mode 100644 index 0000000..9e3e240 Binary files /dev/null and b/rm.o differ diff --git a/rm.sym b/rm.sym new file mode 100644 index 0000000..ab2b961 --- /dev/null +++ b/rm.sym @@ -0,0 +1,50 @@ +00000000 rm.c +00000000 ulib.c +00000000 printf.c +000003a0 printint +00000804 digits.0 +00000000 umalloc.c +00000abc freep +00000ac0 base +00000080 strcpy +00000450 printf +0000037b greeting +000002a0 memmove +0000034b mknod +000001a0 gets +0000031b getpid +0000038b screen +00000680 malloc +0000032b sleep +000002e3 pipe +00000373 getch +00000343 write +00000303 fstat +000002f3 kill +0000030b chdir +000002fb exec +000002db wait +000002eb read +00000353 unlink +000002cb fork +00000323 sbrk +00000333 uptime +00000abc __bss_start +00000140 memset +00000000 main +000000b0 strcmp +00000383 shutdown +00000313 dup +00000210 stat +00000abc _edata +00000ac8 _end +0000035b link +000002d3 exit +00000260 atoi +00000393 cls +00000110 strlen +0000033b open +00000160 strchr +00000363 mkdir +0000036b close +000005f0 free diff --git a/screen.asm b/screen.asm new file mode 100644 index 0000000..aa996dd --- /dev/null +++ b/screen.asm @@ -0,0 +1,1389 @@ + +_screen: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "user.h" + +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: 51 push %ecx + 11: 83 ec 38 sub $0x38,%esp + 14: 8b 39 mov (%ecx),%edi + 16: 8b 71 04 mov 0x4(%ecx),%esi + 19: 89 7d c4 mov %edi,-0x3c(%ebp) + int pid; + int selopt = getpid() % 10; + 1c: e8 aa 04 00 00 call 4cb + 21: ba 67 66 66 66 mov $0x66666667,%edx + 26: 89 c1 mov %eax,%ecx + 28: f7 ea imul %edx + 2a: 89 c8 mov %ecx,%eax + 2c: c1 f8 1f sar $0x1f,%eax + 2f: c1 fa 02 sar $0x2,%edx + 32: 29 c2 sub %eax,%edx + 34: 8d 04 92 lea (%edx,%edx,4),%eax + 37: 01 c0 add %eax,%eax + 39: 29 c1 sub %eax,%ecx + 3b: 89 4d c0 mov %ecx,-0x40(%ebp) + int bgcol = 0x4F00; + char title[20]; + int accepttitle = 0; + int currenttitlelen = 0; + + for (int i = 1; i < argc; i++) { + 3e: 83 ff 01 cmp $0x1,%edi + 41: 7e 6c jle af + int currenttitlelen = 0; + 43: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + for (int i = 1; i < argc; i++) { + 4a: bb 01 00 00 00 mov $0x1,%ebx + int accepttitle = 0; + 4f: 31 ff xor %edi,%edi + 51: eb 21 jmp 74 + 53: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 57: 90 nop + if (strcmp(argv[i], "-bg") == 0) + { + accepttitle = 0; + selopt = atoi(argv[i + 1]); + 58: 83 ec 0c sub $0xc,%esp + 5b: ff 74 9e 04 push 0x4(%esi,%ebx,4) + accepttitle = 0; + 5f: 31 ff xor %edi,%edi + selopt = atoi(argv[i + 1]); + 61: e8 aa 03 00 00 call 410 + 66: 83 c4 10 add $0x10,%esp + 69: 89 45 c0 mov %eax,-0x40(%ebp) + for (int i = 1; i < argc; i++) { + 6c: 83 c3 01 add $0x1,%ebx + 6f: 39 5d c4 cmp %ebx,-0x3c(%ebp) + 72: 74 3b je af + if (strcmp(argv[i], "-bg") == 0) + 74: 83 ec 08 sub $0x8,%esp + 77: 68 40 09 00 00 push $0x940 + 7c: ff 34 9e push (%esi,%ebx,4) + 7f: e8 dc 01 00 00 call 260 + 84: 83 c4 10 add $0x10,%esp + 87: 85 c0 test %eax,%eax + 89: 74 cd je 58 + } + else if (strcmp(argv[i], "-t") == 0) + 8b: 83 ec 08 sub $0x8,%esp + 8e: 68 44 09 00 00 push $0x944 + 93: ff 34 9e push (%esi,%ebx,4) + 96: e8 c5 01 00 00 call 260 + 9b: 83 c4 10 add $0x10,%esp + 9e: 85 c0 test %eax,%eax + a0: 75 3e jne e0 + { + accepttitle = 1; + a2: bf 01 00 00 00 mov $0x1,%edi + for (int i = 1; i < argc; i++) { + a7: 83 c3 01 add $0x1,%ebx + aa: 39 5d c4 cmp %ebx,-0x3c(%ebp) + ad: 75 c5 jne 74 + } + } + } + + // Set the variable to the selected bg/fg preset option + switch(selopt) + af: 8b 45 c0 mov -0x40(%ebp),%eax + b2: bb 00 4f 00 00 mov $0x4f00,%ebx + b7: 83 e8 01 sub $0x1,%eax + ba: 83 f8 08 cmp $0x8,%eax + bd: 0f 86 9a 00 00 00 jbe 15d + bgcol = 0xCF00; + break; + } + + // Fork into a new process and create the screen + pid = fork(); + c3: e8 b3 03 00 00 call 47b + if (pid < 0) { + c8: 85 c0 test %eax,%eax + ca: 0f 88 f7 00 00 00 js 1c7 + printf(1, "screen: fork failed\n"); + } + if (pid == 0) { + d0: 0f 84 93 00 00 00 je 169 + else + { + + } + } + exit(); + d6: e8 a8 03 00 00 call 483 + db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + df: 90 nop + else if (strcmp(argv[i], "-help") == 0) + e0: 83 ec 08 sub $0x8,%esp + e3: 68 47 09 00 00 push $0x947 + e8: ff 34 9e push (%esi,%ebx,4) + eb: e8 70 01 00 00 call 260 + f0: 83 c4 10 add $0x10,%esp + f3: 85 c0 test %eax,%eax + f5: 0f 84 e2 00 00 00 je 1dd + if (accepttitle) + fb: 85 ff test %edi,%edi + fd: 0f 84 69 ff ff ff je 6c + if (currenttitlelen > 0) + 103: 8b 45 bc mov -0x44(%ebp),%eax + for (sx = argv[i]; *sx != '\0'; sx++) + 106: 8b 0c 9e mov (%esi,%ebx,4),%ecx + if (currenttitlelen > 0) + 109: 85 c0 test %eax,%eax + 10b: 0f 84 92 00 00 00 je 1a3 + title[currenttitlelen] = ' '; + 111: c6 44 05 d4 20 movb $0x20,-0x2c(%ebp,%eax,1) + currenttitlelen++; + 116: 8d 50 01 lea 0x1(%eax),%edx + for (sx = argv[i]; *sx != '\0'; sx++) + 119: 0f b6 01 movzbl (%ecx),%eax + 11c: 84 c0 test %al,%al + 11e: 0f 84 f6 00 00 00 je 21a + currenttitlelen++; + 124: 83 45 bc 02 addl $0x2,-0x44(%ebp) + title[currenttitlelen] = *sx; + 128: 88 44 15 d4 mov %al,-0x2c(%ebp,%edx,1) + currenttitlelen++; + 12c: 8b 45 bc mov -0x44(%ebp),%eax + if (currenttitlelen >= 20) + 12f: 83 f8 13 cmp $0x13,%eax + 132: 0f 8f 88 00 00 00 jg 1c0 + currenttitlelen++; + 138: 8b 45 bc mov -0x44(%ebp),%eax + for (sx = argv[i]; *sx != '\0'; sx++) + 13b: 29 c1 sub %eax,%ecx + 13d: eb 0d jmp 14c + 13f: 90 nop + title[currenttitlelen] = *sx; + 140: 88 54 05 d4 mov %dl,-0x2c(%ebp,%eax,1) + currenttitlelen++; + 144: 83 c0 01 add $0x1,%eax + if (currenttitlelen >= 20) + 147: 83 f8 14 cmp $0x14,%eax + 14a: 74 6d je 1b9 + for (sx = argv[i]; *sx != '\0'; sx++) + 14c: 0f b6 54 01 01 movzbl 0x1(%ecx,%eax,1),%edx + 151: 84 d2 test %dl,%dl + 153: 75 eb jne 140 + 155: 89 45 bc mov %eax,-0x44(%ebp) + 158: e9 0f ff ff ff jmp 6c + 15d: 8b 1c 85 20 0a 00 00 mov 0xa20(,%eax,4),%ebx + 164: e9 5a ff ff ff jmp c3 + if (screen(title, bgcol) != 0) + 169: 8d 45 d4 lea -0x2c(%ebp),%eax + 16c: 57 push %edi + 16d: 57 push %edi + 16e: 53 push %ebx + 16f: 50 push %eax + 170: e8 c6 03 00 00 call 53b + 175: 83 c4 10 add $0x10,%esp + 178: 85 c0 test %eax,%eax + 17a: 0f 84 56 ff ff ff je d6 + exec("sh", argv); + 180: 50 push %eax + 181: 50 push %eax + 182: 56 push %esi + 183: 68 6c 09 00 00 push $0x96c + 188: e8 1e 03 00 00 call 4ab + printf(1, "screen: exec sh failed\n"); + 18d: 5a pop %edx + 18e: 59 pop %ecx + 18f: 68 6f 09 00 00 push $0x96f + 194: 6a 01 push $0x1 + 196: e8 65 04 00 00 call 600 + 19b: 83 c4 10 add $0x10,%esp + 19e: e9 33 ff ff ff jmp d6 + for (sx = argv[i]; *sx != '\0'; sx++) + 1a3: 0f b6 01 movzbl (%ecx),%eax + 1a6: 84 c0 test %al,%al + 1a8: 0f 84 be fe ff ff je 6c + title[currenttitlelen] = *sx; + 1ae: 88 45 d4 mov %al,-0x2c(%ebp) + currenttitlelen++; + 1b1: 89 7d bc mov %edi,-0x44(%ebp) + 1b4: e9 7f ff ff ff jmp 138 + 1b9: c7 45 bc 14 00 00 00 movl $0x14,-0x44(%ebp) + accepttitle = 0; + 1c0: 31 ff xor %edi,%edi + 1c2: e9 a5 fe ff ff jmp 6c + printf(1, "screen: fork failed\n"); + 1c7: 50 push %eax + 1c8: 50 push %eax + 1c9: 68 57 09 00 00 push $0x957 + 1ce: 6a 01 push $0x1 + 1d0: e8 2b 04 00 00 call 600 + 1d5: 83 c4 10 add $0x10,%esp + 1d8: e9 f9 fe ff ff jmp d6 + printf(1, "Creates a new virtual console.\n"); + 1dd: 50 push %eax + 1de: 50 push %eax + 1df: 68 88 09 00 00 push $0x988 + 1e4: 6a 01 push $0x1 + 1e6: e8 15 04 00 00 call 600 + printf(1, "Options:\n"); + 1eb: 58 pop %eax + 1ec: 5a pop %edx + 1ed: 68 4d 09 00 00 push $0x94d + 1f2: 6a 01 push $0x1 + 1f4: e8 07 04 00 00 call 600 + printf(1, "-bg [0 - 9] : Sets a background preset for the title bar.\n"); + 1f9: 59 pop %ecx + 1fa: 5b pop %ebx + 1fb: 68 a8 09 00 00 push $0x9a8 + 200: 6a 01 push $0x1 + 202: e8 f9 03 00 00 call 600 + printf(1, "-t [String] : Sets a custom title for the console.\n"); + 207: 5e pop %esi + 208: 5f pop %edi + 209: 68 e4 09 00 00 push $0x9e4 + 20e: 6a 01 push $0x1 + 210: e8 eb 03 00 00 call 600 + exit(); + 215: e8 69 02 00 00 call 483 + currenttitlelen++; + 21a: 89 55 bc mov %edx,-0x44(%ebp) + 21d: e9 4a fe ff ff jmp 6c + 222: 66 90 xchg %ax,%ax + 224: 66 90 xchg %ax,%ax + 226: 66 90 xchg %ax,%ax + 228: 66 90 xchg %ax,%ax + 22a: 66 90 xchg %ax,%ax + 22c: 66 90 xchg %ax,%ax + 22e: 66 90 xchg %ax,%ax + +00000230 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 230: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 231: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 233: 89 e5 mov %esp,%ebp + 235: 53 push %ebx + 236: 8b 4d 08 mov 0x8(%ebp),%ecx + 239: 8b 5d 0c mov 0xc(%ebp),%ebx + 23c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 240: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 244: 88 14 01 mov %dl,(%ecx,%eax,1) + 247: 83 c0 01 add $0x1,%eax + 24a: 84 d2 test %dl,%dl + 24c: 75 f2 jne 240 + ; + } + return os; +} + 24e: 8b 5d fc mov -0x4(%ebp),%ebx + 251: 89 c8 mov %ecx,%eax + 253: c9 leave + 254: c3 ret + 255: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000260 : + +int strcmp(const char *p, const char *q) { + 260: 55 push %ebp + 261: 89 e5 mov %esp,%ebp + 263: 53 push %ebx + 264: 8b 55 08 mov 0x8(%ebp),%edx + 267: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 26a: 0f b6 02 movzbl (%edx),%eax + 26d: 84 c0 test %al,%al + 26f: 75 17 jne 288 + 271: eb 3a jmp 2ad + 273: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 277: 90 nop + 278: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 27c: 83 c2 01 add $0x1,%edx + 27f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 282: 84 c0 test %al,%al + 284: 74 1a je 2a0 + p++, q++; + 286: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 288: 0f b6 19 movzbl (%ecx),%ebx + 28b: 38 c3 cmp %al,%bl + 28d: 74 e9 je 278 + } + return (uchar) * p - (uchar) * q; + 28f: 29 d8 sub %ebx,%eax +} + 291: 8b 5d fc mov -0x4(%ebp),%ebx + 294: c9 leave + 295: c3 ret + 296: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 29d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 2a0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 2a4: 31 c0 xor %eax,%eax + 2a6: 29 d8 sub %ebx,%eax +} + 2a8: 8b 5d fc mov -0x4(%ebp),%ebx + 2ab: c9 leave + 2ac: c3 ret + return (uchar) * p - (uchar) * q; + 2ad: 0f b6 19 movzbl (%ecx),%ebx + 2b0: 31 c0 xor %eax,%eax + 2b2: eb db jmp 28f + 2b4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 2bf: 90 nop + +000002c0 : + +uint strlen(const char *s) { + 2c0: 55 push %ebp + 2c1: 89 e5 mov %esp,%ebp + 2c3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 2c6: 80 3a 00 cmpb $0x0,(%edx) + 2c9: 74 15 je 2e0 + 2cb: 31 c0 xor %eax,%eax + 2cd: 8d 76 00 lea 0x0(%esi),%esi + 2d0: 83 c0 01 add $0x1,%eax + 2d3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 2d7: 89 c1 mov %eax,%ecx + 2d9: 75 f5 jne 2d0 + ; + } + return n; +} + 2db: 89 c8 mov %ecx,%eax + 2dd: 5d pop %ebp + 2de: c3 ret + 2df: 90 nop + for (n = 0; s[n]; n++) { + 2e0: 31 c9 xor %ecx,%ecx +} + 2e2: 5d pop %ebp + 2e3: 89 c8 mov %ecx,%eax + 2e5: c3 ret + 2e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2ed: 8d 76 00 lea 0x0(%esi),%esi + +000002f0 : + +void* memset(void *dst, int c, uint n) { + 2f0: 55 push %ebp + 2f1: 89 e5 mov %esp,%ebp + 2f3: 57 push %edi + 2f4: 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" : + 2f7: 8b 4d 10 mov 0x10(%ebp),%ecx + 2fa: 8b 45 0c mov 0xc(%ebp),%eax + 2fd: 89 d7 mov %edx,%edi + 2ff: fc cld + 300: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 302: 8b 7d fc mov -0x4(%ebp),%edi + 305: 89 d0 mov %edx,%eax + 307: c9 leave + 308: c3 ret + 309: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000310 : + +char* strchr(const char *s, char c) { + 310: 55 push %ebp + 311: 89 e5 mov %esp,%ebp + 313: 8b 45 08 mov 0x8(%ebp),%eax + 316: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 31a: 0f b6 10 movzbl (%eax),%edx + 31d: 84 d2 test %dl,%dl + 31f: 75 12 jne 333 + 321: eb 1d jmp 340 + 323: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 327: 90 nop + 328: 0f b6 50 01 movzbl 0x1(%eax),%edx + 32c: 83 c0 01 add $0x1,%eax + 32f: 84 d2 test %dl,%dl + 331: 74 0d je 340 + if (*s == c) { + 333: 38 d1 cmp %dl,%cl + 335: 75 f1 jne 328 + return (char*)s; + } + } + return 0; +} + 337: 5d pop %ebp + 338: c3 ret + 339: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 340: 31 c0 xor %eax,%eax +} + 342: 5d pop %ebp + 343: c3 ret + 344: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 34b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 34f: 90 nop + +00000350 : + +char* gets(char *buf, int max) { + 350: 55 push %ebp + 351: 89 e5 mov %esp,%ebp + 353: 57 push %edi + 354: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 355: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 358: 53 push %ebx + for (i = 0; i + 1 < max;) { + 359: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 35b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 35e: eb 27 jmp 387 + cc = read(0, &c, 1); + 360: 83 ec 04 sub $0x4,%esp + 363: 6a 01 push $0x1 + 365: 57 push %edi + 366: 6a 00 push $0x0 + 368: e8 2e 01 00 00 call 49b + if (cc < 1) { + 36d: 83 c4 10 add $0x10,%esp + 370: 85 c0 test %eax,%eax + 372: 7e 1d jle 391 + break; + } + buf[i++] = c; + 374: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 378: 8b 55 08 mov 0x8(%ebp),%edx + 37b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 37f: 3c 0a cmp $0xa,%al + 381: 74 1d je 3a0 + 383: 3c 0d cmp $0xd,%al + 385: 74 19 je 3a0 + for (i = 0; i + 1 < max;) { + 387: 89 de mov %ebx,%esi + 389: 83 c3 01 add $0x1,%ebx + 38c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 38f: 7c cf jl 360 + break; + } + } + buf[i] = '\0'; + 391: 8b 45 08 mov 0x8(%ebp),%eax + 394: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 398: 8d 65 f4 lea -0xc(%ebp),%esp + 39b: 5b pop %ebx + 39c: 5e pop %esi + 39d: 5f pop %edi + 39e: 5d pop %ebp + 39f: c3 ret + buf[i] = '\0'; + 3a0: 8b 45 08 mov 0x8(%ebp),%eax + 3a3: 89 de mov %ebx,%esi + 3a5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 3a9: 8d 65 f4 lea -0xc(%ebp),%esp + 3ac: 5b pop %ebx + 3ad: 5e pop %esi + 3ae: 5f pop %edi + 3af: 5d pop %ebp + 3b0: c3 ret + 3b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3bf: 90 nop + +000003c0 : + +int stat(const char *n, struct stat *st) { + 3c0: 55 push %ebp + 3c1: 89 e5 mov %esp,%ebp + 3c3: 56 push %esi + 3c4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 3c5: 83 ec 08 sub $0x8,%esp + 3c8: 6a 00 push $0x0 + 3ca: ff 75 08 push 0x8(%ebp) + 3cd: e8 19 01 00 00 call 4eb + if (fd < 0) { + 3d2: 83 c4 10 add $0x10,%esp + 3d5: 85 c0 test %eax,%eax + 3d7: 78 27 js 400 + return -1; + } + r = fstat(fd, st); + 3d9: 83 ec 08 sub $0x8,%esp + 3dc: ff 75 0c push 0xc(%ebp) + 3df: 89 c3 mov %eax,%ebx + 3e1: 50 push %eax + 3e2: e8 cc 00 00 00 call 4b3 + close(fd); + 3e7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 3ea: 89 c6 mov %eax,%esi + close(fd); + 3ec: e8 2a 01 00 00 call 51b + return r; + 3f1: 83 c4 10 add $0x10,%esp +} + 3f4: 8d 65 f8 lea -0x8(%ebp),%esp + 3f7: 89 f0 mov %esi,%eax + 3f9: 5b pop %ebx + 3fa: 5e pop %esi + 3fb: 5d pop %ebp + 3fc: c3 ret + 3fd: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 400: be ff ff ff ff mov $0xffffffff,%esi + 405: eb ed jmp 3f4 + 407: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 40e: 66 90 xchg %ax,%ax + +00000410 : + +int atoi(const char *s) { + 410: 55 push %ebp + 411: 89 e5 mov %esp,%ebp + 413: 53 push %ebx + 414: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 417: 0f be 02 movsbl (%edx),%eax + 41a: 8d 48 d0 lea -0x30(%eax),%ecx + 41d: 80 f9 09 cmp $0x9,%cl + n = 0; + 420: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 425: 77 1e ja 445 + 427: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 42e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 430: 83 c2 01 add $0x1,%edx + 433: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 436: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 43a: 0f be 02 movsbl (%edx),%eax + 43d: 8d 58 d0 lea -0x30(%eax),%ebx + 440: 80 fb 09 cmp $0x9,%bl + 443: 76 eb jbe 430 + } + return n; +} + 445: 8b 5d fc mov -0x4(%ebp),%ebx + 448: 89 c8 mov %ecx,%eax + 44a: c9 leave + 44b: c3 ret + 44c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000450 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 450: 55 push %ebp + 451: 89 e5 mov %esp,%ebp + 453: 57 push %edi + 454: 8b 45 10 mov 0x10(%ebp),%eax + 457: 8b 55 08 mov 0x8(%ebp),%edx + 45a: 56 push %esi + 45b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 45e: 85 c0 test %eax,%eax + 460: 7e 13 jle 475 + 462: 01 d0 add %edx,%eax + dst = vdst; + 464: 89 d7 mov %edx,%edi + 466: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 46d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 470: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 471: 39 f8 cmp %edi,%eax + 473: 75 fb jne 470 + } + return vdst; +} + 475: 5e pop %esi + 476: 89 d0 mov %edx,%eax + 478: 5f pop %edi + 479: 5d pop %ebp + 47a: c3 ret + +0000047b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 47b: b8 01 00 00 00 mov $0x1,%eax + 480: cd 40 int $0x40 + 482: c3 ret + +00000483 : +SYSCALL(exit) + 483: b8 02 00 00 00 mov $0x2,%eax + 488: cd 40 int $0x40 + 48a: c3 ret + +0000048b : +SYSCALL(wait) + 48b: b8 03 00 00 00 mov $0x3,%eax + 490: cd 40 int $0x40 + 492: c3 ret + +00000493 : +SYSCALL(pipe) + 493: b8 04 00 00 00 mov $0x4,%eax + 498: cd 40 int $0x40 + 49a: c3 ret + +0000049b : +SYSCALL(read) + 49b: b8 05 00 00 00 mov $0x5,%eax + 4a0: cd 40 int $0x40 + 4a2: c3 ret + +000004a3 : +SYSCALL(kill) + 4a3: b8 06 00 00 00 mov $0x6,%eax + 4a8: cd 40 int $0x40 + 4aa: c3 ret + +000004ab : +SYSCALL(exec) + 4ab: b8 07 00 00 00 mov $0x7,%eax + 4b0: cd 40 int $0x40 + 4b2: c3 ret + +000004b3 : +SYSCALL(fstat) + 4b3: b8 08 00 00 00 mov $0x8,%eax + 4b8: cd 40 int $0x40 + 4ba: c3 ret + +000004bb : +SYSCALL(chdir) + 4bb: b8 09 00 00 00 mov $0x9,%eax + 4c0: cd 40 int $0x40 + 4c2: c3 ret + +000004c3 : +SYSCALL(dup) + 4c3: b8 0a 00 00 00 mov $0xa,%eax + 4c8: cd 40 int $0x40 + 4ca: c3 ret + +000004cb : +SYSCALL(getpid) + 4cb: b8 0b 00 00 00 mov $0xb,%eax + 4d0: cd 40 int $0x40 + 4d2: c3 ret + +000004d3 : +SYSCALL(sbrk) + 4d3: b8 0c 00 00 00 mov $0xc,%eax + 4d8: cd 40 int $0x40 + 4da: c3 ret + +000004db : +SYSCALL(sleep) + 4db: b8 0d 00 00 00 mov $0xd,%eax + 4e0: cd 40 int $0x40 + 4e2: c3 ret + +000004e3 : +SYSCALL(uptime) + 4e3: b8 0e 00 00 00 mov $0xe,%eax + 4e8: cd 40 int $0x40 + 4ea: c3 ret + +000004eb : +SYSCALL(open) + 4eb: b8 0f 00 00 00 mov $0xf,%eax + 4f0: cd 40 int $0x40 + 4f2: c3 ret + +000004f3 : +SYSCALL(write) + 4f3: b8 10 00 00 00 mov $0x10,%eax + 4f8: cd 40 int $0x40 + 4fa: c3 ret + +000004fb : +SYSCALL(mknod) + 4fb: b8 11 00 00 00 mov $0x11,%eax + 500: cd 40 int $0x40 + 502: c3 ret + +00000503 : +SYSCALL(unlink) + 503: b8 12 00 00 00 mov $0x12,%eax + 508: cd 40 int $0x40 + 50a: c3 ret + +0000050b : +SYSCALL(link) + 50b: b8 13 00 00 00 mov $0x13,%eax + 510: cd 40 int $0x40 + 512: c3 ret + +00000513 : +SYSCALL(mkdir) + 513: b8 14 00 00 00 mov $0x14,%eax + 518: cd 40 int $0x40 + 51a: c3 ret + +0000051b : +SYSCALL(close) + 51b: b8 15 00 00 00 mov $0x15,%eax + 520: cd 40 int $0x40 + 522: c3 ret + +00000523 : +SYSCALL(getch) + 523: b8 16 00 00 00 mov $0x16,%eax + 528: cd 40 int $0x40 + 52a: c3 ret + +0000052b : +SYSCALL(greeting) + 52b: b8 17 00 00 00 mov $0x17,%eax + 530: cd 40 int $0x40 + 532: c3 ret + +00000533 : +SYSCALL(shutdown) + 533: b8 18 00 00 00 mov $0x18,%eax + 538: cd 40 int $0x40 + 53a: c3 ret + +0000053b : +SYSCALL(screen) + 53b: b8 19 00 00 00 mov $0x19,%eax + 540: cd 40 int $0x40 + 542: c3 ret + +00000543 : +SYSCALL(cls) + 543: b8 1a 00 00 00 mov $0x1a,%eax + 548: cd 40 int $0x40 + 54a: c3 ret + 54b: 66 90 xchg %ax,%ax + 54d: 66 90 xchg %ax,%ax + 54f: 90 nop + +00000550 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 550: 55 push %ebp + 551: 89 e5 mov %esp,%ebp + 553: 57 push %edi + 554: 56 push %esi + 555: 53 push %ebx + 556: 83 ec 3c sub $0x3c,%esp + 559: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 55c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 55e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 561: 85 d2 test %edx,%edx + 563: 0f 89 7f 00 00 00 jns 5e8 + 569: f6 45 08 01 testb $0x1,0x8(%ebp) + 56d: 74 79 je 5e8 + neg = 1; + 56f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 576: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 578: 31 db xor %ebx,%ebx + 57a: 8d 75 d7 lea -0x29(%ebp),%esi + 57d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 580: 89 c8 mov %ecx,%eax + 582: 31 d2 xor %edx,%edx + 584: 89 cf mov %ecx,%edi + 586: f7 75 c4 divl -0x3c(%ebp) + 589: 0f b6 92 a4 0a 00 00 movzbl 0xaa4(%edx),%edx + 590: 89 45 c0 mov %eax,-0x40(%ebp) + 593: 89 d8 mov %ebx,%eax + 595: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 598: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 59b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 59e: 39 7d c4 cmp %edi,-0x3c(%ebp) + 5a1: 76 dd jbe 580 + if (neg) { + 5a3: 8b 4d bc mov -0x44(%ebp),%ecx + 5a6: 85 c9 test %ecx,%ecx + 5a8: 74 0c je 5b6 + buf[i++] = '-'; + 5aa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 5af: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 5b1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 5b6: 8b 7d b8 mov -0x48(%ebp),%edi + 5b9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 5bd: eb 07 jmp 5c6 + 5bf: 90 nop + putc(fd, buf[i]); + 5c0: 0f b6 13 movzbl (%ebx),%edx + 5c3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 5c6: 83 ec 04 sub $0x4,%esp + 5c9: 88 55 d7 mov %dl,-0x29(%ebp) + 5cc: 6a 01 push $0x1 + 5ce: 56 push %esi + 5cf: 57 push %edi + 5d0: e8 1e ff ff ff call 4f3 + while (--i >= 0) { + 5d5: 83 c4 10 add $0x10,%esp + 5d8: 39 de cmp %ebx,%esi + 5da: 75 e4 jne 5c0 + } +} + 5dc: 8d 65 f4 lea -0xc(%ebp),%esp + 5df: 5b pop %ebx + 5e0: 5e pop %esi + 5e1: 5f pop %edi + 5e2: 5d pop %ebp + 5e3: c3 ret + 5e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 5e8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 5ef: eb 87 jmp 578 + 5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5ff: 90 nop + +00000600 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 600: 55 push %ebp + 601: 89 e5 mov %esp,%ebp + 603: 57 push %edi + 604: 56 push %esi + 605: 53 push %ebx + 606: 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++) { + 609: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 60c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 60f: 0f b6 13 movzbl (%ebx),%edx + 612: 84 d2 test %dl,%dl + 614: 74 6a je 680 + ap = (uint*)(void*)&fmt + 1; + 616: 8d 45 10 lea 0x10(%ebp),%eax + 619: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 61c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 61f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 621: 89 45 d0 mov %eax,-0x30(%ebp) + 624: eb 36 jmp 65c + 626: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 62d: 8d 76 00 lea 0x0(%esi),%esi + 630: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 633: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 638: 83 f8 25 cmp $0x25,%eax + 63b: 74 15 je 652 + write(fd, &c, 1); + 63d: 83 ec 04 sub $0x4,%esp + 640: 88 55 e7 mov %dl,-0x19(%ebp) + 643: 6a 01 push $0x1 + 645: 57 push %edi + 646: 56 push %esi + 647: e8 a7 fe ff ff call 4f3 + 64c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 64f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 652: 0f b6 13 movzbl (%ebx),%edx + 655: 83 c3 01 add $0x1,%ebx + 658: 84 d2 test %dl,%dl + 65a: 74 24 je 680 + c = fmt[i] & 0xff; + 65c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 65f: 85 c9 test %ecx,%ecx + 661: 74 cd je 630 + } + } + else if (state == '%') { + 663: 83 f9 25 cmp $0x25,%ecx + 666: 75 ea jne 652 + if (c == 'd') { + 668: 83 f8 25 cmp $0x25,%eax + 66b: 0f 84 07 01 00 00 je 778 + 671: 83 e8 63 sub $0x63,%eax + 674: 83 f8 15 cmp $0x15,%eax + 677: 77 17 ja 690 + 679: ff 24 85 4c 0a 00 00 jmp *0xa4c(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 680: 8d 65 f4 lea -0xc(%ebp),%esp + 683: 5b pop %ebx + 684: 5e pop %esi + 685: 5f pop %edi + 686: 5d pop %ebp + 687: c3 ret + 688: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 68f: 90 nop + write(fd, &c, 1); + 690: 83 ec 04 sub $0x4,%esp + 693: 88 55 d4 mov %dl,-0x2c(%ebp) + 696: 6a 01 push $0x1 + 698: 57 push %edi + 699: 56 push %esi + 69a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 69e: e8 50 fe ff ff call 4f3 + putc(fd, c); + 6a3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 6a7: 83 c4 0c add $0xc,%esp + 6aa: 88 55 e7 mov %dl,-0x19(%ebp) + 6ad: 6a 01 push $0x1 + 6af: 57 push %edi + 6b0: 56 push %esi + 6b1: e8 3d fe ff ff call 4f3 + putc(fd, c); + 6b6: 83 c4 10 add $0x10,%esp + state = 0; + 6b9: 31 c9 xor %ecx,%ecx + 6bb: eb 95 jmp 652 + 6bd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 6c0: 83 ec 0c sub $0xc,%esp + 6c3: b9 10 00 00 00 mov $0x10,%ecx + 6c8: 6a 00 push $0x0 + 6ca: 8b 45 d0 mov -0x30(%ebp),%eax + 6cd: 8b 10 mov (%eax),%edx + 6cf: 89 f0 mov %esi,%eax + 6d1: e8 7a fe ff ff call 550 + ap++; + 6d6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 6da: 83 c4 10 add $0x10,%esp + state = 0; + 6dd: 31 c9 xor %ecx,%ecx + 6df: e9 6e ff ff ff jmp 652 + 6e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 6e8: 8b 45 d0 mov -0x30(%ebp),%eax + 6eb: 8b 10 mov (%eax),%edx + ap++; + 6ed: 83 c0 04 add $0x4,%eax + 6f0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 6f3: 85 d2 test %edx,%edx + 6f5: 0f 84 8d 00 00 00 je 788 + while (*s != 0) { + 6fb: 0f b6 02 movzbl (%edx),%eax + state = 0; + 6fe: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 700: 84 c0 test %al,%al + 702: 0f 84 4a ff ff ff je 652 + 708: 89 5d d4 mov %ebx,-0x2c(%ebp) + 70b: 89 d3 mov %edx,%ebx + 70d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 710: 83 ec 04 sub $0x4,%esp + s++; + 713: 83 c3 01 add $0x1,%ebx + 716: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 719: 6a 01 push $0x1 + 71b: 57 push %edi + 71c: 56 push %esi + 71d: e8 d1 fd ff ff call 4f3 + while (*s != 0) { + 722: 0f b6 03 movzbl (%ebx),%eax + 725: 83 c4 10 add $0x10,%esp + 728: 84 c0 test %al,%al + 72a: 75 e4 jne 710 + state = 0; + 72c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 72f: 31 c9 xor %ecx,%ecx + 731: e9 1c ff ff ff jmp 652 + 736: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 73d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 740: 83 ec 0c sub $0xc,%esp + 743: b9 0a 00 00 00 mov $0xa,%ecx + 748: 6a 01 push $0x1 + 74a: e9 7b ff ff ff jmp 6ca + 74f: 90 nop + putc(fd, *ap); + 750: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 753: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 756: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 758: 6a 01 push $0x1 + 75a: 57 push %edi + 75b: 56 push %esi + putc(fd, *ap); + 75c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 75f: e8 8f fd ff ff call 4f3 + ap++; + 764: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 768: 83 c4 10 add $0x10,%esp + state = 0; + 76b: 31 c9 xor %ecx,%ecx + 76d: e9 e0 fe ff ff jmp 652 + 772: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 778: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 77b: 83 ec 04 sub $0x4,%esp + 77e: e9 2a ff ff ff jmp 6ad + 783: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 787: 90 nop + s = "(null)"; + 788: ba 44 0a 00 00 mov $0xa44,%edx + while (*s != 0) { + 78d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 790: b8 28 00 00 00 mov $0x28,%eax + 795: 89 d3 mov %edx,%ebx + 797: e9 74 ff ff ff jmp 710 + 79c: 66 90 xchg %ax,%ax + 79e: 66 90 xchg %ax,%ax + +000007a0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 7a0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 7a1: a1 58 0d 00 00 mov 0xd58,%eax +void free(void *ap) { + 7a6: 89 e5 mov %esp,%ebp + 7a8: 57 push %edi + 7a9: 56 push %esi + 7aa: 53 push %ebx + 7ab: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 7ae: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 7b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 7b8: 89 c2 mov %eax,%edx + 7ba: 8b 00 mov (%eax),%eax + 7bc: 39 ca cmp %ecx,%edx + 7be: 73 30 jae 7f0 + 7c0: 39 c1 cmp %eax,%ecx + 7c2: 72 04 jb 7c8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 7c4: 39 c2 cmp %eax,%edx + 7c6: 72 f0 jb 7b8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 7c8: 8b 73 fc mov -0x4(%ebx),%esi + 7cb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 7ce: 39 f8 cmp %edi,%eax + 7d0: 74 30 je 802 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 7d2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 7d5: 8b 42 04 mov 0x4(%edx),%eax + 7d8: 8d 34 c2 lea (%edx,%eax,8),%esi + 7db: 39 f1 cmp %esi,%ecx + 7dd: 74 3a je 819 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 7df: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 7e1: 5b pop %ebx + freep = p; + 7e2: 89 15 58 0d 00 00 mov %edx,0xd58 +} + 7e8: 5e pop %esi + 7e9: 5f pop %edi + 7ea: 5d pop %ebp + 7eb: c3 ret + 7ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 7f0: 39 c2 cmp %eax,%edx + 7f2: 72 c4 jb 7b8 + 7f4: 39 c1 cmp %eax,%ecx + 7f6: 73 c0 jae 7b8 + if (bp + bp->s.size == p->s.ptr) { + 7f8: 8b 73 fc mov -0x4(%ebx),%esi + 7fb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 7fe: 39 f8 cmp %edi,%eax + 800: 75 d0 jne 7d2 + bp->s.size += p->s.ptr->s.size; + 802: 03 70 04 add 0x4(%eax),%esi + 805: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 808: 8b 02 mov (%edx),%eax + 80a: 8b 00 mov (%eax),%eax + 80c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 80f: 8b 42 04 mov 0x4(%edx),%eax + 812: 8d 34 c2 lea (%edx,%eax,8),%esi + 815: 39 f1 cmp %esi,%ecx + 817: 75 c6 jne 7df + p->s.size += bp->s.size; + 819: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 81c: 89 15 58 0d 00 00 mov %edx,0xd58 + p->s.size += bp->s.size; + 822: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 825: 8b 4b f8 mov -0x8(%ebx),%ecx + 828: 89 0a mov %ecx,(%edx) +} + 82a: 5b pop %ebx + 82b: 5e pop %esi + 82c: 5f pop %edi + 82d: 5d pop %ebp + 82e: c3 ret + 82f: 90 nop + +00000830 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 830: 55 push %ebp + 831: 89 e5 mov %esp,%ebp + 833: 57 push %edi + 834: 56 push %esi + 835: 53 push %ebx + 836: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 839: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 83c: 8b 3d 58 0d 00 00 mov 0xd58,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 842: 8d 70 07 lea 0x7(%eax),%esi + 845: c1 ee 03 shr $0x3,%esi + 848: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 84b: 85 ff test %edi,%edi + 84d: 0f 84 9d 00 00 00 je 8f0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 853: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 855: 8b 4a 04 mov 0x4(%edx),%ecx + 858: 39 f1 cmp %esi,%ecx + 85a: 73 6a jae 8c6 + 85c: bb 00 10 00 00 mov $0x1000,%ebx + 861: 39 de cmp %ebx,%esi + 863: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 866: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 86d: 89 45 e4 mov %eax,-0x1c(%ebp) + 870: eb 17 jmp 889 + 872: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 878: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 87a: 8b 48 04 mov 0x4(%eax),%ecx + 87d: 39 f1 cmp %esi,%ecx + 87f: 73 4f jae 8d0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 881: 8b 3d 58 0d 00 00 mov 0xd58,%edi + 887: 89 c2 mov %eax,%edx + 889: 39 d7 cmp %edx,%edi + 88b: 75 eb jne 878 + p = sbrk(nu * sizeof(Header)); + 88d: 83 ec 0c sub $0xc,%esp + 890: ff 75 e4 push -0x1c(%ebp) + 893: e8 3b fc ff ff call 4d3 + if (p == (char*)-1) { + 898: 83 c4 10 add $0x10,%esp + 89b: 83 f8 ff cmp $0xffffffff,%eax + 89e: 74 1c je 8bc + hp->s.size = nu; + 8a0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 8a3: 83 ec 0c sub $0xc,%esp + 8a6: 83 c0 08 add $0x8,%eax + 8a9: 50 push %eax + 8aa: e8 f1 fe ff ff call 7a0 + return freep; + 8af: 8b 15 58 0d 00 00 mov 0xd58,%edx + if ((p = morecore(nunits)) == 0) { + 8b5: 83 c4 10 add $0x10,%esp + 8b8: 85 d2 test %edx,%edx + 8ba: 75 bc jne 878 + return 0; + } + } + } +} + 8bc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 8bf: 31 c0 xor %eax,%eax +} + 8c1: 5b pop %ebx + 8c2: 5e pop %esi + 8c3: 5f pop %edi + 8c4: 5d pop %ebp + 8c5: c3 ret + if (p->s.size >= nunits) { + 8c6: 89 d0 mov %edx,%eax + 8c8: 89 fa mov %edi,%edx + 8ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 8d0: 39 ce cmp %ecx,%esi + 8d2: 74 4c je 920 + p->s.size -= nunits; + 8d4: 29 f1 sub %esi,%ecx + 8d6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 8d9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 8dc: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 8df: 89 15 58 0d 00 00 mov %edx,0xd58 +} + 8e5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 8e8: 83 c0 08 add $0x8,%eax +} + 8eb: 5b pop %ebx + 8ec: 5e pop %esi + 8ed: 5f pop %edi + 8ee: 5d pop %ebp + 8ef: c3 ret + base.s.ptr = freep = prevp = &base; + 8f0: c7 05 58 0d 00 00 5c movl $0xd5c,0xd58 + 8f7: 0d 00 00 + base.s.size = 0; + 8fa: bf 5c 0d 00 00 mov $0xd5c,%edi + base.s.ptr = freep = prevp = &base; + 8ff: c7 05 5c 0d 00 00 5c movl $0xd5c,0xd5c + 906: 0d 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 909: 89 fa mov %edi,%edx + base.s.size = 0; + 90b: c7 05 60 0d 00 00 00 movl $0x0,0xd60 + 912: 00 00 00 + if (p->s.size >= nunits) { + 915: e9 42 ff ff ff jmp 85c + 91a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 920: 8b 08 mov (%eax),%ecx + 922: 89 0a mov %ecx,(%edx) + 924: eb b9 jmp 8df diff --git a/screen.c b/screen.c index 02c08c0..8c2bdea 100644 --- a/screen.c +++ b/screen.c @@ -93,8 +93,8 @@ int main(int argc, char *argv[]) { } if (pid == 0) { if (screen(title, bgcol) != 0) - { - exec("sh", argv); + { + exec("sh", argv); printf(1, "screen: exec sh failed\n"); } else diff --git a/screen.d b/screen.d new file mode 100644 index 0000000..38dc977 --- /dev/null +++ b/screen.d @@ -0,0 +1 @@ +screen.o: screen.c /usr/include/stdc-predef.h types.h user.h diff --git a/screen.o b/screen.o new file mode 100644 index 0000000..b10f042 Binary files /dev/null and b/screen.o differ diff --git a/screen.sym b/screen.sym new file mode 100644 index 0000000..e9a8a07 --- /dev/null +++ b/screen.sym @@ -0,0 +1,51 @@ +00000000 screen.c +00000a20 CSWTCH.6 +00000000 ulib.c +00000000 printf.c +00000550 printint +00000aa4 digits.0 +00000000 umalloc.c +00000d58 freep +00000d5c base +00000230 strcpy +00000600 printf +0000052b greeting +00000450 memmove +000004fb mknod +00000350 gets +000004cb getpid +0000053b screen +00000830 malloc +000004db sleep +00000493 pipe +00000523 getch +000004f3 write +000004b3 fstat +000004a3 kill +000004bb chdir +000004ab exec +0000048b wait +0000049b read +00000503 unlink +0000047b fork +000004d3 sbrk +000004e3 uptime +00000d58 __bss_start +000002f0 memset +00000000 main +00000260 strcmp +00000533 shutdown +000004c3 dup +000003c0 stat +00000d58 _edata +00000d64 _end +0000050b link +00000483 exit +00000410 atoi +00000543 cls +000002c0 strlen +000004eb open +00000310 strchr +00000513 mkdir +0000051b close +000007a0 free diff --git a/sh.asm b/sh.asm new file mode 100644 index 0000000..5e936e9 --- /dev/null +++ b/sh.asm @@ -0,0 +1,2727 @@ + +_sh: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + return -1; + } + return 0; +} + +int main(void) { + 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: 51 push %ecx + e: 83 ec 04 sub $0x4,%esp + static char buf[100]; + int fd; + + // Ensure that three file descriptors are open. + while ((fd = open("console", O_RDWR)) >= 0) { + 11: eb 0e jmp 21 + 13: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 17: 90 nop + if (fd >= 3) { + 18: 83 f8 02 cmp $0x2,%eax + 1b: 0f 8f 01 01 00 00 jg 122 + while ((fd = open("console", O_RDWR)) >= 0) { + 21: 83 ec 08 sub $0x8,%esp + 24: 6a 02 push $0x2 + 26: 68 99 13 00 00 push $0x1399 + 2b: e8 8b 0e 00 00 call ebb + 30: 83 c4 10 add $0x10,%esp + 33: 85 c0 test %eax,%eax + 35: 79 e1 jns 18 + 37: eb 33 jmp 6c + 39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + // Read and run input commands. + while (getcmd(buf, sizeof(buf)) >= 0) { + if (buf[0] == 'e' && buf[1] == 'x' && buf[2] == 'i' && buf[3] == 't') { + exit(); + } + if (buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' ') { + 40: 3c 63 cmp $0x63,%al + 42: 75 0d jne 51 + 44: 80 3d 41 1a 00 00 64 cmpb $0x64,0x1a41 + 4b: 0f 84 7f 00 00 00 je d0 +} + +int fork1(void) { + int pid; + + pid = fork(); + 51: e8 f5 0d 00 00 call e4b + if (pid == -1) { + 56: 83 f8 ff cmp $0xffffffff,%eax + 59: 0f 84 e9 00 00 00 je 148 + if (fork1() == 0) { + 5f: 85 c0 test %eax,%eax + 61: 0f 84 cc 00 00 00 je 133 + wait(); + 67: e8 ef 0d 00 00 call e5b + printf(2, "$ "); + 6c: 83 ec 08 sub $0x8,%esp + 6f: 68 f8 12 00 00 push $0x12f8 + 74: 6a 02 push $0x2 + 76: e8 55 0f 00 00 call fd0 + memset(buf, 0, nbuf); + 7b: 83 c4 0c add $0xc,%esp + 7e: 6a 64 push $0x64 + 80: 6a 00 push $0x0 + 82: 68 40 1a 00 00 push $0x1a40 + 87: e8 34 0c 00 00 call cc0 + gets(buf, nbuf); + 8c: 58 pop %eax + 8d: 5a pop %edx + 8e: 6a 64 push $0x64 + 90: 68 40 1a 00 00 push $0x1a40 + 95: e8 86 0c 00 00 call d20 + if (buf[0] == 0) { // EOF + 9a: 0f b6 05 40 1a 00 00 movzbl 0x1a40,%eax + a1: 83 c4 10 add $0x10,%esp + a4: 84 c0 test %al,%al + a6: 74 1f je c7 + if (buf[0] == 'e' && buf[1] == 'x' && buf[2] == 'i' && buf[3] == 't') { + a8: 3c 65 cmp $0x65,%al + aa: 75 94 jne 40 + ac: 80 3d 41 1a 00 00 78 cmpb $0x78,0x1a41 + b3: 75 9c jne 51 + b5: 80 3d 42 1a 00 00 69 cmpb $0x69,0x1a42 + bc: 75 93 jne 51 + be: 80 3d 43 1a 00 00 74 cmpb $0x74,0x1a43 + c5: 75 8a jne 51 + exit(); + c7: e8 87 0d 00 00 call e53 + cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' ') { + d0: 80 3d 42 1a 00 00 20 cmpb $0x20,0x1a42 + d7: 0f 85 74 ff ff ff jne 51 + buf[strlen(buf) - 1] = 0; // chop \n + dd: 83 ec 0c sub $0xc,%esp + e0: 68 40 1a 00 00 push $0x1a40 + e5: e8 a6 0b 00 00 call c90 + if (chdir(buf + 3) < 0) { + ea: c7 04 24 43 1a 00 00 movl $0x1a43,(%esp) + buf[strlen(buf) - 1] = 0; // chop \n + f1: c6 80 3f 1a 00 00 00 movb $0x0,0x1a3f(%eax) + if (chdir(buf + 3) < 0) { + f8: e8 8e 0d 00 00 call e8b + fd: 83 c4 10 add $0x10,%esp + 100: 85 c0 test %eax,%eax + 102: 0f 89 64 ff ff ff jns 6c + printf(2, "cannot cd %s\n", buf + 3); + 108: 51 push %ecx + 109: 68 43 1a 00 00 push $0x1a43 + 10e: 68 a1 13 00 00 push $0x13a1 + 113: 6a 02 push $0x2 + 115: e8 b6 0e 00 00 call fd0 + 11a: 83 c4 10 add $0x10,%esp + 11d: e9 4a ff ff ff jmp 6c + close(fd); + 122: 83 ec 0c sub $0xc,%esp + 125: 50 push %eax + 126: e8 c0 0d 00 00 call eeb + break; + 12b: 83 c4 10 add $0x10,%esp + 12e: e9 39 ff ff ff jmp 6c + runcmd(parsecmd(buf)); + 133: 83 ec 0c sub $0xc,%esp + 136: 68 40 1a 00 00 push $0x1a40 + 13b: e8 50 0a 00 00 call b90 + 140: 89 04 24 mov %eax,(%esp) + 143: e8 98 00 00 00 call 1e0 + panic("fork"); + 148: 83 ec 0c sub $0xc,%esp + 14b: 68 fb 12 00 00 push $0x12fb + 150: e8 4b 00 00 00 call 1a0 + 155: 66 90 xchg %ax,%ax + 157: 66 90 xchg %ax,%ax + 159: 66 90 xchg %ax,%ax + 15b: 66 90 xchg %ax,%ax + 15d: 66 90 xchg %ax,%ax + 15f: 90 nop + +00000160 : +int getcmd(char *buf, int nbuf) { + 160: 55 push %ebp + 161: 89 e5 mov %esp,%ebp + 163: 56 push %esi + 164: 53 push %ebx + 165: 8b 75 0c mov 0xc(%ebp),%esi + 168: 8b 5d 08 mov 0x8(%ebp),%ebx + printf(2, "$ "); + 16b: 83 ec 08 sub $0x8,%esp + 16e: 68 f8 12 00 00 push $0x12f8 + 173: 6a 02 push $0x2 + 175: e8 56 0e 00 00 call fd0 + memset(buf, 0, nbuf); + 17a: 83 c4 0c add $0xc,%esp + 17d: 56 push %esi + 17e: 6a 00 push $0x0 + 180: 53 push %ebx + 181: e8 3a 0b 00 00 call cc0 + gets(buf, nbuf); + 186: 58 pop %eax + 187: 5a pop %edx + 188: 56 push %esi + 189: 53 push %ebx + 18a: e8 91 0b 00 00 call d20 + if (buf[0] == 0) { // EOF + 18f: 83 c4 10 add $0x10,%esp + 192: 80 3b 01 cmpb $0x1,(%ebx) + 195: 19 c0 sbb %eax,%eax +} + 197: 8d 65 f8 lea -0x8(%ebp),%esp + 19a: 5b pop %ebx + 19b: 5e pop %esi + 19c: 5d pop %ebp + 19d: c3 ret + 19e: 66 90 xchg %ax,%ax + +000001a0 : +void panic(char *s) { + 1a0: 55 push %ebp + 1a1: 89 e5 mov %esp,%ebp + 1a3: 83 ec 0c sub $0xc,%esp + printf(2, "%s\n", s); + 1a6: ff 75 08 push 0x8(%ebp) + 1a9: 68 95 13 00 00 push $0x1395 + 1ae: 6a 02 push $0x2 + 1b0: e8 1b 0e 00 00 call fd0 + exit(); + 1b5: e8 99 0c 00 00 call e53 + 1ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000001c0 : +int fork1(void) { + 1c0: 55 push %ebp + 1c1: 89 e5 mov %esp,%ebp + 1c3: 83 ec 08 sub $0x8,%esp + pid = fork(); + 1c6: e8 80 0c 00 00 call e4b + if (pid == -1) { + 1cb: 83 f8 ff cmp $0xffffffff,%eax + 1ce: 74 02 je 1d2 + } + return pid; +} + 1d0: c9 leave + 1d1: c3 ret + panic("fork"); + 1d2: 83 ec 0c sub $0xc,%esp + 1d5: 68 fb 12 00 00 push $0x12fb + 1da: e8 c1 ff ff ff call 1a0 + 1df: 90 nop + +000001e0 : +void runcmd(struct cmd *cmd) { + 1e0: 55 push %ebp + 1e1: 89 e5 mov %esp,%ebp + 1e3: 53 push %ebx + 1e4: 83 ec 14 sub $0x14,%esp + 1e7: 8b 5d 08 mov 0x8(%ebp),%ebx + if (cmd == 0) { + 1ea: 85 db test %ebx,%ebx + 1ec: 74 42 je 230 + switch (cmd->type) { + 1ee: 83 3b 05 cmpl $0x5,(%ebx) + 1f1: 0f 87 e3 00 00 00 ja 2da + 1f7: 8b 03 mov (%ebx),%eax + 1f9: ff 24 85 b0 13 00 00 jmp *0x13b0(,%eax,4) + if (ecmd->argv[0] == 0) { + 200: 8b 43 04 mov 0x4(%ebx),%eax + 203: 85 c0 test %eax,%eax + 205: 74 29 je 230 + exec(ecmd->argv[0], ecmd->argv); + 207: 8d 53 04 lea 0x4(%ebx),%edx + 20a: 51 push %ecx + 20b: 51 push %ecx + 20c: 52 push %edx + 20d: 50 push %eax + 20e: e8 68 0c 00 00 call e7b + printf(2, "exec %s failed\n", ecmd->argv[0]); + 213: 83 c4 0c add $0xc,%esp + 216: ff 73 04 push 0x4(%ebx) + 219: 68 07 13 00 00 push $0x1307 + 21e: 6a 02 push $0x2 + 220: e8 ab 0d 00 00 call fd0 + break; + 225: 83 c4 10 add $0x10,%esp + 228: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 22f: 90 nop + exit(); + 230: e8 1e 0c 00 00 call e53 + if (fork1() == 0) { + 235: e8 86 ff ff ff call 1c0 + 23a: 85 c0 test %eax,%eax + 23c: 75 f2 jne 230 + 23e: e9 8c 00 00 00 jmp 2cf + if (pipe(p) < 0) { + 243: 83 ec 0c sub $0xc,%esp + 246: 8d 45 f0 lea -0x10(%ebp),%eax + 249: 50 push %eax + 24a: e8 14 0c 00 00 call e63 + 24f: 83 c4 10 add $0x10,%esp + 252: 85 c0 test %eax,%eax + 254: 0f 88 a2 00 00 00 js 2fc + if (fork1() == 0) { + 25a: e8 61 ff ff ff call 1c0 + 25f: 85 c0 test %eax,%eax + 261: 0f 84 a2 00 00 00 je 309 + if (fork1() == 0) { + 267: e8 54 ff ff ff call 1c0 + 26c: 85 c0 test %eax,%eax + 26e: 0f 84 c3 00 00 00 je 337 + close(p[0]); + 274: 83 ec 0c sub $0xc,%esp + 277: ff 75 f0 push -0x10(%ebp) + 27a: e8 6c 0c 00 00 call eeb + close(p[1]); + 27f: 58 pop %eax + 280: ff 75 f4 push -0xc(%ebp) + 283: e8 63 0c 00 00 call eeb + wait(); + 288: e8 ce 0b 00 00 call e5b + wait(); + 28d: e8 c9 0b 00 00 call e5b + break; + 292: 83 c4 10 add $0x10,%esp + 295: eb 99 jmp 230 + if (fork1() == 0) { + 297: e8 24 ff ff ff call 1c0 + 29c: 85 c0 test %eax,%eax + 29e: 74 2f je 2cf + wait(); + 2a0: e8 b6 0b 00 00 call e5b + runcmd(lcmd->right); + 2a5: 83 ec 0c sub $0xc,%esp + 2a8: ff 73 08 push 0x8(%ebx) + 2ab: e8 30 ff ff ff call 1e0 + close(rcmd->fd); + 2b0: 83 ec 0c sub $0xc,%esp + 2b3: ff 73 14 push 0x14(%ebx) + 2b6: e8 30 0c 00 00 call eeb + if (open(rcmd->file, rcmd->mode) < 0) { + 2bb: 58 pop %eax + 2bc: 5a pop %edx + 2bd: ff 73 10 push 0x10(%ebx) + 2c0: ff 73 08 push 0x8(%ebx) + 2c3: e8 f3 0b 00 00 call ebb + 2c8: 83 c4 10 add $0x10,%esp + 2cb: 85 c0 test %eax,%eax + 2cd: 78 18 js 2e7 + runcmd(bcmd->cmd); + 2cf: 83 ec 0c sub $0xc,%esp + 2d2: ff 73 04 push 0x4(%ebx) + 2d5: e8 06 ff ff ff call 1e0 + panic("runcmd"); + 2da: 83 ec 0c sub $0xc,%esp + 2dd: 68 00 13 00 00 push $0x1300 + 2e2: e8 b9 fe ff ff call 1a0 + printf(2, "open %s failed\n", rcmd->file); + 2e7: 51 push %ecx + 2e8: ff 73 08 push 0x8(%ebx) + 2eb: 68 17 13 00 00 push $0x1317 + 2f0: 6a 02 push $0x2 + 2f2: e8 d9 0c 00 00 call fd0 + exit(); + 2f7: e8 57 0b 00 00 call e53 + panic("pipe"); + 2fc: 83 ec 0c sub $0xc,%esp + 2ff: 68 27 13 00 00 push $0x1327 + 304: e8 97 fe ff ff call 1a0 + close(1); + 309: 83 ec 0c sub $0xc,%esp + 30c: 6a 01 push $0x1 + 30e: e8 d8 0b 00 00 call eeb + dup(p[1]); + 313: 58 pop %eax + 314: ff 75 f4 push -0xc(%ebp) + 317: e8 77 0b 00 00 call e93 + close(p[0]); + 31c: 58 pop %eax + 31d: ff 75 f0 push -0x10(%ebp) + 320: e8 c6 0b 00 00 call eeb + close(p[1]); + 325: 58 pop %eax + 326: ff 75 f4 push -0xc(%ebp) + 329: e8 bd 0b 00 00 call eeb + runcmd(pcmd->left); + 32e: 5a pop %edx + 32f: ff 73 04 push 0x4(%ebx) + 332: e8 a9 fe ff ff call 1e0 + close(0); + 337: 83 ec 0c sub $0xc,%esp + 33a: 6a 00 push $0x0 + 33c: e8 aa 0b 00 00 call eeb + dup(p[0]); + 341: 5a pop %edx + 342: ff 75 f0 push -0x10(%ebp) + 345: e8 49 0b 00 00 call e93 + close(p[0]); + 34a: 59 pop %ecx + 34b: ff 75 f0 push -0x10(%ebp) + 34e: e8 98 0b 00 00 call eeb + close(p[1]); + 353: 58 pop %eax + 354: ff 75 f4 push -0xc(%ebp) + 357: e8 8f 0b 00 00 call eeb + runcmd(pcmd->right); + 35c: 58 pop %eax + 35d: ff 73 08 push 0x8(%ebx) + 360: e8 7b fe ff ff call 1e0 + 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 : + + +// Constructors + +struct cmd* execcmd(void) { + 370: 55 push %ebp + 371: 89 e5 mov %esp,%ebp + 373: 53 push %ebx + 374: 83 ec 10 sub $0x10,%esp + struct execcmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 377: 6a 54 push $0x54 + 379: e8 82 0e 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 37e: 83 c4 0c add $0xc,%esp + 381: 6a 54 push $0x54 + cmd = malloc(sizeof(*cmd)); + 383: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 385: 6a 00 push $0x0 + 387: 50 push %eax + 388: e8 33 09 00 00 call cc0 + cmd->type = EXEC; + 38d: c7 03 01 00 00 00 movl $0x1,(%ebx) + return (struct cmd*)cmd; +} + 393: 89 d8 mov %ebx,%eax + 395: 8b 5d fc mov -0x4(%ebp),%ebx + 398: c9 leave + 399: c3 ret + 39a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000003a0 : + +struct cmd* redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd) { + 3a0: 55 push %ebp + 3a1: 89 e5 mov %esp,%ebp + 3a3: 53 push %ebx + 3a4: 83 ec 10 sub $0x10,%esp + struct redircmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 3a7: 6a 18 push $0x18 + 3a9: e8 52 0e 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 3ae: 83 c4 0c add $0xc,%esp + 3b1: 6a 18 push $0x18 + cmd = malloc(sizeof(*cmd)); + 3b3: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 3b5: 6a 00 push $0x0 + 3b7: 50 push %eax + 3b8: e8 03 09 00 00 call cc0 + cmd->type = REDIR; + cmd->cmd = subcmd; + 3bd: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = REDIR; + 3c0: c7 03 02 00 00 00 movl $0x2,(%ebx) + cmd->cmd = subcmd; + 3c6: 89 43 04 mov %eax,0x4(%ebx) + cmd->file = file; + 3c9: 8b 45 0c mov 0xc(%ebp),%eax + 3cc: 89 43 08 mov %eax,0x8(%ebx) + cmd->efile = efile; + 3cf: 8b 45 10 mov 0x10(%ebp),%eax + 3d2: 89 43 0c mov %eax,0xc(%ebx) + cmd->mode = mode; + 3d5: 8b 45 14 mov 0x14(%ebp),%eax + 3d8: 89 43 10 mov %eax,0x10(%ebx) + cmd->fd = fd; + 3db: 8b 45 18 mov 0x18(%ebp),%eax + 3de: 89 43 14 mov %eax,0x14(%ebx) + return (struct cmd*)cmd; +} + 3e1: 89 d8 mov %ebx,%eax + 3e3: 8b 5d fc mov -0x4(%ebp),%ebx + 3e6: c9 leave + 3e7: c3 ret + 3e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3ef: 90 nop + +000003f0 : + +struct cmd* pipecmd(struct cmd *left, struct cmd *right) { + 3f0: 55 push %ebp + 3f1: 89 e5 mov %esp,%ebp + 3f3: 53 push %ebx + 3f4: 83 ec 10 sub $0x10,%esp + struct pipecmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 3f7: 6a 0c push $0xc + 3f9: e8 02 0e 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 3fe: 83 c4 0c add $0xc,%esp + 401: 6a 0c push $0xc + cmd = malloc(sizeof(*cmd)); + 403: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 405: 6a 00 push $0x0 + 407: 50 push %eax + 408: e8 b3 08 00 00 call cc0 + cmd->type = PIPE; + cmd->left = left; + 40d: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = PIPE; + 410: c7 03 03 00 00 00 movl $0x3,(%ebx) + cmd->left = left; + 416: 89 43 04 mov %eax,0x4(%ebx) + cmd->right = right; + 419: 8b 45 0c mov 0xc(%ebp),%eax + 41c: 89 43 08 mov %eax,0x8(%ebx) + return (struct cmd*)cmd; +} + 41f: 89 d8 mov %ebx,%eax + 421: 8b 5d fc mov -0x4(%ebp),%ebx + 424: c9 leave + 425: c3 ret + 426: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 42d: 8d 76 00 lea 0x0(%esi),%esi + +00000430 : + +struct cmd* listcmd(struct cmd *left, struct cmd *right) { + 430: 55 push %ebp + 431: 89 e5 mov %esp,%ebp + 433: 53 push %ebx + 434: 83 ec 10 sub $0x10,%esp + struct listcmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 437: 6a 0c push $0xc + 439: e8 c2 0d 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 43e: 83 c4 0c add $0xc,%esp + 441: 6a 0c push $0xc + cmd = malloc(sizeof(*cmd)); + 443: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 445: 6a 00 push $0x0 + 447: 50 push %eax + 448: e8 73 08 00 00 call cc0 + cmd->type = LIST; + cmd->left = left; + 44d: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = LIST; + 450: c7 03 04 00 00 00 movl $0x4,(%ebx) + cmd->left = left; + 456: 89 43 04 mov %eax,0x4(%ebx) + cmd->right = right; + 459: 8b 45 0c mov 0xc(%ebp),%eax + 45c: 89 43 08 mov %eax,0x8(%ebx) + return (struct cmd*)cmd; +} + 45f: 89 d8 mov %ebx,%eax + 461: 8b 5d fc mov -0x4(%ebp),%ebx + 464: c9 leave + 465: c3 ret + 466: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 46d: 8d 76 00 lea 0x0(%esi),%esi + +00000470 : + +struct cmd* backcmd(struct cmd *subcmd) { + 470: 55 push %ebp + 471: 89 e5 mov %esp,%ebp + 473: 53 push %ebx + 474: 83 ec 10 sub $0x10,%esp + struct backcmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 477: 6a 08 push $0x8 + 479: e8 82 0d 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 47e: 83 c4 0c add $0xc,%esp + 481: 6a 08 push $0x8 + cmd = malloc(sizeof(*cmd)); + 483: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 485: 6a 00 push $0x0 + 487: 50 push %eax + 488: e8 33 08 00 00 call cc0 + cmd->type = BACK; + cmd->cmd = subcmd; + 48d: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = BACK; + 490: c7 03 05 00 00 00 movl $0x5,(%ebx) + cmd->cmd = subcmd; + 496: 89 43 04 mov %eax,0x4(%ebx) + return (struct cmd*)cmd; +} + 499: 89 d8 mov %ebx,%eax + 49b: 8b 5d fc mov -0x4(%ebp),%ebx + 49e: c9 leave + 49f: c3 ret + +000004a0 : +// Parsing + +char whitespace[] = " \t\r\n\v"; +char symbols[] = "<|>&;()"; + +int gettoken(char **ps, char *es, char **q, char **eq) { + 4a0: 55 push %ebp + 4a1: 89 e5 mov %esp,%ebp + 4a3: 57 push %edi + 4a4: 56 push %esi + 4a5: 53 push %ebx + 4a6: 83 ec 0c sub $0xc,%esp + char *s; + int ret; + + s = *ps; + 4a9: 8b 45 08 mov 0x8(%ebp),%eax +int gettoken(char **ps, char *es, char **q, char **eq) { + 4ac: 8b 5d 0c mov 0xc(%ebp),%ebx + 4af: 8b 75 10 mov 0x10(%ebp),%esi + s = *ps; + 4b2: 8b 38 mov (%eax),%edi + while (s < es && strchr(whitespace, *s)) { + 4b4: 39 df cmp %ebx,%edi + 4b6: 72 0f jb 4c7 + 4b8: eb 25 jmp 4df + 4ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + s++; + 4c0: 83 c7 01 add $0x1,%edi + while (s < es && strchr(whitespace, *s)) { + 4c3: 39 fb cmp %edi,%ebx + 4c5: 74 18 je 4df + 4c7: 0f be 07 movsbl (%edi),%eax + 4ca: 83 ec 08 sub $0x8,%esp + 4cd: 50 push %eax + 4ce: 68 1c 1a 00 00 push $0x1a1c + 4d3: e8 08 08 00 00 call ce0 + 4d8: 83 c4 10 add $0x10,%esp + 4db: 85 c0 test %eax,%eax + 4dd: 75 e1 jne 4c0 + } + if (q) { + 4df: 85 f6 test %esi,%esi + 4e1: 74 02 je 4e5 + *q = s; + 4e3: 89 3e mov %edi,(%esi) + } + ret = *s; + 4e5: 0f b6 07 movzbl (%edi),%eax + switch (*s) { + 4e8: 3c 3c cmp $0x3c,%al + 4ea: 0f 8f d0 00 00 00 jg 5c0 + 4f0: 3c 3a cmp $0x3a,%al + 4f2: 0f 8f b4 00 00 00 jg 5ac + 4f8: 84 c0 test %al,%al + 4fa: 75 44 jne 540 + 4fc: 31 f6 xor %esi,%esi + while (s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) { + s++; + } + break; + } + if (eq) { + 4fe: 8b 55 14 mov 0x14(%ebp),%edx + 501: 85 d2 test %edx,%edx + 503: 74 05 je 50a + *eq = s; + 505: 8b 45 14 mov 0x14(%ebp),%eax + 508: 89 38 mov %edi,(%eax) + } + + while (s < es && strchr(whitespace, *s)) { + 50a: 39 df cmp %ebx,%edi + 50c: 72 09 jb 517 + 50e: eb 1f jmp 52f + s++; + 510: 83 c7 01 add $0x1,%edi + while (s < es && strchr(whitespace, *s)) { + 513: 39 fb cmp %edi,%ebx + 515: 74 18 je 52f + 517: 0f be 07 movsbl (%edi),%eax + 51a: 83 ec 08 sub $0x8,%esp + 51d: 50 push %eax + 51e: 68 1c 1a 00 00 push $0x1a1c + 523: e8 b8 07 00 00 call ce0 + 528: 83 c4 10 add $0x10,%esp + 52b: 85 c0 test %eax,%eax + 52d: 75 e1 jne 510 + } + *ps = s; + 52f: 8b 45 08 mov 0x8(%ebp),%eax + 532: 89 38 mov %edi,(%eax) + return ret; +} + 534: 8d 65 f4 lea -0xc(%ebp),%esp + 537: 89 f0 mov %esi,%eax + 539: 5b pop %ebx + 53a: 5e pop %esi + 53b: 5f pop %edi + 53c: 5d pop %ebp + 53d: c3 ret + 53e: 66 90 xchg %ax,%ax + switch (*s) { + 540: 79 5e jns 5a0 + while (s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) { + 542: 39 fb cmp %edi,%ebx + 544: 77 34 ja 57a + if (eq) { + 546: 8b 45 14 mov 0x14(%ebp),%eax + 549: be 61 00 00 00 mov $0x61,%esi + 54e: 85 c0 test %eax,%eax + 550: 75 b3 jne 505 + 552: eb db jmp 52f + 554: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while (s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) { + 558: 0f be 07 movsbl (%edi),%eax + 55b: 83 ec 08 sub $0x8,%esp + 55e: 50 push %eax + 55f: 68 14 1a 00 00 push $0x1a14 + 564: e8 77 07 00 00 call ce0 + 569: 83 c4 10 add $0x10,%esp + 56c: 85 c0 test %eax,%eax + 56e: 75 22 jne 592 + s++; + 570: 83 c7 01 add $0x1,%edi + while (s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) { + 573: 39 fb cmp %edi,%ebx + 575: 74 cf je 546 + 577: 0f b6 07 movzbl (%edi),%eax + 57a: 83 ec 08 sub $0x8,%esp + 57d: 0f be f0 movsbl %al,%esi + 580: 56 push %esi + 581: 68 1c 1a 00 00 push $0x1a1c + 586: e8 55 07 00 00 call ce0 + 58b: 83 c4 10 add $0x10,%esp + 58e: 85 c0 test %eax,%eax + 590: 74 c6 je 558 + ret = 'a'; + 592: be 61 00 00 00 mov $0x61,%esi + 597: e9 62 ff ff ff jmp 4fe + 59c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + switch (*s) { + 5a0: 3c 26 cmp $0x26,%al + 5a2: 74 08 je 5ac + 5a4: 8d 48 d8 lea -0x28(%eax),%ecx + 5a7: 80 f9 01 cmp $0x1,%cl + 5aa: 77 96 ja 542 + ret = *s; + 5ac: 0f be f0 movsbl %al,%esi + s++; + 5af: 83 c7 01 add $0x1,%edi + break; + 5b2: e9 47 ff ff ff jmp 4fe + 5b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5be: 66 90 xchg %ax,%ax + switch (*s) { + 5c0: 3c 3e cmp $0x3e,%al + 5c2: 75 1c jne 5e0 + if (*s == '>') { + 5c4: 80 7f 01 3e cmpb $0x3e,0x1(%edi) + s++; + 5c8: 8d 47 01 lea 0x1(%edi),%eax + if (*s == '>') { + 5cb: 74 1c je 5e9 + s++; + 5cd: 89 c7 mov %eax,%edi + 5cf: be 3e 00 00 00 mov $0x3e,%esi + 5d4: e9 25 ff ff ff jmp 4fe + 5d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + switch (*s) { + 5e0: 3c 7c cmp $0x7c,%al + 5e2: 74 c8 je 5ac + 5e4: e9 59 ff ff ff jmp 542 + s++; + 5e9: 83 c7 02 add $0x2,%edi + ret = '+'; + 5ec: be 2b 00 00 00 mov $0x2b,%esi + 5f1: e9 08 ff ff ff jmp 4fe + 5f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5fd: 8d 76 00 lea 0x0(%esi),%esi + +00000600 : + +int peek(char **ps, char *es, char *toks) { + 600: 55 push %ebp + 601: 89 e5 mov %esp,%ebp + 603: 57 push %edi + 604: 56 push %esi + 605: 53 push %ebx + 606: 83 ec 0c sub $0xc,%esp + 609: 8b 7d 08 mov 0x8(%ebp),%edi + 60c: 8b 75 0c mov 0xc(%ebp),%esi + char *s; + + s = *ps; + 60f: 8b 1f mov (%edi),%ebx + while (s < es && strchr(whitespace, *s)) { + 611: 39 f3 cmp %esi,%ebx + 613: 72 12 jb 627 + 615: eb 28 jmp 63f + 617: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 61e: 66 90 xchg %ax,%ax + s++; + 620: 83 c3 01 add $0x1,%ebx + while (s < es && strchr(whitespace, *s)) { + 623: 39 de cmp %ebx,%esi + 625: 74 18 je 63f + 627: 0f be 03 movsbl (%ebx),%eax + 62a: 83 ec 08 sub $0x8,%esp + 62d: 50 push %eax + 62e: 68 1c 1a 00 00 push $0x1a1c + 633: e8 a8 06 00 00 call ce0 + 638: 83 c4 10 add $0x10,%esp + 63b: 85 c0 test %eax,%eax + 63d: 75 e1 jne 620 + } + *ps = s; + 63f: 89 1f mov %ebx,(%edi) + return *s && strchr(toks, *s); + 641: 0f be 03 movsbl (%ebx),%eax + 644: 31 d2 xor %edx,%edx + 646: 84 c0 test %al,%al + 648: 75 0e jne 658 +} + 64a: 8d 65 f4 lea -0xc(%ebp),%esp + 64d: 89 d0 mov %edx,%eax + 64f: 5b pop %ebx + 650: 5e pop %esi + 651: 5f pop %edi + 652: 5d pop %ebp + 653: c3 ret + 654: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return *s && strchr(toks, *s); + 658: 83 ec 08 sub $0x8,%esp + 65b: 50 push %eax + 65c: ff 75 10 push 0x10(%ebp) + 65f: e8 7c 06 00 00 call ce0 + 664: 83 c4 10 add $0x10,%esp + 667: 31 d2 xor %edx,%edx + 669: 85 c0 test %eax,%eax + 66b: 0f 95 c2 setne %dl +} + 66e: 8d 65 f4 lea -0xc(%ebp),%esp + 671: 5b pop %ebx + 672: 89 d0 mov %edx,%eax + 674: 5e pop %esi + 675: 5f pop %edi + 676: 5d pop %ebp + 677: c3 ret + 678: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 67f: 90 nop + +00000680 : + cmd = pipecmd(cmd, parsepipe(ps, es)); + } + return cmd; +} + +struct cmd* parseredirs(struct cmd *cmd, char **ps, char *es) { + 680: 55 push %ebp + 681: 89 e5 mov %esp,%ebp + 683: 57 push %edi + 684: 56 push %esi + 685: 53 push %ebx + 686: 83 ec 2c sub $0x2c,%esp + 689: 8b 75 0c mov 0xc(%ebp),%esi + 68c: 8b 5d 10 mov 0x10(%ebp),%ebx + int tok; + char *q, *eq; + + while (peek(ps, es, "<>")) { + 68f: 90 nop + 690: 83 ec 04 sub $0x4,%esp + 693: 68 49 13 00 00 push $0x1349 + 698: 53 push %ebx + 699: 56 push %esi + 69a: e8 61 ff ff ff call 600 + 69f: 83 c4 10 add $0x10,%esp + 6a2: 85 c0 test %eax,%eax + 6a4: 0f 84 f6 00 00 00 je 7a0 + tok = gettoken(ps, es, 0, 0); + 6aa: 6a 00 push $0x0 + 6ac: 6a 00 push $0x0 + 6ae: 53 push %ebx + 6af: 56 push %esi + 6b0: e8 eb fd ff ff call 4a0 + 6b5: 89 c7 mov %eax,%edi + if (gettoken(ps, es, &q, &eq) != 'a') { + 6b7: 8d 45 e4 lea -0x1c(%ebp),%eax + 6ba: 50 push %eax + 6bb: 8d 45 e0 lea -0x20(%ebp),%eax + 6be: 50 push %eax + 6bf: 53 push %ebx + 6c0: 56 push %esi + 6c1: e8 da fd ff ff call 4a0 + 6c6: 83 c4 20 add $0x20,%esp + 6c9: 83 f8 61 cmp $0x61,%eax + 6cc: 0f 85 d9 00 00 00 jne 7ab + panic("missing file for redirection"); + } + switch (tok) { + 6d2: 83 ff 3c cmp $0x3c,%edi + 6d5: 74 69 je 740 + 6d7: 83 ff 3e cmp $0x3e,%edi + 6da: 74 05 je 6e1 + 6dc: 83 ff 2b cmp $0x2b,%edi + 6df: 75 af jne 690 + cmd = malloc(sizeof(*cmd)); + 6e1: 83 ec 0c sub $0xc,%esp + break; + case '>': + cmd = redircmd(cmd, q, eq, O_WRONLY | O_CREATE, 1); + break; + case '+': // >> + cmd = redircmd(cmd, q, eq, O_WRONLY | O_CREATE, 1); + 6e4: 8b 55 e4 mov -0x1c(%ebp),%edx + 6e7: 8b 4d e0 mov -0x20(%ebp),%ecx + cmd = malloc(sizeof(*cmd)); + 6ea: 6a 18 push $0x18 + cmd = redircmd(cmd, q, eq, O_WRONLY | O_CREATE, 1); + 6ec: 89 55 d0 mov %edx,-0x30(%ebp) + 6ef: 89 4d d4 mov %ecx,-0x2c(%ebp) + cmd = malloc(sizeof(*cmd)); + 6f2: e8 09 0b 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 6f7: 83 c4 0c add $0xc,%esp + 6fa: 6a 18 push $0x18 + cmd = malloc(sizeof(*cmd)); + 6fc: 89 c7 mov %eax,%edi + memset(cmd, 0, sizeof(*cmd)); + 6fe: 6a 00 push $0x0 + 700: 50 push %eax + 701: e8 ba 05 00 00 call cc0 + cmd->type = REDIR; + 706: c7 07 02 00 00 00 movl $0x2,(%edi) + cmd->cmd = subcmd; + 70c: 8b 45 08 mov 0x8(%ebp),%eax + break; + 70f: 83 c4 10 add $0x10,%esp + cmd->cmd = subcmd; + 712: 89 47 04 mov %eax,0x4(%edi) + cmd->file = file; + 715: 8b 4d d4 mov -0x2c(%ebp),%ecx + 718: 89 4f 08 mov %ecx,0x8(%edi) + cmd->efile = efile; + 71b: 8b 55 d0 mov -0x30(%ebp),%edx + cmd->mode = mode; + 71e: c7 47 10 01 02 00 00 movl $0x201,0x10(%edi) + cmd->efile = efile; + 725: 89 57 0c mov %edx,0xc(%edi) + cmd->fd = fd; + 728: c7 47 14 01 00 00 00 movl $0x1,0x14(%edi) + break; + 72f: 89 7d 08 mov %edi,0x8(%ebp) + 732: e9 59 ff ff ff jmp 690 + 737: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 73e: 66 90 xchg %ax,%ax + cmd = malloc(sizeof(*cmd)); + 740: 83 ec 0c sub $0xc,%esp + cmd = redircmd(cmd, q, eq, O_RDONLY, 0); + 743: 8b 55 e4 mov -0x1c(%ebp),%edx + 746: 8b 4d e0 mov -0x20(%ebp),%ecx + cmd = malloc(sizeof(*cmd)); + 749: 6a 18 push $0x18 + cmd = redircmd(cmd, q, eq, O_RDONLY, 0); + 74b: 89 55 d0 mov %edx,-0x30(%ebp) + 74e: 89 4d d4 mov %ecx,-0x2c(%ebp) + cmd = malloc(sizeof(*cmd)); + 751: e8 aa 0a 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 756: 83 c4 0c add $0xc,%esp + 759: 6a 18 push $0x18 + cmd = malloc(sizeof(*cmd)); + 75b: 89 c7 mov %eax,%edi + memset(cmd, 0, sizeof(*cmd)); + 75d: 6a 00 push $0x0 + 75f: 50 push %eax + 760: e8 5b 05 00 00 call cc0 + cmd->cmd = subcmd; + 765: 8b 45 08 mov 0x8(%ebp),%eax + cmd->file = file; + 768: 8b 4d d4 mov -0x2c(%ebp),%ecx + break; + 76b: 89 7d 08 mov %edi,0x8(%ebp) + cmd->efile = efile; + 76e: 8b 55 d0 mov -0x30(%ebp),%edx + cmd->type = REDIR; + 771: c7 07 02 00 00 00 movl $0x2,(%edi) + break; + 777: 83 c4 10 add $0x10,%esp + cmd->cmd = subcmd; + 77a: 89 47 04 mov %eax,0x4(%edi) + cmd->file = file; + 77d: 89 4f 08 mov %ecx,0x8(%edi) + cmd->efile = efile; + 780: 89 57 0c mov %edx,0xc(%edi) + cmd->mode = mode; + 783: c7 47 10 00 00 00 00 movl $0x0,0x10(%edi) + cmd->fd = fd; + 78a: c7 47 14 00 00 00 00 movl $0x0,0x14(%edi) + break; + 791: e9 fa fe ff ff jmp 690 + 796: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 79d: 8d 76 00 lea 0x0(%esi),%esi + } + } + return cmd; +} + 7a0: 8b 45 08 mov 0x8(%ebp),%eax + 7a3: 8d 65 f4 lea -0xc(%ebp),%esp + 7a6: 5b pop %ebx + 7a7: 5e pop %esi + 7a8: 5f pop %edi + 7a9: 5d pop %ebp + 7aa: c3 ret + panic("missing file for redirection"); + 7ab: 83 ec 0c sub $0xc,%esp + 7ae: 68 2c 13 00 00 push $0x132c + 7b3: e8 e8 f9 ff ff call 1a0 + 7b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 7bf: 90 nop + +000007c0 : + gettoken(ps, es, 0, 0); + cmd = parseredirs(cmd, ps, es); + return cmd; +} + +struct cmd* parseexec(char **ps, char *es) { + 7c0: 55 push %ebp + 7c1: 89 e5 mov %esp,%ebp + 7c3: 57 push %edi + 7c4: 56 push %esi + 7c5: 53 push %ebx + 7c6: 83 ec 30 sub $0x30,%esp + 7c9: 8b 75 08 mov 0x8(%ebp),%esi + 7cc: 8b 7d 0c mov 0xc(%ebp),%edi + char *q, *eq; + int tok, argc; + struct execcmd *cmd; + struct cmd *ret; + + if (peek(ps, es, "(")) { + 7cf: 68 4c 13 00 00 push $0x134c + 7d4: 57 push %edi + 7d5: 56 push %esi + 7d6: e8 25 fe ff ff call 600 + 7db: 83 c4 10 add $0x10,%esp + 7de: 85 c0 test %eax,%eax + 7e0: 0f 85 aa 00 00 00 jne 890 + cmd = malloc(sizeof(*cmd)); + 7e6: 83 ec 0c sub $0xc,%esp + 7e9: 89 c3 mov %eax,%ebx + 7eb: 6a 54 push $0x54 + 7ed: e8 0e 0a 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 7f2: 83 c4 0c add $0xc,%esp + 7f5: 6a 54 push $0x54 + 7f7: 6a 00 push $0x0 + 7f9: 50 push %eax + 7fa: 89 45 d0 mov %eax,-0x30(%ebp) + 7fd: e8 be 04 00 00 call cc0 + cmd->type = EXEC; + 802: 8b 45 d0 mov -0x30(%ebp),%eax + + ret = execcmd(); + cmd = (struct execcmd*)ret; + + argc = 0; + ret = parseredirs(ret, ps, es); + 805: 83 c4 0c add $0xc,%esp + cmd->type = EXEC; + 808: c7 00 01 00 00 00 movl $0x1,(%eax) + ret = parseredirs(ret, ps, es); + 80e: 57 push %edi + 80f: 56 push %esi + 810: 50 push %eax + 811: e8 6a fe ff ff call 680 + while (!peek(ps, es, "|)&;")) { + 816: 83 c4 10 add $0x10,%esp + ret = parseredirs(ret, ps, es); + 819: 89 45 d4 mov %eax,-0x2c(%ebp) + while (!peek(ps, es, "|)&;")) { + 81c: eb 15 jmp 833 + 81e: 66 90 xchg %ax,%ax + cmd->eargv[argc] = eq; + argc++; + if (argc >= MAXARGS) { + panic("too many args"); + } + ret = parseredirs(ret, ps, es); + 820: 83 ec 04 sub $0x4,%esp + 823: 57 push %edi + 824: 56 push %esi + 825: ff 75 d4 push -0x2c(%ebp) + 828: e8 53 fe ff ff call 680 + 82d: 83 c4 10 add $0x10,%esp + 830: 89 45 d4 mov %eax,-0x2c(%ebp) + while (!peek(ps, es, "|)&;")) { + 833: 83 ec 04 sub $0x4,%esp + 836: 68 63 13 00 00 push $0x1363 + 83b: 57 push %edi + 83c: 56 push %esi + 83d: e8 be fd ff ff call 600 + 842: 83 c4 10 add $0x10,%esp + 845: 85 c0 test %eax,%eax + 847: 75 5f jne 8a8 + if ((tok = gettoken(ps, es, &q, &eq)) == 0) { + 849: 8d 45 e4 lea -0x1c(%ebp),%eax + 84c: 50 push %eax + 84d: 8d 45 e0 lea -0x20(%ebp),%eax + 850: 50 push %eax + 851: 57 push %edi + 852: 56 push %esi + 853: e8 48 fc ff ff call 4a0 + 858: 83 c4 10 add $0x10,%esp + 85b: 85 c0 test %eax,%eax + 85d: 74 49 je 8a8 + if (tok != 'a') { + 85f: 83 f8 61 cmp $0x61,%eax + 862: 75 62 jne 8c6 + cmd->argv[argc] = q; + 864: 8b 45 e0 mov -0x20(%ebp),%eax + 867: 8b 55 d0 mov -0x30(%ebp),%edx + 86a: 89 44 9a 04 mov %eax,0x4(%edx,%ebx,4) + cmd->eargv[argc] = eq; + 86e: 8b 45 e4 mov -0x1c(%ebp),%eax + 871: 89 44 9a 2c mov %eax,0x2c(%edx,%ebx,4) + argc++; + 875: 83 c3 01 add $0x1,%ebx + if (argc >= MAXARGS) { + 878: 83 fb 0a cmp $0xa,%ebx + 87b: 75 a3 jne 820 + panic("too many args"); + 87d: 83 ec 0c sub $0xc,%esp + 880: 68 55 13 00 00 push $0x1355 + 885: e8 16 f9 ff ff call 1a0 + 88a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return parseblock(ps, es); + 890: 89 7d 0c mov %edi,0xc(%ebp) + 893: 89 75 08 mov %esi,0x8(%ebp) + } + cmd->argv[argc] = 0; + cmd->eargv[argc] = 0; + return ret; +} + 896: 8d 65 f4 lea -0xc(%ebp),%esp + 899: 5b pop %ebx + 89a: 5e pop %esi + 89b: 5f pop %edi + 89c: 5d pop %ebp + return parseblock(ps, es); + 89d: e9 ae 01 00 00 jmp a50 + 8a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + cmd->argv[argc] = 0; + 8a8: 8b 45 d0 mov -0x30(%ebp),%eax + 8ab: c7 44 98 04 00 00 00 movl $0x0,0x4(%eax,%ebx,4) + 8b2: 00 + cmd->eargv[argc] = 0; + 8b3: c7 44 98 2c 00 00 00 movl $0x0,0x2c(%eax,%ebx,4) + 8ba: 00 +} + 8bb: 8b 45 d4 mov -0x2c(%ebp),%eax + 8be: 8d 65 f4 lea -0xc(%ebp),%esp + 8c1: 5b pop %ebx + 8c2: 5e pop %esi + 8c3: 5f pop %edi + 8c4: 5d pop %ebp + 8c5: c3 ret + panic("syntax"); + 8c6: 83 ec 0c sub $0xc,%esp + 8c9: 68 4e 13 00 00 push $0x134e + 8ce: e8 cd f8 ff ff call 1a0 + 8d3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 8da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000008e0 : +struct cmd* parsepipe(char **ps, char *es) { + 8e0: 55 push %ebp + 8e1: 89 e5 mov %esp,%ebp + 8e3: 57 push %edi + 8e4: 56 push %esi + 8e5: 53 push %ebx + 8e6: 83 ec 14 sub $0x14,%esp + 8e9: 8b 75 08 mov 0x8(%ebp),%esi + 8ec: 8b 7d 0c mov 0xc(%ebp),%edi + cmd = parseexec(ps, es); + 8ef: 57 push %edi + 8f0: 56 push %esi + 8f1: e8 ca fe ff ff call 7c0 + if (peek(ps, es, "|")) { + 8f6: 83 c4 0c add $0xc,%esp + 8f9: 68 68 13 00 00 push $0x1368 + cmd = parseexec(ps, es); + 8fe: 89 c3 mov %eax,%ebx + if (peek(ps, es, "|")) { + 900: 57 push %edi + 901: 56 push %esi + 902: e8 f9 fc ff ff call 600 + 907: 83 c4 10 add $0x10,%esp + 90a: 85 c0 test %eax,%eax + 90c: 75 12 jne 920 +} + 90e: 8d 65 f4 lea -0xc(%ebp),%esp + 911: 89 d8 mov %ebx,%eax + 913: 5b pop %ebx + 914: 5e pop %esi + 915: 5f pop %edi + 916: 5d pop %ebp + 917: c3 ret + 918: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 91f: 90 nop + gettoken(ps, es, 0, 0); + 920: 6a 00 push $0x0 + 922: 6a 00 push $0x0 + 924: 57 push %edi + 925: 56 push %esi + 926: e8 75 fb ff ff call 4a0 + cmd = pipecmd(cmd, parsepipe(ps, es)); + 92b: 58 pop %eax + 92c: 5a pop %edx + 92d: 57 push %edi + 92e: 56 push %esi + 92f: e8 ac ff ff ff call 8e0 + cmd = malloc(sizeof(*cmd)); + 934: c7 04 24 0c 00 00 00 movl $0xc,(%esp) + cmd = pipecmd(cmd, parsepipe(ps, es)); + 93b: 89 c7 mov %eax,%edi + cmd = malloc(sizeof(*cmd)); + 93d: e8 be 08 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 942: 83 c4 0c add $0xc,%esp + 945: 6a 0c push $0xc + cmd = malloc(sizeof(*cmd)); + 947: 89 c6 mov %eax,%esi + memset(cmd, 0, sizeof(*cmd)); + 949: 6a 00 push $0x0 + 94b: 50 push %eax + 94c: e8 6f 03 00 00 call cc0 + cmd->left = left; + 951: 89 5e 04 mov %ebx,0x4(%esi) + cmd->right = right; + 954: 83 c4 10 add $0x10,%esp + 957: 89 f3 mov %esi,%ebx + cmd->type = PIPE; + 959: c7 06 03 00 00 00 movl $0x3,(%esi) +} + 95f: 89 d8 mov %ebx,%eax + cmd->right = right; + 961: 89 7e 08 mov %edi,0x8(%esi) +} + 964: 8d 65 f4 lea -0xc(%ebp),%esp + 967: 5b pop %ebx + 968: 5e pop %esi + 969: 5f pop %edi + 96a: 5d pop %ebp + 96b: c3 ret + 96c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000970 : +struct cmd* parseline(char **ps, char *es) { + 970: 55 push %ebp + 971: 89 e5 mov %esp,%ebp + 973: 57 push %edi + 974: 56 push %esi + 975: 53 push %ebx + 976: 83 ec 24 sub $0x24,%esp + 979: 8b 75 08 mov 0x8(%ebp),%esi + 97c: 8b 7d 0c mov 0xc(%ebp),%edi + cmd = parsepipe(ps, es); + 97f: 57 push %edi + 980: 56 push %esi + 981: e8 5a ff ff ff call 8e0 + while (peek(ps, es, "&")) { + 986: 83 c4 10 add $0x10,%esp + cmd = parsepipe(ps, es); + 989: 89 c3 mov %eax,%ebx + while (peek(ps, es, "&")) { + 98b: eb 3b jmp 9c8 + 98d: 8d 76 00 lea 0x0(%esi),%esi + gettoken(ps, es, 0, 0); + 990: 6a 00 push $0x0 + 992: 6a 00 push $0x0 + 994: 57 push %edi + 995: 56 push %esi + 996: e8 05 fb ff ff call 4a0 + cmd = malloc(sizeof(*cmd)); + 99b: c7 04 24 08 00 00 00 movl $0x8,(%esp) + 9a2: e8 59 08 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + 9a7: 83 c4 0c add $0xc,%esp + 9aa: 6a 08 push $0x8 + 9ac: 6a 00 push $0x0 + 9ae: 50 push %eax + 9af: 89 45 e4 mov %eax,-0x1c(%ebp) + 9b2: e8 09 03 00 00 call cc0 + cmd->type = BACK; + 9b7: 8b 55 e4 mov -0x1c(%ebp),%edx + cmd->cmd = subcmd; + 9ba: 83 c4 10 add $0x10,%esp + cmd->type = BACK; + 9bd: c7 02 05 00 00 00 movl $0x5,(%edx) + cmd->cmd = subcmd; + 9c3: 89 5a 04 mov %ebx,0x4(%edx) + 9c6: 89 d3 mov %edx,%ebx + while (peek(ps, es, "&")) { + 9c8: 83 ec 04 sub $0x4,%esp + 9cb: 68 6a 13 00 00 push $0x136a + 9d0: 57 push %edi + 9d1: 56 push %esi + 9d2: e8 29 fc ff ff call 600 + 9d7: 83 c4 10 add $0x10,%esp + 9da: 85 c0 test %eax,%eax + 9dc: 75 b2 jne 990 + if (peek(ps, es, ";")) { + 9de: 83 ec 04 sub $0x4,%esp + 9e1: 68 66 13 00 00 push $0x1366 + 9e6: 57 push %edi + 9e7: 56 push %esi + 9e8: e8 13 fc ff ff call 600 + 9ed: 83 c4 10 add $0x10,%esp + 9f0: 85 c0 test %eax,%eax + 9f2: 75 0c jne a00 +} + 9f4: 8d 65 f4 lea -0xc(%ebp),%esp + 9f7: 89 d8 mov %ebx,%eax + 9f9: 5b pop %ebx + 9fa: 5e pop %esi + 9fb: 5f pop %edi + 9fc: 5d pop %ebp + 9fd: c3 ret + 9fe: 66 90 xchg %ax,%ax + gettoken(ps, es, 0, 0); + a00: 6a 00 push $0x0 + a02: 6a 00 push $0x0 + a04: 57 push %edi + a05: 56 push %esi + a06: e8 95 fa ff ff call 4a0 + cmd = listcmd(cmd, parseline(ps, es)); + a0b: 58 pop %eax + a0c: 5a pop %edx + a0d: 57 push %edi + a0e: 56 push %esi + a0f: e8 5c ff ff ff call 970 + cmd = malloc(sizeof(*cmd)); + a14: c7 04 24 0c 00 00 00 movl $0xc,(%esp) + cmd = listcmd(cmd, parseline(ps, es)); + a1b: 89 c7 mov %eax,%edi + cmd = malloc(sizeof(*cmd)); + a1d: e8 de 07 00 00 call 1200 + memset(cmd, 0, sizeof(*cmd)); + a22: 83 c4 0c add $0xc,%esp + a25: 6a 0c push $0xc + cmd = malloc(sizeof(*cmd)); + a27: 89 c6 mov %eax,%esi + memset(cmd, 0, sizeof(*cmd)); + a29: 6a 00 push $0x0 + a2b: 50 push %eax + a2c: e8 8f 02 00 00 call cc0 + cmd->left = left; + a31: 89 5e 04 mov %ebx,0x4(%esi) + cmd->right = right; + a34: 83 c4 10 add $0x10,%esp + a37: 89 f3 mov %esi,%ebx + cmd->type = LIST; + a39: c7 06 04 00 00 00 movl $0x4,(%esi) +} + a3f: 89 d8 mov %ebx,%eax + cmd->right = right; + a41: 89 7e 08 mov %edi,0x8(%esi) +} + a44: 8d 65 f4 lea -0xc(%ebp),%esp + a47: 5b pop %ebx + a48: 5e pop %esi + a49: 5f pop %edi + a4a: 5d pop %ebp + a4b: c3 ret + a4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000a50 : +struct cmd* parseblock(char **ps, char *es) { + a50: 55 push %ebp + a51: 89 e5 mov %esp,%ebp + a53: 57 push %edi + a54: 56 push %esi + a55: 53 push %ebx + a56: 83 ec 10 sub $0x10,%esp + a59: 8b 5d 08 mov 0x8(%ebp),%ebx + a5c: 8b 75 0c mov 0xc(%ebp),%esi + if (!peek(ps, es, "(")) { + a5f: 68 4c 13 00 00 push $0x134c + a64: 56 push %esi + a65: 53 push %ebx + a66: e8 95 fb ff ff call 600 + a6b: 83 c4 10 add $0x10,%esp + a6e: 85 c0 test %eax,%eax + a70: 74 4a je abc + gettoken(ps, es, 0, 0); + a72: 6a 00 push $0x0 + a74: 6a 00 push $0x0 + a76: 56 push %esi + a77: 53 push %ebx + a78: e8 23 fa ff ff call 4a0 + cmd = parseline(ps, es); + a7d: 58 pop %eax + a7e: 5a pop %edx + a7f: 56 push %esi + a80: 53 push %ebx + a81: e8 ea fe ff ff call 970 + if (!peek(ps, es, ")")) { + a86: 83 c4 0c add $0xc,%esp + a89: 68 88 13 00 00 push $0x1388 + cmd = parseline(ps, es); + a8e: 89 c7 mov %eax,%edi + if (!peek(ps, es, ")")) { + a90: 56 push %esi + a91: 53 push %ebx + a92: e8 69 fb ff ff call 600 + a97: 83 c4 10 add $0x10,%esp + a9a: 85 c0 test %eax,%eax + a9c: 74 2b je ac9 + gettoken(ps, es, 0, 0); + a9e: 6a 00 push $0x0 + aa0: 6a 00 push $0x0 + aa2: 56 push %esi + aa3: 53 push %ebx + aa4: e8 f7 f9 ff ff call 4a0 + cmd = parseredirs(cmd, ps, es); + aa9: 83 c4 0c add $0xc,%esp + aac: 56 push %esi + aad: 53 push %ebx + aae: 57 push %edi + aaf: e8 cc fb ff ff call 680 +} + ab4: 8d 65 f4 lea -0xc(%ebp),%esp + ab7: 5b pop %ebx + ab8: 5e pop %esi + ab9: 5f pop %edi + aba: 5d pop %ebp + abb: c3 ret + panic("parseblock"); + abc: 83 ec 0c sub $0xc,%esp + abf: 68 6c 13 00 00 push $0x136c + ac4: e8 d7 f6 ff ff call 1a0 + panic("syntax - missing )"); + ac9: 83 ec 0c sub $0xc,%esp + acc: 68 77 13 00 00 push $0x1377 + ad1: e8 ca f6 ff ff call 1a0 + ad6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + add: 8d 76 00 lea 0x0(%esi),%esi + +00000ae0 : + +// NUL-terminate all the counted strings. +struct cmd* nulterminate(struct cmd *cmd) { + ae0: 55 push %ebp + ae1: 89 e5 mov %esp,%ebp + ae3: 53 push %ebx + ae4: 83 ec 04 sub $0x4,%esp + ae7: 8b 5d 08 mov 0x8(%ebp),%ebx + struct execcmd *ecmd; + struct listcmd *lcmd; + struct pipecmd *pcmd; + struct redircmd *rcmd; + + if (cmd == 0) { + aea: 85 db test %ebx,%ebx + aec: 0f 84 8e 00 00 00 je b80 + return 0; + } + + switch (cmd->type) { + af2: 83 3b 05 cmpl $0x5,(%ebx) + af5: 77 61 ja b58 + af7: 8b 03 mov (%ebx),%eax + af9: ff 24 85 c8 13 00 00 jmp *0x13c8(,%eax,4) + nulterminate(pcmd->right); + break; + + case LIST: + lcmd = (struct listcmd*)cmd; + nulterminate(lcmd->left); + b00: 83 ec 0c sub $0xc,%esp + b03: ff 73 04 push 0x4(%ebx) + b06: e8 d5 ff ff ff call ae0 + nulterminate(lcmd->right); + b0b: 58 pop %eax + b0c: ff 73 08 push 0x8(%ebx) + b0f: e8 cc ff ff ff call ae0 + break; + b14: 83 c4 10 add $0x10,%esp + b17: 89 d8 mov %ebx,%eax + bcmd = (struct backcmd*)cmd; + nulterminate(bcmd->cmd); + break; + } + return cmd; +} + b19: 8b 5d fc mov -0x4(%ebp),%ebx + b1c: c9 leave + b1d: c3 ret + b1e: 66 90 xchg %ax,%ax + nulterminate(bcmd->cmd); + b20: 83 ec 0c sub $0xc,%esp + b23: ff 73 04 push 0x4(%ebx) + b26: e8 b5 ff ff ff call ae0 + break; + b2b: 89 d8 mov %ebx,%eax + b2d: 83 c4 10 add $0x10,%esp +} + b30: 8b 5d fc mov -0x4(%ebp),%ebx + b33: c9 leave + b34: c3 ret + b35: 8d 76 00 lea 0x0(%esi),%esi + for (i = 0; ecmd->argv[i]; i++) { + b38: 8b 4b 04 mov 0x4(%ebx),%ecx + b3b: 8d 43 08 lea 0x8(%ebx),%eax + b3e: 85 c9 test %ecx,%ecx + b40: 74 16 je b58 + b42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + *ecmd->eargv[i] = 0; + b48: 8b 50 24 mov 0x24(%eax),%edx + for (i = 0; ecmd->argv[i]; i++) { + b4b: 83 c0 04 add $0x4,%eax + *ecmd->eargv[i] = 0; + b4e: c6 02 00 movb $0x0,(%edx) + for (i = 0; ecmd->argv[i]; i++) { + b51: 8b 50 fc mov -0x4(%eax),%edx + b54: 85 d2 test %edx,%edx + b56: 75 f0 jne b48 + switch (cmd->type) { + b58: 89 d8 mov %ebx,%eax +} + b5a: 8b 5d fc mov -0x4(%ebp),%ebx + b5d: c9 leave + b5e: c3 ret + b5f: 90 nop + nulterminate(rcmd->cmd); + b60: 83 ec 0c sub $0xc,%esp + b63: ff 73 04 push 0x4(%ebx) + b66: e8 75 ff ff ff call ae0 + *rcmd->efile = 0; + b6b: 8b 43 0c mov 0xc(%ebx),%eax + break; + b6e: 83 c4 10 add $0x10,%esp + *rcmd->efile = 0; + b71: c6 00 00 movb $0x0,(%eax) + break; + b74: 89 d8 mov %ebx,%eax +} + b76: 8b 5d fc mov -0x4(%ebp),%ebx + b79: c9 leave + b7a: c3 ret + b7b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + b7f: 90 nop + return 0; + b80: 31 c0 xor %eax,%eax + b82: eb 95 jmp b19 + b84: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + b8b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + b8f: 90 nop + +00000b90 : +struct cmd* parsecmd(char *s) { + b90: 55 push %ebp + b91: 89 e5 mov %esp,%ebp + b93: 57 push %edi + b94: 56 push %esi + cmd = parseline(&s, es); + b95: 8d 7d 08 lea 0x8(%ebp),%edi +struct cmd* parsecmd(char *s) { + b98: 53 push %ebx + b99: 83 ec 18 sub $0x18,%esp + es = s + strlen(s); + b9c: 8b 5d 08 mov 0x8(%ebp),%ebx + b9f: 53 push %ebx + ba0: e8 eb 00 00 00 call c90 + cmd = parseline(&s, es); + ba5: 59 pop %ecx + ba6: 5e pop %esi + es = s + strlen(s); + ba7: 01 c3 add %eax,%ebx + cmd = parseline(&s, es); + ba9: 53 push %ebx + baa: 57 push %edi + bab: e8 c0 fd ff ff call 970 + peek(&s, es, ""); + bb0: 83 c4 0c add $0xc,%esp + bb3: 68 16 13 00 00 push $0x1316 + cmd = parseline(&s, es); + bb8: 89 c6 mov %eax,%esi + peek(&s, es, ""); + bba: 53 push %ebx + bbb: 57 push %edi + bbc: e8 3f fa ff ff call 600 + if (s != es) { + bc1: 8b 45 08 mov 0x8(%ebp),%eax + bc4: 83 c4 10 add $0x10,%esp + bc7: 39 d8 cmp %ebx,%eax + bc9: 75 13 jne bde + nulterminate(cmd); + bcb: 83 ec 0c sub $0xc,%esp + bce: 56 push %esi + bcf: e8 0c ff ff ff call ae0 +} + bd4: 8d 65 f4 lea -0xc(%ebp),%esp + bd7: 89 f0 mov %esi,%eax + bd9: 5b pop %ebx + bda: 5e pop %esi + bdb: 5f pop %edi + bdc: 5d pop %ebp + bdd: c3 ret + printf(2, "leftovers: %s\n", s); + bde: 52 push %edx + bdf: 50 push %eax + be0: 68 8a 13 00 00 push $0x138a + be5: 6a 02 push $0x2 + be7: e8 e4 03 00 00 call fd0 + panic("syntax"); + bec: c7 04 24 4e 13 00 00 movl $0x134e,(%esp) + bf3: e8 a8 f5 ff ff call 1a0 + bf8: 66 90 xchg %ax,%ax + bfa: 66 90 xchg %ax,%ax + bfc: 66 90 xchg %ax,%ax + bfe: 66 90 xchg %ax,%ax + +00000c00 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + c00: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + c01: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + c03: 89 e5 mov %esp,%ebp + c05: 53 push %ebx + c06: 8b 4d 08 mov 0x8(%ebp),%ecx + c09: 8b 5d 0c mov 0xc(%ebp),%ebx + c0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + c10: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + c14: 88 14 01 mov %dl,(%ecx,%eax,1) + c17: 83 c0 01 add $0x1,%eax + c1a: 84 d2 test %dl,%dl + c1c: 75 f2 jne c10 + ; + } + return os; +} + c1e: 8b 5d fc mov -0x4(%ebp),%ebx + c21: 89 c8 mov %ecx,%eax + c23: c9 leave + c24: c3 ret + c25: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + c2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000c30 : + +int strcmp(const char *p, const char *q) { + c30: 55 push %ebp + c31: 89 e5 mov %esp,%ebp + c33: 53 push %ebx + c34: 8b 55 08 mov 0x8(%ebp),%edx + c37: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + c3a: 0f b6 02 movzbl (%edx),%eax + c3d: 84 c0 test %al,%al + c3f: 75 17 jne c58 + c41: eb 3a jmp c7d + c43: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c47: 90 nop + c48: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + c4c: 83 c2 01 add $0x1,%edx + c4f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + c52: 84 c0 test %al,%al + c54: 74 1a je c70 + p++, q++; + c56: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + c58: 0f b6 19 movzbl (%ecx),%ebx + c5b: 38 c3 cmp %al,%bl + c5d: 74 e9 je c48 + } + return (uchar) * p - (uchar) * q; + c5f: 29 d8 sub %ebx,%eax +} + c61: 8b 5d fc mov -0x4(%ebp),%ebx + c64: c9 leave + c65: c3 ret + c66: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + c6d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + c70: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + c74: 31 c0 xor %eax,%eax + c76: 29 d8 sub %ebx,%eax +} + c78: 8b 5d fc mov -0x4(%ebp),%ebx + c7b: c9 leave + c7c: c3 ret + return (uchar) * p - (uchar) * q; + c7d: 0f b6 19 movzbl (%ecx),%ebx + c80: 31 c0 xor %eax,%eax + c82: eb db jmp c5f + c84: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + c8b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c8f: 90 nop + +00000c90 : + +uint strlen(const char *s) { + c90: 55 push %ebp + c91: 89 e5 mov %esp,%ebp + c93: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + c96: 80 3a 00 cmpb $0x0,(%edx) + c99: 74 15 je cb0 + c9b: 31 c0 xor %eax,%eax + c9d: 8d 76 00 lea 0x0(%esi),%esi + ca0: 83 c0 01 add $0x1,%eax + ca3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + ca7: 89 c1 mov %eax,%ecx + ca9: 75 f5 jne ca0 + ; + } + return n; +} + cab: 89 c8 mov %ecx,%eax + cad: 5d pop %ebp + cae: c3 ret + caf: 90 nop + for (n = 0; s[n]; n++) { + cb0: 31 c9 xor %ecx,%ecx +} + cb2: 5d pop %ebp + cb3: 89 c8 mov %ecx,%eax + cb5: c3 ret + cb6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cbd: 8d 76 00 lea 0x0(%esi),%esi + +00000cc0 : + +void* memset(void *dst, int c, uint n) { + cc0: 55 push %ebp + cc1: 89 e5 mov %esp,%ebp + cc3: 57 push %edi + cc4: 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" : + cc7: 8b 4d 10 mov 0x10(%ebp),%ecx + cca: 8b 45 0c mov 0xc(%ebp),%eax + ccd: 89 d7 mov %edx,%edi + ccf: fc cld + cd0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + cd2: 8b 7d fc mov -0x4(%ebp),%edi + cd5: 89 d0 mov %edx,%eax + cd7: c9 leave + cd8: c3 ret + cd9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000ce0 : + +char* strchr(const char *s, char c) { + ce0: 55 push %ebp + ce1: 89 e5 mov %esp,%ebp + ce3: 8b 45 08 mov 0x8(%ebp),%eax + ce6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + cea: 0f b6 10 movzbl (%eax),%edx + ced: 84 d2 test %dl,%dl + cef: 75 12 jne d03 + cf1: eb 1d jmp d10 + cf3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + cf7: 90 nop + cf8: 0f b6 50 01 movzbl 0x1(%eax),%edx + cfc: 83 c0 01 add $0x1,%eax + cff: 84 d2 test %dl,%dl + d01: 74 0d je d10 + if (*s == c) { + d03: 38 d1 cmp %dl,%cl + d05: 75 f1 jne cf8 + return (char*)s; + } + } + return 0; +} + d07: 5d pop %ebp + d08: c3 ret + d09: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + d10: 31 c0 xor %eax,%eax +} + d12: 5d pop %ebp + d13: c3 ret + d14: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + d1b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + d1f: 90 nop + +00000d20 : + +char* gets(char *buf, int max) { + d20: 55 push %ebp + d21: 89 e5 mov %esp,%ebp + d23: 57 push %edi + d24: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + d25: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + d28: 53 push %ebx + for (i = 0; i + 1 < max;) { + d29: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + d2b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + d2e: eb 27 jmp d57 + cc = read(0, &c, 1); + d30: 83 ec 04 sub $0x4,%esp + d33: 6a 01 push $0x1 + d35: 57 push %edi + d36: 6a 00 push $0x0 + d38: e8 2e 01 00 00 call e6b + if (cc < 1) { + d3d: 83 c4 10 add $0x10,%esp + d40: 85 c0 test %eax,%eax + d42: 7e 1d jle d61 + break; + } + buf[i++] = c; + d44: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + d48: 8b 55 08 mov 0x8(%ebp),%edx + d4b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + d4f: 3c 0a cmp $0xa,%al + d51: 74 1d je d70 + d53: 3c 0d cmp $0xd,%al + d55: 74 19 je d70 + for (i = 0; i + 1 < max;) { + d57: 89 de mov %ebx,%esi + d59: 83 c3 01 add $0x1,%ebx + d5c: 3b 5d 0c cmp 0xc(%ebp),%ebx + d5f: 7c cf jl d30 + break; + } + } + buf[i] = '\0'; + d61: 8b 45 08 mov 0x8(%ebp),%eax + d64: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + d68: 8d 65 f4 lea -0xc(%ebp),%esp + d6b: 5b pop %ebx + d6c: 5e pop %esi + d6d: 5f pop %edi + d6e: 5d pop %ebp + d6f: c3 ret + buf[i] = '\0'; + d70: 8b 45 08 mov 0x8(%ebp),%eax + d73: 89 de mov %ebx,%esi + d75: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + d79: 8d 65 f4 lea -0xc(%ebp),%esp + d7c: 5b pop %ebx + d7d: 5e pop %esi + d7e: 5f pop %edi + d7f: 5d pop %ebp + d80: c3 ret + d81: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + d88: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + d8f: 90 nop + +00000d90 : + +int stat(const char *n, struct stat *st) { + d90: 55 push %ebp + d91: 89 e5 mov %esp,%ebp + d93: 56 push %esi + d94: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + d95: 83 ec 08 sub $0x8,%esp + d98: 6a 00 push $0x0 + d9a: ff 75 08 push 0x8(%ebp) + d9d: e8 19 01 00 00 call ebb + if (fd < 0) { + da2: 83 c4 10 add $0x10,%esp + da5: 85 c0 test %eax,%eax + da7: 78 27 js dd0 + return -1; + } + r = fstat(fd, st); + da9: 83 ec 08 sub $0x8,%esp + dac: ff 75 0c push 0xc(%ebp) + daf: 89 c3 mov %eax,%ebx + db1: 50 push %eax + db2: e8 cc 00 00 00 call e83 + close(fd); + db7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + dba: 89 c6 mov %eax,%esi + close(fd); + dbc: e8 2a 01 00 00 call eeb + return r; + dc1: 83 c4 10 add $0x10,%esp +} + dc4: 8d 65 f8 lea -0x8(%ebp),%esp + dc7: 89 f0 mov %esi,%eax + dc9: 5b pop %ebx + dca: 5e pop %esi + dcb: 5d pop %ebp + dcc: c3 ret + dcd: 8d 76 00 lea 0x0(%esi),%esi + return -1; + dd0: be ff ff ff ff mov $0xffffffff,%esi + dd5: eb ed jmp dc4 + dd7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + dde: 66 90 xchg %ax,%ax + +00000de0 : + +int atoi(const char *s) { + de0: 55 push %ebp + de1: 89 e5 mov %esp,%ebp + de3: 53 push %ebx + de4: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + de7: 0f be 02 movsbl (%edx),%eax + dea: 8d 48 d0 lea -0x30(%eax),%ecx + ded: 80 f9 09 cmp $0x9,%cl + n = 0; + df0: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + df5: 77 1e ja e15 + df7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + dfe: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + e00: 83 c2 01 add $0x1,%edx + e03: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + e06: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + e0a: 0f be 02 movsbl (%edx),%eax + e0d: 8d 58 d0 lea -0x30(%eax),%ebx + e10: 80 fb 09 cmp $0x9,%bl + e13: 76 eb jbe e00 + } + return n; +} + e15: 8b 5d fc mov -0x4(%ebp),%ebx + e18: 89 c8 mov %ecx,%eax + e1a: c9 leave + e1b: c3 ret + e1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000e20 : + +void* memmove(void *vdst, const void *vsrc, int n) { + e20: 55 push %ebp + e21: 89 e5 mov %esp,%ebp + e23: 57 push %edi + e24: 8b 45 10 mov 0x10(%ebp),%eax + e27: 8b 55 08 mov 0x8(%ebp),%edx + e2a: 56 push %esi + e2b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + e2e: 85 c0 test %eax,%eax + e30: 7e 13 jle e45 + e32: 01 d0 add %edx,%eax + dst = vdst; + e34: 89 d7 mov %edx,%edi + e36: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + e3d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + e40: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + e41: 39 f8 cmp %edi,%eax + e43: 75 fb jne e40 + } + return vdst; +} + e45: 5e pop %esi + e46: 89 d0 mov %edx,%eax + e48: 5f pop %edi + e49: 5d pop %ebp + e4a: c3 ret + +00000e4b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + e4b: b8 01 00 00 00 mov $0x1,%eax + e50: cd 40 int $0x40 + e52: c3 ret + +00000e53 : +SYSCALL(exit) + e53: b8 02 00 00 00 mov $0x2,%eax + e58: cd 40 int $0x40 + e5a: c3 ret + +00000e5b : +SYSCALL(wait) + e5b: b8 03 00 00 00 mov $0x3,%eax + e60: cd 40 int $0x40 + e62: c3 ret + +00000e63 : +SYSCALL(pipe) + e63: b8 04 00 00 00 mov $0x4,%eax + e68: cd 40 int $0x40 + e6a: c3 ret + +00000e6b : +SYSCALL(read) + e6b: b8 05 00 00 00 mov $0x5,%eax + e70: cd 40 int $0x40 + e72: c3 ret + +00000e73 : +SYSCALL(kill) + e73: b8 06 00 00 00 mov $0x6,%eax + e78: cd 40 int $0x40 + e7a: c3 ret + +00000e7b : +SYSCALL(exec) + e7b: b8 07 00 00 00 mov $0x7,%eax + e80: cd 40 int $0x40 + e82: c3 ret + +00000e83 : +SYSCALL(fstat) + e83: b8 08 00 00 00 mov $0x8,%eax + e88: cd 40 int $0x40 + e8a: c3 ret + +00000e8b : +SYSCALL(chdir) + e8b: b8 09 00 00 00 mov $0x9,%eax + e90: cd 40 int $0x40 + e92: c3 ret + +00000e93 : +SYSCALL(dup) + e93: b8 0a 00 00 00 mov $0xa,%eax + e98: cd 40 int $0x40 + e9a: c3 ret + +00000e9b : +SYSCALL(getpid) + e9b: b8 0b 00 00 00 mov $0xb,%eax + ea0: cd 40 int $0x40 + ea2: c3 ret + +00000ea3 : +SYSCALL(sbrk) + ea3: b8 0c 00 00 00 mov $0xc,%eax + ea8: cd 40 int $0x40 + eaa: c3 ret + +00000eab : +SYSCALL(sleep) + eab: b8 0d 00 00 00 mov $0xd,%eax + eb0: cd 40 int $0x40 + eb2: c3 ret + +00000eb3 : +SYSCALL(uptime) + eb3: b8 0e 00 00 00 mov $0xe,%eax + eb8: cd 40 int $0x40 + eba: c3 ret + +00000ebb : +SYSCALL(open) + ebb: b8 0f 00 00 00 mov $0xf,%eax + ec0: cd 40 int $0x40 + ec2: c3 ret + +00000ec3 : +SYSCALL(write) + ec3: b8 10 00 00 00 mov $0x10,%eax + ec8: cd 40 int $0x40 + eca: c3 ret + +00000ecb : +SYSCALL(mknod) + ecb: b8 11 00 00 00 mov $0x11,%eax + ed0: cd 40 int $0x40 + ed2: c3 ret + +00000ed3 : +SYSCALL(unlink) + ed3: b8 12 00 00 00 mov $0x12,%eax + ed8: cd 40 int $0x40 + eda: c3 ret + +00000edb : +SYSCALL(link) + edb: b8 13 00 00 00 mov $0x13,%eax + ee0: cd 40 int $0x40 + ee2: c3 ret + +00000ee3 : +SYSCALL(mkdir) + ee3: b8 14 00 00 00 mov $0x14,%eax + ee8: cd 40 int $0x40 + eea: c3 ret + +00000eeb : +SYSCALL(close) + eeb: b8 15 00 00 00 mov $0x15,%eax + ef0: cd 40 int $0x40 + ef2: c3 ret + +00000ef3 : +SYSCALL(getch) + ef3: b8 16 00 00 00 mov $0x16,%eax + ef8: cd 40 int $0x40 + efa: c3 ret + +00000efb : +SYSCALL(greeting) + efb: b8 17 00 00 00 mov $0x17,%eax + f00: cd 40 int $0x40 + f02: c3 ret + +00000f03 : +SYSCALL(shutdown) + f03: b8 18 00 00 00 mov $0x18,%eax + f08: cd 40 int $0x40 + f0a: c3 ret + +00000f0b : +SYSCALL(screen) + f0b: b8 19 00 00 00 mov $0x19,%eax + f10: cd 40 int $0x40 + f12: c3 ret + +00000f13 : +SYSCALL(cls) + f13: b8 1a 00 00 00 mov $0x1a,%eax + f18: cd 40 int $0x40 + f1a: c3 ret + f1b: 66 90 xchg %ax,%ax + f1d: 66 90 xchg %ax,%ax + f1f: 90 nop + +00000f20 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + f20: 55 push %ebp + f21: 89 e5 mov %esp,%ebp + f23: 57 push %edi + f24: 56 push %esi + f25: 53 push %ebx + f26: 83 ec 3c sub $0x3c,%esp + f29: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + f2c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + f2e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + f31: 85 d2 test %edx,%edx + f33: 0f 89 7f 00 00 00 jns fb8 + f39: f6 45 08 01 testb $0x1,0x8(%ebp) + f3d: 74 79 je fb8 + neg = 1; + f3f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + f46: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + f48: 31 db xor %ebx,%ebx + f4a: 8d 75 d7 lea -0x29(%ebp),%esi + f4d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + f50: 89 c8 mov %ecx,%eax + f52: 31 d2 xor %edx,%edx + f54: 89 cf mov %ecx,%edi + f56: f7 75 c4 divl -0x3c(%ebp) + f59: 0f b6 92 40 14 00 00 movzbl 0x1440(%edx),%edx + f60: 89 45 c0 mov %eax,-0x40(%ebp) + f63: 89 d8 mov %ebx,%eax + f65: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + f68: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + f6b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + f6e: 39 7d c4 cmp %edi,-0x3c(%ebp) + f71: 76 dd jbe f50 + if (neg) { + f73: 8b 4d bc mov -0x44(%ebp),%ecx + f76: 85 c9 test %ecx,%ecx + f78: 74 0c je f86 + buf[i++] = '-'; + f7a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + f7f: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + f81: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + f86: 8b 7d b8 mov -0x48(%ebp),%edi + f89: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + f8d: eb 07 jmp f96 + f8f: 90 nop + putc(fd, buf[i]); + f90: 0f b6 13 movzbl (%ebx),%edx + f93: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + f96: 83 ec 04 sub $0x4,%esp + f99: 88 55 d7 mov %dl,-0x29(%ebp) + f9c: 6a 01 push $0x1 + f9e: 56 push %esi + f9f: 57 push %edi + fa0: e8 1e ff ff ff call ec3 + while (--i >= 0) { + fa5: 83 c4 10 add $0x10,%esp + fa8: 39 de cmp %ebx,%esi + faa: 75 e4 jne f90 + } +} + fac: 8d 65 f4 lea -0xc(%ebp),%esp + faf: 5b pop %ebx + fb0: 5e pop %esi + fb1: 5f pop %edi + fb2: 5d pop %ebp + fb3: c3 ret + fb4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + fb8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + fbf: eb 87 jmp f48 + fc1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + fc8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + fcf: 90 nop + +00000fd0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + fd0: 55 push %ebp + fd1: 89 e5 mov %esp,%ebp + fd3: 57 push %edi + fd4: 56 push %esi + fd5: 53 push %ebx + fd6: 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++) { + fd9: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + fdc: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + fdf: 0f b6 13 movzbl (%ebx),%edx + fe2: 84 d2 test %dl,%dl + fe4: 74 6a je 1050 + ap = (uint*)(void*)&fmt + 1; + fe6: 8d 45 10 lea 0x10(%ebp),%eax + fe9: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + fec: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + fef: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + ff1: 89 45 d0 mov %eax,-0x30(%ebp) + ff4: eb 36 jmp 102c + ff6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ffd: 8d 76 00 lea 0x0(%esi),%esi + 1000: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 1003: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 1008: 83 f8 25 cmp $0x25,%eax + 100b: 74 15 je 1022 + write(fd, &c, 1); + 100d: 83 ec 04 sub $0x4,%esp + 1010: 88 55 e7 mov %dl,-0x19(%ebp) + 1013: 6a 01 push $0x1 + 1015: 57 push %edi + 1016: 56 push %esi + 1017: e8 a7 fe ff ff call ec3 + 101c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 101f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 1022: 0f b6 13 movzbl (%ebx),%edx + 1025: 83 c3 01 add $0x1,%ebx + 1028: 84 d2 test %dl,%dl + 102a: 74 24 je 1050 + c = fmt[i] & 0xff; + 102c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 102f: 85 c9 test %ecx,%ecx + 1031: 74 cd je 1000 + } + } + else if (state == '%') { + 1033: 83 f9 25 cmp $0x25,%ecx + 1036: 75 ea jne 1022 + if (c == 'd') { + 1038: 83 f8 25 cmp $0x25,%eax + 103b: 0f 84 07 01 00 00 je 1148 + 1041: 83 e8 63 sub $0x63,%eax + 1044: 83 f8 15 cmp $0x15,%eax + 1047: 77 17 ja 1060 + 1049: ff 24 85 e8 13 00 00 jmp *0x13e8(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 1050: 8d 65 f4 lea -0xc(%ebp),%esp + 1053: 5b pop %ebx + 1054: 5e pop %esi + 1055: 5f pop %edi + 1056: 5d pop %ebp + 1057: c3 ret + 1058: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 105f: 90 nop + write(fd, &c, 1); + 1060: 83 ec 04 sub $0x4,%esp + 1063: 88 55 d4 mov %dl,-0x2c(%ebp) + 1066: 6a 01 push $0x1 + 1068: 57 push %edi + 1069: 56 push %esi + 106a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 106e: e8 50 fe ff ff call ec3 + putc(fd, c); + 1073: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 1077: 83 c4 0c add $0xc,%esp + 107a: 88 55 e7 mov %dl,-0x19(%ebp) + 107d: 6a 01 push $0x1 + 107f: 57 push %edi + 1080: 56 push %esi + 1081: e8 3d fe ff ff call ec3 + putc(fd, c); + 1086: 83 c4 10 add $0x10,%esp + state = 0; + 1089: 31 c9 xor %ecx,%ecx + 108b: eb 95 jmp 1022 + 108d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1090: 83 ec 0c sub $0xc,%esp + 1093: b9 10 00 00 00 mov $0x10,%ecx + 1098: 6a 00 push $0x0 + 109a: 8b 45 d0 mov -0x30(%ebp),%eax + 109d: 8b 10 mov (%eax),%edx + 109f: 89 f0 mov %esi,%eax + 10a1: e8 7a fe ff ff call f20 + ap++; + 10a6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 10aa: 83 c4 10 add $0x10,%esp + state = 0; + 10ad: 31 c9 xor %ecx,%ecx + 10af: e9 6e ff ff ff jmp 1022 + 10b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 10b8: 8b 45 d0 mov -0x30(%ebp),%eax + 10bb: 8b 10 mov (%eax),%edx + ap++; + 10bd: 83 c0 04 add $0x4,%eax + 10c0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 10c3: 85 d2 test %edx,%edx + 10c5: 0f 84 8d 00 00 00 je 1158 + while (*s != 0) { + 10cb: 0f b6 02 movzbl (%edx),%eax + state = 0; + 10ce: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 10d0: 84 c0 test %al,%al + 10d2: 0f 84 4a ff ff ff je 1022 + 10d8: 89 5d d4 mov %ebx,-0x2c(%ebp) + 10db: 89 d3 mov %edx,%ebx + 10dd: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 10e0: 83 ec 04 sub $0x4,%esp + s++; + 10e3: 83 c3 01 add $0x1,%ebx + 10e6: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 10e9: 6a 01 push $0x1 + 10eb: 57 push %edi + 10ec: 56 push %esi + 10ed: e8 d1 fd ff ff call ec3 + while (*s != 0) { + 10f2: 0f b6 03 movzbl (%ebx),%eax + 10f5: 83 c4 10 add $0x10,%esp + 10f8: 84 c0 test %al,%al + 10fa: 75 e4 jne 10e0 + state = 0; + 10fc: 8b 5d d4 mov -0x2c(%ebp),%ebx + 10ff: 31 c9 xor %ecx,%ecx + 1101: e9 1c ff ff ff jmp 1022 + 1106: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 110d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1110: 83 ec 0c sub $0xc,%esp + 1113: b9 0a 00 00 00 mov $0xa,%ecx + 1118: 6a 01 push $0x1 + 111a: e9 7b ff ff ff jmp 109a + 111f: 90 nop + putc(fd, *ap); + 1120: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 1123: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 1126: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 1128: 6a 01 push $0x1 + 112a: 57 push %edi + 112b: 56 push %esi + putc(fd, *ap); + 112c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 112f: e8 8f fd ff ff call ec3 + ap++; + 1134: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 1138: 83 c4 10 add $0x10,%esp + state = 0; + 113b: 31 c9 xor %ecx,%ecx + 113d: e9 e0 fe ff ff jmp 1022 + 1142: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 1148: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 114b: 83 ec 04 sub $0x4,%esp + 114e: e9 2a ff ff ff jmp 107d + 1153: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1157: 90 nop + s = "(null)"; + 1158: ba e0 13 00 00 mov $0x13e0,%edx + while (*s != 0) { + 115d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 1160: b8 28 00 00 00 mov $0x28,%eax + 1165: 89 d3 mov %edx,%ebx + 1167: e9 74 ff ff ff jmp 10e0 + 116c: 66 90 xchg %ax,%ax + 116e: 66 90 xchg %ax,%ax + +00001170 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 1170: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 1171: a1 a4 1a 00 00 mov 0x1aa4,%eax +void free(void *ap) { + 1176: 89 e5 mov %esp,%ebp + 1178: 57 push %edi + 1179: 56 push %esi + 117a: 53 push %ebx + 117b: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 117e: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 1181: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1188: 89 c2 mov %eax,%edx + 118a: 8b 00 mov (%eax),%eax + 118c: 39 ca cmp %ecx,%edx + 118e: 73 30 jae 11c0 + 1190: 39 c1 cmp %eax,%ecx + 1192: 72 04 jb 1198 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 1194: 39 c2 cmp %eax,%edx + 1196: 72 f0 jb 1188 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 1198: 8b 73 fc mov -0x4(%ebx),%esi + 119b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 119e: 39 f8 cmp %edi,%eax + 11a0: 74 30 je 11d2 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 11a2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 11a5: 8b 42 04 mov 0x4(%edx),%eax + 11a8: 8d 34 c2 lea (%edx,%eax,8),%esi + 11ab: 39 f1 cmp %esi,%ecx + 11ad: 74 3a je 11e9 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 11af: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 11b1: 5b pop %ebx + freep = p; + 11b2: 89 15 a4 1a 00 00 mov %edx,0x1aa4 +} + 11b8: 5e pop %esi + 11b9: 5f pop %edi + 11ba: 5d pop %ebp + 11bb: c3 ret + 11bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 11c0: 39 c2 cmp %eax,%edx + 11c2: 72 c4 jb 1188 + 11c4: 39 c1 cmp %eax,%ecx + 11c6: 73 c0 jae 1188 + if (bp + bp->s.size == p->s.ptr) { + 11c8: 8b 73 fc mov -0x4(%ebx),%esi + 11cb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 11ce: 39 f8 cmp %edi,%eax + 11d0: 75 d0 jne 11a2 + bp->s.size += p->s.ptr->s.size; + 11d2: 03 70 04 add 0x4(%eax),%esi + 11d5: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 11d8: 8b 02 mov (%edx),%eax + 11da: 8b 00 mov (%eax),%eax + 11dc: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 11df: 8b 42 04 mov 0x4(%edx),%eax + 11e2: 8d 34 c2 lea (%edx,%eax,8),%esi + 11e5: 39 f1 cmp %esi,%ecx + 11e7: 75 c6 jne 11af + p->s.size += bp->s.size; + 11e9: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 11ec: 89 15 a4 1a 00 00 mov %edx,0x1aa4 + p->s.size += bp->s.size; + 11f2: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 11f5: 8b 4b f8 mov -0x8(%ebx),%ecx + 11f8: 89 0a mov %ecx,(%edx) +} + 11fa: 5b pop %ebx + 11fb: 5e pop %esi + 11fc: 5f pop %edi + 11fd: 5d pop %ebp + 11fe: c3 ret + 11ff: 90 nop + +00001200 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 1200: 55 push %ebp + 1201: 89 e5 mov %esp,%ebp + 1203: 57 push %edi + 1204: 56 push %esi + 1205: 53 push %ebx + 1206: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 1209: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 120c: 8b 3d a4 1a 00 00 mov 0x1aa4,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 1212: 8d 70 07 lea 0x7(%eax),%esi + 1215: c1 ee 03 shr $0x3,%esi + 1218: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 121b: 85 ff test %edi,%edi + 121d: 0f 84 9d 00 00 00 je 12c0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 1223: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 1225: 8b 4a 04 mov 0x4(%edx),%ecx + 1228: 39 f1 cmp %esi,%ecx + 122a: 73 6a jae 1296 + 122c: bb 00 10 00 00 mov $0x1000,%ebx + 1231: 39 de cmp %ebx,%esi + 1233: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 1236: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 123d: 89 45 e4 mov %eax,-0x1c(%ebp) + 1240: eb 17 jmp 1259 + 1242: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 1248: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 124a: 8b 48 04 mov 0x4(%eax),%ecx + 124d: 39 f1 cmp %esi,%ecx + 124f: 73 4f jae 12a0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 1251: 8b 3d a4 1a 00 00 mov 0x1aa4,%edi + 1257: 89 c2 mov %eax,%edx + 1259: 39 d7 cmp %edx,%edi + 125b: 75 eb jne 1248 + p = sbrk(nu * sizeof(Header)); + 125d: 83 ec 0c sub $0xc,%esp + 1260: ff 75 e4 push -0x1c(%ebp) + 1263: e8 3b fc ff ff call ea3 + if (p == (char*)-1) { + 1268: 83 c4 10 add $0x10,%esp + 126b: 83 f8 ff cmp $0xffffffff,%eax + 126e: 74 1c je 128c + hp->s.size = nu; + 1270: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 1273: 83 ec 0c sub $0xc,%esp + 1276: 83 c0 08 add $0x8,%eax + 1279: 50 push %eax + 127a: e8 f1 fe ff ff call 1170 + return freep; + 127f: 8b 15 a4 1a 00 00 mov 0x1aa4,%edx + if ((p = morecore(nunits)) == 0) { + 1285: 83 c4 10 add $0x10,%esp + 1288: 85 d2 test %edx,%edx + 128a: 75 bc jne 1248 + return 0; + } + } + } +} + 128c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 128f: 31 c0 xor %eax,%eax +} + 1291: 5b pop %ebx + 1292: 5e pop %esi + 1293: 5f pop %edi + 1294: 5d pop %ebp + 1295: c3 ret + if (p->s.size >= nunits) { + 1296: 89 d0 mov %edx,%eax + 1298: 89 fa mov %edi,%edx + 129a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 12a0: 39 ce cmp %ecx,%esi + 12a2: 74 4c je 12f0 + p->s.size -= nunits; + 12a4: 29 f1 sub %esi,%ecx + 12a6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 12a9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 12ac: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 12af: 89 15 a4 1a 00 00 mov %edx,0x1aa4 +} + 12b5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 12b8: 83 c0 08 add $0x8,%eax +} + 12bb: 5b pop %ebx + 12bc: 5e pop %esi + 12bd: 5f pop %edi + 12be: 5d pop %ebp + 12bf: c3 ret + base.s.ptr = freep = prevp = &base; + 12c0: c7 05 a4 1a 00 00 a8 movl $0x1aa8,0x1aa4 + 12c7: 1a 00 00 + base.s.size = 0; + 12ca: bf a8 1a 00 00 mov $0x1aa8,%edi + base.s.ptr = freep = prevp = &base; + 12cf: c7 05 a8 1a 00 00 a8 movl $0x1aa8,0x1aa8 + 12d6: 1a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 12d9: 89 fa mov %edi,%edx + base.s.size = 0; + 12db: c7 05 ac 1a 00 00 00 movl $0x0,0x1aac + 12e2: 00 00 00 + if (p->s.size >= nunits) { + 12e5: e9 42 ff ff ff jmp 122c + 12ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 12f0: 8b 08 mov (%eax),%ecx + 12f2: 89 0a mov %ecx,(%edx) + 12f4: eb b9 jmp 12af diff --git a/sh.d b/sh.d new file mode 100644 index 0000000..51ddf2d --- /dev/null +++ b/sh.d @@ -0,0 +1 @@ +sh.o: sh.c /usr/include/stdc-predef.h types.h user.h fcntl.h diff --git a/sh.o b/sh.o new file mode 100644 index 0000000..53f6979 Binary files /dev/null and b/sh.o differ diff --git a/sh.sym b/sh.sym new file mode 100644 index 0000000..01e9c45 --- /dev/null +++ b/sh.sym @@ -0,0 +1,71 @@ +00000000 sh.c +00001a40 buf.0 +00000000 ulib.c +00000000 printf.c +00000f20 printint +00001440 digits.0 +00000000 umalloc.c +00001aa4 freep +00001aa8 base +00000c00 strcpy +00000fd0 printf +00000efb greeting +00000e20 memmove +00000ecb mknod +00000370 execcmd +00000d20 gets +00000e9b getpid +000008e0 parsepipe +00000b90 parsecmd +00000470 backcmd +00000600 peek +00000f0b screen +00000680 parseredirs +000004a0 gettoken +00001200 malloc +00000eab sleep +00001a1c whitespace +000001c0 fork1 +00000ae0 nulterminate +00000e63 pipe +00000ef3 getch +00000160 getcmd +00000ec3 write +00000e83 fstat +00000e73 kill +00000e8b chdir +00000970 parseline +000001e0 runcmd +00000a50 parseblock +00000e7b exec +00000e5b wait +00001a14 symbols +00000e6b read +000007c0 parseexec +00000ed3 unlink +000001a0 panic +00000e4b fork +00000ea3 sbrk +00000eb3 uptime +00001a22 __bss_start +00000cc0 memset +00000000 main +00000c30 strcmp +00000f03 shutdown +00000e93 dup +000003f0 pipecmd +000003a0 redircmd +00000d90 stat +00001a22 _edata +00001ab0 _end +00000edb link +00000e53 exit +00000de0 atoi +00000f13 cls +00000c90 strlen +00000ebb open +00000ce0 strchr +00000ee3 mkdir +00000eeb close +00000430 listcmd +00001170 free diff --git a/shutdown.asm b/shutdown.asm new file mode 100644 index 0000000..89620a6 --- /dev/null +++ b/shutdown.asm @@ -0,0 +1,1210 @@ + +_shutdown: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "types.h" +#include "user.h" + +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: 51 push %ecx + 11: 83 ec 18 sub $0x18,%esp + 14: 8b 01 mov (%ecx),%eax + 16: 8b 71 04 mov 0x4(%ecx),%esi + 19: 89 45 e4 mov %eax,-0x1c(%ebp) + int restart = 0; + + for (int i = 1; i < argc; i++) { + 1c: 83 f8 01 cmp $0x1,%eax + 1f: 7e 58 jle 79 + 21: bb 01 00 00 00 mov $0x1,%ebx + int restart = 0; + 26: 31 ff xor %edi,%edi + 28: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2f: 90 nop + if (strcmp(argv[i], "-r") == 0) { + 30: 83 ec 08 sub $0x8,%esp + 33: 68 88 07 00 00 push $0x788 + 38: ff 34 9e push (%esi,%ebx,4) + 3b: e8 80 00 00 00 call c0 + 40: 83 c4 10 add $0x10,%esp + restart = 1; + 43: 85 c0 test %eax,%eax + 45: b8 01 00 00 00 mov $0x1,%eax + 4a: 0f 44 f8 cmove %eax,%edi + for (int i = 1; i < argc; i++) { + 4d: 83 c3 01 add $0x1,%ebx + 50: 39 5d e4 cmp %ebx,-0x1c(%ebp) + 53: 75 db jne 30 + } + } + + switch(restart) { + 55: 83 ff 01 cmp $0x1,%edi + 58: 75 1f jne 79 + case 0: + printf(1, "Shutting Down...\n"); + break; + case 1: + printf(1, "Restarting...\n"); + 5a: 50 push %eax + 5b: 50 push %eax + 5c: 68 9d 07 00 00 push $0x79d + 61: 6a 01 push $0x1 + 63: e8 f8 03 00 00 call 460 + break; + 68: 83 c4 10 add $0x10,%esp + } + + shutdown(restart); + 6b: 83 ec 0c sub $0xc,%esp + 6e: 57 push %edi + 6f: e8 1f 03 00 00 call 393 + exit(); + 74: e8 6a 02 00 00 call 2e3 + printf(1, "Shutting Down...\n"); + 79: 52 push %edx + break; + 7a: 31 ff xor %edi,%edi + printf(1, "Shutting Down...\n"); + 7c: 52 push %edx + 7d: 68 8b 07 00 00 push $0x78b + 82: 6a 01 push $0x1 + 84: e8 d7 03 00 00 call 460 + break; + 89: 83 c4 10 add $0x10,%esp + 8c: eb dd jmp 6b + 8e: 66 90 xchg %ax,%ax + +00000090 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 90: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 91: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 93: 89 e5 mov %esp,%ebp + 95: 53 push %ebx + 96: 8b 4d 08 mov 0x8(%ebp),%ecx + 99: 8b 5d 0c mov 0xc(%ebp),%ebx + 9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + a0: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + a4: 88 14 01 mov %dl,(%ecx,%eax,1) + a7: 83 c0 01 add $0x1,%eax + aa: 84 d2 test %dl,%dl + ac: 75 f2 jne a0 + ; + } + return os; +} + ae: 8b 5d fc mov -0x4(%ebp),%ebx + b1: 89 c8 mov %ecx,%eax + b3: c9 leave + b4: c3 ret + b5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000000c0 : + +int strcmp(const char *p, const char *q) { + c0: 55 push %ebp + c1: 89 e5 mov %esp,%ebp + c3: 53 push %ebx + c4: 8b 55 08 mov 0x8(%ebp),%edx + c7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + ca: 0f b6 02 movzbl (%edx),%eax + cd: 84 c0 test %al,%al + cf: 75 17 jne e8 + d1: eb 3a jmp 10d + d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + d7: 90 nop + d8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + dc: 83 c2 01 add $0x1,%edx + df: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + e2: 84 c0 test %al,%al + e4: 74 1a je 100 + p++, q++; + e6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + e8: 0f b6 19 movzbl (%ecx),%ebx + eb: 38 c3 cmp %al,%bl + ed: 74 e9 je d8 + } + return (uchar) * p - (uchar) * q; + ef: 29 d8 sub %ebx,%eax +} + f1: 8b 5d fc mov -0x4(%ebp),%ebx + f4: c9 leave + f5: c3 ret + f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + fd: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 100: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 104: 31 c0 xor %eax,%eax + 106: 29 d8 sub %ebx,%eax +} + 108: 8b 5d fc mov -0x4(%ebp),%ebx + 10b: c9 leave + 10c: c3 ret + return (uchar) * p - (uchar) * q; + 10d: 0f b6 19 movzbl (%ecx),%ebx + 110: 31 c0 xor %eax,%eax + 112: eb db jmp ef + 114: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 11b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 11f: 90 nop + +00000120 : + +uint strlen(const char *s) { + 120: 55 push %ebp + 121: 89 e5 mov %esp,%ebp + 123: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 126: 80 3a 00 cmpb $0x0,(%edx) + 129: 74 15 je 140 + 12b: 31 c0 xor %eax,%eax + 12d: 8d 76 00 lea 0x0(%esi),%esi + 130: 83 c0 01 add $0x1,%eax + 133: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 137: 89 c1 mov %eax,%ecx + 139: 75 f5 jne 130 + ; + } + return n; +} + 13b: 89 c8 mov %ecx,%eax + 13d: 5d pop %ebp + 13e: c3 ret + 13f: 90 nop + for (n = 0; s[n]; n++) { + 140: 31 c9 xor %ecx,%ecx +} + 142: 5d pop %ebp + 143: 89 c8 mov %ecx,%eax + 145: c3 ret + 146: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 14d: 8d 76 00 lea 0x0(%esi),%esi + +00000150 : + +void* memset(void *dst, int c, uint n) { + 150: 55 push %ebp + 151: 89 e5 mov %esp,%ebp + 153: 57 push %edi + 154: 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" : + 157: 8b 4d 10 mov 0x10(%ebp),%ecx + 15a: 8b 45 0c mov 0xc(%ebp),%eax + 15d: 89 d7 mov %edx,%edi + 15f: fc cld + 160: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 162: 8b 7d fc mov -0x4(%ebp),%edi + 165: 89 d0 mov %edx,%eax + 167: c9 leave + 168: c3 ret + 169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000170 : + +char* strchr(const char *s, char c) { + 170: 55 push %ebp + 171: 89 e5 mov %esp,%ebp + 173: 8b 45 08 mov 0x8(%ebp),%eax + 176: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 17a: 0f b6 10 movzbl (%eax),%edx + 17d: 84 d2 test %dl,%dl + 17f: 75 12 jne 193 + 181: eb 1d jmp 1a0 + 183: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 187: 90 nop + 188: 0f b6 50 01 movzbl 0x1(%eax),%edx + 18c: 83 c0 01 add $0x1,%eax + 18f: 84 d2 test %dl,%dl + 191: 74 0d je 1a0 + if (*s == c) { + 193: 38 d1 cmp %dl,%cl + 195: 75 f1 jne 188 + return (char*)s; + } + } + return 0; +} + 197: 5d pop %ebp + 198: c3 ret + 199: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 1a0: 31 c0 xor %eax,%eax +} + 1a2: 5d pop %ebp + 1a3: c3 ret + 1a4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1af: 90 nop + +000001b0 : + +char* gets(char *buf, int max) { + 1b0: 55 push %ebp + 1b1: 89 e5 mov %esp,%ebp + 1b3: 57 push %edi + 1b4: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 1b5: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 1b8: 53 push %ebx + for (i = 0; i + 1 < max;) { + 1b9: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 1bb: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 1be: eb 27 jmp 1e7 + cc = read(0, &c, 1); + 1c0: 83 ec 04 sub $0x4,%esp + 1c3: 6a 01 push $0x1 + 1c5: 57 push %edi + 1c6: 6a 00 push $0x0 + 1c8: e8 2e 01 00 00 call 2fb + if (cc < 1) { + 1cd: 83 c4 10 add $0x10,%esp + 1d0: 85 c0 test %eax,%eax + 1d2: 7e 1d jle 1f1 + break; + } + buf[i++] = c; + 1d4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 1d8: 8b 55 08 mov 0x8(%ebp),%edx + 1db: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 1df: 3c 0a cmp $0xa,%al + 1e1: 74 1d je 200 + 1e3: 3c 0d cmp $0xd,%al + 1e5: 74 19 je 200 + for (i = 0; i + 1 < max;) { + 1e7: 89 de mov %ebx,%esi + 1e9: 83 c3 01 add $0x1,%ebx + 1ec: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1ef: 7c cf jl 1c0 + break; + } + } + buf[i] = '\0'; + 1f1: 8b 45 08 mov 0x8(%ebp),%eax + 1f4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1f8: 8d 65 f4 lea -0xc(%ebp),%esp + 1fb: 5b pop %ebx + 1fc: 5e pop %esi + 1fd: 5f pop %edi + 1fe: 5d pop %ebp + 1ff: c3 ret + buf[i] = '\0'; + 200: 8b 45 08 mov 0x8(%ebp),%eax + 203: 89 de mov %ebx,%esi + 205: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 209: 8d 65 f4 lea -0xc(%ebp),%esp + 20c: 5b pop %ebx + 20d: 5e pop %esi + 20e: 5f pop %edi + 20f: 5d pop %ebp + 210: c3 ret + 211: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 218: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 21f: 90 nop + +00000220 : + +int stat(const char *n, struct stat *st) { + 220: 55 push %ebp + 221: 89 e5 mov %esp,%ebp + 223: 56 push %esi + 224: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 225: 83 ec 08 sub $0x8,%esp + 228: 6a 00 push $0x0 + 22a: ff 75 08 push 0x8(%ebp) + 22d: e8 19 01 00 00 call 34b + if (fd < 0) { + 232: 83 c4 10 add $0x10,%esp + 235: 85 c0 test %eax,%eax + 237: 78 27 js 260 + return -1; + } + r = fstat(fd, st); + 239: 83 ec 08 sub $0x8,%esp + 23c: ff 75 0c push 0xc(%ebp) + 23f: 89 c3 mov %eax,%ebx + 241: 50 push %eax + 242: e8 cc 00 00 00 call 313 + close(fd); + 247: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 24a: 89 c6 mov %eax,%esi + close(fd); + 24c: e8 2a 01 00 00 call 37b + return r; + 251: 83 c4 10 add $0x10,%esp +} + 254: 8d 65 f8 lea -0x8(%ebp),%esp + 257: 89 f0 mov %esi,%eax + 259: 5b pop %ebx + 25a: 5e pop %esi + 25b: 5d pop %ebp + 25c: c3 ret + 25d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 260: be ff ff ff ff mov $0xffffffff,%esi + 265: eb ed jmp 254 + 267: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26e: 66 90 xchg %ax,%ax + +00000270 : + +int atoi(const char *s) { + 270: 55 push %ebp + 271: 89 e5 mov %esp,%ebp + 273: 53 push %ebx + 274: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 277: 0f be 02 movsbl (%edx),%eax + 27a: 8d 48 d0 lea -0x30(%eax),%ecx + 27d: 80 f9 09 cmp $0x9,%cl + n = 0; + 280: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 285: 77 1e ja 2a5 + 287: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 28e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 290: 83 c2 01 add $0x1,%edx + 293: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 296: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 29a: 0f be 02 movsbl (%edx),%eax + 29d: 8d 58 d0 lea -0x30(%eax),%ebx + 2a0: 80 fb 09 cmp $0x9,%bl + 2a3: 76 eb jbe 290 + } + return n; +} + 2a5: 8b 5d fc mov -0x4(%ebp),%ebx + 2a8: 89 c8 mov %ecx,%eax + 2aa: c9 leave + 2ab: c3 ret + 2ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000002b0 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 2b0: 55 push %ebp + 2b1: 89 e5 mov %esp,%ebp + 2b3: 57 push %edi + 2b4: 8b 45 10 mov 0x10(%ebp),%eax + 2b7: 8b 55 08 mov 0x8(%ebp),%edx + 2ba: 56 push %esi + 2bb: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 2be: 85 c0 test %eax,%eax + 2c0: 7e 13 jle 2d5 + 2c2: 01 d0 add %edx,%eax + dst = vdst; + 2c4: 89 d7 mov %edx,%edi + 2c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2cd: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 2d0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 2d1: 39 f8 cmp %edi,%eax + 2d3: 75 fb jne 2d0 + } + return vdst; +} + 2d5: 5e pop %esi + 2d6: 89 d0 mov %edx,%eax + 2d8: 5f pop %edi + 2d9: 5d pop %ebp + 2da: c3 ret + +000002db : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 2db: b8 01 00 00 00 mov $0x1,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(exit) + 2e3: b8 02 00 00 00 mov $0x2,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(wait) + 2eb: b8 03 00 00 00 mov $0x3,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(pipe) + 2f3: b8 04 00 00 00 mov $0x4,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(read) + 2fb: b8 05 00 00 00 mov $0x5,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(kill) + 303: b8 06 00 00 00 mov $0x6,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(exec) + 30b: b8 07 00 00 00 mov $0x7,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(fstat) + 313: b8 08 00 00 00 mov $0x8,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(chdir) + 31b: b8 09 00 00 00 mov $0x9,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(dup) + 323: b8 0a 00 00 00 mov $0xa,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(getpid) + 32b: b8 0b 00 00 00 mov $0xb,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(sbrk) + 333: b8 0c 00 00 00 mov $0xc,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(sleep) + 33b: b8 0d 00 00 00 mov $0xd,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(uptime) + 343: b8 0e 00 00 00 mov $0xe,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + +0000034b : +SYSCALL(open) + 34b: b8 0f 00 00 00 mov $0xf,%eax + 350: cd 40 int $0x40 + 352: c3 ret + +00000353 : +SYSCALL(write) + 353: b8 10 00 00 00 mov $0x10,%eax + 358: cd 40 int $0x40 + 35a: c3 ret + +0000035b : +SYSCALL(mknod) + 35b: b8 11 00 00 00 mov $0x11,%eax + 360: cd 40 int $0x40 + 362: c3 ret + +00000363 : +SYSCALL(unlink) + 363: b8 12 00 00 00 mov $0x12,%eax + 368: cd 40 int $0x40 + 36a: c3 ret + +0000036b : +SYSCALL(link) + 36b: b8 13 00 00 00 mov $0x13,%eax + 370: cd 40 int $0x40 + 372: c3 ret + +00000373 : +SYSCALL(mkdir) + 373: b8 14 00 00 00 mov $0x14,%eax + 378: cd 40 int $0x40 + 37a: c3 ret + +0000037b : +SYSCALL(close) + 37b: b8 15 00 00 00 mov $0x15,%eax + 380: cd 40 int $0x40 + 382: c3 ret + +00000383 : +SYSCALL(getch) + 383: b8 16 00 00 00 mov $0x16,%eax + 388: cd 40 int $0x40 + 38a: c3 ret + +0000038b : +SYSCALL(greeting) + 38b: b8 17 00 00 00 mov $0x17,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(shutdown) + 393: b8 18 00 00 00 mov $0x18,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + +0000039b : +SYSCALL(screen) + 39b: b8 19 00 00 00 mov $0x19,%eax + 3a0: cd 40 int $0x40 + 3a2: c3 ret + +000003a3 : +SYSCALL(cls) + 3a3: b8 1a 00 00 00 mov $0x1a,%eax + 3a8: cd 40 int $0x40 + 3aa: c3 ret + 3ab: 66 90 xchg %ax,%ax + 3ad: 66 90 xchg %ax,%ax + 3af: 90 nop + +000003b0 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 3b0: 55 push %ebp + 3b1: 89 e5 mov %esp,%ebp + 3b3: 57 push %edi + 3b4: 56 push %esi + 3b5: 53 push %ebx + 3b6: 83 ec 3c sub $0x3c,%esp + 3b9: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 3bc: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 3be: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 3c1: 85 d2 test %edx,%edx + 3c3: 0f 89 7f 00 00 00 jns 448 + 3c9: f6 45 08 01 testb $0x1,0x8(%ebp) + 3cd: 74 79 je 448 + neg = 1; + 3cf: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 3d6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 3d8: 31 db xor %ebx,%ebx + 3da: 8d 75 d7 lea -0x29(%ebp),%esi + 3dd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 3e0: 89 c8 mov %ecx,%eax + 3e2: 31 d2 xor %edx,%edx + 3e4: 89 cf mov %ecx,%edi + 3e6: f7 75 c4 divl -0x3c(%ebp) + 3e9: 0f b6 92 0c 08 00 00 movzbl 0x80c(%edx),%edx + 3f0: 89 45 c0 mov %eax,-0x40(%ebp) + 3f3: 89 d8 mov %ebx,%eax + 3f5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 3f8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 3fb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 3fe: 39 7d c4 cmp %edi,-0x3c(%ebp) + 401: 76 dd jbe 3e0 + if (neg) { + 403: 8b 4d bc mov -0x44(%ebp),%ecx + 406: 85 c9 test %ecx,%ecx + 408: 74 0c je 416 + buf[i++] = '-'; + 40a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 40f: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 411: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 416: 8b 7d b8 mov -0x48(%ebp),%edi + 419: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 41d: eb 07 jmp 426 + 41f: 90 nop + putc(fd, buf[i]); + 420: 0f b6 13 movzbl (%ebx),%edx + 423: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 426: 83 ec 04 sub $0x4,%esp + 429: 88 55 d7 mov %dl,-0x29(%ebp) + 42c: 6a 01 push $0x1 + 42e: 56 push %esi + 42f: 57 push %edi + 430: e8 1e ff ff ff call 353 + while (--i >= 0) { + 435: 83 c4 10 add $0x10,%esp + 438: 39 de cmp %ebx,%esi + 43a: 75 e4 jne 420 + } +} + 43c: 8d 65 f4 lea -0xc(%ebp),%esp + 43f: 5b pop %ebx + 440: 5e pop %esi + 441: 5f pop %edi + 442: 5d pop %ebp + 443: c3 ret + 444: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 448: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 44f: eb 87 jmp 3d8 + 451: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 458: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 45f: 90 nop + +00000460 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 460: 55 push %ebp + 461: 89 e5 mov %esp,%ebp + 463: 57 push %edi + 464: 56 push %esi + 465: 53 push %ebx + 466: 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++) { + 469: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 46c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 46f: 0f b6 13 movzbl (%ebx),%edx + 472: 84 d2 test %dl,%dl + 474: 74 6a je 4e0 + ap = (uint*)(void*)&fmt + 1; + 476: 8d 45 10 lea 0x10(%ebp),%eax + 479: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 47c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 47f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 481: 89 45 d0 mov %eax,-0x30(%ebp) + 484: eb 36 jmp 4bc + 486: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 48d: 8d 76 00 lea 0x0(%esi),%esi + 490: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 493: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 498: 83 f8 25 cmp $0x25,%eax + 49b: 74 15 je 4b2 + write(fd, &c, 1); + 49d: 83 ec 04 sub $0x4,%esp + 4a0: 88 55 e7 mov %dl,-0x19(%ebp) + 4a3: 6a 01 push $0x1 + 4a5: 57 push %edi + 4a6: 56 push %esi + 4a7: e8 a7 fe ff ff call 353 + 4ac: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 4af: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 4b2: 0f b6 13 movzbl (%ebx),%edx + 4b5: 83 c3 01 add $0x1,%ebx + 4b8: 84 d2 test %dl,%dl + 4ba: 74 24 je 4e0 + c = fmt[i] & 0xff; + 4bc: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 4bf: 85 c9 test %ecx,%ecx + 4c1: 74 cd je 490 + } + } + else if (state == '%') { + 4c3: 83 f9 25 cmp $0x25,%ecx + 4c6: 75 ea jne 4b2 + if (c == 'd') { + 4c8: 83 f8 25 cmp $0x25,%eax + 4cb: 0f 84 07 01 00 00 je 5d8 + 4d1: 83 e8 63 sub $0x63,%eax + 4d4: 83 f8 15 cmp $0x15,%eax + 4d7: 77 17 ja 4f0 + 4d9: ff 24 85 b4 07 00 00 jmp *0x7b4(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 4e0: 8d 65 f4 lea -0xc(%ebp),%esp + 4e3: 5b pop %ebx + 4e4: 5e pop %esi + 4e5: 5f pop %edi + 4e6: 5d pop %ebp + 4e7: c3 ret + 4e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4ef: 90 nop + write(fd, &c, 1); + 4f0: 83 ec 04 sub $0x4,%esp + 4f3: 88 55 d4 mov %dl,-0x2c(%ebp) + 4f6: 6a 01 push $0x1 + 4f8: 57 push %edi + 4f9: 56 push %esi + 4fa: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 4fe: e8 50 fe ff ff call 353 + putc(fd, c); + 503: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 507: 83 c4 0c add $0xc,%esp + 50a: 88 55 e7 mov %dl,-0x19(%ebp) + 50d: 6a 01 push $0x1 + 50f: 57 push %edi + 510: 56 push %esi + 511: e8 3d fe ff ff call 353 + putc(fd, c); + 516: 83 c4 10 add $0x10,%esp + state = 0; + 519: 31 c9 xor %ecx,%ecx + 51b: eb 95 jmp 4b2 + 51d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 520: 83 ec 0c sub $0xc,%esp + 523: b9 10 00 00 00 mov $0x10,%ecx + 528: 6a 00 push $0x0 + 52a: 8b 45 d0 mov -0x30(%ebp),%eax + 52d: 8b 10 mov (%eax),%edx + 52f: 89 f0 mov %esi,%eax + 531: e8 7a fe ff ff call 3b0 + ap++; + 536: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 53a: 83 c4 10 add $0x10,%esp + state = 0; + 53d: 31 c9 xor %ecx,%ecx + 53f: e9 6e ff ff ff jmp 4b2 + 544: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 548: 8b 45 d0 mov -0x30(%ebp),%eax + 54b: 8b 10 mov (%eax),%edx + ap++; + 54d: 83 c0 04 add $0x4,%eax + 550: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 553: 85 d2 test %edx,%edx + 555: 0f 84 8d 00 00 00 je 5e8 + while (*s != 0) { + 55b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 55e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 560: 84 c0 test %al,%al + 562: 0f 84 4a ff ff ff je 4b2 + 568: 89 5d d4 mov %ebx,-0x2c(%ebp) + 56b: 89 d3 mov %edx,%ebx + 56d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 570: 83 ec 04 sub $0x4,%esp + s++; + 573: 83 c3 01 add $0x1,%ebx + 576: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 579: 6a 01 push $0x1 + 57b: 57 push %edi + 57c: 56 push %esi + 57d: e8 d1 fd ff ff call 353 + while (*s != 0) { + 582: 0f b6 03 movzbl (%ebx),%eax + 585: 83 c4 10 add $0x10,%esp + 588: 84 c0 test %al,%al + 58a: 75 e4 jne 570 + state = 0; + 58c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 58f: 31 c9 xor %ecx,%ecx + 591: e9 1c ff ff ff jmp 4b2 + 596: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 59d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 5a0: 83 ec 0c sub $0xc,%esp + 5a3: b9 0a 00 00 00 mov $0xa,%ecx + 5a8: 6a 01 push $0x1 + 5aa: e9 7b ff ff ff jmp 52a + 5af: 90 nop + putc(fd, *ap); + 5b0: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 5b3: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 5b6: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 5b8: 6a 01 push $0x1 + 5ba: 57 push %edi + 5bb: 56 push %esi + putc(fd, *ap); + 5bc: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 5bf: e8 8f fd ff ff call 353 + ap++; + 5c4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5c8: 83 c4 10 add $0x10,%esp + state = 0; + 5cb: 31 c9 xor %ecx,%ecx + 5cd: e9 e0 fe ff ff jmp 4b2 + 5d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 5d8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 5db: 83 ec 04 sub $0x4,%esp + 5de: e9 2a ff ff ff jmp 50d + 5e3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5e7: 90 nop + s = "(null)"; + 5e8: ba ac 07 00 00 mov $0x7ac,%edx + while (*s != 0) { + 5ed: 89 5d d4 mov %ebx,-0x2c(%ebp) + 5f0: b8 28 00 00 00 mov $0x28,%eax + 5f5: 89 d3 mov %edx,%ebx + 5f7: e9 74 ff ff ff jmp 570 + 5fc: 66 90 xchg %ax,%ax + 5fe: 66 90 xchg %ax,%ax + +00000600 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 600: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 601: a1 c0 0a 00 00 mov 0xac0,%eax +void free(void *ap) { + 606: 89 e5 mov %esp,%ebp + 608: 57 push %edi + 609: 56 push %esi + 60a: 53 push %ebx + 60b: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 60e: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 618: 89 c2 mov %eax,%edx + 61a: 8b 00 mov (%eax),%eax + 61c: 39 ca cmp %ecx,%edx + 61e: 73 30 jae 650 + 620: 39 c1 cmp %eax,%ecx + 622: 72 04 jb 628 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 624: 39 c2 cmp %eax,%edx + 626: 72 f0 jb 618 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 628: 8b 73 fc mov -0x4(%ebx),%esi + 62b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 62e: 39 f8 cmp %edi,%eax + 630: 74 30 je 662 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 632: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 635: 8b 42 04 mov 0x4(%edx),%eax + 638: 8d 34 c2 lea (%edx,%eax,8),%esi + 63b: 39 f1 cmp %esi,%ecx + 63d: 74 3a je 679 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 63f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 641: 5b pop %ebx + freep = p; + 642: 89 15 c0 0a 00 00 mov %edx,0xac0 +} + 648: 5e pop %esi + 649: 5f pop %edi + 64a: 5d pop %ebp + 64b: c3 ret + 64c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 650: 39 c2 cmp %eax,%edx + 652: 72 c4 jb 618 + 654: 39 c1 cmp %eax,%ecx + 656: 73 c0 jae 618 + if (bp + bp->s.size == p->s.ptr) { + 658: 8b 73 fc mov -0x4(%ebx),%esi + 65b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 65e: 39 f8 cmp %edi,%eax + 660: 75 d0 jne 632 + bp->s.size += p->s.ptr->s.size; + 662: 03 70 04 add 0x4(%eax),%esi + 665: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 668: 8b 02 mov (%edx),%eax + 66a: 8b 00 mov (%eax),%eax + 66c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 66f: 8b 42 04 mov 0x4(%edx),%eax + 672: 8d 34 c2 lea (%edx,%eax,8),%esi + 675: 39 f1 cmp %esi,%ecx + 677: 75 c6 jne 63f + p->s.size += bp->s.size; + 679: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 67c: 89 15 c0 0a 00 00 mov %edx,0xac0 + p->s.size += bp->s.size; + 682: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 685: 8b 4b f8 mov -0x8(%ebx),%ecx + 688: 89 0a mov %ecx,(%edx) +} + 68a: 5b pop %ebx + 68b: 5e pop %esi + 68c: 5f pop %edi + 68d: 5d pop %ebp + 68e: c3 ret + 68f: 90 nop + +00000690 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 690: 55 push %ebp + 691: 89 e5 mov %esp,%ebp + 693: 57 push %edi + 694: 56 push %esi + 695: 53 push %ebx + 696: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 699: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 69c: 8b 3d c0 0a 00 00 mov 0xac0,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 6a2: 8d 70 07 lea 0x7(%eax),%esi + 6a5: c1 ee 03 shr $0x3,%esi + 6a8: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 6ab: 85 ff test %edi,%edi + 6ad: 0f 84 9d 00 00 00 je 750 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6b3: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 6b5: 8b 4a 04 mov 0x4(%edx),%ecx + 6b8: 39 f1 cmp %esi,%ecx + 6ba: 73 6a jae 726 + 6bc: bb 00 10 00 00 mov $0x1000,%ebx + 6c1: 39 de cmp %ebx,%esi + 6c3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 6c6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 6cd: 89 45 e4 mov %eax,-0x1c(%ebp) + 6d0: eb 17 jmp 6e9 + 6d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 6d8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 6da: 8b 48 04 mov 0x4(%eax),%ecx + 6dd: 39 f1 cmp %esi,%ecx + 6df: 73 4f jae 730 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 6e1: 8b 3d c0 0a 00 00 mov 0xac0,%edi + 6e7: 89 c2 mov %eax,%edx + 6e9: 39 d7 cmp %edx,%edi + 6eb: 75 eb jne 6d8 + p = sbrk(nu * sizeof(Header)); + 6ed: 83 ec 0c sub $0xc,%esp + 6f0: ff 75 e4 push -0x1c(%ebp) + 6f3: e8 3b fc ff ff call 333 + if (p == (char*)-1) { + 6f8: 83 c4 10 add $0x10,%esp + 6fb: 83 f8 ff cmp $0xffffffff,%eax + 6fe: 74 1c je 71c + hp->s.size = nu; + 700: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 703: 83 ec 0c sub $0xc,%esp + 706: 83 c0 08 add $0x8,%eax + 709: 50 push %eax + 70a: e8 f1 fe ff ff call 600 + return freep; + 70f: 8b 15 c0 0a 00 00 mov 0xac0,%edx + if ((p = morecore(nunits)) == 0) { + 715: 83 c4 10 add $0x10,%esp + 718: 85 d2 test %edx,%edx + 71a: 75 bc jne 6d8 + return 0; + } + } + } +} + 71c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 71f: 31 c0 xor %eax,%eax +} + 721: 5b pop %ebx + 722: 5e pop %esi + 723: 5f pop %edi + 724: 5d pop %ebp + 725: c3 ret + if (p->s.size >= nunits) { + 726: 89 d0 mov %edx,%eax + 728: 89 fa mov %edi,%edx + 72a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 730: 39 ce cmp %ecx,%esi + 732: 74 4c je 780 + p->s.size -= nunits; + 734: 29 f1 sub %esi,%ecx + 736: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 739: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 73c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 73f: 89 15 c0 0a 00 00 mov %edx,0xac0 +} + 745: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 748: 83 c0 08 add $0x8,%eax +} + 74b: 5b pop %ebx + 74c: 5e pop %esi + 74d: 5f pop %edi + 74e: 5d pop %ebp + 74f: c3 ret + base.s.ptr = freep = prevp = &base; + 750: c7 05 c0 0a 00 00 c4 movl $0xac4,0xac0 + 757: 0a 00 00 + base.s.size = 0; + 75a: bf c4 0a 00 00 mov $0xac4,%edi + base.s.ptr = freep = prevp = &base; + 75f: c7 05 c4 0a 00 00 c4 movl $0xac4,0xac4 + 766: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 769: 89 fa mov %edi,%edx + base.s.size = 0; + 76b: c7 05 c8 0a 00 00 00 movl $0x0,0xac8 + 772: 00 00 00 + if (p->s.size >= nunits) { + 775: e9 42 ff ff ff jmp 6bc + 77a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 780: 8b 08 mov (%eax),%ecx + 782: 89 0a mov %ecx,(%edx) + 784: eb b9 jmp 73f diff --git a/shutdown.d b/shutdown.d new file mode 100644 index 0000000..a21cde4 --- /dev/null +++ b/shutdown.d @@ -0,0 +1 @@ +shutdown.o: shutdown.c /usr/include/stdc-predef.h types.h user.h diff --git a/shutdown.o b/shutdown.o new file mode 100644 index 0000000..6832f32 Binary files /dev/null and b/shutdown.o differ diff --git a/shutdown.sym b/shutdown.sym new file mode 100644 index 0000000..e29ee46 --- /dev/null +++ b/shutdown.sym @@ -0,0 +1,50 @@ +00000000 shutdown.c +00000000 ulib.c +00000000 printf.c +000003b0 printint +0000080c digits.0 +00000000 umalloc.c +00000ac0 freep +00000ac4 base +00000090 strcpy +00000460 printf +0000038b greeting +000002b0 memmove +0000035b mknod +000001b0 gets +0000032b getpid +0000039b screen +00000690 malloc +0000033b sleep +000002f3 pipe +00000383 getch +00000353 write +00000313 fstat +00000303 kill +0000031b chdir +0000030b exec +000002eb wait +000002fb read +00000363 unlink +000002db fork +00000333 sbrk +00000343 uptime +00000ac0 __bss_start +00000150 memset +00000000 main +000000c0 strcmp +00000393 shutdown +00000323 dup +00000220 stat +00000ac0 _edata +00000acc _end +0000036b link +000002e3 exit +00000270 atoi +000003a3 cls +00000120 strlen +0000034b open +00000170 strchr +00000373 mkdir +0000037b close +00000600 free diff --git a/sleeplock.d b/sleeplock.d new file mode 100644 index 0000000..e50551a --- /dev/null +++ b/sleeplock.d @@ -0,0 +1,2 @@ +sleeplock.o: sleeplock.c /usr/include/stdc-predef.h types.h defs.h \ + param.h x86.h memlayout.h mmu.h proc.h spinlock.h sleeplock.h diff --git a/sleeplock.o b/sleeplock.o new file mode 100644 index 0000000..713d0e7 Binary files /dev/null and b/sleeplock.o differ diff --git a/spinlock.d b/spinlock.d new file mode 100644 index 0000000..9f70952 --- /dev/null +++ b/spinlock.d @@ -0,0 +1,2 @@ +spinlock.o: spinlock.c /usr/include/stdc-predef.h types.h defs.h param.h \ + x86.h memlayout.h mmu.h proc.h spinlock.h diff --git a/spinlock.o b/spinlock.o new file mode 100644 index 0000000..1d082d1 Binary files /dev/null and b/spinlock.o differ diff --git a/stressfs.asm b/stressfs.asm new file mode 100644 index 0000000..b9166d4 --- /dev/null +++ b/stressfs.asm @@ -0,0 +1,1288 @@ + +_stressfs: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +#include "stat.h" +#include "user.h" +#include "fs.h" +#include "fcntl.h" + +int main(int argc, char *argv[]) { + 0: 8d 4c 24 04 lea 0x4(%esp),%ecx + 4: 83 e4 f0 and $0xfffffff0,%esp + int fd, i; + char path[] = "stressfs0"; + 7: b8 30 00 00 00 mov $0x30,%eax +int main(int argc, char *argv[]) { + c: ff 71 fc push -0x4(%ecx) + f: 55 push %ebp + 10: 89 e5 mov %esp,%ebp + 12: 57 push %edi + 13: 56 push %esi + char data[512]; + + printf(1, "stressfs starting\n"); + memset(data, 'a', sizeof(data)); + 14: 8d b5 e8 fd ff ff lea -0x218(%ebp),%esi +int main(int argc, char *argv[]) { + 1a: 53 push %ebx + + for (i = 0; i < 4; i++) { + 1b: 31 db xor %ebx,%ebx +int main(int argc, char *argv[]) { + 1d: 51 push %ecx + 1e: 81 ec 20 02 00 00 sub $0x220,%esp + char path[] = "stressfs0"; + 24: 66 89 85 e6 fd ff ff mov %ax,-0x21a(%ebp) + printf(1, "stressfs starting\n"); + 2b: 68 38 08 00 00 push $0x838 + 30: 6a 01 push $0x1 + char path[] = "stressfs0"; + 32: c7 85 de fd ff ff 73 movl $0x65727473,-0x222(%ebp) + 39: 74 72 65 + 3c: c7 85 e2 fd ff ff 73 movl $0x73667373,-0x21e(%ebp) + 43: 73 66 73 + printf(1, "stressfs starting\n"); + 46: e8 c5 04 00 00 call 510 + memset(data, 'a', sizeof(data)); + 4b: 83 c4 0c add $0xc,%esp + 4e: 68 00 02 00 00 push $0x200 + 53: 6a 61 push $0x61 + 55: 56 push %esi + 56: e8 a5 01 00 00 call 200 + 5b: 83 c4 10 add $0x10,%esp + if (fork() > 0) { + 5e: e8 28 03 00 00 call 38b + 63: 85 c0 test %eax,%eax + 65: 0f 8f bf 00 00 00 jg 12a + for (i = 0; i < 4; i++) { + 6b: 83 c3 01 add $0x1,%ebx + 6e: 83 fb 04 cmp $0x4,%ebx + 71: 75 eb jne 5e + 73: bf 04 00 00 00 mov $0x4,%edi + break; + } + } + + printf(1, "write %d\n", i); + 78: 83 ec 04 sub $0x4,%esp + 7b: 53 push %ebx + + path[8] += i; + fd = open(path, O_CREATE | O_RDWR); + 7c: bb 14 00 00 00 mov $0x14,%ebx + printf(1, "write %d\n", i); + 81: 68 4b 08 00 00 push $0x84b + 86: 6a 01 push $0x1 + 88: e8 83 04 00 00 call 510 + path[8] += i; + 8d: 89 f8 mov %edi,%eax + fd = open(path, O_CREATE | O_RDWR); + 8f: 5f pop %edi + path[8] += i; + 90: 00 85 e6 fd ff ff add %al,-0x21a(%ebp) + fd = open(path, O_CREATE | O_RDWR); + 96: 58 pop %eax + 97: 8d 85 de fd ff ff lea -0x222(%ebp),%eax + 9d: 68 02 02 00 00 push $0x202 + a2: 50 push %eax + a3: e8 53 03 00 00 call 3fb + a8: 83 c4 10 add $0x10,%esp + ab: 89 c7 mov %eax,%edi + for (i = 0; i < 20; i++) { + ad: 8d 76 00 lea 0x0(%esi),%esi +// printf(fd, "%d\n", i); + write(fd, data, sizeof(data)); + b0: 83 ec 04 sub $0x4,%esp + b3: 68 00 02 00 00 push $0x200 + b8: 56 push %esi + b9: 57 push %edi + ba: e8 44 03 00 00 call 403 + for (i = 0; i < 20; i++) { + bf: 83 c4 10 add $0x10,%esp + c2: 83 eb 01 sub $0x1,%ebx + c5: 75 e9 jne b0 + } + close(fd); + c7: 83 ec 0c sub $0xc,%esp + ca: 57 push %edi + cb: e8 5b 03 00 00 call 42b + + printf(1, "read\n"); + d0: 58 pop %eax + d1: 5a pop %edx + d2: 68 55 08 00 00 push $0x855 + d7: 6a 01 push $0x1 + d9: e8 32 04 00 00 call 510 + + fd = open(path, O_RDONLY); + de: 8d 85 de fd ff ff lea -0x222(%ebp),%eax + e4: 59 pop %ecx + e5: 5b pop %ebx + e6: 6a 00 push $0x0 + e8: bb 14 00 00 00 mov $0x14,%ebx + ed: 50 push %eax + ee: e8 08 03 00 00 call 3fb + f3: 83 c4 10 add $0x10,%esp + f6: 89 c7 mov %eax,%edi + for (i = 0; i < 20; i++) { + f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ff: 90 nop + read(fd, data, sizeof(data)); + 100: 83 ec 04 sub $0x4,%esp + 103: 68 00 02 00 00 push $0x200 + 108: 56 push %esi + 109: 57 push %edi + 10a: e8 9c 02 00 00 call 3ab + for (i = 0; i < 20; i++) { + 10f: 83 c4 10 add $0x10,%esp + 112: 83 eb 01 sub $0x1,%ebx + 115: 75 e9 jne 100 + } + close(fd); + 117: 83 ec 0c sub $0xc,%esp + 11a: 57 push %edi + 11b: e8 0b 03 00 00 call 42b + + wait(); + 120: e8 76 02 00 00 call 39b + + exit(); + 125: e8 69 02 00 00 call 393 + path[8] += i; + 12a: 89 df mov %ebx,%edi + 12c: e9 47 ff ff ff jmp 78 + 131: 66 90 xchg %ax,%ax + 133: 66 90 xchg %ax,%ax + 135: 66 90 xchg %ax,%ax + 137: 66 90 xchg %ax,%ax + 139: 66 90 xchg %ax,%ax + 13b: 66 90 xchg %ax,%ax + 13d: 66 90 xchg %ax,%ax + 13f: 90 nop + +00000140 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 140: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 141: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 143: 89 e5 mov %esp,%ebp + 145: 53 push %ebx + 146: 8b 4d 08 mov 0x8(%ebp),%ecx + 149: 8b 5d 0c mov 0xc(%ebp),%ebx + 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 150: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 154: 88 14 01 mov %dl,(%ecx,%eax,1) + 157: 83 c0 01 add $0x1,%eax + 15a: 84 d2 test %dl,%dl + 15c: 75 f2 jne 150 + ; + } + return os; +} + 15e: 8b 5d fc mov -0x4(%ebp),%ebx + 161: 89 c8 mov %ecx,%eax + 163: c9 leave + 164: c3 ret + 165: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 16c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000170 : + +int strcmp(const char *p, const char *q) { + 170: 55 push %ebp + 171: 89 e5 mov %esp,%ebp + 173: 53 push %ebx + 174: 8b 55 08 mov 0x8(%ebp),%edx + 177: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 17a: 0f b6 02 movzbl (%edx),%eax + 17d: 84 c0 test %al,%al + 17f: 75 17 jne 198 + 181: eb 3a jmp 1bd + 183: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 187: 90 nop + 188: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 18c: 83 c2 01 add $0x1,%edx + 18f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 192: 84 c0 test %al,%al + 194: 74 1a je 1b0 + p++, q++; + 196: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 198: 0f b6 19 movzbl (%ecx),%ebx + 19b: 38 c3 cmp %al,%bl + 19d: 74 e9 je 188 + } + return (uchar) * p - (uchar) * q; + 19f: 29 d8 sub %ebx,%eax +} + 1a1: 8b 5d fc mov -0x4(%ebp),%ebx + 1a4: c9 leave + 1a5: c3 ret + 1a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ad: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 1b0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 1b4: 31 c0 xor %eax,%eax + 1b6: 29 d8 sub %ebx,%eax +} + 1b8: 8b 5d fc mov -0x4(%ebp),%ebx + 1bb: c9 leave + 1bc: c3 ret + return (uchar) * p - (uchar) * q; + 1bd: 0f b6 19 movzbl (%ecx),%ebx + 1c0: 31 c0 xor %eax,%eax + 1c2: eb db jmp 19f + 1c4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1cb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1cf: 90 nop + +000001d0 : + +uint strlen(const char *s) { + 1d0: 55 push %ebp + 1d1: 89 e5 mov %esp,%ebp + 1d3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 1d6: 80 3a 00 cmpb $0x0,(%edx) + 1d9: 74 15 je 1f0 + 1db: 31 c0 xor %eax,%eax + 1dd: 8d 76 00 lea 0x0(%esi),%esi + 1e0: 83 c0 01 add $0x1,%eax + 1e3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 1e7: 89 c1 mov %eax,%ecx + 1e9: 75 f5 jne 1e0 + ; + } + return n; +} + 1eb: 89 c8 mov %ecx,%eax + 1ed: 5d pop %ebp + 1ee: c3 ret + 1ef: 90 nop + for (n = 0; s[n]; n++) { + 1f0: 31 c9 xor %ecx,%ecx +} + 1f2: 5d pop %ebp + 1f3: 89 c8 mov %ecx,%eax + 1f5: c3 ret + 1f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1fd: 8d 76 00 lea 0x0(%esi),%esi + +00000200 : + +void* memset(void *dst, int c, uint n) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 57 push %edi + 204: 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" : + 207: 8b 4d 10 mov 0x10(%ebp),%ecx + 20a: 8b 45 0c mov 0xc(%ebp),%eax + 20d: 89 d7 mov %edx,%edi + 20f: fc cld + 210: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 212: 8b 7d fc mov -0x4(%ebp),%edi + 215: 89 d0 mov %edx,%eax + 217: c9 leave + 218: c3 ret + 219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000220 : + +char* strchr(const char *s, char c) { + 220: 55 push %ebp + 221: 89 e5 mov %esp,%ebp + 223: 8b 45 08 mov 0x8(%ebp),%eax + 226: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 22a: 0f b6 10 movzbl (%eax),%edx + 22d: 84 d2 test %dl,%dl + 22f: 75 12 jne 243 + 231: eb 1d jmp 250 + 233: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 237: 90 nop + 238: 0f b6 50 01 movzbl 0x1(%eax),%edx + 23c: 83 c0 01 add $0x1,%eax + 23f: 84 d2 test %dl,%dl + 241: 74 0d je 250 + if (*s == c) { + 243: 38 d1 cmp %dl,%cl + 245: 75 f1 jne 238 + return (char*)s; + } + } + return 0; +} + 247: 5d pop %ebp + 248: c3 ret + 249: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 250: 31 c0 xor %eax,%eax +} + 252: 5d pop %ebp + 253: c3 ret + 254: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 25b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 25f: 90 nop + +00000260 : + +char* gets(char *buf, int max) { + 260: 55 push %ebp + 261: 89 e5 mov %esp,%ebp + 263: 57 push %edi + 264: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 265: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 268: 53 push %ebx + for (i = 0; i + 1 < max;) { + 269: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 26b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 26e: eb 27 jmp 297 + cc = read(0, &c, 1); + 270: 83 ec 04 sub $0x4,%esp + 273: 6a 01 push $0x1 + 275: 57 push %edi + 276: 6a 00 push $0x0 + 278: e8 2e 01 00 00 call 3ab + if (cc < 1) { + 27d: 83 c4 10 add $0x10,%esp + 280: 85 c0 test %eax,%eax + 282: 7e 1d jle 2a1 + break; + } + buf[i++] = c; + 284: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 288: 8b 55 08 mov 0x8(%ebp),%edx + 28b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 28f: 3c 0a cmp $0xa,%al + 291: 74 1d je 2b0 + 293: 3c 0d cmp $0xd,%al + 295: 74 19 je 2b0 + for (i = 0; i + 1 < max;) { + 297: 89 de mov %ebx,%esi + 299: 83 c3 01 add $0x1,%ebx + 29c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 29f: 7c cf jl 270 + break; + } + } + buf[i] = '\0'; + 2a1: 8b 45 08 mov 0x8(%ebp),%eax + 2a4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 2a8: 8d 65 f4 lea -0xc(%ebp),%esp + 2ab: 5b pop %ebx + 2ac: 5e pop %esi + 2ad: 5f pop %edi + 2ae: 5d pop %ebp + 2af: c3 ret + buf[i] = '\0'; + 2b0: 8b 45 08 mov 0x8(%ebp),%eax + 2b3: 89 de mov %ebx,%esi + 2b5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 2b9: 8d 65 f4 lea -0xc(%ebp),%esp + 2bc: 5b pop %ebx + 2bd: 5e pop %esi + 2be: 5f pop %edi + 2bf: 5d pop %ebp + 2c0: c3 ret + 2c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2cf: 90 nop + +000002d0 : + +int stat(const char *n, struct stat *st) { + 2d0: 55 push %ebp + 2d1: 89 e5 mov %esp,%ebp + 2d3: 56 push %esi + 2d4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 2d5: 83 ec 08 sub $0x8,%esp + 2d8: 6a 00 push $0x0 + 2da: ff 75 08 push 0x8(%ebp) + 2dd: e8 19 01 00 00 call 3fb + if (fd < 0) { + 2e2: 83 c4 10 add $0x10,%esp + 2e5: 85 c0 test %eax,%eax + 2e7: 78 27 js 310 + return -1; + } + r = fstat(fd, st); + 2e9: 83 ec 08 sub $0x8,%esp + 2ec: ff 75 0c push 0xc(%ebp) + 2ef: 89 c3 mov %eax,%ebx + 2f1: 50 push %eax + 2f2: e8 cc 00 00 00 call 3c3 + close(fd); + 2f7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 2fa: 89 c6 mov %eax,%esi + close(fd); + 2fc: e8 2a 01 00 00 call 42b + return r; + 301: 83 c4 10 add $0x10,%esp +} + 304: 8d 65 f8 lea -0x8(%ebp),%esp + 307: 89 f0 mov %esi,%eax + 309: 5b pop %ebx + 30a: 5e pop %esi + 30b: 5d pop %ebp + 30c: c3 ret + 30d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 310: be ff ff ff ff mov $0xffffffff,%esi + 315: eb ed jmp 304 + 317: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 31e: 66 90 xchg %ax,%ax + +00000320 : + +int atoi(const char *s) { + 320: 55 push %ebp + 321: 89 e5 mov %esp,%ebp + 323: 53 push %ebx + 324: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 327: 0f be 02 movsbl (%edx),%eax + 32a: 8d 48 d0 lea -0x30(%eax),%ecx + 32d: 80 f9 09 cmp $0x9,%cl + n = 0; + 330: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 335: 77 1e ja 355 + 337: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 33e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 340: 83 c2 01 add $0x1,%edx + 343: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 346: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 34a: 0f be 02 movsbl (%edx),%eax + 34d: 8d 58 d0 lea -0x30(%eax),%ebx + 350: 80 fb 09 cmp $0x9,%bl + 353: 76 eb jbe 340 + } + return n; +} + 355: 8b 5d fc mov -0x4(%ebp),%ebx + 358: 89 c8 mov %ecx,%eax + 35a: c9 leave + 35b: c3 ret + 35c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000360 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 360: 55 push %ebp + 361: 89 e5 mov %esp,%ebp + 363: 57 push %edi + 364: 8b 45 10 mov 0x10(%ebp),%eax + 367: 8b 55 08 mov 0x8(%ebp),%edx + 36a: 56 push %esi + 36b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 36e: 85 c0 test %eax,%eax + 370: 7e 13 jle 385 + 372: 01 d0 add %edx,%eax + dst = vdst; + 374: 89 d7 mov %edx,%edi + 376: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 37d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 380: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 381: 39 f8 cmp %edi,%eax + 383: 75 fb jne 380 + } + return vdst; +} + 385: 5e pop %esi + 386: 89 d0 mov %edx,%eax + 388: 5f pop %edi + 389: 5d pop %ebp + 38a: c3 ret + +0000038b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 38b: b8 01 00 00 00 mov $0x1,%eax + 390: cd 40 int $0x40 + 392: c3 ret + +00000393 : +SYSCALL(exit) + 393: b8 02 00 00 00 mov $0x2,%eax + 398: cd 40 int $0x40 + 39a: c3 ret + +0000039b : +SYSCALL(wait) + 39b: b8 03 00 00 00 mov $0x3,%eax + 3a0: cd 40 int $0x40 + 3a2: c3 ret + +000003a3 : +SYSCALL(pipe) + 3a3: b8 04 00 00 00 mov $0x4,%eax + 3a8: cd 40 int $0x40 + 3aa: c3 ret + +000003ab : +SYSCALL(read) + 3ab: b8 05 00 00 00 mov $0x5,%eax + 3b0: cd 40 int $0x40 + 3b2: c3 ret + +000003b3 : +SYSCALL(kill) + 3b3: b8 06 00 00 00 mov $0x6,%eax + 3b8: cd 40 int $0x40 + 3ba: c3 ret + +000003bb : +SYSCALL(exec) + 3bb: b8 07 00 00 00 mov $0x7,%eax + 3c0: cd 40 int $0x40 + 3c2: c3 ret + +000003c3 : +SYSCALL(fstat) + 3c3: b8 08 00 00 00 mov $0x8,%eax + 3c8: cd 40 int $0x40 + 3ca: c3 ret + +000003cb : +SYSCALL(chdir) + 3cb: b8 09 00 00 00 mov $0x9,%eax + 3d0: cd 40 int $0x40 + 3d2: c3 ret + +000003d3 : +SYSCALL(dup) + 3d3: b8 0a 00 00 00 mov $0xa,%eax + 3d8: cd 40 int $0x40 + 3da: c3 ret + +000003db : +SYSCALL(getpid) + 3db: b8 0b 00 00 00 mov $0xb,%eax + 3e0: cd 40 int $0x40 + 3e2: c3 ret + +000003e3 : +SYSCALL(sbrk) + 3e3: b8 0c 00 00 00 mov $0xc,%eax + 3e8: cd 40 int $0x40 + 3ea: c3 ret + +000003eb : +SYSCALL(sleep) + 3eb: b8 0d 00 00 00 mov $0xd,%eax + 3f0: cd 40 int $0x40 + 3f2: c3 ret + +000003f3 : +SYSCALL(uptime) + 3f3: b8 0e 00 00 00 mov $0xe,%eax + 3f8: cd 40 int $0x40 + 3fa: c3 ret + +000003fb : +SYSCALL(open) + 3fb: b8 0f 00 00 00 mov $0xf,%eax + 400: cd 40 int $0x40 + 402: c3 ret + +00000403 : +SYSCALL(write) + 403: b8 10 00 00 00 mov $0x10,%eax + 408: cd 40 int $0x40 + 40a: c3 ret + +0000040b : +SYSCALL(mknod) + 40b: b8 11 00 00 00 mov $0x11,%eax + 410: cd 40 int $0x40 + 412: c3 ret + +00000413 : +SYSCALL(unlink) + 413: b8 12 00 00 00 mov $0x12,%eax + 418: cd 40 int $0x40 + 41a: c3 ret + +0000041b : +SYSCALL(link) + 41b: b8 13 00 00 00 mov $0x13,%eax + 420: cd 40 int $0x40 + 422: c3 ret + +00000423 : +SYSCALL(mkdir) + 423: b8 14 00 00 00 mov $0x14,%eax + 428: cd 40 int $0x40 + 42a: c3 ret + +0000042b : +SYSCALL(close) + 42b: b8 15 00 00 00 mov $0x15,%eax + 430: cd 40 int $0x40 + 432: c3 ret + +00000433 : +SYSCALL(getch) + 433: b8 16 00 00 00 mov $0x16,%eax + 438: cd 40 int $0x40 + 43a: c3 ret + +0000043b : +SYSCALL(greeting) + 43b: b8 17 00 00 00 mov $0x17,%eax + 440: cd 40 int $0x40 + 442: c3 ret + +00000443 : +SYSCALL(shutdown) + 443: b8 18 00 00 00 mov $0x18,%eax + 448: cd 40 int $0x40 + 44a: c3 ret + +0000044b : +SYSCALL(screen) + 44b: b8 19 00 00 00 mov $0x19,%eax + 450: cd 40 int $0x40 + 452: c3 ret + +00000453 : +SYSCALL(cls) + 453: b8 1a 00 00 00 mov $0x1a,%eax + 458: cd 40 int $0x40 + 45a: c3 ret + 45b: 66 90 xchg %ax,%ax + 45d: 66 90 xchg %ax,%ax + 45f: 90 nop + +00000460 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 460: 55 push %ebp + 461: 89 e5 mov %esp,%ebp + 463: 57 push %edi + 464: 56 push %esi + 465: 53 push %ebx + 466: 83 ec 3c sub $0x3c,%esp + 469: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 46c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 46e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 471: 85 d2 test %edx,%edx + 473: 0f 89 7f 00 00 00 jns 4f8 + 479: f6 45 08 01 testb $0x1,0x8(%ebp) + 47d: 74 79 je 4f8 + neg = 1; + 47f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 486: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 488: 31 db xor %ebx,%ebx + 48a: 8d 75 d7 lea -0x29(%ebp),%esi + 48d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 490: 89 c8 mov %ecx,%eax + 492: 31 d2 xor %edx,%edx + 494: 89 cf mov %ecx,%edi + 496: f7 75 c4 divl -0x3c(%ebp) + 499: 0f b6 92 bc 08 00 00 movzbl 0x8bc(%edx),%edx + 4a0: 89 45 c0 mov %eax,-0x40(%ebp) + 4a3: 89 d8 mov %ebx,%eax + 4a5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 4a8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 4ab: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 4ae: 39 7d c4 cmp %edi,-0x3c(%ebp) + 4b1: 76 dd jbe 490 + if (neg) { + 4b3: 8b 4d bc mov -0x44(%ebp),%ecx + 4b6: 85 c9 test %ecx,%ecx + 4b8: 74 0c je 4c6 + buf[i++] = '-'; + 4ba: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 4bf: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 4c1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 4c6: 8b 7d b8 mov -0x48(%ebp),%edi + 4c9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 4cd: eb 07 jmp 4d6 + 4cf: 90 nop + putc(fd, buf[i]); + 4d0: 0f b6 13 movzbl (%ebx),%edx + 4d3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 4d6: 83 ec 04 sub $0x4,%esp + 4d9: 88 55 d7 mov %dl,-0x29(%ebp) + 4dc: 6a 01 push $0x1 + 4de: 56 push %esi + 4df: 57 push %edi + 4e0: e8 1e ff ff ff call 403 + while (--i >= 0) { + 4e5: 83 c4 10 add $0x10,%esp + 4e8: 39 de cmp %ebx,%esi + 4ea: 75 e4 jne 4d0 + } +} + 4ec: 8d 65 f4 lea -0xc(%ebp),%esp + 4ef: 5b pop %ebx + 4f0: 5e pop %esi + 4f1: 5f pop %edi + 4f2: 5d pop %ebp + 4f3: c3 ret + 4f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 4f8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 4ff: eb 87 jmp 488 + 501: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 508: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 50f: 90 nop + +00000510 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 510: 55 push %ebp + 511: 89 e5 mov %esp,%ebp + 513: 57 push %edi + 514: 56 push %esi + 515: 53 push %ebx + 516: 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++) { + 519: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 51c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 51f: 0f b6 13 movzbl (%ebx),%edx + 522: 84 d2 test %dl,%dl + 524: 74 6a je 590 + ap = (uint*)(void*)&fmt + 1; + 526: 8d 45 10 lea 0x10(%ebp),%eax + 529: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 52c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 52f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 531: 89 45 d0 mov %eax,-0x30(%ebp) + 534: eb 36 jmp 56c + 536: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 53d: 8d 76 00 lea 0x0(%esi),%esi + 540: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 543: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 548: 83 f8 25 cmp $0x25,%eax + 54b: 74 15 je 562 + write(fd, &c, 1); + 54d: 83 ec 04 sub $0x4,%esp + 550: 88 55 e7 mov %dl,-0x19(%ebp) + 553: 6a 01 push $0x1 + 555: 57 push %edi + 556: 56 push %esi + 557: e8 a7 fe ff ff call 403 + 55c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 55f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 562: 0f b6 13 movzbl (%ebx),%edx + 565: 83 c3 01 add $0x1,%ebx + 568: 84 d2 test %dl,%dl + 56a: 74 24 je 590 + c = fmt[i] & 0xff; + 56c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 56f: 85 c9 test %ecx,%ecx + 571: 74 cd je 540 + } + } + else if (state == '%') { + 573: 83 f9 25 cmp $0x25,%ecx + 576: 75 ea jne 562 + if (c == 'd') { + 578: 83 f8 25 cmp $0x25,%eax + 57b: 0f 84 07 01 00 00 je 688 + 581: 83 e8 63 sub $0x63,%eax + 584: 83 f8 15 cmp $0x15,%eax + 587: 77 17 ja 5a0 + 589: ff 24 85 64 08 00 00 jmp *0x864(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 590: 8d 65 f4 lea -0xc(%ebp),%esp + 593: 5b pop %ebx + 594: 5e pop %esi + 595: 5f pop %edi + 596: 5d pop %ebp + 597: c3 ret + 598: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 59f: 90 nop + write(fd, &c, 1); + 5a0: 83 ec 04 sub $0x4,%esp + 5a3: 88 55 d4 mov %dl,-0x2c(%ebp) + 5a6: 6a 01 push $0x1 + 5a8: 57 push %edi + 5a9: 56 push %esi + 5aa: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 5ae: e8 50 fe ff ff call 403 + putc(fd, c); + 5b3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 5b7: 83 c4 0c add $0xc,%esp + 5ba: 88 55 e7 mov %dl,-0x19(%ebp) + 5bd: 6a 01 push $0x1 + 5bf: 57 push %edi + 5c0: 56 push %esi + 5c1: e8 3d fe ff ff call 403 + putc(fd, c); + 5c6: 83 c4 10 add $0x10,%esp + state = 0; + 5c9: 31 c9 xor %ecx,%ecx + 5cb: eb 95 jmp 562 + 5cd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 5d0: 83 ec 0c sub $0xc,%esp + 5d3: b9 10 00 00 00 mov $0x10,%ecx + 5d8: 6a 00 push $0x0 + 5da: 8b 45 d0 mov -0x30(%ebp),%eax + 5dd: 8b 10 mov (%eax),%edx + 5df: 89 f0 mov %esi,%eax + 5e1: e8 7a fe ff ff call 460 + ap++; + 5e6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 5ea: 83 c4 10 add $0x10,%esp + state = 0; + 5ed: 31 c9 xor %ecx,%ecx + 5ef: e9 6e ff ff ff jmp 562 + 5f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 5f8: 8b 45 d0 mov -0x30(%ebp),%eax + 5fb: 8b 10 mov (%eax),%edx + ap++; + 5fd: 83 c0 04 add $0x4,%eax + 600: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 603: 85 d2 test %edx,%edx + 605: 0f 84 8d 00 00 00 je 698 + while (*s != 0) { + 60b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 60e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 610: 84 c0 test %al,%al + 612: 0f 84 4a ff ff ff je 562 + 618: 89 5d d4 mov %ebx,-0x2c(%ebp) + 61b: 89 d3 mov %edx,%ebx + 61d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 620: 83 ec 04 sub $0x4,%esp + s++; + 623: 83 c3 01 add $0x1,%ebx + 626: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 629: 6a 01 push $0x1 + 62b: 57 push %edi + 62c: 56 push %esi + 62d: e8 d1 fd ff ff call 403 + while (*s != 0) { + 632: 0f b6 03 movzbl (%ebx),%eax + 635: 83 c4 10 add $0x10,%esp + 638: 84 c0 test %al,%al + 63a: 75 e4 jne 620 + state = 0; + 63c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 63f: 31 c9 xor %ecx,%ecx + 641: e9 1c ff ff ff jmp 562 + 646: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 64d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 650: 83 ec 0c sub $0xc,%esp + 653: b9 0a 00 00 00 mov $0xa,%ecx + 658: 6a 01 push $0x1 + 65a: e9 7b ff ff ff jmp 5da + 65f: 90 nop + putc(fd, *ap); + 660: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 663: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 666: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 668: 6a 01 push $0x1 + 66a: 57 push %edi + 66b: 56 push %esi + putc(fd, *ap); + 66c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 66f: e8 8f fd ff ff call 403 + ap++; + 674: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 678: 83 c4 10 add $0x10,%esp + state = 0; + 67b: 31 c9 xor %ecx,%ecx + 67d: e9 e0 fe ff ff jmp 562 + 682: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 688: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 68b: 83 ec 04 sub $0x4,%esp + 68e: e9 2a ff ff ff jmp 5bd + 693: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 697: 90 nop + s = "(null)"; + 698: ba 5b 08 00 00 mov $0x85b,%edx + while (*s != 0) { + 69d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 6a0: b8 28 00 00 00 mov $0x28,%eax + 6a5: 89 d3 mov %edx,%ebx + 6a7: e9 74 ff ff ff jmp 620 + 6ac: 66 90 xchg %ax,%ax + 6ae: 66 90 xchg %ax,%ax + +000006b0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 6b0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 6b1: a1 74 0b 00 00 mov 0xb74,%eax +void free(void *ap) { + 6b6: 89 e5 mov %esp,%ebp + 6b8: 57 push %edi + 6b9: 56 push %esi + 6ba: 53 push %ebx + 6bb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 6be: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 6c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 6c8: 89 c2 mov %eax,%edx + 6ca: 8b 00 mov (%eax),%eax + 6cc: 39 ca cmp %ecx,%edx + 6ce: 73 30 jae 700 + 6d0: 39 c1 cmp %eax,%ecx + 6d2: 72 04 jb 6d8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 6d4: 39 c2 cmp %eax,%edx + 6d6: 72 f0 jb 6c8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 6d8: 8b 73 fc mov -0x4(%ebx),%esi + 6db: 8d 3c f1 lea (%ecx,%esi,8),%edi + 6de: 39 f8 cmp %edi,%eax + 6e0: 74 30 je 712 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 6e2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 6e5: 8b 42 04 mov 0x4(%edx),%eax + 6e8: 8d 34 c2 lea (%edx,%eax,8),%esi + 6eb: 39 f1 cmp %esi,%ecx + 6ed: 74 3a je 729 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 6ef: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 6f1: 5b pop %ebx + freep = p; + 6f2: 89 15 74 0b 00 00 mov %edx,0xb74 +} + 6f8: 5e pop %esi + 6f9: 5f pop %edi + 6fa: 5d pop %ebp + 6fb: c3 ret + 6fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 700: 39 c2 cmp %eax,%edx + 702: 72 c4 jb 6c8 + 704: 39 c1 cmp %eax,%ecx + 706: 73 c0 jae 6c8 + if (bp + bp->s.size == p->s.ptr) { + 708: 8b 73 fc mov -0x4(%ebx),%esi + 70b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 70e: 39 f8 cmp %edi,%eax + 710: 75 d0 jne 6e2 + bp->s.size += p->s.ptr->s.size; + 712: 03 70 04 add 0x4(%eax),%esi + 715: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 718: 8b 02 mov (%edx),%eax + 71a: 8b 00 mov (%eax),%eax + 71c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 71f: 8b 42 04 mov 0x4(%edx),%eax + 722: 8d 34 c2 lea (%edx,%eax,8),%esi + 725: 39 f1 cmp %esi,%ecx + 727: 75 c6 jne 6ef + p->s.size += bp->s.size; + 729: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 72c: 89 15 74 0b 00 00 mov %edx,0xb74 + p->s.size += bp->s.size; + 732: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 735: 8b 4b f8 mov -0x8(%ebx),%ecx + 738: 89 0a mov %ecx,(%edx) +} + 73a: 5b pop %ebx + 73b: 5e pop %esi + 73c: 5f pop %edi + 73d: 5d pop %ebp + 73e: c3 ret + 73f: 90 nop + +00000740 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 740: 55 push %ebp + 741: 89 e5 mov %esp,%ebp + 743: 57 push %edi + 744: 56 push %esi + 745: 53 push %ebx + 746: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 749: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 74c: 8b 3d 74 0b 00 00 mov 0xb74,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 752: 8d 70 07 lea 0x7(%eax),%esi + 755: c1 ee 03 shr $0x3,%esi + 758: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 75b: 85 ff test %edi,%edi + 75d: 0f 84 9d 00 00 00 je 800 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 763: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 765: 8b 4a 04 mov 0x4(%edx),%ecx + 768: 39 f1 cmp %esi,%ecx + 76a: 73 6a jae 7d6 + 76c: bb 00 10 00 00 mov $0x1000,%ebx + 771: 39 de cmp %ebx,%esi + 773: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 776: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 77d: 89 45 e4 mov %eax,-0x1c(%ebp) + 780: eb 17 jmp 799 + 782: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 788: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 78a: 8b 48 04 mov 0x4(%eax),%ecx + 78d: 39 f1 cmp %esi,%ecx + 78f: 73 4f jae 7e0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 791: 8b 3d 74 0b 00 00 mov 0xb74,%edi + 797: 89 c2 mov %eax,%edx + 799: 39 d7 cmp %edx,%edi + 79b: 75 eb jne 788 + p = sbrk(nu * sizeof(Header)); + 79d: 83 ec 0c sub $0xc,%esp + 7a0: ff 75 e4 push -0x1c(%ebp) + 7a3: e8 3b fc ff ff call 3e3 + if (p == (char*)-1) { + 7a8: 83 c4 10 add $0x10,%esp + 7ab: 83 f8 ff cmp $0xffffffff,%eax + 7ae: 74 1c je 7cc + hp->s.size = nu; + 7b0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 7b3: 83 ec 0c sub $0xc,%esp + 7b6: 83 c0 08 add $0x8,%eax + 7b9: 50 push %eax + 7ba: e8 f1 fe ff ff call 6b0 + return freep; + 7bf: 8b 15 74 0b 00 00 mov 0xb74,%edx + if ((p = morecore(nunits)) == 0) { + 7c5: 83 c4 10 add $0x10,%esp + 7c8: 85 d2 test %edx,%edx + 7ca: 75 bc jne 788 + return 0; + } + } + } +} + 7cc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 7cf: 31 c0 xor %eax,%eax +} + 7d1: 5b pop %ebx + 7d2: 5e pop %esi + 7d3: 5f pop %edi + 7d4: 5d pop %ebp + 7d5: c3 ret + if (p->s.size >= nunits) { + 7d6: 89 d0 mov %edx,%eax + 7d8: 89 fa mov %edi,%edx + 7da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 7e0: 39 ce cmp %ecx,%esi + 7e2: 74 4c je 830 + p->s.size -= nunits; + 7e4: 29 f1 sub %esi,%ecx + 7e6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 7e9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 7ec: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 7ef: 89 15 74 0b 00 00 mov %edx,0xb74 +} + 7f5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 7f8: 83 c0 08 add $0x8,%eax +} + 7fb: 5b pop %ebx + 7fc: 5e pop %esi + 7fd: 5f pop %edi + 7fe: 5d pop %ebp + 7ff: c3 ret + base.s.ptr = freep = prevp = &base; + 800: c7 05 74 0b 00 00 78 movl $0xb78,0xb74 + 807: 0b 00 00 + base.s.size = 0; + 80a: bf 78 0b 00 00 mov $0xb78,%edi + base.s.ptr = freep = prevp = &base; + 80f: c7 05 78 0b 00 00 78 movl $0xb78,0xb78 + 816: 0b 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 819: 89 fa mov %edi,%edx + base.s.size = 0; + 81b: c7 05 7c 0b 00 00 00 movl $0x0,0xb7c + 822: 00 00 00 + if (p->s.size >= nunits) { + 825: e9 42 ff ff ff jmp 76c + 82a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 830: 8b 08 mov (%eax),%ecx + 832: 89 0a mov %ecx,(%edx) + 834: eb b9 jmp 7ef diff --git a/stressfs.d b/stressfs.d new file mode 100644 index 0000000..7d5de54 --- /dev/null +++ b/stressfs.d @@ -0,0 +1,2 @@ +stressfs.o: stressfs.c /usr/include/stdc-predef.h types.h stat.h user.h \ + fs.h fcntl.h diff --git a/stressfs.o b/stressfs.o new file mode 100644 index 0000000..54dea28 Binary files /dev/null and b/stressfs.o differ diff --git a/stressfs.sym b/stressfs.sym new file mode 100644 index 0000000..8c48447 --- /dev/null +++ b/stressfs.sym @@ -0,0 +1,50 @@ +00000000 stressfs.c +00000000 ulib.c +00000000 printf.c +00000460 printint +000008bc digits.0 +00000000 umalloc.c +00000b74 freep +00000b78 base +00000140 strcpy +00000510 printf +0000043b greeting +00000360 memmove +0000040b mknod +00000260 gets +000003db getpid +0000044b screen +00000740 malloc +000003eb sleep +000003a3 pipe +00000433 getch +00000403 write +000003c3 fstat +000003b3 kill +000003cb chdir +000003bb exec +0000039b wait +000003ab read +00000413 unlink +0000038b fork +000003e3 sbrk +000003f3 uptime +00000b74 __bss_start +00000200 memset +00000000 main +00000170 strcmp +00000443 shutdown +000003d3 dup +000002d0 stat +00000b74 _edata +00000b80 _end +0000041b link +00000393 exit +00000320 atoi +00000453 cls +000001d0 strlen +000003fb open +00000220 strchr +00000423 mkdir +0000042b close +000006b0 free diff --git a/string.d b/string.d new file mode 100644 index 0000000..68931ed --- /dev/null +++ b/string.d @@ -0,0 +1 @@ +string.o: string.c /usr/include/stdc-predef.h types.h x86.h diff --git a/string.o b/string.o new file mode 100644 index 0000000..4431e96 Binary files /dev/null and b/string.o differ diff --git a/swtch.o b/swtch.o new file mode 100644 index 0000000..29c6b7d Binary files /dev/null and b/swtch.o differ diff --git a/syscall.d b/syscall.d new file mode 100644 index 0000000..07012da --- /dev/null +++ b/syscall.d @@ -0,0 +1,2 @@ +syscall.o: syscall.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h syscall.h syscalltable.h diff --git a/syscall.h b/syscall.h new file mode 100644 index 0000000..015ae85 --- /dev/null +++ b/syscall.h @@ -0,0 +1,29 @@ +// Generated by gensyscalls.pl. Do not edit. +// To change syscall numbers or add new syscalls, edit gensyscalls.pl + +#define SYS_fork 1 +#define SYS_exit 2 +#define SYS_wait 3 +#define SYS_pipe 4 +#define SYS_read 5 +#define SYS_kill 6 +#define SYS_exec 7 +#define SYS_fstat 8 +#define SYS_chdir 9 +#define SYS_dup 10 +#define SYS_getpid 11 +#define SYS_sbrk 12 +#define SYS_sleep 13 +#define SYS_uptime 14 +#define SYS_open 15 +#define SYS_write 16 +#define SYS_mknod 17 +#define SYS_unlink 18 +#define SYS_link 19 +#define SYS_mkdir 20 +#define SYS_close 21 +#define SYS_getch 22 +#define SYS_greeting 23 +#define SYS_shutdown 24 +#define SYS_screen 25 +#define SYS_cls 26 diff --git a/syscall.o b/syscall.o new file mode 100644 index 0000000..76526bc Binary files /dev/null and b/syscall.o differ diff --git a/syscalltable.h b/syscalltable.h new file mode 100644 index 0000000..3250768 --- /dev/null +++ b/syscalltable.h @@ -0,0 +1,58 @@ +// Generated by gensyscalls.pl. Do not edit. +// To change syscall numbers or add new syscalls, edit gensyscalls.pl + +extern int sys_fork(void); +extern int sys_exit(void); +extern int sys_wait(void); +extern int sys_pipe(void); +extern int sys_read(void); +extern int sys_kill(void); +extern int sys_exec(void); +extern int sys_fstat(void); +extern int sys_chdir(void); +extern int sys_dup(void); +extern int sys_getpid(void); +extern int sys_sbrk(void); +extern int sys_sleep(void); +extern int sys_uptime(void); +extern int sys_open(void); +extern int sys_write(void); +extern int sys_mknod(void); +extern int sys_unlink(void); +extern int sys_link(void); +extern int sys_mkdir(void); +extern int sys_close(void); +extern int sys_getch(void); +extern int sys_greeting(void); +extern int sys_shutdown(void); +extern int sys_screen(void); +extern int sys_cls(void); + +static int(*syscalls[])(void) = { +[SYS_fork] sys_fork, +[SYS_exit] sys_exit, +[SYS_wait] sys_wait, +[SYS_pipe] sys_pipe, +[SYS_read] sys_read, +[SYS_kill] sys_kill, +[SYS_exec] sys_exec, +[SYS_fstat] sys_fstat, +[SYS_chdir] sys_chdir, +[SYS_dup] sys_dup, +[SYS_getpid] sys_getpid, +[SYS_sbrk] sys_sbrk, +[SYS_sleep] sys_sleep, +[SYS_uptime] sys_uptime, +[SYS_open] sys_open, +[SYS_write] sys_write, +[SYS_mknod] sys_mknod, +[SYS_unlink] sys_unlink, +[SYS_link] sys_link, +[SYS_mkdir] sys_mkdir, +[SYS_close] sys_close, +[SYS_getch] sys_getch, +[SYS_greeting] sys_greeting, +[SYS_shutdown] sys_shutdown, +[SYS_screen] sys_screen, +[SYS_cls] sys_cls, +}; diff --git a/sysfile.d b/sysfile.d new file mode 100644 index 0000000..74f1a20 --- /dev/null +++ b/sysfile.d @@ -0,0 +1,2 @@ +sysfile.o: sysfile.c /usr/include/stdc-predef.h types.h defs.h param.h \ + stat.h mmu.h proc.h fs.h spinlock.h sleeplock.h file.h fcntl.h diff --git a/sysfile.o b/sysfile.o new file mode 100644 index 0000000..69db225 Binary files /dev/null and b/sysfile.o differ diff --git a/sysproc.d b/sysproc.d new file mode 100644 index 0000000..2f26f0c --- /dev/null +++ b/sysproc.d @@ -0,0 +1,2 @@ +sysproc.o: sysproc.c /usr/include/stdc-predef.h types.h x86.h defs.h \ + date.h param.h memlayout.h mmu.h proc.h diff --git a/sysproc.o b/sysproc.o new file mode 100644 index 0000000..615c898 Binary files /dev/null and b/sysproc.o differ diff --git a/trap.d b/trap.d new file mode 100644 index 0000000..c48ab89 --- /dev/null +++ b/trap.d @@ -0,0 +1,2 @@ +trap.o: trap.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h traps.h spinlock.h diff --git a/trap.o b/trap.o new file mode 100644 index 0000000..459d42c Binary files /dev/null and b/trap.o differ diff --git a/trapasm.o b/trapasm.o new file mode 100644 index 0000000..b5ce65b Binary files /dev/null and b/trapasm.o differ diff --git a/uart.d b/uart.d new file mode 100644 index 0000000..d156629 --- /dev/null +++ b/uart.d @@ -0,0 +1,2 @@ +uart.o: uart.c /usr/include/stdc-predef.h types.h defs.h param.h traps.h \ + spinlock.h sleeplock.h fs.h file.h mmu.h proc.h x86.h diff --git a/uart.o b/uart.o new file mode 100644 index 0000000..555950b Binary files /dev/null and b/uart.o differ diff --git a/ulib.d b/ulib.d new file mode 100644 index 0000000..61f575e --- /dev/null +++ b/ulib.d @@ -0,0 +1,2 @@ +ulib.o: ulib.c /usr/include/stdc-predef.h types.h stat.h fcntl.h user.h \ + x86.h diff --git a/ulib.o b/ulib.o new file mode 100644 index 0000000..2a6f7b7 Binary files /dev/null and b/ulib.o differ diff --git a/umalloc.d b/umalloc.d new file mode 100644 index 0000000..cc1d152 --- /dev/null +++ b/umalloc.d @@ -0,0 +1,2 @@ +umalloc.o: umalloc.c /usr/include/stdc-predef.h types.h stat.h user.h \ + param.h diff --git a/umalloc.o b/umalloc.o new file mode 100644 index 0000000..2041a13 Binary files /dev/null and b/umalloc.o differ diff --git a/usertests.asm b/usertests.asm new file mode 100644 index 0000000..5154487 --- /dev/null +++ b/usertests.asm @@ -0,0 +1,6630 @@ + +_usertests: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: +unsigned int rand() { + randstate = randstate * 1664525 + 1013904223; + return randstate; +} + +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: 51 push %ecx + e: 83 ec 0c sub $0xc,%esp + printf(1, "usertests starting\n"); + 11: 68 66 4d 00 00 push $0x4d66 + 16: 6a 01 push $0x1 + 18: e8 33 3a 00 00 call 3a50 + + if (open("usertests.ran", 0) >= 0) { + 1d: 59 pop %ecx + 1e: 58 pop %eax + 1f: 6a 00 push $0x0 + 21: 68 7a 4d 00 00 push $0x4d7a + 26: e8 10 39 00 00 call 393b + 2b: 83 c4 10 add $0x10,%esp + 2e: 85 c0 test %eax,%eax + 30: 78 13 js 45 + printf(1, "already ran user tests -- rebuild fs.img\n"); + 32: 52 push %edx + 33: 52 push %edx + 34: 68 e4 54 00 00 push $0x54e4 + 39: 6a 01 push $0x1 + 3b: e8 10 3a 00 00 call 3a50 + exit(); + 40: e8 8e 38 00 00 call 38d3 + } + close(open("usertests.ran", O_CREATE)); + 45: 50 push %eax + 46: 50 push %eax + 47: 68 00 02 00 00 push $0x200 + 4c: 68 7a 4d 00 00 push $0x4d7a + 51: e8 e5 38 00 00 call 393b + 56: 89 04 24 mov %eax,(%esp) + 59: e8 0d 39 00 00 call 396b + + argptest(); + 5e: e8 8d 35 00 00 call 35f0 + createdelete(); + 63: e8 b8 11 00 00 call 1220 + linkunlink(); + 68: e8 73 1a 00 00 call 1ae0 + concreate(); + 6d: e8 6e 17 00 00 call 17e0 + fourfiles(); + 72: e8 a9 0f 00 00 call 1020 + sharedfd(); + 77: e8 e4 0d 00 00 call e60 + + bigargtest(); + 7c: e8 2f 32 00 00 call 32b0 + bigwrite(); + 81: e8 7a 23 00 00 call 2400 + bigargtest(); + 86: e8 25 32 00 00 call 32b0 + bsstest(); + 8b: e8 b0 31 00 00 call 3240 + sbrktest(); + 90: e8 ab 2c 00 00 call 2d40 + validatetest(); + 95: e8 f6 30 00 00 call 3190 + + opentest(); + 9a: e8 61 03 00 00 call 400 + writetest(); + 9f: e8 ec 03 00 00 call 490 + writetest1(); + a4: e8 c7 05 00 00 call 670 + createtest(); + a9: e8 92 07 00 00 call 840 + + openiputtest(); + ae: e8 4d 02 00 00 call 300 + exitiputtest(); + b3: e8 48 01 00 00 call 200 + iputtest(); + b8: e8 63 00 00 00 call 120 + + mem(); + bd: e8 ce 0c 00 00 call d90 + pipe1(); + c2: e8 59 09 00 00 call a20 + preempt(); + c7: e8 e4 0a 00 00 call bb0 + exitwait(); + cc: e8 3f 0c 00 00 call d10 + + rmdot(); + d1: e8 1a 27 00 00 call 27f0 + fourteen(); + d6: e8 d5 25 00 00 call 26b0 + bigfile(); + db: e8 00 24 00 00 call 24e0 + subdir(); + e0: e8 3b 1c 00 00 call 1d20 + linktest(); + e5: e8 e6 14 00 00 call 15d0 + unlinkread(); + ea: e8 51 13 00 00 call 1440 + dirfile(); + ef: e8 7c 28 00 00 call 2970 + iref(); + f4: e8 77 2a 00 00 call 2b70 + forktest(); + f9: e8 92 2b 00 00 call 2c90 + bigdir(); // slow + fe: e8 ed 1a 00 00 call 1bf0 + + uio(); + 103: e8 78 34 00 00 call 3580 + + exectest(); + 108: e8 c3 08 00 00 call 9d0 + + exit(); + 10d: e8 c1 37 00 00 call 38d3 + 112: 66 90 xchg %ax,%ax + 114: 66 90 xchg %ax,%ax + 116: 66 90 xchg %ax,%ax + 118: 66 90 xchg %ax,%ax + 11a: 66 90 xchg %ax,%ax + 11c: 66 90 xchg %ax,%ax + 11e: 66 90 xchg %ax,%ax + +00000120 : +void iputtest(void) { + 120: 55 push %ebp + 121: 89 e5 mov %esp,%ebp + 123: 83 ec 10 sub $0x10,%esp + printf(stdout, "iput test\n"); + 126: 68 0c 3e 00 00 push $0x3e0c + 12b: ff 35 68 5e 00 00 push 0x5e68 + 131: e8 1a 39 00 00 call 3a50 + if (mkdir("iputdir") < 0) { + 136: c7 04 24 9f 3d 00 00 movl $0x3d9f,(%esp) + 13d: e8 21 38 00 00 call 3963 + 142: 83 c4 10 add $0x10,%esp + 145: 85 c0 test %eax,%eax + 147: 78 58 js 1a1 + if (chdir("iputdir") < 0) { + 149: 83 ec 0c sub $0xc,%esp + 14c: 68 9f 3d 00 00 push $0x3d9f + 151: e8 b5 37 00 00 call 390b + 156: 83 c4 10 add $0x10,%esp + 159: 85 c0 test %eax,%eax + 15b: 0f 88 85 00 00 00 js 1e6 + if (unlink("../iputdir") < 0) { + 161: 83 ec 0c sub $0xc,%esp + 164: 68 9c 3d 00 00 push $0x3d9c + 169: e8 e5 37 00 00 call 3953 + 16e: 83 c4 10 add $0x10,%esp + 171: 85 c0 test %eax,%eax + 173: 78 5a js 1cf + if (chdir("/") < 0) { + 175: 83 ec 0c sub $0xc,%esp + 178: 68 c1 3d 00 00 push $0x3dc1 + 17d: e8 89 37 00 00 call 390b + 182: 83 c4 10 add $0x10,%esp + 185: 85 c0 test %eax,%eax + 187: 78 2f js 1b8 + printf(stdout, "iput test ok\n"); + 189: 83 ec 08 sub $0x8,%esp + 18c: 68 44 3e 00 00 push $0x3e44 + 191: ff 35 68 5e 00 00 push 0x5e68 + 197: e8 b4 38 00 00 call 3a50 +} + 19c: 83 c4 10 add $0x10,%esp + 19f: c9 leave + 1a0: c3 ret + printf(stdout, "mkdir failed\n"); + 1a1: 50 push %eax + 1a2: 50 push %eax + 1a3: 68 78 3d 00 00 push $0x3d78 + 1a8: ff 35 68 5e 00 00 push 0x5e68 + 1ae: e8 9d 38 00 00 call 3a50 + exit(); + 1b3: e8 1b 37 00 00 call 38d3 + printf(stdout, "chdir / failed\n"); + 1b8: 50 push %eax + 1b9: 50 push %eax + 1ba: 68 c3 3d 00 00 push $0x3dc3 + 1bf: ff 35 68 5e 00 00 push 0x5e68 + 1c5: e8 86 38 00 00 call 3a50 + exit(); + 1ca: e8 04 37 00 00 call 38d3 + printf(stdout, "unlink ../iputdir failed\n"); + 1cf: 52 push %edx + 1d0: 52 push %edx + 1d1: 68 a7 3d 00 00 push $0x3da7 + 1d6: ff 35 68 5e 00 00 push 0x5e68 + 1dc: e8 6f 38 00 00 call 3a50 + exit(); + 1e1: e8 ed 36 00 00 call 38d3 + printf(stdout, "chdir iputdir failed\n"); + 1e6: 51 push %ecx + 1e7: 51 push %ecx + 1e8: 68 86 3d 00 00 push $0x3d86 + 1ed: ff 35 68 5e 00 00 push 0x5e68 + 1f3: e8 58 38 00 00 call 3a50 + exit(); + 1f8: e8 d6 36 00 00 call 38d3 + 1fd: 8d 76 00 lea 0x0(%esi),%esi + +00000200 : +void exitiputtest(void) { + 200: 55 push %ebp + 201: 89 e5 mov %esp,%ebp + 203: 83 ec 10 sub $0x10,%esp + printf(stdout, "exitiput test\n"); + 206: 68 d3 3d 00 00 push $0x3dd3 + 20b: ff 35 68 5e 00 00 push 0x5e68 + 211: e8 3a 38 00 00 call 3a50 + pid = fork(); + 216: e8 b0 36 00 00 call 38cb + if (pid < 0) { + 21b: 83 c4 10 add $0x10,%esp + 21e: 85 c0 test %eax,%eax + 220: 0f 88 8a 00 00 00 js 2b0 + if (pid == 0) { + 226: 75 50 jne 278 + if (mkdir("iputdir") < 0) { + 228: 83 ec 0c sub $0xc,%esp + 22b: 68 9f 3d 00 00 push $0x3d9f + 230: e8 2e 37 00 00 call 3963 + 235: 83 c4 10 add $0x10,%esp + 238: 85 c0 test %eax,%eax + 23a: 0f 88 87 00 00 00 js 2c7 + if (chdir("iputdir") < 0) { + 240: 83 ec 0c sub $0xc,%esp + 243: 68 9f 3d 00 00 push $0x3d9f + 248: e8 be 36 00 00 call 390b + 24d: 83 c4 10 add $0x10,%esp + 250: 85 c0 test %eax,%eax + 252: 0f 88 86 00 00 00 js 2de + if (unlink("../iputdir") < 0) { + 258: 83 ec 0c sub $0xc,%esp + 25b: 68 9c 3d 00 00 push $0x3d9c + 260: e8 ee 36 00 00 call 3953 + 265: 83 c4 10 add $0x10,%esp + 268: 85 c0 test %eax,%eax + 26a: 78 2c js 298 + exit(); + 26c: e8 62 36 00 00 call 38d3 + 271: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + wait(); + 278: e8 5e 36 00 00 call 38db + printf(stdout, "exitiput test ok\n"); + 27d: 83 ec 08 sub $0x8,%esp + 280: 68 f6 3d 00 00 push $0x3df6 + 285: ff 35 68 5e 00 00 push 0x5e68 + 28b: e8 c0 37 00 00 call 3a50 +} + 290: 83 c4 10 add $0x10,%esp + 293: c9 leave + 294: c3 ret + 295: 8d 76 00 lea 0x0(%esi),%esi + printf(stdout, "unlink ../iputdir failed\n"); + 298: 83 ec 08 sub $0x8,%esp + 29b: 68 a7 3d 00 00 push $0x3da7 + 2a0: ff 35 68 5e 00 00 push 0x5e68 + 2a6: e8 a5 37 00 00 call 3a50 + exit(); + 2ab: e8 23 36 00 00 call 38d3 + printf(stdout, "fork failed\n"); + 2b0: 51 push %ecx + 2b1: 51 push %ecx + 2b2: 68 b9 4c 00 00 push $0x4cb9 + 2b7: ff 35 68 5e 00 00 push 0x5e68 + 2bd: e8 8e 37 00 00 call 3a50 + exit(); + 2c2: e8 0c 36 00 00 call 38d3 + printf(stdout, "mkdir failed\n"); + 2c7: 52 push %edx + 2c8: 52 push %edx + 2c9: 68 78 3d 00 00 push $0x3d78 + 2ce: ff 35 68 5e 00 00 push 0x5e68 + 2d4: e8 77 37 00 00 call 3a50 + exit(); + 2d9: e8 f5 35 00 00 call 38d3 + printf(stdout, "child chdir failed\n"); + 2de: 50 push %eax + 2df: 50 push %eax + 2e0: 68 e2 3d 00 00 push $0x3de2 + 2e5: ff 35 68 5e 00 00 push 0x5e68 + 2eb: e8 60 37 00 00 call 3a50 + exit(); + 2f0: e8 de 35 00 00 call 38d3 + 2f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000300 : +void openiputtest(void) { + 300: 55 push %ebp + 301: 89 e5 mov %esp,%ebp + 303: 83 ec 10 sub $0x10,%esp + printf(stdout, "openiput test\n"); + 306: 68 08 3e 00 00 push $0x3e08 + 30b: ff 35 68 5e 00 00 push 0x5e68 + 311: e8 3a 37 00 00 call 3a50 + if (mkdir("oidir") < 0) { + 316: c7 04 24 17 3e 00 00 movl $0x3e17,(%esp) + 31d: e8 41 36 00 00 call 3963 + 322: 83 c4 10 add $0x10,%esp + 325: 85 c0 test %eax,%eax + 327: 0f 88 9f 00 00 00 js 3cc + pid = fork(); + 32d: e8 99 35 00 00 call 38cb + if (pid < 0) { + 332: 85 c0 test %eax,%eax + 334: 78 7f js 3b5 + if (pid == 0) { + 336: 75 38 jne 370 + int fd = open("oidir", O_RDWR); + 338: 83 ec 08 sub $0x8,%esp + 33b: 6a 02 push $0x2 + 33d: 68 17 3e 00 00 push $0x3e17 + 342: e8 f4 35 00 00 call 393b + if (fd >= 0) { + 347: 83 c4 10 add $0x10,%esp + 34a: 85 c0 test %eax,%eax + 34c: 78 62 js 3b0 + printf(stdout, "open directory for write succeeded\n"); + 34e: 83 ec 08 sub $0x8,%esp + 351: 68 9c 4d 00 00 push $0x4d9c + 356: ff 35 68 5e 00 00 push 0x5e68 + 35c: e8 ef 36 00 00 call 3a50 + exit(); + 361: e8 6d 35 00 00 call 38d3 + 366: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 36d: 8d 76 00 lea 0x0(%esi),%esi + sleep(1); + 370: 83 ec 0c sub $0xc,%esp + 373: 6a 01 push $0x1 + 375: e8 b1 35 00 00 call 392b + if (unlink("oidir") != 0) { + 37a: c7 04 24 17 3e 00 00 movl $0x3e17,(%esp) + 381: e8 cd 35 00 00 call 3953 + 386: 83 c4 10 add $0x10,%esp + 389: 85 c0 test %eax,%eax + 38b: 75 56 jne 3e3 + wait(); + 38d: e8 49 35 00 00 call 38db + printf(stdout, "openiput test ok\n"); + 392: 83 ec 08 sub $0x8,%esp + 395: 68 40 3e 00 00 push $0x3e40 + 39a: ff 35 68 5e 00 00 push 0x5e68 + 3a0: e8 ab 36 00 00 call 3a50 +} + 3a5: 83 c4 10 add $0x10,%esp + 3a8: c9 leave + 3a9: c3 ret + 3aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + exit(); + 3b0: e8 1e 35 00 00 call 38d3 + printf(stdout, "fork failed\n"); + 3b5: 52 push %edx + 3b6: 52 push %edx + 3b7: 68 b9 4c 00 00 push $0x4cb9 + 3bc: ff 35 68 5e 00 00 push 0x5e68 + 3c2: e8 89 36 00 00 call 3a50 + exit(); + 3c7: e8 07 35 00 00 call 38d3 + printf(stdout, "mkdir oidir failed\n"); + 3cc: 51 push %ecx + 3cd: 51 push %ecx + 3ce: 68 1d 3e 00 00 push $0x3e1d + 3d3: ff 35 68 5e 00 00 push 0x5e68 + 3d9: e8 72 36 00 00 call 3a50 + exit(); + 3de: e8 f0 34 00 00 call 38d3 + printf(stdout, "unlink failed\n"); + 3e3: 50 push %eax + 3e4: 50 push %eax + 3e5: 68 31 3e 00 00 push $0x3e31 + 3ea: ff 35 68 5e 00 00 push 0x5e68 + 3f0: e8 5b 36 00 00 call 3a50 + exit(); + 3f5: e8 d9 34 00 00 call 38d3 + 3fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00000400 : +void opentest(void) { + 400: 55 push %ebp + 401: 89 e5 mov %esp,%ebp + 403: 83 ec 10 sub $0x10,%esp + printf(stdout, "open test\n"); + 406: 68 52 3e 00 00 push $0x3e52 + 40b: ff 35 68 5e 00 00 push 0x5e68 + 411: e8 3a 36 00 00 call 3a50 + fd = open("echo", 0); + 416: 58 pop %eax + 417: 5a pop %edx + 418: 6a 00 push $0x0 + 41a: 68 5d 3e 00 00 push $0x3e5d + 41f: e8 17 35 00 00 call 393b + if (fd < 0) { + 424: 83 c4 10 add $0x10,%esp + 427: 85 c0 test %eax,%eax + 429: 78 36 js 461 + close(fd); + 42b: 83 ec 0c sub $0xc,%esp + 42e: 50 push %eax + 42f: e8 37 35 00 00 call 396b + fd = open("doesnotexist", 0); + 434: 5a pop %edx + 435: 59 pop %ecx + 436: 6a 00 push $0x0 + 438: 68 75 3e 00 00 push $0x3e75 + 43d: e8 f9 34 00 00 call 393b + if (fd >= 0) { + 442: 83 c4 10 add $0x10,%esp + 445: 85 c0 test %eax,%eax + 447: 79 2f jns 478 + printf(stdout, "open test ok\n"); + 449: 83 ec 08 sub $0x8,%esp + 44c: 68 a0 3e 00 00 push $0x3ea0 + 451: ff 35 68 5e 00 00 push 0x5e68 + 457: e8 f4 35 00 00 call 3a50 +} + 45c: 83 c4 10 add $0x10,%esp + 45f: c9 leave + 460: c3 ret + printf(stdout, "open echo failed!\n"); + 461: 50 push %eax + 462: 50 push %eax + 463: 68 62 3e 00 00 push $0x3e62 + 468: ff 35 68 5e 00 00 push 0x5e68 + 46e: e8 dd 35 00 00 call 3a50 + exit(); + 473: e8 5b 34 00 00 call 38d3 + printf(stdout, "open doesnotexist succeeded!\n"); + 478: 50 push %eax + 479: 50 push %eax + 47a: 68 82 3e 00 00 push $0x3e82 + 47f: ff 35 68 5e 00 00 push 0x5e68 + 485: e8 c6 35 00 00 call 3a50 + exit(); + 48a: e8 44 34 00 00 call 38d3 + 48f: 90 nop + +00000490 : +void writetest(void) { + 490: 55 push %ebp + 491: 89 e5 mov %esp,%ebp + 493: 56 push %esi + 494: 53 push %ebx + printf(stdout, "small file test\n"); + 495: 83 ec 08 sub $0x8,%esp + 498: 68 ae 3e 00 00 push $0x3eae + 49d: ff 35 68 5e 00 00 push 0x5e68 + 4a3: e8 a8 35 00 00 call 3a50 + fd = open("small", O_CREATE | O_RDWR); + 4a8: 58 pop %eax + 4a9: 5a pop %edx + 4aa: 68 02 02 00 00 push $0x202 + 4af: 68 bf 3e 00 00 push $0x3ebf + 4b4: e8 82 34 00 00 call 393b + if (fd >= 0) { + 4b9: 83 c4 10 add $0x10,%esp + 4bc: 85 c0 test %eax,%eax + 4be: 0f 88 88 01 00 00 js 64c + printf(stdout, "creat small succeeded; ok\n"); + 4c4: 83 ec 08 sub $0x8,%esp + 4c7: 89 c6 mov %eax,%esi + for (i = 0; i < 100; i++) { + 4c9: 31 db xor %ebx,%ebx + printf(stdout, "creat small succeeded; ok\n"); + 4cb: 68 c5 3e 00 00 push $0x3ec5 + 4d0: ff 35 68 5e 00 00 push 0x5e68 + 4d6: e8 75 35 00 00 call 3a50 + 4db: 83 c4 10 add $0x10,%esp + 4de: 66 90 xchg %ax,%ax + if (write(fd, "aaaaaaaaaa", 10) != 10) { + 4e0: 83 ec 04 sub $0x4,%esp + 4e3: 6a 0a push $0xa + 4e5: 68 fc 3e 00 00 push $0x3efc + 4ea: 56 push %esi + 4eb: e8 53 34 00 00 call 3943 + 4f0: 83 c4 10 add $0x10,%esp + 4f3: 83 f8 0a cmp $0xa,%eax + 4f6: 0f 85 d9 00 00 00 jne 5d5 + if (write(fd, "bbbbbbbbbb", 10) != 10) { + 4fc: 83 ec 04 sub $0x4,%esp + 4ff: 6a 0a push $0xa + 501: 68 07 3f 00 00 push $0x3f07 + 506: 56 push %esi + 507: e8 37 34 00 00 call 3943 + 50c: 83 c4 10 add $0x10,%esp + 50f: 83 f8 0a cmp $0xa,%eax + 512: 0f 85 d6 00 00 00 jne 5ee + for (i = 0; i < 100; i++) { + 518: 83 c3 01 add $0x1,%ebx + 51b: 83 fb 64 cmp $0x64,%ebx + 51e: 75 c0 jne 4e0 + printf(stdout, "writes ok\n"); + 520: 83 ec 08 sub $0x8,%esp + 523: 68 12 3f 00 00 push $0x3f12 + 528: ff 35 68 5e 00 00 push 0x5e68 + 52e: e8 1d 35 00 00 call 3a50 + close(fd); + 533: 89 34 24 mov %esi,(%esp) + 536: e8 30 34 00 00 call 396b + fd = open("small", O_RDONLY); + 53b: 5b pop %ebx + 53c: 5e pop %esi + 53d: 6a 00 push $0x0 + 53f: 68 bf 3e 00 00 push $0x3ebf + 544: e8 f2 33 00 00 call 393b + if (fd >= 0) { + 549: 83 c4 10 add $0x10,%esp + fd = open("small", O_RDONLY); + 54c: 89 c3 mov %eax,%ebx + if (fd >= 0) { + 54e: 85 c0 test %eax,%eax + 550: 0f 88 b1 00 00 00 js 607 + printf(stdout, "open small succeeded ok\n"); + 556: 83 ec 08 sub $0x8,%esp + 559: 68 1d 3f 00 00 push $0x3f1d + 55e: ff 35 68 5e 00 00 push 0x5e68 + 564: e8 e7 34 00 00 call 3a50 + i = read(fd, buf, 2000); + 569: 83 c4 0c add $0xc,%esp + 56c: 68 d0 07 00 00 push $0x7d0 + 571: 68 a0 85 00 00 push $0x85a0 + 576: 53 push %ebx + 577: e8 6f 33 00 00 call 38eb + if (i == 2000) { + 57c: 83 c4 10 add $0x10,%esp + 57f: 3d d0 07 00 00 cmp $0x7d0,%eax + 584: 0f 85 94 00 00 00 jne 61e + printf(stdout, "read succeeded ok\n"); + 58a: 83 ec 08 sub $0x8,%esp + 58d: 68 51 3f 00 00 push $0x3f51 + 592: ff 35 68 5e 00 00 push 0x5e68 + 598: e8 b3 34 00 00 call 3a50 + close(fd); + 59d: 89 1c 24 mov %ebx,(%esp) + 5a0: e8 c6 33 00 00 call 396b + if (unlink("small") < 0) { + 5a5: c7 04 24 bf 3e 00 00 movl $0x3ebf,(%esp) + 5ac: e8 a2 33 00 00 call 3953 + 5b1: 83 c4 10 add $0x10,%esp + 5b4: 85 c0 test %eax,%eax + 5b6: 78 7d js 635 + printf(stdout, "small file test ok\n"); + 5b8: 83 ec 08 sub $0x8,%esp + 5bb: 68 79 3f 00 00 push $0x3f79 + 5c0: ff 35 68 5e 00 00 push 0x5e68 + 5c6: e8 85 34 00 00 call 3a50 +} + 5cb: 83 c4 10 add $0x10,%esp + 5ce: 8d 65 f8 lea -0x8(%ebp),%esp + 5d1: 5b pop %ebx + 5d2: 5e pop %esi + 5d3: 5d pop %ebp + 5d4: c3 ret + printf(stdout, "error: write aa %d new file failed\n", i); + 5d5: 83 ec 04 sub $0x4,%esp + 5d8: 53 push %ebx + 5d9: 68 c0 4d 00 00 push $0x4dc0 + 5de: ff 35 68 5e 00 00 push 0x5e68 + 5e4: e8 67 34 00 00 call 3a50 + exit(); + 5e9: e8 e5 32 00 00 call 38d3 + printf(stdout, "error: write bb %d new file failed\n", i); + 5ee: 83 ec 04 sub $0x4,%esp + 5f1: 53 push %ebx + 5f2: 68 e4 4d 00 00 push $0x4de4 + 5f7: ff 35 68 5e 00 00 push 0x5e68 + 5fd: e8 4e 34 00 00 call 3a50 + exit(); + 602: e8 cc 32 00 00 call 38d3 + printf(stdout, "error: open small failed!\n"); + 607: 51 push %ecx + 608: 51 push %ecx + 609: 68 36 3f 00 00 push $0x3f36 + 60e: ff 35 68 5e 00 00 push 0x5e68 + 614: e8 37 34 00 00 call 3a50 + exit(); + 619: e8 b5 32 00 00 call 38d3 + printf(stdout, "read failed\n"); + 61e: 52 push %edx + 61f: 52 push %edx + 620: 68 7d 42 00 00 push $0x427d + 625: ff 35 68 5e 00 00 push 0x5e68 + 62b: e8 20 34 00 00 call 3a50 + exit(); + 630: e8 9e 32 00 00 call 38d3 + printf(stdout, "unlink small failed\n"); + 635: 50 push %eax + 636: 50 push %eax + 637: 68 64 3f 00 00 push $0x3f64 + 63c: ff 35 68 5e 00 00 push 0x5e68 + 642: e8 09 34 00 00 call 3a50 + exit(); + 647: e8 87 32 00 00 call 38d3 + printf(stdout, "error: creat small failed!\n"); + 64c: 50 push %eax + 64d: 50 push %eax + 64e: 68 e0 3e 00 00 push $0x3ee0 + 653: ff 35 68 5e 00 00 push 0x5e68 + 659: e8 f2 33 00 00 call 3a50 + exit(); + 65e: e8 70 32 00 00 call 38d3 + 663: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 66a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00000670 : +void writetest1(void) { + 670: 55 push %ebp + 671: 89 e5 mov %esp,%ebp + 673: 56 push %esi + 674: 53 push %ebx + printf(stdout, "big files test\n"); + 675: 83 ec 08 sub $0x8,%esp + 678: 68 8d 3f 00 00 push $0x3f8d + 67d: ff 35 68 5e 00 00 push 0x5e68 + 683: e8 c8 33 00 00 call 3a50 + fd = open("big", O_CREATE | O_RDWR); + 688: 58 pop %eax + 689: 5a pop %edx + 68a: 68 02 02 00 00 push $0x202 + 68f: 68 07 40 00 00 push $0x4007 + 694: e8 a2 32 00 00 call 393b + if (fd < 0) { + 699: 83 c4 10 add $0x10,%esp + 69c: 85 c0 test %eax,%eax + 69e: 0f 88 61 01 00 00 js 805 + 6a4: 89 c6 mov %eax,%esi + for (i = 0; i < MAXFILE; i++) { + 6a6: 31 db xor %ebx,%ebx + 6a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 6af: 90 nop + if (write(fd, buf, 512) != 512) { + 6b0: 83 ec 04 sub $0x4,%esp + ((int*)buf)[0] = i; + 6b3: 89 1d a0 85 00 00 mov %ebx,0x85a0 + if (write(fd, buf, 512) != 512) { + 6b9: 68 00 02 00 00 push $0x200 + 6be: 68 a0 85 00 00 push $0x85a0 + 6c3: 56 push %esi + 6c4: e8 7a 32 00 00 call 3943 + 6c9: 83 c4 10 add $0x10,%esp + 6cc: 3d 00 02 00 00 cmp $0x200,%eax + 6d1: 0f 85 b3 00 00 00 jne 78a + for (i = 0; i < MAXFILE; i++) { + 6d7: 83 c3 01 add $0x1,%ebx + 6da: 81 fb 8c 00 00 00 cmp $0x8c,%ebx + 6e0: 75 ce jne 6b0 + close(fd); + 6e2: 83 ec 0c sub $0xc,%esp + 6e5: 56 push %esi + 6e6: e8 80 32 00 00 call 396b + fd = open("big", O_RDONLY); + 6eb: 5b pop %ebx + 6ec: 5e pop %esi + 6ed: 6a 00 push $0x0 + 6ef: 68 07 40 00 00 push $0x4007 + 6f4: e8 42 32 00 00 call 393b + if (fd < 0) { + 6f9: 83 c4 10 add $0x10,%esp + fd = open("big", O_RDONLY); + 6fc: 89 c3 mov %eax,%ebx + if (fd < 0) { + 6fe: 85 c0 test %eax,%eax + 700: 0f 88 e8 00 00 00 js 7ee + n = 0; + 706: 31 f6 xor %esi,%esi + 708: eb 1d jmp 727 + 70a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + else if (i != 512) { + 710: 3d 00 02 00 00 cmp $0x200,%eax + 715: 0f 85 9f 00 00 00 jne 7ba + if (((int*)buf)[0] != n) { + 71b: a1 a0 85 00 00 mov 0x85a0,%eax + 720: 39 f0 cmp %esi,%eax + 722: 75 7f jne 7a3 + n++; + 724: 83 c6 01 add $0x1,%esi + i = read(fd, buf, 512); + 727: 83 ec 04 sub $0x4,%esp + 72a: 68 00 02 00 00 push $0x200 + 72f: 68 a0 85 00 00 push $0x85a0 + 734: 53 push %ebx + 735: e8 b1 31 00 00 call 38eb + if (i == 0) { + 73a: 83 c4 10 add $0x10,%esp + 73d: 85 c0 test %eax,%eax + 73f: 75 cf jne 710 + if (n == MAXFILE - 1) { + 741: 81 fe 8b 00 00 00 cmp $0x8b,%esi + 747: 0f 84 86 00 00 00 je 7d3 + close(fd); + 74d: 83 ec 0c sub $0xc,%esp + 750: 53 push %ebx + 751: e8 15 32 00 00 call 396b + if (unlink("big") < 0) { + 756: c7 04 24 07 40 00 00 movl $0x4007,(%esp) + 75d: e8 f1 31 00 00 call 3953 + 762: 83 c4 10 add $0x10,%esp + 765: 85 c0 test %eax,%eax + 767: 0f 88 af 00 00 00 js 81c + printf(stdout, "big files ok\n"); + 76d: 83 ec 08 sub $0x8,%esp + 770: 68 2e 40 00 00 push $0x402e + 775: ff 35 68 5e 00 00 push 0x5e68 + 77b: e8 d0 32 00 00 call 3a50 +} + 780: 83 c4 10 add $0x10,%esp + 783: 8d 65 f8 lea -0x8(%ebp),%esp + 786: 5b pop %ebx + 787: 5e pop %esi + 788: 5d pop %ebp + 789: c3 ret + printf(stdout, "error: write big file failed\n", i); + 78a: 83 ec 04 sub $0x4,%esp + 78d: 53 push %ebx + 78e: 68 b7 3f 00 00 push $0x3fb7 + 793: ff 35 68 5e 00 00 push 0x5e68 + 799: e8 b2 32 00 00 call 3a50 + exit(); + 79e: e8 30 31 00 00 call 38d3 + printf(stdout, "read content of block %d is %d\n", + 7a3: 50 push %eax + 7a4: 56 push %esi + 7a5: 68 08 4e 00 00 push $0x4e08 + 7aa: ff 35 68 5e 00 00 push 0x5e68 + 7b0: e8 9b 32 00 00 call 3a50 + exit(); + 7b5: e8 19 31 00 00 call 38d3 + printf(stdout, "read failed %d\n", i); + 7ba: 83 ec 04 sub $0x4,%esp + 7bd: 50 push %eax + 7be: 68 0b 40 00 00 push $0x400b + 7c3: ff 35 68 5e 00 00 push 0x5e68 + 7c9: e8 82 32 00 00 call 3a50 + exit(); + 7ce: e8 00 31 00 00 call 38d3 + printf(stdout, "read only %d blocks from big", n); + 7d3: 52 push %edx + 7d4: 68 8b 00 00 00 push $0x8b + 7d9: 68 ee 3f 00 00 push $0x3fee + 7de: ff 35 68 5e 00 00 push 0x5e68 + 7e4: e8 67 32 00 00 call 3a50 + exit(); + 7e9: e8 e5 30 00 00 call 38d3 + printf(stdout, "error: open big failed!\n"); + 7ee: 51 push %ecx + 7ef: 51 push %ecx + 7f0: 68 d5 3f 00 00 push $0x3fd5 + 7f5: ff 35 68 5e 00 00 push 0x5e68 + 7fb: e8 50 32 00 00 call 3a50 + exit(); + 800: e8 ce 30 00 00 call 38d3 + printf(stdout, "error: creat big failed!\n"); + 805: 50 push %eax + 806: 50 push %eax + 807: 68 9d 3f 00 00 push $0x3f9d + 80c: ff 35 68 5e 00 00 push 0x5e68 + 812: e8 39 32 00 00 call 3a50 + exit(); + 817: e8 b7 30 00 00 call 38d3 + printf(stdout, "unlink big failed\n"); + 81c: 50 push %eax + 81d: 50 push %eax + 81e: 68 1b 40 00 00 push $0x401b + 823: ff 35 68 5e 00 00 push 0x5e68 + 829: e8 22 32 00 00 call 3a50 + exit(); + 82e: e8 a0 30 00 00 call 38d3 + 833: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 83a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00000840 : +void createtest(void) { + 840: 55 push %ebp + 841: 89 e5 mov %esp,%ebp + 843: 53 push %ebx + name[2] = '\0'; + 844: bb 30 00 00 00 mov $0x30,%ebx +void createtest(void) { + 849: 83 ec 0c sub $0xc,%esp + printf(stdout, "many creates, followed by unlink test\n"); + 84c: 68 28 4e 00 00 push $0x4e28 + 851: ff 35 68 5e 00 00 push 0x5e68 + 857: e8 f4 31 00 00 call 3a50 + name[0] = 'a'; + 85c: c6 05 90 85 00 00 61 movb $0x61,0x8590 + name[2] = '\0'; + 863: 83 c4 10 add $0x10,%esp + 866: c6 05 92 85 00 00 00 movb $0x0,0x8592 + for (i = 0; i < 52; i++) { + 86d: 8d 76 00 lea 0x0(%esi),%esi + fd = open(name, O_CREATE | O_RDWR); + 870: 83 ec 08 sub $0x8,%esp + name[1] = '0' + i; + 873: 88 1d 91 85 00 00 mov %bl,0x8591 + for (i = 0; i < 52; i++) { + 879: 83 c3 01 add $0x1,%ebx + fd = open(name, O_CREATE | O_RDWR); + 87c: 68 02 02 00 00 push $0x202 + 881: 68 90 85 00 00 push $0x8590 + 886: e8 b0 30 00 00 call 393b + close(fd); + 88b: 89 04 24 mov %eax,(%esp) + 88e: e8 d8 30 00 00 call 396b + for (i = 0; i < 52; i++) { + 893: 83 c4 10 add $0x10,%esp + 896: 80 fb 64 cmp $0x64,%bl + 899: 75 d5 jne 870 + name[0] = 'a'; + 89b: c6 05 90 85 00 00 61 movb $0x61,0x8590 + name[2] = '\0'; + 8a2: bb 30 00 00 00 mov $0x30,%ebx + 8a7: c6 05 92 85 00 00 00 movb $0x0,0x8592 + for (i = 0; i < 52; i++) { + 8ae: 66 90 xchg %ax,%ax + unlink(name); + 8b0: 83 ec 0c sub $0xc,%esp + name[1] = '0' + i; + 8b3: 88 1d 91 85 00 00 mov %bl,0x8591 + for (i = 0; i < 52; i++) { + 8b9: 83 c3 01 add $0x1,%ebx + unlink(name); + 8bc: 68 90 85 00 00 push $0x8590 + 8c1: e8 8d 30 00 00 call 3953 + for (i = 0; i < 52; i++) { + 8c6: 83 c4 10 add $0x10,%esp + 8c9: 80 fb 64 cmp $0x64,%bl + 8cc: 75 e2 jne 8b0 + printf(stdout, "many creates, followed by unlink; ok\n"); + 8ce: 83 ec 08 sub $0x8,%esp + 8d1: 68 50 4e 00 00 push $0x4e50 + 8d6: ff 35 68 5e 00 00 push 0x5e68 + 8dc: e8 6f 31 00 00 call 3a50 +} + 8e1: 8b 5d fc mov -0x4(%ebp),%ebx + 8e4: 83 c4 10 add $0x10,%esp + 8e7: c9 leave + 8e8: c3 ret + 8e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000008f0 : +void dirtest(void){ + 8f0: 55 push %ebp + 8f1: 89 e5 mov %esp,%ebp + 8f3: 83 ec 10 sub $0x10,%esp + printf(stdout, "mkdir test\n"); + 8f6: 68 3c 40 00 00 push $0x403c + 8fb: ff 35 68 5e 00 00 push 0x5e68 + 901: e8 4a 31 00 00 call 3a50 + if (mkdir("dir0") < 0) { + 906: c7 04 24 48 40 00 00 movl $0x4048,(%esp) + 90d: e8 51 30 00 00 call 3963 + 912: 83 c4 10 add $0x10,%esp + 915: 85 c0 test %eax,%eax + 917: 78 58 js 971 + if (chdir("dir0") < 0) { + 919: 83 ec 0c sub $0xc,%esp + 91c: 68 48 40 00 00 push $0x4048 + 921: e8 e5 2f 00 00 call 390b + 926: 83 c4 10 add $0x10,%esp + 929: 85 c0 test %eax,%eax + 92b: 0f 88 85 00 00 00 js 9b6 + if (chdir("..") < 0) { + 931: 83 ec 0c sub $0xc,%esp + 934: 68 ed 45 00 00 push $0x45ed + 939: e8 cd 2f 00 00 call 390b + 93e: 83 c4 10 add $0x10,%esp + 941: 85 c0 test %eax,%eax + 943: 78 5a js 99f + if (unlink("dir0") < 0) { + 945: 83 ec 0c sub $0xc,%esp + 948: 68 48 40 00 00 push $0x4048 + 94d: e8 01 30 00 00 call 3953 + 952: 83 c4 10 add $0x10,%esp + 955: 85 c0 test %eax,%eax + 957: 78 2f js 988 + printf(stdout, "mkdir test ok\n"); + 959: 83 ec 08 sub $0x8,%esp + 95c: 68 85 40 00 00 push $0x4085 + 961: ff 35 68 5e 00 00 push 0x5e68 + 967: e8 e4 30 00 00 call 3a50 +} + 96c: 83 c4 10 add $0x10,%esp + 96f: c9 leave + 970: c3 ret + printf(stdout, "mkdir failed\n"); + 971: 50 push %eax + 972: 50 push %eax + 973: 68 78 3d 00 00 push $0x3d78 + 978: ff 35 68 5e 00 00 push 0x5e68 + 97e: e8 cd 30 00 00 call 3a50 + exit(); + 983: e8 4b 2f 00 00 call 38d3 + printf(stdout, "unlink dir0 failed\n"); + 988: 50 push %eax + 989: 50 push %eax + 98a: 68 71 40 00 00 push $0x4071 + 98f: ff 35 68 5e 00 00 push 0x5e68 + 995: e8 b6 30 00 00 call 3a50 + exit(); + 99a: e8 34 2f 00 00 call 38d3 + printf(stdout, "chdir .. failed\n"); + 99f: 52 push %edx + 9a0: 52 push %edx + 9a1: 68 60 40 00 00 push $0x4060 + 9a6: ff 35 68 5e 00 00 push 0x5e68 + 9ac: e8 9f 30 00 00 call 3a50 + exit(); + 9b1: e8 1d 2f 00 00 call 38d3 + printf(stdout, "chdir dir0 failed\n"); + 9b6: 51 push %ecx + 9b7: 51 push %ecx + 9b8: 68 4d 40 00 00 push $0x404d + 9bd: ff 35 68 5e 00 00 push 0x5e68 + 9c3: e8 88 30 00 00 call 3a50 + exit(); + 9c8: e8 06 2f 00 00 call 38d3 + 9cd: 8d 76 00 lea 0x0(%esi),%esi + +000009d0 : +void exectest(void) { + 9d0: 55 push %ebp + 9d1: 89 e5 mov %esp,%ebp + 9d3: 83 ec 10 sub $0x10,%esp + printf(stdout, "exec test\n"); + 9d6: 68 94 40 00 00 push $0x4094 + 9db: ff 35 68 5e 00 00 push 0x5e68 + 9e1: e8 6a 30 00 00 call 3a50 + if (exec("echo", echoargv) < 0) { + 9e6: 5a pop %edx + 9e7: 59 pop %ecx + 9e8: 68 6c 5e 00 00 push $0x5e6c + 9ed: 68 5d 3e 00 00 push $0x3e5d + 9f2: e8 04 2f 00 00 call 38fb + 9f7: 83 c4 10 add $0x10,%esp + 9fa: 85 c0 test %eax,%eax + 9fc: 78 02 js a00 +} + 9fe: c9 leave + 9ff: c3 ret + printf(stdout, "exec echo failed\n"); + a00: 50 push %eax + a01: 50 push %eax + a02: 68 9f 40 00 00 push $0x409f + a07: ff 35 68 5e 00 00 push 0x5e68 + a0d: e8 3e 30 00 00 call 3a50 + exit(); + a12: e8 bc 2e 00 00 call 38d3 + a17: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + a1e: 66 90 xchg %ax,%ax + +00000a20 : +void pipe1(void) { + a20: 55 push %ebp + a21: 89 e5 mov %esp,%ebp + a23: 57 push %edi + a24: 56 push %esi + if (pipe(fds) != 0) { + a25: 8d 45 e0 lea -0x20(%ebp),%eax +void pipe1(void) { + a28: 53 push %ebx + a29: 83 ec 38 sub $0x38,%esp + if (pipe(fds) != 0) { + a2c: 50 push %eax + a2d: e8 b1 2e 00 00 call 38e3 + a32: 83 c4 10 add $0x10,%esp + a35: 85 c0 test %eax,%eax + a37: 0f 85 34 01 00 00 jne b71 + pid = fork(); + a3d: e8 89 2e 00 00 call 38cb + if (pid == 0) { + a42: 85 c0 test %eax,%eax + a44: 0f 84 85 00 00 00 je acf + else if (pid > 0) { + a4a: 0f 8e 34 01 00 00 jle b84 + close(fds[1]); + a50: 83 ec 0c sub $0xc,%esp + a53: ff 75 e4 push -0x1c(%ebp) + seq = 0; + a56: 31 db xor %ebx,%ebx + cc = 1; + a58: be 01 00 00 00 mov $0x1,%esi + close(fds[1]); + a5d: e8 09 2f 00 00 call 396b + total = 0; + a62: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) + while ((n = read(fds[0], buf, cc)) > 0) { + a69: 83 c4 10 add $0x10,%esp + a6c: 83 ec 04 sub $0x4,%esp + a6f: 56 push %esi + a70: 68 a0 85 00 00 push $0x85a0 + a75: ff 75 e0 push -0x20(%ebp) + a78: e8 6e 2e 00 00 call 38eb + a7d: 83 c4 10 add $0x10,%esp + a80: 89 c7 mov %eax,%edi + a82: 85 c0 test %eax,%eax + a84: 0f 8e a3 00 00 00 jle b2d + a8a: 8d 0c 1f lea (%edi,%ebx,1),%ecx + for (i = 0; i < n; i++) { + a8d: 31 c0 xor %eax,%eax + a8f: 90 nop + if ((buf[i] & 0xff) != (seq++ & 0xff)) { + a90: 89 da mov %ebx,%edx + a92: 83 c3 01 add $0x1,%ebx + a95: 38 90 a0 85 00 00 cmp %dl,0x85a0(%eax) + a9b: 75 18 jne ab5 + for (i = 0; i < n; i++) { + a9d: 83 c0 01 add $0x1,%eax + aa0: 39 d9 cmp %ebx,%ecx + aa2: 75 ec jne a90 + cc = cc * 2; + aa4: 01 f6 add %esi,%esi + aa6: b8 00 20 00 00 mov $0x2000,%eax + total += n; + aab: 01 7d d4 add %edi,-0x2c(%ebp) + aae: 39 c6 cmp %eax,%esi + ab0: 0f 4f f0 cmovg %eax,%esi + ab3: eb b7 jmp a6c + printf(1, "pipe1 oops 2\n"); + ab5: 83 ec 08 sub $0x8,%esp + ab8: 68 ce 40 00 00 push $0x40ce + abd: 6a 01 push $0x1 + abf: e8 8c 2f 00 00 call 3a50 + ac4: 83 c4 10 add $0x10,%esp +} + ac7: 8d 65 f4 lea -0xc(%ebp),%esp + aca: 5b pop %ebx + acb: 5e pop %esi + acc: 5f pop %edi + acd: 5d pop %ebp + ace: c3 ret + close(fds[0]); + acf: 83 ec 0c sub $0xc,%esp + ad2: ff 75 e0 push -0x20(%ebp) + seq = 0; + ad5: 31 db xor %ebx,%ebx + close(fds[0]); + ad7: e8 8f 2e 00 00 call 396b + adc: 83 c4 10 add $0x10,%esp + for (i = 0; i < 1033; i++) { + adf: 31 c0 xor %eax,%eax + ae1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + buf[i] = seq++; + ae8: 8d 14 18 lea (%eax,%ebx,1),%edx + for (i = 0; i < 1033; i++) { + aeb: 83 c0 01 add $0x1,%eax + buf[i] = seq++; + aee: 88 90 9f 85 00 00 mov %dl,0x859f(%eax) + for (i = 0; i < 1033; i++) { + af4: 3d 09 04 00 00 cmp $0x409,%eax + af9: 75 ed jne ae8 + if (write(fds[1], buf, 1033) != 1033) { + afb: 83 ec 04 sub $0x4,%esp + buf[i] = seq++; + afe: 81 c3 09 04 00 00 add $0x409,%ebx + if (write(fds[1], buf, 1033) != 1033) { + b04: 68 09 04 00 00 push $0x409 + b09: 68 a0 85 00 00 push $0x85a0 + b0e: ff 75 e4 push -0x1c(%ebp) + b11: e8 2d 2e 00 00 call 3943 + b16: 83 c4 10 add $0x10,%esp + b19: 3d 09 04 00 00 cmp $0x409,%eax + b1e: 75 77 jne b97 + for (n = 0; n < 5; n++) { + b20: 81 fb 2d 14 00 00 cmp $0x142d,%ebx + b26: 75 b7 jne adf + exit(); + b28: e8 a6 2d 00 00 call 38d3 + if (total != 5 * 1033) { + b2d: 81 7d d4 2d 14 00 00 cmpl $0x142d,-0x2c(%ebp) + b34: 75 26 jne b5c + close(fds[0]); + b36: 83 ec 0c sub $0xc,%esp + b39: ff 75 e0 push -0x20(%ebp) + b3c: e8 2a 2e 00 00 call 396b + wait(); + b41: e8 95 2d 00 00 call 38db + printf(1, "pipe1 ok\n"); + b46: 5a pop %edx + b47: 59 pop %ecx + b48: 68 f3 40 00 00 push $0x40f3 + b4d: 6a 01 push $0x1 + b4f: e8 fc 2e 00 00 call 3a50 + b54: 83 c4 10 add $0x10,%esp + b57: e9 6b ff ff ff jmp ac7 + printf(1, "pipe1 oops 3 total %d\n", total); + b5c: 53 push %ebx + b5d: ff 75 d4 push -0x2c(%ebp) + b60: 68 dc 40 00 00 push $0x40dc + b65: 6a 01 push $0x1 + b67: e8 e4 2e 00 00 call 3a50 + exit(); + b6c: e8 62 2d 00 00 call 38d3 + printf(1, "pipe() failed\n"); + b71: 57 push %edi + b72: 57 push %edi + b73: 68 b1 40 00 00 push $0x40b1 + b78: 6a 01 push $0x1 + b7a: e8 d1 2e 00 00 call 3a50 + exit(); + b7f: e8 4f 2d 00 00 call 38d3 + printf(1, "fork() failed\n"); + b84: 50 push %eax + b85: 50 push %eax + b86: 68 fd 40 00 00 push $0x40fd + b8b: 6a 01 push $0x1 + b8d: e8 be 2e 00 00 call 3a50 + exit(); + b92: e8 3c 2d 00 00 call 38d3 + printf(1, "pipe1 oops 1\n"); + b97: 56 push %esi + b98: 56 push %esi + b99: 68 c0 40 00 00 push $0x40c0 + b9e: 6a 01 push $0x1 + ba0: e8 ab 2e 00 00 call 3a50 + exit(); + ba5: e8 29 2d 00 00 call 38d3 + baa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00000bb0 : +void preempt(void) { + bb0: 55 push %ebp + bb1: 89 e5 mov %esp,%ebp + bb3: 57 push %edi + bb4: 56 push %esi + bb5: 53 push %ebx + bb6: 83 ec 24 sub $0x24,%esp + printf(1, "preempt: "); + bb9: 68 0c 41 00 00 push $0x410c + bbe: 6a 01 push $0x1 + bc0: e8 8b 2e 00 00 call 3a50 + pid1 = fork(); + bc5: e8 01 2d 00 00 call 38cb + if (pid1 == 0) { + bca: 83 c4 10 add $0x10,%esp + bcd: 85 c0 test %eax,%eax + bcf: 75 07 jne bd8 + for (;;) { + bd1: eb fe jmp bd1 + bd3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bd7: 90 nop + bd8: 89 c3 mov %eax,%ebx + pid2 = fork(); + bda: e8 ec 2c 00 00 call 38cb + bdf: 89 c6 mov %eax,%esi + if (pid2 == 0) { + be1: 85 c0 test %eax,%eax + be3: 75 0b jne bf0 + for (;;) { + be5: eb fe jmp be5 + be7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + bee: 66 90 xchg %ax,%ax + pipe(pfds); + bf0: 83 ec 0c sub $0xc,%esp + bf3: 8d 45 e0 lea -0x20(%ebp),%eax + bf6: 50 push %eax + bf7: e8 e7 2c 00 00 call 38e3 + pid3 = fork(); + bfc: e8 ca 2c 00 00 call 38cb + if (pid3 == 0) { + c01: 83 c4 10 add $0x10,%esp + pid3 = fork(); + c04: 89 c7 mov %eax,%edi + if (pid3 == 0) { + c06: 85 c0 test %eax,%eax + c08: 75 3e jne c48 + close(pfds[0]); + c0a: 83 ec 0c sub $0xc,%esp + c0d: ff 75 e0 push -0x20(%ebp) + c10: e8 56 2d 00 00 call 396b + if (write(pfds[1], "x", 1) != 1) { + c15: 83 c4 0c add $0xc,%esp + c18: 6a 01 push $0x1 + c1a: 68 d1 46 00 00 push $0x46d1 + c1f: ff 75 e4 push -0x1c(%ebp) + c22: e8 1c 2d 00 00 call 3943 + c27: 83 c4 10 add $0x10,%esp + c2a: 83 f8 01 cmp $0x1,%eax + c2d: 0f 85 b8 00 00 00 jne ceb + close(pfds[1]); + c33: 83 ec 0c sub $0xc,%esp + c36: ff 75 e4 push -0x1c(%ebp) + c39: e8 2d 2d 00 00 call 396b + c3e: 83 c4 10 add $0x10,%esp + for (;;) { + c41: eb fe jmp c41 + c43: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c47: 90 nop + close(pfds[1]); + c48: 83 ec 0c sub $0xc,%esp + c4b: ff 75 e4 push -0x1c(%ebp) + c4e: e8 18 2d 00 00 call 396b + if (read(pfds[0], buf, sizeof(buf)) != 1) { + c53: 83 c4 0c add $0xc,%esp + c56: 68 00 20 00 00 push $0x2000 + c5b: 68 a0 85 00 00 push $0x85a0 + c60: ff 75 e0 push -0x20(%ebp) + c63: e8 83 2c 00 00 call 38eb + c68: 83 c4 10 add $0x10,%esp + c6b: 83 f8 01 cmp $0x1,%eax + c6e: 75 67 jne cd7 + close(pfds[0]); + c70: 83 ec 0c sub $0xc,%esp + c73: ff 75 e0 push -0x20(%ebp) + c76: e8 f0 2c 00 00 call 396b + printf(1, "kill... "); + c7b: 58 pop %eax + c7c: 5a pop %edx + c7d: 68 3d 41 00 00 push $0x413d + c82: 6a 01 push $0x1 + c84: e8 c7 2d 00 00 call 3a50 + kill(pid1); + c89: 89 1c 24 mov %ebx,(%esp) + c8c: e8 62 2c 00 00 call 38f3 + kill(pid2); + c91: 89 34 24 mov %esi,(%esp) + c94: e8 5a 2c 00 00 call 38f3 + kill(pid3); + c99: 89 3c 24 mov %edi,(%esp) + c9c: e8 52 2c 00 00 call 38f3 + printf(1, "wait... "); + ca1: 59 pop %ecx + ca2: 5b pop %ebx + ca3: 68 46 41 00 00 push $0x4146 + ca8: 6a 01 push $0x1 + caa: e8 a1 2d 00 00 call 3a50 + wait(); + caf: e8 27 2c 00 00 call 38db + wait(); + cb4: e8 22 2c 00 00 call 38db + wait(); + cb9: e8 1d 2c 00 00 call 38db + printf(1, "preempt ok\n"); + cbe: 5e pop %esi + cbf: 5f pop %edi + cc0: 68 4f 41 00 00 push $0x414f + cc5: 6a 01 push $0x1 + cc7: e8 84 2d 00 00 call 3a50 + ccc: 83 c4 10 add $0x10,%esp +} + ccf: 8d 65 f4 lea -0xc(%ebp),%esp + cd2: 5b pop %ebx + cd3: 5e pop %esi + cd4: 5f pop %edi + cd5: 5d pop %ebp + cd6: c3 ret + printf(1, "preempt read error"); + cd7: 83 ec 08 sub $0x8,%esp + cda: 68 2a 41 00 00 push $0x412a + cdf: 6a 01 push $0x1 + ce1: e8 6a 2d 00 00 call 3a50 + ce6: 83 c4 10 add $0x10,%esp + ce9: eb e4 jmp ccf + printf(1, "preempt write error"); + ceb: 83 ec 08 sub $0x8,%esp + cee: 68 16 41 00 00 push $0x4116 + cf3: 6a 01 push $0x1 + cf5: e8 56 2d 00 00 call 3a50 + cfa: 83 c4 10 add $0x10,%esp + cfd: e9 31 ff ff ff jmp c33 + d02: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + d09: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000d10 : +void exitwait(void) { + d10: 55 push %ebp + d11: 89 e5 mov %esp,%ebp + d13: 56 push %esi + d14: be 64 00 00 00 mov $0x64,%esi + d19: 53 push %ebx + d1a: eb 14 jmp d30 + d1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (pid) { + d20: 74 68 je d8a + if (wait() != pid) { + d22: e8 b4 2b 00 00 call 38db + d27: 39 d8 cmp %ebx,%eax + d29: 75 2d jne d58 + for (i = 0; i < 100; i++) { + d2b: 83 ee 01 sub $0x1,%esi + d2e: 74 41 je d71 + pid = fork(); + d30: e8 96 2b 00 00 call 38cb + d35: 89 c3 mov %eax,%ebx + if (pid < 0) { + d37: 85 c0 test %eax,%eax + d39: 79 e5 jns d20 + printf(1, "fork failed\n"); + d3b: 83 ec 08 sub $0x8,%esp + d3e: 68 b9 4c 00 00 push $0x4cb9 + d43: 6a 01 push $0x1 + d45: e8 06 2d 00 00 call 3a50 + return; + d4a: 83 c4 10 add $0x10,%esp +} + d4d: 8d 65 f8 lea -0x8(%ebp),%esp + d50: 5b pop %ebx + d51: 5e pop %esi + d52: 5d pop %ebp + d53: c3 ret + d54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(1, "wait wrong pid\n"); + d58: 83 ec 08 sub $0x8,%esp + d5b: 68 5b 41 00 00 push $0x415b + d60: 6a 01 push $0x1 + d62: e8 e9 2c 00 00 call 3a50 + return; + d67: 83 c4 10 add $0x10,%esp +} + d6a: 8d 65 f8 lea -0x8(%ebp),%esp + d6d: 5b pop %ebx + d6e: 5e pop %esi + d6f: 5d pop %ebp + d70: c3 ret + printf(1, "exitwait ok\n"); + d71: 83 ec 08 sub $0x8,%esp + d74: 68 6b 41 00 00 push $0x416b + d79: 6a 01 push $0x1 + d7b: e8 d0 2c 00 00 call 3a50 + d80: 83 c4 10 add $0x10,%esp +} + d83: 8d 65 f8 lea -0x8(%ebp),%esp + d86: 5b pop %ebx + d87: 5e pop %esi + d88: 5d pop %ebp + d89: c3 ret + exit(); + d8a: e8 44 2b 00 00 call 38d3 + d8f: 90 nop + +00000d90 : +void mem(void) { + d90: 55 push %ebp + d91: 89 e5 mov %esp,%ebp + d93: 56 push %esi + d94: 31 f6 xor %esi,%esi + d96: 53 push %ebx + printf(1, "mem test\n"); + d97: 83 ec 08 sub $0x8,%esp + d9a: 68 78 41 00 00 push $0x4178 + d9f: 6a 01 push $0x1 + da1: e8 aa 2c 00 00 call 3a50 + ppid = getpid(); + da6: e8 70 2b 00 00 call 391b + dab: 89 c3 mov %eax,%ebx + if ((pid = fork()) == 0) { + dad: e8 19 2b 00 00 call 38cb + db2: 83 c4 10 add $0x10,%esp + db5: 85 c0 test %eax,%eax + db7: 74 0b je dc4 + db9: e9 8a 00 00 00 jmp e48 + dbe: 66 90 xchg %ax,%ax + *(char**)m2 = m1; + dc0: 89 30 mov %esi,(%eax) + dc2: 89 c6 mov %eax,%esi + while ((m2 = malloc(10001)) != 0) { + dc4: 83 ec 0c sub $0xc,%esp + dc7: 68 11 27 00 00 push $0x2711 + dcc: e8 af 2e 00 00 call 3c80 + dd1: 83 c4 10 add $0x10,%esp + dd4: 85 c0 test %eax,%eax + dd6: 75 e8 jne dc0 + while (m1) { + dd8: 85 f6 test %esi,%esi + dda: 74 18 je df4 + ddc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + m2 = *(char**)m1; + de0: 89 f0 mov %esi,%eax + free(m1); + de2: 83 ec 0c sub $0xc,%esp + m2 = *(char**)m1; + de5: 8b 36 mov (%esi),%esi + free(m1); + de7: 50 push %eax + de8: e8 03 2e 00 00 call 3bf0 + while (m1) { + ded: 83 c4 10 add $0x10,%esp + df0: 85 f6 test %esi,%esi + df2: 75 ec jne de0 + m1 = malloc(1024 * 20); + df4: 83 ec 0c sub $0xc,%esp + df7: 68 00 50 00 00 push $0x5000 + dfc: e8 7f 2e 00 00 call 3c80 + if (m1 == 0) { + e01: 83 c4 10 add $0x10,%esp + e04: 85 c0 test %eax,%eax + e06: 74 20 je e28 + free(m1); + e08: 83 ec 0c sub $0xc,%esp + e0b: 50 push %eax + e0c: e8 df 2d 00 00 call 3bf0 + printf(1, "mem ok\n"); + e11: 58 pop %eax + e12: 5a pop %edx + e13: 68 9c 41 00 00 push $0x419c + e18: 6a 01 push $0x1 + e1a: e8 31 2c 00 00 call 3a50 + exit(); + e1f: e8 af 2a 00 00 call 38d3 + e24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(1, "couldn't allocate mem?!!\n"); + e28: 83 ec 08 sub $0x8,%esp + e2b: 68 82 41 00 00 push $0x4182 + e30: 6a 01 push $0x1 + e32: e8 19 2c 00 00 call 3a50 + kill(ppid); + e37: 89 1c 24 mov %ebx,(%esp) + e3a: e8 b4 2a 00 00 call 38f3 + exit(); + e3f: e8 8f 2a 00 00 call 38d3 + e44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +} + e48: 8d 65 f8 lea -0x8(%ebp),%esp + e4b: 5b pop %ebx + e4c: 5e pop %esi + e4d: 5d pop %ebp + wait(); + e4e: e9 88 2a 00 00 jmp 38db + e53: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + e5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00000e60 : +void sharedfd(void) { + e60: 55 push %ebp + e61: 89 e5 mov %esp,%ebp + e63: 57 push %edi + e64: 56 push %esi + e65: 53 push %ebx + e66: 83 ec 34 sub $0x34,%esp + printf(1, "sharedfd test\n"); + e69: 68 a4 41 00 00 push $0x41a4 + e6e: 6a 01 push $0x1 + e70: e8 db 2b 00 00 call 3a50 + unlink("sharedfd"); + e75: c7 04 24 b3 41 00 00 movl $0x41b3,(%esp) + e7c: e8 d2 2a 00 00 call 3953 + fd = open("sharedfd", O_CREATE | O_RDWR); + e81: 5b pop %ebx + e82: 5e pop %esi + e83: 68 02 02 00 00 push $0x202 + e88: 68 b3 41 00 00 push $0x41b3 + e8d: e8 a9 2a 00 00 call 393b + if (fd < 0) { + e92: 83 c4 10 add $0x10,%esp + e95: 85 c0 test %eax,%eax + e97: 0f 88 2a 01 00 00 js fc7 + e9d: 89 c7 mov %eax,%edi + memset(buf, pid == 0 ? 'c' : 'p', sizeof(buf)); + e9f: 8d 75 de lea -0x22(%ebp),%esi + ea2: bb e8 03 00 00 mov $0x3e8,%ebx + pid = fork(); + ea7: e8 1f 2a 00 00 call 38cb + memset(buf, pid == 0 ? 'c' : 'p', sizeof(buf)); + eac: 83 f8 01 cmp $0x1,%eax + pid = fork(); + eaf: 89 45 d4 mov %eax,-0x2c(%ebp) + memset(buf, pid == 0 ? 'c' : 'p', sizeof(buf)); + eb2: 19 c0 sbb %eax,%eax + eb4: 83 ec 04 sub $0x4,%esp + eb7: 83 e0 f3 and $0xfffffff3,%eax + eba: 6a 0a push $0xa + ebc: 83 c0 70 add $0x70,%eax + ebf: 50 push %eax + ec0: 56 push %esi + ec1: e8 7a 28 00 00 call 3740 + ec6: 83 c4 10 add $0x10,%esp + ec9: eb 0a jmp ed5 + ecb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ecf: 90 nop + for (i = 0; i < 1000; i++) { + ed0: 83 eb 01 sub $0x1,%ebx + ed3: 74 26 je efb + if (write(fd, buf, sizeof(buf)) != sizeof(buf)) { + ed5: 83 ec 04 sub $0x4,%esp + ed8: 6a 0a push $0xa + eda: 56 push %esi + edb: 57 push %edi + edc: e8 62 2a 00 00 call 3943 + ee1: 83 c4 10 add $0x10,%esp + ee4: 83 f8 0a cmp $0xa,%eax + ee7: 74 e7 je ed0 + printf(1, "fstests: write sharedfd failed\n"); + ee9: 83 ec 08 sub $0x8,%esp + eec: 68 a4 4e 00 00 push $0x4ea4 + ef1: 6a 01 push $0x1 + ef3: e8 58 2b 00 00 call 3a50 + break; + ef8: 83 c4 10 add $0x10,%esp + if (pid == 0) { + efb: 8b 4d d4 mov -0x2c(%ebp),%ecx + efe: 85 c9 test %ecx,%ecx + f00: 0f 84 f5 00 00 00 je ffb + wait(); + f06: e8 d0 29 00 00 call 38db + close(fd); + f0b: 83 ec 0c sub $0xc,%esp + nc = np = 0; + f0e: 31 db xor %ebx,%ebx + close(fd); + f10: 57 push %edi + f11: 8d 7d e8 lea -0x18(%ebp),%edi + f14: e8 52 2a 00 00 call 396b + fd = open("sharedfd", 0); + f19: 58 pop %eax + f1a: 5a pop %edx + f1b: 6a 00 push $0x0 + f1d: 68 b3 41 00 00 push $0x41b3 + f22: e8 14 2a 00 00 call 393b + if (fd < 0) { + f27: 83 c4 10 add $0x10,%esp + nc = np = 0; + f2a: 31 d2 xor %edx,%edx + fd = open("sharedfd", 0); + f2c: 89 45 d0 mov %eax,-0x30(%ebp) + if (fd < 0) { + f2f: 85 c0 test %eax,%eax + f31: 0f 88 aa 00 00 00 js fe1 + f37: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + f3e: 66 90 xchg %ax,%ax + while ((n = read(fd, buf, sizeof(buf))) > 0) { + f40: 83 ec 04 sub $0x4,%esp + f43: 89 55 d4 mov %edx,-0x2c(%ebp) + f46: 6a 0a push $0xa + f48: 56 push %esi + f49: ff 75 d0 push -0x30(%ebp) + f4c: e8 9a 29 00 00 call 38eb + f51: 83 c4 10 add $0x10,%esp + f54: 85 c0 test %eax,%eax + f56: 7e 28 jle f80 + f58: 8b 55 d4 mov -0x2c(%ebp),%edx + f5b: 89 f0 mov %esi,%eax + f5d: eb 13 jmp f72 + f5f: 90 nop + np++; + f60: 80 f9 70 cmp $0x70,%cl + f63: 0f 94 c1 sete %cl + f66: 0f b6 c9 movzbl %cl,%ecx + f69: 01 cb add %ecx,%ebx + for (i = 0; i < sizeof(buf); i++) { + f6b: 83 c0 01 add $0x1,%eax + f6e: 39 f8 cmp %edi,%eax + f70: 74 ce je f40 + if (buf[i] == 'c') { + f72: 0f b6 08 movzbl (%eax),%ecx + f75: 80 f9 63 cmp $0x63,%cl + f78: 75 e6 jne f60 + nc++; + f7a: 83 c2 01 add $0x1,%edx + if (buf[i] == 'p') { + f7d: eb ec jmp f6b + f7f: 90 nop + close(fd); + f80: 83 ec 0c sub $0xc,%esp + f83: ff 75 d0 push -0x30(%ebp) + f86: e8 e0 29 00 00 call 396b + unlink("sharedfd"); + f8b: c7 04 24 b3 41 00 00 movl $0x41b3,(%esp) + f92: e8 bc 29 00 00 call 3953 + if (nc == 10000 && np == 10000) { + f97: 8b 55 d4 mov -0x2c(%ebp),%edx + f9a: 83 c4 10 add $0x10,%esp + f9d: 81 fa 10 27 00 00 cmp $0x2710,%edx + fa3: 75 5b jne 1000 + fa5: 81 fb 10 27 00 00 cmp $0x2710,%ebx + fab: 75 53 jne 1000 + printf(1, "sharedfd ok\n"); + fad: 83 ec 08 sub $0x8,%esp + fb0: 68 bc 41 00 00 push $0x41bc + fb5: 6a 01 push $0x1 + fb7: e8 94 2a 00 00 call 3a50 + fbc: 83 c4 10 add $0x10,%esp +} + fbf: 8d 65 f4 lea -0xc(%ebp),%esp + fc2: 5b pop %ebx + fc3: 5e pop %esi + fc4: 5f pop %edi + fc5: 5d pop %ebp + fc6: c3 ret + printf(1, "fstests: cannot open sharedfd for writing"); + fc7: 83 ec 08 sub $0x8,%esp + fca: 68 78 4e 00 00 push $0x4e78 + fcf: 6a 01 push $0x1 + fd1: e8 7a 2a 00 00 call 3a50 + return; + fd6: 83 c4 10 add $0x10,%esp +} + fd9: 8d 65 f4 lea -0xc(%ebp),%esp + fdc: 5b pop %ebx + fdd: 5e pop %esi + fde: 5f pop %edi + fdf: 5d pop %ebp + fe0: c3 ret + printf(1, "fstests: cannot open sharedfd for reading\n"); + fe1: 83 ec 08 sub $0x8,%esp + fe4: 68 c4 4e 00 00 push $0x4ec4 + fe9: 6a 01 push $0x1 + feb: e8 60 2a 00 00 call 3a50 + return; + ff0: 83 c4 10 add $0x10,%esp +} + ff3: 8d 65 f4 lea -0xc(%ebp),%esp + ff6: 5b pop %ebx + ff7: 5e pop %esi + ff8: 5f pop %edi + ff9: 5d pop %ebp + ffa: c3 ret + exit(); + ffb: e8 d3 28 00 00 call 38d3 + printf(1, "sharedfd oops %d %d\n", nc, np); + 1000: 53 push %ebx + 1001: 52 push %edx + 1002: 68 c9 41 00 00 push $0x41c9 + 1007: 6a 01 push $0x1 + 1009: e8 42 2a 00 00 call 3a50 + exit(); + 100e: e8 c0 28 00 00 call 38d3 + 1013: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 101a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001020 : +void fourfiles(void) { + 1020: 55 push %ebp + 1021: 89 e5 mov %esp,%ebp + 1023: 57 push %edi + 1024: 56 push %esi + printf(1, "fourfiles test\n"); + 1025: be de 41 00 00 mov $0x41de,%esi +void fourfiles(void) { + 102a: 53 push %ebx + for (pi = 0; pi < 4; pi++) { + 102b: 31 db xor %ebx,%ebx +void fourfiles(void) { + 102d: 83 ec 34 sub $0x34,%esp + char *names[] = { "f0", "f1", "f2", "f3" }; + 1030: c7 45 d8 de 41 00 00 movl $0x41de,-0x28(%ebp) + printf(1, "fourfiles test\n"); + 1037: 68 e4 41 00 00 push $0x41e4 + 103c: 6a 01 push $0x1 + char *names[] = { "f0", "f1", "f2", "f3" }; + 103e: c7 45 dc 27 43 00 00 movl $0x4327,-0x24(%ebp) + 1045: c7 45 e0 2b 43 00 00 movl $0x432b,-0x20(%ebp) + 104c: c7 45 e4 e1 41 00 00 movl $0x41e1,-0x1c(%ebp) + printf(1, "fourfiles test\n"); + 1053: e8 f8 29 00 00 call 3a50 + 1058: 83 c4 10 add $0x10,%esp + unlink(fname); + 105b: 83 ec 0c sub $0xc,%esp + 105e: 56 push %esi + 105f: e8 ef 28 00 00 call 3953 + pid = fork(); + 1064: e8 62 28 00 00 call 38cb + if (pid < 0) { + 1069: 83 c4 10 add $0x10,%esp + 106c: 85 c0 test %eax,%eax + 106e: 0f 88 64 01 00 00 js 11d8 + if (pid == 0) { + 1074: 0f 84 e9 00 00 00 je 1163 + for (pi = 0; pi < 4; pi++) { + 107a: 83 c3 01 add $0x1,%ebx + 107d: 83 fb 04 cmp $0x4,%ebx + 1080: 74 06 je 1088 + fname = names[pi]; + 1082: 8b 74 9d d8 mov -0x28(%ebp,%ebx,4),%esi + 1086: eb d3 jmp 105b + wait(); + 1088: e8 4e 28 00 00 call 38db + for (i = 0; i < 2; i++) { + 108d: 31 f6 xor %esi,%esi + wait(); + 108f: e8 47 28 00 00 call 38db + 1094: e8 42 28 00 00 call 38db + 1099: e8 3d 28 00 00 call 38db + fname = names[i]; + 109e: 8b 44 b5 d8 mov -0x28(%ebp,%esi,4),%eax + fd = open(fname, 0); + 10a2: 83 ec 08 sub $0x8,%esp + total = 0; + 10a5: 31 db xor %ebx,%ebx + fd = open(fname, 0); + 10a7: 6a 00 push $0x0 + 10a9: 50 push %eax + fname = names[i]; + 10aa: 89 45 d0 mov %eax,-0x30(%ebp) + fd = open(fname, 0); + 10ad: e8 89 28 00 00 call 393b + while ((n = read(fd, buf, sizeof(buf))) > 0) { + 10b2: 83 c4 10 add $0x10,%esp + fd = open(fname, 0); + 10b5: 89 45 d4 mov %eax,-0x2c(%ebp) + while ((n = read(fd, buf, sizeof(buf))) > 0) { + 10b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 10bf: 90 nop + 10c0: 83 ec 04 sub $0x4,%esp + 10c3: 68 00 20 00 00 push $0x2000 + 10c8: 68 a0 85 00 00 push $0x85a0 + 10cd: ff 75 d4 push -0x2c(%ebp) + 10d0: e8 16 28 00 00 call 38eb + 10d5: 83 c4 10 add $0x10,%esp + 10d8: 89 c7 mov %eax,%edi + 10da: 85 c0 test %eax,%eax + 10dc: 7e 20 jle 10fe + for (j = 0; j < n; j++) { + 10de: 31 c0 xor %eax,%eax + if (buf[j] != '0' + i) { + 10e0: 83 fe 01 cmp $0x1,%esi + 10e3: 0f be 88 a0 85 00 00 movsbl 0x85a0(%eax),%ecx + 10ea: 19 d2 sbb %edx,%edx + 10ec: 83 c2 31 add $0x31,%edx + 10ef: 39 d1 cmp %edx,%ecx + 10f1: 75 5c jne 114f + for (j = 0; j < n; j++) { + 10f3: 83 c0 01 add $0x1,%eax + 10f6: 39 c7 cmp %eax,%edi + 10f8: 75 e6 jne 10e0 + total += n; + 10fa: 01 fb add %edi,%ebx + 10fc: eb c2 jmp 10c0 + close(fd); + 10fe: 83 ec 0c sub $0xc,%esp + 1101: ff 75 d4 push -0x2c(%ebp) + 1104: e8 62 28 00 00 call 396b + if (total != 12 * 500) { + 1109: 83 c4 10 add $0x10,%esp + 110c: 81 fb 70 17 00 00 cmp $0x1770,%ebx + 1112: 0f 85 d4 00 00 00 jne 11ec + unlink(fname); + 1118: 83 ec 0c sub $0xc,%esp + 111b: ff 75 d0 push -0x30(%ebp) + 111e: e8 30 28 00 00 call 3953 + for (i = 0; i < 2; i++) { + 1123: 83 c4 10 add $0x10,%esp + 1126: 83 fe 01 cmp $0x1,%esi + 1129: 75 1a jne 1145 + printf(1, "fourfiles ok\n"); + 112b: 83 ec 08 sub $0x8,%esp + 112e: 68 22 42 00 00 push $0x4222 + 1133: 6a 01 push $0x1 + 1135: e8 16 29 00 00 call 3a50 +} + 113a: 83 c4 10 add $0x10,%esp + 113d: 8d 65 f4 lea -0xc(%ebp),%esp + 1140: 5b pop %ebx + 1141: 5e pop %esi + 1142: 5f pop %edi + 1143: 5d pop %ebp + 1144: c3 ret + 1145: be 01 00 00 00 mov $0x1,%esi + 114a: e9 4f ff ff ff jmp 109e + printf(1, "wrong char\n"); + 114f: 83 ec 08 sub $0x8,%esp + 1152: 68 05 42 00 00 push $0x4205 + 1157: 6a 01 push $0x1 + 1159: e8 f2 28 00 00 call 3a50 + exit(); + 115e: e8 70 27 00 00 call 38d3 + fd = open(fname, O_CREATE | O_RDWR); + 1163: 83 ec 08 sub $0x8,%esp + 1166: 68 02 02 00 00 push $0x202 + 116b: 56 push %esi + 116c: e8 ca 27 00 00 call 393b + if (fd < 0) { + 1171: 83 c4 10 add $0x10,%esp + fd = open(fname, O_CREATE | O_RDWR); + 1174: 89 c6 mov %eax,%esi + if (fd < 0) { + 1176: 85 c0 test %eax,%eax + 1178: 78 45 js 11bf + memset(buf, '0' + pi, 512); + 117a: 83 ec 04 sub $0x4,%esp + 117d: 83 c3 30 add $0x30,%ebx + 1180: 68 00 02 00 00 push $0x200 + 1185: 53 push %ebx + 1186: bb 0c 00 00 00 mov $0xc,%ebx + 118b: 68 a0 85 00 00 push $0x85a0 + 1190: e8 ab 25 00 00 call 3740 + 1195: 83 c4 10 add $0x10,%esp + if ((n = write(fd, buf, 500)) != 500) { + 1198: 83 ec 04 sub $0x4,%esp + 119b: 68 f4 01 00 00 push $0x1f4 + 11a0: 68 a0 85 00 00 push $0x85a0 + 11a5: 56 push %esi + 11a6: e8 98 27 00 00 call 3943 + 11ab: 83 c4 10 add $0x10,%esp + 11ae: 3d f4 01 00 00 cmp $0x1f4,%eax + 11b3: 75 4a jne 11ff + for (i = 0; i < 12; i++) { + 11b5: 83 eb 01 sub $0x1,%ebx + 11b8: 75 de jne 1198 + exit(); + 11ba: e8 14 27 00 00 call 38d3 + printf(1, "create failed\n"); + 11bf: 51 push %ecx + 11c0: 51 push %ecx + 11c1: 68 7f 44 00 00 push $0x447f + 11c6: 6a 01 push $0x1 + 11c8: e8 83 28 00 00 call 3a50 + exit(); + 11cd: e8 01 27 00 00 call 38d3 + 11d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printf(1, "fork failed\n"); + 11d8: 83 ec 08 sub $0x8,%esp + 11db: 68 b9 4c 00 00 push $0x4cb9 + 11e0: 6a 01 push $0x1 + 11e2: e8 69 28 00 00 call 3a50 + exit(); + 11e7: e8 e7 26 00 00 call 38d3 + printf(1, "wrong length %d\n", total); + 11ec: 50 push %eax + 11ed: 53 push %ebx + 11ee: 68 11 42 00 00 push $0x4211 + 11f3: 6a 01 push $0x1 + 11f5: e8 56 28 00 00 call 3a50 + exit(); + 11fa: e8 d4 26 00 00 call 38d3 + printf(1, "write failed %d\n", n); + 11ff: 52 push %edx + 1200: 50 push %eax + 1201: 68 f4 41 00 00 push $0x41f4 + 1206: 6a 01 push $0x1 + 1208: e8 43 28 00 00 call 3a50 + exit(); + 120d: e8 c1 26 00 00 call 38d3 + 1212: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001220 : +void createdelete(void) { + 1220: 55 push %ebp + 1221: 89 e5 mov %esp,%ebp + 1223: 57 push %edi + 1224: 56 push %esi + 1225: 53 push %ebx + for (pi = 0; pi < 4; pi++) { + 1226: 31 db xor %ebx,%ebx +void createdelete(void) { + 1228: 83 ec 44 sub $0x44,%esp + printf(1, "createdelete test\n"); + 122b: 68 30 42 00 00 push $0x4230 + 1230: 6a 01 push $0x1 + 1232: e8 19 28 00 00 call 3a50 + 1237: 83 c4 10 add $0x10,%esp + pid = fork(); + 123a: e8 8c 26 00 00 call 38cb + if (pid < 0) { + 123f: 85 c0 test %eax,%eax + 1241: 0f 88 c3 01 00 00 js 140a + if (pid == 0) { + 1247: 0f 84 13 01 00 00 je 1360 + for (pi = 0; pi < 4; pi++) { + 124d: 83 c3 01 add $0x1,%ebx + 1250: 83 fb 04 cmp $0x4,%ebx + 1253: 75 e5 jne 123a + wait(); + 1255: e8 81 26 00 00 call 38db + for (i = 0; i < N; i++) { + 125a: 31 f6 xor %esi,%esi + 125c: 8d 7d c8 lea -0x38(%ebp),%edi + wait(); + 125f: e8 77 26 00 00 call 38db + 1264: e8 72 26 00 00 call 38db + 1269: e8 6d 26 00 00 call 38db + name[0] = name[1] = name[2] = 0; + 126e: c6 45 ca 00 movb $0x0,-0x36(%ebp) + for (i = 0; i < N; i++) { + 1272: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if ((i == 0 || i >= N / 2) && fd < 0) { + 1278: 85 f6 test %esi,%esi + 127a: 8d 46 30 lea 0x30(%esi),%eax + 127d: 0f 94 c3 sete %bl + 1280: 83 fe 09 cmp $0x9,%esi + 1283: 88 45 c7 mov %al,-0x39(%ebp) + 1286: 0f 9f c0 setg %al + 1289: 09 c3 or %eax,%ebx + else if ((i >= 1 && i < N / 2) && fd >= 0) { + 128b: 8d 46 ff lea -0x1(%esi),%eax + 128e: 89 45 c0 mov %eax,-0x40(%ebp) + if ((i == 0 || i >= N / 2) && fd < 0) { + 1291: 88 5d c6 mov %bl,-0x3a(%ebp) + 1294: bb 70 00 00 00 mov $0x70,%ebx + fd = open(name, 0); + 1299: 83 ec 08 sub $0x8,%esp + name[1] = '0' + i; + 129c: 0f b6 45 c7 movzbl -0x39(%ebp),%eax + name[0] = 'p' + pi; + 12a0: 88 5d c8 mov %bl,-0x38(%ebp) + fd = open(name, 0); + 12a3: 6a 00 push $0x0 + 12a5: 57 push %edi + name[1] = '0' + i; + 12a6: 88 45 c9 mov %al,-0x37(%ebp) + fd = open(name, 0); + 12a9: e8 8d 26 00 00 call 393b + if ((i == 0 || i >= N / 2) && fd < 0) { + 12ae: 83 c4 10 add $0x10,%esp + 12b1: 80 7d c6 00 cmpb $0x0,-0x3a(%ebp) + 12b5: 0f 84 85 00 00 00 je 1340 + 12bb: 85 c0 test %eax,%eax + 12bd: 0f 88 32 01 00 00 js 13f5 + else if ((i >= 1 && i < N / 2) && fd >= 0) { + 12c3: 83 7d c0 08 cmpl $0x8,-0x40(%ebp) + 12c7: 76 7b jbe 1344 + close(fd); + 12c9: 83 ec 0c sub $0xc,%esp + 12cc: 50 push %eax + 12cd: e8 99 26 00 00 call 396b + 12d2: 83 c4 10 add $0x10,%esp + for (pi = 0; pi < 4; pi++) { + 12d5: 83 c3 01 add $0x1,%ebx + 12d8: 80 fb 74 cmp $0x74,%bl + 12db: 75 bc jne 1299 + for (i = 0; i < N; i++) { + 12dd: 83 c6 01 add $0x1,%esi + 12e0: 83 fe 14 cmp $0x14,%esi + 12e3: 75 93 jne 1278 + 12e5: be 70 00 00 00 mov $0x70,%esi + 12ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (pi = 0; pi < 4; pi++) { + 12f0: 8d 46 c0 lea -0x40(%esi),%eax + name[0] = 'p' + i; + 12f3: bb 04 00 00 00 mov $0x4,%ebx + 12f8: 88 45 c7 mov %al,-0x39(%ebp) + unlink(name); + 12fb: 83 ec 0c sub $0xc,%esp + name[0] = 'p' + i; + 12fe: 89 f0 mov %esi,%eax + unlink(name); + 1300: 57 push %edi + name[0] = 'p' + i; + 1301: 88 45 c8 mov %al,-0x38(%ebp) + name[1] = '0' + i; + 1304: 0f b6 45 c7 movzbl -0x39(%ebp),%eax + 1308: 88 45 c9 mov %al,-0x37(%ebp) + unlink(name); + 130b: e8 43 26 00 00 call 3953 + for (pi = 0; pi < 4; pi++) { + 1310: 83 c4 10 add $0x10,%esp + 1313: 83 eb 01 sub $0x1,%ebx + 1316: 75 e3 jne 12fb + for (i = 0; i < N; i++) { + 1318: 83 c6 01 add $0x1,%esi + 131b: 89 f0 mov %esi,%eax + 131d: 3c 84 cmp $0x84,%al + 131f: 75 cf jne 12f0 + printf(1, "createdelete ok\n"); + 1321: 83 ec 08 sub $0x8,%esp + 1324: 68 43 42 00 00 push $0x4243 + 1329: 6a 01 push $0x1 + 132b: e8 20 27 00 00 call 3a50 +} + 1330: 8d 65 f4 lea -0xc(%ebp),%esp + 1333: 5b pop %ebx + 1334: 5e pop %esi + 1335: 5f pop %edi + 1336: 5d pop %ebp + 1337: c3 ret + 1338: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 133f: 90 nop + else if ((i >= 1 && i < N / 2) && fd >= 0) { + 1340: 85 c0 test %eax,%eax + 1342: 78 91 js 12d5 + printf(1, "oops createdelete %s did exist\n", name); + 1344: 50 push %eax + 1345: 57 push %edi + 1346: 68 14 4f 00 00 push $0x4f14 + 134b: 6a 01 push $0x1 + 134d: e8 fe 26 00 00 call 3a50 + exit(); + 1352: e8 7c 25 00 00 call 38d3 + 1357: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 135e: 66 90 xchg %ax,%ax + name[0] = 'p' + pi; + 1360: 83 c3 70 add $0x70,%ebx + name[2] = '\0'; + 1363: c6 45 ca 00 movb $0x0,-0x36(%ebp) + 1367: be 01 00 00 00 mov $0x1,%esi + 136c: 8d 7d c8 lea -0x38(%ebp),%edi + name[0] = 'p' + pi; + 136f: 88 5d c8 mov %bl,-0x38(%ebp) + name[2] = '\0'; + 1372: 31 db xor %ebx,%ebx + 1374: eb 15 jmp 138b + 1376: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 137d: 8d 76 00 lea 0x0(%esi),%esi + for (i = 0; i < N; i++) { + 1380: 83 fe 14 cmp $0x14,%esi + 1383: 74 6b je 13f0 + 1385: 83 c3 01 add $0x1,%ebx + 1388: 83 c6 01 add $0x1,%esi + fd = open(name, O_CREATE | O_RDWR); + 138b: 83 ec 08 sub $0x8,%esp + name[1] = '0' + i; + 138e: 8d 43 30 lea 0x30(%ebx),%eax + fd = open(name, O_CREATE | O_RDWR); + 1391: 68 02 02 00 00 push $0x202 + 1396: 57 push %edi + name[1] = '0' + i; + 1397: 88 45 c9 mov %al,-0x37(%ebp) + fd = open(name, O_CREATE | O_RDWR); + 139a: e8 9c 25 00 00 call 393b + if (fd < 0) { + 139f: 83 c4 10 add $0x10,%esp + 13a2: 85 c0 test %eax,%eax + 13a4: 78 78 js 141e + close(fd); + 13a6: 83 ec 0c sub $0xc,%esp + 13a9: 50 push %eax + 13aa: e8 bc 25 00 00 call 396b + if (i > 0 && (i % 2) == 0) { + 13af: 83 c4 10 add $0x10,%esp + 13b2: 85 db test %ebx,%ebx + 13b4: 74 cf je 1385 + 13b6: f6 c3 01 test $0x1,%bl + 13b9: 75 c5 jne 1380 + if (unlink(name) < 0) { + 13bb: 83 ec 0c sub $0xc,%esp + name[1] = '0' + (i / 2); + 13be: 89 d8 mov %ebx,%eax + if (unlink(name) < 0) { + 13c0: 57 push %edi + name[1] = '0' + (i / 2); + 13c1: d1 f8 sar %eax + 13c3: 83 c0 30 add $0x30,%eax + 13c6: 88 45 c9 mov %al,-0x37(%ebp) + if (unlink(name) < 0) { + 13c9: e8 85 25 00 00 call 3953 + 13ce: 83 c4 10 add $0x10,%esp + 13d1: 85 c0 test %eax,%eax + 13d3: 79 ab jns 1380 + printf(1, "unlink failed\n"); + 13d5: 52 push %edx + 13d6: 52 push %edx + 13d7: 68 31 3e 00 00 push $0x3e31 + 13dc: 6a 01 push $0x1 + 13de: e8 6d 26 00 00 call 3a50 + exit(); + 13e3: e8 eb 24 00 00 call 38d3 + 13e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 13ef: 90 nop + exit(); + 13f0: e8 de 24 00 00 call 38d3 + printf(1, "oops createdelete %s didn't exist\n", name); + 13f5: 83 ec 04 sub $0x4,%esp + 13f8: 57 push %edi + 13f9: 68 f0 4e 00 00 push $0x4ef0 + 13fe: 6a 01 push $0x1 + 1400: e8 4b 26 00 00 call 3a50 + exit(); + 1405: e8 c9 24 00 00 call 38d3 + printf(1, "fork failed\n"); + 140a: 83 ec 08 sub $0x8,%esp + 140d: 68 b9 4c 00 00 push $0x4cb9 + 1412: 6a 01 push $0x1 + 1414: e8 37 26 00 00 call 3a50 + exit(); + 1419: e8 b5 24 00 00 call 38d3 + printf(1, "create failed\n"); + 141e: 83 ec 08 sub $0x8,%esp + 1421: 68 7f 44 00 00 push $0x447f + 1426: 6a 01 push $0x1 + 1428: e8 23 26 00 00 call 3a50 + exit(); + 142d: e8 a1 24 00 00 call 38d3 + 1432: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1439: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001440 : +void unlinkread(void) { + 1440: 55 push %ebp + 1441: 89 e5 mov %esp,%ebp + 1443: 56 push %esi + 1444: 53 push %ebx + printf(1, "unlinkread test\n"); + 1445: 83 ec 08 sub $0x8,%esp + 1448: 68 54 42 00 00 push $0x4254 + 144d: 6a 01 push $0x1 + 144f: e8 fc 25 00 00 call 3a50 + fd = open("unlinkread", O_CREATE | O_RDWR); + 1454: 5b pop %ebx + 1455: 5e pop %esi + 1456: 68 02 02 00 00 push $0x202 + 145b: 68 65 42 00 00 push $0x4265 + 1460: e8 d6 24 00 00 call 393b + if (fd < 0) { + 1465: 83 c4 10 add $0x10,%esp + 1468: 85 c0 test %eax,%eax + 146a: 0f 88 e6 00 00 00 js 1556 + write(fd, "hello", 5); + 1470: 83 ec 04 sub $0x4,%esp + 1473: 89 c3 mov %eax,%ebx + 1475: 6a 05 push $0x5 + 1477: 68 8a 42 00 00 push $0x428a + 147c: 50 push %eax + 147d: e8 c1 24 00 00 call 3943 + close(fd); + 1482: 89 1c 24 mov %ebx,(%esp) + 1485: e8 e1 24 00 00 call 396b + fd = open("unlinkread", O_RDWR); + 148a: 58 pop %eax + 148b: 5a pop %edx + 148c: 6a 02 push $0x2 + 148e: 68 65 42 00 00 push $0x4265 + 1493: e8 a3 24 00 00 call 393b + if (fd < 0) { + 1498: 83 c4 10 add $0x10,%esp + fd = open("unlinkread", O_RDWR); + 149b: 89 c3 mov %eax,%ebx + if (fd < 0) { + 149d: 85 c0 test %eax,%eax + 149f: 0f 88 10 01 00 00 js 15b5 + if (unlink("unlinkread") != 0) { + 14a5: 83 ec 0c sub $0xc,%esp + 14a8: 68 65 42 00 00 push $0x4265 + 14ad: e8 a1 24 00 00 call 3953 + 14b2: 83 c4 10 add $0x10,%esp + 14b5: 85 c0 test %eax,%eax + 14b7: 0f 85 e5 00 00 00 jne 15a2 + fd1 = open("unlinkread", O_CREATE | O_RDWR); + 14bd: 83 ec 08 sub $0x8,%esp + 14c0: 68 02 02 00 00 push $0x202 + 14c5: 68 65 42 00 00 push $0x4265 + 14ca: e8 6c 24 00 00 call 393b + write(fd1, "yyy", 3); + 14cf: 83 c4 0c add $0xc,%esp + 14d2: 6a 03 push $0x3 + fd1 = open("unlinkread", O_CREATE | O_RDWR); + 14d4: 89 c6 mov %eax,%esi + write(fd1, "yyy", 3); + 14d6: 68 c2 42 00 00 push $0x42c2 + 14db: 50 push %eax + 14dc: e8 62 24 00 00 call 3943 + close(fd1); + 14e1: 89 34 24 mov %esi,(%esp) + 14e4: e8 82 24 00 00 call 396b + if (read(fd, buf, sizeof(buf)) != 5) { + 14e9: 83 c4 0c add $0xc,%esp + 14ec: 68 00 20 00 00 push $0x2000 + 14f1: 68 a0 85 00 00 push $0x85a0 + 14f6: 53 push %ebx + 14f7: e8 ef 23 00 00 call 38eb + 14fc: 83 c4 10 add $0x10,%esp + 14ff: 83 f8 05 cmp $0x5,%eax + 1502: 0f 85 87 00 00 00 jne 158f + if (buf[0] != 'h') { + 1508: 80 3d a0 85 00 00 68 cmpb $0x68,0x85a0 + 150f: 75 6b jne 157c + if (write(fd, buf, 10) != 10) { + 1511: 83 ec 04 sub $0x4,%esp + 1514: 6a 0a push $0xa + 1516: 68 a0 85 00 00 push $0x85a0 + 151b: 53 push %ebx + 151c: e8 22 24 00 00 call 3943 + 1521: 83 c4 10 add $0x10,%esp + 1524: 83 f8 0a cmp $0xa,%eax + 1527: 75 40 jne 1569 + close(fd); + 1529: 83 ec 0c sub $0xc,%esp + 152c: 53 push %ebx + 152d: e8 39 24 00 00 call 396b + unlink("unlinkread"); + 1532: c7 04 24 65 42 00 00 movl $0x4265,(%esp) + 1539: e8 15 24 00 00 call 3953 + printf(1, "unlinkread ok\n"); + 153e: 58 pop %eax + 153f: 5a pop %edx + 1540: 68 0d 43 00 00 push $0x430d + 1545: 6a 01 push $0x1 + 1547: e8 04 25 00 00 call 3a50 +} + 154c: 83 c4 10 add $0x10,%esp + 154f: 8d 65 f8 lea -0x8(%ebp),%esp + 1552: 5b pop %ebx + 1553: 5e pop %esi + 1554: 5d pop %ebp + 1555: c3 ret + printf(1, "create unlinkread failed\n"); + 1556: 51 push %ecx + 1557: 51 push %ecx + 1558: 68 70 42 00 00 push $0x4270 + 155d: 6a 01 push $0x1 + 155f: e8 ec 24 00 00 call 3a50 + exit(); + 1564: e8 6a 23 00 00 call 38d3 + printf(1, "unlinkread write failed\n"); + 1569: 51 push %ecx + 156a: 51 push %ecx + 156b: 68 f4 42 00 00 push $0x42f4 + 1570: 6a 01 push $0x1 + 1572: e8 d9 24 00 00 call 3a50 + exit(); + 1577: e8 57 23 00 00 call 38d3 + printf(1, "unlinkread wrong data\n"); + 157c: 53 push %ebx + 157d: 53 push %ebx + 157e: 68 dd 42 00 00 push $0x42dd + 1583: 6a 01 push $0x1 + 1585: e8 c6 24 00 00 call 3a50 + exit(); + 158a: e8 44 23 00 00 call 38d3 + printf(1, "unlinkread read failed"); + 158f: 56 push %esi + 1590: 56 push %esi + 1591: 68 c6 42 00 00 push $0x42c6 + 1596: 6a 01 push $0x1 + 1598: e8 b3 24 00 00 call 3a50 + exit(); + 159d: e8 31 23 00 00 call 38d3 + printf(1, "unlink unlinkread failed\n"); + 15a2: 50 push %eax + 15a3: 50 push %eax + 15a4: 68 a8 42 00 00 push $0x42a8 + 15a9: 6a 01 push $0x1 + 15ab: e8 a0 24 00 00 call 3a50 + exit(); + 15b0: e8 1e 23 00 00 call 38d3 + printf(1, "open unlinkread failed\n"); + 15b5: 50 push %eax + 15b6: 50 push %eax + 15b7: 68 90 42 00 00 push $0x4290 + 15bc: 6a 01 push $0x1 + 15be: e8 8d 24 00 00 call 3a50 + exit(); + 15c3: e8 0b 23 00 00 call 38d3 + 15c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 15cf: 90 nop + +000015d0 : +void linktest(void) { + 15d0: 55 push %ebp + 15d1: 89 e5 mov %esp,%ebp + 15d3: 53 push %ebx + 15d4: 83 ec 0c sub $0xc,%esp + printf(1, "linktest\n"); + 15d7: 68 1c 43 00 00 push $0x431c + 15dc: 6a 01 push $0x1 + 15de: e8 6d 24 00 00 call 3a50 + unlink("lf1"); + 15e3: c7 04 24 26 43 00 00 movl $0x4326,(%esp) + 15ea: e8 64 23 00 00 call 3953 + unlink("lf2"); + 15ef: c7 04 24 2a 43 00 00 movl $0x432a,(%esp) + 15f6: e8 58 23 00 00 call 3953 + fd = open("lf1", O_CREATE | O_RDWR); + 15fb: 58 pop %eax + 15fc: 5a pop %edx + 15fd: 68 02 02 00 00 push $0x202 + 1602: 68 26 43 00 00 push $0x4326 + 1607: e8 2f 23 00 00 call 393b + if (fd < 0) { + 160c: 83 c4 10 add $0x10,%esp + 160f: 85 c0 test %eax,%eax + 1611: 0f 88 1e 01 00 00 js 1735 + if (write(fd, "hello", 5) != 5) { + 1617: 83 ec 04 sub $0x4,%esp + 161a: 89 c3 mov %eax,%ebx + 161c: 6a 05 push $0x5 + 161e: 68 8a 42 00 00 push $0x428a + 1623: 50 push %eax + 1624: e8 1a 23 00 00 call 3943 + 1629: 83 c4 10 add $0x10,%esp + 162c: 83 f8 05 cmp $0x5,%eax + 162f: 0f 85 98 01 00 00 jne 17cd + close(fd); + 1635: 83 ec 0c sub $0xc,%esp + 1638: 53 push %ebx + 1639: e8 2d 23 00 00 call 396b + if (link("lf1", "lf2") < 0) { + 163e: 5b pop %ebx + 163f: 58 pop %eax + 1640: 68 2a 43 00 00 push $0x432a + 1645: 68 26 43 00 00 push $0x4326 + 164a: e8 0c 23 00 00 call 395b + 164f: 83 c4 10 add $0x10,%esp + 1652: 85 c0 test %eax,%eax + 1654: 0f 88 60 01 00 00 js 17ba + unlink("lf1"); + 165a: 83 ec 0c sub $0xc,%esp + 165d: 68 26 43 00 00 push $0x4326 + 1662: e8 ec 22 00 00 call 3953 + if (open("lf1", 0) >= 0) { + 1667: 58 pop %eax + 1668: 5a pop %edx + 1669: 6a 00 push $0x0 + 166b: 68 26 43 00 00 push $0x4326 + 1670: e8 c6 22 00 00 call 393b + 1675: 83 c4 10 add $0x10,%esp + 1678: 85 c0 test %eax,%eax + 167a: 0f 89 27 01 00 00 jns 17a7 + fd = open("lf2", 0); + 1680: 83 ec 08 sub $0x8,%esp + 1683: 6a 00 push $0x0 + 1685: 68 2a 43 00 00 push $0x432a + 168a: e8 ac 22 00 00 call 393b + if (fd < 0) { + 168f: 83 c4 10 add $0x10,%esp + fd = open("lf2", 0); + 1692: 89 c3 mov %eax,%ebx + if (fd < 0) { + 1694: 85 c0 test %eax,%eax + 1696: 0f 88 f8 00 00 00 js 1794 + if (read(fd, buf, sizeof(buf)) != 5) { + 169c: 83 ec 04 sub $0x4,%esp + 169f: 68 00 20 00 00 push $0x2000 + 16a4: 68 a0 85 00 00 push $0x85a0 + 16a9: 50 push %eax + 16aa: e8 3c 22 00 00 call 38eb + 16af: 83 c4 10 add $0x10,%esp + 16b2: 83 f8 05 cmp $0x5,%eax + 16b5: 0f 85 c6 00 00 00 jne 1781 + close(fd); + 16bb: 83 ec 0c sub $0xc,%esp + 16be: 53 push %ebx + 16bf: e8 a7 22 00 00 call 396b + if (link("lf2", "lf2") >= 0) { + 16c4: 58 pop %eax + 16c5: 5a pop %edx + 16c6: 68 2a 43 00 00 push $0x432a + 16cb: 68 2a 43 00 00 push $0x432a + 16d0: e8 86 22 00 00 call 395b + 16d5: 83 c4 10 add $0x10,%esp + 16d8: 85 c0 test %eax,%eax + 16da: 0f 89 8e 00 00 00 jns 176e + unlink("lf2"); + 16e0: 83 ec 0c sub $0xc,%esp + 16e3: 68 2a 43 00 00 push $0x432a + 16e8: e8 66 22 00 00 call 3953 + if (link("lf2", "lf1") >= 0) { + 16ed: 59 pop %ecx + 16ee: 5b pop %ebx + 16ef: 68 26 43 00 00 push $0x4326 + 16f4: 68 2a 43 00 00 push $0x432a + 16f9: e8 5d 22 00 00 call 395b + 16fe: 83 c4 10 add $0x10,%esp + 1701: 85 c0 test %eax,%eax + 1703: 79 56 jns 175b + if (link(".", "lf1") >= 0) { + 1705: 83 ec 08 sub $0x8,%esp + 1708: 68 26 43 00 00 push $0x4326 + 170d: 68 ee 45 00 00 push $0x45ee + 1712: e8 44 22 00 00 call 395b + 1717: 83 c4 10 add $0x10,%esp + 171a: 85 c0 test %eax,%eax + 171c: 79 2a jns 1748 + printf(1, "linktest ok\n"); + 171e: 83 ec 08 sub $0x8,%esp + 1721: 68 c4 43 00 00 push $0x43c4 + 1726: 6a 01 push $0x1 + 1728: e8 23 23 00 00 call 3a50 +} + 172d: 8b 5d fc mov -0x4(%ebp),%ebx + 1730: 83 c4 10 add $0x10,%esp + 1733: c9 leave + 1734: c3 ret + printf(1, "create lf1 failed\n"); + 1735: 50 push %eax + 1736: 50 push %eax + 1737: 68 2e 43 00 00 push $0x432e + 173c: 6a 01 push $0x1 + 173e: e8 0d 23 00 00 call 3a50 + exit(); + 1743: e8 8b 21 00 00 call 38d3 + printf(1, "link . lf1 succeeded! oops\n"); + 1748: 50 push %eax + 1749: 50 push %eax + 174a: 68 a8 43 00 00 push $0x43a8 + 174f: 6a 01 push $0x1 + 1751: e8 fa 22 00 00 call 3a50 + exit(); + 1756: e8 78 21 00 00 call 38d3 + printf(1, "link non-existant succeeded! oops\n"); + 175b: 52 push %edx + 175c: 52 push %edx + 175d: 68 5c 4f 00 00 push $0x4f5c + 1762: 6a 01 push $0x1 + 1764: e8 e7 22 00 00 call 3a50 + exit(); + 1769: e8 65 21 00 00 call 38d3 + printf(1, "link lf2 lf2 succeeded! oops\n"); + 176e: 50 push %eax + 176f: 50 push %eax + 1770: 68 8a 43 00 00 push $0x438a + 1775: 6a 01 push $0x1 + 1777: e8 d4 22 00 00 call 3a50 + exit(); + 177c: e8 52 21 00 00 call 38d3 + printf(1, "read lf2 failed\n"); + 1781: 51 push %ecx + 1782: 51 push %ecx + 1783: 68 79 43 00 00 push $0x4379 + 1788: 6a 01 push $0x1 + 178a: e8 c1 22 00 00 call 3a50 + exit(); + 178f: e8 3f 21 00 00 call 38d3 + printf(1, "open lf2 failed\n"); + 1794: 53 push %ebx + 1795: 53 push %ebx + 1796: 68 68 43 00 00 push $0x4368 + 179b: 6a 01 push $0x1 + 179d: e8 ae 22 00 00 call 3a50 + exit(); + 17a2: e8 2c 21 00 00 call 38d3 + printf(1, "unlinked lf1 but it is still there!\n"); + 17a7: 50 push %eax + 17a8: 50 push %eax + 17a9: 68 34 4f 00 00 push $0x4f34 + 17ae: 6a 01 push $0x1 + 17b0: e8 9b 22 00 00 call 3a50 + exit(); + 17b5: e8 19 21 00 00 call 38d3 + printf(1, "link lf1 lf2 failed\n"); + 17ba: 51 push %ecx + 17bb: 51 push %ecx + 17bc: 68 53 43 00 00 push $0x4353 + 17c1: 6a 01 push $0x1 + 17c3: e8 88 22 00 00 call 3a50 + exit(); + 17c8: e8 06 21 00 00 call 38d3 + printf(1, "write lf1 failed\n"); + 17cd: 50 push %eax + 17ce: 50 push %eax + 17cf: 68 41 43 00 00 push $0x4341 + 17d4: 6a 01 push $0x1 + 17d6: e8 75 22 00 00 call 3a50 + exit(); + 17db: e8 f3 20 00 00 call 38d3 + +000017e0 : +void concreate(void) { + 17e0: 55 push %ebp + 17e1: 89 e5 mov %esp,%ebp + 17e3: 57 push %edi + 17e4: 56 push %esi + for (i = 0; i < 40; i++) { + 17e5: 31 f6 xor %esi,%esi +void concreate(void) { + 17e7: 53 push %ebx + 17e8: 8d 5d ad lea -0x53(%ebp),%ebx + 17eb: 83 ec 64 sub $0x64,%esp + printf(1, "concreate test\n"); + 17ee: 68 d1 43 00 00 push $0x43d1 + 17f3: 6a 01 push $0x1 + 17f5: e8 56 22 00 00 call 3a50 + file[0] = 'C'; + 17fa: c6 45 ad 43 movb $0x43,-0x53(%ebp) + file[2] = '\0'; + 17fe: 83 c4 10 add $0x10,%esp + 1801: c6 45 af 00 movb $0x0,-0x51(%ebp) + for (i = 0; i < 40; i++) { + 1805: eb 4c jmp 1853 + 1807: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 180e: 66 90 xchg %ax,%ax + 1810: 69 c6 ab aa aa aa imul $0xaaaaaaab,%esi,%eax + if (pid && (i % 3) == 1) { + 1816: 3d ab aa aa aa cmp $0xaaaaaaab,%eax + 181b: 0f 83 af 00 00 00 jae 18d0 + fd = open(file, O_CREATE | O_RDWR); + 1821: 83 ec 08 sub $0x8,%esp + 1824: 68 02 02 00 00 push $0x202 + 1829: 53 push %ebx + 182a: e8 0c 21 00 00 call 393b + if (fd < 0) { + 182f: 83 c4 10 add $0x10,%esp + 1832: 85 c0 test %eax,%eax + 1834: 78 5f js 1895 + close(fd); + 1836: 83 ec 0c sub $0xc,%esp + for (i = 0; i < 40; i++) { + 1839: 83 c6 01 add $0x1,%esi + close(fd); + 183c: 50 push %eax + 183d: e8 29 21 00 00 call 396b + 1842: 83 c4 10 add $0x10,%esp + wait(); + 1845: e8 91 20 00 00 call 38db + for (i = 0; i < 40; i++) { + 184a: 83 fe 28 cmp $0x28,%esi + 184d: 0f 84 9f 00 00 00 je 18f2 + unlink(file); + 1853: 83 ec 0c sub $0xc,%esp + file[1] = '0' + i; + 1856: 8d 46 30 lea 0x30(%esi),%eax + unlink(file); + 1859: 53 push %ebx + file[1] = '0' + i; + 185a: 88 45 ae mov %al,-0x52(%ebp) + unlink(file); + 185d: e8 f1 20 00 00 call 3953 + pid = fork(); + 1862: e8 64 20 00 00 call 38cb + if (pid && (i % 3) == 1) { + 1867: 83 c4 10 add $0x10,%esp + 186a: 85 c0 test %eax,%eax + 186c: 75 a2 jne 1810 + link("C0", file); + 186e: 69 f6 cd cc cc cc imul $0xcccccccd,%esi,%esi + else if (pid == 0 && (i % 5) == 1) { + 1874: 81 fe cd cc cc cc cmp $0xcccccccd,%esi + 187a: 73 34 jae 18b0 + fd = open(file, O_CREATE | O_RDWR); + 187c: 83 ec 08 sub $0x8,%esp + 187f: 68 02 02 00 00 push $0x202 + 1884: 53 push %ebx + 1885: e8 b1 20 00 00 call 393b + if (fd < 0) { + 188a: 83 c4 10 add $0x10,%esp + 188d: 85 c0 test %eax,%eax + 188f: 0f 89 39 02 00 00 jns 1ace + printf(1, "concreate create %s failed\n", file); + 1895: 83 ec 04 sub $0x4,%esp + 1898: 53 push %ebx + 1899: 68 e4 43 00 00 push $0x43e4 + 189e: 6a 01 push $0x1 + 18a0: e8 ab 21 00 00 call 3a50 + exit(); + 18a5: e8 29 20 00 00 call 38d3 + 18aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + link("C0", file); + 18b0: 83 ec 08 sub $0x8,%esp + 18b3: 53 push %ebx + 18b4: 68 e1 43 00 00 push $0x43e1 + 18b9: e8 9d 20 00 00 call 395b + 18be: 83 c4 10 add $0x10,%esp + exit(); + 18c1: e8 0d 20 00 00 call 38d3 + 18c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 18cd: 8d 76 00 lea 0x0(%esi),%esi + link("C0", file); + 18d0: 83 ec 08 sub $0x8,%esp + for (i = 0; i < 40; i++) { + 18d3: 83 c6 01 add $0x1,%esi + link("C0", file); + 18d6: 53 push %ebx + 18d7: 68 e1 43 00 00 push $0x43e1 + 18dc: e8 7a 20 00 00 call 395b + 18e1: 83 c4 10 add $0x10,%esp + wait(); + 18e4: e8 f2 1f 00 00 call 38db + for (i = 0; i < 40; i++) { + 18e9: 83 fe 28 cmp $0x28,%esi + 18ec: 0f 85 61 ff ff ff jne 1853 + memset(fa, 0, sizeof(fa)); + 18f2: 83 ec 04 sub $0x4,%esp + 18f5: 8d 45 c0 lea -0x40(%ebp),%eax + 18f8: 6a 28 push $0x28 + 18fa: 6a 00 push $0x0 + 18fc: 50 push %eax + 18fd: e8 3e 1e 00 00 call 3740 + fd = open(".", 0); + 1902: 5e pop %esi + 1903: 5f pop %edi + 1904: 6a 00 push $0x0 + 1906: 68 ee 45 00 00 push $0x45ee + 190b: 8d 7d b0 lea -0x50(%ebp),%edi + 190e: e8 28 20 00 00 call 393b + n = 0; + 1913: c7 45 a4 00 00 00 00 movl $0x0,-0x5c(%ebp) + while (read(fd, &de, sizeof(de)) > 0) { + 191a: 83 c4 10 add $0x10,%esp + fd = open(".", 0); + 191d: 89 c6 mov %eax,%esi + while (read(fd, &de, sizeof(de)) > 0) { + 191f: 90 nop + 1920: 83 ec 04 sub $0x4,%esp + 1923: 6a 10 push $0x10 + 1925: 57 push %edi + 1926: 56 push %esi + 1927: e8 bf 1f 00 00 call 38eb + 192c: 83 c4 10 add $0x10,%esp + 192f: 85 c0 test %eax,%eax + 1931: 7e 3d jle 1970 + if (de.inum == 0) { + 1933: 66 83 7d b0 00 cmpw $0x0,-0x50(%ebp) + 1938: 74 e6 je 1920 + if (de.name[0] == 'C' && de.name[2] == '\0') { + 193a: 80 7d b2 43 cmpb $0x43,-0x4e(%ebp) + 193e: 75 e0 jne 1920 + 1940: 80 7d b4 00 cmpb $0x0,-0x4c(%ebp) + 1944: 75 da jne 1920 + i = de.name[1] - '0'; + 1946: 0f be 45 b3 movsbl -0x4d(%ebp),%eax + 194a: 83 e8 30 sub $0x30,%eax + if (i < 0 || i >= sizeof(fa)) { + 194d: 83 f8 27 cmp $0x27,%eax + 1950: 0f 87 60 01 00 00 ja 1ab6 + if (fa[i]) { + 1956: 80 7c 05 c0 00 cmpb $0x0,-0x40(%ebp,%eax,1) + 195b: 0f 85 3d 01 00 00 jne 1a9e + n++; + 1961: 83 45 a4 01 addl $0x1,-0x5c(%ebp) + fa[i] = 1; + 1965: c6 44 05 c0 01 movb $0x1,-0x40(%ebp,%eax,1) + n++; + 196a: eb b4 jmp 1920 + 196c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + close(fd); + 1970: 83 ec 0c sub $0xc,%esp + 1973: 56 push %esi + 1974: e8 f2 1f 00 00 call 396b + if (n != 40) { + 1979: 83 c4 10 add $0x10,%esp + 197c: 83 7d a4 28 cmpl $0x28,-0x5c(%ebp) + 1980: 0f 85 05 01 00 00 jne 1a8b + for (i = 0; i < 40; i++) { + 1986: 31 f6 xor %esi,%esi + 1988: eb 4c jmp 19d6 + 198a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + ((i % 3) == 1 && pid != 0)) { + 1990: 85 ff test %edi,%edi + 1992: 74 05 je 1999 + 1994: 83 f8 01 cmp $0x1,%eax + 1997: 74 6c je 1a05 + unlink(file); + 1999: 83 ec 0c sub $0xc,%esp + 199c: 53 push %ebx + 199d: e8 b1 1f 00 00 call 3953 + unlink(file); + 19a2: 89 1c 24 mov %ebx,(%esp) + 19a5: e8 a9 1f 00 00 call 3953 + unlink(file); + 19aa: 89 1c 24 mov %ebx,(%esp) + 19ad: e8 a1 1f 00 00 call 3953 + unlink(file); + 19b2: 89 1c 24 mov %ebx,(%esp) + 19b5: e8 99 1f 00 00 call 3953 + 19ba: 83 c4 10 add $0x10,%esp + if (pid == 0) { + 19bd: 85 ff test %edi,%edi + 19bf: 0f 84 fc fe ff ff je 18c1 + wait(); + 19c5: e8 11 1f 00 00 call 38db + for (i = 0; i < 40; i++) { + 19ca: 83 c6 01 add $0x1,%esi + 19cd: 83 fe 28 cmp $0x28,%esi + 19d0: 0f 84 8a 00 00 00 je 1a60 + file[1] = '0' + i; + 19d6: 8d 46 30 lea 0x30(%esi),%eax + 19d9: 88 45 ae mov %al,-0x52(%ebp) + pid = fork(); + 19dc: e8 ea 1e 00 00 call 38cb + 19e1: 89 c7 mov %eax,%edi + if (pid < 0) { + 19e3: 85 c0 test %eax,%eax + 19e5: 0f 88 8c 00 00 00 js 1a77 + if (((i % 3) == 0 && pid == 0) || + 19eb: b8 ab aa aa aa mov $0xaaaaaaab,%eax + 19f0: f7 e6 mul %esi + 19f2: 89 d0 mov %edx,%eax + 19f4: 83 e2 fe and $0xfffffffe,%edx + 19f7: d1 e8 shr %eax + 19f9: 01 c2 add %eax,%edx + 19fb: 89 f0 mov %esi,%eax + 19fd: 29 d0 sub %edx,%eax + 19ff: 89 c1 mov %eax,%ecx + 1a01: 09 f9 or %edi,%ecx + 1a03: 75 8b jne 1990 + close(open(file, 0)); + 1a05: 83 ec 08 sub $0x8,%esp + 1a08: 6a 00 push $0x0 + 1a0a: 53 push %ebx + 1a0b: e8 2b 1f 00 00 call 393b + 1a10: 89 04 24 mov %eax,(%esp) + 1a13: e8 53 1f 00 00 call 396b + close(open(file, 0)); + 1a18: 58 pop %eax + 1a19: 5a pop %edx + 1a1a: 6a 00 push $0x0 + 1a1c: 53 push %ebx + 1a1d: e8 19 1f 00 00 call 393b + 1a22: 89 04 24 mov %eax,(%esp) + 1a25: e8 41 1f 00 00 call 396b + close(open(file, 0)); + 1a2a: 59 pop %ecx + 1a2b: 58 pop %eax + 1a2c: 6a 00 push $0x0 + 1a2e: 53 push %ebx + 1a2f: e8 07 1f 00 00 call 393b + 1a34: 89 04 24 mov %eax,(%esp) + 1a37: e8 2f 1f 00 00 call 396b + close(open(file, 0)); + 1a3c: 58 pop %eax + 1a3d: 5a pop %edx + 1a3e: 6a 00 push $0x0 + 1a40: 53 push %ebx + 1a41: e8 f5 1e 00 00 call 393b + 1a46: 89 04 24 mov %eax,(%esp) + 1a49: e8 1d 1f 00 00 call 396b + 1a4e: 83 c4 10 add $0x10,%esp + 1a51: e9 67 ff ff ff jmp 19bd + 1a56: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1a5d: 8d 76 00 lea 0x0(%esi),%esi + printf(1, "concreate ok\n"); + 1a60: 83 ec 08 sub $0x8,%esp + 1a63: 68 36 44 00 00 push $0x4436 + 1a68: 6a 01 push $0x1 + 1a6a: e8 e1 1f 00 00 call 3a50 +} + 1a6f: 8d 65 f4 lea -0xc(%ebp),%esp + 1a72: 5b pop %ebx + 1a73: 5e pop %esi + 1a74: 5f pop %edi + 1a75: 5d pop %ebp + 1a76: c3 ret + printf(1, "fork failed\n"); + 1a77: 83 ec 08 sub $0x8,%esp + 1a7a: 68 b9 4c 00 00 push $0x4cb9 + 1a7f: 6a 01 push $0x1 + 1a81: e8 ca 1f 00 00 call 3a50 + exit(); + 1a86: e8 48 1e 00 00 call 38d3 + printf(1, "concreate not enough files in directory listing\n"); + 1a8b: 51 push %ecx + 1a8c: 51 push %ecx + 1a8d: 68 80 4f 00 00 push $0x4f80 + 1a92: 6a 01 push $0x1 + 1a94: e8 b7 1f 00 00 call 3a50 + exit(); + 1a99: e8 35 1e 00 00 call 38d3 + printf(1, "concreate duplicate file %s\n", de.name); + 1a9e: 83 ec 04 sub $0x4,%esp + 1aa1: 8d 45 b2 lea -0x4e(%ebp),%eax + 1aa4: 50 push %eax + 1aa5: 68 19 44 00 00 push $0x4419 + 1aaa: 6a 01 push $0x1 + 1aac: e8 9f 1f 00 00 call 3a50 + exit(); + 1ab1: e8 1d 1e 00 00 call 38d3 + printf(1, "concreate weird file %s\n", de.name); + 1ab6: 83 ec 04 sub $0x4,%esp + 1ab9: 8d 45 b2 lea -0x4e(%ebp),%eax + 1abc: 50 push %eax + 1abd: 68 00 44 00 00 push $0x4400 + 1ac2: 6a 01 push $0x1 + 1ac4: e8 87 1f 00 00 call 3a50 + exit(); + 1ac9: e8 05 1e 00 00 call 38d3 + close(fd); + 1ace: 83 ec 0c sub $0xc,%esp + 1ad1: 50 push %eax + 1ad2: e8 94 1e 00 00 call 396b + 1ad7: 83 c4 10 add $0x10,%esp + 1ada: e9 e2 fd ff ff jmp 18c1 + 1adf: 90 nop + +00001ae0 : +void linkunlink() { + 1ae0: 55 push %ebp + 1ae1: 89 e5 mov %esp,%ebp + 1ae3: 57 push %edi + 1ae4: 56 push %esi + 1ae5: 53 push %ebx + 1ae6: 83 ec 24 sub $0x24,%esp + printf(1, "linkunlink test\n"); + 1ae9: 68 44 44 00 00 push $0x4444 + 1aee: 6a 01 push $0x1 + 1af0: e8 5b 1f 00 00 call 3a50 + unlink("x"); + 1af5: c7 04 24 d1 46 00 00 movl $0x46d1,(%esp) + 1afc: e8 52 1e 00 00 call 3953 + pid = fork(); + 1b01: e8 c5 1d 00 00 call 38cb + if (pid < 0) { + 1b06: 83 c4 10 add $0x10,%esp + pid = fork(); + 1b09: 89 45 e4 mov %eax,-0x1c(%ebp) + if (pid < 0) { + 1b0c: 85 c0 test %eax,%eax + 1b0e: 0f 88 b6 00 00 00 js 1bca + unsigned int x = (pid ? 1 : 97); + 1b14: 83 7d e4 01 cmpl $0x1,-0x1c(%ebp) + 1b18: bb 64 00 00 00 mov $0x64,%ebx + if ((x % 3) == 0) { + 1b1d: be ab aa aa aa mov $0xaaaaaaab,%esi + unsigned int x = (pid ? 1 : 97); + 1b22: 19 ff sbb %edi,%edi + 1b24: 83 e7 60 and $0x60,%edi + 1b27: 83 c7 01 add $0x1,%edi + 1b2a: eb 1e jmp 1b4a + 1b2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + else if ((x % 3) == 1) { + 1b30: 83 f8 01 cmp $0x1,%eax + 1b33: 74 7b je 1bb0 + unlink("x"); + 1b35: 83 ec 0c sub $0xc,%esp + 1b38: 68 d1 46 00 00 push $0x46d1 + 1b3d: e8 11 1e 00 00 call 3953 + 1b42: 83 c4 10 add $0x10,%esp + for (i = 0; i < 100; i++) { + 1b45: 83 eb 01 sub $0x1,%ebx + 1b48: 74 41 je 1b8b + x = x * 1103515245 + 12345; + 1b4a: 69 cf 6d 4e c6 41 imul $0x41c64e6d,%edi,%ecx + 1b50: 8d b9 39 30 00 00 lea 0x3039(%ecx),%edi + if ((x % 3) == 0) { + 1b56: 89 f8 mov %edi,%eax + 1b58: f7 e6 mul %esi + 1b5a: 89 d0 mov %edx,%eax + 1b5c: 83 e2 fe and $0xfffffffe,%edx + 1b5f: d1 e8 shr %eax + 1b61: 01 c2 add %eax,%edx + 1b63: 89 f8 mov %edi,%eax + 1b65: 29 d0 sub %edx,%eax + 1b67: 75 c7 jne 1b30 + close(open("x", O_RDWR | O_CREATE)); + 1b69: 83 ec 08 sub $0x8,%esp + 1b6c: 68 02 02 00 00 push $0x202 + 1b71: 68 d1 46 00 00 push $0x46d1 + 1b76: e8 c0 1d 00 00 call 393b + 1b7b: 89 04 24 mov %eax,(%esp) + 1b7e: e8 e8 1d 00 00 call 396b + 1b83: 83 c4 10 add $0x10,%esp + for (i = 0; i < 100; i++) { + 1b86: 83 eb 01 sub $0x1,%ebx + 1b89: 75 bf jne 1b4a + if (pid) { + 1b8b: 8b 45 e4 mov -0x1c(%ebp),%eax + 1b8e: 85 c0 test %eax,%eax + 1b90: 74 4b je 1bdd + wait(); + 1b92: e8 44 1d 00 00 call 38db + printf(1, "linkunlink ok\n"); + 1b97: 83 ec 08 sub $0x8,%esp + 1b9a: 68 59 44 00 00 push $0x4459 + 1b9f: 6a 01 push $0x1 + 1ba1: e8 aa 1e 00 00 call 3a50 +} + 1ba6: 8d 65 f4 lea -0xc(%ebp),%esp + 1ba9: 5b pop %ebx + 1baa: 5e pop %esi + 1bab: 5f pop %edi + 1bac: 5d pop %ebp + 1bad: c3 ret + 1bae: 66 90 xchg %ax,%ax + link("cat", "x"); + 1bb0: 83 ec 08 sub $0x8,%esp + 1bb3: 68 d1 46 00 00 push $0x46d1 + 1bb8: 68 55 44 00 00 push $0x4455 + 1bbd: e8 99 1d 00 00 call 395b + 1bc2: 83 c4 10 add $0x10,%esp + 1bc5: e9 7b ff ff ff jmp 1b45 + printf(1, "fork failed\n"); + 1bca: 52 push %edx + 1bcb: 52 push %edx + 1bcc: 68 b9 4c 00 00 push $0x4cb9 + 1bd1: 6a 01 push $0x1 + 1bd3: e8 78 1e 00 00 call 3a50 + exit(); + 1bd8: e8 f6 1c 00 00 call 38d3 + exit(); + 1bdd: e8 f1 1c 00 00 call 38d3 + 1be2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1be9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001bf0 : +void bigdir(void) { + 1bf0: 55 push %ebp + 1bf1: 89 e5 mov %esp,%ebp + 1bf3: 57 push %edi + 1bf4: 56 push %esi + 1bf5: 53 push %ebx + 1bf6: 83 ec 24 sub $0x24,%esp + printf(1, "bigdir test\n"); + 1bf9: 68 68 44 00 00 push $0x4468 + 1bfe: 6a 01 push $0x1 + 1c00: e8 4b 1e 00 00 call 3a50 + unlink("bd"); + 1c05: c7 04 24 75 44 00 00 movl $0x4475,(%esp) + 1c0c: e8 42 1d 00 00 call 3953 + fd = open("bd", O_CREATE); + 1c11: 5a pop %edx + 1c12: 59 pop %ecx + 1c13: 68 00 02 00 00 push $0x200 + 1c18: 68 75 44 00 00 push $0x4475 + 1c1d: e8 19 1d 00 00 call 393b + if (fd < 0) { + 1c22: 83 c4 10 add $0x10,%esp + 1c25: 85 c0 test %eax,%eax + 1c27: 0f 88 de 00 00 00 js 1d0b + close(fd); + 1c2d: 83 ec 0c sub $0xc,%esp + for (i = 0; i < 500; i++) { + 1c30: 31 f6 xor %esi,%esi + 1c32: 8d 7d de lea -0x22(%ebp),%edi + close(fd); + 1c35: 50 push %eax + 1c36: e8 30 1d 00 00 call 396b + 1c3b: 83 c4 10 add $0x10,%esp + 1c3e: 66 90 xchg %ax,%ax + name[1] = '0' + (i / 64); + 1c40: 89 f0 mov %esi,%eax + if (link("bd", name) != 0) { + 1c42: 83 ec 08 sub $0x8,%esp + name[0] = 'x'; + 1c45: c6 45 de 78 movb $0x78,-0x22(%ebp) + name[1] = '0' + (i / 64); + 1c49: c1 f8 06 sar $0x6,%eax + if (link("bd", name) != 0) { + 1c4c: 57 push %edi + name[1] = '0' + (i / 64); + 1c4d: 83 c0 30 add $0x30,%eax + if (link("bd", name) != 0) { + 1c50: 68 75 44 00 00 push $0x4475 + name[1] = '0' + (i / 64); + 1c55: 88 45 df mov %al,-0x21(%ebp) + name[2] = '0' + (i % 64); + 1c58: 89 f0 mov %esi,%eax + 1c5a: 83 e0 3f and $0x3f,%eax + name[3] = '\0'; + 1c5d: c6 45 e1 00 movb $0x0,-0x1f(%ebp) + name[2] = '0' + (i % 64); + 1c61: 83 c0 30 add $0x30,%eax + 1c64: 88 45 e0 mov %al,-0x20(%ebp) + if (link("bd", name) != 0) { + 1c67: e8 ef 1c 00 00 call 395b + 1c6c: 83 c4 10 add $0x10,%esp + 1c6f: 89 c3 mov %eax,%ebx + 1c71: 85 c0 test %eax,%eax + 1c73: 75 6e jne 1ce3 + for (i = 0; i < 500; i++) { + 1c75: 83 c6 01 add $0x1,%esi + 1c78: 81 fe f4 01 00 00 cmp $0x1f4,%esi + 1c7e: 75 c0 jne 1c40 + unlink("bd"); + 1c80: 83 ec 0c sub $0xc,%esp + 1c83: 68 75 44 00 00 push $0x4475 + 1c88: e8 c6 1c 00 00 call 3953 + 1c8d: 83 c4 10 add $0x10,%esp + name[1] = '0' + (i / 64); + 1c90: 89 d8 mov %ebx,%eax + if (unlink(name) != 0) { + 1c92: 83 ec 0c sub $0xc,%esp + name[0] = 'x'; + 1c95: c6 45 de 78 movb $0x78,-0x22(%ebp) + name[1] = '0' + (i / 64); + 1c99: c1 f8 06 sar $0x6,%eax + if (unlink(name) != 0) { + 1c9c: 57 push %edi + name[1] = '0' + (i / 64); + 1c9d: 83 c0 30 add $0x30,%eax + name[3] = '\0'; + 1ca0: c6 45 e1 00 movb $0x0,-0x1f(%ebp) + name[1] = '0' + (i / 64); + 1ca4: 88 45 df mov %al,-0x21(%ebp) + name[2] = '0' + (i % 64); + 1ca7: 89 d8 mov %ebx,%eax + 1ca9: 83 e0 3f and $0x3f,%eax + 1cac: 83 c0 30 add $0x30,%eax + 1caf: 88 45 e0 mov %al,-0x20(%ebp) + if (unlink(name) != 0) { + 1cb2: e8 9c 1c 00 00 call 3953 + 1cb7: 83 c4 10 add $0x10,%esp + 1cba: 85 c0 test %eax,%eax + 1cbc: 75 39 jne 1cf7 + for (i = 0; i < 500; i++) { + 1cbe: 83 c3 01 add $0x1,%ebx + 1cc1: 81 fb f4 01 00 00 cmp $0x1f4,%ebx + 1cc7: 75 c7 jne 1c90 + printf(1, "bigdir ok\n"); + 1cc9: 83 ec 08 sub $0x8,%esp + 1ccc: 68 b7 44 00 00 push $0x44b7 + 1cd1: 6a 01 push $0x1 + 1cd3: e8 78 1d 00 00 call 3a50 + 1cd8: 83 c4 10 add $0x10,%esp +} + 1cdb: 8d 65 f4 lea -0xc(%ebp),%esp + 1cde: 5b pop %ebx + 1cdf: 5e pop %esi + 1ce0: 5f pop %edi + 1ce1: 5d pop %ebp + 1ce2: c3 ret + printf(1, "bigdir link failed\n"); + 1ce3: 83 ec 08 sub $0x8,%esp + 1ce6: 68 8e 44 00 00 push $0x448e + 1ceb: 6a 01 push $0x1 + 1ced: e8 5e 1d 00 00 call 3a50 + exit(); + 1cf2: e8 dc 1b 00 00 call 38d3 + printf(1, "bigdir unlink failed"); + 1cf7: 83 ec 08 sub $0x8,%esp + 1cfa: 68 a2 44 00 00 push $0x44a2 + 1cff: 6a 01 push $0x1 + 1d01: e8 4a 1d 00 00 call 3a50 + exit(); + 1d06: e8 c8 1b 00 00 call 38d3 + printf(1, "bigdir create failed\n"); + 1d0b: 50 push %eax + 1d0c: 50 push %eax + 1d0d: 68 78 44 00 00 push $0x4478 + 1d12: 6a 01 push $0x1 + 1d14: e8 37 1d 00 00 call 3a50 + exit(); + 1d19: e8 b5 1b 00 00 call 38d3 + 1d1e: 66 90 xchg %ax,%ax + +00001d20 : +void subdir(void) { + 1d20: 55 push %ebp + 1d21: 89 e5 mov %esp,%ebp + 1d23: 53 push %ebx + 1d24: 83 ec 0c sub $0xc,%esp + printf(1, "subdir test\n"); + 1d27: 68 c2 44 00 00 push $0x44c2 + 1d2c: 6a 01 push $0x1 + 1d2e: e8 1d 1d 00 00 call 3a50 + unlink("ff"); + 1d33: c7 04 24 4b 45 00 00 movl $0x454b,(%esp) + 1d3a: e8 14 1c 00 00 call 3953 + if (mkdir("dd") != 0) { + 1d3f: c7 04 24 e8 45 00 00 movl $0x45e8,(%esp) + 1d46: e8 18 1c 00 00 call 3963 + 1d4b: 83 c4 10 add $0x10,%esp + 1d4e: 85 c0 test %eax,%eax + 1d50: 0f 85 b3 05 00 00 jne 2309 + fd = open("dd/ff", O_CREATE | O_RDWR); + 1d56: 83 ec 08 sub $0x8,%esp + 1d59: 68 02 02 00 00 push $0x202 + 1d5e: 68 21 45 00 00 push $0x4521 + 1d63: e8 d3 1b 00 00 call 393b + if (fd < 0) { + 1d68: 83 c4 10 add $0x10,%esp + fd = open("dd/ff", O_CREATE | O_RDWR); + 1d6b: 89 c3 mov %eax,%ebx + if (fd < 0) { + 1d6d: 85 c0 test %eax,%eax + 1d6f: 0f 88 81 05 00 00 js 22f6 + write(fd, "ff", 2); + 1d75: 83 ec 04 sub $0x4,%esp + 1d78: 6a 02 push $0x2 + 1d7a: 68 4b 45 00 00 push $0x454b + 1d7f: 50 push %eax + 1d80: e8 be 1b 00 00 call 3943 + close(fd); + 1d85: 89 1c 24 mov %ebx,(%esp) + 1d88: e8 de 1b 00 00 call 396b + if (unlink("dd") >= 0) { + 1d8d: c7 04 24 e8 45 00 00 movl $0x45e8,(%esp) + 1d94: e8 ba 1b 00 00 call 3953 + 1d99: 83 c4 10 add $0x10,%esp + 1d9c: 85 c0 test %eax,%eax + 1d9e: 0f 89 3f 05 00 00 jns 22e3 + if (mkdir("/dd/dd") != 0) { + 1da4: 83 ec 0c sub $0xc,%esp + 1da7: 68 fc 44 00 00 push $0x44fc + 1dac: e8 b2 1b 00 00 call 3963 + 1db1: 83 c4 10 add $0x10,%esp + 1db4: 85 c0 test %eax,%eax + 1db6: 0f 85 14 05 00 00 jne 22d0 + fd = open("dd/dd/ff", O_CREATE | O_RDWR); + 1dbc: 83 ec 08 sub $0x8,%esp + 1dbf: 68 02 02 00 00 push $0x202 + 1dc4: 68 1e 45 00 00 push $0x451e + 1dc9: e8 6d 1b 00 00 call 393b + if (fd < 0) { + 1dce: 83 c4 10 add $0x10,%esp + fd = open("dd/dd/ff", O_CREATE | O_RDWR); + 1dd1: 89 c3 mov %eax,%ebx + if (fd < 0) { + 1dd3: 85 c0 test %eax,%eax + 1dd5: 0f 88 24 04 00 00 js 21ff + write(fd, "FF", 2); + 1ddb: 83 ec 04 sub $0x4,%esp + 1dde: 6a 02 push $0x2 + 1de0: 68 3f 45 00 00 push $0x453f + 1de5: 50 push %eax + 1de6: e8 58 1b 00 00 call 3943 + close(fd); + 1deb: 89 1c 24 mov %ebx,(%esp) + 1dee: e8 78 1b 00 00 call 396b + fd = open("dd/dd/../ff", 0); + 1df3: 58 pop %eax + 1df4: 5a pop %edx + 1df5: 6a 00 push $0x0 + 1df7: 68 42 45 00 00 push $0x4542 + 1dfc: e8 3a 1b 00 00 call 393b + if (fd < 0) { + 1e01: 83 c4 10 add $0x10,%esp + fd = open("dd/dd/../ff", 0); + 1e04: 89 c3 mov %eax,%ebx + if (fd < 0) { + 1e06: 85 c0 test %eax,%eax + 1e08: 0f 88 de 03 00 00 js 21ec + cc = read(fd, buf, sizeof(buf)); + 1e0e: 83 ec 04 sub $0x4,%esp + 1e11: 68 00 20 00 00 push $0x2000 + 1e16: 68 a0 85 00 00 push $0x85a0 + 1e1b: 50 push %eax + 1e1c: e8 ca 1a 00 00 call 38eb + if (cc != 2 || buf[0] != 'f') { + 1e21: 83 c4 10 add $0x10,%esp + 1e24: 83 f8 02 cmp $0x2,%eax + 1e27: 0f 85 3a 03 00 00 jne 2167 + 1e2d: 80 3d a0 85 00 00 66 cmpb $0x66,0x85a0 + 1e34: 0f 85 2d 03 00 00 jne 2167 + close(fd); + 1e3a: 83 ec 0c sub $0xc,%esp + 1e3d: 53 push %ebx + 1e3e: e8 28 1b 00 00 call 396b + if (link("dd/dd/ff", "dd/dd/ffff") != 0) { + 1e43: 59 pop %ecx + 1e44: 5b pop %ebx + 1e45: 68 82 45 00 00 push $0x4582 + 1e4a: 68 1e 45 00 00 push $0x451e + 1e4f: e8 07 1b 00 00 call 395b + 1e54: 83 c4 10 add $0x10,%esp + 1e57: 85 c0 test %eax,%eax + 1e59: 0f 85 c6 03 00 00 jne 2225 + if (unlink("dd/dd/ff") != 0) { + 1e5f: 83 ec 0c sub $0xc,%esp + 1e62: 68 1e 45 00 00 push $0x451e + 1e67: e8 e7 1a 00 00 call 3953 + 1e6c: 83 c4 10 add $0x10,%esp + 1e6f: 85 c0 test %eax,%eax + 1e71: 0f 85 16 03 00 00 jne 218d + if (open("dd/dd/ff", O_RDONLY) >= 0) { + 1e77: 83 ec 08 sub $0x8,%esp + 1e7a: 6a 00 push $0x0 + 1e7c: 68 1e 45 00 00 push $0x451e + 1e81: e8 b5 1a 00 00 call 393b + 1e86: 83 c4 10 add $0x10,%esp + 1e89: 85 c0 test %eax,%eax + 1e8b: 0f 89 2c 04 00 00 jns 22bd + if (chdir("dd") != 0) { + 1e91: 83 ec 0c sub $0xc,%esp + 1e94: 68 e8 45 00 00 push $0x45e8 + 1e99: e8 6d 1a 00 00 call 390b + 1e9e: 83 c4 10 add $0x10,%esp + 1ea1: 85 c0 test %eax,%eax + 1ea3: 0f 85 01 04 00 00 jne 22aa + if (chdir("dd/../../dd") != 0) { + 1ea9: 83 ec 0c sub $0xc,%esp + 1eac: 68 b6 45 00 00 push $0x45b6 + 1eb1: e8 55 1a 00 00 call 390b + 1eb6: 83 c4 10 add $0x10,%esp + 1eb9: 85 c0 test %eax,%eax + 1ebb: 0f 85 b9 02 00 00 jne 217a + if (chdir("dd/../../../dd") != 0) { + 1ec1: 83 ec 0c sub $0xc,%esp + 1ec4: 68 dc 45 00 00 push $0x45dc + 1ec9: e8 3d 1a 00 00 call 390b + 1ece: 83 c4 10 add $0x10,%esp + 1ed1: 85 c0 test %eax,%eax + 1ed3: 0f 85 a1 02 00 00 jne 217a + if (chdir("./..") != 0) { + 1ed9: 83 ec 0c sub $0xc,%esp + 1edc: 68 eb 45 00 00 push $0x45eb + 1ee1: e8 25 1a 00 00 call 390b + 1ee6: 83 c4 10 add $0x10,%esp + 1ee9: 85 c0 test %eax,%eax + 1eeb: 0f 85 21 03 00 00 jne 2212 + fd = open("dd/dd/ffff", 0); + 1ef1: 83 ec 08 sub $0x8,%esp + 1ef4: 6a 00 push $0x0 + 1ef6: 68 82 45 00 00 push $0x4582 + 1efb: e8 3b 1a 00 00 call 393b + if (fd < 0) { + 1f00: 83 c4 10 add $0x10,%esp + fd = open("dd/dd/ffff", 0); + 1f03: 89 c3 mov %eax,%ebx + if (fd < 0) { + 1f05: 85 c0 test %eax,%eax + 1f07: 0f 88 e0 04 00 00 js 23ed + if (read(fd, buf, sizeof(buf)) != 2) { + 1f0d: 83 ec 04 sub $0x4,%esp + 1f10: 68 00 20 00 00 push $0x2000 + 1f15: 68 a0 85 00 00 push $0x85a0 + 1f1a: 50 push %eax + 1f1b: e8 cb 19 00 00 call 38eb + 1f20: 83 c4 10 add $0x10,%esp + 1f23: 83 f8 02 cmp $0x2,%eax + 1f26: 0f 85 ae 04 00 00 jne 23da + close(fd); + 1f2c: 83 ec 0c sub $0xc,%esp + 1f2f: 53 push %ebx + 1f30: e8 36 1a 00 00 call 396b + if (open("dd/dd/ff", O_RDONLY) >= 0) { + 1f35: 58 pop %eax + 1f36: 5a pop %edx + 1f37: 6a 00 push $0x0 + 1f39: 68 1e 45 00 00 push $0x451e + 1f3e: e8 f8 19 00 00 call 393b + 1f43: 83 c4 10 add $0x10,%esp + 1f46: 85 c0 test %eax,%eax + 1f48: 0f 89 65 02 00 00 jns 21b3 + if (open("dd/ff/ff", O_CREATE | O_RDWR) >= 0) { + 1f4e: 83 ec 08 sub $0x8,%esp + 1f51: 68 02 02 00 00 push $0x202 + 1f56: 68 36 46 00 00 push $0x4636 + 1f5b: e8 db 19 00 00 call 393b + 1f60: 83 c4 10 add $0x10,%esp + 1f63: 85 c0 test %eax,%eax + 1f65: 0f 89 35 02 00 00 jns 21a0 + if (open("dd/xx/ff", O_CREATE | O_RDWR) >= 0) { + 1f6b: 83 ec 08 sub $0x8,%esp + 1f6e: 68 02 02 00 00 push $0x202 + 1f73: 68 5b 46 00 00 push $0x465b + 1f78: e8 be 19 00 00 call 393b + 1f7d: 83 c4 10 add $0x10,%esp + 1f80: 85 c0 test %eax,%eax + 1f82: 0f 89 0f 03 00 00 jns 2297 + if (open("dd", O_CREATE) >= 0) { + 1f88: 83 ec 08 sub $0x8,%esp + 1f8b: 68 00 02 00 00 push $0x200 + 1f90: 68 e8 45 00 00 push $0x45e8 + 1f95: e8 a1 19 00 00 call 393b + 1f9a: 83 c4 10 add $0x10,%esp + 1f9d: 85 c0 test %eax,%eax + 1f9f: 0f 89 df 02 00 00 jns 2284 + if (open("dd", O_RDWR) >= 0) { + 1fa5: 83 ec 08 sub $0x8,%esp + 1fa8: 6a 02 push $0x2 + 1faa: 68 e8 45 00 00 push $0x45e8 + 1faf: e8 87 19 00 00 call 393b + 1fb4: 83 c4 10 add $0x10,%esp + 1fb7: 85 c0 test %eax,%eax + 1fb9: 0f 89 b2 02 00 00 jns 2271 + if (open("dd", O_WRONLY) >= 0) { + 1fbf: 83 ec 08 sub $0x8,%esp + 1fc2: 6a 01 push $0x1 + 1fc4: 68 e8 45 00 00 push $0x45e8 + 1fc9: e8 6d 19 00 00 call 393b + 1fce: 83 c4 10 add $0x10,%esp + 1fd1: 85 c0 test %eax,%eax + 1fd3: 0f 89 85 02 00 00 jns 225e + if (link("dd/ff/ff", "dd/dd/xx") == 0) { + 1fd9: 83 ec 08 sub $0x8,%esp + 1fdc: 68 ca 46 00 00 push $0x46ca + 1fe1: 68 36 46 00 00 push $0x4636 + 1fe6: e8 70 19 00 00 call 395b + 1feb: 83 c4 10 add $0x10,%esp + 1fee: 85 c0 test %eax,%eax + 1ff0: 0f 84 55 02 00 00 je 224b + if (link("dd/xx/ff", "dd/dd/xx") == 0) { + 1ff6: 83 ec 08 sub $0x8,%esp + 1ff9: 68 ca 46 00 00 push $0x46ca + 1ffe: 68 5b 46 00 00 push $0x465b + 2003: e8 53 19 00 00 call 395b + 2008: 83 c4 10 add $0x10,%esp + 200b: 85 c0 test %eax,%eax + 200d: 0f 84 25 02 00 00 je 2238 + if (link("dd/ff", "dd/dd/ffff") == 0) { + 2013: 83 ec 08 sub $0x8,%esp + 2016: 68 82 45 00 00 push $0x4582 + 201b: 68 21 45 00 00 push $0x4521 + 2020: e8 36 19 00 00 call 395b + 2025: 83 c4 10 add $0x10,%esp + 2028: 85 c0 test %eax,%eax + 202a: 0f 84 a9 01 00 00 je 21d9 + if (mkdir("dd/ff/ff") == 0) { + 2030: 83 ec 0c sub $0xc,%esp + 2033: 68 36 46 00 00 push $0x4636 + 2038: e8 26 19 00 00 call 3963 + 203d: 83 c4 10 add $0x10,%esp + 2040: 85 c0 test %eax,%eax + 2042: 0f 84 7e 01 00 00 je 21c6 + if (mkdir("dd/xx/ff") == 0) { + 2048: 83 ec 0c sub $0xc,%esp + 204b: 68 5b 46 00 00 push $0x465b + 2050: e8 0e 19 00 00 call 3963 + 2055: 83 c4 10 add $0x10,%esp + 2058: 85 c0 test %eax,%eax + 205a: 0f 84 67 03 00 00 je 23c7 + if (mkdir("dd/dd/ffff") == 0) { + 2060: 83 ec 0c sub $0xc,%esp + 2063: 68 82 45 00 00 push $0x4582 + 2068: e8 f6 18 00 00 call 3963 + 206d: 83 c4 10 add $0x10,%esp + 2070: 85 c0 test %eax,%eax + 2072: 0f 84 3c 03 00 00 je 23b4 + if (unlink("dd/xx/ff") == 0) { + 2078: 83 ec 0c sub $0xc,%esp + 207b: 68 5b 46 00 00 push $0x465b + 2080: e8 ce 18 00 00 call 3953 + 2085: 83 c4 10 add $0x10,%esp + 2088: 85 c0 test %eax,%eax + 208a: 0f 84 11 03 00 00 je 23a1 + if (unlink("dd/ff/ff") == 0) { + 2090: 83 ec 0c sub $0xc,%esp + 2093: 68 36 46 00 00 push $0x4636 + 2098: e8 b6 18 00 00 call 3953 + 209d: 83 c4 10 add $0x10,%esp + 20a0: 85 c0 test %eax,%eax + 20a2: 0f 84 e6 02 00 00 je 238e + if (chdir("dd/ff") == 0) { + 20a8: 83 ec 0c sub $0xc,%esp + 20ab: 68 21 45 00 00 push $0x4521 + 20b0: e8 56 18 00 00 call 390b + 20b5: 83 c4 10 add $0x10,%esp + 20b8: 85 c0 test %eax,%eax + 20ba: 0f 84 bb 02 00 00 je 237b + if (chdir("dd/xx") == 0) { + 20c0: 83 ec 0c sub $0xc,%esp + 20c3: 68 cd 46 00 00 push $0x46cd + 20c8: e8 3e 18 00 00 call 390b + 20cd: 83 c4 10 add $0x10,%esp + 20d0: 85 c0 test %eax,%eax + 20d2: 0f 84 90 02 00 00 je 2368 + if (unlink("dd/dd/ffff") != 0) { + 20d8: 83 ec 0c sub $0xc,%esp + 20db: 68 82 45 00 00 push $0x4582 + 20e0: e8 6e 18 00 00 call 3953 + 20e5: 83 c4 10 add $0x10,%esp + 20e8: 85 c0 test %eax,%eax + 20ea: 0f 85 9d 00 00 00 jne 218d + if (unlink("dd/ff") != 0) { + 20f0: 83 ec 0c sub $0xc,%esp + 20f3: 68 21 45 00 00 push $0x4521 + 20f8: e8 56 18 00 00 call 3953 + 20fd: 83 c4 10 add $0x10,%esp + 2100: 85 c0 test %eax,%eax + 2102: 0f 85 4d 02 00 00 jne 2355 + if (unlink("dd") == 0) { + 2108: 83 ec 0c sub $0xc,%esp + 210b: 68 e8 45 00 00 push $0x45e8 + 2110: e8 3e 18 00 00 call 3953 + 2115: 83 c4 10 add $0x10,%esp + 2118: 85 c0 test %eax,%eax + 211a: 0f 84 22 02 00 00 je 2342 + if (unlink("dd/dd") < 0) { + 2120: 83 ec 0c sub $0xc,%esp + 2123: 68 fd 44 00 00 push $0x44fd + 2128: e8 26 18 00 00 call 3953 + 212d: 83 c4 10 add $0x10,%esp + 2130: 85 c0 test %eax,%eax + 2132: 0f 88 f7 01 00 00 js 232f + if (unlink("dd") < 0) { + 2138: 83 ec 0c sub $0xc,%esp + 213b: 68 e8 45 00 00 push $0x45e8 + 2140: e8 0e 18 00 00 call 3953 + 2145: 83 c4 10 add $0x10,%esp + 2148: 85 c0 test %eax,%eax + 214a: 0f 88 cc 01 00 00 js 231c + printf(1, "subdir ok\n"); + 2150: 83 ec 08 sub $0x8,%esp + 2153: 68 ca 47 00 00 push $0x47ca + 2158: 6a 01 push $0x1 + 215a: e8 f1 18 00 00 call 3a50 +} + 215f: 8b 5d fc mov -0x4(%ebp),%ebx + 2162: 83 c4 10 add $0x10,%esp + 2165: c9 leave + 2166: c3 ret + printf(1, "dd/dd/../ff wrong content\n"); + 2167: 50 push %eax + 2168: 50 push %eax + 2169: 68 67 45 00 00 push $0x4567 + 216e: 6a 01 push $0x1 + 2170: e8 db 18 00 00 call 3a50 + exit(); + 2175: e8 59 17 00 00 call 38d3 + printf(1, "chdir dd/../../dd failed\n"); + 217a: 50 push %eax + 217b: 50 push %eax + 217c: 68 c2 45 00 00 push $0x45c2 + 2181: 6a 01 push $0x1 + 2183: e8 c8 18 00 00 call 3a50 + exit(); + 2188: e8 46 17 00 00 call 38d3 + printf(1, "unlink dd/dd/ff failed\n"); + 218d: 50 push %eax + 218e: 50 push %eax + 218f: 68 8d 45 00 00 push $0x458d + 2194: 6a 01 push $0x1 + 2196: e8 b5 18 00 00 call 3a50 + exit(); + 219b: e8 33 17 00 00 call 38d3 + printf(1, "create dd/ff/ff succeeded!\n"); + 21a0: 51 push %ecx + 21a1: 51 push %ecx + 21a2: 68 3f 46 00 00 push $0x463f + 21a7: 6a 01 push $0x1 + 21a9: e8 a2 18 00 00 call 3a50 + exit(); + 21ae: e8 20 17 00 00 call 38d3 + printf(1, "open (unlinked) dd/dd/ff succeeded!\n"); + 21b3: 53 push %ebx + 21b4: 53 push %ebx + 21b5: 68 24 50 00 00 push $0x5024 + 21ba: 6a 01 push $0x1 + 21bc: e8 8f 18 00 00 call 3a50 + exit(); + 21c1: e8 0d 17 00 00 call 38d3 + printf(1, "mkdir dd/ff/ff succeeded!\n"); + 21c6: 51 push %ecx + 21c7: 51 push %ecx + 21c8: 68 d3 46 00 00 push $0x46d3 + 21cd: 6a 01 push $0x1 + 21cf: e8 7c 18 00 00 call 3a50 + exit(); + 21d4: e8 fa 16 00 00 call 38d3 + printf(1, "link dd/ff dd/dd/ffff succeeded!\n"); + 21d9: 53 push %ebx + 21da: 53 push %ebx + 21db: 68 94 50 00 00 push $0x5094 + 21e0: 6a 01 push $0x1 + 21e2: e8 69 18 00 00 call 3a50 + exit(); + 21e7: e8 e7 16 00 00 call 38d3 + printf(1, "open dd/dd/../ff failed\n"); + 21ec: 50 push %eax + 21ed: 50 push %eax + 21ee: 68 4e 45 00 00 push $0x454e + 21f3: 6a 01 push $0x1 + 21f5: e8 56 18 00 00 call 3a50 + exit(); + 21fa: e8 d4 16 00 00 call 38d3 + printf(1, "create dd/dd/ff failed\n"); + 21ff: 51 push %ecx + 2200: 51 push %ecx + 2201: 68 27 45 00 00 push $0x4527 + 2206: 6a 01 push $0x1 + 2208: e8 43 18 00 00 call 3a50 + exit(); + 220d: e8 c1 16 00 00 call 38d3 + printf(1, "chdir ./.. failed\n"); + 2212: 50 push %eax + 2213: 50 push %eax + 2214: 68 f0 45 00 00 push $0x45f0 + 2219: 6a 01 push $0x1 + 221b: e8 30 18 00 00 call 3a50 + exit(); + 2220: e8 ae 16 00 00 call 38d3 + printf(1, "link dd/dd/ff dd/dd/ffff failed\n"); + 2225: 52 push %edx + 2226: 52 push %edx + 2227: 68 dc 4f 00 00 push $0x4fdc + 222c: 6a 01 push $0x1 + 222e: e8 1d 18 00 00 call 3a50 + exit(); + 2233: e8 9b 16 00 00 call 38d3 + printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n"); + 2238: 50 push %eax + 2239: 50 push %eax + 223a: 68 70 50 00 00 push $0x5070 + 223f: 6a 01 push $0x1 + 2241: e8 0a 18 00 00 call 3a50 + exit(); + 2246: e8 88 16 00 00 call 38d3 + printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n"); + 224b: 50 push %eax + 224c: 50 push %eax + 224d: 68 4c 50 00 00 push $0x504c + 2252: 6a 01 push $0x1 + 2254: e8 f7 17 00 00 call 3a50 + exit(); + 2259: e8 75 16 00 00 call 38d3 + printf(1, "open dd wronly succeeded!\n"); + 225e: 50 push %eax + 225f: 50 push %eax + 2260: 68 af 46 00 00 push $0x46af + 2265: 6a 01 push $0x1 + 2267: e8 e4 17 00 00 call 3a50 + exit(); + 226c: e8 62 16 00 00 call 38d3 + printf(1, "open dd rdwr succeeded!\n"); + 2271: 50 push %eax + 2272: 50 push %eax + 2273: 68 96 46 00 00 push $0x4696 + 2278: 6a 01 push $0x1 + 227a: e8 d1 17 00 00 call 3a50 + exit(); + 227f: e8 4f 16 00 00 call 38d3 + printf(1, "create dd succeeded!\n"); + 2284: 50 push %eax + 2285: 50 push %eax + 2286: 68 80 46 00 00 push $0x4680 + 228b: 6a 01 push $0x1 + 228d: e8 be 17 00 00 call 3a50 + exit(); + 2292: e8 3c 16 00 00 call 38d3 + printf(1, "create dd/xx/ff succeeded!\n"); + 2297: 52 push %edx + 2298: 52 push %edx + 2299: 68 64 46 00 00 push $0x4664 + 229e: 6a 01 push $0x1 + 22a0: e8 ab 17 00 00 call 3a50 + exit(); + 22a5: e8 29 16 00 00 call 38d3 + printf(1, "chdir dd failed\n"); + 22aa: 50 push %eax + 22ab: 50 push %eax + 22ac: 68 a5 45 00 00 push $0x45a5 + 22b1: 6a 01 push $0x1 + 22b3: e8 98 17 00 00 call 3a50 + exit(); + 22b8: e8 16 16 00 00 call 38d3 + printf(1, "open (unlinked) dd/dd/ff succeeded\n"); + 22bd: 50 push %eax + 22be: 50 push %eax + 22bf: 68 00 50 00 00 push $0x5000 + 22c4: 6a 01 push $0x1 + 22c6: e8 85 17 00 00 call 3a50 + exit(); + 22cb: e8 03 16 00 00 call 38d3 + printf(1, "subdir mkdir dd/dd failed\n"); + 22d0: 53 push %ebx + 22d1: 53 push %ebx + 22d2: 68 03 45 00 00 push $0x4503 + 22d7: 6a 01 push $0x1 + 22d9: e8 72 17 00 00 call 3a50 + exit(); + 22de: e8 f0 15 00 00 call 38d3 + printf(1, "unlink dd (non-empty dir) succeeded!\n"); + 22e3: 50 push %eax + 22e4: 50 push %eax + 22e5: 68 b4 4f 00 00 push $0x4fb4 + 22ea: 6a 01 push $0x1 + 22ec: e8 5f 17 00 00 call 3a50 + exit(); + 22f1: e8 dd 15 00 00 call 38d3 + printf(1, "create dd/ff failed\n"); + 22f6: 50 push %eax + 22f7: 50 push %eax + 22f8: 68 e7 44 00 00 push $0x44e7 + 22fd: 6a 01 push $0x1 + 22ff: e8 4c 17 00 00 call 3a50 + exit(); + 2304: e8 ca 15 00 00 call 38d3 + printf(1, "subdir mkdir dd failed\n"); + 2309: 50 push %eax + 230a: 50 push %eax + 230b: 68 cf 44 00 00 push $0x44cf + 2310: 6a 01 push $0x1 + 2312: e8 39 17 00 00 call 3a50 + exit(); + 2317: e8 b7 15 00 00 call 38d3 + printf(1, "unlink dd failed\n"); + 231c: 50 push %eax + 231d: 50 push %eax + 231e: 68 b8 47 00 00 push $0x47b8 + 2323: 6a 01 push $0x1 + 2325: e8 26 17 00 00 call 3a50 + exit(); + 232a: e8 a4 15 00 00 call 38d3 + printf(1, "unlink dd/dd failed\n"); + 232f: 52 push %edx + 2330: 52 push %edx + 2331: 68 a3 47 00 00 push $0x47a3 + 2336: 6a 01 push $0x1 + 2338: e8 13 17 00 00 call 3a50 + exit(); + 233d: e8 91 15 00 00 call 38d3 + printf(1, "unlink non-empty dd succeeded!\n"); + 2342: 51 push %ecx + 2343: 51 push %ecx + 2344: 68 b8 50 00 00 push $0x50b8 + 2349: 6a 01 push $0x1 + 234b: e8 00 17 00 00 call 3a50 + exit(); + 2350: e8 7e 15 00 00 call 38d3 + printf(1, "unlink dd/ff failed\n"); + 2355: 53 push %ebx + 2356: 53 push %ebx + 2357: 68 8e 47 00 00 push $0x478e + 235c: 6a 01 push $0x1 + 235e: e8 ed 16 00 00 call 3a50 + exit(); + 2363: e8 6b 15 00 00 call 38d3 + printf(1, "chdir dd/xx succeeded!\n"); + 2368: 50 push %eax + 2369: 50 push %eax + 236a: 68 76 47 00 00 push $0x4776 + 236f: 6a 01 push $0x1 + 2371: e8 da 16 00 00 call 3a50 + exit(); + 2376: e8 58 15 00 00 call 38d3 + printf(1, "chdir dd/ff succeeded!\n"); + 237b: 50 push %eax + 237c: 50 push %eax + 237d: 68 5e 47 00 00 push $0x475e + 2382: 6a 01 push $0x1 + 2384: e8 c7 16 00 00 call 3a50 + exit(); + 2389: e8 45 15 00 00 call 38d3 + printf(1, "unlink dd/ff/ff succeeded!\n"); + 238e: 50 push %eax + 238f: 50 push %eax + 2390: 68 42 47 00 00 push $0x4742 + 2395: 6a 01 push $0x1 + 2397: e8 b4 16 00 00 call 3a50 + exit(); + 239c: e8 32 15 00 00 call 38d3 + printf(1, "unlink dd/xx/ff succeeded!\n"); + 23a1: 50 push %eax + 23a2: 50 push %eax + 23a3: 68 26 47 00 00 push $0x4726 + 23a8: 6a 01 push $0x1 + 23aa: e8 a1 16 00 00 call 3a50 + exit(); + 23af: e8 1f 15 00 00 call 38d3 + printf(1, "mkdir dd/dd/ffff succeeded!\n"); + 23b4: 50 push %eax + 23b5: 50 push %eax + 23b6: 68 09 47 00 00 push $0x4709 + 23bb: 6a 01 push $0x1 + 23bd: e8 8e 16 00 00 call 3a50 + exit(); + 23c2: e8 0c 15 00 00 call 38d3 + printf(1, "mkdir dd/xx/ff succeeded!\n"); + 23c7: 52 push %edx + 23c8: 52 push %edx + 23c9: 68 ee 46 00 00 push $0x46ee + 23ce: 6a 01 push $0x1 + 23d0: e8 7b 16 00 00 call 3a50 + exit(); + 23d5: e8 f9 14 00 00 call 38d3 + printf(1, "read dd/dd/ffff wrong len\n"); + 23da: 51 push %ecx + 23db: 51 push %ecx + 23dc: 68 1b 46 00 00 push $0x461b + 23e1: 6a 01 push $0x1 + 23e3: e8 68 16 00 00 call 3a50 + exit(); + 23e8: e8 e6 14 00 00 call 38d3 + printf(1, "open dd/dd/ffff failed\n"); + 23ed: 53 push %ebx + 23ee: 53 push %ebx + 23ef: 68 03 46 00 00 push $0x4603 + 23f4: 6a 01 push $0x1 + 23f6: e8 55 16 00 00 call 3a50 + exit(); + 23fb: e8 d3 14 00 00 call 38d3 + +00002400 : +void bigwrite(void) { + 2400: 55 push %ebp + 2401: 89 e5 mov %esp,%ebp + 2403: 56 push %esi + 2404: 53 push %ebx + for (sz = 499; sz < 12 * 512; sz += 471) { + 2405: bb f3 01 00 00 mov $0x1f3,%ebx + printf(1, "bigwrite test\n"); + 240a: 83 ec 08 sub $0x8,%esp + 240d: 68 d5 47 00 00 push $0x47d5 + 2412: 6a 01 push $0x1 + 2414: e8 37 16 00 00 call 3a50 + unlink("bigwrite"); + 2419: c7 04 24 e4 47 00 00 movl $0x47e4,(%esp) + 2420: e8 2e 15 00 00 call 3953 + 2425: 83 c4 10 add $0x10,%esp + 2428: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 242f: 90 nop + fd = open("bigwrite", O_CREATE | O_RDWR); + 2430: 83 ec 08 sub $0x8,%esp + 2433: 68 02 02 00 00 push $0x202 + 2438: 68 e4 47 00 00 push $0x47e4 + 243d: e8 f9 14 00 00 call 393b + if (fd < 0) { + 2442: 83 c4 10 add $0x10,%esp + fd = open("bigwrite", O_CREATE | O_RDWR); + 2445: 89 c6 mov %eax,%esi + if (fd < 0) { + 2447: 85 c0 test %eax,%eax + 2449: 78 7e js 24c9 + int cc = write(fd, buf, sz); + 244b: 83 ec 04 sub $0x4,%esp + 244e: 53 push %ebx + 244f: 68 a0 85 00 00 push $0x85a0 + 2454: 50 push %eax + 2455: e8 e9 14 00 00 call 3943 + if (cc != sz) { + 245a: 83 c4 10 add $0x10,%esp + 245d: 39 d8 cmp %ebx,%eax + 245f: 75 55 jne 24b6 + int cc = write(fd, buf, sz); + 2461: 83 ec 04 sub $0x4,%esp + 2464: 53 push %ebx + 2465: 68 a0 85 00 00 push $0x85a0 + 246a: 56 push %esi + 246b: e8 d3 14 00 00 call 3943 + if (cc != sz) { + 2470: 83 c4 10 add $0x10,%esp + 2473: 39 d8 cmp %ebx,%eax + 2475: 75 3f jne 24b6 + close(fd); + 2477: 83 ec 0c sub $0xc,%esp + for (sz = 499; sz < 12 * 512; sz += 471) { + 247a: 81 c3 d7 01 00 00 add $0x1d7,%ebx + close(fd); + 2480: 56 push %esi + 2481: e8 e5 14 00 00 call 396b + unlink("bigwrite"); + 2486: c7 04 24 e4 47 00 00 movl $0x47e4,(%esp) + 248d: e8 c1 14 00 00 call 3953 + for (sz = 499; sz < 12 * 512; sz += 471) { + 2492: 83 c4 10 add $0x10,%esp + 2495: 81 fb 07 18 00 00 cmp $0x1807,%ebx + 249b: 75 93 jne 2430 + printf(1, "bigwrite ok\n"); + 249d: 83 ec 08 sub $0x8,%esp + 24a0: 68 17 48 00 00 push $0x4817 + 24a5: 6a 01 push $0x1 + 24a7: e8 a4 15 00 00 call 3a50 +} + 24ac: 83 c4 10 add $0x10,%esp + 24af: 8d 65 f8 lea -0x8(%ebp),%esp + 24b2: 5b pop %ebx + 24b3: 5e pop %esi + 24b4: 5d pop %ebp + 24b5: c3 ret + printf(1, "write(%d) ret %d\n", sz, cc); + 24b6: 50 push %eax + 24b7: 53 push %ebx + 24b8: 68 05 48 00 00 push $0x4805 + 24bd: 6a 01 push $0x1 + 24bf: e8 8c 15 00 00 call 3a50 + exit(); + 24c4: e8 0a 14 00 00 call 38d3 + printf(1, "cannot create bigwrite\n"); + 24c9: 83 ec 08 sub $0x8,%esp + 24cc: 68 ed 47 00 00 push $0x47ed + 24d1: 6a 01 push $0x1 + 24d3: e8 78 15 00 00 call 3a50 + exit(); + 24d8: e8 f6 13 00 00 call 38d3 + 24dd: 8d 76 00 lea 0x0(%esi),%esi + +000024e0 : +void bigfile(void) { + 24e0: 55 push %ebp + 24e1: 89 e5 mov %esp,%ebp + 24e3: 57 push %edi + 24e4: 56 push %esi + 24e5: 53 push %ebx + 24e6: 83 ec 14 sub $0x14,%esp + printf(1, "bigfile test\n"); + 24e9: 68 24 48 00 00 push $0x4824 + 24ee: 6a 01 push $0x1 + 24f0: e8 5b 15 00 00 call 3a50 + unlink("bigfile"); + 24f5: c7 04 24 40 48 00 00 movl $0x4840,(%esp) + 24fc: e8 52 14 00 00 call 3953 + fd = open("bigfile", O_CREATE | O_RDWR); + 2501: 58 pop %eax + 2502: 5a pop %edx + 2503: 68 02 02 00 00 push $0x202 + 2508: 68 40 48 00 00 push $0x4840 + 250d: e8 29 14 00 00 call 393b + if (fd < 0) { + 2512: 83 c4 10 add $0x10,%esp + 2515: 85 c0 test %eax,%eax + 2517: 0f 88 5e 01 00 00 js 267b + 251d: 89 c6 mov %eax,%esi + for (i = 0; i < 20; i++) { + 251f: 31 db xor %ebx,%ebx + 2521: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + memset(buf, i, 600); + 2528: 83 ec 04 sub $0x4,%esp + 252b: 68 58 02 00 00 push $0x258 + 2530: 53 push %ebx + 2531: 68 a0 85 00 00 push $0x85a0 + 2536: e8 05 12 00 00 call 3740 + if (write(fd, buf, 600) != 600) { + 253b: 83 c4 0c add $0xc,%esp + 253e: 68 58 02 00 00 push $0x258 + 2543: 68 a0 85 00 00 push $0x85a0 + 2548: 56 push %esi + 2549: e8 f5 13 00 00 call 3943 + 254e: 83 c4 10 add $0x10,%esp + 2551: 3d 58 02 00 00 cmp $0x258,%eax + 2556: 0f 85 f8 00 00 00 jne 2654 + for (i = 0; i < 20; i++) { + 255c: 83 c3 01 add $0x1,%ebx + 255f: 83 fb 14 cmp $0x14,%ebx + 2562: 75 c4 jne 2528 + close(fd); + 2564: 83 ec 0c sub $0xc,%esp + 2567: 56 push %esi + 2568: e8 fe 13 00 00 call 396b + fd = open("bigfile", 0); + 256d: 5e pop %esi + 256e: 5f pop %edi + 256f: 6a 00 push $0x0 + 2571: 68 40 48 00 00 push $0x4840 + 2576: e8 c0 13 00 00 call 393b + if (fd < 0) { + 257b: 83 c4 10 add $0x10,%esp + fd = open("bigfile", 0); + 257e: 89 c6 mov %eax,%esi + if (fd < 0) { + 2580: 85 c0 test %eax,%eax + 2582: 0f 88 e0 00 00 00 js 2668 + total = 0; + 2588: 31 db xor %ebx,%ebx + for (i = 0;; i++) { + 258a: 31 ff xor %edi,%edi + 258c: eb 30 jmp 25be + 258e: 66 90 xchg %ax,%ax + if (cc != 300) { + 2590: 3d 2c 01 00 00 cmp $0x12c,%eax + 2595: 0f 85 91 00 00 00 jne 262c + if (buf[0] != i / 2 || buf[299] != i / 2) { + 259b: 89 fa mov %edi,%edx + 259d: 0f be 05 a0 85 00 00 movsbl 0x85a0,%eax + 25a4: d1 fa sar %edx + 25a6: 39 d0 cmp %edx,%eax + 25a8: 75 6e jne 2618 + 25aa: 0f be 15 cb 86 00 00 movsbl 0x86cb,%edx + 25b1: 39 d0 cmp %edx,%eax + 25b3: 75 63 jne 2618 + total += cc; + 25b5: 81 c3 2c 01 00 00 add $0x12c,%ebx + for (i = 0;; i++) { + 25bb: 83 c7 01 add $0x1,%edi + cc = read(fd, buf, 300); + 25be: 83 ec 04 sub $0x4,%esp + 25c1: 68 2c 01 00 00 push $0x12c + 25c6: 68 a0 85 00 00 push $0x85a0 + 25cb: 56 push %esi + 25cc: e8 1a 13 00 00 call 38eb + if (cc < 0) { + 25d1: 83 c4 10 add $0x10,%esp + 25d4: 85 c0 test %eax,%eax + 25d6: 78 68 js 2640 + if (cc == 0) { + 25d8: 75 b6 jne 2590 + close(fd); + 25da: 83 ec 0c sub $0xc,%esp + 25dd: 56 push %esi + 25de: e8 88 13 00 00 call 396b + if (total != 20 * 600) { + 25e3: 83 c4 10 add $0x10,%esp + 25e6: 81 fb e0 2e 00 00 cmp $0x2ee0,%ebx + 25ec: 0f 85 9c 00 00 00 jne 268e + unlink("bigfile"); + 25f2: 83 ec 0c sub $0xc,%esp + 25f5: 68 40 48 00 00 push $0x4840 + 25fa: e8 54 13 00 00 call 3953 + printf(1, "bigfile test ok\n"); + 25ff: 58 pop %eax + 2600: 5a pop %edx + 2601: 68 cf 48 00 00 push $0x48cf + 2606: 6a 01 push $0x1 + 2608: e8 43 14 00 00 call 3a50 +} + 260d: 83 c4 10 add $0x10,%esp + 2610: 8d 65 f4 lea -0xc(%ebp),%esp + 2613: 5b pop %ebx + 2614: 5e pop %esi + 2615: 5f pop %edi + 2616: 5d pop %ebp + 2617: c3 ret + printf(1, "read bigfile wrong data\n"); + 2618: 83 ec 08 sub $0x8,%esp + 261b: 68 9c 48 00 00 push $0x489c + 2620: 6a 01 push $0x1 + 2622: e8 29 14 00 00 call 3a50 + exit(); + 2627: e8 a7 12 00 00 call 38d3 + printf(1, "short read bigfile\n"); + 262c: 83 ec 08 sub $0x8,%esp + 262f: 68 88 48 00 00 push $0x4888 + 2634: 6a 01 push $0x1 + 2636: e8 15 14 00 00 call 3a50 + exit(); + 263b: e8 93 12 00 00 call 38d3 + printf(1, "read bigfile failed\n"); + 2640: 83 ec 08 sub $0x8,%esp + 2643: 68 73 48 00 00 push $0x4873 + 2648: 6a 01 push $0x1 + 264a: e8 01 14 00 00 call 3a50 + exit(); + 264f: e8 7f 12 00 00 call 38d3 + printf(1, "write bigfile failed\n"); + 2654: 83 ec 08 sub $0x8,%esp + 2657: 68 48 48 00 00 push $0x4848 + 265c: 6a 01 push $0x1 + 265e: e8 ed 13 00 00 call 3a50 + exit(); + 2663: e8 6b 12 00 00 call 38d3 + printf(1, "cannot open bigfile\n"); + 2668: 53 push %ebx + 2669: 53 push %ebx + 266a: 68 5e 48 00 00 push $0x485e + 266f: 6a 01 push $0x1 + 2671: e8 da 13 00 00 call 3a50 + exit(); + 2676: e8 58 12 00 00 call 38d3 + printf(1, "cannot create bigfile"); + 267b: 50 push %eax + 267c: 50 push %eax + 267d: 68 32 48 00 00 push $0x4832 + 2682: 6a 01 push $0x1 + 2684: e8 c7 13 00 00 call 3a50 + exit(); + 2689: e8 45 12 00 00 call 38d3 + printf(1, "read bigfile wrong total\n"); + 268e: 51 push %ecx + 268f: 51 push %ecx + 2690: 68 b5 48 00 00 push $0x48b5 + 2695: 6a 01 push $0x1 + 2697: e8 b4 13 00 00 call 3a50 + exit(); + 269c: e8 32 12 00 00 call 38d3 + 26a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26af: 90 nop + +000026b0 : +void fourteen(void) { + 26b0: 55 push %ebp + 26b1: 89 e5 mov %esp,%ebp + 26b3: 83 ec 10 sub $0x10,%esp + printf(1, "fourteen test\n"); + 26b6: 68 e0 48 00 00 push $0x48e0 + 26bb: 6a 01 push $0x1 + 26bd: e8 8e 13 00 00 call 3a50 + if (mkdir("12345678901234") != 0) { + 26c2: c7 04 24 1b 49 00 00 movl $0x491b,(%esp) + 26c9: e8 95 12 00 00 call 3963 + 26ce: 83 c4 10 add $0x10,%esp + 26d1: 85 c0 test %eax,%eax + 26d3: 0f 85 97 00 00 00 jne 2770 + if (mkdir("12345678901234/123456789012345") != 0) { + 26d9: 83 ec 0c sub $0xc,%esp + 26dc: 68 d8 50 00 00 push $0x50d8 + 26e1: e8 7d 12 00 00 call 3963 + 26e6: 83 c4 10 add $0x10,%esp + 26e9: 85 c0 test %eax,%eax + 26eb: 0f 85 de 00 00 00 jne 27cf + fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); + 26f1: 83 ec 08 sub $0x8,%esp + 26f4: 68 00 02 00 00 push $0x200 + 26f9: 68 28 51 00 00 push $0x5128 + 26fe: e8 38 12 00 00 call 393b + if (fd < 0) { + 2703: 83 c4 10 add $0x10,%esp + 2706: 85 c0 test %eax,%eax + 2708: 0f 88 ae 00 00 00 js 27bc + close(fd); + 270e: 83 ec 0c sub $0xc,%esp + 2711: 50 push %eax + 2712: e8 54 12 00 00 call 396b + fd = open("12345678901234/12345678901234/12345678901234", 0); + 2717: 58 pop %eax + 2718: 5a pop %edx + 2719: 6a 00 push $0x0 + 271b: 68 98 51 00 00 push $0x5198 + 2720: e8 16 12 00 00 call 393b + if (fd < 0) { + 2725: 83 c4 10 add $0x10,%esp + 2728: 85 c0 test %eax,%eax + 272a: 78 7d js 27a9 + close(fd); + 272c: 83 ec 0c sub $0xc,%esp + 272f: 50 push %eax + 2730: e8 36 12 00 00 call 396b + if (mkdir("12345678901234/12345678901234") == 0) { + 2735: c7 04 24 0c 49 00 00 movl $0x490c,(%esp) + 273c: e8 22 12 00 00 call 3963 + 2741: 83 c4 10 add $0x10,%esp + 2744: 85 c0 test %eax,%eax + 2746: 74 4e je 2796 + if (mkdir("123456789012345/12345678901234") == 0) { + 2748: 83 ec 0c sub $0xc,%esp + 274b: 68 34 52 00 00 push $0x5234 + 2750: e8 0e 12 00 00 call 3963 + 2755: 83 c4 10 add $0x10,%esp + 2758: 85 c0 test %eax,%eax + 275a: 74 27 je 2783 + printf(1, "fourteen ok\n"); + 275c: 83 ec 08 sub $0x8,%esp + 275f: 68 2a 49 00 00 push $0x492a + 2764: 6a 01 push $0x1 + 2766: e8 e5 12 00 00 call 3a50 +} + 276b: 83 c4 10 add $0x10,%esp + 276e: c9 leave + 276f: c3 ret + printf(1, "mkdir 12345678901234 failed\n"); + 2770: 50 push %eax + 2771: 50 push %eax + 2772: 68 ef 48 00 00 push $0x48ef + 2777: 6a 01 push $0x1 + 2779: e8 d2 12 00 00 call 3a50 + exit(); + 277e: e8 50 11 00 00 call 38d3 + printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n"); + 2783: 50 push %eax + 2784: 50 push %eax + 2785: 68 54 52 00 00 push $0x5254 + 278a: 6a 01 push $0x1 + 278c: e8 bf 12 00 00 call 3a50 + exit(); + 2791: e8 3d 11 00 00 call 38d3 + printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n"); + 2796: 52 push %edx + 2797: 52 push %edx + 2798: 68 04 52 00 00 push $0x5204 + 279d: 6a 01 push $0x1 + 279f: e8 ac 12 00 00 call 3a50 + exit(); + 27a4: e8 2a 11 00 00 call 38d3 + printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n"); + 27a9: 51 push %ecx + 27aa: 51 push %ecx + 27ab: 68 c8 51 00 00 push $0x51c8 + 27b0: 6a 01 push $0x1 + 27b2: e8 99 12 00 00 call 3a50 + exit(); + 27b7: e8 17 11 00 00 call 38d3 + printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n"); + 27bc: 51 push %ecx + 27bd: 51 push %ecx + 27be: 68 58 51 00 00 push $0x5158 + 27c3: 6a 01 push $0x1 + 27c5: e8 86 12 00 00 call 3a50 + exit(); + 27ca: e8 04 11 00 00 call 38d3 + printf(1, "mkdir 12345678901234/123456789012345 failed\n"); + 27cf: 50 push %eax + 27d0: 50 push %eax + 27d1: 68 f8 50 00 00 push $0x50f8 + 27d6: 6a 01 push $0x1 + 27d8: e8 73 12 00 00 call 3a50 + exit(); + 27dd: e8 f1 10 00 00 call 38d3 + 27e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 27e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000027f0 : +void rmdot(void) { + 27f0: 55 push %ebp + 27f1: 89 e5 mov %esp,%ebp + 27f3: 83 ec 10 sub $0x10,%esp + printf(1, "rmdot test\n"); + 27f6: 68 37 49 00 00 push $0x4937 + 27fb: 6a 01 push $0x1 + 27fd: e8 4e 12 00 00 call 3a50 + if (mkdir("dots") != 0) { + 2802: c7 04 24 43 49 00 00 movl $0x4943,(%esp) + 2809: e8 55 11 00 00 call 3963 + 280e: 83 c4 10 add $0x10,%esp + 2811: 85 c0 test %eax,%eax + 2813: 0f 85 b0 00 00 00 jne 28c9 + if (chdir("dots") != 0) { + 2819: 83 ec 0c sub $0xc,%esp + 281c: 68 43 49 00 00 push $0x4943 + 2821: e8 e5 10 00 00 call 390b + 2826: 83 c4 10 add $0x10,%esp + 2829: 85 c0 test %eax,%eax + 282b: 0f 85 1d 01 00 00 jne 294e + if (unlink(".") == 0) { + 2831: 83 ec 0c sub $0xc,%esp + 2834: 68 ee 45 00 00 push $0x45ee + 2839: e8 15 11 00 00 call 3953 + 283e: 83 c4 10 add $0x10,%esp + 2841: 85 c0 test %eax,%eax + 2843: 0f 84 f2 00 00 00 je 293b + if (unlink("..") == 0) { + 2849: 83 ec 0c sub $0xc,%esp + 284c: 68 ed 45 00 00 push $0x45ed + 2851: e8 fd 10 00 00 call 3953 + 2856: 83 c4 10 add $0x10,%esp + 2859: 85 c0 test %eax,%eax + 285b: 0f 84 c7 00 00 00 je 2928 + if (chdir("/") != 0) { + 2861: 83 ec 0c sub $0xc,%esp + 2864: 68 c1 3d 00 00 push $0x3dc1 + 2869: e8 9d 10 00 00 call 390b + 286e: 83 c4 10 add $0x10,%esp + 2871: 85 c0 test %eax,%eax + 2873: 0f 85 9c 00 00 00 jne 2915 + if (unlink("dots/.") == 0) { + 2879: 83 ec 0c sub $0xc,%esp + 287c: 68 8b 49 00 00 push $0x498b + 2881: e8 cd 10 00 00 call 3953 + 2886: 83 c4 10 add $0x10,%esp + 2889: 85 c0 test %eax,%eax + 288b: 74 75 je 2902 + if (unlink("dots/..") == 0) { + 288d: 83 ec 0c sub $0xc,%esp + 2890: 68 a9 49 00 00 push $0x49a9 + 2895: e8 b9 10 00 00 call 3953 + 289a: 83 c4 10 add $0x10,%esp + 289d: 85 c0 test %eax,%eax + 289f: 74 4e je 28ef + if (unlink("dots") != 0) { + 28a1: 83 ec 0c sub $0xc,%esp + 28a4: 68 43 49 00 00 push $0x4943 + 28a9: e8 a5 10 00 00 call 3953 + 28ae: 83 c4 10 add $0x10,%esp + 28b1: 85 c0 test %eax,%eax + 28b3: 75 27 jne 28dc + printf(1, "rmdot ok\n"); + 28b5: 83 ec 08 sub $0x8,%esp + 28b8: 68 de 49 00 00 push $0x49de + 28bd: 6a 01 push $0x1 + 28bf: e8 8c 11 00 00 call 3a50 +} + 28c4: 83 c4 10 add $0x10,%esp + 28c7: c9 leave + 28c8: c3 ret + printf(1, "mkdir dots failed\n"); + 28c9: 50 push %eax + 28ca: 50 push %eax + 28cb: 68 48 49 00 00 push $0x4948 + 28d0: 6a 01 push $0x1 + 28d2: e8 79 11 00 00 call 3a50 + exit(); + 28d7: e8 f7 0f 00 00 call 38d3 + printf(1, "unlink dots failed!\n"); + 28dc: 50 push %eax + 28dd: 50 push %eax + 28de: 68 c9 49 00 00 push $0x49c9 + 28e3: 6a 01 push $0x1 + 28e5: e8 66 11 00 00 call 3a50 + exit(); + 28ea: e8 e4 0f 00 00 call 38d3 + printf(1, "unlink dots/.. worked!\n"); + 28ef: 52 push %edx + 28f0: 52 push %edx + 28f1: 68 b1 49 00 00 push $0x49b1 + 28f6: 6a 01 push $0x1 + 28f8: e8 53 11 00 00 call 3a50 + exit(); + 28fd: e8 d1 0f 00 00 call 38d3 + printf(1, "unlink dots/. worked!\n"); + 2902: 51 push %ecx + 2903: 51 push %ecx + 2904: 68 92 49 00 00 push $0x4992 + 2909: 6a 01 push $0x1 + 290b: e8 40 11 00 00 call 3a50 + exit(); + 2910: e8 be 0f 00 00 call 38d3 + printf(1, "chdir / failed\n"); + 2915: 50 push %eax + 2916: 50 push %eax + 2917: 68 c3 3d 00 00 push $0x3dc3 + 291c: 6a 01 push $0x1 + 291e: e8 2d 11 00 00 call 3a50 + exit(); + 2923: e8 ab 0f 00 00 call 38d3 + printf(1, "rm .. worked!\n"); + 2928: 50 push %eax + 2929: 50 push %eax + 292a: 68 7c 49 00 00 push $0x497c + 292f: 6a 01 push $0x1 + 2931: e8 1a 11 00 00 call 3a50 + exit(); + 2936: e8 98 0f 00 00 call 38d3 + printf(1, "rm . worked!\n"); + 293b: 50 push %eax + 293c: 50 push %eax + 293d: 68 6e 49 00 00 push $0x496e + 2942: 6a 01 push $0x1 + 2944: e8 07 11 00 00 call 3a50 + exit(); + 2949: e8 85 0f 00 00 call 38d3 + printf(1, "chdir dots failed\n"); + 294e: 50 push %eax + 294f: 50 push %eax + 2950: 68 5b 49 00 00 push $0x495b + 2955: 6a 01 push $0x1 + 2957: e8 f4 10 00 00 call 3a50 + exit(); + 295c: e8 72 0f 00 00 call 38d3 + 2961: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2968: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 296f: 90 nop + +00002970 : +void dirfile(void) { + 2970: 55 push %ebp + 2971: 89 e5 mov %esp,%ebp + 2973: 53 push %ebx + 2974: 83 ec 0c sub $0xc,%esp + printf(1, "dir vs file\n"); + 2977: 68 e8 49 00 00 push $0x49e8 + 297c: 6a 01 push $0x1 + 297e: e8 cd 10 00 00 call 3a50 + fd = open("dirfile", O_CREATE); + 2983: 5b pop %ebx + 2984: 58 pop %eax + 2985: 68 00 02 00 00 push $0x200 + 298a: 68 f5 49 00 00 push $0x49f5 + 298f: e8 a7 0f 00 00 call 393b + if (fd < 0) { + 2994: 83 c4 10 add $0x10,%esp + 2997: 85 c0 test %eax,%eax + 2999: 0f 88 43 01 00 00 js 2ae2 + close(fd); + 299f: 83 ec 0c sub $0xc,%esp + 29a2: 50 push %eax + 29a3: e8 c3 0f 00 00 call 396b + if (chdir("dirfile") == 0) { + 29a8: c7 04 24 f5 49 00 00 movl $0x49f5,(%esp) + 29af: e8 57 0f 00 00 call 390b + 29b4: 83 c4 10 add $0x10,%esp + 29b7: 85 c0 test %eax,%eax + 29b9: 0f 84 10 01 00 00 je 2acf + fd = open("dirfile/xx", 0); + 29bf: 83 ec 08 sub $0x8,%esp + 29c2: 6a 00 push $0x0 + 29c4: 68 2e 4a 00 00 push $0x4a2e + 29c9: e8 6d 0f 00 00 call 393b + if (fd >= 0) { + 29ce: 83 c4 10 add $0x10,%esp + 29d1: 85 c0 test %eax,%eax + 29d3: 0f 89 e3 00 00 00 jns 2abc + fd = open("dirfile/xx", O_CREATE); + 29d9: 83 ec 08 sub $0x8,%esp + 29dc: 68 00 02 00 00 push $0x200 + 29e1: 68 2e 4a 00 00 push $0x4a2e + 29e6: e8 50 0f 00 00 call 393b + if (fd >= 0) { + 29eb: 83 c4 10 add $0x10,%esp + 29ee: 85 c0 test %eax,%eax + 29f0: 0f 89 c6 00 00 00 jns 2abc + if (mkdir("dirfile/xx") == 0) { + 29f6: 83 ec 0c sub $0xc,%esp + 29f9: 68 2e 4a 00 00 push $0x4a2e + 29fe: e8 60 0f 00 00 call 3963 + 2a03: 83 c4 10 add $0x10,%esp + 2a06: 85 c0 test %eax,%eax + 2a08: 0f 84 46 01 00 00 je 2b54 + if (unlink("dirfile/xx") == 0) { + 2a0e: 83 ec 0c sub $0xc,%esp + 2a11: 68 2e 4a 00 00 push $0x4a2e + 2a16: e8 38 0f 00 00 call 3953 + 2a1b: 83 c4 10 add $0x10,%esp + 2a1e: 85 c0 test %eax,%eax + 2a20: 0f 84 1b 01 00 00 je 2b41 + if (link("README", "dirfile/xx") == 0) { + 2a26: 83 ec 08 sub $0x8,%esp + 2a29: 68 2e 4a 00 00 push $0x4a2e + 2a2e: 68 92 4a 00 00 push $0x4a92 + 2a33: e8 23 0f 00 00 call 395b + 2a38: 83 c4 10 add $0x10,%esp + 2a3b: 85 c0 test %eax,%eax + 2a3d: 0f 84 eb 00 00 00 je 2b2e + if (unlink("dirfile") != 0) { + 2a43: 83 ec 0c sub $0xc,%esp + 2a46: 68 f5 49 00 00 push $0x49f5 + 2a4b: e8 03 0f 00 00 call 3953 + 2a50: 83 c4 10 add $0x10,%esp + 2a53: 85 c0 test %eax,%eax + 2a55: 0f 85 c0 00 00 00 jne 2b1b + fd = open(".", O_RDWR); + 2a5b: 83 ec 08 sub $0x8,%esp + 2a5e: 6a 02 push $0x2 + 2a60: 68 ee 45 00 00 push $0x45ee + 2a65: e8 d1 0e 00 00 call 393b + if (fd >= 0) { + 2a6a: 83 c4 10 add $0x10,%esp + 2a6d: 85 c0 test %eax,%eax + 2a6f: 0f 89 93 00 00 00 jns 2b08 + fd = open(".", 0); + 2a75: 83 ec 08 sub $0x8,%esp + 2a78: 6a 00 push $0x0 + 2a7a: 68 ee 45 00 00 push $0x45ee + 2a7f: e8 b7 0e 00 00 call 393b + if (write(fd, "x", 1) > 0) { + 2a84: 83 c4 0c add $0xc,%esp + 2a87: 6a 01 push $0x1 + fd = open(".", 0); + 2a89: 89 c3 mov %eax,%ebx + if (write(fd, "x", 1) > 0) { + 2a8b: 68 d1 46 00 00 push $0x46d1 + 2a90: 50 push %eax + 2a91: e8 ad 0e 00 00 call 3943 + 2a96: 83 c4 10 add $0x10,%esp + 2a99: 85 c0 test %eax,%eax + 2a9b: 7f 58 jg 2af5 + close(fd); + 2a9d: 83 ec 0c sub $0xc,%esp + 2aa0: 53 push %ebx + 2aa1: e8 c5 0e 00 00 call 396b + printf(1, "dir vs file OK\n"); + 2aa6: 58 pop %eax + 2aa7: 5a pop %edx + 2aa8: 68 c5 4a 00 00 push $0x4ac5 + 2aad: 6a 01 push $0x1 + 2aaf: e8 9c 0f 00 00 call 3a50 +} + 2ab4: 8b 5d fc mov -0x4(%ebp),%ebx + 2ab7: 83 c4 10 add $0x10,%esp + 2aba: c9 leave + 2abb: c3 ret + printf(1, "create dirfile/xx succeeded!\n"); + 2abc: 50 push %eax + 2abd: 50 push %eax + 2abe: 68 39 4a 00 00 push $0x4a39 + 2ac3: 6a 01 push $0x1 + 2ac5: e8 86 0f 00 00 call 3a50 + exit(); + 2aca: e8 04 0e 00 00 call 38d3 + printf(1, "chdir dirfile succeeded!\n"); + 2acf: 52 push %edx + 2ad0: 52 push %edx + 2ad1: 68 14 4a 00 00 push $0x4a14 + 2ad6: 6a 01 push $0x1 + 2ad8: e8 73 0f 00 00 call 3a50 + exit(); + 2add: e8 f1 0d 00 00 call 38d3 + printf(1, "create dirfile failed\n"); + 2ae2: 51 push %ecx + 2ae3: 51 push %ecx + 2ae4: 68 fd 49 00 00 push $0x49fd + 2ae9: 6a 01 push $0x1 + 2aeb: e8 60 0f 00 00 call 3a50 + exit(); + 2af0: e8 de 0d 00 00 call 38d3 + printf(1, "write . succeeded!\n"); + 2af5: 51 push %ecx + 2af6: 51 push %ecx + 2af7: 68 b1 4a 00 00 push $0x4ab1 + 2afc: 6a 01 push $0x1 + 2afe: e8 4d 0f 00 00 call 3a50 + exit(); + 2b03: e8 cb 0d 00 00 call 38d3 + printf(1, "open . for writing succeeded!\n"); + 2b08: 53 push %ebx + 2b09: 53 push %ebx + 2b0a: 68 a8 52 00 00 push $0x52a8 + 2b0f: 6a 01 push $0x1 + 2b11: e8 3a 0f 00 00 call 3a50 + exit(); + 2b16: e8 b8 0d 00 00 call 38d3 + printf(1, "unlink dirfile failed!\n"); + 2b1b: 50 push %eax + 2b1c: 50 push %eax + 2b1d: 68 99 4a 00 00 push $0x4a99 + 2b22: 6a 01 push $0x1 + 2b24: e8 27 0f 00 00 call 3a50 + exit(); + 2b29: e8 a5 0d 00 00 call 38d3 + printf(1, "link to dirfile/xx succeeded!\n"); + 2b2e: 50 push %eax + 2b2f: 50 push %eax + 2b30: 68 88 52 00 00 push $0x5288 + 2b35: 6a 01 push $0x1 + 2b37: e8 14 0f 00 00 call 3a50 + exit(); + 2b3c: e8 92 0d 00 00 call 38d3 + printf(1, "unlink dirfile/xx succeeded!\n"); + 2b41: 50 push %eax + 2b42: 50 push %eax + 2b43: 68 74 4a 00 00 push $0x4a74 + 2b48: 6a 01 push $0x1 + 2b4a: e8 01 0f 00 00 call 3a50 + exit(); + 2b4f: e8 7f 0d 00 00 call 38d3 + printf(1, "mkdir dirfile/xx succeeded!\n"); + 2b54: 50 push %eax + 2b55: 50 push %eax + 2b56: 68 57 4a 00 00 push $0x4a57 + 2b5b: 6a 01 push $0x1 + 2b5d: e8 ee 0e 00 00 call 3a50 + exit(); + 2b62: e8 6c 0d 00 00 call 38d3 + 2b67: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2b6e: 66 90 xchg %ax,%ax + +00002b70 : +void iref(void) { + 2b70: 55 push %ebp + 2b71: 89 e5 mov %esp,%ebp + 2b73: 53 push %ebx + printf(1, "empty file name\n"); + 2b74: bb 33 00 00 00 mov $0x33,%ebx +void iref(void) { + 2b79: 83 ec 0c sub $0xc,%esp + printf(1, "empty file name\n"); + 2b7c: 68 d5 4a 00 00 push $0x4ad5 + 2b81: 6a 01 push $0x1 + 2b83: e8 c8 0e 00 00 call 3a50 + 2b88: 83 c4 10 add $0x10,%esp + 2b8b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 2b8f: 90 nop + if (mkdir("irefd") != 0) { + 2b90: 83 ec 0c sub $0xc,%esp + 2b93: 68 e6 4a 00 00 push $0x4ae6 + 2b98: e8 c6 0d 00 00 call 3963 + 2b9d: 83 c4 10 add $0x10,%esp + 2ba0: 85 c0 test %eax,%eax + 2ba2: 0f 85 bb 00 00 00 jne 2c63 + if (chdir("irefd") != 0) { + 2ba8: 83 ec 0c sub $0xc,%esp + 2bab: 68 e6 4a 00 00 push $0x4ae6 + 2bb0: e8 56 0d 00 00 call 390b + 2bb5: 83 c4 10 add $0x10,%esp + 2bb8: 85 c0 test %eax,%eax + 2bba: 0f 85 b7 00 00 00 jne 2c77 + mkdir(""); + 2bc0: 83 ec 0c sub $0xc,%esp + 2bc3: 68 9b 41 00 00 push $0x419b + 2bc8: e8 96 0d 00 00 call 3963 + link("README", ""); + 2bcd: 59 pop %ecx + 2bce: 58 pop %eax + 2bcf: 68 9b 41 00 00 push $0x419b + 2bd4: 68 92 4a 00 00 push $0x4a92 + 2bd9: e8 7d 0d 00 00 call 395b + fd = open("", O_CREATE); + 2bde: 58 pop %eax + 2bdf: 5a pop %edx + 2be0: 68 00 02 00 00 push $0x200 + 2be5: 68 9b 41 00 00 push $0x419b + 2bea: e8 4c 0d 00 00 call 393b + if (fd >= 0) { + 2bef: 83 c4 10 add $0x10,%esp + 2bf2: 85 c0 test %eax,%eax + 2bf4: 78 0c js 2c02 + close(fd); + 2bf6: 83 ec 0c sub $0xc,%esp + 2bf9: 50 push %eax + 2bfa: e8 6c 0d 00 00 call 396b + 2bff: 83 c4 10 add $0x10,%esp + fd = open("xx", O_CREATE); + 2c02: 83 ec 08 sub $0x8,%esp + 2c05: 68 00 02 00 00 push $0x200 + 2c0a: 68 d0 46 00 00 push $0x46d0 + 2c0f: e8 27 0d 00 00 call 393b + if (fd >= 0) { + 2c14: 83 c4 10 add $0x10,%esp + 2c17: 85 c0 test %eax,%eax + 2c19: 78 0c js 2c27 + close(fd); + 2c1b: 83 ec 0c sub $0xc,%esp + 2c1e: 50 push %eax + 2c1f: e8 47 0d 00 00 call 396b + 2c24: 83 c4 10 add $0x10,%esp + unlink("xx"); + 2c27: 83 ec 0c sub $0xc,%esp + 2c2a: 68 d0 46 00 00 push $0x46d0 + 2c2f: e8 1f 0d 00 00 call 3953 + for (i = 0; i < 50 + 1; i++) { + 2c34: 83 c4 10 add $0x10,%esp + 2c37: 83 eb 01 sub $0x1,%ebx + 2c3a: 0f 85 50 ff ff ff jne 2b90 + chdir("/"); + 2c40: 83 ec 0c sub $0xc,%esp + 2c43: 68 c1 3d 00 00 push $0x3dc1 + 2c48: e8 be 0c 00 00 call 390b + printf(1, "empty file name OK\n"); + 2c4d: 58 pop %eax + 2c4e: 5a pop %edx + 2c4f: 68 14 4b 00 00 push $0x4b14 + 2c54: 6a 01 push $0x1 + 2c56: e8 f5 0d 00 00 call 3a50 +} + 2c5b: 8b 5d fc mov -0x4(%ebp),%ebx + 2c5e: 83 c4 10 add $0x10,%esp + 2c61: c9 leave + 2c62: c3 ret + printf(1, "mkdir irefd failed\n"); + 2c63: 83 ec 08 sub $0x8,%esp + 2c66: 68 ec 4a 00 00 push $0x4aec + 2c6b: 6a 01 push $0x1 + 2c6d: e8 de 0d 00 00 call 3a50 + exit(); + 2c72: e8 5c 0c 00 00 call 38d3 + printf(1, "chdir irefd failed\n"); + 2c77: 83 ec 08 sub $0x8,%esp + 2c7a: 68 00 4b 00 00 push $0x4b00 + 2c7f: 6a 01 push $0x1 + 2c81: e8 ca 0d 00 00 call 3a50 + exit(); + 2c86: e8 48 0c 00 00 call 38d3 + 2c8b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 2c8f: 90 nop + +00002c90 : +void forktest(void) { + 2c90: 55 push %ebp + 2c91: 89 e5 mov %esp,%ebp + 2c93: 53 push %ebx + for (n = 0; n < 1000; n++) { + 2c94: 31 db xor %ebx,%ebx +void forktest(void) { + 2c96: 83 ec 0c sub $0xc,%esp + printf(1, "fork test\n"); + 2c99: 68 28 4b 00 00 push $0x4b28 + 2c9e: 6a 01 push $0x1 + 2ca0: e8 ab 0d 00 00 call 3a50 + 2ca5: 83 c4 10 add $0x10,%esp + 2ca8: eb 13 jmp 2cbd + 2caa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (pid == 0) { + 2cb0: 74 4a je 2cfc + for (n = 0; n < 1000; n++) { + 2cb2: 83 c3 01 add $0x1,%ebx + 2cb5: 81 fb e8 03 00 00 cmp $0x3e8,%ebx + 2cbb: 74 6b je 2d28 + pid = fork(); + 2cbd: e8 09 0c 00 00 call 38cb + if (pid < 0) { + 2cc2: 85 c0 test %eax,%eax + 2cc4: 79 ea jns 2cb0 + for (; n > 0; n--) { + 2cc6: 85 db test %ebx,%ebx + 2cc8: 74 14 je 2cde + 2cca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (wait() < 0) { + 2cd0: e8 06 0c 00 00 call 38db + 2cd5: 85 c0 test %eax,%eax + 2cd7: 78 28 js 2d01 + for (; n > 0; n--) { + 2cd9: 83 eb 01 sub $0x1,%ebx + 2cdc: 75 f2 jne 2cd0 + if (wait() != -1) { + 2cde: e8 f8 0b 00 00 call 38db + 2ce3: 83 f8 ff cmp $0xffffffff,%eax + 2ce6: 75 2d jne 2d15 + printf(1, "fork test OK\n"); + 2ce8: 83 ec 08 sub $0x8,%esp + 2ceb: 68 5a 4b 00 00 push $0x4b5a + 2cf0: 6a 01 push $0x1 + 2cf2: e8 59 0d 00 00 call 3a50 +} + 2cf7: 8b 5d fc mov -0x4(%ebp),%ebx + 2cfa: c9 leave + 2cfb: c3 ret + exit(); + 2cfc: e8 d2 0b 00 00 call 38d3 + printf(1, "wait stopped early\n"); + 2d01: 83 ec 08 sub $0x8,%esp + 2d04: 68 33 4b 00 00 push $0x4b33 + 2d09: 6a 01 push $0x1 + 2d0b: e8 40 0d 00 00 call 3a50 + exit(); + 2d10: e8 be 0b 00 00 call 38d3 + printf(1, "wait got too many\n"); + 2d15: 52 push %edx + 2d16: 52 push %edx + 2d17: 68 47 4b 00 00 push $0x4b47 + 2d1c: 6a 01 push $0x1 + 2d1e: e8 2d 0d 00 00 call 3a50 + exit(); + 2d23: e8 ab 0b 00 00 call 38d3 + printf(1, "fork claimed to work 1000 times!\n"); + 2d28: 50 push %eax + 2d29: 50 push %eax + 2d2a: 68 c8 52 00 00 push $0x52c8 + 2d2f: 6a 01 push $0x1 + 2d31: e8 1a 0d 00 00 call 3a50 + exit(); + 2d36: e8 98 0b 00 00 call 38d3 + 2d3b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 2d3f: 90 nop + +00002d40 : +void sbrktest(void) { + 2d40: 55 push %ebp + 2d41: 89 e5 mov %esp,%ebp + 2d43: 57 push %edi + 2d44: 56 push %esi + for (i = 0; i < 5000; i++) { + 2d45: 31 f6 xor %esi,%esi +void sbrktest(void) { + 2d47: 53 push %ebx + 2d48: 83 ec 64 sub $0x64,%esp + printf(stdout, "sbrk test\n"); + 2d4b: 68 68 4b 00 00 push $0x4b68 + 2d50: ff 35 68 5e 00 00 push 0x5e68 + 2d56: e8 f5 0c 00 00 call 3a50 + oldbrk = sbrk(0); + 2d5b: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 2d62: e8 bc 0b 00 00 call 3923 + a = sbrk(0); + 2d67: c7 04 24 00 00 00 00 movl $0x0,(%esp) + oldbrk = sbrk(0); + 2d6e: 89 45 a4 mov %eax,-0x5c(%ebp) + a = sbrk(0); + 2d71: e8 ad 0b 00 00 call 3923 + 2d76: 83 c4 10 add $0x10,%esp + 2d79: 89 c3 mov %eax,%ebx + for (i = 0; i < 5000; i++) { + 2d7b: eb 05 jmp 2d82 + 2d7d: 8d 76 00 lea 0x0(%esi),%esi + a = b + 1; + 2d80: 89 c3 mov %eax,%ebx + b = sbrk(1); + 2d82: 83 ec 0c sub $0xc,%esp + 2d85: 6a 01 push $0x1 + 2d87: e8 97 0b 00 00 call 3923 + if (b != a) { + 2d8c: 83 c4 10 add $0x10,%esp + 2d8f: 39 d8 cmp %ebx,%eax + 2d91: 0f 85 9c 02 00 00 jne 3033 + for (i = 0; i < 5000; i++) { + 2d97: 83 c6 01 add $0x1,%esi + *b = 1; + 2d9a: c6 03 01 movb $0x1,(%ebx) + a = b + 1; + 2d9d: 8d 43 01 lea 0x1(%ebx),%eax + for (i = 0; i < 5000; i++) { + 2da0: 81 fe 88 13 00 00 cmp $0x1388,%esi + 2da6: 75 d8 jne 2d80 + pid = fork(); + 2da8: e8 1e 0b 00 00 call 38cb + 2dad: 89 c6 mov %eax,%esi + if (pid < 0) { + 2daf: 85 c0 test %eax,%eax + 2db1: 0f 88 02 03 00 00 js 30b9 + c = sbrk(1); + 2db7: 83 ec 0c sub $0xc,%esp + if (c != a + 1) { + 2dba: 83 c3 02 add $0x2,%ebx + c = sbrk(1); + 2dbd: 6a 01 push $0x1 + 2dbf: e8 5f 0b 00 00 call 3923 + c = sbrk(1); + 2dc4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2dcb: e8 53 0b 00 00 call 3923 + if (c != a + 1) { + 2dd0: 83 c4 10 add $0x10,%esp + 2dd3: 39 c3 cmp %eax,%ebx + 2dd5: 0f 85 3b 03 00 00 jne 3116 + if (pid == 0) { + 2ddb: 85 f6 test %esi,%esi + 2ddd: 0f 84 2e 03 00 00 je 3111 + wait(); + 2de3: e8 f3 0a 00 00 call 38db + a = sbrk(0); + 2de8: 83 ec 0c sub $0xc,%esp + 2deb: 6a 00 push $0x0 + 2ded: e8 31 0b 00 00 call 3923 + 2df2: 89 c3 mov %eax,%ebx + amt = (BIG) -(uint)a; + 2df4: b8 00 00 40 06 mov $0x6400000,%eax + 2df9: 29 d8 sub %ebx,%eax + p = sbrk(amt); + 2dfb: 89 04 24 mov %eax,(%esp) + 2dfe: e8 20 0b 00 00 call 3923 + if (p != a) { + 2e03: 83 c4 10 add $0x10,%esp + 2e06: 39 c3 cmp %eax,%ebx + 2e08: 0f 85 94 02 00 00 jne 30a2 + a = sbrk(0); + 2e0e: 83 ec 0c sub $0xc,%esp + *lastaddr = 99; + 2e11: c6 05 ff ff 3f 06 63 movb $0x63,0x63fffff + a = sbrk(0); + 2e18: 6a 00 push $0x0 + 2e1a: e8 04 0b 00 00 call 3923 + c = sbrk(-4096); + 2e1f: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp) + a = sbrk(0); + 2e26: 89 c3 mov %eax,%ebx + c = sbrk(-4096); + 2e28: e8 f6 0a 00 00 call 3923 + if (c == (char*)0xffffffff) { + 2e2d: 83 c4 10 add $0x10,%esp + 2e30: 83 f8 ff cmp $0xffffffff,%eax + 2e33: 0f 84 22 03 00 00 je 315b + c = sbrk(0); + 2e39: 83 ec 0c sub $0xc,%esp + 2e3c: 6a 00 push $0x0 + 2e3e: e8 e0 0a 00 00 call 3923 + if (c != a - 4096) { + 2e43: 8d 93 00 f0 ff ff lea -0x1000(%ebx),%edx + 2e49: 83 c4 10 add $0x10,%esp + 2e4c: 39 d0 cmp %edx,%eax + 2e4e: 0f 85 f0 02 00 00 jne 3144 + a = sbrk(0); + 2e54: 83 ec 0c sub $0xc,%esp + 2e57: 6a 00 push $0x0 + 2e59: e8 c5 0a 00 00 call 3923 + c = sbrk(4096); + 2e5e: c7 04 24 00 10 00 00 movl $0x1000,(%esp) + a = sbrk(0); + 2e65: 89 c3 mov %eax,%ebx + c = sbrk(4096); + 2e67: e8 b7 0a 00 00 call 3923 + if (c != a || sbrk(0) != a + 4096) { + 2e6c: 83 c4 10 add $0x10,%esp + c = sbrk(4096); + 2e6f: 89 c6 mov %eax,%esi + if (c != a || sbrk(0) != a + 4096) { + 2e71: 39 c3 cmp %eax,%ebx + 2e73: 0f 85 b4 02 00 00 jne 312d + 2e79: 83 ec 0c sub $0xc,%esp + 2e7c: 6a 00 push $0x0 + 2e7e: e8 a0 0a 00 00 call 3923 + 2e83: 8d 93 00 10 00 00 lea 0x1000(%ebx),%edx + 2e89: 83 c4 10 add $0x10,%esp + 2e8c: 39 c2 cmp %eax,%edx + 2e8e: 0f 85 99 02 00 00 jne 312d + if (*lastaddr == 99) { + 2e94: 80 3d ff ff 3f 06 63 cmpb $0x63,0x63fffff + 2e9b: 0f 84 2f 02 00 00 je 30d0 + a = sbrk(0); + 2ea1: 83 ec 0c sub $0xc,%esp + 2ea4: 6a 00 push $0x0 + 2ea6: e8 78 0a 00 00 call 3923 + c = sbrk(-(sbrk(0) - oldbrk)); + 2eab: c7 04 24 00 00 00 00 movl $0x0,(%esp) + a = sbrk(0); + 2eb2: 89 c3 mov %eax,%ebx + c = sbrk(-(sbrk(0) - oldbrk)); + 2eb4: e8 6a 0a 00 00 call 3923 + 2eb9: 89 c2 mov %eax,%edx + 2ebb: 8b 45 a4 mov -0x5c(%ebp),%eax + 2ebe: 29 d0 sub %edx,%eax + 2ec0: 89 04 24 mov %eax,(%esp) + 2ec3: e8 5b 0a 00 00 call 3923 + if (c != a) { + 2ec8: 83 c4 10 add $0x10,%esp + 2ecb: 39 c3 cmp %eax,%ebx + 2ecd: 0f 85 b8 01 00 00 jne 308b + for (a = (char*)(KERNBASE); a < (char*) (KERNBASE + 2000000); a += 50000) { + 2ed3: bb 00 00 00 80 mov $0x80000000,%ebx + 2ed8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 2edf: 90 nop + ppid = getpid(); + 2ee0: e8 36 0a 00 00 call 391b + 2ee5: 89 c6 mov %eax,%esi + pid = fork(); + 2ee7: e8 df 09 00 00 call 38cb + if (pid < 0) { + 2eec: 85 c0 test %eax,%eax + 2eee: 0f 88 5d 01 00 00 js 3051 + if (pid == 0) { + 2ef4: 0f 84 6f 01 00 00 je 3069 + wait(); + 2efa: e8 dc 09 00 00 call 38db + for (a = (char*)(KERNBASE); a < (char*) (KERNBASE + 2000000); a += 50000) { + 2eff: 81 c3 50 c3 00 00 add $0xc350,%ebx + 2f05: 81 fb 80 84 1e 80 cmp $0x801e8480,%ebx + 2f0b: 75 d3 jne 2ee0 + if (pipe(fds) != 0) { + 2f0d: 83 ec 0c sub $0xc,%esp + 2f10: 8d 45 b8 lea -0x48(%ebp),%eax + 2f13: 50 push %eax + 2f14: e8 ca 09 00 00 call 38e3 + 2f19: 83 c4 10 add $0x10,%esp + 2f1c: 85 c0 test %eax,%eax + 2f1e: 0f 85 da 01 00 00 jne 30fe + 2f24: 8d 5d c0 lea -0x40(%ebp),%ebx + 2f27: 8d 75 e8 lea -0x18(%ebp),%esi + 2f2a: 89 df mov %ebx,%edi + 2f2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if ((pids[i] = fork()) == 0) { + 2f30: e8 96 09 00 00 call 38cb + 2f35: 89 07 mov %eax,(%edi) + 2f37: 85 c0 test %eax,%eax + 2f39: 0f 84 91 00 00 00 je 2fd0 + if (pids[i] != -1) { + 2f3f: 83 f8 ff cmp $0xffffffff,%eax + 2f42: 74 14 je 2f58 + read(fds[0], &scratch, 1); + 2f44: 83 ec 04 sub $0x4,%esp + 2f47: 8d 45 b7 lea -0x49(%ebp),%eax + 2f4a: 6a 01 push $0x1 + 2f4c: 50 push %eax + 2f4d: ff 75 b8 push -0x48(%ebp) + 2f50: e8 96 09 00 00 call 38eb + 2f55: 83 c4 10 add $0x10,%esp + for (i = 0; i < sizeof(pids) / sizeof(pids[0]); i++) { + 2f58: 83 c7 04 add $0x4,%edi + 2f5b: 39 f7 cmp %esi,%edi + 2f5d: 75 d1 jne 2f30 + c = sbrk(4096); + 2f5f: 83 ec 0c sub $0xc,%esp + 2f62: 68 00 10 00 00 push $0x1000 + 2f67: e8 b7 09 00 00 call 3923 + 2f6c: 83 c4 10 add $0x10,%esp + 2f6f: 89 c7 mov %eax,%edi + for (i = 0; i < sizeof(pids) / sizeof(pids[0]); i++) { + 2f71: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if (pids[i] == -1) { + 2f78: 8b 03 mov (%ebx),%eax + 2f7a: 83 f8 ff cmp $0xffffffff,%eax + 2f7d: 74 11 je 2f90 + kill(pids[i]); + 2f7f: 83 ec 0c sub $0xc,%esp + 2f82: 50 push %eax + 2f83: e8 6b 09 00 00 call 38f3 + wait(); + 2f88: e8 4e 09 00 00 call 38db + 2f8d: 83 c4 10 add $0x10,%esp + for (i = 0; i < sizeof(pids) / sizeof(pids[0]); i++) { + 2f90: 83 c3 04 add $0x4,%ebx + 2f93: 39 de cmp %ebx,%esi + 2f95: 75 e1 jne 2f78 + if (c == (char*)0xffffffff) { + 2f97: 83 ff ff cmp $0xffffffff,%edi + 2f9a: 0f 84 47 01 00 00 je 30e7 + if (sbrk(0) > oldbrk) { + 2fa0: 83 ec 0c sub $0xc,%esp + 2fa3: 6a 00 push $0x0 + 2fa5: e8 79 09 00 00 call 3923 + 2faa: 83 c4 10 add $0x10,%esp + 2fad: 39 45 a4 cmp %eax,-0x5c(%ebp) + 2fb0: 72 60 jb 3012 + printf(stdout, "sbrk test OK\n"); + 2fb2: 83 ec 08 sub $0x8,%esp + 2fb5: 68 10 4c 00 00 push $0x4c10 + 2fba: ff 35 68 5e 00 00 push 0x5e68 + 2fc0: e8 8b 0a 00 00 call 3a50 +} + 2fc5: 83 c4 10 add $0x10,%esp + 2fc8: 8d 65 f4 lea -0xc(%ebp),%esp + 2fcb: 5b pop %ebx + 2fcc: 5e pop %esi + 2fcd: 5f pop %edi + 2fce: 5d pop %ebp + 2fcf: c3 ret + sbrk(BIG - (uint)sbrk(0)); + 2fd0: 83 ec 0c sub $0xc,%esp + 2fd3: 6a 00 push $0x0 + 2fd5: e8 49 09 00 00 call 3923 + 2fda: 89 c2 mov %eax,%edx + 2fdc: b8 00 00 40 06 mov $0x6400000,%eax + 2fe1: 29 d0 sub %edx,%eax + 2fe3: 89 04 24 mov %eax,(%esp) + 2fe6: e8 38 09 00 00 call 3923 + write(fds[1], "x", 1); + 2feb: 83 c4 0c add $0xc,%esp + 2fee: 6a 01 push $0x1 + 2ff0: 68 d1 46 00 00 push $0x46d1 + 2ff5: ff 75 bc push -0x44(%ebp) + 2ff8: e8 46 09 00 00 call 3943 + 2ffd: 83 c4 10 add $0x10,%esp + for (;;) { sleep(1000); + 3000: 83 ec 0c sub $0xc,%esp + 3003: 68 e8 03 00 00 push $0x3e8 + 3008: e8 1e 09 00 00 call 392b + 300d: 83 c4 10 add $0x10,%esp + 3010: eb ee jmp 3000 + sbrk(-(sbrk(0) - oldbrk)); + 3012: 83 ec 0c sub $0xc,%esp + 3015: 6a 00 push $0x0 + 3017: e8 07 09 00 00 call 3923 + 301c: 89 c2 mov %eax,%edx + 301e: 8b 45 a4 mov -0x5c(%ebp),%eax + 3021: 29 d0 sub %edx,%eax + 3023: 89 04 24 mov %eax,(%esp) + 3026: e8 f8 08 00 00 call 3923 + 302b: 83 c4 10 add $0x10,%esp + 302e: e9 7f ff ff ff jmp 2fb2 + printf(stdout, "sbrk test failed %d %x %x\n", i, a, b); + 3033: 83 ec 0c sub $0xc,%esp + 3036: 50 push %eax + 3037: 53 push %ebx + 3038: 56 push %esi + 3039: 68 73 4b 00 00 push $0x4b73 + 303e: ff 35 68 5e 00 00 push 0x5e68 + 3044: e8 07 0a 00 00 call 3a50 + exit(); + 3049: 83 c4 20 add $0x20,%esp + 304c: e8 82 08 00 00 call 38d3 + printf(stdout, "fork failed\n"); + 3051: 83 ec 08 sub $0x8,%esp + 3054: 68 b9 4c 00 00 push $0x4cb9 + 3059: ff 35 68 5e 00 00 push 0x5e68 + 305f: e8 ec 09 00 00 call 3a50 + exit(); + 3064: e8 6a 08 00 00 call 38d3 + printf(stdout, "oops could read %x = %x\n", a, *a); + 3069: 0f be 03 movsbl (%ebx),%eax + 306c: 50 push %eax + 306d: 53 push %ebx + 306e: 68 dc 4b 00 00 push $0x4bdc + 3073: ff 35 68 5e 00 00 push 0x5e68 + 3079: e8 d2 09 00 00 call 3a50 + kill(ppid); + 307e: 89 34 24 mov %esi,(%esp) + 3081: e8 6d 08 00 00 call 38f3 + exit(); + 3086: e8 48 08 00 00 call 38d3 + printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); + 308b: 50 push %eax + 308c: 53 push %ebx + 308d: 68 bc 53 00 00 push $0x53bc + 3092: ff 35 68 5e 00 00 push 0x5e68 + 3098: e8 b3 09 00 00 call 3a50 + exit(); + 309d: e8 31 08 00 00 call 38d3 + printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n"); + 30a2: 56 push %esi + 30a3: 56 push %esi + 30a4: 68 ec 52 00 00 push $0x52ec + 30a9: ff 35 68 5e 00 00 push 0x5e68 + 30af: e8 9c 09 00 00 call 3a50 + exit(); + 30b4: e8 1a 08 00 00 call 38d3 + printf(stdout, "sbrk test fork failed\n"); + 30b9: 50 push %eax + 30ba: 50 push %eax + 30bb: 68 8e 4b 00 00 push $0x4b8e + 30c0: ff 35 68 5e 00 00 push 0x5e68 + 30c6: e8 85 09 00 00 call 3a50 + exit(); + 30cb: e8 03 08 00 00 call 38d3 + printf(stdout, "sbrk de-allocation didn't really deallocate\n"); + 30d0: 51 push %ecx + 30d1: 51 push %ecx + 30d2: 68 8c 53 00 00 push $0x538c + 30d7: ff 35 68 5e 00 00 push 0x5e68 + 30dd: e8 6e 09 00 00 call 3a50 + exit(); + 30e2: e8 ec 07 00 00 call 38d3 + printf(stdout, "failed sbrk leaked memory\n"); + 30e7: 50 push %eax + 30e8: 50 push %eax + 30e9: 68 f5 4b 00 00 push $0x4bf5 + 30ee: ff 35 68 5e 00 00 push 0x5e68 + 30f4: e8 57 09 00 00 call 3a50 + exit(); + 30f9: e8 d5 07 00 00 call 38d3 + printf(1, "pipe() failed\n"); + 30fe: 52 push %edx + 30ff: 52 push %edx + 3100: 68 b1 40 00 00 push $0x40b1 + 3105: 6a 01 push $0x1 + 3107: e8 44 09 00 00 call 3a50 + exit(); + 310c: e8 c2 07 00 00 call 38d3 + exit(); + 3111: e8 bd 07 00 00 call 38d3 + printf(stdout, "sbrk test failed post-fork\n"); + 3116: 57 push %edi + 3117: 57 push %edi + 3118: 68 a5 4b 00 00 push $0x4ba5 + 311d: ff 35 68 5e 00 00 push 0x5e68 + 3123: e8 28 09 00 00 call 3a50 + exit(); + 3128: e8 a6 07 00 00 call 38d3 + printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c); + 312d: 56 push %esi + 312e: 53 push %ebx + 312f: 68 64 53 00 00 push $0x5364 + 3134: ff 35 68 5e 00 00 push 0x5e68 + 313a: e8 11 09 00 00 call 3a50 + exit(); + 313f: e8 8f 07 00 00 call 38d3 + printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c); + 3144: 50 push %eax + 3145: 53 push %ebx + 3146: 68 2c 53 00 00 push $0x532c + 314b: ff 35 68 5e 00 00 push 0x5e68 + 3151: e8 fa 08 00 00 call 3a50 + exit(); + 3156: e8 78 07 00 00 call 38d3 + printf(stdout, "sbrk could not deallocate\n"); + 315b: 53 push %ebx + 315c: 53 push %ebx + 315d: 68 c1 4b 00 00 push $0x4bc1 + 3162: ff 35 68 5e 00 00 push 0x5e68 + 3168: e8 e3 08 00 00 call 3a50 + exit(); + 316d: e8 61 07 00 00 call 38d3 + 3172: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00003180 : +} + 3180: c3 ret + 3181: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3188: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 318f: 90 nop + +00003190 : +void validatetest(void) { + 3190: 55 push %ebp + 3191: 89 e5 mov %esp,%ebp + 3193: 56 push %esi + for (p = 0; p <= (uint)hi; p += 4096) { + 3194: 31 f6 xor %esi,%esi +void validatetest(void) { + 3196: 53 push %ebx + printf(stdout, "validate test\n"); + 3197: 83 ec 08 sub $0x8,%esp + 319a: 68 1e 4c 00 00 push $0x4c1e + 319f: ff 35 68 5e 00 00 push 0x5e68 + 31a5: e8 a6 08 00 00 call 3a50 + 31aa: 83 c4 10 add $0x10,%esp + 31ad: 8d 76 00 lea 0x0(%esi),%esi + if ((pid = fork()) == 0) { + 31b0: e8 16 07 00 00 call 38cb + 31b5: 89 c3 mov %eax,%ebx + 31b7: 85 c0 test %eax,%eax + 31b9: 74 63 je 321e + sleep(0); + 31bb: 83 ec 0c sub $0xc,%esp + 31be: 6a 00 push $0x0 + 31c0: e8 66 07 00 00 call 392b + sleep(0); + 31c5: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 31cc: e8 5a 07 00 00 call 392b + kill(pid); + 31d1: 89 1c 24 mov %ebx,(%esp) + 31d4: e8 1a 07 00 00 call 38f3 + wait(); + 31d9: e8 fd 06 00 00 call 38db + if (link("nosuchfile", (char*)p) != -1) { + 31de: 58 pop %eax + 31df: 5a pop %edx + 31e0: 56 push %esi + 31e1: 68 2d 4c 00 00 push $0x4c2d + 31e6: e8 70 07 00 00 call 395b + 31eb: 83 c4 10 add $0x10,%esp + 31ee: 83 f8 ff cmp $0xffffffff,%eax + 31f1: 75 30 jne 3223 + for (p = 0; p <= (uint)hi; p += 4096) { + 31f3: 81 c6 00 10 00 00 add $0x1000,%esi + 31f9: 81 fe 00 40 11 00 cmp $0x114000,%esi + 31ff: 75 af jne 31b0 + printf(stdout, "validate ok\n"); + 3201: 83 ec 08 sub $0x8,%esp + 3204: 68 51 4c 00 00 push $0x4c51 + 3209: ff 35 68 5e 00 00 push 0x5e68 + 320f: e8 3c 08 00 00 call 3a50 +} + 3214: 83 c4 10 add $0x10,%esp + 3217: 8d 65 f8 lea -0x8(%ebp),%esp + 321a: 5b pop %ebx + 321b: 5e pop %esi + 321c: 5d pop %ebp + 321d: c3 ret + exit(); + 321e: e8 b0 06 00 00 call 38d3 + printf(stdout, "link should not succeed\n"); + 3223: 83 ec 08 sub $0x8,%esp + 3226: 68 38 4c 00 00 push $0x4c38 + 322b: ff 35 68 5e 00 00 push 0x5e68 + 3231: e8 1a 08 00 00 call 3a50 + exit(); + 3236: e8 98 06 00 00 call 38d3 + 323b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 323f: 90 nop + +00003240 : +void bsstest(void) { + 3240: 55 push %ebp + 3241: 89 e5 mov %esp,%ebp + 3243: 83 ec 10 sub $0x10,%esp + printf(stdout, "bss test\n"); + 3246: 68 5e 4c 00 00 push $0x4c5e + 324b: ff 35 68 5e 00 00 push 0x5e68 + 3251: e8 fa 07 00 00 call 3a50 + 3256: 83 c4 10 add $0x10,%esp + for (i = 0; i < sizeof(uninit); i++) { + 3259: 31 c0 xor %eax,%eax + 325b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 325f: 90 nop + if (uninit[i] != '\0') { + 3260: 80 b8 80 5e 00 00 00 cmpb $0x0,0x5e80(%eax) + 3267: 75 22 jne 328b + for (i = 0; i < sizeof(uninit); i++) { + 3269: 83 c0 01 add $0x1,%eax + 326c: 3d 10 27 00 00 cmp $0x2710,%eax + 3271: 75 ed jne 3260 + printf(stdout, "bss test ok\n"); + 3273: 83 ec 08 sub $0x8,%esp + 3276: 68 79 4c 00 00 push $0x4c79 + 327b: ff 35 68 5e 00 00 push 0x5e68 + 3281: e8 ca 07 00 00 call 3a50 +} + 3286: 83 c4 10 add $0x10,%esp + 3289: c9 leave + 328a: c3 ret + printf(stdout, "bss test failed\n"); + 328b: 83 ec 08 sub $0x8,%esp + 328e: 68 68 4c 00 00 push $0x4c68 + 3293: ff 35 68 5e 00 00 push 0x5e68 + 3299: e8 b2 07 00 00 call 3a50 + exit(); + 329e: e8 30 06 00 00 call 38d3 + 32a3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 32aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000032b0 : +void bigargtest(void) { + 32b0: 55 push %ebp + 32b1: 89 e5 mov %esp,%ebp + 32b3: 83 ec 14 sub $0x14,%esp + unlink("bigarg-ok"); + 32b6: 68 86 4c 00 00 push $0x4c86 + 32bb: e8 93 06 00 00 call 3953 + pid = fork(); + 32c0: e8 06 06 00 00 call 38cb + if (pid == 0) { + 32c5: 83 c4 10 add $0x10,%esp + 32c8: 85 c0 test %eax,%eax + 32ca: 74 44 je 3310 + else if (pid < 0) { + 32cc: 0f 88 c5 00 00 00 js 3397 + wait(); + 32d2: e8 04 06 00 00 call 38db + fd = open("bigarg-ok", 0); + 32d7: 83 ec 08 sub $0x8,%esp + 32da: 6a 00 push $0x0 + 32dc: 68 86 4c 00 00 push $0x4c86 + 32e1: e8 55 06 00 00 call 393b + if (fd < 0) { + 32e6: 83 c4 10 add $0x10,%esp + 32e9: 85 c0 test %eax,%eax + 32eb: 0f 88 8f 00 00 00 js 3380 + close(fd); + 32f1: 83 ec 0c sub $0xc,%esp + 32f4: 50 push %eax + 32f5: e8 71 06 00 00 call 396b + unlink("bigarg-ok"); + 32fa: c7 04 24 86 4c 00 00 movl $0x4c86,(%esp) + 3301: e8 4d 06 00 00 call 3953 +} + 3306: 83 c4 10 add $0x10,%esp + 3309: c9 leave + 330a: c3 ret + 330b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 330f: 90 nop + args[i] = "bigargs test: failed\n "; + 3310: c7 04 85 a0 a5 00 00 movl $0x53e0,0xa5a0(,%eax,4) + 3317: e0 53 00 00 + for (i = 0; i < MAXARG - 1; i++) { + 331b: 83 c0 01 add $0x1,%eax + 331e: 83 f8 1f cmp $0x1f,%eax + 3321: 75 ed jne 3310 + printf(stdout, "bigarg test\n"); + 3323: 51 push %ecx + 3324: 51 push %ecx + 3325: 68 90 4c 00 00 push $0x4c90 + 332a: ff 35 68 5e 00 00 push 0x5e68 + args[MAXARG - 1] = 0; + 3330: c7 05 1c a6 00 00 00 movl $0x0,0xa61c + 3337: 00 00 00 + printf(stdout, "bigarg test\n"); + 333a: e8 11 07 00 00 call 3a50 + exec("echo", args); + 333f: 58 pop %eax + 3340: 5a pop %edx + 3341: 68 a0 a5 00 00 push $0xa5a0 + 3346: 68 5d 3e 00 00 push $0x3e5d + 334b: e8 ab 05 00 00 call 38fb + printf(stdout, "bigarg test ok\n"); + 3350: 59 pop %ecx + 3351: 58 pop %eax + 3352: 68 9d 4c 00 00 push $0x4c9d + 3357: ff 35 68 5e 00 00 push 0x5e68 + 335d: e8 ee 06 00 00 call 3a50 + fd = open("bigarg-ok", O_CREATE); + 3362: 58 pop %eax + 3363: 5a pop %edx + 3364: 68 00 02 00 00 push $0x200 + 3369: 68 86 4c 00 00 push $0x4c86 + 336e: e8 c8 05 00 00 call 393b + close(fd); + 3373: 89 04 24 mov %eax,(%esp) + 3376: e8 f0 05 00 00 call 396b + exit(); + 337b: e8 53 05 00 00 call 38d3 + printf(stdout, "bigarg test failed!\n"); + 3380: 50 push %eax + 3381: 50 push %eax + 3382: 68 c6 4c 00 00 push $0x4cc6 + 3387: ff 35 68 5e 00 00 push 0x5e68 + 338d: e8 be 06 00 00 call 3a50 + exit(); + 3392: e8 3c 05 00 00 call 38d3 + printf(stdout, "bigargtest: fork failed\n"); + 3397: 52 push %edx + 3398: 52 push %edx + 3399: 68 ad 4c 00 00 push $0x4cad + 339e: ff 35 68 5e 00 00 push 0x5e68 + 33a4: e8 a7 06 00 00 call 3a50 + exit(); + 33a9: e8 25 05 00 00 call 38d3 + 33ae: 66 90 xchg %ax,%ax + +000033b0 : +void fsfull() { + 33b0: 55 push %ebp + 33b1: 89 e5 mov %esp,%ebp + 33b3: 57 push %edi + 33b4: 56 push %esi + for (nfiles = 0;; nfiles++) { + 33b5: 31 f6 xor %esi,%esi +void fsfull() { + 33b7: 53 push %ebx + 33b8: 83 ec 54 sub $0x54,%esp + printf(1, "fsfull test\n"); + 33bb: 68 db 4c 00 00 push $0x4cdb + 33c0: 6a 01 push $0x1 + 33c2: e8 89 06 00 00 call 3a50 + 33c7: 83 c4 10 add $0x10,%esp + 33ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + name[1] = '0' + nfiles / 1000; + 33d0: b8 d3 4d 62 10 mov $0x10624dd3,%eax + name[3] = '0' + (nfiles % 100) / 10; + 33d5: b9 cd cc cc cc mov $0xcccccccd,%ecx + printf(1, "writing %s\n", name); + 33da: 83 ec 04 sub $0x4,%esp + name[0] = 'f'; + 33dd: c6 45 a8 66 movb $0x66,-0x58(%ebp) + name[1] = '0' + nfiles / 1000; + 33e1: f7 e6 mul %esi + name[5] = '\0'; + 33e3: c6 45 ad 00 movb $0x0,-0x53(%ebp) + name[1] = '0' + nfiles / 1000; + 33e7: c1 ea 06 shr $0x6,%edx + 33ea: 8d 42 30 lea 0x30(%edx),%eax + 33ed: 88 45 a9 mov %al,-0x57(%ebp) + name[2] = '0' + (nfiles % 1000) / 100; + 33f0: 69 c2 e8 03 00 00 imul $0x3e8,%edx,%eax + 33f6: 89 f2 mov %esi,%edx + 33f8: 29 c2 sub %eax,%edx + 33fa: b8 1f 85 eb 51 mov $0x51eb851f,%eax + 33ff: f7 e2 mul %edx + name[3] = '0' + (nfiles % 100) / 10; + 3401: b8 1f 85 eb 51 mov $0x51eb851f,%eax + name[2] = '0' + (nfiles % 1000) / 100; + 3406: c1 ea 05 shr $0x5,%edx + 3409: 83 c2 30 add $0x30,%edx + 340c: 88 55 aa mov %dl,-0x56(%ebp) + name[3] = '0' + (nfiles % 100) / 10; + 340f: f7 e6 mul %esi + 3411: c1 ea 05 shr $0x5,%edx + 3414: 6b c2 64 imul $0x64,%edx,%eax + 3417: 89 f2 mov %esi,%edx + 3419: 29 c2 sub %eax,%edx + 341b: 89 d0 mov %edx,%eax + 341d: f7 e1 mul %ecx + name[4] = '0' + (nfiles % 10); + 341f: 89 f0 mov %esi,%eax + name[3] = '0' + (nfiles % 100) / 10; + 3421: c1 ea 03 shr $0x3,%edx + 3424: 83 c2 30 add $0x30,%edx + 3427: 88 55 ab mov %dl,-0x55(%ebp) + name[4] = '0' + (nfiles % 10); + 342a: f7 e1 mul %ecx + 342c: 89 f0 mov %esi,%eax + 342e: c1 ea 03 shr $0x3,%edx + 3431: 8d 14 92 lea (%edx,%edx,4),%edx + 3434: 01 d2 add %edx,%edx + 3436: 29 d0 sub %edx,%eax + 3438: 83 c0 30 add $0x30,%eax + 343b: 88 45 ac mov %al,-0x54(%ebp) + printf(1, "writing %s\n", name); + 343e: 8d 45 a8 lea -0x58(%ebp),%eax + 3441: 50 push %eax + 3442: 68 e8 4c 00 00 push $0x4ce8 + 3447: 6a 01 push $0x1 + 3449: e8 02 06 00 00 call 3a50 + int fd = open(name, O_CREATE | O_RDWR); + 344e: 58 pop %eax + 344f: 8d 45 a8 lea -0x58(%ebp),%eax + 3452: 5a pop %edx + 3453: 68 02 02 00 00 push $0x202 + 3458: 50 push %eax + 3459: e8 dd 04 00 00 call 393b + if (fd < 0) { + 345e: 83 c4 10 add $0x10,%esp + int fd = open(name, O_CREATE | O_RDWR); + 3461: 89 c7 mov %eax,%edi + if (fd < 0) { + 3463: 85 c0 test %eax,%eax + 3465: 78 4f js 34b6 + int total = 0; + 3467: 31 db xor %ebx,%ebx + 3469: eb 07 jmp 3472 + 346b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 346f: 90 nop + total += cc; + 3470: 01 c3 add %eax,%ebx + int cc = write(fd, buf, 512); + 3472: 83 ec 04 sub $0x4,%esp + 3475: 68 00 02 00 00 push $0x200 + 347a: 68 a0 85 00 00 push $0x85a0 + 347f: 57 push %edi + 3480: e8 be 04 00 00 call 3943 + if (cc < 512) { + 3485: 83 c4 10 add $0x10,%esp + 3488: 3d ff 01 00 00 cmp $0x1ff,%eax + 348d: 7f e1 jg 3470 + printf(1, "wrote %d bytes\n", total); + 348f: 83 ec 04 sub $0x4,%esp + 3492: 53 push %ebx + 3493: 68 04 4d 00 00 push $0x4d04 + 3498: 6a 01 push $0x1 + 349a: e8 b1 05 00 00 call 3a50 + close(fd); + 349f: 89 3c 24 mov %edi,(%esp) + 34a2: e8 c4 04 00 00 call 396b + if (total == 0) { + 34a7: 83 c4 10 add $0x10,%esp + 34aa: 85 db test %ebx,%ebx + 34ac: 74 1e je 34cc + for (nfiles = 0;; nfiles++) { + 34ae: 83 c6 01 add $0x1,%esi + 34b1: e9 1a ff ff ff jmp 33d0 + printf(1, "open %s failed\n", name); + 34b6: 83 ec 04 sub $0x4,%esp + 34b9: 8d 45 a8 lea -0x58(%ebp),%eax + 34bc: 50 push %eax + 34bd: 68 f4 4c 00 00 push $0x4cf4 + 34c2: 6a 01 push $0x1 + 34c4: e8 87 05 00 00 call 3a50 + break; + 34c9: 83 c4 10 add $0x10,%esp + name[1] = '0' + nfiles / 1000; + 34cc: bf d3 4d 62 10 mov $0x10624dd3,%edi + name[2] = '0' + (nfiles % 1000) / 100; + 34d1: bb 1f 85 eb 51 mov $0x51eb851f,%ebx + 34d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 34dd: 8d 76 00 lea 0x0(%esi),%esi + name[1] = '0' + nfiles / 1000; + 34e0: 89 f0 mov %esi,%eax + unlink(name); + 34e2: 83 ec 0c sub $0xc,%esp + name[0] = 'f'; + 34e5: c6 45 a8 66 movb $0x66,-0x58(%ebp) + name[1] = '0' + nfiles / 1000; + 34e9: f7 e7 mul %edi + name[5] = '\0'; + 34eb: c6 45 ad 00 movb $0x0,-0x53(%ebp) + name[1] = '0' + nfiles / 1000; + 34ef: c1 ea 06 shr $0x6,%edx + 34f2: 8d 42 30 lea 0x30(%edx),%eax + 34f5: 88 45 a9 mov %al,-0x57(%ebp) + name[2] = '0' + (nfiles % 1000) / 100; + 34f8: 69 c2 e8 03 00 00 imul $0x3e8,%edx,%eax + 34fe: 89 f2 mov %esi,%edx + 3500: 29 c2 sub %eax,%edx + 3502: 89 d0 mov %edx,%eax + 3504: f7 e3 mul %ebx + name[3] = '0' + (nfiles % 100) / 10; + 3506: 89 f0 mov %esi,%eax + name[2] = '0' + (nfiles % 1000) / 100; + 3508: c1 ea 05 shr $0x5,%edx + 350b: 83 c2 30 add $0x30,%edx + 350e: 88 55 aa mov %dl,-0x56(%ebp) + name[3] = '0' + (nfiles % 100) / 10; + 3511: f7 e3 mul %ebx + 3513: c1 ea 05 shr $0x5,%edx + 3516: 6b ca 64 imul $0x64,%edx,%ecx + 3519: 89 f2 mov %esi,%edx + 351b: 29 ca sub %ecx,%edx + 351d: b9 cd cc cc cc mov $0xcccccccd,%ecx + 3522: 89 d0 mov %edx,%eax + 3524: f7 e1 mul %ecx + name[4] = '0' + (nfiles % 10); + 3526: 89 f0 mov %esi,%eax + name[3] = '0' + (nfiles % 100) / 10; + 3528: c1 ea 03 shr $0x3,%edx + 352b: 83 c2 30 add $0x30,%edx + 352e: 88 55 ab mov %dl,-0x55(%ebp) + name[4] = '0' + (nfiles % 10); + 3531: f7 e1 mul %ecx + 3533: 89 f0 mov %esi,%eax + nfiles--; + 3535: 83 ee 01 sub $0x1,%esi + name[4] = '0' + (nfiles % 10); + 3538: c1 ea 03 shr $0x3,%edx + 353b: 8d 14 92 lea (%edx,%edx,4),%edx + 353e: 01 d2 add %edx,%edx + 3540: 29 d0 sub %edx,%eax + 3542: 83 c0 30 add $0x30,%eax + 3545: 88 45 ac mov %al,-0x54(%ebp) + unlink(name); + 3548: 8d 45 a8 lea -0x58(%ebp),%eax + 354b: 50 push %eax + 354c: e8 02 04 00 00 call 3953 + while (nfiles >= 0) { + 3551: 83 c4 10 add $0x10,%esp + 3554: 83 fe ff cmp $0xffffffff,%esi + 3557: 75 87 jne 34e0 + printf(1, "fsfull test finished\n"); + 3559: 83 ec 08 sub $0x8,%esp + 355c: 68 14 4d 00 00 push $0x4d14 + 3561: 6a 01 push $0x1 + 3563: e8 e8 04 00 00 call 3a50 +} + 3568: 83 c4 10 add $0x10,%esp + 356b: 8d 65 f4 lea -0xc(%ebp),%esp + 356e: 5b pop %ebx + 356f: 5e pop %esi + 3570: 5f pop %edi + 3571: 5d pop %ebp + 3572: c3 ret + 3573: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 357a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00003580 : +void uio() { + 3580: 55 push %ebp + 3581: 89 e5 mov %esp,%ebp + 3583: 83 ec 10 sub $0x10,%esp + printf(1, "uio test\n"); + 3586: 68 2a 4d 00 00 push $0x4d2a + 358b: 6a 01 push $0x1 + 358d: e8 be 04 00 00 call 3a50 + pid = fork(); + 3592: e8 34 03 00 00 call 38cb + if (pid == 0) { + 3597: 83 c4 10 add $0x10,%esp + 359a: 85 c0 test %eax,%eax + 359c: 74 1b je 35b9 + else if (pid < 0) { + 359e: 78 3d js 35dd + wait(); + 35a0: e8 36 03 00 00 call 38db + printf(1, "uio test done\n"); + 35a5: 83 ec 08 sub $0x8,%esp + 35a8: 68 34 4d 00 00 push $0x4d34 + 35ad: 6a 01 push $0x1 + 35af: e8 9c 04 00 00 call 3a50 +} + 35b4: 83 c4 10 add $0x10,%esp + 35b7: c9 leave + 35b8: c3 ret + asm volatile ("outb %0,%1" : : "a" (val), "d" (port)); + 35b9: b8 09 00 00 00 mov $0x9,%eax + 35be: ba 70 00 00 00 mov $0x70,%edx + 35c3: ee out %al,(%dx) + asm volatile ("inb %1,%0" : "=a" (val) : "d" (port)); + 35c4: ba 71 00 00 00 mov $0x71,%edx + 35c9: ec in (%dx),%al + printf(1, "uio: uio succeeded; test FAILED\n"); + 35ca: 52 push %edx + 35cb: 52 push %edx + 35cc: 68 c0 54 00 00 push $0x54c0 + 35d1: 6a 01 push $0x1 + 35d3: e8 78 04 00 00 call 3a50 + exit(); + 35d8: e8 f6 02 00 00 call 38d3 + printf(1, "fork failed\n"); + 35dd: 50 push %eax + 35de: 50 push %eax + 35df: 68 b9 4c 00 00 push $0x4cb9 + 35e4: 6a 01 push $0x1 + 35e6: e8 65 04 00 00 call 3a50 + exit(); + 35eb: e8 e3 02 00 00 call 38d3 + +000035f0 : +void argptest(){ + 35f0: 55 push %ebp + 35f1: 89 e5 mov %esp,%ebp + 35f3: 53 push %ebx + 35f4: 83 ec 0c sub $0xc,%esp + fd = open("init", O_RDONLY); + 35f7: 6a 00 push $0x0 + 35f9: 68 43 4d 00 00 push $0x4d43 + 35fe: e8 38 03 00 00 call 393b + if (fd < 0) { + 3603: 83 c4 10 add $0x10,%esp + 3606: 85 c0 test %eax,%eax + 3608: 78 39 js 3643 + read(fd, sbrk(0) - 1, -1); + 360a: 83 ec 0c sub $0xc,%esp + 360d: 89 c3 mov %eax,%ebx + 360f: 6a 00 push $0x0 + 3611: e8 0d 03 00 00 call 3923 + 3616: 83 c4 0c add $0xc,%esp + 3619: 83 e8 01 sub $0x1,%eax + 361c: 6a ff push $0xffffffff + 361e: 50 push %eax + 361f: 53 push %ebx + 3620: e8 c6 02 00 00 call 38eb + close(fd); + 3625: 89 1c 24 mov %ebx,(%esp) + 3628: e8 3e 03 00 00 call 396b + printf(1, "arg test passed\n"); + 362d: 58 pop %eax + 362e: 5a pop %edx + 362f: 68 55 4d 00 00 push $0x4d55 + 3634: 6a 01 push $0x1 + 3636: e8 15 04 00 00 call 3a50 +} + 363b: 8b 5d fc mov -0x4(%ebp),%ebx + 363e: 83 c4 10 add $0x10,%esp + 3641: c9 leave + 3642: c3 ret + printf(2, "open failed\n"); + 3643: 51 push %ecx + 3644: 51 push %ecx + 3645: 68 48 4d 00 00 push $0x4d48 + 364a: 6a 02 push $0x2 + 364c: e8 ff 03 00 00 call 3a50 + exit(); + 3651: e8 7d 02 00 00 call 38d3 + 3656: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 365d: 8d 76 00 lea 0x0(%esi),%esi + +00003660 : + randstate = randstate * 1664525 + 1013904223; + 3660: 69 05 64 5e 00 00 0d imul $0x19660d,0x5e64,%eax + 3667: 66 19 00 + 366a: 05 5f f3 6e 3c add $0x3c6ef35f,%eax + 366f: a3 64 5e 00 00 mov %eax,0x5e64 +} + 3674: c3 ret + 3675: 66 90 xchg %ax,%ax + 3677: 66 90 xchg %ax,%ax + 3679: 66 90 xchg %ax,%ax + 367b: 66 90 xchg %ax,%ax + 367d: 66 90 xchg %ax,%ax + 367f: 90 nop + +00003680 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 3680: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 3681: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 3683: 89 e5 mov %esp,%ebp + 3685: 53 push %ebx + 3686: 8b 4d 08 mov 0x8(%ebp),%ecx + 3689: 8b 5d 0c mov 0xc(%ebp),%ebx + 368c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 3690: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 3694: 88 14 01 mov %dl,(%ecx,%eax,1) + 3697: 83 c0 01 add $0x1,%eax + 369a: 84 d2 test %dl,%dl + 369c: 75 f2 jne 3690 + ; + } + return os; +} + 369e: 8b 5d fc mov -0x4(%ebp),%ebx + 36a1: 89 c8 mov %ecx,%eax + 36a3: c9 leave + 36a4: c3 ret + 36a5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 36ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000036b0 : + +int strcmp(const char *p, const char *q) { + 36b0: 55 push %ebp + 36b1: 89 e5 mov %esp,%ebp + 36b3: 53 push %ebx + 36b4: 8b 55 08 mov 0x8(%ebp),%edx + 36b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 36ba: 0f b6 02 movzbl (%edx),%eax + 36bd: 84 c0 test %al,%al + 36bf: 75 17 jne 36d8 + 36c1: eb 3a jmp 36fd + 36c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 36c7: 90 nop + 36c8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 36cc: 83 c2 01 add $0x1,%edx + 36cf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 36d2: 84 c0 test %al,%al + 36d4: 74 1a je 36f0 + p++, q++; + 36d6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 36d8: 0f b6 19 movzbl (%ecx),%ebx + 36db: 38 c3 cmp %al,%bl + 36dd: 74 e9 je 36c8 + } + return (uchar) * p - (uchar) * q; + 36df: 29 d8 sub %ebx,%eax +} + 36e1: 8b 5d fc mov -0x4(%ebp),%ebx + 36e4: c9 leave + 36e5: c3 ret + 36e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 36ed: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 36f0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 36f4: 31 c0 xor %eax,%eax + 36f6: 29 d8 sub %ebx,%eax +} + 36f8: 8b 5d fc mov -0x4(%ebp),%ebx + 36fb: c9 leave + 36fc: c3 ret + return (uchar) * p - (uchar) * q; + 36fd: 0f b6 19 movzbl (%ecx),%ebx + 3700: 31 c0 xor %eax,%eax + 3702: eb db jmp 36df + 3704: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 370b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 370f: 90 nop + +00003710 : + +uint strlen(const char *s) { + 3710: 55 push %ebp + 3711: 89 e5 mov %esp,%ebp + 3713: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 3716: 80 3a 00 cmpb $0x0,(%edx) + 3719: 74 15 je 3730 + 371b: 31 c0 xor %eax,%eax + 371d: 8d 76 00 lea 0x0(%esi),%esi + 3720: 83 c0 01 add $0x1,%eax + 3723: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 3727: 89 c1 mov %eax,%ecx + 3729: 75 f5 jne 3720 + ; + } + return n; +} + 372b: 89 c8 mov %ecx,%eax + 372d: 5d pop %ebp + 372e: c3 ret + 372f: 90 nop + for (n = 0; s[n]; n++) { + 3730: 31 c9 xor %ecx,%ecx +} + 3732: 5d pop %ebp + 3733: 89 c8 mov %ecx,%eax + 3735: c3 ret + 3736: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 373d: 8d 76 00 lea 0x0(%esi),%esi + +00003740 : + +void* memset(void *dst, int c, uint n) { + 3740: 55 push %ebp + 3741: 89 e5 mov %esp,%ebp + 3743: 57 push %edi + 3744: 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" : + 3747: 8b 4d 10 mov 0x10(%ebp),%ecx + 374a: 8b 45 0c mov 0xc(%ebp),%eax + 374d: 89 d7 mov %edx,%edi + 374f: fc cld + 3750: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 3752: 8b 7d fc mov -0x4(%ebp),%edi + 3755: 89 d0 mov %edx,%eax + 3757: c9 leave + 3758: c3 ret + 3759: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00003760 : + +char* strchr(const char *s, char c) { + 3760: 55 push %ebp + 3761: 89 e5 mov %esp,%ebp + 3763: 8b 45 08 mov 0x8(%ebp),%eax + 3766: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 376a: 0f b6 10 movzbl (%eax),%edx + 376d: 84 d2 test %dl,%dl + 376f: 75 12 jne 3783 + 3771: eb 1d jmp 3790 + 3773: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 3777: 90 nop + 3778: 0f b6 50 01 movzbl 0x1(%eax),%edx + 377c: 83 c0 01 add $0x1,%eax + 377f: 84 d2 test %dl,%dl + 3781: 74 0d je 3790 + if (*s == c) { + 3783: 38 d1 cmp %dl,%cl + 3785: 75 f1 jne 3778 + return (char*)s; + } + } + return 0; +} + 3787: 5d pop %ebp + 3788: c3 ret + 3789: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 3790: 31 c0 xor %eax,%eax +} + 3792: 5d pop %ebp + 3793: c3 ret + 3794: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 379b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 379f: 90 nop + +000037a0 : + +char* gets(char *buf, int max) { + 37a0: 55 push %ebp + 37a1: 89 e5 mov %esp,%ebp + 37a3: 57 push %edi + 37a4: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 37a5: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 37a8: 53 push %ebx + for (i = 0; i + 1 < max;) { + 37a9: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 37ab: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 37ae: eb 27 jmp 37d7 + cc = read(0, &c, 1); + 37b0: 83 ec 04 sub $0x4,%esp + 37b3: 6a 01 push $0x1 + 37b5: 57 push %edi + 37b6: 6a 00 push $0x0 + 37b8: e8 2e 01 00 00 call 38eb + if (cc < 1) { + 37bd: 83 c4 10 add $0x10,%esp + 37c0: 85 c0 test %eax,%eax + 37c2: 7e 1d jle 37e1 + break; + } + buf[i++] = c; + 37c4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 37c8: 8b 55 08 mov 0x8(%ebp),%edx + 37cb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 37cf: 3c 0a cmp $0xa,%al + 37d1: 74 1d je 37f0 + 37d3: 3c 0d cmp $0xd,%al + 37d5: 74 19 je 37f0 + for (i = 0; i + 1 < max;) { + 37d7: 89 de mov %ebx,%esi + 37d9: 83 c3 01 add $0x1,%ebx + 37dc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 37df: 7c cf jl 37b0 + break; + } + } + buf[i] = '\0'; + 37e1: 8b 45 08 mov 0x8(%ebp),%eax + 37e4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 37e8: 8d 65 f4 lea -0xc(%ebp),%esp + 37eb: 5b pop %ebx + 37ec: 5e pop %esi + 37ed: 5f pop %edi + 37ee: 5d pop %ebp + 37ef: c3 ret + buf[i] = '\0'; + 37f0: 8b 45 08 mov 0x8(%ebp),%eax + 37f3: 89 de mov %ebx,%esi + 37f5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 37f9: 8d 65 f4 lea -0xc(%ebp),%esp + 37fc: 5b pop %ebx + 37fd: 5e pop %esi + 37fe: 5f pop %edi + 37ff: 5d pop %ebp + 3800: c3 ret + 3801: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3808: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 380f: 90 nop + +00003810 : + +int stat(const char *n, struct stat *st) { + 3810: 55 push %ebp + 3811: 89 e5 mov %esp,%ebp + 3813: 56 push %esi + 3814: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 3815: 83 ec 08 sub $0x8,%esp + 3818: 6a 00 push $0x0 + 381a: ff 75 08 push 0x8(%ebp) + 381d: e8 19 01 00 00 call 393b + if (fd < 0) { + 3822: 83 c4 10 add $0x10,%esp + 3825: 85 c0 test %eax,%eax + 3827: 78 27 js 3850 + return -1; + } + r = fstat(fd, st); + 3829: 83 ec 08 sub $0x8,%esp + 382c: ff 75 0c push 0xc(%ebp) + 382f: 89 c3 mov %eax,%ebx + 3831: 50 push %eax + 3832: e8 cc 00 00 00 call 3903 + close(fd); + 3837: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 383a: 89 c6 mov %eax,%esi + close(fd); + 383c: e8 2a 01 00 00 call 396b + return r; + 3841: 83 c4 10 add $0x10,%esp +} + 3844: 8d 65 f8 lea -0x8(%ebp),%esp + 3847: 89 f0 mov %esi,%eax + 3849: 5b pop %ebx + 384a: 5e pop %esi + 384b: 5d pop %ebp + 384c: c3 ret + 384d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 3850: be ff ff ff ff mov $0xffffffff,%esi + 3855: eb ed jmp 3844 + 3857: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 385e: 66 90 xchg %ax,%ax + +00003860 : + +int atoi(const char *s) { + 3860: 55 push %ebp + 3861: 89 e5 mov %esp,%ebp + 3863: 53 push %ebx + 3864: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 3867: 0f be 02 movsbl (%edx),%eax + 386a: 8d 48 d0 lea -0x30(%eax),%ecx + 386d: 80 f9 09 cmp $0x9,%cl + n = 0; + 3870: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 3875: 77 1e ja 3895 + 3877: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 387e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 3880: 83 c2 01 add $0x1,%edx + 3883: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 3886: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 388a: 0f be 02 movsbl (%edx),%eax + 388d: 8d 58 d0 lea -0x30(%eax),%ebx + 3890: 80 fb 09 cmp $0x9,%bl + 3893: 76 eb jbe 3880 + } + return n; +} + 3895: 8b 5d fc mov -0x4(%ebp),%ebx + 3898: 89 c8 mov %ecx,%eax + 389a: c9 leave + 389b: c3 ret + 389c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000038a0 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 38a0: 55 push %ebp + 38a1: 89 e5 mov %esp,%ebp + 38a3: 57 push %edi + 38a4: 8b 45 10 mov 0x10(%ebp),%eax + 38a7: 8b 55 08 mov 0x8(%ebp),%edx + 38aa: 56 push %esi + 38ab: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 38ae: 85 c0 test %eax,%eax + 38b0: 7e 13 jle 38c5 + 38b2: 01 d0 add %edx,%eax + dst = vdst; + 38b4: 89 d7 mov %edx,%edi + 38b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 38bd: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 38c0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 38c1: 39 f8 cmp %edi,%eax + 38c3: 75 fb jne 38c0 + } + return vdst; +} + 38c5: 5e pop %esi + 38c6: 89 d0 mov %edx,%eax + 38c8: 5f pop %edi + 38c9: 5d pop %ebp + 38ca: c3 ret + +000038cb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 38cb: b8 01 00 00 00 mov $0x1,%eax + 38d0: cd 40 int $0x40 + 38d2: c3 ret + +000038d3 : +SYSCALL(exit) + 38d3: b8 02 00 00 00 mov $0x2,%eax + 38d8: cd 40 int $0x40 + 38da: c3 ret + +000038db : +SYSCALL(wait) + 38db: b8 03 00 00 00 mov $0x3,%eax + 38e0: cd 40 int $0x40 + 38e2: c3 ret + +000038e3 : +SYSCALL(pipe) + 38e3: b8 04 00 00 00 mov $0x4,%eax + 38e8: cd 40 int $0x40 + 38ea: c3 ret + +000038eb : +SYSCALL(read) + 38eb: b8 05 00 00 00 mov $0x5,%eax + 38f0: cd 40 int $0x40 + 38f2: c3 ret + +000038f3 : +SYSCALL(kill) + 38f3: b8 06 00 00 00 mov $0x6,%eax + 38f8: cd 40 int $0x40 + 38fa: c3 ret + +000038fb : +SYSCALL(exec) + 38fb: b8 07 00 00 00 mov $0x7,%eax + 3900: cd 40 int $0x40 + 3902: c3 ret + +00003903 : +SYSCALL(fstat) + 3903: b8 08 00 00 00 mov $0x8,%eax + 3908: cd 40 int $0x40 + 390a: c3 ret + +0000390b : +SYSCALL(chdir) + 390b: b8 09 00 00 00 mov $0x9,%eax + 3910: cd 40 int $0x40 + 3912: c3 ret + +00003913 : +SYSCALL(dup) + 3913: b8 0a 00 00 00 mov $0xa,%eax + 3918: cd 40 int $0x40 + 391a: c3 ret + +0000391b : +SYSCALL(getpid) + 391b: b8 0b 00 00 00 mov $0xb,%eax + 3920: cd 40 int $0x40 + 3922: c3 ret + +00003923 : +SYSCALL(sbrk) + 3923: b8 0c 00 00 00 mov $0xc,%eax + 3928: cd 40 int $0x40 + 392a: c3 ret + +0000392b : +SYSCALL(sleep) + 392b: b8 0d 00 00 00 mov $0xd,%eax + 3930: cd 40 int $0x40 + 3932: c3 ret + +00003933 : +SYSCALL(uptime) + 3933: b8 0e 00 00 00 mov $0xe,%eax + 3938: cd 40 int $0x40 + 393a: c3 ret + +0000393b : +SYSCALL(open) + 393b: b8 0f 00 00 00 mov $0xf,%eax + 3940: cd 40 int $0x40 + 3942: c3 ret + +00003943 : +SYSCALL(write) + 3943: b8 10 00 00 00 mov $0x10,%eax + 3948: cd 40 int $0x40 + 394a: c3 ret + +0000394b : +SYSCALL(mknod) + 394b: b8 11 00 00 00 mov $0x11,%eax + 3950: cd 40 int $0x40 + 3952: c3 ret + +00003953 : +SYSCALL(unlink) + 3953: b8 12 00 00 00 mov $0x12,%eax + 3958: cd 40 int $0x40 + 395a: c3 ret + +0000395b : +SYSCALL(link) + 395b: b8 13 00 00 00 mov $0x13,%eax + 3960: cd 40 int $0x40 + 3962: c3 ret + +00003963 : +SYSCALL(mkdir) + 3963: b8 14 00 00 00 mov $0x14,%eax + 3968: cd 40 int $0x40 + 396a: c3 ret + +0000396b : +SYSCALL(close) + 396b: b8 15 00 00 00 mov $0x15,%eax + 3970: cd 40 int $0x40 + 3972: c3 ret + +00003973 : +SYSCALL(getch) + 3973: b8 16 00 00 00 mov $0x16,%eax + 3978: cd 40 int $0x40 + 397a: c3 ret + +0000397b : +SYSCALL(greeting) + 397b: b8 17 00 00 00 mov $0x17,%eax + 3980: cd 40 int $0x40 + 3982: c3 ret + +00003983 : +SYSCALL(shutdown) + 3983: b8 18 00 00 00 mov $0x18,%eax + 3988: cd 40 int $0x40 + 398a: c3 ret + +0000398b : +SYSCALL(screen) + 398b: b8 19 00 00 00 mov $0x19,%eax + 3990: cd 40 int $0x40 + 3992: c3 ret + +00003993 : +SYSCALL(cls) + 3993: b8 1a 00 00 00 mov $0x1a,%eax + 3998: cd 40 int $0x40 + 399a: c3 ret + 399b: 66 90 xchg %ax,%ax + 399d: 66 90 xchg %ax,%ax + 399f: 90 nop + +000039a0 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 39a0: 55 push %ebp + 39a1: 89 e5 mov %esp,%ebp + 39a3: 57 push %edi + 39a4: 56 push %esi + 39a5: 53 push %ebx + 39a6: 83 ec 3c sub $0x3c,%esp + 39a9: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 39ac: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 39ae: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 39b1: 85 d2 test %edx,%edx + 39b3: 0f 89 7f 00 00 00 jns 3a38 + 39b9: f6 45 08 01 testb $0x1,0x8(%ebp) + 39bd: 74 79 je 3a38 + neg = 1; + 39bf: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 39c6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 39c8: 31 db xor %ebx,%ebx + 39ca: 8d 75 d7 lea -0x29(%ebp),%esi + 39cd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 39d0: 89 c8 mov %ecx,%eax + 39d2: 31 d2 xor %edx,%edx + 39d4: 89 cf mov %ecx,%edi + 39d6: f7 75 c4 divl -0x3c(%ebp) + 39d9: 0f b6 92 70 55 00 00 movzbl 0x5570(%edx),%edx + 39e0: 89 45 c0 mov %eax,-0x40(%ebp) + 39e3: 89 d8 mov %ebx,%eax + 39e5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 39e8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 39eb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 39ee: 39 7d c4 cmp %edi,-0x3c(%ebp) + 39f1: 76 dd jbe 39d0 + if (neg) { + 39f3: 8b 4d bc mov -0x44(%ebp),%ecx + 39f6: 85 c9 test %ecx,%ecx + 39f8: 74 0c je 3a06 + buf[i++] = '-'; + 39fa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 39ff: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3a01: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3a06: 8b 7d b8 mov -0x48(%ebp),%edi + 3a09: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3a0d: eb 07 jmp 3a16 + 3a0f: 90 nop + putc(fd, buf[i]); + 3a10: 0f b6 13 movzbl (%ebx),%edx + 3a13: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 3a16: 83 ec 04 sub $0x4,%esp + 3a19: 88 55 d7 mov %dl,-0x29(%ebp) + 3a1c: 6a 01 push $0x1 + 3a1e: 56 push %esi + 3a1f: 57 push %edi + 3a20: e8 1e ff ff ff call 3943 + while (--i >= 0) { + 3a25: 83 c4 10 add $0x10,%esp + 3a28: 39 de cmp %ebx,%esi + 3a2a: 75 e4 jne 3a10 + } +} + 3a2c: 8d 65 f4 lea -0xc(%ebp),%esp + 3a2f: 5b pop %ebx + 3a30: 5e pop %esi + 3a31: 5f pop %edi + 3a32: 5d pop %ebp + 3a33: c3 ret + 3a34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 3a38: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 3a3f: eb 87 jmp 39c8 + 3a41: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3a48: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3a4f: 90 nop + +00003a50 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 3a50: 55 push %ebp + 3a51: 89 e5 mov %esp,%ebp + 3a53: 57 push %edi + 3a54: 56 push %esi + 3a55: 53 push %ebx + 3a56: 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++) { + 3a59: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 3a5c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 3a5f: 0f b6 13 movzbl (%ebx),%edx + 3a62: 84 d2 test %dl,%dl + 3a64: 74 6a je 3ad0 + ap = (uint*)(void*)&fmt + 1; + 3a66: 8d 45 10 lea 0x10(%ebp),%eax + 3a69: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 3a6c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 3a6f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 3a71: 89 45 d0 mov %eax,-0x30(%ebp) + 3a74: eb 36 jmp 3aac + 3a76: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3a7d: 8d 76 00 lea 0x0(%esi),%esi + 3a80: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 3a83: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 3a88: 83 f8 25 cmp $0x25,%eax + 3a8b: 74 15 je 3aa2 + write(fd, &c, 1); + 3a8d: 83 ec 04 sub $0x4,%esp + 3a90: 88 55 e7 mov %dl,-0x19(%ebp) + 3a93: 6a 01 push $0x1 + 3a95: 57 push %edi + 3a96: 56 push %esi + 3a97: e8 a7 fe ff ff call 3943 + 3a9c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 3a9f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 3aa2: 0f b6 13 movzbl (%ebx),%edx + 3aa5: 83 c3 01 add $0x1,%ebx + 3aa8: 84 d2 test %dl,%dl + 3aaa: 74 24 je 3ad0 + c = fmt[i] & 0xff; + 3aac: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 3aaf: 85 c9 test %ecx,%ecx + 3ab1: 74 cd je 3a80 + } + } + else if (state == '%') { + 3ab3: 83 f9 25 cmp $0x25,%ecx + 3ab6: 75 ea jne 3aa2 + if (c == 'd') { + 3ab8: 83 f8 25 cmp $0x25,%eax + 3abb: 0f 84 07 01 00 00 je 3bc8 + 3ac1: 83 e8 63 sub $0x63,%eax + 3ac4: 83 f8 15 cmp $0x15,%eax + 3ac7: 77 17 ja 3ae0 + 3ac9: ff 24 85 18 55 00 00 jmp *0x5518(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 3ad0: 8d 65 f4 lea -0xc(%ebp),%esp + 3ad3: 5b pop %ebx + 3ad4: 5e pop %esi + 3ad5: 5f pop %edi + 3ad6: 5d pop %ebp + 3ad7: c3 ret + 3ad8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3adf: 90 nop + write(fd, &c, 1); + 3ae0: 83 ec 04 sub $0x4,%esp + 3ae3: 88 55 d4 mov %dl,-0x2c(%ebp) + 3ae6: 6a 01 push $0x1 + 3ae8: 57 push %edi + 3ae9: 56 push %esi + 3aea: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 3aee: e8 50 fe ff ff call 3943 + putc(fd, c); + 3af3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 3af7: 83 c4 0c add $0xc,%esp + 3afa: 88 55 e7 mov %dl,-0x19(%ebp) + 3afd: 6a 01 push $0x1 + 3aff: 57 push %edi + 3b00: 56 push %esi + 3b01: e8 3d fe ff ff call 3943 + putc(fd, c); + 3b06: 83 c4 10 add $0x10,%esp + state = 0; + 3b09: 31 c9 xor %ecx,%ecx + 3b0b: eb 95 jmp 3aa2 + 3b0d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 3b10: 83 ec 0c sub $0xc,%esp + 3b13: b9 10 00 00 00 mov $0x10,%ecx + 3b18: 6a 00 push $0x0 + 3b1a: 8b 45 d0 mov -0x30(%ebp),%eax + 3b1d: 8b 10 mov (%eax),%edx + 3b1f: 89 f0 mov %esi,%eax + 3b21: e8 7a fe ff ff call 39a0 + ap++; + 3b26: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 3b2a: 83 c4 10 add $0x10,%esp + state = 0; + 3b2d: 31 c9 xor %ecx,%ecx + 3b2f: e9 6e ff ff ff jmp 3aa2 + 3b34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 3b38: 8b 45 d0 mov -0x30(%ebp),%eax + 3b3b: 8b 10 mov (%eax),%edx + ap++; + 3b3d: 83 c0 04 add $0x4,%eax + 3b40: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 3b43: 85 d2 test %edx,%edx + 3b45: 0f 84 8d 00 00 00 je 3bd8 + while (*s != 0) { + 3b4b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 3b4e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 3b50: 84 c0 test %al,%al + 3b52: 0f 84 4a ff ff ff je 3aa2 + 3b58: 89 5d d4 mov %ebx,-0x2c(%ebp) + 3b5b: 89 d3 mov %edx,%ebx + 3b5d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 3b60: 83 ec 04 sub $0x4,%esp + s++; + 3b63: 83 c3 01 add $0x1,%ebx + 3b66: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 3b69: 6a 01 push $0x1 + 3b6b: 57 push %edi + 3b6c: 56 push %esi + 3b6d: e8 d1 fd ff ff call 3943 + while (*s != 0) { + 3b72: 0f b6 03 movzbl (%ebx),%eax + 3b75: 83 c4 10 add $0x10,%esp + 3b78: 84 c0 test %al,%al + 3b7a: 75 e4 jne 3b60 + state = 0; + 3b7c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 3b7f: 31 c9 xor %ecx,%ecx + 3b81: e9 1c ff ff ff jmp 3aa2 + 3b86: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3b8d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 3b90: 83 ec 0c sub $0xc,%esp + 3b93: b9 0a 00 00 00 mov $0xa,%ecx + 3b98: 6a 01 push $0x1 + 3b9a: e9 7b ff ff ff jmp 3b1a + 3b9f: 90 nop + putc(fd, *ap); + 3ba0: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 3ba3: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 3ba6: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 3ba8: 6a 01 push $0x1 + 3baa: 57 push %edi + 3bab: 56 push %esi + putc(fd, *ap); + 3bac: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 3baf: e8 8f fd ff ff call 3943 + ap++; + 3bb4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 3bb8: 83 c4 10 add $0x10,%esp + state = 0; + 3bbb: 31 c9 xor %ecx,%ecx + 3bbd: e9 e0 fe ff ff jmp 3aa2 + 3bc2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 3bc8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 3bcb: 83 ec 04 sub $0x4,%esp + 3bce: e9 2a ff ff ff jmp 3afd + 3bd3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 3bd7: 90 nop + s = "(null)"; + 3bd8: ba 0e 55 00 00 mov $0x550e,%edx + while (*s != 0) { + 3bdd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 3be0: b8 28 00 00 00 mov $0x28,%eax + 3be5: 89 d3 mov %edx,%ebx + 3be7: e9 74 ff ff ff jmp 3b60 + 3bec: 66 90 xchg %ax,%ax + 3bee: 66 90 xchg %ax,%ax + +00003bf0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 3bf0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 3bf1: a1 20 a6 00 00 mov 0xa620,%eax +void free(void *ap) { + 3bf6: 89 e5 mov %esp,%ebp + 3bf8: 57 push %edi + 3bf9: 56 push %esi + 3bfa: 53 push %ebx + 3bfb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 3bfe: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 3c01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3c08: 89 c2 mov %eax,%edx + 3c0a: 8b 00 mov (%eax),%eax + 3c0c: 39 ca cmp %ecx,%edx + 3c0e: 73 30 jae 3c40 + 3c10: 39 c1 cmp %eax,%ecx + 3c12: 72 04 jb 3c18 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 3c14: 39 c2 cmp %eax,%edx + 3c16: 72 f0 jb 3c08 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 3c18: 8b 73 fc mov -0x4(%ebx),%esi + 3c1b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 3c1e: 39 f8 cmp %edi,%eax + 3c20: 74 30 je 3c52 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 3c22: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 3c25: 8b 42 04 mov 0x4(%edx),%eax + 3c28: 8d 34 c2 lea (%edx,%eax,8),%esi + 3c2b: 39 f1 cmp %esi,%ecx + 3c2d: 74 3a je 3c69 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 3c2f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 3c31: 5b pop %ebx + freep = p; + 3c32: 89 15 20 a6 00 00 mov %edx,0xa620 +} + 3c38: 5e pop %esi + 3c39: 5f pop %edi + 3c3a: 5d pop %ebp + 3c3b: c3 ret + 3c3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 3c40: 39 c2 cmp %eax,%edx + 3c42: 72 c4 jb 3c08 + 3c44: 39 c1 cmp %eax,%ecx + 3c46: 73 c0 jae 3c08 + if (bp + bp->s.size == p->s.ptr) { + 3c48: 8b 73 fc mov -0x4(%ebx),%esi + 3c4b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 3c4e: 39 f8 cmp %edi,%eax + 3c50: 75 d0 jne 3c22 + bp->s.size += p->s.ptr->s.size; + 3c52: 03 70 04 add 0x4(%eax),%esi + 3c55: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 3c58: 8b 02 mov (%edx),%eax + 3c5a: 8b 00 mov (%eax),%eax + 3c5c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 3c5f: 8b 42 04 mov 0x4(%edx),%eax + 3c62: 8d 34 c2 lea (%edx,%eax,8),%esi + 3c65: 39 f1 cmp %esi,%ecx + 3c67: 75 c6 jne 3c2f + p->s.size += bp->s.size; + 3c69: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 3c6c: 89 15 20 a6 00 00 mov %edx,0xa620 + p->s.size += bp->s.size; + 3c72: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 3c75: 8b 4b f8 mov -0x8(%ebx),%ecx + 3c78: 89 0a mov %ecx,(%edx) +} + 3c7a: 5b pop %ebx + 3c7b: 5e pop %esi + 3c7c: 5f pop %edi + 3c7d: 5d pop %ebp + 3c7e: c3 ret + 3c7f: 90 nop + +00003c80 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 3c80: 55 push %ebp + 3c81: 89 e5 mov %esp,%ebp + 3c83: 57 push %edi + 3c84: 56 push %esi + 3c85: 53 push %ebx + 3c86: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 3c89: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 3c8c: 8b 3d 20 a6 00 00 mov 0xa620,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 3c92: 8d 70 07 lea 0x7(%eax),%esi + 3c95: c1 ee 03 shr $0x3,%esi + 3c98: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 3c9b: 85 ff test %edi,%edi + 3c9d: 0f 84 9d 00 00 00 je 3d40 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 3ca3: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 3ca5: 8b 4a 04 mov 0x4(%edx),%ecx + 3ca8: 39 f1 cmp %esi,%ecx + 3caa: 73 6a jae 3d16 + 3cac: bb 00 10 00 00 mov $0x1000,%ebx + 3cb1: 39 de cmp %ebx,%esi + 3cb3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 3cb6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 3cbd: 89 45 e4 mov %eax,-0x1c(%ebp) + 3cc0: eb 17 jmp 3cd9 + 3cc2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 3cc8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 3cca: 8b 48 04 mov 0x4(%eax),%ecx + 3ccd: 39 f1 cmp %esi,%ecx + 3ccf: 73 4f jae 3d20 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 3cd1: 8b 3d 20 a6 00 00 mov 0xa620,%edi + 3cd7: 89 c2 mov %eax,%edx + 3cd9: 39 d7 cmp %edx,%edi + 3cdb: 75 eb jne 3cc8 + p = sbrk(nu * sizeof(Header)); + 3cdd: 83 ec 0c sub $0xc,%esp + 3ce0: ff 75 e4 push -0x1c(%ebp) + 3ce3: e8 3b fc ff ff call 3923 + if (p == (char*)-1) { + 3ce8: 83 c4 10 add $0x10,%esp + 3ceb: 83 f8 ff cmp $0xffffffff,%eax + 3cee: 74 1c je 3d0c + hp->s.size = nu; + 3cf0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 3cf3: 83 ec 0c sub $0xc,%esp + 3cf6: 83 c0 08 add $0x8,%eax + 3cf9: 50 push %eax + 3cfa: e8 f1 fe ff ff call 3bf0 + return freep; + 3cff: 8b 15 20 a6 00 00 mov 0xa620,%edx + if ((p = morecore(nunits)) == 0) { + 3d05: 83 c4 10 add $0x10,%esp + 3d08: 85 d2 test %edx,%edx + 3d0a: 75 bc jne 3cc8 + return 0; + } + } + } +} + 3d0c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 3d0f: 31 c0 xor %eax,%eax +} + 3d11: 5b pop %ebx + 3d12: 5e pop %esi + 3d13: 5f pop %edi + 3d14: 5d pop %ebp + 3d15: c3 ret + if (p->s.size >= nunits) { + 3d16: 89 d0 mov %edx,%eax + 3d18: 89 fa mov %edi,%edx + 3d1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 3d20: 39 ce cmp %ecx,%esi + 3d22: 74 4c je 3d70 + p->s.size -= nunits; + 3d24: 29 f1 sub %esi,%ecx + 3d26: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 3d29: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 3d2c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 3d2f: 89 15 20 a6 00 00 mov %edx,0xa620 +} + 3d35: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 3d38: 83 c0 08 add $0x8,%eax +} + 3d3b: 5b pop %ebx + 3d3c: 5e pop %esi + 3d3d: 5f pop %edi + 3d3e: 5d pop %ebp + 3d3f: c3 ret + base.s.ptr = freep = prevp = &base; + 3d40: c7 05 20 a6 00 00 24 movl $0xa624,0xa620 + 3d47: a6 00 00 + base.s.size = 0; + 3d4a: bf 24 a6 00 00 mov $0xa624,%edi + base.s.ptr = freep = prevp = &base; + 3d4f: c7 05 24 a6 00 00 24 movl $0xa624,0xa624 + 3d56: a6 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 3d59: 89 fa mov %edi,%edx + base.s.size = 0; + 3d5b: c7 05 28 a6 00 00 00 movl $0x0,0xa628 + 3d62: 00 00 00 + if (p->s.size >= nunits) { + 3d65: e9 42 ff ff ff jmp 3cac + 3d6a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 3d70: 8b 08 mov (%eax),%ecx + 3d72: 89 0a mov %ecx,(%edx) + 3d74: eb b9 jmp 3d2f diff --git a/usertests.d b/usertests.d new file mode 100644 index 0000000..a4933d3 --- /dev/null +++ b/usertests.d @@ -0,0 +1,2 @@ +usertests.o: usertests.c /usr/include/stdc-predef.h param.h types.h \ + stat.h user.h fs.h fcntl.h syscall.h traps.h memlayout.h diff --git a/usertests.o b/usertests.o new file mode 100644 index 0000000..7162c9b Binary files /dev/null and b/usertests.o differ diff --git a/usertests.sym b/usertests.sym new file mode 100644 index 0000000..e9170d6 --- /dev/null +++ b/usertests.sym @@ -0,0 +1,95 @@ +00000000 usertests.c +0000a5a0 args.0 +00000000 ulib.c +00000000 printf.c +000039a0 printint +00005570 digits.0 +00000000 umalloc.c +0000a620 freep +0000a624 base +00003680 strcpy +00000d10 exitwait +00003a50 printf +00005e68 stdout +000032b0 bigargtest +0000397b greeting +000038a0 memmove +00000300 openiputtest +0000394b mknod +000037a0 gets +0000391b getpid +00000a20 pipe1 +00002b70 iref +0000398b screen +00003c80 malloc +0000392b sleep +00000200 exitiputtest +000033b0 fsfull +00001bf0 bigdir +00002c90 forktest +00000670 writetest1 +00002400 bigwrite +00000e60 sharedfd +00005e64 randstate +000038e3 pipe +00005e80 uninit +00003973 getch +00002970 dirfile +00003943 write +00003240 bsstest +00005e6c echoargv +00003903 fstat +000038f3 kill +00003190 validatetest +000027f0 rmdot +0000390b chdir +000009d0 exectest +000038fb exec +000038db wait +00003660 rand +000038eb read +00000bb0 preempt +00003953 unlink +000035f0 argptest +00000d90 mem +000038cb fork +00003923 sbrk +00003933 uptime +00005e80 __bss_start +00003740 memset +00000840 createtest +00000000 main +00001220 createdelete +000036b0 strcmp +00003983 shutdown +00000490 writetest +00003913 dup +00002d40 sbrktest +00000400 opentest +00001d20 subdir +00003580 uio +000015d0 linktest +000085a0 buf +000008f0 dirtest +00000120 iputtest +00003810 stat +000024e0 bigfile +00005e80 _edata +0000a62c _end +00001440 unlinkread +0000395b link +000038d3 exit +00003860 atoi +00001ae0 linkunlink +00003993 cls +00008590 name +00003710 strlen +0000393b open +00003760 strchr +000017e0 concreate +000026b0 fourteen +00003180 validateint +00001020 fourfiles +00003963 mkdir +0000396b close +00003bf0 free diff --git a/usys.S b/usys.S new file mode 100644 index 0000000..aad2633 --- /dev/null +++ b/usys.S @@ -0,0 +1,39 @@ +# Generated by gensyscalls.pl. Do not edit. +# To change syscall numbers or add new syscalls, edit gensyscalls.pl + +#include "syscall.h" +#include "traps.h" + +#define SYSCALL(name) \ +.globl name; \ +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) +SYSCALL(exit) +SYSCALL(wait) +SYSCALL(pipe) +SYSCALL(read) +SYSCALL(kill) +SYSCALL(exec) +SYSCALL(fstat) +SYSCALL(chdir) +SYSCALL(dup) +SYSCALL(getpid) +SYSCALL(sbrk) +SYSCALL(sleep) +SYSCALL(uptime) +SYSCALL(open) +SYSCALL(write) +SYSCALL(mknod) +SYSCALL(unlink) +SYSCALL(link) +SYSCALL(mkdir) +SYSCALL(close) +SYSCALL(getch) +SYSCALL(greeting) +SYSCALL(shutdown) +SYSCALL(screen) +SYSCALL(cls) diff --git a/usys.o b/usys.o new file mode 100644 index 0000000..2d03dbd Binary files /dev/null and b/usys.o differ diff --git a/vectors.S b/vectors.S new file mode 100644 index 0000000..9e4041a --- /dev/null +++ b/vectors.S @@ -0,0 +1,1537 @@ +# generated by vectors.pl - do not edit +# handlers +.globl alltraps +.globl vector0 +vector0: + pushl $0 + pushl $0 + jmp alltraps +.globl vector1 +vector1: + pushl $0 + pushl $1 + jmp alltraps +.globl vector2 +vector2: + pushl $0 + pushl $2 + jmp alltraps +.globl vector3 +vector3: + pushl $0 + pushl $3 + jmp alltraps +.globl vector4 +vector4: + pushl $0 + pushl $4 + jmp alltraps +.globl vector5 +vector5: + pushl $0 + pushl $5 + jmp alltraps +.globl vector6 +vector6: + pushl $0 + pushl $6 + jmp alltraps +.globl vector7 +vector7: + pushl $0 + pushl $7 + jmp alltraps +.globl vector8 +vector8: + pushl $8 + jmp alltraps +.globl vector9 +vector9: + pushl $0 + pushl $9 + jmp alltraps +.globl vector10 +vector10: + pushl $10 + jmp alltraps +.globl vector11 +vector11: + pushl $11 + jmp alltraps +.globl vector12 +vector12: + pushl $12 + jmp alltraps +.globl vector13 +vector13: + pushl $13 + jmp alltraps +.globl vector14 +vector14: + pushl $14 + jmp alltraps +.globl vector15 +vector15: + pushl $0 + pushl $15 + jmp alltraps +.globl vector16 +vector16: + pushl $0 + pushl $16 + jmp alltraps +.globl vector17 +vector17: + pushl $17 + jmp alltraps +.globl vector18 +vector18: + pushl $0 + pushl $18 + jmp alltraps +.globl vector19 +vector19: + pushl $0 + pushl $19 + jmp alltraps +.globl vector20 +vector20: + pushl $0 + pushl $20 + jmp alltraps +.globl vector21 +vector21: + pushl $0 + pushl $21 + jmp alltraps +.globl vector22 +vector22: + pushl $0 + pushl $22 + jmp alltraps +.globl vector23 +vector23: + pushl $0 + pushl $23 + jmp alltraps +.globl vector24 +vector24: + pushl $0 + pushl $24 + jmp alltraps +.globl vector25 +vector25: + pushl $0 + pushl $25 + jmp alltraps +.globl vector26 +vector26: + pushl $0 + pushl $26 + jmp alltraps +.globl vector27 +vector27: + pushl $0 + pushl $27 + jmp alltraps +.globl vector28 +vector28: + pushl $0 + pushl $28 + jmp alltraps +.globl vector29 +vector29: + pushl $0 + pushl $29 + jmp alltraps +.globl vector30 +vector30: + pushl $0 + pushl $30 + jmp alltraps +.globl vector31 +vector31: + pushl $0 + pushl $31 + jmp alltraps +.globl vector32 +vector32: + pushl $0 + pushl $32 + jmp alltraps +.globl vector33 +vector33: + pushl $0 + pushl $33 + jmp alltraps +.globl vector34 +vector34: + pushl $0 + pushl $34 + jmp alltraps +.globl vector35 +vector35: + pushl $0 + pushl $35 + jmp alltraps +.globl vector36 +vector36: + pushl $0 + pushl $36 + jmp alltraps +.globl vector37 +vector37: + pushl $0 + pushl $37 + jmp alltraps +.globl vector38 +vector38: + pushl $0 + pushl $38 + jmp alltraps +.globl vector39 +vector39: + pushl $0 + pushl $39 + jmp alltraps +.globl vector40 +vector40: + pushl $0 + pushl $40 + jmp alltraps +.globl vector41 +vector41: + pushl $0 + pushl $41 + jmp alltraps +.globl vector42 +vector42: + pushl $0 + pushl $42 + jmp alltraps +.globl vector43 +vector43: + pushl $0 + pushl $43 + jmp alltraps +.globl vector44 +vector44: + pushl $0 + pushl $44 + jmp alltraps +.globl vector45 +vector45: + pushl $0 + pushl $45 + jmp alltraps +.globl vector46 +vector46: + pushl $0 + pushl $46 + jmp alltraps +.globl vector47 +vector47: + pushl $0 + pushl $47 + jmp alltraps +.globl vector48 +vector48: + pushl $0 + pushl $48 + jmp alltraps +.globl vector49 +vector49: + pushl $0 + pushl $49 + jmp alltraps +.globl vector50 +vector50: + pushl $0 + pushl $50 + jmp alltraps +.globl vector51 +vector51: + pushl $0 + pushl $51 + jmp alltraps +.globl vector52 +vector52: + pushl $0 + pushl $52 + jmp alltraps +.globl vector53 +vector53: + pushl $0 + pushl $53 + jmp alltraps +.globl vector54 +vector54: + pushl $0 + pushl $54 + jmp alltraps +.globl vector55 +vector55: + pushl $0 + pushl $55 + jmp alltraps +.globl vector56 +vector56: + pushl $0 + pushl $56 + jmp alltraps +.globl vector57 +vector57: + pushl $0 + pushl $57 + jmp alltraps +.globl vector58 +vector58: + pushl $0 + pushl $58 + jmp alltraps +.globl vector59 +vector59: + pushl $0 + pushl $59 + jmp alltraps +.globl vector60 +vector60: + pushl $0 + pushl $60 + jmp alltraps +.globl vector61 +vector61: + pushl $0 + pushl $61 + jmp alltraps +.globl vector62 +vector62: + pushl $0 + pushl $62 + jmp alltraps +.globl vector63 +vector63: + pushl $0 + pushl $63 + jmp alltraps +.globl vector64 +vector64: + pushl $0 + pushl $64 + jmp alltraps +.globl vector65 +vector65: + pushl $0 + pushl $65 + jmp alltraps +.globl vector66 +vector66: + pushl $0 + pushl $66 + jmp alltraps +.globl vector67 +vector67: + pushl $0 + pushl $67 + jmp alltraps +.globl vector68 +vector68: + pushl $0 + pushl $68 + jmp alltraps +.globl vector69 +vector69: + pushl $0 + pushl $69 + jmp alltraps +.globl vector70 +vector70: + pushl $0 + pushl $70 + jmp alltraps +.globl vector71 +vector71: + pushl $0 + pushl $71 + jmp alltraps +.globl vector72 +vector72: + pushl $0 + pushl $72 + jmp alltraps +.globl vector73 +vector73: + pushl $0 + pushl $73 + jmp alltraps +.globl vector74 +vector74: + pushl $0 + pushl $74 + jmp alltraps +.globl vector75 +vector75: + pushl $0 + pushl $75 + jmp alltraps +.globl vector76 +vector76: + pushl $0 + pushl $76 + jmp alltraps +.globl vector77 +vector77: + pushl $0 + pushl $77 + jmp alltraps +.globl vector78 +vector78: + pushl $0 + pushl $78 + jmp alltraps +.globl vector79 +vector79: + pushl $0 + pushl $79 + jmp alltraps +.globl vector80 +vector80: + pushl $0 + pushl $80 + jmp alltraps +.globl vector81 +vector81: + pushl $0 + pushl $81 + jmp alltraps +.globl vector82 +vector82: + pushl $0 + pushl $82 + jmp alltraps +.globl vector83 +vector83: + pushl $0 + pushl $83 + jmp alltraps +.globl vector84 +vector84: + pushl $0 + pushl $84 + jmp alltraps +.globl vector85 +vector85: + pushl $0 + pushl $85 + jmp alltraps +.globl vector86 +vector86: + pushl $0 + pushl $86 + jmp alltraps +.globl vector87 +vector87: + pushl $0 + pushl $87 + jmp alltraps +.globl vector88 +vector88: + pushl $0 + pushl $88 + jmp alltraps +.globl vector89 +vector89: + pushl $0 + pushl $89 + jmp alltraps +.globl vector90 +vector90: + pushl $0 + pushl $90 + jmp alltraps +.globl vector91 +vector91: + pushl $0 + pushl $91 + jmp alltraps +.globl vector92 +vector92: + pushl $0 + pushl $92 + jmp alltraps +.globl vector93 +vector93: + pushl $0 + pushl $93 + jmp alltraps +.globl vector94 +vector94: + pushl $0 + pushl $94 + jmp alltraps +.globl vector95 +vector95: + pushl $0 + pushl $95 + jmp alltraps +.globl vector96 +vector96: + pushl $0 + pushl $96 + jmp alltraps +.globl vector97 +vector97: + pushl $0 + pushl $97 + jmp alltraps +.globl vector98 +vector98: + pushl $0 + pushl $98 + jmp alltraps +.globl vector99 +vector99: + pushl $0 + pushl $99 + jmp alltraps +.globl vector100 +vector100: + pushl $0 + pushl $100 + jmp alltraps +.globl vector101 +vector101: + pushl $0 + pushl $101 + jmp alltraps +.globl vector102 +vector102: + pushl $0 + pushl $102 + jmp alltraps +.globl vector103 +vector103: + pushl $0 + pushl $103 + jmp alltraps +.globl vector104 +vector104: + pushl $0 + pushl $104 + jmp alltraps +.globl vector105 +vector105: + pushl $0 + pushl $105 + jmp alltraps +.globl vector106 +vector106: + pushl $0 + pushl $106 + jmp alltraps +.globl vector107 +vector107: + pushl $0 + pushl $107 + jmp alltraps +.globl vector108 +vector108: + pushl $0 + pushl $108 + jmp alltraps +.globl vector109 +vector109: + pushl $0 + pushl $109 + jmp alltraps +.globl vector110 +vector110: + pushl $0 + pushl $110 + jmp alltraps +.globl vector111 +vector111: + pushl $0 + pushl $111 + jmp alltraps +.globl vector112 +vector112: + pushl $0 + pushl $112 + jmp alltraps +.globl vector113 +vector113: + pushl $0 + pushl $113 + jmp alltraps +.globl vector114 +vector114: + pushl $0 + pushl $114 + jmp alltraps +.globl vector115 +vector115: + pushl $0 + pushl $115 + jmp alltraps +.globl vector116 +vector116: + pushl $0 + pushl $116 + jmp alltraps +.globl vector117 +vector117: + pushl $0 + pushl $117 + jmp alltraps +.globl vector118 +vector118: + pushl $0 + pushl $118 + jmp alltraps +.globl vector119 +vector119: + pushl $0 + pushl $119 + jmp alltraps +.globl vector120 +vector120: + pushl $0 + pushl $120 + jmp alltraps +.globl vector121 +vector121: + pushl $0 + pushl $121 + jmp alltraps +.globl vector122 +vector122: + pushl $0 + pushl $122 + jmp alltraps +.globl vector123 +vector123: + pushl $0 + pushl $123 + jmp alltraps +.globl vector124 +vector124: + pushl $0 + pushl $124 + jmp alltraps +.globl vector125 +vector125: + pushl $0 + pushl $125 + jmp alltraps +.globl vector126 +vector126: + pushl $0 + pushl $126 + jmp alltraps +.globl vector127 +vector127: + pushl $0 + pushl $127 + jmp alltraps +.globl vector128 +vector128: + pushl $0 + pushl $128 + jmp alltraps +.globl vector129 +vector129: + pushl $0 + pushl $129 + jmp alltraps +.globl vector130 +vector130: + pushl $0 + pushl $130 + jmp alltraps +.globl vector131 +vector131: + pushl $0 + pushl $131 + jmp alltraps +.globl vector132 +vector132: + pushl $0 + pushl $132 + jmp alltraps +.globl vector133 +vector133: + pushl $0 + pushl $133 + jmp alltraps +.globl vector134 +vector134: + pushl $0 + pushl $134 + jmp alltraps +.globl vector135 +vector135: + pushl $0 + pushl $135 + jmp alltraps +.globl vector136 +vector136: + pushl $0 + pushl $136 + jmp alltraps +.globl vector137 +vector137: + pushl $0 + pushl $137 + jmp alltraps +.globl vector138 +vector138: + pushl $0 + pushl $138 + jmp alltraps +.globl vector139 +vector139: + pushl $0 + pushl $139 + jmp alltraps +.globl vector140 +vector140: + pushl $0 + pushl $140 + jmp alltraps +.globl vector141 +vector141: + pushl $0 + pushl $141 + jmp alltraps +.globl vector142 +vector142: + pushl $0 + pushl $142 + jmp alltraps +.globl vector143 +vector143: + pushl $0 + pushl $143 + jmp alltraps +.globl vector144 +vector144: + pushl $0 + pushl $144 + jmp alltraps +.globl vector145 +vector145: + pushl $0 + pushl $145 + jmp alltraps +.globl vector146 +vector146: + pushl $0 + pushl $146 + jmp alltraps +.globl vector147 +vector147: + pushl $0 + pushl $147 + jmp alltraps +.globl vector148 +vector148: + pushl $0 + pushl $148 + jmp alltraps +.globl vector149 +vector149: + pushl $0 + pushl $149 + jmp alltraps +.globl vector150 +vector150: + pushl $0 + pushl $150 + jmp alltraps +.globl vector151 +vector151: + pushl $0 + pushl $151 + jmp alltraps +.globl vector152 +vector152: + pushl $0 + pushl $152 + jmp alltraps +.globl vector153 +vector153: + pushl $0 + pushl $153 + jmp alltraps +.globl vector154 +vector154: + pushl $0 + pushl $154 + jmp alltraps +.globl vector155 +vector155: + pushl $0 + pushl $155 + jmp alltraps +.globl vector156 +vector156: + pushl $0 + pushl $156 + jmp alltraps +.globl vector157 +vector157: + pushl $0 + pushl $157 + jmp alltraps +.globl vector158 +vector158: + pushl $0 + pushl $158 + jmp alltraps +.globl vector159 +vector159: + pushl $0 + pushl $159 + jmp alltraps +.globl vector160 +vector160: + pushl $0 + pushl $160 + jmp alltraps +.globl vector161 +vector161: + pushl $0 + pushl $161 + jmp alltraps +.globl vector162 +vector162: + pushl $0 + pushl $162 + jmp alltraps +.globl vector163 +vector163: + pushl $0 + pushl $163 + jmp alltraps +.globl vector164 +vector164: + pushl $0 + pushl $164 + jmp alltraps +.globl vector165 +vector165: + pushl $0 + pushl $165 + jmp alltraps +.globl vector166 +vector166: + pushl $0 + pushl $166 + jmp alltraps +.globl vector167 +vector167: + pushl $0 + pushl $167 + jmp alltraps +.globl vector168 +vector168: + pushl $0 + pushl $168 + jmp alltraps +.globl vector169 +vector169: + pushl $0 + pushl $169 + jmp alltraps +.globl vector170 +vector170: + pushl $0 + pushl $170 + jmp alltraps +.globl vector171 +vector171: + pushl $0 + pushl $171 + jmp alltraps +.globl vector172 +vector172: + pushl $0 + pushl $172 + jmp alltraps +.globl vector173 +vector173: + pushl $0 + pushl $173 + jmp alltraps +.globl vector174 +vector174: + pushl $0 + pushl $174 + jmp alltraps +.globl vector175 +vector175: + pushl $0 + pushl $175 + jmp alltraps +.globl vector176 +vector176: + pushl $0 + pushl $176 + jmp alltraps +.globl vector177 +vector177: + pushl $0 + pushl $177 + jmp alltraps +.globl vector178 +vector178: + pushl $0 + pushl $178 + jmp alltraps +.globl vector179 +vector179: + pushl $0 + pushl $179 + jmp alltraps +.globl vector180 +vector180: + pushl $0 + pushl $180 + jmp alltraps +.globl vector181 +vector181: + pushl $0 + pushl $181 + jmp alltraps +.globl vector182 +vector182: + pushl $0 + pushl $182 + jmp alltraps +.globl vector183 +vector183: + pushl $0 + pushl $183 + jmp alltraps +.globl vector184 +vector184: + pushl $0 + pushl $184 + jmp alltraps +.globl vector185 +vector185: + pushl $0 + pushl $185 + jmp alltraps +.globl vector186 +vector186: + pushl $0 + pushl $186 + jmp alltraps +.globl vector187 +vector187: + pushl $0 + pushl $187 + jmp alltraps +.globl vector188 +vector188: + pushl $0 + pushl $188 + jmp alltraps +.globl vector189 +vector189: + pushl $0 + pushl $189 + jmp alltraps +.globl vector190 +vector190: + pushl $0 + pushl $190 + jmp alltraps +.globl vector191 +vector191: + pushl $0 + pushl $191 + jmp alltraps +.globl vector192 +vector192: + pushl $0 + pushl $192 + jmp alltraps +.globl vector193 +vector193: + pushl $0 + pushl $193 + jmp alltraps +.globl vector194 +vector194: + pushl $0 + pushl $194 + jmp alltraps +.globl vector195 +vector195: + pushl $0 + pushl $195 + jmp alltraps +.globl vector196 +vector196: + pushl $0 + pushl $196 + jmp alltraps +.globl vector197 +vector197: + pushl $0 + pushl $197 + jmp alltraps +.globl vector198 +vector198: + pushl $0 + pushl $198 + jmp alltraps +.globl vector199 +vector199: + pushl $0 + pushl $199 + jmp alltraps +.globl vector200 +vector200: + pushl $0 + pushl $200 + jmp alltraps +.globl vector201 +vector201: + pushl $0 + pushl $201 + jmp alltraps +.globl vector202 +vector202: + pushl $0 + pushl $202 + jmp alltraps +.globl vector203 +vector203: + pushl $0 + pushl $203 + jmp alltraps +.globl vector204 +vector204: + pushl $0 + pushl $204 + jmp alltraps +.globl vector205 +vector205: + pushl $0 + pushl $205 + jmp alltraps +.globl vector206 +vector206: + pushl $0 + pushl $206 + jmp alltraps +.globl vector207 +vector207: + pushl $0 + pushl $207 + jmp alltraps +.globl vector208 +vector208: + pushl $0 + pushl $208 + jmp alltraps +.globl vector209 +vector209: + pushl $0 + pushl $209 + jmp alltraps +.globl vector210 +vector210: + pushl $0 + pushl $210 + jmp alltraps +.globl vector211 +vector211: + pushl $0 + pushl $211 + jmp alltraps +.globl vector212 +vector212: + pushl $0 + pushl $212 + jmp alltraps +.globl vector213 +vector213: + pushl $0 + pushl $213 + jmp alltraps +.globl vector214 +vector214: + pushl $0 + pushl $214 + jmp alltraps +.globl vector215 +vector215: + pushl $0 + pushl $215 + jmp alltraps +.globl vector216 +vector216: + pushl $0 + pushl $216 + jmp alltraps +.globl vector217 +vector217: + pushl $0 + pushl $217 + jmp alltraps +.globl vector218 +vector218: + pushl $0 + pushl $218 + jmp alltraps +.globl vector219 +vector219: + pushl $0 + pushl $219 + jmp alltraps +.globl vector220 +vector220: + pushl $0 + pushl $220 + jmp alltraps +.globl vector221 +vector221: + pushl $0 + pushl $221 + jmp alltraps +.globl vector222 +vector222: + pushl $0 + pushl $222 + jmp alltraps +.globl vector223 +vector223: + pushl $0 + pushl $223 + jmp alltraps +.globl vector224 +vector224: + pushl $0 + pushl $224 + jmp alltraps +.globl vector225 +vector225: + pushl $0 + pushl $225 + jmp alltraps +.globl vector226 +vector226: + pushl $0 + pushl $226 + jmp alltraps +.globl vector227 +vector227: + pushl $0 + pushl $227 + jmp alltraps +.globl vector228 +vector228: + pushl $0 + pushl $228 + jmp alltraps +.globl vector229 +vector229: + pushl $0 + pushl $229 + jmp alltraps +.globl vector230 +vector230: + pushl $0 + pushl $230 + jmp alltraps +.globl vector231 +vector231: + pushl $0 + pushl $231 + jmp alltraps +.globl vector232 +vector232: + pushl $0 + pushl $232 + jmp alltraps +.globl vector233 +vector233: + pushl $0 + pushl $233 + jmp alltraps +.globl vector234 +vector234: + pushl $0 + pushl $234 + jmp alltraps +.globl vector235 +vector235: + pushl $0 + pushl $235 + jmp alltraps +.globl vector236 +vector236: + pushl $0 + pushl $236 + jmp alltraps +.globl vector237 +vector237: + pushl $0 + pushl $237 + jmp alltraps +.globl vector238 +vector238: + pushl $0 + pushl $238 + jmp alltraps +.globl vector239 +vector239: + pushl $0 + pushl $239 + jmp alltraps +.globl vector240 +vector240: + pushl $0 + pushl $240 + jmp alltraps +.globl vector241 +vector241: + pushl $0 + pushl $241 + jmp alltraps +.globl vector242 +vector242: + pushl $0 + pushl $242 + jmp alltraps +.globl vector243 +vector243: + pushl $0 + pushl $243 + jmp alltraps +.globl vector244 +vector244: + pushl $0 + pushl $244 + jmp alltraps +.globl vector245 +vector245: + pushl $0 + pushl $245 + jmp alltraps +.globl vector246 +vector246: + pushl $0 + pushl $246 + jmp alltraps +.globl vector247 +vector247: + pushl $0 + pushl $247 + jmp alltraps +.globl vector248 +vector248: + pushl $0 + pushl $248 + jmp alltraps +.globl vector249 +vector249: + pushl $0 + pushl $249 + jmp alltraps +.globl vector250 +vector250: + pushl $0 + pushl $250 + jmp alltraps +.globl vector251 +vector251: + pushl $0 + pushl $251 + jmp alltraps +.globl vector252 +vector252: + pushl $0 + pushl $252 + jmp alltraps +.globl vector253 +vector253: + pushl $0 + pushl $253 + jmp alltraps +.globl vector254 +vector254: + pushl $0 + pushl $254 + jmp alltraps +.globl vector255 +vector255: + pushl $0 + pushl $255 + jmp alltraps + +# vector table +.data +.globl vectors +vectors: + .long vector0 + .long vector1 + .long vector2 + .long vector3 + .long vector4 + .long vector5 + .long vector6 + .long vector7 + .long vector8 + .long vector9 + .long vector10 + .long vector11 + .long vector12 + .long vector13 + .long vector14 + .long vector15 + .long vector16 + .long vector17 + .long vector18 + .long vector19 + .long vector20 + .long vector21 + .long vector22 + .long vector23 + .long vector24 + .long vector25 + .long vector26 + .long vector27 + .long vector28 + .long vector29 + .long vector30 + .long vector31 + .long vector32 + .long vector33 + .long vector34 + .long vector35 + .long vector36 + .long vector37 + .long vector38 + .long vector39 + .long vector40 + .long vector41 + .long vector42 + .long vector43 + .long vector44 + .long vector45 + .long vector46 + .long vector47 + .long vector48 + .long vector49 + .long vector50 + .long vector51 + .long vector52 + .long vector53 + .long vector54 + .long vector55 + .long vector56 + .long vector57 + .long vector58 + .long vector59 + .long vector60 + .long vector61 + .long vector62 + .long vector63 + .long vector64 + .long vector65 + .long vector66 + .long vector67 + .long vector68 + .long vector69 + .long vector70 + .long vector71 + .long vector72 + .long vector73 + .long vector74 + .long vector75 + .long vector76 + .long vector77 + .long vector78 + .long vector79 + .long vector80 + .long vector81 + .long vector82 + .long vector83 + .long vector84 + .long vector85 + .long vector86 + .long vector87 + .long vector88 + .long vector89 + .long vector90 + .long vector91 + .long vector92 + .long vector93 + .long vector94 + .long vector95 + .long vector96 + .long vector97 + .long vector98 + .long vector99 + .long vector100 + .long vector101 + .long vector102 + .long vector103 + .long vector104 + .long vector105 + .long vector106 + .long vector107 + .long vector108 + .long vector109 + .long vector110 + .long vector111 + .long vector112 + .long vector113 + .long vector114 + .long vector115 + .long vector116 + .long vector117 + .long vector118 + .long vector119 + .long vector120 + .long vector121 + .long vector122 + .long vector123 + .long vector124 + .long vector125 + .long vector126 + .long vector127 + .long vector128 + .long vector129 + .long vector130 + .long vector131 + .long vector132 + .long vector133 + .long vector134 + .long vector135 + .long vector136 + .long vector137 + .long vector138 + .long vector139 + .long vector140 + .long vector141 + .long vector142 + .long vector143 + .long vector144 + .long vector145 + .long vector146 + .long vector147 + .long vector148 + .long vector149 + .long vector150 + .long vector151 + .long vector152 + .long vector153 + .long vector154 + .long vector155 + .long vector156 + .long vector157 + .long vector158 + .long vector159 + .long vector160 + .long vector161 + .long vector162 + .long vector163 + .long vector164 + .long vector165 + .long vector166 + .long vector167 + .long vector168 + .long vector169 + .long vector170 + .long vector171 + .long vector172 + .long vector173 + .long vector174 + .long vector175 + .long vector176 + .long vector177 + .long vector178 + .long vector179 + .long vector180 + .long vector181 + .long vector182 + .long vector183 + .long vector184 + .long vector185 + .long vector186 + .long vector187 + .long vector188 + .long vector189 + .long vector190 + .long vector191 + .long vector192 + .long vector193 + .long vector194 + .long vector195 + .long vector196 + .long vector197 + .long vector198 + .long vector199 + .long vector200 + .long vector201 + .long vector202 + .long vector203 + .long vector204 + .long vector205 + .long vector206 + .long vector207 + .long vector208 + .long vector209 + .long vector210 + .long vector211 + .long vector212 + .long vector213 + .long vector214 + .long vector215 + .long vector216 + .long vector217 + .long vector218 + .long vector219 + .long vector220 + .long vector221 + .long vector222 + .long vector223 + .long vector224 + .long vector225 + .long vector226 + .long vector227 + .long vector228 + .long vector229 + .long vector230 + .long vector231 + .long vector232 + .long vector233 + .long vector234 + .long vector235 + .long vector236 + .long vector237 + .long vector238 + .long vector239 + .long vector240 + .long vector241 + .long vector242 + .long vector243 + .long vector244 + .long vector245 + .long vector246 + .long vector247 + .long vector248 + .long vector249 + .long vector250 + .long vector251 + .long vector252 + .long vector253 + .long vector254 + .long vector255 diff --git a/vectors.o b/vectors.o new file mode 100644 index 0000000..6e18ee3 Binary files /dev/null and b/vectors.o differ diff --git a/vm.d b/vm.d new file mode 100644 index 0000000..51631b1 --- /dev/null +++ b/vm.d @@ -0,0 +1,2 @@ +vm.o: vm.c /usr/include/stdc-predef.h param.h types.h defs.h x86.h \ + memlayout.h mmu.h proc.h elf.h diff --git a/vm.o b/vm.o new file mode 100644 index 0000000..7f45e9b Binary files /dev/null and b/vm.o differ diff --git a/wc.asm b/wc.asm new file mode 100644 index 0000000..3053056 --- /dev/null +++ b/wc.asm @@ -0,0 +1,1319 @@ + +_wc: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + exit(); + } + printf(1, "%d %d %d %s\n", l, w, c, name); +} + +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: be 01 00 00 00 mov $0x1,%esi + 14: 53 push %ebx + 15: 51 push %ecx + 16: 83 ec 18 sub $0x18,%esp + 19: 8b 01 mov (%ecx),%eax + 1b: 8b 59 04 mov 0x4(%ecx),%ebx + 1e: 89 45 e4 mov %eax,-0x1c(%ebp) + 21: 83 c3 04 add $0x4,%ebx + int fd, i; + + if (argc <= 1) { + 24: 83 f8 01 cmp $0x1,%eax + 27: 7e 56 jle 7f + 29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + wc(0, ""); + exit(); + } + + for (i = 1; i < argc; i++) { + if ((fd = open(argv[i], 0)) < 0) { + 30: 83 ec 08 sub $0x8,%esp + 33: 6a 00 push $0x0 + 35: ff 33 push (%ebx) + 37: e8 ff 03 00 00 call 43b + 3c: 83 c4 10 add $0x10,%esp + 3f: 89 c7 mov %eax,%edi + 41: 85 c0 test %eax,%eax + 43: 78 26 js 6b + printf(1, "wc: cannot open %s\n", argv[i]); + exit(); + } + wc(fd, argv[i]); + 45: 83 ec 08 sub $0x8,%esp + 48: ff 33 push (%ebx) + for (i = 1; i < argc; i++) { + 4a: 83 c6 01 add $0x1,%esi + 4d: 83 c3 04 add $0x4,%ebx + wc(fd, argv[i]); + 50: 50 push %eax + 51: e8 4a 00 00 00 call a0 + close(fd); + 56: 89 3c 24 mov %edi,(%esp) + 59: e8 0d 04 00 00 call 46b + for (i = 1; i < argc; i++) { + 5e: 83 c4 10 add $0x10,%esp + 61: 39 75 e4 cmp %esi,-0x1c(%ebp) + 64: 75 ca jne 30 + } + exit(); + 66: e8 68 03 00 00 call 3d3 + printf(1, "wc: cannot open %s\n", argv[i]); + 6b: 50 push %eax + 6c: ff 33 push (%ebx) + 6e: 68 9b 08 00 00 push $0x89b + 73: 6a 01 push $0x1 + 75: e8 d6 04 00 00 call 550 + exit(); + 7a: e8 54 03 00 00 call 3d3 + wc(0, ""); + 7f: 52 push %edx + 80: 52 push %edx + 81: 68 8d 08 00 00 push $0x88d + 86: 6a 00 push $0x0 + 88: e8 13 00 00 00 call a0 + exit(); + 8d: e8 41 03 00 00 call 3d3 + 92: 66 90 xchg %ax,%ax + 94: 66 90 xchg %ax,%ax + 96: 66 90 xchg %ax,%ax + 98: 66 90 xchg %ax,%ax + 9a: 66 90 xchg %ax,%ax + 9c: 66 90 xchg %ax,%ax + 9e: 66 90 xchg %ax,%ax + +000000a0 : +void wc(int fd, char *name) { + a0: 55 push %ebp + a1: 89 e5 mov %esp,%ebp + a3: 57 push %edi + a4: 56 push %esi + a5: 53 push %ebx + l = w = c = 0; + a6: 31 db xor %ebx,%ebx +void wc(int fd, char *name) { + a8: 83 ec 1c sub $0x1c,%esp + inword = 0; + ab: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) + l = w = c = 0; + b2: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + b9: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) + while ((n = read(fd, buf, sizeof(buf))) > 0) { + c0: 83 ec 04 sub $0x4,%esp + c3: 68 00 02 00 00 push $0x200 + c8: 68 00 0c 00 00 push $0xc00 + cd: ff 75 08 push 0x8(%ebp) + d0: e8 16 03 00 00 call 3eb + d5: 83 c4 10 add $0x10,%esp + d8: 89 c6 mov %eax,%esi + da: 85 c0 test %eax,%eax + dc: 7e 62 jle 140 + for (i = 0; i < n; i++) { + de: 31 ff xor %edi,%edi + e0: eb 14 jmp f6 + e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + inword = 0; + e8: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) + for (i = 0; i < n; i++) { + ef: 83 c7 01 add $0x1,%edi + f2: 39 fe cmp %edi,%esi + f4: 74 42 je 138 + if (buf[i] == '\n') { + f6: 0f be 87 00 0c 00 00 movsbl 0xc00(%edi),%eax + l++; + fd: 31 c9 xor %ecx,%ecx + ff: 3c 0a cmp $0xa,%al + 101: 0f 94 c1 sete %cl + if (strchr(" \r\t\n\v", buf[i])) { + 104: 83 ec 08 sub $0x8,%esp + 107: 50 push %eax + l++; + 108: 01 cb add %ecx,%ebx + if (strchr(" \r\t\n\v", buf[i])) { + 10a: 68 78 08 00 00 push $0x878 + 10f: e8 4c 01 00 00 call 260 + 114: 83 c4 10 add $0x10,%esp + 117: 85 c0 test %eax,%eax + 119: 75 cd jne e8 + else if (!inword) { + 11b: 8b 55 e4 mov -0x1c(%ebp),%edx + 11e: 85 d2 test %edx,%edx + 120: 75 cd jne ef + for (i = 0; i < n; i++) { + 122: 83 c7 01 add $0x1,%edi + w++; + 125: 83 45 e0 01 addl $0x1,-0x20(%ebp) + inword = 1; + 129: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp) + for (i = 0; i < n; i++) { + 130: 39 fe cmp %edi,%esi + 132: 75 c2 jne f6 + 134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c++; + 138: 01 75 dc add %esi,-0x24(%ebp) + 13b: eb 83 jmp c0 + 13d: 8d 76 00 lea 0x0(%esi),%esi + if (n < 0) { + 140: 75 24 jne 166 + printf(1, "%d %d %d %s\n", l, w, c, name); + 142: 83 ec 08 sub $0x8,%esp + 145: ff 75 0c push 0xc(%ebp) + 148: ff 75 dc push -0x24(%ebp) + 14b: ff 75 e0 push -0x20(%ebp) + 14e: 53 push %ebx + 14f: 68 8e 08 00 00 push $0x88e + 154: 6a 01 push $0x1 + 156: e8 f5 03 00 00 call 550 +} + 15b: 83 c4 20 add $0x20,%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 + printf(1, "wc: read error\n"); + 166: 50 push %eax + 167: 50 push %eax + 168: 68 7e 08 00 00 push $0x87e + 16d: 6a 01 push $0x1 + 16f: e8 dc 03 00 00 call 550 + exit(); + 174: e8 5a 02 00 00 call 3d3 + 179: 66 90 xchg %ax,%ax + 17b: 66 90 xchg %ax,%ax + 17d: 66 90 xchg %ax,%ax + 17f: 90 nop + +00000180 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 180: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 181: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 183: 89 e5 mov %esp,%ebp + 185: 53 push %ebx + 186: 8b 4d 08 mov 0x8(%ebp),%ecx + 189: 8b 5d 0c mov 0xc(%ebp),%ebx + 18c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 190: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 194: 88 14 01 mov %dl,(%ecx,%eax,1) + 197: 83 c0 01 add $0x1,%eax + 19a: 84 d2 test %dl,%dl + 19c: 75 f2 jne 190 + ; + } + return os; +} + 19e: 8b 5d fc mov -0x4(%ebp),%ebx + 1a1: 89 c8 mov %ecx,%eax + 1a3: c9 leave + 1a4: c3 ret + 1a5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000001b0 : + +int strcmp(const char *p, const char *q) { + 1b0: 55 push %ebp + 1b1: 89 e5 mov %esp,%ebp + 1b3: 53 push %ebx + 1b4: 8b 55 08 mov 0x8(%ebp),%edx + 1b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 1ba: 0f b6 02 movzbl (%edx),%eax + 1bd: 84 c0 test %al,%al + 1bf: 75 17 jne 1d8 + 1c1: eb 3a jmp 1fd + 1c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1c7: 90 nop + 1c8: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 1cc: 83 c2 01 add $0x1,%edx + 1cf: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 1d2: 84 c0 test %al,%al + 1d4: 74 1a je 1f0 + p++, q++; + 1d6: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 1d8: 0f b6 19 movzbl (%ecx),%ebx + 1db: 38 c3 cmp %al,%bl + 1dd: 74 e9 je 1c8 + } + return (uchar) * p - (uchar) * q; + 1df: 29 d8 sub %ebx,%eax +} + 1e1: 8b 5d fc mov -0x4(%ebp),%ebx + 1e4: c9 leave + 1e5: c3 ret + 1e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1ed: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + 1f0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + 1f4: 31 c0 xor %eax,%eax + 1f6: 29 d8 sub %ebx,%eax +} + 1f8: 8b 5d fc mov -0x4(%ebp),%ebx + 1fb: c9 leave + 1fc: c3 ret + return (uchar) * p - (uchar) * q; + 1fd: 0f b6 19 movzbl (%ecx),%ebx + 200: 31 c0 xor %eax,%eax + 202: eb db jmp 1df + 204: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 20b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 20f: 90 nop + +00000210 : + +uint strlen(const char *s) { + 210: 55 push %ebp + 211: 89 e5 mov %esp,%ebp + 213: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + 216: 80 3a 00 cmpb $0x0,(%edx) + 219: 74 15 je 230 + 21b: 31 c0 xor %eax,%eax + 21d: 8d 76 00 lea 0x0(%esi),%esi + 220: 83 c0 01 add $0x1,%eax + 223: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + 227: 89 c1 mov %eax,%ecx + 229: 75 f5 jne 220 + ; + } + return n; +} + 22b: 89 c8 mov %ecx,%eax + 22d: 5d pop %ebp + 22e: c3 ret + 22f: 90 nop + for (n = 0; s[n]; n++) { + 230: 31 c9 xor %ecx,%ecx +} + 232: 5d pop %ebp + 233: 89 c8 mov %ecx,%eax + 235: c3 ret + 236: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 23d: 8d 76 00 lea 0x0(%esi),%esi + +00000240 : + +void* memset(void *dst, int c, uint n) { + 240: 55 push %ebp + 241: 89 e5 mov %esp,%ebp + 243: 57 push %edi + 244: 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" : + 247: 8b 4d 10 mov 0x10(%ebp),%ecx + 24a: 8b 45 0c mov 0xc(%ebp),%eax + 24d: 89 d7 mov %edx,%edi + 24f: fc cld + 250: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 252: 8b 7d fc mov -0x4(%ebp),%edi + 255: 89 d0 mov %edx,%eax + 257: c9 leave + 258: c3 ret + 259: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000260 : + +char* strchr(const char *s, char c) { + 260: 55 push %ebp + 261: 89 e5 mov %esp,%ebp + 263: 8b 45 08 mov 0x8(%ebp),%eax + 266: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 26a: 0f b6 10 movzbl (%eax),%edx + 26d: 84 d2 test %dl,%dl + 26f: 75 12 jne 283 + 271: eb 1d jmp 290 + 273: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 277: 90 nop + 278: 0f b6 50 01 movzbl 0x1(%eax),%edx + 27c: 83 c0 01 add $0x1,%eax + 27f: 84 d2 test %dl,%dl + 281: 74 0d je 290 + if (*s == c) { + 283: 38 d1 cmp %dl,%cl + 285: 75 f1 jne 278 + return (char*)s; + } + } + return 0; +} + 287: 5d pop %ebp + 288: c3 ret + 289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 290: 31 c0 xor %eax,%eax +} + 292: 5d pop %ebp + 293: c3 ret + 294: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 29b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 29f: 90 nop + +000002a0 : + +char* gets(char *buf, int max) { + 2a0: 55 push %ebp + 2a1: 89 e5 mov %esp,%ebp + 2a3: 57 push %edi + 2a4: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 2a5: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 2a8: 53 push %ebx + for (i = 0; i + 1 < max;) { + 2a9: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 2ab: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 2ae: eb 27 jmp 2d7 + cc = read(0, &c, 1); + 2b0: 83 ec 04 sub $0x4,%esp + 2b3: 6a 01 push $0x1 + 2b5: 57 push %edi + 2b6: 6a 00 push $0x0 + 2b8: e8 2e 01 00 00 call 3eb + if (cc < 1) { + 2bd: 83 c4 10 add $0x10,%esp + 2c0: 85 c0 test %eax,%eax + 2c2: 7e 1d jle 2e1 + break; + } + buf[i++] = c; + 2c4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 2c8: 8b 55 08 mov 0x8(%ebp),%edx + 2cb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 2cf: 3c 0a cmp $0xa,%al + 2d1: 74 1d je 2f0 + 2d3: 3c 0d cmp $0xd,%al + 2d5: 74 19 je 2f0 + for (i = 0; i + 1 < max;) { + 2d7: 89 de mov %ebx,%esi + 2d9: 83 c3 01 add $0x1,%ebx + 2dc: 3b 5d 0c cmp 0xc(%ebp),%ebx + 2df: 7c cf jl 2b0 + break; + } + } + buf[i] = '\0'; + 2e1: 8b 45 08 mov 0x8(%ebp),%eax + 2e4: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 2e8: 8d 65 f4 lea -0xc(%ebp),%esp + 2eb: 5b pop %ebx + 2ec: 5e pop %esi + 2ed: 5f pop %edi + 2ee: 5d pop %ebp + 2ef: c3 ret + buf[i] = '\0'; + 2f0: 8b 45 08 mov 0x8(%ebp),%eax + 2f3: 89 de mov %ebx,%esi + 2f5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 2f9: 8d 65 f4 lea -0xc(%ebp),%esp + 2fc: 5b pop %ebx + 2fd: 5e pop %esi + 2fe: 5f pop %edi + 2ff: 5d pop %ebp + 300: c3 ret + 301: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 308: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 30f: 90 nop + +00000310 : + +int stat(const char *n, struct stat *st) { + 310: 55 push %ebp + 311: 89 e5 mov %esp,%ebp + 313: 56 push %esi + 314: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 315: 83 ec 08 sub $0x8,%esp + 318: 6a 00 push $0x0 + 31a: ff 75 08 push 0x8(%ebp) + 31d: e8 19 01 00 00 call 43b + if (fd < 0) { + 322: 83 c4 10 add $0x10,%esp + 325: 85 c0 test %eax,%eax + 327: 78 27 js 350 + return -1; + } + r = fstat(fd, st); + 329: 83 ec 08 sub $0x8,%esp + 32c: ff 75 0c push 0xc(%ebp) + 32f: 89 c3 mov %eax,%ebx + 331: 50 push %eax + 332: e8 cc 00 00 00 call 403 + close(fd); + 337: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 33a: 89 c6 mov %eax,%esi + close(fd); + 33c: e8 2a 01 00 00 call 46b + return r; + 341: 83 c4 10 add $0x10,%esp +} + 344: 8d 65 f8 lea -0x8(%ebp),%esp + 347: 89 f0 mov %esi,%eax + 349: 5b pop %ebx + 34a: 5e pop %esi + 34b: 5d pop %ebp + 34c: c3 ret + 34d: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 350: be ff ff ff ff mov $0xffffffff,%esi + 355: eb ed jmp 344 + 357: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 35e: 66 90 xchg %ax,%ax + +00000360 : + +int atoi(const char *s) { + 360: 55 push %ebp + 361: 89 e5 mov %esp,%ebp + 363: 53 push %ebx + 364: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 367: 0f be 02 movsbl (%edx),%eax + 36a: 8d 48 d0 lea -0x30(%eax),%ecx + 36d: 80 f9 09 cmp $0x9,%cl + n = 0; + 370: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 375: 77 1e ja 395 + 377: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 37e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 380: 83 c2 01 add $0x1,%edx + 383: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 386: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 38a: 0f be 02 movsbl (%edx),%eax + 38d: 8d 58 d0 lea -0x30(%eax),%ebx + 390: 80 fb 09 cmp $0x9,%bl + 393: 76 eb jbe 380 + } + return n; +} + 395: 8b 5d fc mov -0x4(%ebp),%ebx + 398: 89 c8 mov %ecx,%eax + 39a: c9 leave + 39b: c3 ret + 39c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000003a0 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 3a0: 55 push %ebp + 3a1: 89 e5 mov %esp,%ebp + 3a3: 57 push %edi + 3a4: 8b 45 10 mov 0x10(%ebp),%eax + 3a7: 8b 55 08 mov 0x8(%ebp),%edx + 3aa: 56 push %esi + 3ab: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 3ae: 85 c0 test %eax,%eax + 3b0: 7e 13 jle 3c5 + 3b2: 01 d0 add %edx,%eax + dst = vdst; + 3b4: 89 d7 mov %edx,%edi + 3b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3bd: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 3c0: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 3c1: 39 f8 cmp %edi,%eax + 3c3: 75 fb jne 3c0 + } + return vdst; +} + 3c5: 5e pop %esi + 3c6: 89 d0 mov %edx,%eax + 3c8: 5f pop %edi + 3c9: 5d pop %ebp + 3ca: c3 ret + +000003cb : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 3cb: b8 01 00 00 00 mov $0x1,%eax + 3d0: cd 40 int $0x40 + 3d2: c3 ret + +000003d3 : +SYSCALL(exit) + 3d3: b8 02 00 00 00 mov $0x2,%eax + 3d8: cd 40 int $0x40 + 3da: c3 ret + +000003db : +SYSCALL(wait) + 3db: b8 03 00 00 00 mov $0x3,%eax + 3e0: cd 40 int $0x40 + 3e2: c3 ret + +000003e3 : +SYSCALL(pipe) + 3e3: b8 04 00 00 00 mov $0x4,%eax + 3e8: cd 40 int $0x40 + 3ea: c3 ret + +000003eb : +SYSCALL(read) + 3eb: b8 05 00 00 00 mov $0x5,%eax + 3f0: cd 40 int $0x40 + 3f2: c3 ret + +000003f3 : +SYSCALL(kill) + 3f3: b8 06 00 00 00 mov $0x6,%eax + 3f8: cd 40 int $0x40 + 3fa: c3 ret + +000003fb : +SYSCALL(exec) + 3fb: b8 07 00 00 00 mov $0x7,%eax + 400: cd 40 int $0x40 + 402: c3 ret + +00000403 : +SYSCALL(fstat) + 403: b8 08 00 00 00 mov $0x8,%eax + 408: cd 40 int $0x40 + 40a: c3 ret + +0000040b : +SYSCALL(chdir) + 40b: b8 09 00 00 00 mov $0x9,%eax + 410: cd 40 int $0x40 + 412: c3 ret + +00000413 : +SYSCALL(dup) + 413: b8 0a 00 00 00 mov $0xa,%eax + 418: cd 40 int $0x40 + 41a: c3 ret + +0000041b : +SYSCALL(getpid) + 41b: b8 0b 00 00 00 mov $0xb,%eax + 420: cd 40 int $0x40 + 422: c3 ret + +00000423 : +SYSCALL(sbrk) + 423: b8 0c 00 00 00 mov $0xc,%eax + 428: cd 40 int $0x40 + 42a: c3 ret + +0000042b : +SYSCALL(sleep) + 42b: b8 0d 00 00 00 mov $0xd,%eax + 430: cd 40 int $0x40 + 432: c3 ret + +00000433 : +SYSCALL(uptime) + 433: b8 0e 00 00 00 mov $0xe,%eax + 438: cd 40 int $0x40 + 43a: c3 ret + +0000043b : +SYSCALL(open) + 43b: b8 0f 00 00 00 mov $0xf,%eax + 440: cd 40 int $0x40 + 442: c3 ret + +00000443 : +SYSCALL(write) + 443: b8 10 00 00 00 mov $0x10,%eax + 448: cd 40 int $0x40 + 44a: c3 ret + +0000044b : +SYSCALL(mknod) + 44b: b8 11 00 00 00 mov $0x11,%eax + 450: cd 40 int $0x40 + 452: c3 ret + +00000453 : +SYSCALL(unlink) + 453: b8 12 00 00 00 mov $0x12,%eax + 458: cd 40 int $0x40 + 45a: c3 ret + +0000045b : +SYSCALL(link) + 45b: b8 13 00 00 00 mov $0x13,%eax + 460: cd 40 int $0x40 + 462: c3 ret + +00000463 : +SYSCALL(mkdir) + 463: b8 14 00 00 00 mov $0x14,%eax + 468: cd 40 int $0x40 + 46a: c3 ret + +0000046b : +SYSCALL(close) + 46b: b8 15 00 00 00 mov $0x15,%eax + 470: cd 40 int $0x40 + 472: c3 ret + +00000473 : +SYSCALL(getch) + 473: b8 16 00 00 00 mov $0x16,%eax + 478: cd 40 int $0x40 + 47a: c3 ret + +0000047b : +SYSCALL(greeting) + 47b: b8 17 00 00 00 mov $0x17,%eax + 480: cd 40 int $0x40 + 482: c3 ret + +00000483 : +SYSCALL(shutdown) + 483: b8 18 00 00 00 mov $0x18,%eax + 488: cd 40 int $0x40 + 48a: c3 ret + +0000048b : +SYSCALL(screen) + 48b: b8 19 00 00 00 mov $0x19,%eax + 490: cd 40 int $0x40 + 492: c3 ret + +00000493 : +SYSCALL(cls) + 493: b8 1a 00 00 00 mov $0x1a,%eax + 498: cd 40 int $0x40 + 49a: c3 ret + 49b: 66 90 xchg %ax,%ax + 49d: 66 90 xchg %ax,%ax + 49f: 90 nop + +000004a0 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 4a0: 55 push %ebp + 4a1: 89 e5 mov %esp,%ebp + 4a3: 57 push %edi + 4a4: 56 push %esi + 4a5: 53 push %ebx + 4a6: 83 ec 3c sub $0x3c,%esp + 4a9: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 4ac: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 4ae: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 4b1: 85 d2 test %edx,%edx + 4b3: 0f 89 7f 00 00 00 jns 538 + 4b9: f6 45 08 01 testb $0x1,0x8(%ebp) + 4bd: 74 79 je 538 + neg = 1; + 4bf: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 4c6: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 4c8: 31 db xor %ebx,%ebx + 4ca: 8d 75 d7 lea -0x29(%ebp),%esi + 4cd: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 4d0: 89 c8 mov %ecx,%eax + 4d2: 31 d2 xor %edx,%edx + 4d4: 89 cf mov %ecx,%edi + 4d6: f7 75 c4 divl -0x3c(%ebp) + 4d9: 0f b6 92 10 09 00 00 movzbl 0x910(%edx),%edx + 4e0: 89 45 c0 mov %eax,-0x40(%ebp) + 4e3: 89 d8 mov %ebx,%eax + 4e5: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 4e8: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 4eb: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 4ee: 39 7d c4 cmp %edi,-0x3c(%ebp) + 4f1: 76 dd jbe 4d0 + if (neg) { + 4f3: 8b 4d bc mov -0x44(%ebp),%ecx + 4f6: 85 c9 test %ecx,%ecx + 4f8: 74 0c je 506 + buf[i++] = '-'; + 4fa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 4ff: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 501: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 506: 8b 7d b8 mov -0x48(%ebp),%edi + 509: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 50d: eb 07 jmp 516 + 50f: 90 nop + putc(fd, buf[i]); + 510: 0f b6 13 movzbl (%ebx),%edx + 513: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 516: 83 ec 04 sub $0x4,%esp + 519: 88 55 d7 mov %dl,-0x29(%ebp) + 51c: 6a 01 push $0x1 + 51e: 56 push %esi + 51f: 57 push %edi + 520: e8 1e ff ff ff call 443 + while (--i >= 0) { + 525: 83 c4 10 add $0x10,%esp + 528: 39 de cmp %ebx,%esi + 52a: 75 e4 jne 510 + } +} + 52c: 8d 65 f4 lea -0xc(%ebp),%esp + 52f: 5b pop %ebx + 530: 5e pop %esi + 531: 5f pop %edi + 532: 5d pop %ebp + 533: c3 ret + 534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 538: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 53f: eb 87 jmp 4c8 + 541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 548: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 54f: 90 nop + +00000550 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 550: 55 push %ebp + 551: 89 e5 mov %esp,%ebp + 553: 57 push %edi + 554: 56 push %esi + 555: 53 push %ebx + 556: 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++) { + 559: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 55c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 55f: 0f b6 13 movzbl (%ebx),%edx + 562: 84 d2 test %dl,%dl + 564: 74 6a je 5d0 + ap = (uint*)(void*)&fmt + 1; + 566: 8d 45 10 lea 0x10(%ebp),%eax + 569: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 56c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 56f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 571: 89 45 d0 mov %eax,-0x30(%ebp) + 574: eb 36 jmp 5ac + 576: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 57d: 8d 76 00 lea 0x0(%esi),%esi + 580: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 583: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 588: 83 f8 25 cmp $0x25,%eax + 58b: 74 15 je 5a2 + write(fd, &c, 1); + 58d: 83 ec 04 sub $0x4,%esp + 590: 88 55 e7 mov %dl,-0x19(%ebp) + 593: 6a 01 push $0x1 + 595: 57 push %edi + 596: 56 push %esi + 597: e8 a7 fe ff ff call 443 + 59c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 59f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 5a2: 0f b6 13 movzbl (%ebx),%edx + 5a5: 83 c3 01 add $0x1,%ebx + 5a8: 84 d2 test %dl,%dl + 5aa: 74 24 je 5d0 + c = fmt[i] & 0xff; + 5ac: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 5af: 85 c9 test %ecx,%ecx + 5b1: 74 cd je 580 + } + } + else if (state == '%') { + 5b3: 83 f9 25 cmp $0x25,%ecx + 5b6: 75 ea jne 5a2 + if (c == 'd') { + 5b8: 83 f8 25 cmp $0x25,%eax + 5bb: 0f 84 07 01 00 00 je 6c8 + 5c1: 83 e8 63 sub $0x63,%eax + 5c4: 83 f8 15 cmp $0x15,%eax + 5c7: 77 17 ja 5e0 + 5c9: ff 24 85 b8 08 00 00 jmp *0x8b8(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 5d0: 8d 65 f4 lea -0xc(%ebp),%esp + 5d3: 5b pop %ebx + 5d4: 5e pop %esi + 5d5: 5f pop %edi + 5d6: 5d pop %ebp + 5d7: c3 ret + 5d8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5df: 90 nop + write(fd, &c, 1); + 5e0: 83 ec 04 sub $0x4,%esp + 5e3: 88 55 d4 mov %dl,-0x2c(%ebp) + 5e6: 6a 01 push $0x1 + 5e8: 57 push %edi + 5e9: 56 push %esi + 5ea: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 5ee: e8 50 fe ff ff call 443 + putc(fd, c); + 5f3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 5f7: 83 c4 0c add $0xc,%esp + 5fa: 88 55 e7 mov %dl,-0x19(%ebp) + 5fd: 6a 01 push $0x1 + 5ff: 57 push %edi + 600: 56 push %esi + 601: e8 3d fe ff ff call 443 + putc(fd, c); + 606: 83 c4 10 add $0x10,%esp + state = 0; + 609: 31 c9 xor %ecx,%ecx + 60b: eb 95 jmp 5a2 + 60d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 610: 83 ec 0c sub $0xc,%esp + 613: b9 10 00 00 00 mov $0x10,%ecx + 618: 6a 00 push $0x0 + 61a: 8b 45 d0 mov -0x30(%ebp),%eax + 61d: 8b 10 mov (%eax),%edx + 61f: 89 f0 mov %esi,%eax + 621: e8 7a fe ff ff call 4a0 + ap++; + 626: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 62a: 83 c4 10 add $0x10,%esp + state = 0; + 62d: 31 c9 xor %ecx,%ecx + 62f: e9 6e ff ff ff jmp 5a2 + 634: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 638: 8b 45 d0 mov -0x30(%ebp),%eax + 63b: 8b 10 mov (%eax),%edx + ap++; + 63d: 83 c0 04 add $0x4,%eax + 640: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 643: 85 d2 test %edx,%edx + 645: 0f 84 8d 00 00 00 je 6d8 + while (*s != 0) { + 64b: 0f b6 02 movzbl (%edx),%eax + state = 0; + 64e: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 650: 84 c0 test %al,%al + 652: 0f 84 4a ff ff ff je 5a2 + 658: 89 5d d4 mov %ebx,-0x2c(%ebp) + 65b: 89 d3 mov %edx,%ebx + 65d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 660: 83 ec 04 sub $0x4,%esp + s++; + 663: 83 c3 01 add $0x1,%ebx + 666: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 669: 6a 01 push $0x1 + 66b: 57 push %edi + 66c: 56 push %esi + 66d: e8 d1 fd ff ff call 443 + while (*s != 0) { + 672: 0f b6 03 movzbl (%ebx),%eax + 675: 83 c4 10 add $0x10,%esp + 678: 84 c0 test %al,%al + 67a: 75 e4 jne 660 + state = 0; + 67c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 67f: 31 c9 xor %ecx,%ecx + 681: e9 1c ff ff ff jmp 5a2 + 686: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 68d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 690: 83 ec 0c sub $0xc,%esp + 693: b9 0a 00 00 00 mov $0xa,%ecx + 698: 6a 01 push $0x1 + 69a: e9 7b ff ff ff jmp 61a + 69f: 90 nop + putc(fd, *ap); + 6a0: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 6a3: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 6a6: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 6a8: 6a 01 push $0x1 + 6aa: 57 push %edi + 6ab: 56 push %esi + putc(fd, *ap); + 6ac: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 6af: e8 8f fd ff ff call 443 + ap++; + 6b4: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 6b8: 83 c4 10 add $0x10,%esp + state = 0; + 6bb: 31 c9 xor %ecx,%ecx + 6bd: e9 e0 fe ff ff jmp 5a2 + 6c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 6c8: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 6cb: 83 ec 04 sub $0x4,%esp + 6ce: e9 2a ff ff ff jmp 5fd + 6d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 6d7: 90 nop + s = "(null)"; + 6d8: ba af 08 00 00 mov $0x8af,%edx + while (*s != 0) { + 6dd: 89 5d d4 mov %ebx,-0x2c(%ebp) + 6e0: b8 28 00 00 00 mov $0x28,%eax + 6e5: 89 d3 mov %edx,%ebx + 6e7: e9 74 ff ff ff jmp 660 + 6ec: 66 90 xchg %ax,%ax + 6ee: 66 90 xchg %ax,%ax + +000006f0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 6f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 6f1: a1 00 0e 00 00 mov 0xe00,%eax +void free(void *ap) { + 6f6: 89 e5 mov %esp,%ebp + 6f8: 57 push %edi + 6f9: 56 push %esi + 6fa: 53 push %ebx + 6fb: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 6fe: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 701: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 708: 89 c2 mov %eax,%edx + 70a: 8b 00 mov (%eax),%eax + 70c: 39 ca cmp %ecx,%edx + 70e: 73 30 jae 740 + 710: 39 c1 cmp %eax,%ecx + 712: 72 04 jb 718 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 714: 39 c2 cmp %eax,%edx + 716: 72 f0 jb 708 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 718: 8b 73 fc mov -0x4(%ebx),%esi + 71b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 71e: 39 f8 cmp %edi,%eax + 720: 74 30 je 752 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 722: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 725: 8b 42 04 mov 0x4(%edx),%eax + 728: 8d 34 c2 lea (%edx,%eax,8),%esi + 72b: 39 f1 cmp %esi,%ecx + 72d: 74 3a je 769 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 72f: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 731: 5b pop %ebx + freep = p; + 732: 89 15 00 0e 00 00 mov %edx,0xe00 +} + 738: 5e pop %esi + 739: 5f pop %edi + 73a: 5d pop %ebp + 73b: c3 ret + 73c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 740: 39 c2 cmp %eax,%edx + 742: 72 c4 jb 708 + 744: 39 c1 cmp %eax,%ecx + 746: 73 c0 jae 708 + if (bp + bp->s.size == p->s.ptr) { + 748: 8b 73 fc mov -0x4(%ebx),%esi + 74b: 8d 3c f1 lea (%ecx,%esi,8),%edi + 74e: 39 f8 cmp %edi,%eax + 750: 75 d0 jne 722 + bp->s.size += p->s.ptr->s.size; + 752: 03 70 04 add 0x4(%eax),%esi + 755: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 758: 8b 02 mov (%edx),%eax + 75a: 8b 00 mov (%eax),%eax + 75c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 75f: 8b 42 04 mov 0x4(%edx),%eax + 762: 8d 34 c2 lea (%edx,%eax,8),%esi + 765: 39 f1 cmp %esi,%ecx + 767: 75 c6 jne 72f + p->s.size += bp->s.size; + 769: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 76c: 89 15 00 0e 00 00 mov %edx,0xe00 + p->s.size += bp->s.size; + 772: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 775: 8b 4b f8 mov -0x8(%ebx),%ecx + 778: 89 0a mov %ecx,(%edx) +} + 77a: 5b pop %ebx + 77b: 5e pop %esi + 77c: 5f pop %edi + 77d: 5d pop %ebp + 77e: c3 ret + 77f: 90 nop + +00000780 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 780: 55 push %ebp + 781: 89 e5 mov %esp,%ebp + 783: 57 push %edi + 784: 56 push %esi + 785: 53 push %ebx + 786: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 789: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 78c: 8b 3d 00 0e 00 00 mov 0xe00,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 792: 8d 70 07 lea 0x7(%eax),%esi + 795: c1 ee 03 shr $0x3,%esi + 798: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 79b: 85 ff test %edi,%edi + 79d: 0f 84 9d 00 00 00 je 840 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 7a3: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 7a5: 8b 4a 04 mov 0x4(%edx),%ecx + 7a8: 39 f1 cmp %esi,%ecx + 7aa: 73 6a jae 816 + 7ac: bb 00 10 00 00 mov $0x1000,%ebx + 7b1: 39 de cmp %ebx,%esi + 7b3: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 7b6: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 7bd: 89 45 e4 mov %eax,-0x1c(%ebp) + 7c0: eb 17 jmp 7d9 + 7c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 7c8: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 7ca: 8b 48 04 mov 0x4(%eax),%ecx + 7cd: 39 f1 cmp %esi,%ecx + 7cf: 73 4f jae 820 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 7d1: 8b 3d 00 0e 00 00 mov 0xe00,%edi + 7d7: 89 c2 mov %eax,%edx + 7d9: 39 d7 cmp %edx,%edi + 7db: 75 eb jne 7c8 + p = sbrk(nu * sizeof(Header)); + 7dd: 83 ec 0c sub $0xc,%esp + 7e0: ff 75 e4 push -0x1c(%ebp) + 7e3: e8 3b fc ff ff call 423 + if (p == (char*)-1) { + 7e8: 83 c4 10 add $0x10,%esp + 7eb: 83 f8 ff cmp $0xffffffff,%eax + 7ee: 74 1c je 80c + hp->s.size = nu; + 7f0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 7f3: 83 ec 0c sub $0xc,%esp + 7f6: 83 c0 08 add $0x8,%eax + 7f9: 50 push %eax + 7fa: e8 f1 fe ff ff call 6f0 + return freep; + 7ff: 8b 15 00 0e 00 00 mov 0xe00,%edx + if ((p = morecore(nunits)) == 0) { + 805: 83 c4 10 add $0x10,%esp + 808: 85 d2 test %edx,%edx + 80a: 75 bc jne 7c8 + return 0; + } + } + } +} + 80c: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 80f: 31 c0 xor %eax,%eax +} + 811: 5b pop %ebx + 812: 5e pop %esi + 813: 5f pop %edi + 814: 5d pop %ebp + 815: c3 ret + if (p->s.size >= nunits) { + 816: 89 d0 mov %edx,%eax + 818: 89 fa mov %edi,%edx + 81a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 820: 39 ce cmp %ecx,%esi + 822: 74 4c je 870 + p->s.size -= nunits; + 824: 29 f1 sub %esi,%ecx + 826: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 829: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 82c: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 82f: 89 15 00 0e 00 00 mov %edx,0xe00 +} + 835: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 838: 83 c0 08 add $0x8,%eax +} + 83b: 5b pop %ebx + 83c: 5e pop %esi + 83d: 5f pop %edi + 83e: 5d pop %ebp + 83f: c3 ret + base.s.ptr = freep = prevp = &base; + 840: c7 05 00 0e 00 00 04 movl $0xe04,0xe00 + 847: 0e 00 00 + base.s.size = 0; + 84a: bf 04 0e 00 00 mov $0xe04,%edi + base.s.ptr = freep = prevp = &base; + 84f: c7 05 04 0e 00 00 04 movl $0xe04,0xe04 + 856: 0e 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 859: 89 fa mov %edi,%edx + base.s.size = 0; + 85b: c7 05 08 0e 00 00 00 movl $0x0,0xe08 + 862: 00 00 00 + if (p->s.size >= nunits) { + 865: e9 42 ff ff ff jmp 7ac + 86a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 870: 8b 08 mov (%eax),%ecx + 872: 89 0a mov %ecx,(%edx) + 874: eb b9 jmp 82f diff --git a/wc.d b/wc.d new file mode 100644 index 0000000..6adc498 --- /dev/null +++ b/wc.d @@ -0,0 +1 @@ +wc.o: wc.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/wc.o b/wc.o new file mode 100644 index 0000000..df9fa60 Binary files /dev/null and b/wc.o differ diff --git a/wc.sym b/wc.sym new file mode 100644 index 0000000..bc1facb --- /dev/null +++ b/wc.sym @@ -0,0 +1,52 @@ +00000000 wc.c +00000000 ulib.c +00000000 printf.c +000004a0 printint +00000910 digits.0 +00000000 umalloc.c +00000e00 freep +00000e04 base +00000180 strcpy +00000550 printf +0000047b greeting +000003a0 memmove +0000044b mknod +000002a0 gets +0000041b getpid +0000048b screen +00000780 malloc +0000042b sleep +000003e3 pipe +00000473 getch +00000443 write +00000403 fstat +000003f3 kill +0000040b chdir +000003fb exec +000003db wait +000003eb read +00000453 unlink +000000a0 wc +000003cb fork +00000423 sbrk +00000433 uptime +00000bf8 __bss_start +00000240 memset +00000000 main +000001b0 strcmp +00000483 shutdown +00000413 dup +00000c00 buf +00000310 stat +00000bf8 _edata +00000e0c _end +0000045b link +000003d3 exit +00000360 atoi +00000493 cls +00000210 strlen +0000043b open +00000260 strchr +00000463 mkdir +0000046b close +000006f0 free diff --git a/xv6.img b/xv6.img new file mode 100644 index 0000000..689a56e --- /dev/null +++ b/xv6.img @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:feb549da4c598bcedd9556334286cf2dd9da6f5a0049756a68c08fdcc814b41b +size 5120000 diff --git a/zombie.asm b/zombie.asm new file mode 100644 index 0000000..401a10c --- /dev/null +++ b/zombie.asm @@ -0,0 +1,1157 @@ + +_zombie: file format elf32-i386 + + +Disassembly of section .text: + +00000000
: + +#include "types.h" +#include "stat.h" +#include "user.h" + +int main(void) { + 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: 51 push %ecx + e: 83 ec 04 sub $0x4,%esp + if (fork() > 0) { + 11: e8 65 02 00 00 call 27b + 16: 85 c0 test %eax,%eax + 18: 7e 0d jle 27 + sleep(5); // Let child exit before parent. + 1a: 83 ec 0c sub $0xc,%esp + 1d: 6a 05 push $0x5 + 1f: e8 b7 02 00 00 call 2db + 24: 83 c4 10 add $0x10,%esp + } + exit(); + 27: e8 57 02 00 00 call 283 + 2c: 66 90 xchg %ax,%ax + 2e: 66 90 xchg %ax,%ax + +00000030 : +#include "stat.h" +#include "fcntl.h" +#include "user.h" +#include "x86.h" + +char*strcpy(char *s, const char *t) { + 30: 55 push %ebp + char *os; + + os = s; + while ((*s++ = *t++) != 0) { + 31: 31 c0 xor %eax,%eax +char*strcpy(char *s, const char *t) { + 33: 89 e5 mov %esp,%ebp + 35: 53 push %ebx + 36: 8b 4d 08 mov 0x8(%ebp),%ecx + 39: 8b 5d 0c mov 0xc(%ebp),%ebx + 3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while ((*s++ = *t++) != 0) { + 40: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx + 44: 88 14 01 mov %dl,(%ecx,%eax,1) + 47: 83 c0 01 add $0x1,%eax + 4a: 84 d2 test %dl,%dl + 4c: 75 f2 jne 40 + ; + } + return os; +} + 4e: 8b 5d fc mov -0x4(%ebp),%ebx + 51: 89 c8 mov %ecx,%eax + 53: c9 leave + 54: c3 ret + 55: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000060 : + +int strcmp(const char *p, const char *q) { + 60: 55 push %ebp + 61: 89 e5 mov %esp,%ebp + 63: 53 push %ebx + 64: 8b 55 08 mov 0x8(%ebp),%edx + 67: 8b 4d 0c mov 0xc(%ebp),%ecx + while (*p && *p == *q) { + 6a: 0f b6 02 movzbl (%edx),%eax + 6d: 84 c0 test %al,%al + 6f: 75 17 jne 88 + 71: eb 3a jmp ad + 73: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 77: 90 nop + 78: 0f b6 42 01 movzbl 0x1(%edx),%eax + p++, q++; + 7c: 83 c2 01 add $0x1,%edx + 7f: 8d 59 01 lea 0x1(%ecx),%ebx + while (*p && *p == *q) { + 82: 84 c0 test %al,%al + 84: 74 1a je a0 + p++, q++; + 86: 89 d9 mov %ebx,%ecx + while (*p && *p == *q) { + 88: 0f b6 19 movzbl (%ecx),%ebx + 8b: 38 c3 cmp %al,%bl + 8d: 74 e9 je 78 + } + return (uchar) * p - (uchar) * q; + 8f: 29 d8 sub %ebx,%eax +} + 91: 8b 5d fc mov -0x4(%ebp),%ebx + 94: c9 leave + 95: c3 ret + 96: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 9d: 8d 76 00 lea 0x0(%esi),%esi + return (uchar) * p - (uchar) * q; + a0: 0f b6 59 01 movzbl 0x1(%ecx),%ebx + a4: 31 c0 xor %eax,%eax + a6: 29 d8 sub %ebx,%eax +} + a8: 8b 5d fc mov -0x4(%ebp),%ebx + ab: c9 leave + ac: c3 ret + return (uchar) * p - (uchar) * q; + ad: 0f b6 19 movzbl (%ecx),%ebx + b0: 31 c0 xor %eax,%eax + b2: eb db jmp 8f + b4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bf: 90 nop + +000000c0 : + +uint strlen(const char *s) { + c0: 55 push %ebp + c1: 89 e5 mov %esp,%ebp + c3: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + for (n = 0; s[n]; n++) { + c6: 80 3a 00 cmpb $0x0,(%edx) + c9: 74 15 je e0 + cb: 31 c0 xor %eax,%eax + cd: 8d 76 00 lea 0x0(%esi),%esi + d0: 83 c0 01 add $0x1,%eax + d3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) + d7: 89 c1 mov %eax,%ecx + d9: 75 f5 jne d0 + ; + } + return n; +} + db: 89 c8 mov %ecx,%eax + dd: 5d pop %ebp + de: c3 ret + df: 90 nop + for (n = 0; s[n]; n++) { + e0: 31 c9 xor %ecx,%ecx +} + e2: 5d pop %ebp + e3: 89 c8 mov %ecx,%eax + e5: c3 ret + e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ed: 8d 76 00 lea 0x0(%esi),%esi + +000000f0 : + +void* memset(void *dst, int c, uint n) { + f0: 55 push %ebp + f1: 89 e5 mov %esp,%ebp + f3: 57 push %edi + f4: 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" : + f7: 8b 4d 10 mov 0x10(%ebp),%ecx + fa: 8b 45 0c mov 0xc(%ebp),%eax + fd: 89 d7 mov %edx,%edi + ff: fc cld + 100: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 102: 8b 7d fc mov -0x4(%ebp),%edi + 105: 89 d0 mov %edx,%eax + 107: c9 leave + 108: c3 ret + 109: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00000110 : + +char* strchr(const char *s, char c) { + 110: 55 push %ebp + 111: 89 e5 mov %esp,%ebp + 113: 8b 45 08 mov 0x8(%ebp),%eax + 116: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx + for (; *s; s++) { + 11a: 0f b6 10 movzbl (%eax),%edx + 11d: 84 d2 test %dl,%dl + 11f: 75 12 jne 133 + 121: eb 1d jmp 140 + 123: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 127: 90 nop + 128: 0f b6 50 01 movzbl 0x1(%eax),%edx + 12c: 83 c0 01 add $0x1,%eax + 12f: 84 d2 test %dl,%dl + 131: 74 0d je 140 + if (*s == c) { + 133: 38 d1 cmp %dl,%cl + 135: 75 f1 jne 128 + return (char*)s; + } + } + return 0; +} + 137: 5d pop %ebp + 138: c3 ret + 139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 140: 31 c0 xor %eax,%eax +} + 142: 5d pop %ebp + 143: c3 ret + 144: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 14b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 14f: 90 nop + +00000150 : + +char* gets(char *buf, int max) { + 150: 55 push %ebp + 151: 89 e5 mov %esp,%ebp + 153: 57 push %edi + 154: 56 push %esi + int i, cc; + char c; + + for (i = 0; i + 1 < max;) { + cc = read(0, &c, 1); + 155: 8d 7d e7 lea -0x19(%ebp),%edi +char* gets(char *buf, int max) { + 158: 53 push %ebx + for (i = 0; i + 1 < max;) { + 159: 31 db xor %ebx,%ebx +char* gets(char *buf, int max) { + 15b: 83 ec 1c sub $0x1c,%esp + for (i = 0; i + 1 < max;) { + 15e: eb 27 jmp 187 + cc = read(0, &c, 1); + 160: 83 ec 04 sub $0x4,%esp + 163: 6a 01 push $0x1 + 165: 57 push %edi + 166: 6a 00 push $0x0 + 168: e8 2e 01 00 00 call 29b + if (cc < 1) { + 16d: 83 c4 10 add $0x10,%esp + 170: 85 c0 test %eax,%eax + 172: 7e 1d jle 191 + break; + } + buf[i++] = c; + 174: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + 178: 8b 55 08 mov 0x8(%ebp),%edx + 17b: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if (c == '\n' || c == '\r') { + 17f: 3c 0a cmp $0xa,%al + 181: 74 1d je 1a0 + 183: 3c 0d cmp $0xd,%al + 185: 74 19 je 1a0 + for (i = 0; i + 1 < max;) { + 187: 89 de mov %ebx,%esi + 189: 83 c3 01 add $0x1,%ebx + 18c: 3b 5d 0c cmp 0xc(%ebp),%ebx + 18f: 7c cf jl 160 + break; + } + } + buf[i] = '\0'; + 191: 8b 45 08 mov 0x8(%ebp),%eax + 194: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 198: 8d 65 f4 lea -0xc(%ebp),%esp + 19b: 5b pop %ebx + 19c: 5e pop %esi + 19d: 5f pop %edi + 19e: 5d pop %ebp + 19f: c3 ret + buf[i] = '\0'; + 1a0: 8b 45 08 mov 0x8(%ebp),%eax + 1a3: 89 de mov %ebx,%esi + 1a5: c6 04 30 00 movb $0x0,(%eax,%esi,1) +} + 1a9: 8d 65 f4 lea -0xc(%ebp),%esp + 1ac: 5b pop %ebx + 1ad: 5e pop %esi + 1ae: 5f pop %edi + 1af: 5d pop %ebp + 1b0: c3 ret + 1b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1bf: 90 nop + +000001c0 : + +int stat(const char *n, struct stat *st) { + 1c0: 55 push %ebp + 1c1: 89 e5 mov %esp,%ebp + 1c3: 56 push %esi + 1c4: 53 push %ebx + int fd; + int r; + + fd = open(n, O_RDONLY); + 1c5: 83 ec 08 sub $0x8,%esp + 1c8: 6a 00 push $0x0 + 1ca: ff 75 08 push 0x8(%ebp) + 1cd: e8 19 01 00 00 call 2eb + if (fd < 0) { + 1d2: 83 c4 10 add $0x10,%esp + 1d5: 85 c0 test %eax,%eax + 1d7: 78 27 js 200 + return -1; + } + r = fstat(fd, st); + 1d9: 83 ec 08 sub $0x8,%esp + 1dc: ff 75 0c push 0xc(%ebp) + 1df: 89 c3 mov %eax,%ebx + 1e1: 50 push %eax + 1e2: e8 cc 00 00 00 call 2b3 + close(fd); + 1e7: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1ea: 89 c6 mov %eax,%esi + close(fd); + 1ec: e8 2a 01 00 00 call 31b + return r; + 1f1: 83 c4 10 add $0x10,%esp +} + 1f4: 8d 65 f8 lea -0x8(%ebp),%esp + 1f7: 89 f0 mov %esi,%eax + 1f9: 5b pop %ebx + 1fa: 5e pop %esi + 1fb: 5d pop %ebp + 1fc: c3 ret + 1fd: 8d 76 00 lea 0x0(%esi),%esi + return -1; + 200: be ff ff ff ff mov $0xffffffff,%esi + 205: eb ed jmp 1f4 + 207: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 20e: 66 90 xchg %ax,%ax + +00000210 : + +int atoi(const char *s) { + 210: 55 push %ebp + 211: 89 e5 mov %esp,%ebp + 213: 53 push %ebx + 214: 8b 55 08 mov 0x8(%ebp),%edx + int n; + + n = 0; + while ('0' <= *s && *s <= '9') { + 217: 0f be 02 movsbl (%edx),%eax + 21a: 8d 48 d0 lea -0x30(%eax),%ecx + 21d: 80 f9 09 cmp $0x9,%cl + n = 0; + 220: b9 00 00 00 00 mov $0x0,%ecx + while ('0' <= *s && *s <= '9') { + 225: 77 1e ja 245 + 227: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 22e: 66 90 xchg %ax,%ax + n = n * 10 + *s++ - '0'; + 230: 83 c2 01 add $0x1,%edx + 233: 8d 0c 89 lea (%ecx,%ecx,4),%ecx + 236: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx + while ('0' <= *s && *s <= '9') { + 23a: 0f be 02 movsbl (%edx),%eax + 23d: 8d 58 d0 lea -0x30(%eax),%ebx + 240: 80 fb 09 cmp $0x9,%bl + 243: 76 eb jbe 230 + } + return n; +} + 245: 8b 5d fc mov -0x4(%ebp),%ebx + 248: 89 c8 mov %ecx,%eax + 24a: c9 leave + 24b: c3 ret + 24c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00000250 : + +void* memmove(void *vdst, const void *vsrc, int n) { + 250: 55 push %ebp + 251: 89 e5 mov %esp,%ebp + 253: 57 push %edi + 254: 8b 45 10 mov 0x10(%ebp),%eax + 257: 8b 55 08 mov 0x8(%ebp),%edx + 25a: 56 push %esi + 25b: 8b 75 0c mov 0xc(%ebp),%esi + char *dst; + const char *src; + + dst = vdst; + src = vsrc; + while (n-- > 0) { + 25e: 85 c0 test %eax,%eax + 260: 7e 13 jle 275 + 262: 01 d0 add %edx,%eax + dst = vdst; + 264: 89 d7 mov %edx,%edi + 266: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 26d: 8d 76 00 lea 0x0(%esi),%esi + *dst++ = *src++; + 270: a4 movsb %ds:(%esi),%es:(%edi) + while (n-- > 0) { + 271: 39 f8 cmp %edi,%eax + 273: 75 fb jne 270 + } + return vdst; +} + 275: 5e pop %esi + 276: 89 d0 mov %edx,%eax + 278: 5f pop %edi + 279: 5d pop %ebp + 27a: c3 ret + +0000027b : +name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 27b: b8 01 00 00 00 mov $0x1,%eax + 280: cd 40 int $0x40 + 282: c3 ret + +00000283 : +SYSCALL(exit) + 283: b8 02 00 00 00 mov $0x2,%eax + 288: cd 40 int $0x40 + 28a: c3 ret + +0000028b : +SYSCALL(wait) + 28b: b8 03 00 00 00 mov $0x3,%eax + 290: cd 40 int $0x40 + 292: c3 ret + +00000293 : +SYSCALL(pipe) + 293: b8 04 00 00 00 mov $0x4,%eax + 298: cd 40 int $0x40 + 29a: c3 ret + +0000029b : +SYSCALL(read) + 29b: b8 05 00 00 00 mov $0x5,%eax + 2a0: cd 40 int $0x40 + 2a2: c3 ret + +000002a3 : +SYSCALL(kill) + 2a3: b8 06 00 00 00 mov $0x6,%eax + 2a8: cd 40 int $0x40 + 2aa: c3 ret + +000002ab : +SYSCALL(exec) + 2ab: b8 07 00 00 00 mov $0x7,%eax + 2b0: cd 40 int $0x40 + 2b2: c3 ret + +000002b3 : +SYSCALL(fstat) + 2b3: b8 08 00 00 00 mov $0x8,%eax + 2b8: cd 40 int $0x40 + 2ba: c3 ret + +000002bb : +SYSCALL(chdir) + 2bb: b8 09 00 00 00 mov $0x9,%eax + 2c0: cd 40 int $0x40 + 2c2: c3 ret + +000002c3 : +SYSCALL(dup) + 2c3: b8 0a 00 00 00 mov $0xa,%eax + 2c8: cd 40 int $0x40 + 2ca: c3 ret + +000002cb : +SYSCALL(getpid) + 2cb: b8 0b 00 00 00 mov $0xb,%eax + 2d0: cd 40 int $0x40 + 2d2: c3 ret + +000002d3 : +SYSCALL(sbrk) + 2d3: b8 0c 00 00 00 mov $0xc,%eax + 2d8: cd 40 int $0x40 + 2da: c3 ret + +000002db : +SYSCALL(sleep) + 2db: b8 0d 00 00 00 mov $0xd,%eax + 2e0: cd 40 int $0x40 + 2e2: c3 ret + +000002e3 : +SYSCALL(uptime) + 2e3: b8 0e 00 00 00 mov $0xe,%eax + 2e8: cd 40 int $0x40 + 2ea: c3 ret + +000002eb : +SYSCALL(open) + 2eb: b8 0f 00 00 00 mov $0xf,%eax + 2f0: cd 40 int $0x40 + 2f2: c3 ret + +000002f3 : +SYSCALL(write) + 2f3: b8 10 00 00 00 mov $0x10,%eax + 2f8: cd 40 int $0x40 + 2fa: c3 ret + +000002fb : +SYSCALL(mknod) + 2fb: b8 11 00 00 00 mov $0x11,%eax + 300: cd 40 int $0x40 + 302: c3 ret + +00000303 : +SYSCALL(unlink) + 303: b8 12 00 00 00 mov $0x12,%eax + 308: cd 40 int $0x40 + 30a: c3 ret + +0000030b : +SYSCALL(link) + 30b: b8 13 00 00 00 mov $0x13,%eax + 310: cd 40 int $0x40 + 312: c3 ret + +00000313 : +SYSCALL(mkdir) + 313: b8 14 00 00 00 mov $0x14,%eax + 318: cd 40 int $0x40 + 31a: c3 ret + +0000031b : +SYSCALL(close) + 31b: b8 15 00 00 00 mov $0x15,%eax + 320: cd 40 int $0x40 + 322: c3 ret + +00000323 : +SYSCALL(getch) + 323: b8 16 00 00 00 mov $0x16,%eax + 328: cd 40 int $0x40 + 32a: c3 ret + +0000032b : +SYSCALL(greeting) + 32b: b8 17 00 00 00 mov $0x17,%eax + 330: cd 40 int $0x40 + 332: c3 ret + +00000333 : +SYSCALL(shutdown) + 333: b8 18 00 00 00 mov $0x18,%eax + 338: cd 40 int $0x40 + 33a: c3 ret + +0000033b : +SYSCALL(screen) + 33b: b8 19 00 00 00 mov $0x19,%eax + 340: cd 40 int $0x40 + 342: c3 ret + +00000343 : +SYSCALL(cls) + 343: b8 1a 00 00 00 mov $0x1a,%eax + 348: cd 40 int $0x40 + 34a: c3 ret + 34b: 66 90 xchg %ax,%ax + 34d: 66 90 xchg %ax,%ax + 34f: 90 nop + +00000350 : + +static void putc(int fd, char c) { + write(fd, &c, 1); +} + +static void printint(int fd, int xx, int base, int sgn) { + 350: 55 push %ebp + 351: 89 e5 mov %esp,%ebp + 353: 57 push %edi + 354: 56 push %esi + 355: 53 push %ebx + 356: 83 ec 3c sub $0x3c,%esp + 359: 89 4d c4 mov %ecx,-0x3c(%ebp) + uint x; + + neg = 0; + if (sgn && xx < 0) { + neg = 1; + x = -xx; + 35c: 89 d1 mov %edx,%ecx +static void printint(int fd, int xx, int base, int sgn) { + 35e: 89 45 b8 mov %eax,-0x48(%ebp) + if (sgn && xx < 0) { + 361: 85 d2 test %edx,%edx + 363: 0f 89 7f 00 00 00 jns 3e8 + 369: f6 45 08 01 testb $0x1,0x8(%ebp) + 36d: 74 79 je 3e8 + neg = 1; + 36f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) + x = -xx; + 376: f7 d9 neg %ecx + } + else { + x = xx; + } + + i = 0; + 378: 31 db xor %ebx,%ebx + 37a: 8d 75 d7 lea -0x29(%ebp),%esi + 37d: 8d 76 00 lea 0x0(%esi),%esi + do { + buf[i++] = digits[x % base]; + 380: 89 c8 mov %ecx,%eax + 382: 31 d2 xor %edx,%edx + 384: 89 cf mov %ecx,%edi + 386: f7 75 c4 divl -0x3c(%ebp) + 389: 0f b6 92 88 07 00 00 movzbl 0x788(%edx),%edx + 390: 89 45 c0 mov %eax,-0x40(%ebp) + 393: 89 d8 mov %ebx,%eax + 395: 8d 5b 01 lea 0x1(%ebx),%ebx + } + while ((x /= base) != 0); + 398: 8b 4d c0 mov -0x40(%ebp),%ecx + buf[i++] = digits[x % base]; + 39b: 88 14 1e mov %dl,(%esi,%ebx,1) + while ((x /= base) != 0); + 39e: 39 7d c4 cmp %edi,-0x3c(%ebp) + 3a1: 76 dd jbe 380 + if (neg) { + 3a3: 8b 4d bc mov -0x44(%ebp),%ecx + 3a6: 85 c9 test %ecx,%ecx + 3a8: 74 0c je 3b6 + buf[i++] = '-'; + 3aa: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) + buf[i++] = digits[x % base]; + 3af: 89 d8 mov %ebx,%eax + buf[i++] = '-'; + 3b1: ba 2d 00 00 00 mov $0x2d,%edx + } + + while (--i >= 0) { + 3b6: 8b 7d b8 mov -0x48(%ebp),%edi + 3b9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx + 3bd: eb 07 jmp 3c6 + 3bf: 90 nop + putc(fd, buf[i]); + 3c0: 0f b6 13 movzbl (%ebx),%edx + 3c3: 83 eb 01 sub $0x1,%ebx + write(fd, &c, 1); + 3c6: 83 ec 04 sub $0x4,%esp + 3c9: 88 55 d7 mov %dl,-0x29(%ebp) + 3cc: 6a 01 push $0x1 + 3ce: 56 push %esi + 3cf: 57 push %edi + 3d0: e8 1e ff ff ff call 2f3 + while (--i >= 0) { + 3d5: 83 c4 10 add $0x10,%esp + 3d8: 39 de cmp %ebx,%esi + 3da: 75 e4 jne 3c0 + } +} + 3dc: 8d 65 f4 lea -0xc(%ebp),%esp + 3df: 5b pop %ebx + 3e0: 5e pop %esi + 3e1: 5f pop %edi + 3e2: 5d pop %ebp + 3e3: c3 ret + 3e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + neg = 0; + 3e8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) + 3ef: eb 87 jmp 378 + 3f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 3ff: 90 nop + +00000400 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void printf(int fd, const char *fmt, ...) { + 400: 55 push %ebp + 401: 89 e5 mov %esp,%ebp + 403: 57 push %edi + 404: 56 push %esi + 405: 53 push %ebx + 406: 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++) { + 409: 8b 5d 0c mov 0xc(%ebp),%ebx +void printf(int fd, const char *fmt, ...) { + 40c: 8b 75 08 mov 0x8(%ebp),%esi + for (i = 0; fmt[i]; i++) { + 40f: 0f b6 13 movzbl (%ebx),%edx + 412: 84 d2 test %dl,%dl + 414: 74 6a je 480 + ap = (uint*)(void*)&fmt + 1; + 416: 8d 45 10 lea 0x10(%ebp),%eax + 419: 83 c3 01 add $0x1,%ebx + write(fd, &c, 1); + 41c: 8d 7d e7 lea -0x19(%ebp),%edi + state = 0; + 41f: 31 c9 xor %ecx,%ecx + ap = (uint*)(void*)&fmt + 1; + 421: 89 45 d0 mov %eax,-0x30(%ebp) + 424: eb 36 jmp 45c + 426: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 42d: 8d 76 00 lea 0x0(%esi),%esi + 430: 89 4d d4 mov %ecx,-0x2c(%ebp) + c = fmt[i] & 0xff; + if (state == 0) { + if (c == '%') { + state = '%'; + 433: b9 25 00 00 00 mov $0x25,%ecx + if (c == '%') { + 438: 83 f8 25 cmp $0x25,%eax + 43b: 74 15 je 452 + write(fd, &c, 1); + 43d: 83 ec 04 sub $0x4,%esp + 440: 88 55 e7 mov %dl,-0x19(%ebp) + 443: 6a 01 push $0x1 + 445: 57 push %edi + 446: 56 push %esi + 447: e8 a7 fe ff ff call 2f3 + 44c: 8b 4d d4 mov -0x2c(%ebp),%ecx + } + else { + putc(fd, c); + 44f: 83 c4 10 add $0x10,%esp + for (i = 0; fmt[i]; i++) { + 452: 0f b6 13 movzbl (%ebx),%edx + 455: 83 c3 01 add $0x1,%ebx + 458: 84 d2 test %dl,%dl + 45a: 74 24 je 480 + c = fmt[i] & 0xff; + 45c: 0f b6 c2 movzbl %dl,%eax + if (state == 0) { + 45f: 85 c9 test %ecx,%ecx + 461: 74 cd je 430 + } + } + else if (state == '%') { + 463: 83 f9 25 cmp $0x25,%ecx + 466: 75 ea jne 452 + if (c == 'd') { + 468: 83 f8 25 cmp $0x25,%eax + 46b: 0f 84 07 01 00 00 je 578 + 471: 83 e8 63 sub $0x63,%eax + 474: 83 f8 15 cmp $0x15,%eax + 477: 77 17 ja 490 + 479: ff 24 85 30 07 00 00 jmp *0x730(,%eax,4) + putc(fd, c); + } + state = 0; + } + } +} + 480: 8d 65 f4 lea -0xc(%ebp),%esp + 483: 5b pop %ebx + 484: 5e pop %esi + 485: 5f pop %edi + 486: 5d pop %ebp + 487: c3 ret + 488: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 48f: 90 nop + write(fd, &c, 1); + 490: 83 ec 04 sub $0x4,%esp + 493: 88 55 d4 mov %dl,-0x2c(%ebp) + 496: 6a 01 push $0x1 + 498: 57 push %edi + 499: 56 push %esi + 49a: c6 45 e7 25 movb $0x25,-0x19(%ebp) + 49e: e8 50 fe ff ff call 2f3 + putc(fd, c); + 4a3: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx + write(fd, &c, 1); + 4a7: 83 c4 0c add $0xc,%esp + 4aa: 88 55 e7 mov %dl,-0x19(%ebp) + 4ad: 6a 01 push $0x1 + 4af: 57 push %edi + 4b0: 56 push %esi + 4b1: e8 3d fe ff ff call 2f3 + putc(fd, c); + 4b6: 83 c4 10 add $0x10,%esp + state = 0; + 4b9: 31 c9 xor %ecx,%ecx + 4bb: eb 95 jmp 452 + 4bd: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 4c0: 83 ec 0c sub $0xc,%esp + 4c3: b9 10 00 00 00 mov $0x10,%ecx + 4c8: 6a 00 push $0x0 + 4ca: 8b 45 d0 mov -0x30(%ebp),%eax + 4cd: 8b 10 mov (%eax),%edx + 4cf: 89 f0 mov %esi,%eax + 4d1: e8 7a fe ff ff call 350 + ap++; + 4d6: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 4da: 83 c4 10 add $0x10,%esp + state = 0; + 4dd: 31 c9 xor %ecx,%ecx + 4df: e9 6e ff ff ff jmp 452 + 4e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 4e8: 8b 45 d0 mov -0x30(%ebp),%eax + 4eb: 8b 10 mov (%eax),%edx + ap++; + 4ed: 83 c0 04 add $0x4,%eax + 4f0: 89 45 d0 mov %eax,-0x30(%ebp) + if (s == 0) { + 4f3: 85 d2 test %edx,%edx + 4f5: 0f 84 8d 00 00 00 je 588 + while (*s != 0) { + 4fb: 0f b6 02 movzbl (%edx),%eax + state = 0; + 4fe: 31 c9 xor %ecx,%ecx + while (*s != 0) { + 500: 84 c0 test %al,%al + 502: 0f 84 4a ff ff ff je 452 + 508: 89 5d d4 mov %ebx,-0x2c(%ebp) + 50b: 89 d3 mov %edx,%ebx + 50d: 8d 76 00 lea 0x0(%esi),%esi + write(fd, &c, 1); + 510: 83 ec 04 sub $0x4,%esp + s++; + 513: 83 c3 01 add $0x1,%ebx + 516: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 519: 6a 01 push $0x1 + 51b: 57 push %edi + 51c: 56 push %esi + 51d: e8 d1 fd ff ff call 2f3 + while (*s != 0) { + 522: 0f b6 03 movzbl (%ebx),%eax + 525: 83 c4 10 add $0x10,%esp + 528: 84 c0 test %al,%al + 52a: 75 e4 jne 510 + state = 0; + 52c: 8b 5d d4 mov -0x2c(%ebp),%ebx + 52f: 31 c9 xor %ecx,%ecx + 531: e9 1c ff ff ff jmp 452 + 536: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 53d: 8d 76 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 540: 83 ec 0c sub $0xc,%esp + 543: b9 0a 00 00 00 mov $0xa,%ecx + 548: 6a 01 push $0x1 + 54a: e9 7b ff ff ff jmp 4ca + 54f: 90 nop + putc(fd, *ap); + 550: 8b 45 d0 mov -0x30(%ebp),%eax + write(fd, &c, 1); + 553: 83 ec 04 sub $0x4,%esp + putc(fd, *ap); + 556: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 558: 6a 01 push $0x1 + 55a: 57 push %edi + 55b: 56 push %esi + putc(fd, *ap); + 55c: 88 45 e7 mov %al,-0x19(%ebp) + write(fd, &c, 1); + 55f: e8 8f fd ff ff call 2f3 + ap++; + 564: 83 45 d0 04 addl $0x4,-0x30(%ebp) + 568: 83 c4 10 add $0x10,%esp + state = 0; + 56b: 31 c9 xor %ecx,%ecx + 56d: e9 e0 fe ff ff jmp 452 + 572: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + putc(fd, c); + 578: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 57b: 83 ec 04 sub $0x4,%esp + 57e: e9 2a ff ff ff jmp 4ad + 583: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 587: 90 nop + s = "(null)"; + 588: ba 28 07 00 00 mov $0x728,%edx + while (*s != 0) { + 58d: 89 5d d4 mov %ebx,-0x2c(%ebp) + 590: b8 28 00 00 00 mov $0x28,%eax + 595: 89 d3 mov %edx,%ebx + 597: e9 74 ff ff ff jmp 510 + 59c: 66 90 xchg %ax,%ax + 59e: 66 90 xchg %ax,%ax + +000005a0 : +typedef union header Header; + +static Header base; +static Header *freep; + +void free(void *ap) { + 5a0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5a1: a1 30 0a 00 00 mov 0xa30,%eax +void free(void *ap) { + 5a6: 89 e5 mov %esp,%ebp + 5a8: 57 push %edi + 5a9: 56 push %esi + 5aa: 53 push %ebx + 5ab: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = (Header*)ap - 1; + 5ae: 8d 4b f8 lea -0x8(%ebx),%ecx + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { + 5b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 5b8: 89 c2 mov %eax,%edx + 5ba: 8b 00 mov (%eax),%eax + 5bc: 39 ca cmp %ecx,%edx + 5be: 73 30 jae 5f0 + 5c0: 39 c1 cmp %eax,%ecx + 5c2: 72 04 jb 5c8 + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5c4: 39 c2 cmp %eax,%edx + 5c6: 72 f0 jb 5b8 + break; + } + } + if (bp + bp->s.size == p->s.ptr) { + 5c8: 8b 73 fc mov -0x4(%ebx),%esi + 5cb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5ce: 39 f8 cmp %edi,%eax + 5d0: 74 30 je 602 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + 5d2: 89 43 f8 mov %eax,-0x8(%ebx) + } + else { + bp->s.ptr = p->s.ptr; + } + if (p + p->s.size == bp) { + 5d5: 8b 42 04 mov 0x4(%edx),%eax + 5d8: 8d 34 c2 lea (%edx,%eax,8),%esi + 5db: 39 f1 cmp %esi,%ecx + 5dd: 74 3a je 619 + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + 5df: 89 0a mov %ecx,(%edx) + } + else { + p->s.ptr = bp; + } + freep = p; +} + 5e1: 5b pop %ebx + freep = p; + 5e2: 89 15 30 0a 00 00 mov %edx,0xa30 +} + 5e8: 5e pop %esi + 5e9: 5f pop %edi + 5ea: 5d pop %ebp + 5eb: c3 ret + 5ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) { + 5f0: 39 c2 cmp %eax,%edx + 5f2: 72 c4 jb 5b8 + 5f4: 39 c1 cmp %eax,%ecx + 5f6: 73 c0 jae 5b8 + if (bp + bp->s.size == p->s.ptr) { + 5f8: 8b 73 fc mov -0x4(%ebx),%esi + 5fb: 8d 3c f1 lea (%ecx,%esi,8),%edi + 5fe: 39 f8 cmp %edi,%eax + 600: 75 d0 jne 5d2 + bp->s.size += p->s.ptr->s.size; + 602: 03 70 04 add 0x4(%eax),%esi + 605: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 608: 8b 02 mov (%edx),%eax + 60a: 8b 00 mov (%eax),%eax + 60c: 89 43 f8 mov %eax,-0x8(%ebx) + if (p + p->s.size == bp) { + 60f: 8b 42 04 mov 0x4(%edx),%eax + 612: 8d 34 c2 lea (%edx,%eax,8),%esi + 615: 39 f1 cmp %esi,%ecx + 617: 75 c6 jne 5df + p->s.size += bp->s.size; + 619: 03 43 fc add -0x4(%ebx),%eax + freep = p; + 61c: 89 15 30 0a 00 00 mov %edx,0xa30 + p->s.size += bp->s.size; + 622: 89 42 04 mov %eax,0x4(%edx) + p->s.ptr = bp->s.ptr; + 625: 8b 4b f8 mov -0x8(%ebx),%ecx + 628: 89 0a mov %ecx,(%edx) +} + 62a: 5b pop %ebx + 62b: 5e pop %esi + 62c: 5f pop %edi + 62d: 5d pop %ebp + 62e: c3 ret + 62f: 90 nop + +00000630 : + hp->s.size = nu; + free((void*)(hp + 1)); + return freep; +} + +void* malloc(uint nbytes) { + 630: 55 push %ebp + 631: 89 e5 mov %esp,%ebp + 633: 57 push %edi + 634: 56 push %esi + 635: 53 push %ebx + 636: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 639: 8b 45 08 mov 0x8(%ebp),%eax + if ((prevp = freep) == 0) { + 63c: 8b 3d 30 0a 00 00 mov 0xa30,%edi + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + 642: 8d 70 07 lea 0x7(%eax),%esi + 645: c1 ee 03 shr $0x3,%esi + 648: 83 c6 01 add $0x1,%esi + if ((prevp = freep) == 0) { + 64b: 85 ff test %edi,%edi + 64d: 0f 84 9d 00 00 00 je 6f0 + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 653: 8b 17 mov (%edi),%edx + if (p->s.size >= nunits) { + 655: 8b 4a 04 mov 0x4(%edx),%ecx + 658: 39 f1 cmp %esi,%ecx + 65a: 73 6a jae 6c6 + 65c: bb 00 10 00 00 mov $0x1000,%ebx + 661: 39 de cmp %ebx,%esi + 663: 0f 43 de cmovae %esi,%ebx + p = sbrk(nu * sizeof(Header)); + 666: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax + 66d: 89 45 e4 mov %eax,-0x1c(%ebp) + 670: eb 17 jmp 689 + 672: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 678: 8b 02 mov (%edx),%eax + if (p->s.size >= nunits) { + 67a: 8b 48 04 mov 0x4(%eax),%ecx + 67d: 39 f1 cmp %esi,%ecx + 67f: 73 4f jae 6d0 + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if (p == freep) { + 681: 8b 3d 30 0a 00 00 mov 0xa30,%edi + 687: 89 c2 mov %eax,%edx + 689: 39 d7 cmp %edx,%edi + 68b: 75 eb jne 678 + p = sbrk(nu * sizeof(Header)); + 68d: 83 ec 0c sub $0xc,%esp + 690: ff 75 e4 push -0x1c(%ebp) + 693: e8 3b fc ff ff call 2d3 + if (p == (char*)-1) { + 698: 83 c4 10 add $0x10,%esp + 69b: 83 f8 ff cmp $0xffffffff,%eax + 69e: 74 1c je 6bc + hp->s.size = nu; + 6a0: 89 58 04 mov %ebx,0x4(%eax) + free((void*)(hp + 1)); + 6a3: 83 ec 0c sub $0xc,%esp + 6a6: 83 c0 08 add $0x8,%eax + 6a9: 50 push %eax + 6aa: e8 f1 fe ff ff call 5a0 + return freep; + 6af: 8b 15 30 0a 00 00 mov 0xa30,%edx + if ((p = morecore(nunits)) == 0) { + 6b5: 83 c4 10 add $0x10,%esp + 6b8: 85 d2 test %edx,%edx + 6ba: 75 bc jne 678 + return 0; + } + } + } +} + 6bc: 8d 65 f4 lea -0xc(%ebp),%esp + return 0; + 6bf: 31 c0 xor %eax,%eax +} + 6c1: 5b pop %ebx + 6c2: 5e pop %esi + 6c3: 5f pop %edi + 6c4: 5d pop %ebp + 6c5: c3 ret + if (p->s.size >= nunits) { + 6c6: 89 d0 mov %edx,%eax + 6c8: 89 fa mov %edi,%edx + 6ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if (p->s.size == nunits) { + 6d0: 39 ce cmp %ecx,%esi + 6d2: 74 4c je 720 + p->s.size -= nunits; + 6d4: 29 f1 sub %esi,%ecx + 6d6: 89 48 04 mov %ecx,0x4(%eax) + p += p->s.size; + 6d9: 8d 04 c8 lea (%eax,%ecx,8),%eax + p->s.size = nunits; + 6dc: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 6df: 89 15 30 0a 00 00 mov %edx,0xa30 +} + 6e5: 8d 65 f4 lea -0xc(%ebp),%esp + return (void*)(p + 1); + 6e8: 83 c0 08 add $0x8,%eax +} + 6eb: 5b pop %ebx + 6ec: 5e pop %esi + 6ed: 5f pop %edi + 6ee: 5d pop %ebp + 6ef: c3 ret + base.s.ptr = freep = prevp = &base; + 6f0: c7 05 30 0a 00 00 34 movl $0xa34,0xa30 + 6f7: 0a 00 00 + base.s.size = 0; + 6fa: bf 34 0a 00 00 mov $0xa34,%edi + base.s.ptr = freep = prevp = &base; + 6ff: c7 05 34 0a 00 00 34 movl $0xa34,0xa34 + 706: 0a 00 00 + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + 709: 89 fa mov %edi,%edx + base.s.size = 0; + 70b: c7 05 38 0a 00 00 00 movl $0x0,0xa38 + 712: 00 00 00 + if (p->s.size >= nunits) { + 715: e9 42 ff ff ff jmp 65c + 71a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + prevp->s.ptr = p->s.ptr; + 720: 8b 08 mov (%eax),%ecx + 722: 89 0a mov %ecx,(%edx) + 724: eb b9 jmp 6df diff --git a/zombie.d b/zombie.d new file mode 100644 index 0000000..c3e36f5 --- /dev/null +++ b/zombie.d @@ -0,0 +1 @@ +zombie.o: zombie.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/zombie.o b/zombie.o new file mode 100644 index 0000000..db656c2 Binary files /dev/null and b/zombie.o differ diff --git a/zombie.sym b/zombie.sym new file mode 100644 index 0000000..f32a1f7 --- /dev/null +++ b/zombie.sym @@ -0,0 +1,50 @@ +00000000 zombie.c +00000000 ulib.c +00000000 printf.c +00000350 printint +00000788 digits.0 +00000000 umalloc.c +00000a30 freep +00000a34 base +00000030 strcpy +00000400 printf +0000032b greeting +00000250 memmove +000002fb mknod +00000150 gets +000002cb getpid +0000033b screen +00000630 malloc +000002db sleep +00000293 pipe +00000323 getch +000002f3 write +000002b3 fstat +000002a3 kill +000002bb chdir +000002ab exec +0000028b wait +0000029b read +00000303 unlink +0000027b fork +000002d3 sbrk +000002e3 uptime +00000a30 __bss_start +000000f0 memset +00000000 main +00000060 strcmp +00000333 shutdown +000002c3 dup +000001c0 stat +00000a30 _edata +00000a3c _end +0000030b link +00000283 exit +00000210 atoi +00000343 cls +000000c0 strlen +000002eb open +00000110 strchr +00000313 mkdir +0000031b close +000005a0 free