checkasm-a.asm
上传用户:hjq518
上传日期:2021-12-09
资源大小:5084k
文件大小:3k
源码类别:

Audio

开发平台:

Visual C++

  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. %include "x86inc.asm"
  21. SECTION_RODATA
  22. error_message: db "failed to preserve register", 10, 0
  23. SECTION .text
  24. cextern printf
  25. ; max number of args used by any x264 asm function.
  26. ; (max_args % 4) must equal 3 for stack alignment
  27. %define max_args 11
  28. ; just random numbers to reduce the chance of incidental match
  29. %define n3 dword 0x6549315c
  30. %define n4 dword 0xe02f3e23
  31. %define n5 dword 0xb78d0d1d
  32. %define n6 dword 0x33627ba7
  33. %ifndef ARCH_X86_64
  34. ;-----------------------------------------------------------------------------
  35. ; long x264_checkasm_call( long (*func)(), int *ok, ... )
  36. ;-----------------------------------------------------------------------------
  37. cglobal x264_checkasm_call, 1,7
  38.     mov  r3, n3
  39.     mov  r4, n4
  40.     mov  r5, n5
  41.     mov  r6, n6
  42. %rep max_args
  43.     push dword [esp+24+max_args*4]
  44. %endrep
  45.     call r0
  46.     add  esp, max_args*4
  47.     xor  r3, n3
  48.     xor  r4, n4
  49.     xor  r5, n5
  50.     xor  r6, n6
  51.     or   r3, r4
  52.     or   r5, r6
  53.     or   r3, r5
  54.     jz .ok
  55.     mov  r3, eax
  56.     lea  r1, [error_message GLOBAL]
  57.     push r1
  58.     xor  eax, eax
  59.     call printf
  60.     add  esp, 4
  61.     mov  r1, r1m
  62.     mov  dword [r1], 0
  63.     mov  eax, r3
  64. .ok:
  65.     RET
  66. %endif ; ARCH_X86_64
  67. ;-----------------------------------------------------------------------------
  68. ; int x264_stack_pagealign( int (*func)(), int align )
  69. ;-----------------------------------------------------------------------------
  70. cglobal x264_stack_pagealign, 2,2
  71.     push rbp
  72.     mov  rbp, rsp
  73.     and  rsp, ~0xfff
  74.     sub  rsp, r1
  75.     call r0
  76.     leave
  77.     RET