kill.asm 36 KB

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