summary refs log tree commit diff stats
path: root/lib/amd64.asm.in
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andi>2008-06-22 16:14:11 +0200
committerAndreas Rumpf <andreas@andi>2008-06-22 16:14:11 +0200
commit405b86068e6a3d39970b9129ceec0a9108464b28 (patch)
treec0449946f54baae6ea88baf453157ddd7faa8f86 /lib/amd64.asm.in
downloadNim-405b86068e6a3d39970b9129ceec0a9108464b28.tar.gz
Initial import
Diffstat (limited to 'lib/amd64.asm.in')
-rwxr-xr-xlib/amd64.asm.in39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/amd64.asm.in b/lib/amd64.asm.in
new file mode 100755
index 000000000..2c14bf241
--- /dev/null
+++ b/lib/amd64.asm.in
@@ -0,0 +1,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