ln.asm 36 KB

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