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