init.asm 38 KB

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