|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * Miscellaneous machine dependent support functions and definitions ! 5: * ! 6: * Copyright 1996 Bernd Schmidt ! 7: */ ! 8: ! 9: ! 10: #include "sysconfig.h" ! 11: #include "sysdeps.h" ! 12: ! 13: #include "config.h" ! 14: #include "options.h" ! 15: #include "machdep/m68k.h" ! 16: ! 17: struct flag_struct regflags; ! 18: ! 19: /* ! 20: * Careful: No unique labels. Unfortunately, not each installation of GCC ! 21: * comes with GAS. Bletch. ! 22: */ ! 23: ! 24: int fast_memcmp(const void *foo, const void *bar, int len) ! 25: { ! 26: int differs, baz; ! 27: __asm__ __volatile__ ("subl $4, %2\n" ! 28: "jc LLA2\n" ! 29: "LLA1:\n" ! 30: "movl (%0),%%ebx\n" ! 31: "cmpl (%1),%%ebx\n" ! 32: "jne LLA5\n" ! 33: "addl $4, %0\n" ! 34: "addl $4, %1\n" ! 35: "subl $4, %2\n" ! 36: "jnc LLA1\n" ! 37: "LLA2:\n" ! 38: "addl $4, %2\n" ! 39: "jz LLA4\n" ! 40: "LLA3:\n" ! 41: "movb (%0),%%bl\n" ! 42: "cmpb (%1),%%bl\n" ! 43: "jne LLA5\n" ! 44: "incl %0\n" ! 45: "incl %1\n" ! 46: "decl %2\n" ! 47: "jnz LLA3\n" ! 48: "LLA4:\n" ! 49: "movl $0, %3\n" ! 50: "jmp LLA6\n" ! 51: "LLA5:\n" ! 52: "movl $1, %3\n" ! 53: "LLA6:\n" ! 54: : "=&r" (foo), "=&r" (bar), "=&rm" (len), "=rm" (differs), ! 55: "=&b" (baz) ! 56: : "0" (foo), "1" (bar), "2" (len), "3" (baz) : "cc"); ! 57: return differs; ! 58: } ! 59: ! 60: int memcmpy(void *foo, const void *bar, int len) ! 61: { ! 62: int differs, baz = 0, uupzuq = 0; ! 63: ! 64: __asm__ __volatile__ ("subl %1, %2\n" ! 65: "movl $0, %0\n" ! 66: "subl $16, %3\n" ! 67: "jc LLB7\n" ! 68: ! 69: "LLB8:\n" ! 70: "movl (%1),%%ecx\n" ! 71: "movl (%2,%1),%%ebx\n" ! 72: "xorl %%ebx, %%ecx\n" ! 73: "movl %%ebx, (%1)\n" ! 74: "orl %%ecx, %0\n" ! 75: ! 76: "movl 4(%2,%1),%%ebx\n" ! 77: "movl 4(%1),%%ecx\n" ! 78: "xorl %%ebx, %%ecx\n" ! 79: "movl %%ebx, 4(%1)\n" ! 80: "orl %%ecx, %0\n" ! 81: ! 82: "movl 8(%2,%1),%%ebx\n" ! 83: "movl 8(%1),%%ecx\n" ! 84: "xorl %%ebx, %%ecx\n" ! 85: "movl %%ebx, 8(%1)\n" ! 86: "orl %%ecx, %0\n" ! 87: ! 88: "movl 12(%2,%1),%%ebx\n" ! 89: "movl 12(%1),%%ecx\n" ! 90: "xorl %%ebx, %%ecx\n" ! 91: "movl %%ebx, 12(%1)\n" ! 92: "orl %%ecx, %0\n" ! 93: ! 94: "addl $16, %1\n" ! 95: "subl $16, %3\n" ! 96: "jnc LLB8\n" ! 97: ! 98: "LLB7:\n" ! 99: "addl $16, %3\n" ! 100: "subl $4, %3\n" ! 101: "jc LLB2\n" ! 102: ! 103: "LLB1:\n" ! 104: "movl (%2,%1),%%ebx\n" ! 105: "movl (%1),%%ecx\n" ! 106: "xorl %%ebx, %%ecx\n" ! 107: "movl %%ebx, (%1)\n" ! 108: "orl %%ecx, %0\n" ! 109: "addl $4, %1\n" ! 110: "subl $4, %3\n" ! 111: "jnc LLB1\n" ! 112: ! 113: "LLB2:\n" ! 114: "addl $4, %3\n" ! 115: "jz LLB6\n" ! 116: "xorl %%ecx, %%ecx\n" ! 117: ! 118: "LLB3:\n" ! 119: "movb (%2,%1),%%bl\n" ! 120: "movb (%1),%%cl\n" ! 121: "xorb %%bl,%%cl\n" ! 122: "movb %%bl,(%1)\n" ! 123: "orl %%ecx, %0\n" ! 124: "incl %1\n" ! 125: "decl %3\n" ! 126: "jnz LLB3\n" ! 127: ! 128: "LLB6:\n" ! 129: : "=m" (differs) ! 130: : "r" (foo), "r" (bar), "r" (len), "b" (baz), "c" (uupzuq) : "cc", "memory"); ! 131: /* Now tell the compiler that foo, bar and len have been modified ! 132: * If someone finds a way to express all this cleaner in constraints that ! 133: * GCC 2.7.2 understands, please FIXME */ ! 134: __asm__ __volatile__ ("" : "=rm" (foo), "=rm" (bar), "=rm" (len) : : "ebx", "ecx", "edx", "eax", "esi", "memory"); ! 135: ! 136: return differs; ! 137: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.