zombie.asm 36 KB

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