src/hermes/x86_main.asm
author Sam Lantinga
Mon, 06 Feb 2006 08:28:51 +0000
changeset 1330 450721ad5436
parent 1227 3202d727bb4b
child 1697 393092a3ebf6
permissions -rw-r--r--
It's now possible to build SDL without any C runtime at all on Windows,
using Visual C++ 2005
     1 ;
     2 ; x86 format converters for HERMES
     3 ; Some routines Copyright (c) 1998 Christian Nentwich (brn@eleet.mcb.at)
     4 ; This source code is licensed under the GNU LGPL
     5 ; 
     6 ; Please refer to the file COPYING.LIB contained in the distribution for
     7 ; licensing conditions		
     8 ;
     9 ; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission
    10 ; 
    11 
    12 BITS 32
    13 
    14 GLOBAL _ConvertX86
    15 GLOBAL _x86return
    16 	
    17 GLOBAL _Hermes_X86_CPU
    18 
    19 SECTION .text
    20 		
    21 ;; _ConvertX86:	 
    22 ;; [ESP+8] ConverterInfo*
    23 ;; --------------------------------------------------------------------------
    24 ;; ConverterInfo (ebp+..)
    25 ;;   0:	void *s_pixels
    26 ;;   4:	int s_width
    27 ;;   8:	int s_height
    28 ;;  12:	int s_add
    29 ;;  16:	void *d_pixels
    30 ;;  20:	int d_width
    31 ;;  24:	int d_height
    32 ;;  28:	int d_add
    33 ;;  32:	void (*converter_function)() 
    34 ;;  36: int32 *lookup
    35 	
    36 _ConvertX86:
    37 	push ebp
    38 	mov ebp,esp
    39 
    40 ; Save the registers used by the blitters, necessary for optimized code
    41 	pusha
    42 
    43 	mov eax,[ebp+8]
    44 
    45         cmp dword [eax+4],BYTE 0
    46 	je endconvert
    47 	
    48 	mov ebp,eax
    49 	
    50 	mov esi,[ebp+0]
    51 	mov edi,[ebp+16]
    52 	
    53 y_loop:	
    54 	mov ecx,[ebp+4]
    55 
    56 	jmp [ebp+32]
    57 
    58 _x86return:	
    59 	add esi,[ebp+12]
    60 	add edi,[ebp+28]
    61 	
    62 	dec dword  [ebp+8]
    63 	jnz y_loop
    64 
    65 ; Restore the registers used by the blitters, necessary for optimized code
    66 	popa
    67 	
    68 	pop ebp
    69 
    70 endconvert:	
    71 	ret		
    72 
    73 
    74 
    75 ;; Hermes_X86_CPU returns the CPUID flags in eax
    76 	
    77 _Hermes_X86_CPU:
    78 	pushfd
    79 	pop eax
    80 	
    81 	mov ecx,eax
    82 	
    83 	xor eax,040000h
    84 	push eax
    85 	
    86 	popfd
    87 	pushfd
    88 
    89 	pop eax
    90 	xor eax,ecx
    91 	jz .L1			; Processor is 386
    92 
    93 	push ecx
    94 	popfd
    95 
    96 	mov eax,ecx
    97 	xor eax,200000h
    98 
    99 	push eax
   100 	popfd
   101 	pushfd
   102 
   103 	pop eax
   104 	xor eax,ecx
   105 	je .L1
   106 	
   107 	push ebx
   108 
   109 	mov eax,1
   110 	cpuid
   111 	mov eax,edx
   112 
   113 	pop ebx
   114 
   115 .L1:	
   116 	ret
   117 
   118 %ifidn __OUTPUT_FORMAT__,elf
   119 section .note.GNU-stack noalloc noexec nowrite progbits
   120 %endif