]> git.sesse.net Git - x264/blob - tools/checkasm-a.asm
Update file headers throughout x264
[x264] / tools / checkasm-a.asm
1 ;*****************************************************************************
2 ;* checkasm-a.asm
3 ;*****************************************************************************
4 ;* Copyright (C) 2008 Loren Merritt <lorenm@u.washington.edu>
5 ;*
6 ;* This program is free software; you can redistribute it and/or modify
7 ;* it under the terms of the GNU General Public License as published by
8 ;* the Free Software Foundation; either version 2 of the License, or
9 ;* (at your option) any later version.
10 ;*
11 ;* This program is distributed in the hope that it will be useful,
12 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;* GNU General Public License for more details.
15 ;*
16 ;* You should have received a copy of the GNU General Public License
17 ;* along with this program; if not, write to the Free Software
18 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
19 ;*****************************************************************************
20
21 %include "x86inc.asm"
22
23 SECTION_RODATA
24
25 error_message: db "failed to preserve register", 10, 0
26
27 SECTION .text
28
29 cextern printf
30
31 ; max number of args used by any x264 asm function.
32 ; (max_args % 4) must equal 3 for stack alignment
33 %define max_args 11
34
35 ; just random numbers to reduce the chance of incidental match
36 %define n3 dword 0x6549315c
37 %define n4 dword 0xe02f3e23
38 %define n5 dword 0xb78d0d1d
39 %define n6 dword 0x33627ba7
40
41 %ifndef ARCH_X86_64
42 ;-----------------------------------------------------------------------------
43 ; long x264_checkasm_call( long (*func)(), int *ok, ... )
44 ;-----------------------------------------------------------------------------
45 cglobal x264_checkasm_call, 1,7
46     mov  r3, n3
47     mov  r4, n4
48     mov  r5, n5
49     mov  r6, n6
50 %rep max_args
51     push dword [esp+24+max_args*4]
52 %endrep
53     call r0
54     add  esp, max_args*4
55     xor  r3, n3
56     xor  r4, n4
57     xor  r5, n5
58     xor  r6, n6
59     or   r3, r4
60     or   r5, r6
61     or   r3, r5
62     jz .ok
63     mov  r3, eax
64     picgetgot r1
65     lea  r1, [error_message GLOBAL]
66     push r1
67     xor  eax, eax
68     call printf
69     add  esp, 4
70     mov  r1, r1m
71     mov  dword [r1], 0
72     mov  eax, r3
73 .ok:
74     RET
75 %endif ; ARCH_X86_64
76
77 ;-----------------------------------------------------------------------------
78 ; int x264_stack_pagealign( int (*func)(), int align )
79 ;-----------------------------------------------------------------------------
80 cglobal x264_stack_pagealign, 2,2
81     push rbp
82     mov  rbp, rsp
83     and  rsp, ~0xfff
84     sub  rsp, r1
85     call r0
86     leave
87     RET
88