wc.asm 41 KB

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