mkdir.asm 37 KB

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