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