cat.asm 38 KB

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