src/hermes/x86_main.asm
author Ryan C. Gordon
Wed, 29 Nov 2006 10:30:05 +0000
branchSDL-1.2
changeset 3900 ce3a2bd11305
parent 1873 eb4d9d99849b
child 2134 180fa05e98e2
permissions -rw-r--r--
Wrapped some macro params in parentheses for alloca wrappers.
Thansk, Suzuki Masahiro.
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@1873
    14
%include "common.inc"
slouken@1871
    15
slouken@1871
    16
SDL_FUNC _ConvertX86
slouken@1871
    17
SDL_FUNC _x86return
slouken@0
    18
	
slouken@1871
    19
SDL_FUNC _Hermes_X86_CPU
slouken@0
    20
slouken@0
    21
SECTION .text
slouken@0
    22
		
slouken@0
    23
;; _ConvertX86:	 
slouken@0
    24
;; [ESP+8] ConverterInfo*
slouken@0
    25
;; --------------------------------------------------------------------------
slouken@0
    26
;; ConverterInfo (ebp+..)
slouken@0
    27
;;   0:	void *s_pixels
slouken@0
    28
;;   4:	int s_width
slouken@0
    29
;;   8:	int s_height
slouken@0
    30
;;  12:	int s_add
slouken@0
    31
;;  16:	void *d_pixels
slouken@0
    32
;;  20:	int d_width
slouken@0
    33
;;  24:	int d_height
slouken@0
    34
;;  28:	int d_add
slouken@0
    35
;;  32:	void (*converter_function)() 
slouken@0
    36
;;  36: int32 *lookup
slouken@0
    37
	
slouken@0
    38
_ConvertX86:
slouken@0
    39
	push ebp
slouken@0
    40
	mov ebp,esp
slouken@0
    41
slouken@0
    42
; Save the registers used by the blitters, necessary for optimized code
slouken@0
    43
	pusha
slouken@0
    44
slouken@0
    45
	mov eax,[ebp+8]
slouken@0
    46
slouken@0
    47
        cmp dword [eax+4],BYTE 0
slouken@0
    48
	je endconvert
slouken@0
    49
	
slouken@0
    50
	mov ebp,eax
slouken@0
    51
	
slouken@0
    52
	mov esi,[ebp+0]
slouken@0
    53
	mov edi,[ebp+16]
slouken@0
    54
	
slouken@0
    55
y_loop:	
slouken@0
    56
	mov ecx,[ebp+4]
slouken@0
    57
slouken@0
    58
	jmp [ebp+32]
slouken@0
    59
slouken@0
    60
_x86return:	
slouken@0
    61
	add esi,[ebp+12]
slouken@0
    62
	add edi,[ebp+28]
slouken@0
    63
	
slouken@0
    64
	dec dword  [ebp+8]
slouken@0
    65
	jnz y_loop
slouken@0
    66
slouken@0
    67
; Restore the registers used by the blitters, necessary for optimized code
slouken@0
    68
	popa
slouken@0
    69
	
slouken@0
    70
	pop ebp
slouken@0
    71
slouken@0
    72
endconvert:	
slouken@0
    73
	ret		
slouken@0
    74
slouken@0
    75
slouken@0
    76
slouken@0
    77
;; Hermes_X86_CPU returns the CPUID flags in eax
slouken@0
    78
	
slouken@0
    79
_Hermes_X86_CPU:
slouken@0
    80
	pushfd
slouken@0
    81
	pop eax
slouken@0
    82
	
slouken@0
    83
	mov ecx,eax
slouken@0
    84
	
slouken@0
    85
	xor eax,040000h
slouken@0
    86
	push eax
slouken@0
    87
	
slouken@0
    88
	popfd
slouken@0
    89
	pushfd
slouken@0
    90
slouken@0
    91
	pop eax
slouken@0
    92
	xor eax,ecx
slouken@0
    93
	jz .L1			; Processor is 386
slouken@0
    94
slouken@0
    95
	push ecx
slouken@0
    96
	popfd
slouken@0
    97
slouken@0
    98
	mov eax,ecx
slouken@0
    99
	xor eax,200000h
slouken@0
   100
slouken@0
   101
	push eax
slouken@0
   102
	popfd
slouken@0
   103
	pushfd
slouken@0
   104
slouken@0
   105
	pop eax
slouken@0
   106
	xor eax,ecx
slouken@0
   107
	je .L1
slouken@0
   108
	
icculus@1227
   109
	push ebx
icculus@1227
   110
slouken@0
   111
	mov eax,1
slouken@0
   112
	cpuid
icculus@1227
   113
	mov eax,edx
slouken@0
   114
icculus@1227
   115
	pop ebx
slouken@0
   116
slouken@0
   117
.L1:	
slouken@0
   118
	ret
icculus@1199
   119
icculus@1199
   120
%ifidn __OUTPUT_FORMAT__,elf
icculus@1199
   121
section .note.GNU-stack noalloc noexec nowrite progbits
icculus@1199
   122
%endif