summary refs log tree commit diff stats
path: root/lib/amd64.asm.in
blob: 2c14bf241d364f41483732123dd6c28e28767636 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
; This contains the CPU-dependant variants of some routines.
; (C) 2005 Andreas Rumpf
; This code was inspired by the Freepascal compiler's sources
; All routines here have the _cdecl calling convention because
; that is the only convention any C compiler supports.

\python{
# as usual I use my own preprocessor :-)
import os

def c(name): 
  if os.name == 'posix':
    return name
  else:
    return "_" + name
    
def arg:
  if os.name == 'posix':
    return 'rdi'
  else:
    return 'rcx' # on win64 uses its own calling convention; this sucks!
}

segment code

global \c{cpu_inc_locked}
global \c{cpu_dec_locked}

\c{cpu_dec_locked}: 
     lock
     dec       [\arg]
     setz      al
     ret
     
\c{cpu_inc_locked}:
     lock
     inc       [\arg]
     setz      al
     ret