summary refs log tree commit diff stats
path: root/lib/powerpc.asm.in
blob: 107f887ab178654aa4172888435870ac10114756 (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
; 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{
def c(name): 
  if os.name == 'posix':
    return name
  else:
    return "_" + name
}

segment code

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

\c{cpu_dec_locked}: 
; input:  address of arg in r3 
  .LDecLockedLoop:
    lwarx   r10,0,r3
    subi    r10,r10,1
    stwcx.  r10,0,r3
    bne-    .LDecLockedLoop
    cntlzw  r3,r10
    srwi    r3,r3,5
     
\c{cpu_inc_locked}:
  .LIncLockedLoop:
    lwarx   r10,0,r3
    addi    r10,r10,1
    stwcx.  r10,0,r3
    bne-    .LIncLockedLoop