1{ 2 x86 format converters for HERMES 3 Some routines Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk) 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version 9 with the following modification: 10 11 As a special exception, the copyright holders of this library give you 12 permission to link this library with independent modules to produce an 13 executable, regardless of the license terms of these independent modules,and 14 to copy and distribute the resulting executable under terms of your choice, 15 provided that you also meet, for each linked independent module, the terms 16 and conditions of the license of that module. An independent module is a 17 module which is not derived from or based on this library. If you modify 18 this library, you may extend this exception to your version of the library, 19 but you are not obligated to do so. If you do not wish to do so, delete this 20 exception statement from your version. 21 22 This library is distributed in the hope that it will be useful, 23 but WITHOUT ANY WARRANTY; without even the implied warranty of 24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 Lesser General Public License for more details. 26 27 You should have received a copy of the GNU Lesser General Public 28 License along with this library; if not, write to the Free Software 29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 30} 31 32label 33 _x86return, _x86return_S; 34 35var 36 cpu_flags: DWord = 0; 37 38{ _ConvertX86: 39 [ESP+8] ConverterInfo* 40 -------------------------------------------------------------------------- 41 42 ConvertX86Stretch 'abuses' the following info structure fields: 43 - d_pitch for the y increment 44 - s_add for the x increment 45 because they're unused anyway and this is thread safe.. (it's a per 46 converter handle structure) 47} 48procedure ConvertX86Stretch(hci: PHermesConverterInterface); cdecl; assembler; 49label 50 endconvert_S; 51asm 52 pushl %ebp 53 54 movl 8(%ebp),%ebp 55 56 movl 8(%ebp),%eax // s_height 57 sall $16,%eax 58 cltd 59 idivl 24(%ebp) // d_height 60 movl %eax,44(%ebp) // d_pitch 61 62 movl 4(%ebp),%eax // s_width 63 sall $16,%eax 64 cltd 65 idivl 20(%ebp) // d_width 66 movl %eax,12(%ebp) // s_add 67 68 movl $0,8(%ebp) // s_height 69 70 movl 16(%ebp),%edi // d_pixels 71 movl 0(%ebp),%esi // s_pixels 72 73 movl 12(%ebp),%edx // s_add 74 movl 20(%ebp),%ecx // d_width 75 jmp *32(%ebp) // conv_func 76 77.balign 8 78_x86return_S: 79 80 decl 24(%ebp) // d_height 81 jz endconvert_S 82 83 movl 8(%ebp),%eax // s_height 84 addl 28(%ebp),%edi // d_add 85 86 addl 44(%ebp),%eax // d_pitch 87 88 movl %eax,%ebx 89 90 shrl $16,%eax 91 92 mull 40(%ebp) // s_pitch 93 andl $0x0ffff,%ebx 94 95 movl %ebx,8(%ebp) // s_height 96 addl %eax,%esi 97 98 movl 12(%ebp),%edx // s_add 99 movl 20(%ebp),%ecx // d_width 100 101 jmp *32(%ebp) // conv_func 102 103endconvert_S: 104 105 popl %ebp 106end; 107 108procedure ConvertX86(hci: PHermesConverterInterface); cdecl; assembler; 109label 110 endconvert; 111asm 112 pushl %ebp 113 114 movl 8(%ebp),%ebp 115 116 movl 0(%ebp),%esi // s_pixels 117 movl 20(%ebp),%ecx // d_width 118 movl 16(%ebp),%edi // d_pixels 119 120 jmp *32(%ebp) 121 122.balign 8 123_x86return: 124 decl 8(%ebp) // s_height 125 jz endconvert 126 127 movl 20(%ebp),%ecx // d_width 128 addl 12(%ebp),%esi // s_add 129 addl 28(%ebp),%edi // d_add 130 131 jmp *32(%ebp) 132 133 134endconvert: 135 popl %ebp 136end; 137 138// Hermes_X86_CPU returns the CPUID flags in eax 139function Hermes_X86_CPU: Integer; cdecl; assembler; 140asm 141 pushfl 142 popl %eax 143 144 movl %eax,%ecx 145 146 xorl $0x040000,%eax 147 pushl %eax 148 149 popfl 150 pushfl 151 152 popl %eax 153 xorl %ecx,%eax 154 jz .L1 // Processor is 386 155 156 pushl %ecx 157 popfl 158 159 movl %ecx,%eax 160 xorl $0x200000,%eax 161 162 pushl %eax 163 popfl 164 pushfl 165 166 popl %eax 167 xorl %ecx,%eax 168 je .L1 169 170 pusha 171 172 movl $1,%eax 173 cpuid 174 175 movl %edx,cpu_flags 176 177 popa 178 179 movl cpu_flags,%eax 180 181.L1: 182end; 183