Skip to content

Instantly share code, notes, and snippets.

View AdrianV's full-sized avatar

Adrian Veith AdrianV

  • Veith System GmbH
  • Frasdorf, Germany
View GitHub Profile
@AdrianV
AdrianV / ranges.nim
Created April 16, 2013 16:39
ranges.nim is a proof of concept how to implement abstract ranges in Nimrod
# ranges.nim
type
TDownSlice* {.final, pure.}[T] = object
a*, b*: T
TCountUpRange* [T] = ref RCountUpRange[T]
RCountUpRange [T] = object
cur: T
a: T
last: T
TCountDownRange* [T] = ref RCountDownRange[T]
@AdrianV
AdrianV / raytracer.nim
Created June 13, 2013 14:31
a simple raytracer converted from D code from this https://dl.dropboxusercontent.com/u/974356/raytracer.d source
import math
import sequtils
import sdl
const
width = 1280
height = 720
fov = 45.0
max_depth = 6
@AdrianV
AdrianV / benchOOP1.nim
Created June 6, 2014 13:36
OOP in nimrod via case statement
import benchmark
type
ClassID = enum CBase, CSecond, CThird
TBase = ref object {.inheritable.}
class: ClassID
data: int
TSecond = ref object of TBase
d2: int
TThird = ref object of TSecond
@AdrianV
AdrianV / benchOOP2.nim
Created June 6, 2014 13:39
OOP via VTables
import oopHelper, benchmark
declClass TBase:
var
data: int
proc create(data: int) {.constructor.} =
self.data = data
method Foo(): int = return self.data
method Multi(a, b, c: int): int = 0
proc initialize() {.inline.} =
@AdrianV
AdrianV / benchOOP3.nim
Created June 6, 2014 13:41
OOP nimrod style
import benchmark
type
TBase = ref object {.inheritable.}
data: int
TSecond = ref object of TBase
d2: int
TThird = ref object of TSecond
d3: int
@AdrianV
AdrianV / Main.hx
Created May 20, 2020 10:47
fast expression evaluation
import VExpr;
import VExpr.C.*;
@:access(VExpr)
class Main {
macro static public function benchmark(test, start, done) {
return macro {
trace($start);
var dt = haxe.Timer.stamp();

Adrian Veith

and how do I code InterlockedExchangeAdd64 in In 32-bit x86 assembly ?

gpt4

InterlockedExchangeAdd64 is a function that atomically adds a 64-bit integer to a target variable and returns the original value of the target variable. In 32-bit x86 assembly, you can implement this using a combination of the LOCK prefix, CMPXCHG8B instruction, and ADD instruction. Here's an example implementation in x86 assembly:

assembly