grep.asm 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205
  1. _grep: file format elf32-littlearm
  2. Disassembly of section .text:
  3. 00000000 <main>:
  4. main(int argc, char *argv[])
  5. {
  6. int fd, i;
  7. char *pattern;
  8. if(argc <= 1){
  9. 0: e3500001 cmp r0, #1
  10. }
  11. }
  12. int
  13. main(int argc, char *argv[])
  14. {
  15. 4: e92d4df0 push {r4, r5, r6, r7, r8, sl, fp, lr}
  16. 8: e1a08000 mov r8, r0
  17. c: e28db01c add fp, sp, #28
  18. int fd, i;
  19. char *pattern;
  20. if(argc <= 1){
  21. 10: da00001d ble 8c <main+0x8c>
  22. printf(2, "usage: grep pattern [file ...]\n");
  23. exit();
  24. }
  25. pattern = argv[1];
  26. if(argc <= 2){
  27. 14: e3500002 cmp r0, #2
  28. if(argc <= 1){
  29. printf(2, "usage: grep pattern [file ...]\n");
  30. exit();
  31. }
  32. pattern = argv[1];
  33. 18: e591a004 ldr sl, [r1, #4]
  34. }
  35. }
  36. }
  37. int
  38. main(int argc, char *argv[])
  39. 1c: 12814008 addne r4, r1, #8
  40. 20: 13a05002 movne r5, #2
  41. printf(2, "usage: grep pattern [file ...]\n");
  42. exit();
  43. }
  44. pattern = argv[1];
  45. if(argc <= 2){
  46. 24: 0a000014 beq 7c <main+0x7c>
  47. grep(pattern, 0);
  48. exit();
  49. }
  50. for(i = 2; i < argc; i++){
  51. if((fd = open(argv[i], 0)) < 0){
  52. 28: e5940000 ldr r0, [r4]
  53. 2c: e3a01000 mov r1, #0
  54. 30: eb0001c7 bl 754 <open>
  55. 34: e1a07004 mov r7, r4
  56. 38: e2844004 add r4, r4, #4
  57. 3c: e2506000 subs r6, r0, #0
  58. 40: ba000008 blt 68 <main+0x68>
  59. printf(1, "grep: cannot open %s\n", argv[i]);
  60. exit();
  61. }
  62. grep(pattern, fd);
  63. 44: e1a01006 mov r1, r6
  64. 48: e1a0000a mov r0, sl
  65. 4c: eb00006f bl 210 <grep>
  66. if(argc <= 2){
  67. grep(pattern, 0);
  68. exit();
  69. }
  70. for(i = 2; i < argc; i++){
  71. 50: e2855001 add r5, r5, #1
  72. if((fd = open(argv[i], 0)) < 0){
  73. printf(1, "grep: cannot open %s\n", argv[i]);
  74. exit();
  75. }
  76. grep(pattern, fd);
  77. close(fd);
  78. 54: e1a00006 mov r0, r6
  79. 58: eb000196 bl 6b8 <close>
  80. if(argc <= 2){
  81. grep(pattern, 0);
  82. exit();
  83. }
  84. for(i = 2; i < argc; i++){
  85. 5c: e1580005 cmp r8, r5
  86. 60: cafffff0 bgt 28 <main+0x28>
  87. exit();
  88. }
  89. grep(pattern, fd);
  90. close(fd);
  91. }
  92. exit();
  93. 64: eb000152 bl 5b4 <exit>
  94. exit();
  95. }
  96. for(i = 2; i < argc; i++){
  97. if((fd = open(argv[i], 0)) < 0){
  98. printf(1, "grep: cannot open %s\n", argv[i]);
  99. 68: e3a00001 mov r0, #1
  100. 6c: e59f1028 ldr r1, [pc, #40] ; 9c <main+0x9c>
  101. 70: e5972000 ldr r2, [r7]
  102. 74: eb0002a1 bl b00 <printf>
  103. exit();
  104. 78: eb00014d bl 5b4 <exit>
  105. exit();
  106. }
  107. pattern = argv[1];
  108. if(argc <= 2){
  109. grep(pattern, 0);
  110. 7c: e1a0000a mov r0, sl
  111. 80: e3a01000 mov r1, #0
  112. 84: eb000061 bl 210 <grep>
  113. exit();
  114. 88: eb000149 bl 5b4 <exit>
  115. {
  116. int fd, i;
  117. char *pattern;
  118. if(argc <= 1){
  119. printf(2, "usage: grep pattern [file ...]\n");
  120. 8c: e3a00002 mov r0, #2
  121. 90: e59f1008 ldr r1, [pc, #8] ; a0 <main+0xa0>
  122. 94: eb000299 bl b00 <printf>
  123. exit();
  124. 98: eb000145 bl 5b4 <exit>
  125. 9c: 00000e08 .word 0x00000e08
  126. a0: 00000de8 .word 0x00000de8
  127. 000000a4 <matchstar>:
  128. return 0;
  129. }
  130. // matchstar: search for c*re at beginning of text
  131. int matchstar(int c, char *re, char *text)
  132. {
  133. a4: e92d4878 push {r3, r4, r5, r6, fp, lr}
  134. a8: e1a04000 mov r4, r0
  135. ac: e28db014 add fp, sp, #20
  136. b0: e1a05001 mov r5, r1
  137. b4: e1a06002 mov r6, r2
  138. do{ // a * matches zero or more instances
  139. if(matchhere(re, text))
  140. b8: e1a01006 mov r1, r6
  141. bc: e1a00005 mov r0, r5
  142. c0: eb00000d bl fc <matchhere>
  143. c4: e3500000 cmp r0, #0
  144. c8: 1a000007 bne ec <matchstar+0x48>
  145. return 1;
  146. }while(*text!='\0' && (*text++==c || c=='.'));
  147. cc: e4d63001 ldrb r3, [r6], #1
  148. d0: e3530000 cmp r3, #0
  149. d4: 0a000006 beq f4 <matchstar+0x50>
  150. d8: e1530004 cmp r3, r4
  151. dc: 0afffff5 beq b8 <matchstar+0x14>
  152. e0: e354002e cmp r4, #46 ; 0x2e
  153. e4: 0afffff3 beq b8 <matchstar+0x14>
  154. e8: e8bd8878 pop {r3, r4, r5, r6, fp, pc}
  155. // matchstar: search for c*re at beginning of text
  156. int matchstar(int c, char *re, char *text)
  157. {
  158. do{ // a * matches zero or more instances
  159. if(matchhere(re, text))
  160. return 1;
  161. ec: e3a00001 mov r0, #1
  162. f0: e8bd8878 pop {r3, r4, r5, r6, fp, pc}
  163. }while(*text!='\0' && (*text++==c || c=='.'));
  164. return 0;
  165. f4: e1a00003 mov r0, r3
  166. }
  167. f8: e8bd8878 pop {r3, r4, r5, r6, fp, pc}
  168. 000000fc <matchhere>:
  169. return 0;
  170. }
  171. // matchhere: search for re at beginning of text
  172. int matchhere(char *re, char *text)
  173. {
  174. fc: e92d0810 push {r4, fp}
  175. 100: e1a03000 mov r3, r0
  176. if(re[0] == '\0')
  177. 104: e5d00000 ldrb r0, [r0]
  178. return 0;
  179. }
  180. // matchhere: search for re at beginning of text
  181. int matchhere(char *re, char *text)
  182. {
  183. 108: e28db004 add fp, sp, #4
  184. 10c: e1a02001 mov r2, r1
  185. if(re[0] == '\0')
  186. 110: e3500000 cmp r0, #0
  187. 114: 0a00001c beq 18c <matchhere+0x90>
  188. return 1;
  189. if(re[1] == '*')
  190. 118: e5d3c001 ldrb ip, [r3, #1]
  191. 11c: e35c002a cmp ip, #42 ; 0x2a
  192. }while(*text++ != '\0');
  193. return 0;
  194. }
  195. // matchhere: search for re at beginning of text
  196. int matchhere(char *re, char *text)
  197. 120: 12834002 addne r4, r3, #2
  198. {
  199. if(re[0] == '\0')
  200. return 1;
  201. if(re[1] == '*')
  202. return matchstar(re[0], re+2, text);
  203. 124: 11a01001 movne r1, r1
  204. // matchhere: search for re at beginning of text
  205. int matchhere(char *re, char *text)
  206. {
  207. if(re[0] == '\0')
  208. return 1;
  209. if(re[1] == '*')
  210. 128: 1a00000f bne 16c <matchhere+0x70>
  211. 12c: ea00001a b 19c <matchhere+0xa0>
  212. return matchstar(re[0], re+2, text);
  213. if(re[0] == '$' && re[1] == '\0')
  214. return *text == '\0';
  215. if(*text!='\0' && (re[0]=='.' || re[0]==*text))
  216. 130: e4d12001 ldrb r2, [r1], #1
  217. 134: e3520000 cmp r2, #0
  218. 138: 0a00001b beq 1ac <matchhere+0xb0>
  219. 13c: e350002e cmp r0, #46 ; 0x2e
  220. 140: 0a000001 beq 14c <matchhere+0x50>
  221. 144: e1500002 cmp r0, r2
  222. 148: 1a000019 bne 1b4 <matchhere+0xb8>
  223. }
  224. // matchhere: search for re at beginning of text
  225. int matchhere(char *re, char *text)
  226. {
  227. if(re[0] == '\0')
  228. 14c: e5d30001 ldrb r0, [r3, #1]
  229. if(re[1] == '*')
  230. return matchstar(re[0], re+2, text);
  231. if(re[0] == '$' && re[1] == '\0')
  232. return *text == '\0';
  233. if(*text!='\0' && (re[0]=='.' || re[0]==*text))
  234. return matchhere(re+1, text+1);
  235. 150: e1a02001 mov r2, r1
  236. 154: e2833001 add r3, r3, #1
  237. }
  238. // matchhere: search for re at beginning of text
  239. int matchhere(char *re, char *text)
  240. {
  241. if(re[0] == '\0')
  242. 158: e3500000 cmp r0, #0
  243. 15c: 0a00000a beq 18c <matchhere+0x90>
  244. return 1;
  245. if(re[1] == '*')
  246. 160: e4d4c001 ldrb ip, [r4], #1
  247. 164: e35c002a cmp ip, #42 ; 0x2a
  248. 168: 0a00000b beq 19c <matchhere+0xa0>
  249. return matchstar(re[0], re+2, text);
  250. if(re[0] == '$' && re[1] == '\0')
  251. 16c: e3500024 cmp r0, #36 ; 0x24
  252. 170: 1affffee bne 130 <matchhere+0x34>
  253. 174: e35c0000 cmp ip, #0
  254. 178: 1affffec bne 130 <matchhere+0x34>
  255. return *text == '\0';
  256. 17c: e5d10000 ldrb r0, [r1]
  257. 180: e2700001 rsbs r0, r0, #1
  258. 184: 33a00000 movcc r0, #0
  259. 188: ea000000 b 190 <matchhere+0x94>
  260. // matchhere: search for re at beginning of text
  261. int matchhere(char *re, char *text)
  262. {
  263. if(re[0] == '\0')
  264. return 1;
  265. 18c: e3a00001 mov r0, #1
  266. if(re[0] == '$' && re[1] == '\0')
  267. return *text == '\0';
  268. if(*text!='\0' && (re[0]=='.' || re[0]==*text))
  269. return matchhere(re+1, text+1);
  270. return 0;
  271. }
  272. 190: e24bd004 sub sp, fp, #4
  273. 194: e8bd0810 pop {r4, fp}
  274. 198: e12fff1e bx lr
  275. int matchhere(char *re, char *text)
  276. {
  277. if(re[0] == '\0')
  278. return 1;
  279. if(re[1] == '*')
  280. return matchstar(re[0], re+2, text);
  281. 19c: e2831002 add r1, r3, #2
  282. if(re[0] == '$' && re[1] == '\0')
  283. return *text == '\0';
  284. if(*text!='\0' && (re[0]=='.' || re[0]==*text))
  285. return matchhere(re+1, text+1);
  286. return 0;
  287. }
  288. 1a0: e24bd004 sub sp, fp, #4
  289. 1a4: e8bd0810 pop {r4, fp}
  290. int matchhere(char *re, char *text)
  291. {
  292. if(re[0] == '\0')
  293. return 1;
  294. if(re[1] == '*')
  295. return matchstar(re[0], re+2, text);
  296. 1a8: eaffffbd b a4 <matchstar>
  297. if(re[0] == '$' && re[1] == '\0')
  298. return *text == '\0';
  299. if(*text!='\0' && (re[0]=='.' || re[0]==*text))
  300. return matchhere(re+1, text+1);
  301. return 0;
  302. 1ac: e1a00002 mov r0, r2
  303. 1b0: eafffff6 b 190 <matchhere+0x94>
  304. 1b4: e3a00000 mov r0, #0
  305. 1b8: eafffff4 b 190 <matchhere+0x94>
  306. 000001bc <match>:
  307. int matchhere(char*, char*);
  308. int matchstar(int, char*, char*);
  309. int
  310. match(char *re, char *text)
  311. {
  312. 1bc: e92d4830 push {r4, r5, fp, lr}
  313. 1c0: e1a05000 mov r5, r0
  314. if(re[0] == '^')
  315. 1c4: e5d03000 ldrb r3, [r0]
  316. int matchhere(char*, char*);
  317. int matchstar(int, char*, char*);
  318. int
  319. match(char *re, char *text)
  320. {
  321. 1c8: e28db00c add fp, sp, #12
  322. 1cc: e1a04001 mov r4, r1
  323. if(re[0] == '^')
  324. 1d0: e353005e cmp r3, #94 ; 0x5e
  325. 1d4: 0a00000a beq 204 <match+0x48>
  326. return matchhere(re+1, text);
  327. do{ // must look at empty string
  328. if(matchhere(re, text))
  329. 1d8: e1a01004 mov r1, r4
  330. 1dc: e1a00005 mov r0, r5
  331. 1e0: ebffffc5 bl fc <matchhere>
  332. 1e4: e3500000 cmp r0, #0
  333. 1e8: 1a000003 bne 1fc <match+0x40>
  334. return 1;
  335. }while(*text++ != '\0');
  336. 1ec: e4d40001 ldrb r0, [r4], #1
  337. 1f0: e3500000 cmp r0, #0
  338. 1f4: 1afffff7 bne 1d8 <match+0x1c>
  339. 1f8: e8bd8830 pop {r4, r5, fp, pc}
  340. {
  341. if(re[0] == '^')
  342. return matchhere(re+1, text);
  343. do{ // must look at empty string
  344. if(matchhere(re, text))
  345. return 1;
  346. 1fc: e3a00001 mov r0, #1
  347. }while(*text++ != '\0');
  348. return 0;
  349. }
  350. 200: e8bd8830 pop {r4, r5, fp, pc}
  351. int
  352. match(char *re, char *text)
  353. {
  354. if(re[0] == '^')
  355. return matchhere(re+1, text);
  356. 204: e2800001 add r0, r0, #1
  357. do{ // must look at empty string
  358. if(matchhere(re, text))
  359. return 1;
  360. }while(*text++ != '\0');
  361. return 0;
  362. }
  363. 208: e8bd4830 pop {r4, r5, fp, lr}
  364. int
  365. match(char *re, char *text)
  366. {
  367. if(re[0] == '^')
  368. return matchhere(re+1, text);
  369. 20c: eaffffba b fc <matchhere>
  370. 00000210 <grep>:
  371. char buf[1024];
  372. int match(char*, char*);
  373. void
  374. grep(char *pattern, int fd)
  375. {
  376. 210: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
  377. int n, m;
  378. char *p, *q;
  379. m = 0;
  380. 214: e3a07000 mov r7, #0
  381. 218: e59fa0f0 ldr sl, [pc, #240] ; 310 <grep+0x100>
  382. char buf[1024];
  383. int match(char*, char*);
  384. void
  385. grep(char *pattern, int fd)
  386. {
  387. 21c: e28db020 add fp, sp, #32
  388. 220: e1a05000 mov r5, r0
  389. m = 0;
  390. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  391. m += n;
  392. p = buf;
  393. while((q = strchr(p, '\n')) != 0){
  394. *q = 0;
  395. 224: e1a06007 mov r6, r7
  396. char buf[1024];
  397. int match(char*, char*);
  398. void
  399. grep(char *pattern, int fd)
  400. {
  401. 228: e24dd00c sub sp, sp, #12
  402. 22c: e50b102c str r1, [fp, #-44] ; 0x2c
  403. int n, m;
  404. char *p, *q;
  405. m = 0;
  406. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  407. 230: e51b002c ldr r0, [fp, #-44] ; 0x2c
  408. 234: e08a1007 add r1, sl, r7
  409. 238: e2672b01 rsb r2, r7, #1024 ; 0x400
  410. 23c: eb000103 bl 650 <read>
  411. 240: e3500000 cmp r0, #0
  412. 244: e50b0028 str r0, [fp, #-40] ; 0x28
  413. 248: da00002e ble 308 <grep+0xf8>
  414. 24c: e59f90bc ldr r9, [pc, #188] ; 310 <grep+0x100>
  415. m += n;
  416. p = buf;
  417. while((q = strchr(p, '\n')) != 0){
  418. 250: e3a0800a mov r8, #10
  419. 254: e3a0100a mov r1, #10
  420. 258: e1a00009 mov r0, r9
  421. 25c: eb000067 bl 400 <strchr>
  422. *q = 0;
  423. if(match(pattern, p)){
  424. 260: e1a01009 mov r1, r9
  425. m = 0;
  426. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  427. m += n;
  428. p = buf;
  429. while((q = strchr(p, '\n')) != 0){
  430. 264: e2504000 subs r4, r0, #0
  431. *q = 0;
  432. if(match(pattern, p)){
  433. 268: e1a00005 mov r0, r5
  434. m = 0;
  435. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  436. m += n;
  437. p = buf;
  438. while((q = strchr(p, '\n')) != 0){
  439. 26c: 0a000011 beq 2b8 <grep+0xa8>
  440. *q = 0;
  441. 270: e5c46000 strb r6, [r4]
  442. if(match(pattern, p)){
  443. 274: ebffffd0 bl 1bc <match>
  444. 278: e3500000 cmp r0, #0
  445. 27c: 02849001 addeq r9, r4, #1
  446. 280: 0afffff3 beq 254 <grep+0x44>
  447. *q = '\n';
  448. 284: e4c48001 strb r8, [r4], #1
  449. write(1, p, q+1 - p);
  450. 288: e1a01009 mov r1, r9
  451. 28c: e0692004 rsb r2, r9, r4
  452. 290: e3a00001 mov r0, #1
  453. 294: e1a09004 mov r9, r4
  454. 298: eb0000f9 bl 684 <write>
  455. m = 0;
  456. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  457. m += n;
  458. p = buf;
  459. while((q = strchr(p, '\n')) != 0){
  460. 29c: e3a0100a mov r1, #10
  461. 2a0: e1a00009 mov r0, r9
  462. 2a4: eb000055 bl 400 <strchr>
  463. *q = 0;
  464. if(match(pattern, p)){
  465. 2a8: e1a01009 mov r1, r9
  466. m = 0;
  467. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  468. m += n;
  469. p = buf;
  470. while((q = strchr(p, '\n')) != 0){
  471. 2ac: e2504000 subs r4, r0, #0
  472. *q = 0;
  473. if(match(pattern, p)){
  474. 2b0: e1a00005 mov r0, r5
  475. m = 0;
  476. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  477. m += n;
  478. p = buf;
  479. while((q = strchr(p, '\n')) != 0){
  480. 2b4: 1affffed bne 270 <grep+0x60>
  481. *q = '\n';
  482. write(1, p, q+1 - p);
  483. }
  484. p = q+1;
  485. }
  486. if(p == buf)
  487. 2b8: e159000a cmp r9, sl
  488. m = 0;
  489. 2bc: 01a07004 moveq r7, r4
  490. *q = '\n';
  491. write(1, p, q+1 - p);
  492. }
  493. p = q+1;
  494. }
  495. if(p == buf)
  496. 2c0: 0affffda beq 230 <grep+0x20>
  497. int n, m;
  498. char *p, *q;
  499. m = 0;
  500. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  501. m += n;
  502. 2c4: e51b3028 ldr r3, [fp, #-40] ; 0x28
  503. 2c8: e0877003 add r7, r7, r3
  504. }
  505. p = q+1;
  506. }
  507. if(p == buf)
  508. m = 0;
  509. if(m > 0){
  510. 2cc: e3570000 cmp r7, #0
  511. 2d0: daffffd6 ble 230 <grep+0x20>
  512. m -= p - buf;
  513. 2d4: e59f2034 ldr r2, [pc, #52] ; 310 <grep+0x100>
  514. memmove(buf, p, m);
  515. 2d8: e59f0030 ldr r0, [pc, #48] ; 310 <grep+0x100>
  516. p = q+1;
  517. }
  518. if(p == buf)
  519. m = 0;
  520. if(m > 0){
  521. m -= p - buf;
  522. 2dc: e0693002 rsb r3, r9, r2
  523. 2e0: e0877003 add r7, r7, r3
  524. memmove(buf, p, m);
  525. 2e4: e1a02007 mov r2, r7
  526. 2e8: eb000097 bl 54c <memmove>
  527. {
  528. int n, m;
  529. char *p, *q;
  530. m = 0;
  531. while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
  532. 2ec: e51b002c ldr r0, [fp, #-44] ; 0x2c
  533. 2f0: e08a1007 add r1, sl, r7
  534. 2f4: e2672b01 rsb r2, r7, #1024 ; 0x400
  535. 2f8: eb0000d4 bl 650 <read>
  536. 2fc: e3500000 cmp r0, #0
  537. 300: e50b0028 str r0, [fp, #-40] ; 0x28
  538. 304: caffffd0 bgt 24c <grep+0x3c>
  539. if(m > 0){
  540. m -= p - buf;
  541. memmove(buf, p, m);
  542. }
  543. }
  544. }
  545. 308: e24bd020 sub sp, fp, #32
  546. 30c: e8bd8ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, pc}
  547. 310: 00000e48 .word 0x00000e48
  548. 00000314 <strcpy>:
  549. #include "user.h"
  550. #include "arm.h"
  551. char*
  552. strcpy(char *s, char *t)
  553. {
  554. 314: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  555. char *os;
  556. os = s;
  557. while((*s++ = *t++) != 0)
  558. 318: e1a02000 mov r2, r0
  559. #include "user.h"
  560. #include "arm.h"
  561. char*
  562. strcpy(char *s, char *t)
  563. {
  564. 31c: e28db000 add fp, sp, #0
  565. char *os;
  566. os = s;
  567. while((*s++ = *t++) != 0)
  568. 320: e4d13001 ldrb r3, [r1], #1
  569. 324: e3530000 cmp r3, #0
  570. 328: e4c23001 strb r3, [r2], #1
  571. 32c: 1afffffb bne 320 <strcpy+0xc>
  572. ;
  573. return os;
  574. }
  575. 330: e28bd000 add sp, fp, #0
  576. 334: e8bd0800 pop {fp}
  577. 338: e12fff1e bx lr
  578. 0000033c <strcmp>:
  579. int
  580. strcmp(const char *p, const char *q)
  581. {
  582. 33c: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  583. 340: e28db000 add fp, sp, #0
  584. while(*p && *p == *q)
  585. 344: e5d03000 ldrb r3, [r0]
  586. 348: e5d12000 ldrb r2, [r1]
  587. 34c: e3530000 cmp r3, #0
  588. 350: 1a000004 bne 368 <strcmp+0x2c>
  589. 354: ea000005 b 370 <strcmp+0x34>
  590. 358: e5f03001 ldrb r3, [r0, #1]!
  591. 35c: e3530000 cmp r3, #0
  592. 360: 0a000006 beq 380 <strcmp+0x44>
  593. 364: e5f12001 ldrb r2, [r1, #1]!
  594. 368: e1530002 cmp r3, r2
  595. 36c: 0afffff9 beq 358 <strcmp+0x1c>
  596. p++, q++;
  597. return (uchar)*p - (uchar)*q;
  598. }
  599. 370: e0620003 rsb r0, r2, r3
  600. 374: e28bd000 add sp, fp, #0
  601. 378: e8bd0800 pop {fp}
  602. 37c: e12fff1e bx lr
  603. }
  604. int
  605. strcmp(const char *p, const char *q)
  606. {
  607. while(*p && *p == *q)
  608. 380: e5d12001 ldrb r2, [r1, #1]
  609. 384: eafffff9 b 370 <strcmp+0x34>
  610. 00000388 <strlen>:
  611. return (uchar)*p - (uchar)*q;
  612. }
  613. uint
  614. strlen(char *s)
  615. {
  616. 388: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  617. 38c: e28db000 add fp, sp, #0
  618. int n;
  619. for(n = 0; s[n]; n++)
  620. 390: e5d03000 ldrb r3, [r0]
  621. 394: e3530000 cmp r3, #0
  622. 398: 01a00003 moveq r0, r3
  623. 39c: 0a000006 beq 3bc <strlen+0x34>
  624. 3a0: e1a02000 mov r2, r0
  625. 3a4: e3a03000 mov r3, #0
  626. 3a8: e5f21001 ldrb r1, [r2, #1]!
  627. 3ac: e2833001 add r3, r3, #1
  628. 3b0: e1a00003 mov r0, r3
  629. 3b4: e3510000 cmp r1, #0
  630. 3b8: 1afffffa bne 3a8 <strlen+0x20>
  631. ;
  632. return n;
  633. }
  634. 3bc: e28bd000 add sp, fp, #0
  635. 3c0: e8bd0800 pop {fp}
  636. 3c4: e12fff1e bx lr
  637. 000003c8 <memset>:
  638. memset(void *dst, int c, uint n)
  639. {
  640. char *p=dst;
  641. u32 rc=n;
  642. while (rc-- > 0) *p++ = c;
  643. 3c8: e3520000 cmp r2, #0
  644. return n;
  645. }
  646. void*
  647. memset(void *dst, int c, uint n)
  648. {
  649. 3cc: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  650. 3d0: e28db000 add fp, sp, #0
  651. char *p=dst;
  652. u32 rc=n;
  653. while (rc-- > 0) *p++ = c;
  654. 3d4: 0a000006 beq 3f4 <memset+0x2c>
  655. 3d8: e6ef1071 uxtb r1, r1
  656. 3dc: e1a03002 mov r3, r2
  657. }
  658. void*
  659. memset(void *dst, int c, uint n)
  660. {
  661. char *p=dst;
  662. 3e0: e1a0c000 mov ip, r0
  663. u32 rc=n;
  664. while (rc-- > 0) *p++ = c;
  665. 3e4: e2533001 subs r3, r3, #1
  666. 3e8: e4cc1001 strb r1, [ip], #1
  667. 3ec: 1afffffc bne 3e4 <memset+0x1c>
  668. 3f0: e0800002 add r0, r0, r2
  669. return (void *)p;
  670. }
  671. 3f4: e28bd000 add sp, fp, #0
  672. 3f8: e8bd0800 pop {fp}
  673. 3fc: e12fff1e bx lr
  674. 00000400 <strchr>:
  675. char*
  676. strchr(const char *s, char c)
  677. {
  678. 400: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  679. 404: e28db000 add fp, sp, #0
  680. for(; *s; s++)
  681. 408: e5d03000 ldrb r3, [r0]
  682. 40c: e3530000 cmp r3, #0
  683. 410: 1a000004 bne 428 <strchr+0x28>
  684. 414: ea000008 b 43c <strchr+0x3c>
  685. 418: e5d03001 ldrb r3, [r0, #1]
  686. 41c: e2800001 add r0, r0, #1
  687. 420: e3530000 cmp r3, #0
  688. 424: 0a000004 beq 43c <strchr+0x3c>
  689. if(*s == c)
  690. 428: e1530001 cmp r3, r1
  691. 42c: 1afffff9 bne 418 <strchr+0x18>
  692. return (char*)s;
  693. return 0;
  694. }
  695. 430: e28bd000 add sp, fp, #0
  696. 434: e8bd0800 pop {fp}
  697. 438: e12fff1e bx lr
  698. strchr(const char *s, char c)
  699. {
  700. for(; *s; s++)
  701. if(*s == c)
  702. return (char*)s;
  703. return 0;
  704. 43c: e1a00003 mov r0, r3
  705. 440: eafffffa b 430 <strchr+0x30>
  706. 00000444 <gets>:
  707. }
  708. char*
  709. gets(char *buf, int max)
  710. {
  711. 444: e92d49f0 push {r4, r5, r6, r7, r8, fp, lr}
  712. 448: e28db018 add fp, sp, #24
  713. 44c: e24dd00c sub sp, sp, #12
  714. 450: e1a08000 mov r8, r0
  715. 454: e1a07001 mov r7, r1
  716. int i, cc;
  717. char c;
  718. for(i=0; i+1 < max; ){
  719. 458: e1a06000 mov r6, r0
  720. 45c: e3a05000 mov r5, #0
  721. 460: ea000008 b 488 <gets+0x44>
  722. cc = read(0, &c, 1);
  723. 464: eb000079 bl 650 <read>
  724. if(cc < 1)
  725. 468: e3500000 cmp r0, #0
  726. 46c: da00000b ble 4a0 <gets+0x5c>
  727. break;
  728. buf[i++] = c;
  729. 470: e55b301d ldrb r3, [fp, #-29]
  730. if(c == '\n' || c == '\r')
  731. 474: e1a05004 mov r5, r4
  732. 478: e353000a cmp r3, #10
  733. 47c: 1353000d cmpne r3, #13
  734. for(i=0; i+1 < max; ){
  735. cc = read(0, &c, 1);
  736. if(cc < 1)
  737. break;
  738. buf[i++] = c;
  739. 480: e4c63001 strb r3, [r6], #1
  740. if(c == '\n' || c == '\r')
  741. 484: 0a00000a beq 4b4 <gets+0x70>
  742. {
  743. int i, cc;
  744. char c;
  745. for(i=0; i+1 < max; ){
  746. cc = read(0, &c, 1);
  747. 488: e3a02001 mov r2, #1
  748. gets(char *buf, int max)
  749. {
  750. int i, cc;
  751. char c;
  752. for(i=0; i+1 < max; ){
  753. 48c: e0854002 add r4, r5, r2
  754. 490: e1540007 cmp r4, r7
  755. cc = read(0, &c, 1);
  756. 494: e3a00000 mov r0, #0
  757. 498: e24b101d sub r1, fp, #29
  758. gets(char *buf, int max)
  759. {
  760. int i, cc;
  761. char c;
  762. for(i=0; i+1 < max; ){
  763. 49c: bafffff0 blt 464 <gets+0x20>
  764. break;
  765. buf[i++] = c;
  766. if(c == '\n' || c == '\r')
  767. break;
  768. }
  769. buf[i] = '\0';
  770. 4a0: e3a03000 mov r3, #0
  771. 4a4: e7c83005 strb r3, [r8, r5]
  772. return buf;
  773. }
  774. 4a8: e1a00008 mov r0, r8
  775. 4ac: e24bd018 sub sp, fp, #24
  776. 4b0: e8bd89f0 pop {r4, r5, r6, r7, r8, fp, pc}
  777. gets(char *buf, int max)
  778. {
  779. int i, cc;
  780. char c;
  781. for(i=0; i+1 < max; ){
  782. 4b4: e1a05004 mov r5, r4
  783. 4b8: eafffff8 b 4a0 <gets+0x5c>
  784. 000004bc <stat>:
  785. return buf;
  786. }
  787. int
  788. stat(char *n, struct stat *st)
  789. {
  790. 4bc: e92d4830 push {r4, r5, fp, lr}
  791. 4c0: e1a05001 mov r5, r1
  792. 4c4: e28db00c add fp, sp, #12
  793. int fd;
  794. int r;
  795. fd = open(n, O_RDONLY);
  796. 4c8: e3a01000 mov r1, #0
  797. 4cc: eb0000a0 bl 754 <open>
  798. if(fd < 0)
  799. 4d0: e2504000 subs r4, r0, #0
  800. return -1;
  801. 4d4: b3e05000 mvnlt r5, #0
  802. {
  803. int fd;
  804. int r;
  805. fd = open(n, O_RDONLY);
  806. if(fd < 0)
  807. 4d8: ba000004 blt 4f0 <stat+0x34>
  808. return -1;
  809. r = fstat(fd, st);
  810. 4dc: e1a01005 mov r1, r5
  811. 4e0: eb0000c2 bl 7f0 <fstat>
  812. 4e4: e1a05000 mov r5, r0
  813. close(fd);
  814. 4e8: e1a00004 mov r0, r4
  815. 4ec: eb000071 bl 6b8 <close>
  816. return r;
  817. }
  818. 4f0: e1a00005 mov r0, r5
  819. 4f4: e8bd8830 pop {r4, r5, fp, pc}
  820. 000004f8 <atoi>:
  821. int
  822. atoi(const char *s)
  823. {
  824. 4f8: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  825. 4fc: e28db000 add fp, sp, #0
  826. int n;
  827. n = 0;
  828. while('0' <= *s && *s <= '9')
  829. 500: e5d03000 ldrb r3, [r0]
  830. 504: e2432030 sub r2, r3, #48 ; 0x30
  831. 508: e6ef2072 uxtb r2, r2
  832. 50c: e3520009 cmp r2, #9
  833. int
  834. atoi(const char *s)
  835. {
  836. int n;
  837. n = 0;
  838. 510: 83a00000 movhi r0, #0
  839. while('0' <= *s && *s <= '9')
  840. 514: 8a000009 bhi 540 <atoi+0x48>
  841. 518: e1a02000 mov r2, r0
  842. int
  843. atoi(const char *s)
  844. {
  845. int n;
  846. n = 0;
  847. 51c: e3a00000 mov r0, #0
  848. while('0' <= *s && *s <= '9')
  849. n = n*10 + *s++ - '0';
  850. 520: e0800100 add r0, r0, r0, lsl #2
  851. 524: e0830080 add r0, r3, r0, lsl #1
  852. atoi(const char *s)
  853. {
  854. int n;
  855. n = 0;
  856. while('0' <= *s && *s <= '9')
  857. 528: e5f23001 ldrb r3, [r2, #1]!
  858. n = n*10 + *s++ - '0';
  859. 52c: e2400030 sub r0, r0, #48 ; 0x30
  860. atoi(const char *s)
  861. {
  862. int n;
  863. n = 0;
  864. while('0' <= *s && *s <= '9')
  865. 530: e2431030 sub r1, r3, #48 ; 0x30
  866. 534: e6ef1071 uxtb r1, r1
  867. 538: e3510009 cmp r1, #9
  868. 53c: 9afffff7 bls 520 <atoi+0x28>
  869. n = n*10 + *s++ - '0';
  870. return n;
  871. }
  872. 540: e28bd000 add sp, fp, #0
  873. 544: e8bd0800 pop {fp}
  874. 548: e12fff1e bx lr
  875. 0000054c <memmove>:
  876. {
  877. char *dst, *src;
  878. dst = vdst;
  879. src = vsrc;
  880. while(n-- > 0)
  881. 54c: e3520000 cmp r2, #0
  882. return n;
  883. }
  884. void*
  885. memmove(void *vdst, void *vsrc, int n)
  886. {
  887. 550: e52db004 push {fp} ; (str fp, [sp, #-4]!)
  888. 554: e28db000 add fp, sp, #0
  889. char *dst, *src;
  890. dst = vdst;
  891. src = vsrc;
  892. while(n-- > 0)
  893. 558: da000005 ble 574 <memmove+0x28>
  894. n = n*10 + *s++ - '0';
  895. return n;
  896. }
  897. void*
  898. memmove(void *vdst, void *vsrc, int n)
  899. 55c: e0802002 add r2, r0, r2
  900. {
  901. char *dst, *src;
  902. dst = vdst;
  903. 560: e1a03000 mov r3, r0
  904. src = vsrc;
  905. while(n-- > 0)
  906. *dst++ = *src++;
  907. 564: e4d1c001 ldrb ip, [r1], #1
  908. 568: e4c3c001 strb ip, [r3], #1
  909. {
  910. char *dst, *src;
  911. dst = vdst;
  912. src = vsrc;
  913. while(n-- > 0)
  914. 56c: e1530002 cmp r3, r2
  915. 570: 1afffffb bne 564 <memmove+0x18>
  916. *dst++ = *src++;
  917. return vdst;
  918. }
  919. 574: e28bd000 add sp, fp, #0
  920. 578: e8bd0800 pop {fp}
  921. 57c: e12fff1e bx lr
  922. 00000580 <fork>:
  923. 580: e92d4000 push {lr}
  924. 584: e92d0008 push {r3}
  925. 588: e92d0004 push {r2}
  926. 58c: e92d0002 push {r1}
  927. 590: e92d0001 push {r0}
  928. 594: e3a00001 mov r0, #1
  929. 598: ef000040 svc 0x00000040
  930. 59c: e8bd0002 pop {r1}
  931. 5a0: e8bd0002 pop {r1}
  932. 5a4: e8bd0004 pop {r2}
  933. 5a8: e8bd0008 pop {r3}
  934. 5ac: e8bd4000 pop {lr}
  935. 5b0: e12fff1e bx lr
  936. 000005b4 <exit>:
  937. 5b4: e92d4000 push {lr}
  938. 5b8: e92d0008 push {r3}
  939. 5bc: e92d0004 push {r2}
  940. 5c0: e92d0002 push {r1}
  941. 5c4: e92d0001 push {r0}
  942. 5c8: e3a00002 mov r0, #2
  943. 5cc: ef000040 svc 0x00000040
  944. 5d0: e8bd0002 pop {r1}
  945. 5d4: e8bd0002 pop {r1}
  946. 5d8: e8bd0004 pop {r2}
  947. 5dc: e8bd0008 pop {r3}
  948. 5e0: e8bd4000 pop {lr}
  949. 5e4: e12fff1e bx lr
  950. 000005e8 <wait>:
  951. 5e8: e92d4000 push {lr}
  952. 5ec: e92d0008 push {r3}
  953. 5f0: e92d0004 push {r2}
  954. 5f4: e92d0002 push {r1}
  955. 5f8: e92d0001 push {r0}
  956. 5fc: e3a00003 mov r0, #3
  957. 600: ef000040 svc 0x00000040
  958. 604: e8bd0002 pop {r1}
  959. 608: e8bd0002 pop {r1}
  960. 60c: e8bd0004 pop {r2}
  961. 610: e8bd0008 pop {r3}
  962. 614: e8bd4000 pop {lr}
  963. 618: e12fff1e bx lr
  964. 0000061c <pipe>:
  965. 61c: e92d4000 push {lr}
  966. 620: e92d0008 push {r3}
  967. 624: e92d0004 push {r2}
  968. 628: e92d0002 push {r1}
  969. 62c: e92d0001 push {r0}
  970. 630: e3a00004 mov r0, #4
  971. 634: ef000040 svc 0x00000040
  972. 638: e8bd0002 pop {r1}
  973. 63c: e8bd0002 pop {r1}
  974. 640: e8bd0004 pop {r2}
  975. 644: e8bd0008 pop {r3}
  976. 648: e8bd4000 pop {lr}
  977. 64c: e12fff1e bx lr
  978. 00000650 <read>:
  979. 650: e92d4000 push {lr}
  980. 654: e92d0008 push {r3}
  981. 658: e92d0004 push {r2}
  982. 65c: e92d0002 push {r1}
  983. 660: e92d0001 push {r0}
  984. 664: e3a00005 mov r0, #5
  985. 668: ef000040 svc 0x00000040
  986. 66c: e8bd0002 pop {r1}
  987. 670: e8bd0002 pop {r1}
  988. 674: e8bd0004 pop {r2}
  989. 678: e8bd0008 pop {r3}
  990. 67c: e8bd4000 pop {lr}
  991. 680: e12fff1e bx lr
  992. 00000684 <write>:
  993. 684: e92d4000 push {lr}
  994. 688: e92d0008 push {r3}
  995. 68c: e92d0004 push {r2}
  996. 690: e92d0002 push {r1}
  997. 694: e92d0001 push {r0}
  998. 698: e3a00010 mov r0, #16
  999. 69c: ef000040 svc 0x00000040
  1000. 6a0: e8bd0002 pop {r1}
  1001. 6a4: e8bd0002 pop {r1}
  1002. 6a8: e8bd0004 pop {r2}
  1003. 6ac: e8bd0008 pop {r3}
  1004. 6b0: e8bd4000 pop {lr}
  1005. 6b4: e12fff1e bx lr
  1006. 000006b8 <close>:
  1007. 6b8: e92d4000 push {lr}
  1008. 6bc: e92d0008 push {r3}
  1009. 6c0: e92d0004 push {r2}
  1010. 6c4: e92d0002 push {r1}
  1011. 6c8: e92d0001 push {r0}
  1012. 6cc: e3a00015 mov r0, #21
  1013. 6d0: ef000040 svc 0x00000040
  1014. 6d4: e8bd0002 pop {r1}
  1015. 6d8: e8bd0002 pop {r1}
  1016. 6dc: e8bd0004 pop {r2}
  1017. 6e0: e8bd0008 pop {r3}
  1018. 6e4: e8bd4000 pop {lr}
  1019. 6e8: e12fff1e bx lr
  1020. 000006ec <kill>:
  1021. 6ec: e92d4000 push {lr}
  1022. 6f0: e92d0008 push {r3}
  1023. 6f4: e92d0004 push {r2}
  1024. 6f8: e92d0002 push {r1}
  1025. 6fc: e92d0001 push {r0}
  1026. 700: e3a00006 mov r0, #6
  1027. 704: ef000040 svc 0x00000040
  1028. 708: e8bd0002 pop {r1}
  1029. 70c: e8bd0002 pop {r1}
  1030. 710: e8bd0004 pop {r2}
  1031. 714: e8bd0008 pop {r3}
  1032. 718: e8bd4000 pop {lr}
  1033. 71c: e12fff1e bx lr
  1034. 00000720 <exec>:
  1035. 720: e92d4000 push {lr}
  1036. 724: e92d0008 push {r3}
  1037. 728: e92d0004 push {r2}
  1038. 72c: e92d0002 push {r1}
  1039. 730: e92d0001 push {r0}
  1040. 734: e3a00007 mov r0, #7
  1041. 738: ef000040 svc 0x00000040
  1042. 73c: e8bd0002 pop {r1}
  1043. 740: e8bd0002 pop {r1}
  1044. 744: e8bd0004 pop {r2}
  1045. 748: e8bd0008 pop {r3}
  1046. 74c: e8bd4000 pop {lr}
  1047. 750: e12fff1e bx lr
  1048. 00000754 <open>:
  1049. 754: e92d4000 push {lr}
  1050. 758: e92d0008 push {r3}
  1051. 75c: e92d0004 push {r2}
  1052. 760: e92d0002 push {r1}
  1053. 764: e92d0001 push {r0}
  1054. 768: e3a0000f mov r0, #15
  1055. 76c: ef000040 svc 0x00000040
  1056. 770: e8bd0002 pop {r1}
  1057. 774: e8bd0002 pop {r1}
  1058. 778: e8bd0004 pop {r2}
  1059. 77c: e8bd0008 pop {r3}
  1060. 780: e8bd4000 pop {lr}
  1061. 784: e12fff1e bx lr
  1062. 00000788 <mknod>:
  1063. 788: e92d4000 push {lr}
  1064. 78c: e92d0008 push {r3}
  1065. 790: e92d0004 push {r2}
  1066. 794: e92d0002 push {r1}
  1067. 798: e92d0001 push {r0}
  1068. 79c: e3a00011 mov r0, #17
  1069. 7a0: ef000040 svc 0x00000040
  1070. 7a4: e8bd0002 pop {r1}
  1071. 7a8: e8bd0002 pop {r1}
  1072. 7ac: e8bd0004 pop {r2}
  1073. 7b0: e8bd0008 pop {r3}
  1074. 7b4: e8bd4000 pop {lr}
  1075. 7b8: e12fff1e bx lr
  1076. 000007bc <unlink>:
  1077. 7bc: e92d4000 push {lr}
  1078. 7c0: e92d0008 push {r3}
  1079. 7c4: e92d0004 push {r2}
  1080. 7c8: e92d0002 push {r1}
  1081. 7cc: e92d0001 push {r0}
  1082. 7d0: e3a00012 mov r0, #18
  1083. 7d4: ef000040 svc 0x00000040
  1084. 7d8: e8bd0002 pop {r1}
  1085. 7dc: e8bd0002 pop {r1}
  1086. 7e0: e8bd0004 pop {r2}
  1087. 7e4: e8bd0008 pop {r3}
  1088. 7e8: e8bd4000 pop {lr}
  1089. 7ec: e12fff1e bx lr
  1090. 000007f0 <fstat>:
  1091. 7f0: e92d4000 push {lr}
  1092. 7f4: e92d0008 push {r3}
  1093. 7f8: e92d0004 push {r2}
  1094. 7fc: e92d0002 push {r1}
  1095. 800: e92d0001 push {r0}
  1096. 804: e3a00008 mov r0, #8
  1097. 808: ef000040 svc 0x00000040
  1098. 80c: e8bd0002 pop {r1}
  1099. 810: e8bd0002 pop {r1}
  1100. 814: e8bd0004 pop {r2}
  1101. 818: e8bd0008 pop {r3}
  1102. 81c: e8bd4000 pop {lr}
  1103. 820: e12fff1e bx lr
  1104. 00000824 <link>:
  1105. 824: e92d4000 push {lr}
  1106. 828: e92d0008 push {r3}
  1107. 82c: e92d0004 push {r2}
  1108. 830: e92d0002 push {r1}
  1109. 834: e92d0001 push {r0}
  1110. 838: e3a00013 mov r0, #19
  1111. 83c: ef000040 svc 0x00000040
  1112. 840: e8bd0002 pop {r1}
  1113. 844: e8bd0002 pop {r1}
  1114. 848: e8bd0004 pop {r2}
  1115. 84c: e8bd0008 pop {r3}
  1116. 850: e8bd4000 pop {lr}
  1117. 854: e12fff1e bx lr
  1118. 00000858 <mkdir>:
  1119. 858: e92d4000 push {lr}
  1120. 85c: e92d0008 push {r3}
  1121. 860: e92d0004 push {r2}
  1122. 864: e92d0002 push {r1}
  1123. 868: e92d0001 push {r0}
  1124. 86c: e3a00014 mov r0, #20
  1125. 870: ef000040 svc 0x00000040
  1126. 874: e8bd0002 pop {r1}
  1127. 878: e8bd0002 pop {r1}
  1128. 87c: e8bd0004 pop {r2}
  1129. 880: e8bd0008 pop {r3}
  1130. 884: e8bd4000 pop {lr}
  1131. 888: e12fff1e bx lr
  1132. 0000088c <chdir>:
  1133. 88c: e92d4000 push {lr}
  1134. 890: e92d0008 push {r3}
  1135. 894: e92d0004 push {r2}
  1136. 898: e92d0002 push {r1}
  1137. 89c: e92d0001 push {r0}
  1138. 8a0: e3a00009 mov r0, #9
  1139. 8a4: ef000040 svc 0x00000040
  1140. 8a8: e8bd0002 pop {r1}
  1141. 8ac: e8bd0002 pop {r1}
  1142. 8b0: e8bd0004 pop {r2}
  1143. 8b4: e8bd0008 pop {r3}
  1144. 8b8: e8bd4000 pop {lr}
  1145. 8bc: e12fff1e bx lr
  1146. 000008c0 <dup>:
  1147. 8c0: e92d4000 push {lr}
  1148. 8c4: e92d0008 push {r3}
  1149. 8c8: e92d0004 push {r2}
  1150. 8cc: e92d0002 push {r1}
  1151. 8d0: e92d0001 push {r0}
  1152. 8d4: e3a0000a mov r0, #10
  1153. 8d8: ef000040 svc 0x00000040
  1154. 8dc: e8bd0002 pop {r1}
  1155. 8e0: e8bd0002 pop {r1}
  1156. 8e4: e8bd0004 pop {r2}
  1157. 8e8: e8bd0008 pop {r3}
  1158. 8ec: e8bd4000 pop {lr}
  1159. 8f0: e12fff1e bx lr
  1160. 000008f4 <getpid>:
  1161. 8f4: e92d4000 push {lr}
  1162. 8f8: e92d0008 push {r3}
  1163. 8fc: e92d0004 push {r2}
  1164. 900: e92d0002 push {r1}
  1165. 904: e92d0001 push {r0}
  1166. 908: e3a0000b mov r0, #11
  1167. 90c: ef000040 svc 0x00000040
  1168. 910: e8bd0002 pop {r1}
  1169. 914: e8bd0002 pop {r1}
  1170. 918: e8bd0004 pop {r2}
  1171. 91c: e8bd0008 pop {r3}
  1172. 920: e8bd4000 pop {lr}
  1173. 924: e12fff1e bx lr
  1174. 00000928 <sbrk>:
  1175. 928: e92d4000 push {lr}
  1176. 92c: e92d0008 push {r3}
  1177. 930: e92d0004 push {r2}
  1178. 934: e92d0002 push {r1}
  1179. 938: e92d0001 push {r0}
  1180. 93c: e3a0000c mov r0, #12
  1181. 940: ef000040 svc 0x00000040
  1182. 944: e8bd0002 pop {r1}
  1183. 948: e8bd0002 pop {r1}
  1184. 94c: e8bd0004 pop {r2}
  1185. 950: e8bd0008 pop {r3}
  1186. 954: e8bd4000 pop {lr}
  1187. 958: e12fff1e bx lr
  1188. 0000095c <sleep>:
  1189. 95c: e92d4000 push {lr}
  1190. 960: e92d0008 push {r3}
  1191. 964: e92d0004 push {r2}
  1192. 968: e92d0002 push {r1}
  1193. 96c: e92d0001 push {r0}
  1194. 970: e3a0000d mov r0, #13
  1195. 974: ef000040 svc 0x00000040
  1196. 978: e8bd0002 pop {r1}
  1197. 97c: e8bd0002 pop {r1}
  1198. 980: e8bd0004 pop {r2}
  1199. 984: e8bd0008 pop {r3}
  1200. 988: e8bd4000 pop {lr}
  1201. 98c: e12fff1e bx lr
  1202. 00000990 <uptime>:
  1203. 990: e92d4000 push {lr}
  1204. 994: e92d0008 push {r3}
  1205. 998: e92d0004 push {r2}
  1206. 99c: e92d0002 push {r1}
  1207. 9a0: e92d0001 push {r0}
  1208. 9a4: e3a0000e mov r0, #14
  1209. 9a8: ef000040 svc 0x00000040
  1210. 9ac: e8bd0002 pop {r1}
  1211. 9b0: e8bd0002 pop {r1}
  1212. 9b4: e8bd0004 pop {r2}
  1213. 9b8: e8bd0008 pop {r3}
  1214. 9bc: e8bd4000 pop {lr}
  1215. 9c0: e12fff1e bx lr
  1216. 000009c4 <putc>:
  1217. #include "stat.h"
  1218. #include "user.h"
  1219. static void
  1220. putc(int fd, char c)
  1221. {
  1222. 9c4: e92d4800 push {fp, lr}
  1223. 9c8: e28db004 add fp, sp, #4
  1224. 9cc: e24b3004 sub r3, fp, #4
  1225. 9d0: e24dd008 sub sp, sp, #8
  1226. write(fd, &c, 1);
  1227. 9d4: e3a02001 mov r2, #1
  1228. #include "stat.h"
  1229. #include "user.h"
  1230. static void
  1231. putc(int fd, char c)
  1232. {
  1233. 9d8: e5631001 strb r1, [r3, #-1]!
  1234. write(fd, &c, 1);
  1235. 9dc: e1a01003 mov r1, r3
  1236. 9e0: ebffff27 bl 684 <write>
  1237. }
  1238. 9e4: e24bd004 sub sp, fp, #4
  1239. 9e8: e8bd8800 pop {fp, pc}
  1240. 000009ec <printint>:
  1241. return q;
  1242. }
  1243. static void
  1244. printint(int fd, int xx, int base, int sgn)
  1245. {
  1246. 9ec: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
  1247. 9f0: e1a04000 mov r4, r0
  1248. char buf[16];
  1249. int i, neg;
  1250. uint x, y, b;
  1251. neg = 0;
  1252. if(sgn && xx < 0){
  1253. 9f4: e1a00fa1 lsr r0, r1, #31
  1254. 9f8: e3530000 cmp r3, #0
  1255. 9fc: 03a03000 moveq r3, #0
  1256. a00: 12003001 andne r3, r0, #1
  1257. return q;
  1258. }
  1259. static void
  1260. printint(int fd, int xx, int base, int sgn)
  1261. {
  1262. a04: e28db020 add fp, sp, #32
  1263. char buf[16];
  1264. int i, neg;
  1265. uint x, y, b;
  1266. neg = 0;
  1267. if(sgn && xx < 0){
  1268. a08: e3530000 cmp r3, #0
  1269. return q;
  1270. }
  1271. static void
  1272. printint(int fd, int xx, int base, int sgn)
  1273. {
  1274. a0c: e24dd014 sub sp, sp, #20
  1275. a10: e59f909c ldr r9, [pc, #156] ; ab4 <printint+0xc8>
  1276. uint x, y, b;
  1277. neg = 0;
  1278. if(sgn && xx < 0){
  1279. neg = 1;
  1280. x = -xx;
  1281. a14: 12611000 rsbne r1, r1, #0
  1282. int i, neg;
  1283. uint x, y, b;
  1284. neg = 0;
  1285. if(sgn && xx < 0){
  1286. neg = 1;
  1287. a18: 13a03001 movne r3, #1
  1288. } else {
  1289. x = xx;
  1290. }
  1291. b = base;
  1292. i = 0;
  1293. a1c: e3a0a000 mov sl, #0
  1294. a20: e24b6034 sub r6, fp, #52 ; 0x34
  1295. for(i=31;i>=0;i--){
  1296. r = r << 1;
  1297. r = r | ((n >> i) & 1);
  1298. if(r >= d) {
  1299. r = r - d;
  1300. q = q | (1 << i);
  1301. a24: e3a08001 mov r8, #1
  1302. write(fd, &c, 1);
  1303. }
  1304. u32 div(u32 n, u32 d) // long division
  1305. {
  1306. u32 q=0, r=0;
  1307. a28: e3a07000 mov r7, #0
  1308. int i;
  1309. for(i=31;i>=0;i--){
  1310. a2c: e3a0001f mov r0, #31
  1311. write(fd, &c, 1);
  1312. }
  1313. u32 div(u32 n, u32 d) // long division
  1314. {
  1315. u32 q=0, r=0;
  1316. a30: e1a0c007 mov ip, r7
  1317. int i;
  1318. for(i=31;i>=0;i--){
  1319. r = r << 1;
  1320. r = r | ((n >> i) & 1);
  1321. a34: e1a0e031 lsr lr, r1, r0
  1322. a38: e20ee001 and lr, lr, #1
  1323. a3c: e18ec08c orr ip, lr, ip, lsl #1
  1324. if(r >= d) {
  1325. a40: e152000c cmp r2, ip
  1326. r = r - d;
  1327. q = q | (1 << i);
  1328. a44: 91877018 orrls r7, r7, r8, lsl r0
  1329. for(i=31;i>=0;i--){
  1330. r = r << 1;
  1331. r = r | ((n >> i) & 1);
  1332. if(r >= d) {
  1333. r = r - d;
  1334. a48: 9062c00c rsbls ip, r2, ip
  1335. u32 div(u32 n, u32 d) // long division
  1336. {
  1337. u32 q=0, r=0;
  1338. int i;
  1339. for(i=31;i>=0;i--){
  1340. a4c: e2500001 subs r0, r0, #1
  1341. a50: 2afffff7 bcs a34 <printint+0x48>
  1342. b = base;
  1343. i = 0;
  1344. do{
  1345. y = div(x, b);
  1346. buf[i++] = digits[x - y * b];
  1347. a54: e0000792 mul r0, r2, r7
  1348. }while((x = y) != 0);
  1349. a58: e3570000 cmp r7, #0
  1350. b = base;
  1351. i = 0;
  1352. do{
  1353. y = div(x, b);
  1354. buf[i++] = digits[x - y * b];
  1355. a5c: e0601001 rsb r1, r0, r1
  1356. a60: e28a5001 add r5, sl, #1
  1357. a64: e7d91001 ldrb r1, [r9, r1]
  1358. a68: e7c6100a strb r1, [r6, sl]
  1359. }while((x = y) != 0);
  1360. a6c: 11a01007 movne r1, r7
  1361. b = base;
  1362. i = 0;
  1363. do{
  1364. y = div(x, b);
  1365. buf[i++] = digits[x - y * b];
  1366. a70: 11a0a005 movne sl, r5
  1367. a74: 1affffeb bne a28 <printint+0x3c>
  1368. }while((x = y) != 0);
  1369. if(neg)
  1370. a78: e3530000 cmp r3, #0
  1371. buf[i++] = '-';
  1372. a7c: 124b2024 subne r2, fp, #36 ; 0x24
  1373. a80: 10823005 addne r3, r2, r5
  1374. a84: 128a5002 addne r5, sl, #2
  1375. while(--i >= 0)
  1376. a88: e2455001 sub r5, r5, #1
  1377. do{
  1378. y = div(x, b);
  1379. buf[i++] = digits[x - y * b];
  1380. }while((x = y) != 0);
  1381. if(neg)
  1382. buf[i++] = '-';
  1383. a8c: 13a0202d movne r2, #45 ; 0x2d
  1384. a90: 15432010 strbne r2, [r3, #-16]
  1385. while(--i >= 0)
  1386. putc(fd, buf[i]);
  1387. a94: e7d61005 ldrb r1, [r6, r5]
  1388. a98: e1a00004 mov r0, r4
  1389. buf[i++] = digits[x - y * b];
  1390. }while((x = y) != 0);
  1391. if(neg)
  1392. buf[i++] = '-';
  1393. while(--i >= 0)
  1394. a9c: e2455001 sub r5, r5, #1
  1395. putc(fd, buf[i]);
  1396. aa0: ebffffc7 bl 9c4 <putc>
  1397. buf[i++] = digits[x - y * b];
  1398. }while((x = y) != 0);
  1399. if(neg)
  1400. buf[i++] = '-';
  1401. while(--i >= 0)
  1402. aa4: e3750001 cmn r5, #1
  1403. aa8: 1afffff9 bne a94 <printint+0xa8>
  1404. putc(fd, buf[i]);
  1405. }
  1406. aac: e24bd020 sub sp, fp, #32
  1407. ab0: e8bd8ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, pc}
  1408. ab4: 00000e20 .word 0x00000e20
  1409. 00000ab8 <div>:
  1410. write(fd, &c, 1);
  1411. }
  1412. u32 div(u32 n, u32 d) // long division
  1413. {
  1414. u32 q=0, r=0;
  1415. ab8: e3a03000 mov r3, #0
  1416. {
  1417. write(fd, &c, 1);
  1418. }
  1419. u32 div(u32 n, u32 d) // long division
  1420. {
  1421. abc: e92d0830 push {r4, r5, fp}
  1422. ac0: e1a02000 mov r2, r0
  1423. ac4: e28db008 add fp, sp, #8
  1424. u32 q=0, r=0;
  1425. int i;
  1426. for(i=31;i>=0;i--){
  1427. ac8: e3a0c01f mov ip, #31
  1428. write(fd, &c, 1);
  1429. }
  1430. u32 div(u32 n, u32 d) // long division
  1431. {
  1432. u32 q=0, r=0;
  1433. acc: e1a00003 mov r0, r3
  1434. for(i=31;i>=0;i--){
  1435. r = r << 1;
  1436. r = r | ((n >> i) & 1);
  1437. if(r >= d) {
  1438. r = r - d;
  1439. q = q | (1 << i);
  1440. ad0: e3a05001 mov r5, #1
  1441. u32 q=0, r=0;
  1442. int i;
  1443. for(i=31;i>=0;i--){
  1444. r = r << 1;
  1445. r = r | ((n >> i) & 1);
  1446. ad4: e1a04c32 lsr r4, r2, ip
  1447. ad8: e2044001 and r4, r4, #1
  1448. adc: e1843083 orr r3, r4, r3, lsl #1
  1449. if(r >= d) {
  1450. ae0: e1530001 cmp r3, r1
  1451. r = r - d;
  1452. q = q | (1 << i);
  1453. ae4: 21800c15 orrcs r0, r0, r5, lsl ip
  1454. for(i=31;i>=0;i--){
  1455. r = r << 1;
  1456. r = r | ((n >> i) & 1);
  1457. if(r >= d) {
  1458. r = r - d;
  1459. ae8: 20613003 rsbcs r3, r1, r3
  1460. u32 div(u32 n, u32 d) // long division
  1461. {
  1462. u32 q=0, r=0;
  1463. int i;
  1464. for(i=31;i>=0;i--){
  1465. aec: e25cc001 subs ip, ip, #1
  1466. af0: 2afffff7 bcs ad4 <div+0x1c>
  1467. r = r - d;
  1468. q = q | (1 << i);
  1469. }
  1470. }
  1471. return q;
  1472. }
  1473. af4: e24bd008 sub sp, fp, #8
  1474. af8: e8bd0830 pop {r4, r5, fp}
  1475. afc: e12fff1e bx lr
  1476. 00000b00 <printf>:
  1477. }
  1478. // Print to the given fd. Only understands %d, %x, %p, %s.
  1479. void
  1480. printf(int fd, char *fmt, ...)
  1481. {
  1482. b00: e92d000e push {r1, r2, r3}
  1483. b04: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
  1484. b08: e28db020 add fp, sp, #32
  1485. b0c: e1a05000 mov r5, r0
  1486. int c, i, state;
  1487. uint *ap;
  1488. state = 0;
  1489. ap = (uint*)(void*)&fmt + 1;
  1490. for(i = 0; fmt[i]; i++){
  1491. b10: e59b4004 ldr r4, [fp, #4]
  1492. b14: e5d48000 ldrb r8, [r4]
  1493. b18: e3580000 cmp r8, #0
  1494. b1c: 0a000027 beq bc0 <printf+0xc0>
  1495. ap++;
  1496. } else if(c == 's'){
  1497. s = (char*)*ap;
  1498. ap++;
  1499. if(s == 0)
  1500. s = "(null)";
  1501. b20: e59f712c ldr r7, [pc, #300] ; c54 <printf+0x154>
  1502. char *s;
  1503. int c, i, state;
  1504. uint *ap;
  1505. state = 0;
  1506. ap = (uint*)(void*)&fmt + 1;
  1507. b24: e28b6008 add r6, fp, #8
  1508. {
  1509. char *s;
  1510. int c, i, state;
  1511. uint *ap;
  1512. state = 0;
  1513. b28: e3a0a000 mov sl, #0
  1514. b2c: ea000008 b b54 <printf+0x54>
  1515. ap = (uint*)(void*)&fmt + 1;
  1516. for(i = 0; fmt[i]; i++){
  1517. c = fmt[i] & 0xff;
  1518. if(state == 0){
  1519. if(c == '%'){
  1520. b30: e3580025 cmp r8, #37 ; 0x25
  1521. state = '%';
  1522. b34: 01a0a008 moveq sl, r8
  1523. state = 0;
  1524. ap = (uint*)(void*)&fmt + 1;
  1525. for(i = 0; fmt[i]; i++){
  1526. c = fmt[i] & 0xff;
  1527. if(state == 0){
  1528. if(c == '%'){
  1529. b38: 0a000002 beq b48 <printf+0x48>
  1530. state = '%';
  1531. } else {
  1532. putc(fd, c);
  1533. b3c: e1a00005 mov r0, r5
  1534. b40: e1a01008 mov r1, r8
  1535. b44: ebffff9e bl 9c4 <putc>
  1536. int c, i, state;
  1537. uint *ap;
  1538. state = 0;
  1539. ap = (uint*)(void*)&fmt + 1;
  1540. for(i = 0; fmt[i]; i++){
  1541. b48: e5f48001 ldrb r8, [r4, #1]!
  1542. b4c: e3580000 cmp r8, #0
  1543. b50: 0a00001a beq bc0 <printf+0xc0>
  1544. c = fmt[i] & 0xff;
  1545. if(state == 0){
  1546. b54: e35a0000 cmp sl, #0
  1547. b58: 0afffff4 beq b30 <printf+0x30>
  1548. if(c == '%'){
  1549. state = '%';
  1550. } else {
  1551. putc(fd, c);
  1552. }
  1553. } else if(state == '%'){
  1554. b5c: e35a0025 cmp sl, #37 ; 0x25
  1555. b60: 1afffff8 bne b48 <printf+0x48>
  1556. if(c == 'd'){
  1557. b64: e3580064 cmp r8, #100 ; 0x64
  1558. b68: 0a00002c beq c20 <printf+0x120>
  1559. printint(fd, *ap, 10, 1);
  1560. ap++;
  1561. } else if(c == 'x' || c == 'p'){
  1562. b6c: e3580078 cmp r8, #120 ; 0x78
  1563. b70: 13580070 cmpne r8, #112 ; 0x70
  1564. b74: 13a09000 movne r9, #0
  1565. b78: 03a09001 moveq r9, #1
  1566. b7c: 0a000013 beq bd0 <printf+0xd0>
  1567. printint(fd, *ap, 16, 0);
  1568. ap++;
  1569. } else if(c == 's'){
  1570. b80: e3580073 cmp r8, #115 ; 0x73
  1571. b84: 0a000018 beq bec <printf+0xec>
  1572. s = "(null)";
  1573. while(*s != 0){
  1574. putc(fd, *s);
  1575. s++;
  1576. }
  1577. } else if(c == 'c'){
  1578. b88: e3580063 cmp r8, #99 ; 0x63
  1579. b8c: 0a00002a beq c3c <printf+0x13c>
  1580. putc(fd, *ap);
  1581. ap++;
  1582. } else if(c == '%'){
  1583. b90: e3580025 cmp r8, #37 ; 0x25
  1584. putc(fd, c);
  1585. b94: e1a0100a mov r1, sl
  1586. b98: e1a00005 mov r0, r5
  1587. s++;
  1588. }
  1589. } else if(c == 'c'){
  1590. putc(fd, *ap);
  1591. ap++;
  1592. } else if(c == '%'){
  1593. b9c: 0a000002 beq bac <printf+0xac>
  1594. putc(fd, c);
  1595. } else {
  1596. // Unknown % sequence. Print it to draw attention.
  1597. putc(fd, '%');
  1598. ba0: ebffff87 bl 9c4 <putc>
  1599. putc(fd, c);
  1600. ba4: e1a00005 mov r0, r5
  1601. ba8: e1a01008 mov r1, r8
  1602. bac: ebffff84 bl 9c4 <putc>
  1603. int c, i, state;
  1604. uint *ap;
  1605. state = 0;
  1606. ap = (uint*)(void*)&fmt + 1;
  1607. for(i = 0; fmt[i]; i++){
  1608. bb0: e5f48001 ldrb r8, [r4, #1]!
  1609. } else {
  1610. // Unknown % sequence. Print it to draw attention.
  1611. putc(fd, '%');
  1612. putc(fd, c);
  1613. }
  1614. state = 0;
  1615. bb4: e1a0a009 mov sl, r9
  1616. int c, i, state;
  1617. uint *ap;
  1618. state = 0;
  1619. ap = (uint*)(void*)&fmt + 1;
  1620. for(i = 0; fmt[i]; i++){
  1621. bb8: e3580000 cmp r8, #0
  1622. bbc: 1affffe4 bne b54 <printf+0x54>
  1623. putc(fd, c);
  1624. }
  1625. state = 0;
  1626. }
  1627. }
  1628. }
  1629. bc0: e24bd020 sub sp, fp, #32
  1630. bc4: e8bd4ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, lr}
  1631. bc8: e28dd00c add sp, sp, #12
  1632. bcc: e12fff1e bx lr
  1633. } else if(state == '%'){
  1634. if(c == 'd'){
  1635. printint(fd, *ap, 10, 1);
  1636. ap++;
  1637. } else if(c == 'x' || c == 'p'){
  1638. printint(fd, *ap, 16, 0);
  1639. bd0: e1a00005 mov r0, r5
  1640. bd4: e4961004 ldr r1, [r6], #4
  1641. bd8: e3a02010 mov r2, #16
  1642. bdc: e3a03000 mov r3, #0
  1643. be0: ebffff81 bl 9ec <printint>
  1644. } else {
  1645. // Unknown % sequence. Print it to draw attention.
  1646. putc(fd, '%');
  1647. putc(fd, c);
  1648. }
  1649. state = 0;
  1650. be4: e3a0a000 mov sl, #0
  1651. be8: eaffffd6 b b48 <printf+0x48>
  1652. ap++;
  1653. } else if(c == 'x' || c == 'p'){
  1654. printint(fd, *ap, 16, 0);
  1655. ap++;
  1656. } else if(c == 's'){
  1657. s = (char*)*ap;
  1658. bec: e4968004 ldr r8, [r6], #4
  1659. ap++;
  1660. if(s == 0)
  1661. s = "(null)";
  1662. bf0: e3580000 cmp r8, #0
  1663. bf4: 01a08007 moveq r8, r7
  1664. while(*s != 0){
  1665. bf8: e5d81000 ldrb r1, [r8]
  1666. bfc: e3510000 cmp r1, #0
  1667. c00: 0a000004 beq c18 <printf+0x118>
  1668. putc(fd, *s);
  1669. c04: e1a00005 mov r0, r5
  1670. c08: ebffff6d bl 9c4 <putc>
  1671. } else if(c == 's'){
  1672. s = (char*)*ap;
  1673. ap++;
  1674. if(s == 0)
  1675. s = "(null)";
  1676. while(*s != 0){
  1677. c0c: e5f81001 ldrb r1, [r8, #1]!
  1678. c10: e3510000 cmp r1, #0
  1679. c14: 1afffffa bne c04 <printf+0x104>
  1680. } else {
  1681. // Unknown % sequence. Print it to draw attention.
  1682. putc(fd, '%');
  1683. putc(fd, c);
  1684. }
  1685. state = 0;
  1686. c18: e1a0a001 mov sl, r1
  1687. c1c: eaffffc9 b b48 <printf+0x48>
  1688. } else {
  1689. putc(fd, c);
  1690. }
  1691. } else if(state == '%'){
  1692. if(c == 'd'){
  1693. printint(fd, *ap, 10, 1);
  1694. c20: e1a00005 mov r0, r5
  1695. c24: e4961004 ldr r1, [r6], #4
  1696. c28: e3a0200a mov r2, #10
  1697. c2c: e3a03001 mov r3, #1
  1698. c30: ebffff6d bl 9ec <printint>
  1699. } else {
  1700. // Unknown % sequence. Print it to draw attention.
  1701. putc(fd, '%');
  1702. putc(fd, c);
  1703. }
  1704. state = 0;
  1705. c34: e3a0a000 mov sl, #0
  1706. c38: eaffffc2 b b48 <printf+0x48>
  1707. while(*s != 0){
  1708. putc(fd, *s);
  1709. s++;
  1710. }
  1711. } else if(c == 'c'){
  1712. putc(fd, *ap);
  1713. c3c: e4961004 ldr r1, [r6], #4
  1714. c40: e1a00005 mov r0, r5
  1715. } else {
  1716. // Unknown % sequence. Print it to draw attention.
  1717. putc(fd, '%');
  1718. putc(fd, c);
  1719. }
  1720. state = 0;
  1721. c44: e1a0a009 mov sl, r9
  1722. while(*s != 0){
  1723. putc(fd, *s);
  1724. s++;
  1725. }
  1726. } else if(c == 'c'){
  1727. putc(fd, *ap);
  1728. c48: e6ef1071 uxtb r1, r1
  1729. c4c: ebffff5c bl 9c4 <putc>
  1730. c50: eaffffbc b b48 <printf+0x48>
  1731. c54: 00000e34 .word 0x00000e34
  1732. 00000c58 <free>:
  1733. free(void *ap)
  1734. {
  1735. Header *bp, *p;
  1736. bp = (Header*)ap - 1;
  1737. for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
  1738. c58: e59f3098 ldr r3, [pc, #152] ; cf8 <free+0xa0>
  1739. static Header base;
  1740. static Header *freep;
  1741. void
  1742. free(void *ap)
  1743. {
  1744. c5c: e92d0830 push {r4, r5, fp}
  1745. Header *bp, *p;
  1746. bp = (Header*)ap - 1;
  1747. c60: e240c008 sub ip, r0, #8
  1748. for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
  1749. c64: e5932000 ldr r2, [r3]
  1750. static Header base;
  1751. static Header *freep;
  1752. void
  1753. free(void *ap)
  1754. {
  1755. c68: e28db008 add fp, sp, #8
  1756. Header *bp, *p;
  1757. bp = (Header*)ap - 1;
  1758. for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
  1759. c6c: e152000c cmp r2, ip
  1760. c70: e5921000 ldr r1, [r2]
  1761. c74: 2a000001 bcs c80 <free+0x28>
  1762. c78: e15c0001 cmp ip, r1
  1763. c7c: 3a000007 bcc ca0 <free+0x48>
  1764. if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
  1765. c80: e1520001 cmp r2, r1
  1766. c84: 3a000003 bcc c98 <free+0x40>
  1767. c88: e152000c cmp r2, ip
  1768. c8c: 3a000003 bcc ca0 <free+0x48>
  1769. c90: e15c0001 cmp ip, r1
  1770. c94: 3a000001 bcc ca0 <free+0x48>
  1771. static Header base;
  1772. static Header *freep;
  1773. void
  1774. free(void *ap)
  1775. {
  1776. c98: e1a02001 mov r2, r1
  1777. c9c: eafffff2 b c6c <free+0x14>
  1778. bp = (Header*)ap - 1;
  1779. for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
  1780. if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
  1781. break;
  1782. if(bp + bp->s.size == p->s.ptr){
  1783. ca0: e5104004 ldr r4, [r0, #-4]
  1784. if(p + p->s.size == bp){
  1785. p->s.size += bp->s.size;
  1786. p->s.ptr = bp->s.ptr;
  1787. } else
  1788. p->s.ptr = bp;
  1789. freep = p;
  1790. ca4: e5832000 str r2, [r3]
  1791. bp = (Header*)ap - 1;
  1792. for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
  1793. if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
  1794. break;
  1795. if(bp + bp->s.size == p->s.ptr){
  1796. ca8: e08c5184 add r5, ip, r4, lsl #3
  1797. cac: e1550001 cmp r5, r1
  1798. bp->s.size += p->s.ptr->s.size;
  1799. cb0: 05911004 ldreq r1, [r1, #4]
  1800. cb4: 00814004 addeq r4, r1, r4
  1801. cb8: 05004004 streq r4, [r0, #-4]
  1802. bp->s.ptr = p->s.ptr->s.ptr;
  1803. cbc: 05921000 ldreq r1, [r2]
  1804. cc0: 05911000 ldreq r1, [r1]
  1805. } else
  1806. bp->s.ptr = p->s.ptr;
  1807. cc4: e5001008 str r1, [r0, #-8]
  1808. if(p + p->s.size == bp){
  1809. cc8: e5921004 ldr r1, [r2, #4]
  1810. ccc: e0824181 add r4, r2, r1, lsl #3
  1811. cd0: e15c0004 cmp ip, r4
  1812. p->s.size += bp->s.size;
  1813. p->s.ptr = bp->s.ptr;
  1814. } else
  1815. p->s.ptr = bp;
  1816. cd4: 1582c000 strne ip, [r2]
  1817. bp->s.size += p->s.ptr->s.size;
  1818. bp->s.ptr = p->s.ptr->s.ptr;
  1819. } else
  1820. bp->s.ptr = p->s.ptr;
  1821. if(p + p->s.size == bp){
  1822. p->s.size += bp->s.size;
  1823. cd8: 0510c004 ldreq ip, [r0, #-4]
  1824. cdc: 008c1001 addeq r1, ip, r1
  1825. ce0: 05821004 streq r1, [r2, #4]
  1826. p->s.ptr = bp->s.ptr;
  1827. ce4: 05101008 ldreq r1, [r0, #-8]
  1828. ce8: 05821000 streq r1, [r2]
  1829. } else
  1830. p->s.ptr = bp;
  1831. freep = p;
  1832. }
  1833. cec: e24bd008 sub sp, fp, #8
  1834. cf0: e8bd0830 pop {r4, r5, fp}
  1835. cf4: e12fff1e bx lr
  1836. cf8: 00000e3c .word 0x00000e3c
  1837. 00000cfc <malloc>:
  1838. return freep;
  1839. }
  1840. void*
  1841. malloc(uint nbytes)
  1842. {
  1843. cfc: e92d49f8 push {r3, r4, r5, r6, r7, r8, fp, lr}
  1844. Header *p, *prevp;
  1845. uint nunits;
  1846. nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  1847. d00: e2804007 add r4, r0, #7
  1848. if((prevp = freep) == 0){
  1849. d04: e59f50d4 ldr r5, [pc, #212] ; de0 <malloc+0xe4>
  1850. malloc(uint nbytes)
  1851. {
  1852. Header *p, *prevp;
  1853. uint nunits;
  1854. nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  1855. d08: e1a041a4 lsr r4, r4, #3
  1856. return freep;
  1857. }
  1858. void*
  1859. malloc(uint nbytes)
  1860. {
  1861. d0c: e28db01c add fp, sp, #28
  1862. Header *p, *prevp;
  1863. uint nunits;
  1864. nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  1865. if((prevp = freep) == 0){
  1866. d10: e5953000 ldr r3, [r5]
  1867. malloc(uint nbytes)
  1868. {
  1869. Header *p, *prevp;
  1870. uint nunits;
  1871. nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  1872. d14: e2844001 add r4, r4, #1
  1873. if((prevp = freep) == 0){
  1874. d18: e3530000 cmp r3, #0
  1875. d1c: 0a00002b beq dd0 <malloc+0xd4>
  1876. d20: e5930000 ldr r0, [r3]
  1877. d24: e5902004 ldr r2, [r0, #4]
  1878. base.s.ptr = freep = prevp = &base;
  1879. base.s.size = 0;
  1880. }
  1881. for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
  1882. if(p->s.size >= nunits){
  1883. d28: e1520004 cmp r2, r4
  1884. d2c: 2a00001b bcs da0 <malloc+0xa4>
  1885. morecore(uint nu)
  1886. {
  1887. char *p;
  1888. Header *hp;
  1889. if(nu < 4096)
  1890. d30: e59f80ac ldr r8, [pc, #172] ; de4 <malloc+0xe8>
  1891. p->s.size -= nunits;
  1892. p += p->s.size;
  1893. p->s.size = nunits;
  1894. }
  1895. freep = prevp;
  1896. return (void*)(p + 1);
  1897. d34: e1a07184 lsl r7, r4, #3
  1898. d38: ea000003 b d4c <malloc+0x50>
  1899. nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  1900. if((prevp = freep) == 0){
  1901. base.s.ptr = freep = prevp = &base;
  1902. base.s.size = 0;
  1903. }
  1904. for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
  1905. d3c: e5930000 ldr r0, [r3]
  1906. if(p->s.size >= nunits){
  1907. d40: e5902004 ldr r2, [r0, #4]
  1908. d44: e1540002 cmp r4, r2
  1909. d48: 9a000014 bls da0 <malloc+0xa4>
  1910. p->s.size = nunits;
  1911. }
  1912. freep = prevp;
  1913. return (void*)(p + 1);
  1914. }
  1915. if(p == freep)
  1916. d4c: e5952000 ldr r2, [r5]
  1917. d50: e1a03000 mov r3, r0
  1918. d54: e1500002 cmp r0, r2
  1919. d58: 1afffff7 bne d3c <malloc+0x40>
  1920. morecore(uint nu)
  1921. {
  1922. char *p;
  1923. Header *hp;
  1924. if(nu < 4096)
  1925. d5c: e1540008 cmp r4, r8
  1926. nu = 4096;
  1927. p = sbrk(nu * sizeof(Header));
  1928. d60: 81a00007 movhi r0, r7
  1929. d64: 93a00902 movls r0, #32768 ; 0x8000
  1930. morecore(uint nu)
  1931. {
  1932. char *p;
  1933. Header *hp;
  1934. if(nu < 4096)
  1935. d68: 81a06004 movhi r6, r4
  1936. d6c: 93a06a01 movls r6, #4096 ; 0x1000
  1937. nu = 4096;
  1938. p = sbrk(nu * sizeof(Header));
  1939. d70: ebfffeec bl 928 <sbrk>
  1940. d74: e1a03000 mov r3, r0
  1941. if(p == (char*)-1)
  1942. d78: e3730001 cmn r3, #1
  1943. return 0;
  1944. hp = (Header*)p;
  1945. hp->s.size = nu;
  1946. free((void*)(hp + 1));
  1947. d7c: e2800008 add r0, r0, #8
  1948. Header *hp;
  1949. if(nu < 4096)
  1950. nu = 4096;
  1951. p = sbrk(nu * sizeof(Header));
  1952. if(p == (char*)-1)
  1953. d80: 0a000010 beq dc8 <malloc+0xcc>
  1954. return 0;
  1955. hp = (Header*)p;
  1956. hp->s.size = nu;
  1957. d84: e5836004 str r6, [r3, #4]
  1958. free((void*)(hp + 1));
  1959. d88: ebffffb2 bl c58 <free>
  1960. return freep;
  1961. d8c: e5953000 ldr r3, [r5]
  1962. }
  1963. freep = prevp;
  1964. return (void*)(p + 1);
  1965. }
  1966. if(p == freep)
  1967. if((p = morecore(nunits)) == 0)
  1968. d90: e3530000 cmp r3, #0
  1969. d94: 1affffe8 bne d3c <malloc+0x40>
  1970. return 0;
  1971. d98: e1a00003 mov r0, r3
  1972. }
  1973. }
  1974. d9c: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
  1975. base.s.ptr = freep = prevp = &base;
  1976. base.s.size = 0;
  1977. }
  1978. for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
  1979. if(p->s.size >= nunits){
  1980. if(p->s.size == nunits)
  1981. da0: e1540002 cmp r4, r2
  1982. prevp->s.ptr = p->s.ptr;
  1983. else {
  1984. p->s.size -= nunits;
  1985. da4: 10642002 rsbne r2, r4, r2
  1986. da8: 15802004 strne r2, [r0, #4]
  1987. base.s.size = 0;
  1988. }
  1989. for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
  1990. if(p->s.size >= nunits){
  1991. if(p->s.size == nunits)
  1992. prevp->s.ptr = p->s.ptr;
  1993. dac: 05902000 ldreq r2, [r0]
  1994. else {
  1995. p->s.size -= nunits;
  1996. p += p->s.size;
  1997. db0: 10800182 addne r0, r0, r2, lsl #3
  1998. base.s.size = 0;
  1999. }
  2000. for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
  2001. if(p->s.size >= nunits){
  2002. if(p->s.size == nunits)
  2003. prevp->s.ptr = p->s.ptr;
  2004. db4: 05832000 streq r2, [r3]
  2005. else {
  2006. p->s.size -= nunits;
  2007. p += p->s.size;
  2008. p->s.size = nunits;
  2009. db8: 15804004 strne r4, [r0, #4]
  2010. }
  2011. freep = prevp;
  2012. dbc: e5853000 str r3, [r5]
  2013. return (void*)(p + 1);
  2014. dc0: e2800008 add r0, r0, #8
  2015. dc4: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
  2016. }
  2017. if(p == freep)
  2018. if((p = morecore(nunits)) == 0)
  2019. return 0;
  2020. dc8: e3a00000 mov r0, #0
  2021. dcc: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
  2022. Header *p, *prevp;
  2023. uint nunits;
  2024. nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  2025. if((prevp = freep) == 0){
  2026. base.s.ptr = freep = prevp = &base;
  2027. dd0: e2850004 add r0, r5, #4
  2028. dd4: e5850000 str r0, [r5]
  2029. base.s.size = 0;
  2030. dd8: e9850009 stmib r5, {r0, r3}
  2031. ddc: eaffffd3 b d30 <malloc+0x34>
  2032. de0: 00000e3c .word 0x00000e3c
  2033. de4: 00000fff .word 0x00000fff