stressfs.asm 39 KB

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