Replaced inline ASM with C++ method