comparison uprogs/init.asm @ 0:c450faca55f4

Init
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 22 Oct 2017 18:25:39 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c450faca55f4
1
2 _init: file format elf32-littlearm
3
4
5 Disassembly of section .text:
6
7 00000000 <main>:
8
9 char *argv[] = { "sh", 0 };
10
11 int
12 main(void)
13 {
14 0: e92d4818 push {r3, r4, fp, lr}
15 int pid, wpid;
16
17 if(open("console", O_RDWR) < 0){
18 4: e3a01002 mov r1, #2
19
20 char *argv[] = { "sh", 0 };
21
22 int
23 main(void)
24 {
25 8: e28db00c add fp, sp, #12
26 int pid, wpid;
27
28 if(open("console", O_RDWR) < 0){
29 c: e59f00a4 ldr r0, [pc, #164] ; b8 <main+0xb8>
30 10: eb00013f bl 514 <open>
31 14: e3500000 cmp r0, #0
32 18: ba00001e blt 98 <main+0x98>
33 mknod("console", 1, 1);
34 open("console", O_RDWR);
35 }
36 dup(0); // stdout
37 1c: e3a00000 mov r0, #0
38 20: eb000196 bl 680 <dup>
39 dup(0); // stderr
40 24: e3a00000 mov r0, #0
41 28: eb000194 bl 680 <dup>
42
43 for(;;){
44 printf(1, "init: starting sh\n");
45 2c: e3a00001 mov r0, #1
46 30: e59f1084 ldr r1, [pc, #132] ; bc <main+0xbc>
47 34: eb000221 bl 8c0 <printf>
48 pid = fork();
49 38: eb0000c0 bl 340 <fork>
50 if(pid < 0){
51 3c: e2504000 subs r4, r0, #0
52 40: ba000009 blt 6c <main+0x6c>
53 printf(1, "init: fork failed\n");
54 exit();
55 }
56 if(pid == 0){
57 44: 0a00000c beq 7c <main+0x7c>
58 exec("sh", argv);
59 printf(1, "init: exec sh failed\n");
60 exit();
61 }
62 while((wpid=wait()) >= 0 && wpid != pid)
63 48: eb0000d6 bl 3a8 <wait>
64 4c: e3500000 cmp r0, #0
65 50: bafffff5 blt 2c <main+0x2c>
66 54: e1500004 cmp r0, r4
67 58: 0afffff3 beq 2c <main+0x2c>
68 printf(1, "zombie!\n");
69 5c: e3a00001 mov r0, #1
70 60: e59f1058 ldr r1, [pc, #88] ; c0 <main+0xc0>
71 64: eb000215 bl 8c0 <printf>
72 68: eafffff6 b 48 <main+0x48>
73
74 for(;;){
75 printf(1, "init: starting sh\n");
76 pid = fork();
77 if(pid < 0){
78 printf(1, "init: fork failed\n");
79 6c: e3a00001 mov r0, #1
80 70: e59f104c ldr r1, [pc, #76] ; c4 <main+0xc4>
81 74: eb000211 bl 8c0 <printf>
82 exit();
83 78: eb0000bd bl 374 <exit>
84 }
85 if(pid == 0){
86 exec("sh", argv);
87 7c: e59f1044 ldr r1, [pc, #68] ; c8 <main+0xc8>
88 80: e59f0044 ldr r0, [pc, #68] ; cc <main+0xcc>
89 84: eb000115 bl 4e0 <exec>
90 printf(1, "init: exec sh failed\n");
91 88: e3a00001 mov r0, #1
92 8c: e59f103c ldr r1, [pc, #60] ; d0 <main+0xd0>
93 90: eb00020a bl 8c0 <printf>
94 exit();
95 94: eb0000b6 bl 374 <exit>
96 main(void)
97 {
98 int pid, wpid;
99
100 if(open("console", O_RDWR) < 0){
101 mknod("console", 1, 1);
102 98: e3a01001 mov r1, #1
103 9c: e1a02001 mov r2, r1
104 a0: e59f0010 ldr r0, [pc, #16] ; b8 <main+0xb8>
105 a4: eb000127 bl 548 <mknod>
106 open("console", O_RDWR);
107 a8: e3a01002 mov r1, #2
108 ac: e59f0004 ldr r0, [pc, #4] ; b8 <main+0xb8>
109 b0: eb000117 bl 514 <open>
110 b4: eaffffd8 b 1c <main+0x1c>
111 b8: 00000ba8 .word 0x00000ba8
112 bc: 00000bb0 .word 0x00000bb0
113 c0: 00000bf4 .word 0x00000bf4
114 c4: 00000bc4 .word 0x00000bc4
115 c8: 00000c1c .word 0x00000c1c
116 cc: 00000bd8 .word 0x00000bd8
117 d0: 00000bdc .word 0x00000bdc
118
119 000000d4 <strcpy>:
120 #include "user.h"
121 #include "arm.h"
122
123 char*
124 strcpy(char *s, char *t)
125 {
126 d4: e52db004 push {fp} ; (str fp, [sp, #-4]!)
127 char *os;
128
129 os = s;
130 while((*s++ = *t++) != 0)
131 d8: e1a02000 mov r2, r0
132 #include "user.h"
133 #include "arm.h"
134
135 char*
136 strcpy(char *s, char *t)
137 {
138 dc: e28db000 add fp, sp, #0
139 char *os;
140
141 os = s;
142 while((*s++ = *t++) != 0)
143 e0: e4d13001 ldrb r3, [r1], #1
144 e4: e3530000 cmp r3, #0
145 e8: e4c23001 strb r3, [r2], #1
146 ec: 1afffffb bne e0 <strcpy+0xc>
147 ;
148 return os;
149 }
150 f0: e28bd000 add sp, fp, #0
151 f4: e8bd0800 pop {fp}
152 f8: e12fff1e bx lr
153
154 000000fc <strcmp>:
155
156 int
157 strcmp(const char *p, const char *q)
158 {
159 fc: e52db004 push {fp} ; (str fp, [sp, #-4]!)
160 100: e28db000 add fp, sp, #0
161 while(*p && *p == *q)
162 104: e5d03000 ldrb r3, [r0]
163 108: e5d12000 ldrb r2, [r1]
164 10c: e3530000 cmp r3, #0
165 110: 1a000004 bne 128 <strcmp+0x2c>
166 114: ea000005 b 130 <strcmp+0x34>
167 118: e5f03001 ldrb r3, [r0, #1]!
168 11c: e3530000 cmp r3, #0
169 120: 0a000006 beq 140 <strcmp+0x44>
170 124: e5f12001 ldrb r2, [r1, #1]!
171 128: e1530002 cmp r3, r2
172 12c: 0afffff9 beq 118 <strcmp+0x1c>
173 p++, q++;
174 return (uchar)*p - (uchar)*q;
175 }
176 130: e0620003 rsb r0, r2, r3
177 134: e28bd000 add sp, fp, #0
178 138: e8bd0800 pop {fp}
179 13c: e12fff1e bx lr
180 }
181
182 int
183 strcmp(const char *p, const char *q)
184 {
185 while(*p && *p == *q)
186 140: e5d12001 ldrb r2, [r1, #1]
187 144: eafffff9 b 130 <strcmp+0x34>
188
189 00000148 <strlen>:
190 return (uchar)*p - (uchar)*q;
191 }
192
193 uint
194 strlen(char *s)
195 {
196 148: e52db004 push {fp} ; (str fp, [sp, #-4]!)
197 14c: e28db000 add fp, sp, #0
198 int n;
199
200 for(n = 0; s[n]; n++)
201 150: e5d03000 ldrb r3, [r0]
202 154: e3530000 cmp r3, #0
203 158: 01a00003 moveq r0, r3
204 15c: 0a000006 beq 17c <strlen+0x34>
205 160: e1a02000 mov r2, r0
206 164: e3a03000 mov r3, #0
207 168: e5f21001 ldrb r1, [r2, #1]!
208 16c: e2833001 add r3, r3, #1
209 170: e1a00003 mov r0, r3
210 174: e3510000 cmp r1, #0
211 178: 1afffffa bne 168 <strlen+0x20>
212 ;
213 return n;
214 }
215 17c: e28bd000 add sp, fp, #0
216 180: e8bd0800 pop {fp}
217 184: e12fff1e bx lr
218
219 00000188 <memset>:
220 memset(void *dst, int c, uint n)
221 {
222 char *p=dst;
223 u32 rc=n;
224
225 while (rc-- > 0) *p++ = c;
226 188: e3520000 cmp r2, #0
227 return n;
228 }
229
230 void*
231 memset(void *dst, int c, uint n)
232 {
233 18c: e52db004 push {fp} ; (str fp, [sp, #-4]!)
234 190: e28db000 add fp, sp, #0
235 char *p=dst;
236 u32 rc=n;
237
238 while (rc-- > 0) *p++ = c;
239 194: 0a000006 beq 1b4 <memset+0x2c>
240 198: e6ef1071 uxtb r1, r1
241 19c: e1a03002 mov r3, r2
242 }
243
244 void*
245 memset(void *dst, int c, uint n)
246 {
247 char *p=dst;
248 1a0: e1a0c000 mov ip, r0
249 u32 rc=n;
250
251 while (rc-- > 0) *p++ = c;
252 1a4: e2533001 subs r3, r3, #1
253 1a8: e4cc1001 strb r1, [ip], #1
254 1ac: 1afffffc bne 1a4 <memset+0x1c>
255 1b0: e0800002 add r0, r0, r2
256 return (void *)p;
257 }
258 1b4: e28bd000 add sp, fp, #0
259 1b8: e8bd0800 pop {fp}
260 1bc: e12fff1e bx lr
261
262 000001c0 <strchr>:
263
264 char*
265 strchr(const char *s, char c)
266 {
267 1c0: e52db004 push {fp} ; (str fp, [sp, #-4]!)
268 1c4: e28db000 add fp, sp, #0
269 for(; *s; s++)
270 1c8: e5d03000 ldrb r3, [r0]
271 1cc: e3530000 cmp r3, #0
272 1d0: 1a000004 bne 1e8 <strchr+0x28>
273 1d4: ea000008 b 1fc <strchr+0x3c>
274 1d8: e5d03001 ldrb r3, [r0, #1]
275 1dc: e2800001 add r0, r0, #1
276 1e0: e3530000 cmp r3, #0
277 1e4: 0a000004 beq 1fc <strchr+0x3c>
278 if(*s == c)
279 1e8: e1530001 cmp r3, r1
280 1ec: 1afffff9 bne 1d8 <strchr+0x18>
281 return (char*)s;
282 return 0;
283 }
284 1f0: e28bd000 add sp, fp, #0
285 1f4: e8bd0800 pop {fp}
286 1f8: e12fff1e bx lr
287 strchr(const char *s, char c)
288 {
289 for(; *s; s++)
290 if(*s == c)
291 return (char*)s;
292 return 0;
293 1fc: e1a00003 mov r0, r3
294 200: eafffffa b 1f0 <strchr+0x30>
295
296 00000204 <gets>:
297 }
298
299 char*
300 gets(char *buf, int max)
301 {
302 204: e92d49f0 push {r4, r5, r6, r7, r8, fp, lr}
303 208: e28db018 add fp, sp, #24
304 20c: e24dd00c sub sp, sp, #12
305 210: e1a08000 mov r8, r0
306 214: e1a07001 mov r7, r1
307 int i, cc;
308 char c;
309
310 for(i=0; i+1 < max; ){
311 218: e1a06000 mov r6, r0
312 21c: e3a05000 mov r5, #0
313 220: ea000008 b 248 <gets+0x44>
314 cc = read(0, &c, 1);
315 224: eb000079 bl 410 <read>
316 if(cc < 1)
317 228: e3500000 cmp r0, #0
318 22c: da00000b ble 260 <gets+0x5c>
319 break;
320 buf[i++] = c;
321 230: e55b301d ldrb r3, [fp, #-29]
322 if(c == '\n' || c == '\r')
323 234: e1a05004 mov r5, r4
324 238: e353000a cmp r3, #10
325 23c: 1353000d cmpne r3, #13
326
327 for(i=0; i+1 < max; ){
328 cc = read(0, &c, 1);
329 if(cc < 1)
330 break;
331 buf[i++] = c;
332 240: e4c63001 strb r3, [r6], #1
333 if(c == '\n' || c == '\r')
334 244: 0a00000a beq 274 <gets+0x70>
335 {
336 int i, cc;
337 char c;
338
339 for(i=0; i+1 < max; ){
340 cc = read(0, &c, 1);
341 248: e3a02001 mov r2, #1
342 gets(char *buf, int max)
343 {
344 int i, cc;
345 char c;
346
347 for(i=0; i+1 < max; ){
348 24c: e0854002 add r4, r5, r2
349 250: e1540007 cmp r4, r7
350 cc = read(0, &c, 1);
351 254: e3a00000 mov r0, #0
352 258: e24b101d sub r1, fp, #29
353 gets(char *buf, int max)
354 {
355 int i, cc;
356 char c;
357
358 for(i=0; i+1 < max; ){
359 25c: bafffff0 blt 224 <gets+0x20>
360 break;
361 buf[i++] = c;
362 if(c == '\n' || c == '\r')
363 break;
364 }
365 buf[i] = '\0';
366 260: e3a03000 mov r3, #0
367 264: e7c83005 strb r3, [r8, r5]
368 return buf;
369 }
370 268: e1a00008 mov r0, r8
371 26c: e24bd018 sub sp, fp, #24
372 270: e8bd89f0 pop {r4, r5, r6, r7, r8, fp, pc}
373 gets(char *buf, int max)
374 {
375 int i, cc;
376 char c;
377
378 for(i=0; i+1 < max; ){
379 274: e1a05004 mov r5, r4
380 278: eafffff8 b 260 <gets+0x5c>
381
382 0000027c <stat>:
383 return buf;
384 }
385
386 int
387 stat(char *n, struct stat *st)
388 {
389 27c: e92d4830 push {r4, r5, fp, lr}
390 280: e1a05001 mov r5, r1
391 284: e28db00c add fp, sp, #12
392 int fd;
393 int r;
394
395 fd = open(n, O_RDONLY);
396 288: e3a01000 mov r1, #0
397 28c: eb0000a0 bl 514 <open>
398 if(fd < 0)
399 290: e2504000 subs r4, r0, #0
400 return -1;
401 294: b3e05000 mvnlt r5, #0
402 {
403 int fd;
404 int r;
405
406 fd = open(n, O_RDONLY);
407 if(fd < 0)
408 298: ba000004 blt 2b0 <stat+0x34>
409 return -1;
410 r = fstat(fd, st);
411 29c: e1a01005 mov r1, r5
412 2a0: eb0000c2 bl 5b0 <fstat>
413 2a4: e1a05000 mov r5, r0
414 close(fd);
415 2a8: e1a00004 mov r0, r4
416 2ac: eb000071 bl 478 <close>
417 return r;
418 }
419 2b0: e1a00005 mov r0, r5
420 2b4: e8bd8830 pop {r4, r5, fp, pc}
421
422 000002b8 <atoi>:
423
424 int
425 atoi(const char *s)
426 {
427 2b8: e52db004 push {fp} ; (str fp, [sp, #-4]!)
428 2bc: e28db000 add fp, sp, #0
429 int n;
430
431 n = 0;
432 while('0' <= *s && *s <= '9')
433 2c0: e5d03000 ldrb r3, [r0]
434 2c4: e2432030 sub r2, r3, #48 ; 0x30
435 2c8: e6ef2072 uxtb r2, r2
436 2cc: e3520009 cmp r2, #9
437 int
438 atoi(const char *s)
439 {
440 int n;
441
442 n = 0;
443 2d0: 83a00000 movhi r0, #0
444 while('0' <= *s && *s <= '9')
445 2d4: 8a000009 bhi 300 <atoi+0x48>
446 2d8: e1a02000 mov r2, r0
447 int
448 atoi(const char *s)
449 {
450 int n;
451
452 n = 0;
453 2dc: e3a00000 mov r0, #0
454 while('0' <= *s && *s <= '9')
455 n = n*10 + *s++ - '0';
456 2e0: e0800100 add r0, r0, r0, lsl #2
457 2e4: e0830080 add r0, r3, r0, lsl #1
458 atoi(const char *s)
459 {
460 int n;
461
462 n = 0;
463 while('0' <= *s && *s <= '9')
464 2e8: e5f23001 ldrb r3, [r2, #1]!
465 n = n*10 + *s++ - '0';
466 2ec: e2400030 sub r0, r0, #48 ; 0x30
467 atoi(const char *s)
468 {
469 int n;
470
471 n = 0;
472 while('0' <= *s && *s <= '9')
473 2f0: e2431030 sub r1, r3, #48 ; 0x30
474 2f4: e6ef1071 uxtb r1, r1
475 2f8: e3510009 cmp r1, #9
476 2fc: 9afffff7 bls 2e0 <atoi+0x28>
477 n = n*10 + *s++ - '0';
478 return n;
479 }
480 300: e28bd000 add sp, fp, #0
481 304: e8bd0800 pop {fp}
482 308: e12fff1e bx lr
483
484 0000030c <memmove>:
485 {
486 char *dst, *src;
487
488 dst = vdst;
489 src = vsrc;
490 while(n-- > 0)
491 30c: e3520000 cmp r2, #0
492 return n;
493 }
494
495 void*
496 memmove(void *vdst, void *vsrc, int n)
497 {
498 310: e52db004 push {fp} ; (str fp, [sp, #-4]!)
499 314: e28db000 add fp, sp, #0
500 char *dst, *src;
501
502 dst = vdst;
503 src = vsrc;
504 while(n-- > 0)
505 318: da000005 ble 334 <memmove+0x28>
506 n = n*10 + *s++ - '0';
507 return n;
508 }
509
510 void*
511 memmove(void *vdst, void *vsrc, int n)
512 31c: e0802002 add r2, r0, r2
513 {
514 char *dst, *src;
515
516 dst = vdst;
517 320: e1a03000 mov r3, r0
518 src = vsrc;
519 while(n-- > 0)
520 *dst++ = *src++;
521 324: e4d1c001 ldrb ip, [r1], #1
522 328: e4c3c001 strb ip, [r3], #1
523 {
524 char *dst, *src;
525
526 dst = vdst;
527 src = vsrc;
528 while(n-- > 0)
529 32c: e1530002 cmp r3, r2
530 330: 1afffffb bne 324 <memmove+0x18>
531 *dst++ = *src++;
532 return vdst;
533 }
534 334: e28bd000 add sp, fp, #0
535 338: e8bd0800 pop {fp}
536 33c: e12fff1e bx lr
537
538 00000340 <fork>:
539 340: e92d4000 push {lr}
540 344: e92d0008 push {r3}
541 348: e92d0004 push {r2}
542 34c: e92d0002 push {r1}
543 350: e92d0001 push {r0}
544 354: e3a00001 mov r0, #1
545 358: ef000040 svc 0x00000040
546 35c: e8bd0002 pop {r1}
547 360: e8bd0002 pop {r1}
548 364: e8bd0004 pop {r2}
549 368: e8bd0008 pop {r3}
550 36c: e8bd4000 pop {lr}
551 370: e12fff1e bx lr
552
553 00000374 <exit>:
554 374: e92d4000 push {lr}
555 378: e92d0008 push {r3}
556 37c: e92d0004 push {r2}
557 380: e92d0002 push {r1}
558 384: e92d0001 push {r0}
559 388: e3a00002 mov r0, #2
560 38c: ef000040 svc 0x00000040
561 390: e8bd0002 pop {r1}
562 394: e8bd0002 pop {r1}
563 398: e8bd0004 pop {r2}
564 39c: e8bd0008 pop {r3}
565 3a0: e8bd4000 pop {lr}
566 3a4: e12fff1e bx lr
567
568 000003a8 <wait>:
569 3a8: e92d4000 push {lr}
570 3ac: e92d0008 push {r3}
571 3b0: e92d0004 push {r2}
572 3b4: e92d0002 push {r1}
573 3b8: e92d0001 push {r0}
574 3bc: e3a00003 mov r0, #3
575 3c0: ef000040 svc 0x00000040
576 3c4: e8bd0002 pop {r1}
577 3c8: e8bd0002 pop {r1}
578 3cc: e8bd0004 pop {r2}
579 3d0: e8bd0008 pop {r3}
580 3d4: e8bd4000 pop {lr}
581 3d8: e12fff1e bx lr
582
583 000003dc <pipe>:
584 3dc: e92d4000 push {lr}
585 3e0: e92d0008 push {r3}
586 3e4: e92d0004 push {r2}
587 3e8: e92d0002 push {r1}
588 3ec: e92d0001 push {r0}
589 3f0: e3a00004 mov r0, #4
590 3f4: ef000040 svc 0x00000040
591 3f8: e8bd0002 pop {r1}
592 3fc: e8bd0002 pop {r1}
593 400: e8bd0004 pop {r2}
594 404: e8bd0008 pop {r3}
595 408: e8bd4000 pop {lr}
596 40c: e12fff1e bx lr
597
598 00000410 <read>:
599 410: e92d4000 push {lr}
600 414: e92d0008 push {r3}
601 418: e92d0004 push {r2}
602 41c: e92d0002 push {r1}
603 420: e92d0001 push {r0}
604 424: e3a00005 mov r0, #5
605 428: ef000040 svc 0x00000040
606 42c: e8bd0002 pop {r1}
607 430: e8bd0002 pop {r1}
608 434: e8bd0004 pop {r2}
609 438: e8bd0008 pop {r3}
610 43c: e8bd4000 pop {lr}
611 440: e12fff1e bx lr
612
613 00000444 <write>:
614 444: e92d4000 push {lr}
615 448: e92d0008 push {r3}
616 44c: e92d0004 push {r2}
617 450: e92d0002 push {r1}
618 454: e92d0001 push {r0}
619 458: e3a00010 mov r0, #16
620 45c: ef000040 svc 0x00000040
621 460: e8bd0002 pop {r1}
622 464: e8bd0002 pop {r1}
623 468: e8bd0004 pop {r2}
624 46c: e8bd0008 pop {r3}
625 470: e8bd4000 pop {lr}
626 474: e12fff1e bx lr
627
628 00000478 <close>:
629 478: e92d4000 push {lr}
630 47c: e92d0008 push {r3}
631 480: e92d0004 push {r2}
632 484: e92d0002 push {r1}
633 488: e92d0001 push {r0}
634 48c: e3a00015 mov r0, #21
635 490: ef000040 svc 0x00000040
636 494: e8bd0002 pop {r1}
637 498: e8bd0002 pop {r1}
638 49c: e8bd0004 pop {r2}
639 4a0: e8bd0008 pop {r3}
640 4a4: e8bd4000 pop {lr}
641 4a8: e12fff1e bx lr
642
643 000004ac <kill>:
644 4ac: e92d4000 push {lr}
645 4b0: e92d0008 push {r3}
646 4b4: e92d0004 push {r2}
647 4b8: e92d0002 push {r1}
648 4bc: e92d0001 push {r0}
649 4c0: e3a00006 mov r0, #6
650 4c4: ef000040 svc 0x00000040
651 4c8: e8bd0002 pop {r1}
652 4cc: e8bd0002 pop {r1}
653 4d0: e8bd0004 pop {r2}
654 4d4: e8bd0008 pop {r3}
655 4d8: e8bd4000 pop {lr}
656 4dc: e12fff1e bx lr
657
658 000004e0 <exec>:
659 4e0: e92d4000 push {lr}
660 4e4: e92d0008 push {r3}
661 4e8: e92d0004 push {r2}
662 4ec: e92d0002 push {r1}
663 4f0: e92d0001 push {r0}
664 4f4: e3a00007 mov r0, #7
665 4f8: ef000040 svc 0x00000040
666 4fc: e8bd0002 pop {r1}
667 500: e8bd0002 pop {r1}
668 504: e8bd0004 pop {r2}
669 508: e8bd0008 pop {r3}
670 50c: e8bd4000 pop {lr}
671 510: e12fff1e bx lr
672
673 00000514 <open>:
674 514: e92d4000 push {lr}
675 518: e92d0008 push {r3}
676 51c: e92d0004 push {r2}
677 520: e92d0002 push {r1}
678 524: e92d0001 push {r0}
679 528: e3a0000f mov r0, #15
680 52c: ef000040 svc 0x00000040
681 530: e8bd0002 pop {r1}
682 534: e8bd0002 pop {r1}
683 538: e8bd0004 pop {r2}
684 53c: e8bd0008 pop {r3}
685 540: e8bd4000 pop {lr}
686 544: e12fff1e bx lr
687
688 00000548 <mknod>:
689 548: e92d4000 push {lr}
690 54c: e92d0008 push {r3}
691 550: e92d0004 push {r2}
692 554: e92d0002 push {r1}
693 558: e92d0001 push {r0}
694 55c: e3a00011 mov r0, #17
695 560: ef000040 svc 0x00000040
696 564: e8bd0002 pop {r1}
697 568: e8bd0002 pop {r1}
698 56c: e8bd0004 pop {r2}
699 570: e8bd0008 pop {r3}
700 574: e8bd4000 pop {lr}
701 578: e12fff1e bx lr
702
703 0000057c <unlink>:
704 57c: e92d4000 push {lr}
705 580: e92d0008 push {r3}
706 584: e92d0004 push {r2}
707 588: e92d0002 push {r1}
708 58c: e92d0001 push {r0}
709 590: e3a00012 mov r0, #18
710 594: ef000040 svc 0x00000040
711 598: e8bd0002 pop {r1}
712 59c: e8bd0002 pop {r1}
713 5a0: e8bd0004 pop {r2}
714 5a4: e8bd0008 pop {r3}
715 5a8: e8bd4000 pop {lr}
716 5ac: e12fff1e bx lr
717
718 000005b0 <fstat>:
719 5b0: e92d4000 push {lr}
720 5b4: e92d0008 push {r3}
721 5b8: e92d0004 push {r2}
722 5bc: e92d0002 push {r1}
723 5c0: e92d0001 push {r0}
724 5c4: e3a00008 mov r0, #8
725 5c8: ef000040 svc 0x00000040
726 5cc: e8bd0002 pop {r1}
727 5d0: e8bd0002 pop {r1}
728 5d4: e8bd0004 pop {r2}
729 5d8: e8bd0008 pop {r3}
730 5dc: e8bd4000 pop {lr}
731 5e0: e12fff1e bx lr
732
733 000005e4 <link>:
734 5e4: e92d4000 push {lr}
735 5e8: e92d0008 push {r3}
736 5ec: e92d0004 push {r2}
737 5f0: e92d0002 push {r1}
738 5f4: e92d0001 push {r0}
739 5f8: e3a00013 mov r0, #19
740 5fc: ef000040 svc 0x00000040
741 600: e8bd0002 pop {r1}
742 604: e8bd0002 pop {r1}
743 608: e8bd0004 pop {r2}
744 60c: e8bd0008 pop {r3}
745 610: e8bd4000 pop {lr}
746 614: e12fff1e bx lr
747
748 00000618 <mkdir>:
749 618: e92d4000 push {lr}
750 61c: e92d0008 push {r3}
751 620: e92d0004 push {r2}
752 624: e92d0002 push {r1}
753 628: e92d0001 push {r0}
754 62c: e3a00014 mov r0, #20
755 630: ef000040 svc 0x00000040
756 634: e8bd0002 pop {r1}
757 638: e8bd0002 pop {r1}
758 63c: e8bd0004 pop {r2}
759 640: e8bd0008 pop {r3}
760 644: e8bd4000 pop {lr}
761 648: e12fff1e bx lr
762
763 0000064c <chdir>:
764 64c: e92d4000 push {lr}
765 650: e92d0008 push {r3}
766 654: e92d0004 push {r2}
767 658: e92d0002 push {r1}
768 65c: e92d0001 push {r0}
769 660: e3a00009 mov r0, #9
770 664: ef000040 svc 0x00000040
771 668: e8bd0002 pop {r1}
772 66c: e8bd0002 pop {r1}
773 670: e8bd0004 pop {r2}
774 674: e8bd0008 pop {r3}
775 678: e8bd4000 pop {lr}
776 67c: e12fff1e bx lr
777
778 00000680 <dup>:
779 680: e92d4000 push {lr}
780 684: e92d0008 push {r3}
781 688: e92d0004 push {r2}
782 68c: e92d0002 push {r1}
783 690: e92d0001 push {r0}
784 694: e3a0000a mov r0, #10
785 698: ef000040 svc 0x00000040
786 69c: e8bd0002 pop {r1}
787 6a0: e8bd0002 pop {r1}
788 6a4: e8bd0004 pop {r2}
789 6a8: e8bd0008 pop {r3}
790 6ac: e8bd4000 pop {lr}
791 6b0: e12fff1e bx lr
792
793 000006b4 <getpid>:
794 6b4: e92d4000 push {lr}
795 6b8: e92d0008 push {r3}
796 6bc: e92d0004 push {r2}
797 6c0: e92d0002 push {r1}
798 6c4: e92d0001 push {r0}
799 6c8: e3a0000b mov r0, #11
800 6cc: ef000040 svc 0x00000040
801 6d0: e8bd0002 pop {r1}
802 6d4: e8bd0002 pop {r1}
803 6d8: e8bd0004 pop {r2}
804 6dc: e8bd0008 pop {r3}
805 6e0: e8bd4000 pop {lr}
806 6e4: e12fff1e bx lr
807
808 000006e8 <sbrk>:
809 6e8: e92d4000 push {lr}
810 6ec: e92d0008 push {r3}
811 6f0: e92d0004 push {r2}
812 6f4: e92d0002 push {r1}
813 6f8: e92d0001 push {r0}
814 6fc: e3a0000c mov r0, #12
815 700: ef000040 svc 0x00000040
816 704: e8bd0002 pop {r1}
817 708: e8bd0002 pop {r1}
818 70c: e8bd0004 pop {r2}
819 710: e8bd0008 pop {r3}
820 714: e8bd4000 pop {lr}
821 718: e12fff1e bx lr
822
823 0000071c <sleep>:
824 71c: e92d4000 push {lr}
825 720: e92d0008 push {r3}
826 724: e92d0004 push {r2}
827 728: e92d0002 push {r1}
828 72c: e92d0001 push {r0}
829 730: e3a0000d mov r0, #13
830 734: ef000040 svc 0x00000040
831 738: e8bd0002 pop {r1}
832 73c: e8bd0002 pop {r1}
833 740: e8bd0004 pop {r2}
834 744: e8bd0008 pop {r3}
835 748: e8bd4000 pop {lr}
836 74c: e12fff1e bx lr
837
838 00000750 <uptime>:
839 750: e92d4000 push {lr}
840 754: e92d0008 push {r3}
841 758: e92d0004 push {r2}
842 75c: e92d0002 push {r1}
843 760: e92d0001 push {r0}
844 764: e3a0000e mov r0, #14
845 768: ef000040 svc 0x00000040
846 76c: e8bd0002 pop {r1}
847 770: e8bd0002 pop {r1}
848 774: e8bd0004 pop {r2}
849 778: e8bd0008 pop {r3}
850 77c: e8bd4000 pop {lr}
851 780: e12fff1e bx lr
852
853 00000784 <putc>:
854 #include "stat.h"
855 #include "user.h"
856
857 static void
858 putc(int fd, char c)
859 {
860 784: e92d4800 push {fp, lr}
861 788: e28db004 add fp, sp, #4
862 78c: e24b3004 sub r3, fp, #4
863 790: e24dd008 sub sp, sp, #8
864 write(fd, &c, 1);
865 794: e3a02001 mov r2, #1
866 #include "stat.h"
867 #include "user.h"
868
869 static void
870 putc(int fd, char c)
871 {
872 798: e5631001 strb r1, [r3, #-1]!
873 write(fd, &c, 1);
874 79c: e1a01003 mov r1, r3
875 7a0: ebffff27 bl 444 <write>
876 }
877 7a4: e24bd004 sub sp, fp, #4
878 7a8: e8bd8800 pop {fp, pc}
879
880 000007ac <printint>:
881 return q;
882 }
883
884 static void
885 printint(int fd, int xx, int base, int sgn)
886 {
887 7ac: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
888 7b0: e1a04000 mov r4, r0
889 char buf[16];
890 int i, neg;
891 uint x, y, b;
892
893 neg = 0;
894 if(sgn && xx < 0){
895 7b4: e1a00fa1 lsr r0, r1, #31
896 7b8: e3530000 cmp r3, #0
897 7bc: 03a03000 moveq r3, #0
898 7c0: 12003001 andne r3, r0, #1
899 return q;
900 }
901
902 static void
903 printint(int fd, int xx, int base, int sgn)
904 {
905 7c4: e28db020 add fp, sp, #32
906 char buf[16];
907 int i, neg;
908 uint x, y, b;
909
910 neg = 0;
911 if(sgn && xx < 0){
912 7c8: e3530000 cmp r3, #0
913 return q;
914 }
915
916 static void
917 printint(int fd, int xx, int base, int sgn)
918 {
919 7cc: e24dd014 sub sp, sp, #20
920 7d0: e59f909c ldr r9, [pc, #156] ; 874 <printint+0xc8>
921 uint x, y, b;
922
923 neg = 0;
924 if(sgn && xx < 0){
925 neg = 1;
926 x = -xx;
927 7d4: 12611000 rsbne r1, r1, #0
928 int i, neg;
929 uint x, y, b;
930
931 neg = 0;
932 if(sgn && xx < 0){
933 neg = 1;
934 7d8: 13a03001 movne r3, #1
935 } else {
936 x = xx;
937 }
938
939 b = base;
940 i = 0;
941 7dc: e3a0a000 mov sl, #0
942 7e0: e24b6034 sub r6, fp, #52 ; 0x34
943 for(i=31;i>=0;i--){
944 r = r << 1;
945 r = r | ((n >> i) & 1);
946 if(r >= d) {
947 r = r - d;
948 q = q | (1 << i);
949 7e4: e3a08001 mov r8, #1
950 write(fd, &c, 1);
951 }
952
953 u32 div(u32 n, u32 d) // long division
954 {
955 u32 q=0, r=0;
956 7e8: e3a07000 mov r7, #0
957 int i;
958
959 for(i=31;i>=0;i--){
960 7ec: e3a0001f mov r0, #31
961 write(fd, &c, 1);
962 }
963
964 u32 div(u32 n, u32 d) // long division
965 {
966 u32 q=0, r=0;
967 7f0: e1a0c007 mov ip, r7
968 int i;
969
970 for(i=31;i>=0;i--){
971 r = r << 1;
972 r = r | ((n >> i) & 1);
973 7f4: e1a0e031 lsr lr, r1, r0
974 7f8: e20ee001 and lr, lr, #1
975 7fc: e18ec08c orr ip, lr, ip, lsl #1
976 if(r >= d) {
977 800: e152000c cmp r2, ip
978 r = r - d;
979 q = q | (1 << i);
980 804: 91877018 orrls r7, r7, r8, lsl r0
981
982 for(i=31;i>=0;i--){
983 r = r << 1;
984 r = r | ((n >> i) & 1);
985 if(r >= d) {
986 r = r - d;
987 808: 9062c00c rsbls ip, r2, ip
988 u32 div(u32 n, u32 d) // long division
989 {
990 u32 q=0, r=0;
991 int i;
992
993 for(i=31;i>=0;i--){
994 80c: e2500001 subs r0, r0, #1
995 810: 2afffff7 bcs 7f4 <printint+0x48>
996
997 b = base;
998 i = 0;
999 do{
1000 y = div(x, b);
1001 buf[i++] = digits[x - y * b];
1002 814: e0000792 mul r0, r2, r7
1003 }while((x = y) != 0);
1004 818: e3570000 cmp r7, #0
1005
1006 b = base;
1007 i = 0;
1008 do{
1009 y = div(x, b);
1010 buf[i++] = digits[x - y * b];
1011 81c: e0601001 rsb r1, r0, r1
1012 820: e28a5001 add r5, sl, #1
1013 824: e7d91001 ldrb r1, [r9, r1]
1014 828: e7c6100a strb r1, [r6, sl]
1015 }while((x = y) != 0);
1016 82c: 11a01007 movne r1, r7
1017
1018 b = base;
1019 i = 0;
1020 do{
1021 y = div(x, b);
1022 buf[i++] = digits[x - y * b];
1023 830: 11a0a005 movne sl, r5
1024 834: 1affffeb bne 7e8 <printint+0x3c>
1025 }while((x = y) != 0);
1026 if(neg)
1027 838: e3530000 cmp r3, #0
1028 buf[i++] = '-';
1029 83c: 124b2024 subne r2, fp, #36 ; 0x24
1030 840: 10823005 addne r3, r2, r5
1031 844: 128a5002 addne r5, sl, #2
1032
1033 while(--i >= 0)
1034 848: e2455001 sub r5, r5, #1
1035 do{
1036 y = div(x, b);
1037 buf[i++] = digits[x - y * b];
1038 }while((x = y) != 0);
1039 if(neg)
1040 buf[i++] = '-';
1041 84c: 13a0202d movne r2, #45 ; 0x2d
1042 850: 15432010 strbne r2, [r3, #-16]
1043
1044 while(--i >= 0)
1045 putc(fd, buf[i]);
1046 854: e7d61005 ldrb r1, [r6, r5]
1047 858: e1a00004 mov r0, r4
1048 buf[i++] = digits[x - y * b];
1049 }while((x = y) != 0);
1050 if(neg)
1051 buf[i++] = '-';
1052
1053 while(--i >= 0)
1054 85c: e2455001 sub r5, r5, #1
1055 putc(fd, buf[i]);
1056 860: ebffffc7 bl 784 <putc>
1057 buf[i++] = digits[x - y * b];
1058 }while((x = y) != 0);
1059 if(neg)
1060 buf[i++] = '-';
1061
1062 while(--i >= 0)
1063 864: e3750001 cmn r5, #1
1064 868: 1afffff9 bne 854 <printint+0xa8>
1065 putc(fd, buf[i]);
1066 }
1067 86c: e24bd020 sub sp, fp, #32
1068 870: e8bd8ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, pc}
1069 874: 00000c00 .word 0x00000c00
1070
1071 00000878 <div>:
1072 write(fd, &c, 1);
1073 }
1074
1075 u32 div(u32 n, u32 d) // long division
1076 {
1077 u32 q=0, r=0;
1078 878: e3a03000 mov r3, #0
1079 {
1080 write(fd, &c, 1);
1081 }
1082
1083 u32 div(u32 n, u32 d) // long division
1084 {
1085 87c: e92d0830 push {r4, r5, fp}
1086 880: e1a02000 mov r2, r0
1087 884: e28db008 add fp, sp, #8
1088 u32 q=0, r=0;
1089 int i;
1090
1091 for(i=31;i>=0;i--){
1092 888: e3a0c01f mov ip, #31
1093 write(fd, &c, 1);
1094 }
1095
1096 u32 div(u32 n, u32 d) // long division
1097 {
1098 u32 q=0, r=0;
1099 88c: e1a00003 mov r0, r3
1100 for(i=31;i>=0;i--){
1101 r = r << 1;
1102 r = r | ((n >> i) & 1);
1103 if(r >= d) {
1104 r = r - d;
1105 q = q | (1 << i);
1106 890: e3a05001 mov r5, #1
1107 u32 q=0, r=0;
1108 int i;
1109
1110 for(i=31;i>=0;i--){
1111 r = r << 1;
1112 r = r | ((n >> i) & 1);
1113 894: e1a04c32 lsr r4, r2, ip
1114 898: e2044001 and r4, r4, #1
1115 89c: e1843083 orr r3, r4, r3, lsl #1
1116 if(r >= d) {
1117 8a0: e1530001 cmp r3, r1
1118 r = r - d;
1119 q = q | (1 << i);
1120 8a4: 21800c15 orrcs r0, r0, r5, lsl ip
1121
1122 for(i=31;i>=0;i--){
1123 r = r << 1;
1124 r = r | ((n >> i) & 1);
1125 if(r >= d) {
1126 r = r - d;
1127 8a8: 20613003 rsbcs r3, r1, r3
1128 u32 div(u32 n, u32 d) // long division
1129 {
1130 u32 q=0, r=0;
1131 int i;
1132
1133 for(i=31;i>=0;i--){
1134 8ac: e25cc001 subs ip, ip, #1
1135 8b0: 2afffff7 bcs 894 <div+0x1c>
1136 r = r - d;
1137 q = q | (1 << i);
1138 }
1139 }
1140 return q;
1141 }
1142 8b4: e24bd008 sub sp, fp, #8
1143 8b8: e8bd0830 pop {r4, r5, fp}
1144 8bc: e12fff1e bx lr
1145
1146 000008c0 <printf>:
1147 }
1148
1149 // Print to the given fd. Only understands %d, %x, %p, %s.
1150 void
1151 printf(int fd, char *fmt, ...)
1152 {
1153 8c0: e92d000e push {r1, r2, r3}
1154 8c4: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
1155 8c8: e28db020 add fp, sp, #32
1156 8cc: e1a05000 mov r5, r0
1157 int c, i, state;
1158 uint *ap;
1159
1160 state = 0;
1161 ap = (uint*)(void*)&fmt + 1;
1162 for(i = 0; fmt[i]; i++){
1163 8d0: e59b4004 ldr r4, [fp, #4]
1164 8d4: e5d48000 ldrb r8, [r4]
1165 8d8: e3580000 cmp r8, #0
1166 8dc: 0a000027 beq 980 <printf+0xc0>
1167 ap++;
1168 } else if(c == 's'){
1169 s = (char*)*ap;
1170 ap++;
1171 if(s == 0)
1172 s = "(null)";
1173 8e0: e59f712c ldr r7, [pc, #300] ; a14 <printf+0x154>
1174 char *s;
1175 int c, i, state;
1176 uint *ap;
1177
1178 state = 0;
1179 ap = (uint*)(void*)&fmt + 1;
1180 8e4: e28b6008 add r6, fp, #8
1181 {
1182 char *s;
1183 int c, i, state;
1184 uint *ap;
1185
1186 state = 0;
1187 8e8: e3a0a000 mov sl, #0
1188 8ec: ea000008 b 914 <printf+0x54>
1189 ap = (uint*)(void*)&fmt + 1;
1190 for(i = 0; fmt[i]; i++){
1191 c = fmt[i] & 0xff;
1192 if(state == 0){
1193 if(c == '%'){
1194 8f0: e3580025 cmp r8, #37 ; 0x25
1195 state = '%';
1196 8f4: 01a0a008 moveq sl, r8
1197 state = 0;
1198 ap = (uint*)(void*)&fmt + 1;
1199 for(i = 0; fmt[i]; i++){
1200 c = fmt[i] & 0xff;
1201 if(state == 0){
1202 if(c == '%'){
1203 8f8: 0a000002 beq 908 <printf+0x48>
1204 state = '%';
1205 } else {
1206 putc(fd, c);
1207 8fc: e1a00005 mov r0, r5
1208 900: e1a01008 mov r1, r8
1209 904: ebffff9e bl 784 <putc>
1210 int c, i, state;
1211 uint *ap;
1212
1213 state = 0;
1214 ap = (uint*)(void*)&fmt + 1;
1215 for(i = 0; fmt[i]; i++){
1216 908: e5f48001 ldrb r8, [r4, #1]!
1217 90c: e3580000 cmp r8, #0
1218 910: 0a00001a beq 980 <printf+0xc0>
1219 c = fmt[i] & 0xff;
1220 if(state == 0){
1221 914: e35a0000 cmp sl, #0
1222 918: 0afffff4 beq 8f0 <printf+0x30>
1223 if(c == '%'){
1224 state = '%';
1225 } else {
1226 putc(fd, c);
1227 }
1228 } else if(state == '%'){
1229 91c: e35a0025 cmp sl, #37 ; 0x25
1230 920: 1afffff8 bne 908 <printf+0x48>
1231 if(c == 'd'){
1232 924: e3580064 cmp r8, #100 ; 0x64
1233 928: 0a00002c beq 9e0 <printf+0x120>
1234 printint(fd, *ap, 10, 1);
1235 ap++;
1236 } else if(c == 'x' || c == 'p'){
1237 92c: e3580078 cmp r8, #120 ; 0x78
1238 930: 13580070 cmpne r8, #112 ; 0x70
1239 934: 13a09000 movne r9, #0
1240 938: 03a09001 moveq r9, #1
1241 93c: 0a000013 beq 990 <printf+0xd0>
1242 printint(fd, *ap, 16, 0);
1243 ap++;
1244 } else if(c == 's'){
1245 940: e3580073 cmp r8, #115 ; 0x73
1246 944: 0a000018 beq 9ac <printf+0xec>
1247 s = "(null)";
1248 while(*s != 0){
1249 putc(fd, *s);
1250 s++;
1251 }
1252 } else if(c == 'c'){
1253 948: e3580063 cmp r8, #99 ; 0x63
1254 94c: 0a00002a beq 9fc <printf+0x13c>
1255 putc(fd, *ap);
1256 ap++;
1257 } else if(c == '%'){
1258 950: e3580025 cmp r8, #37 ; 0x25
1259 putc(fd, c);
1260 954: e1a0100a mov r1, sl
1261 958: e1a00005 mov r0, r5
1262 s++;
1263 }
1264 } else if(c == 'c'){
1265 putc(fd, *ap);
1266 ap++;
1267 } else if(c == '%'){
1268 95c: 0a000002 beq 96c <printf+0xac>
1269 putc(fd, c);
1270 } else {
1271 // Unknown % sequence. Print it to draw attention.
1272 putc(fd, '%');
1273 960: ebffff87 bl 784 <putc>
1274 putc(fd, c);
1275 964: e1a00005 mov r0, r5
1276 968: e1a01008 mov r1, r8
1277 96c: ebffff84 bl 784 <putc>
1278 int c, i, state;
1279 uint *ap;
1280
1281 state = 0;
1282 ap = (uint*)(void*)&fmt + 1;
1283 for(i = 0; fmt[i]; i++){
1284 970: e5f48001 ldrb r8, [r4, #1]!
1285 } else {
1286 // Unknown % sequence. Print it to draw attention.
1287 putc(fd, '%');
1288 putc(fd, c);
1289 }
1290 state = 0;
1291 974: e1a0a009 mov sl, r9
1292 int c, i, state;
1293 uint *ap;
1294
1295 state = 0;
1296 ap = (uint*)(void*)&fmt + 1;
1297 for(i = 0; fmt[i]; i++){
1298 978: e3580000 cmp r8, #0
1299 97c: 1affffe4 bne 914 <printf+0x54>
1300 putc(fd, c);
1301 }
1302 state = 0;
1303 }
1304 }
1305 }
1306 980: e24bd020 sub sp, fp, #32
1307 984: e8bd4ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, lr}
1308 988: e28dd00c add sp, sp, #12
1309 98c: e12fff1e bx lr
1310 } else if(state == '%'){
1311 if(c == 'd'){
1312 printint(fd, *ap, 10, 1);
1313 ap++;
1314 } else if(c == 'x' || c == 'p'){
1315 printint(fd, *ap, 16, 0);
1316 990: e1a00005 mov r0, r5
1317 994: e4961004 ldr r1, [r6], #4
1318 998: e3a02010 mov r2, #16
1319 99c: e3a03000 mov r3, #0
1320 9a0: ebffff81 bl 7ac <printint>
1321 } else {
1322 // Unknown % sequence. Print it to draw attention.
1323 putc(fd, '%');
1324 putc(fd, c);
1325 }
1326 state = 0;
1327 9a4: e3a0a000 mov sl, #0
1328 9a8: eaffffd6 b 908 <printf+0x48>
1329 ap++;
1330 } else if(c == 'x' || c == 'p'){
1331 printint(fd, *ap, 16, 0);
1332 ap++;
1333 } else if(c == 's'){
1334 s = (char*)*ap;
1335 9ac: e4968004 ldr r8, [r6], #4
1336 ap++;
1337 if(s == 0)
1338 s = "(null)";
1339 9b0: e3580000 cmp r8, #0
1340 9b4: 01a08007 moveq r8, r7
1341 while(*s != 0){
1342 9b8: e5d81000 ldrb r1, [r8]
1343 9bc: e3510000 cmp r1, #0
1344 9c0: 0a000004 beq 9d8 <printf+0x118>
1345 putc(fd, *s);
1346 9c4: e1a00005 mov r0, r5
1347 9c8: ebffff6d bl 784 <putc>
1348 } else if(c == 's'){
1349 s = (char*)*ap;
1350 ap++;
1351 if(s == 0)
1352 s = "(null)";
1353 while(*s != 0){
1354 9cc: e5f81001 ldrb r1, [r8, #1]!
1355 9d0: e3510000 cmp r1, #0
1356 9d4: 1afffffa bne 9c4 <printf+0x104>
1357 } else {
1358 // Unknown % sequence. Print it to draw attention.
1359 putc(fd, '%');
1360 putc(fd, c);
1361 }
1362 state = 0;
1363 9d8: e1a0a001 mov sl, r1
1364 9dc: eaffffc9 b 908 <printf+0x48>
1365 } else {
1366 putc(fd, c);
1367 }
1368 } else if(state == '%'){
1369 if(c == 'd'){
1370 printint(fd, *ap, 10, 1);
1371 9e0: e1a00005 mov r0, r5
1372 9e4: e4961004 ldr r1, [r6], #4
1373 9e8: e3a0200a mov r2, #10
1374 9ec: e3a03001 mov r3, #1
1375 9f0: ebffff6d bl 7ac <printint>
1376 } else {
1377 // Unknown % sequence. Print it to draw attention.
1378 putc(fd, '%');
1379 putc(fd, c);
1380 }
1381 state = 0;
1382 9f4: e3a0a000 mov sl, #0
1383 9f8: eaffffc2 b 908 <printf+0x48>
1384 while(*s != 0){
1385 putc(fd, *s);
1386 s++;
1387 }
1388 } else if(c == 'c'){
1389 putc(fd, *ap);
1390 9fc: e4961004 ldr r1, [r6], #4
1391 a00: e1a00005 mov r0, r5
1392 } else {
1393 // Unknown % sequence. Print it to draw attention.
1394 putc(fd, '%');
1395 putc(fd, c);
1396 }
1397 state = 0;
1398 a04: e1a0a009 mov sl, r9
1399 while(*s != 0){
1400 putc(fd, *s);
1401 s++;
1402 }
1403 } else if(c == 'c'){
1404 putc(fd, *ap);
1405 a08: e6ef1071 uxtb r1, r1
1406 a0c: ebffff5c bl 784 <putc>
1407 a10: eaffffbc b 908 <printf+0x48>
1408 a14: 00000c14 .word 0x00000c14
1409
1410 00000a18 <free>:
1411 free(void *ap)
1412 {
1413 Header *bp, *p;
1414
1415 bp = (Header*)ap - 1;
1416 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1417 a18: e59f3098 ldr r3, [pc, #152] ; ab8 <free+0xa0>
1418 static Header base;
1419 static Header *freep;
1420
1421 void
1422 free(void *ap)
1423 {
1424 a1c: e92d0830 push {r4, r5, fp}
1425 Header *bp, *p;
1426
1427 bp = (Header*)ap - 1;
1428 a20: e240c008 sub ip, r0, #8
1429 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1430 a24: e5932000 ldr r2, [r3]
1431 static Header base;
1432 static Header *freep;
1433
1434 void
1435 free(void *ap)
1436 {
1437 a28: e28db008 add fp, sp, #8
1438 Header *bp, *p;
1439
1440 bp = (Header*)ap - 1;
1441 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1442 a2c: e152000c cmp r2, ip
1443 a30: e5921000 ldr r1, [r2]
1444 a34: 2a000001 bcs a40 <free+0x28>
1445 a38: e15c0001 cmp ip, r1
1446 a3c: 3a000007 bcc a60 <free+0x48>
1447 if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1448 a40: e1520001 cmp r2, r1
1449 a44: 3a000003 bcc a58 <free+0x40>
1450 a48: e152000c cmp r2, ip
1451 a4c: 3a000003 bcc a60 <free+0x48>
1452 a50: e15c0001 cmp ip, r1
1453 a54: 3a000001 bcc a60 <free+0x48>
1454 static Header base;
1455 static Header *freep;
1456
1457 void
1458 free(void *ap)
1459 {
1460 a58: e1a02001 mov r2, r1
1461 a5c: eafffff2 b a2c <free+0x14>
1462
1463 bp = (Header*)ap - 1;
1464 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1465 if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1466 break;
1467 if(bp + bp->s.size == p->s.ptr){
1468 a60: e5104004 ldr r4, [r0, #-4]
1469 if(p + p->s.size == bp){
1470 p->s.size += bp->s.size;
1471 p->s.ptr = bp->s.ptr;
1472 } else
1473 p->s.ptr = bp;
1474 freep = p;
1475 a64: e5832000 str r2, [r3]
1476
1477 bp = (Header*)ap - 1;
1478 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1479 if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1480 break;
1481 if(bp + bp->s.size == p->s.ptr){
1482 a68: e08c5184 add r5, ip, r4, lsl #3
1483 a6c: e1550001 cmp r5, r1
1484 bp->s.size += p->s.ptr->s.size;
1485 a70: 05911004 ldreq r1, [r1, #4]
1486 a74: 00814004 addeq r4, r1, r4
1487 a78: 05004004 streq r4, [r0, #-4]
1488 bp->s.ptr = p->s.ptr->s.ptr;
1489 a7c: 05921000 ldreq r1, [r2]
1490 a80: 05911000 ldreq r1, [r1]
1491 } else
1492 bp->s.ptr = p->s.ptr;
1493 a84: e5001008 str r1, [r0, #-8]
1494 if(p + p->s.size == bp){
1495 a88: e5921004 ldr r1, [r2, #4]
1496 a8c: e0824181 add r4, r2, r1, lsl #3
1497 a90: e15c0004 cmp ip, r4
1498 p->s.size += bp->s.size;
1499 p->s.ptr = bp->s.ptr;
1500 } else
1501 p->s.ptr = bp;
1502 a94: 1582c000 strne ip, [r2]
1503 bp->s.size += p->s.ptr->s.size;
1504 bp->s.ptr = p->s.ptr->s.ptr;
1505 } else
1506 bp->s.ptr = p->s.ptr;
1507 if(p + p->s.size == bp){
1508 p->s.size += bp->s.size;
1509 a98: 0510c004 ldreq ip, [r0, #-4]
1510 a9c: 008c1001 addeq r1, ip, r1
1511 aa0: 05821004 streq r1, [r2, #4]
1512 p->s.ptr = bp->s.ptr;
1513 aa4: 05101008 ldreq r1, [r0, #-8]
1514 aa8: 05821000 streq r1, [r2]
1515 } else
1516 p->s.ptr = bp;
1517 freep = p;
1518 }
1519 aac: e24bd008 sub sp, fp, #8
1520 ab0: e8bd0830 pop {r4, r5, fp}
1521 ab4: e12fff1e bx lr
1522 ab8: 00000c24 .word 0x00000c24
1523
1524 00000abc <malloc>:
1525 return freep;
1526 }
1527
1528 void*
1529 malloc(uint nbytes)
1530 {
1531 abc: e92d49f8 push {r3, r4, r5, r6, r7, r8, fp, lr}
1532 Header *p, *prevp;
1533 uint nunits;
1534
1535 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1536 ac0: e2804007 add r4, r0, #7
1537 if((prevp = freep) == 0){
1538 ac4: e59f50d4 ldr r5, [pc, #212] ; ba0 <malloc+0xe4>
1539 malloc(uint nbytes)
1540 {
1541 Header *p, *prevp;
1542 uint nunits;
1543
1544 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1545 ac8: e1a041a4 lsr r4, r4, #3
1546 return freep;
1547 }
1548
1549 void*
1550 malloc(uint nbytes)
1551 {
1552 acc: e28db01c add fp, sp, #28
1553 Header *p, *prevp;
1554 uint nunits;
1555
1556 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1557 if((prevp = freep) == 0){
1558 ad0: e5953000 ldr r3, [r5]
1559 malloc(uint nbytes)
1560 {
1561 Header *p, *prevp;
1562 uint nunits;
1563
1564 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1565 ad4: e2844001 add r4, r4, #1
1566 if((prevp = freep) == 0){
1567 ad8: e3530000 cmp r3, #0
1568 adc: 0a00002b beq b90 <malloc+0xd4>
1569 ae0: e5930000 ldr r0, [r3]
1570 ae4: e5902004 ldr r2, [r0, #4]
1571 base.s.ptr = freep = prevp = &base;
1572 base.s.size = 0;
1573 }
1574 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1575 if(p->s.size >= nunits){
1576 ae8: e1520004 cmp r2, r4
1577 aec: 2a00001b bcs b60 <malloc+0xa4>
1578 morecore(uint nu)
1579 {
1580 char *p;
1581 Header *hp;
1582
1583 if(nu < 4096)
1584 af0: e59f80ac ldr r8, [pc, #172] ; ba4 <malloc+0xe8>
1585 p->s.size -= nunits;
1586 p += p->s.size;
1587 p->s.size = nunits;
1588 }
1589 freep = prevp;
1590 return (void*)(p + 1);
1591 af4: e1a07184 lsl r7, r4, #3
1592 af8: ea000003 b b0c <malloc+0x50>
1593 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1594 if((prevp = freep) == 0){
1595 base.s.ptr = freep = prevp = &base;
1596 base.s.size = 0;
1597 }
1598 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1599 afc: e5930000 ldr r0, [r3]
1600 if(p->s.size >= nunits){
1601 b00: e5902004 ldr r2, [r0, #4]
1602 b04: e1540002 cmp r4, r2
1603 b08: 9a000014 bls b60 <malloc+0xa4>
1604 p->s.size = nunits;
1605 }
1606 freep = prevp;
1607 return (void*)(p + 1);
1608 }
1609 if(p == freep)
1610 b0c: e5952000 ldr r2, [r5]
1611 b10: e1a03000 mov r3, r0
1612 b14: e1500002 cmp r0, r2
1613 b18: 1afffff7 bne afc <malloc+0x40>
1614 morecore(uint nu)
1615 {
1616 char *p;
1617 Header *hp;
1618
1619 if(nu < 4096)
1620 b1c: e1540008 cmp r4, r8
1621 nu = 4096;
1622 p = sbrk(nu * sizeof(Header));
1623 b20: 81a00007 movhi r0, r7
1624 b24: 93a00902 movls r0, #32768 ; 0x8000
1625 morecore(uint nu)
1626 {
1627 char *p;
1628 Header *hp;
1629
1630 if(nu < 4096)
1631 b28: 81a06004 movhi r6, r4
1632 b2c: 93a06a01 movls r6, #4096 ; 0x1000
1633 nu = 4096;
1634 p = sbrk(nu * sizeof(Header));
1635 b30: ebfffeec bl 6e8 <sbrk>
1636 b34: e1a03000 mov r3, r0
1637 if(p == (char*)-1)
1638 b38: e3730001 cmn r3, #1
1639 return 0;
1640 hp = (Header*)p;
1641 hp->s.size = nu;
1642 free((void*)(hp + 1));
1643 b3c: e2800008 add r0, r0, #8
1644 Header *hp;
1645
1646 if(nu < 4096)
1647 nu = 4096;
1648 p = sbrk(nu * sizeof(Header));
1649 if(p == (char*)-1)
1650 b40: 0a000010 beq b88 <malloc+0xcc>
1651 return 0;
1652 hp = (Header*)p;
1653 hp->s.size = nu;
1654 b44: e5836004 str r6, [r3, #4]
1655 free((void*)(hp + 1));
1656 b48: ebffffb2 bl a18 <free>
1657 return freep;
1658 b4c: e5953000 ldr r3, [r5]
1659 }
1660 freep = prevp;
1661 return (void*)(p + 1);
1662 }
1663 if(p == freep)
1664 if((p = morecore(nunits)) == 0)
1665 b50: e3530000 cmp r3, #0
1666 b54: 1affffe8 bne afc <malloc+0x40>
1667 return 0;
1668 b58: e1a00003 mov r0, r3
1669 }
1670 }
1671 b5c: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
1672 base.s.ptr = freep = prevp = &base;
1673 base.s.size = 0;
1674 }
1675 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1676 if(p->s.size >= nunits){
1677 if(p->s.size == nunits)
1678 b60: e1540002 cmp r4, r2
1679 prevp->s.ptr = p->s.ptr;
1680 else {
1681 p->s.size -= nunits;
1682 b64: 10642002 rsbne r2, r4, r2
1683 b68: 15802004 strne r2, [r0, #4]
1684 base.s.size = 0;
1685 }
1686 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1687 if(p->s.size >= nunits){
1688 if(p->s.size == nunits)
1689 prevp->s.ptr = p->s.ptr;
1690 b6c: 05902000 ldreq r2, [r0]
1691 else {
1692 p->s.size -= nunits;
1693 p += p->s.size;
1694 b70: 10800182 addne r0, r0, r2, lsl #3
1695 base.s.size = 0;
1696 }
1697 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1698 if(p->s.size >= nunits){
1699 if(p->s.size == nunits)
1700 prevp->s.ptr = p->s.ptr;
1701 b74: 05832000 streq r2, [r3]
1702 else {
1703 p->s.size -= nunits;
1704 p += p->s.size;
1705 p->s.size = nunits;
1706 b78: 15804004 strne r4, [r0, #4]
1707 }
1708 freep = prevp;
1709 b7c: e5853000 str r3, [r5]
1710 return (void*)(p + 1);
1711 b80: e2800008 add r0, r0, #8
1712 b84: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
1713 }
1714 if(p == freep)
1715 if((p = morecore(nunits)) == 0)
1716 return 0;
1717 b88: e3a00000 mov r0, #0
1718 b8c: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
1719 Header *p, *prevp;
1720 uint nunits;
1721
1722 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1723 if((prevp = freep) == 0){
1724 base.s.ptr = freep = prevp = &base;
1725 b90: e2850004 add r0, r5, #4
1726 b94: e5850000 str r0, [r5]
1727 base.s.size = 0;
1728 b98: e9850009 stmib r5, {r0, r3}
1729 b9c: eaffffd3 b af0 <malloc+0x34>
1730 ba0: 00000c24 .word 0x00000c24
1731 ba4: 00000fff .word 0x00000fff