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