Skip to content

Instantly share code, notes, and snippets.

@lydonchandra
lydonchandra / ymm-vectorization2.cpp
Last active January 1, 2016 15:19
ymm vectorization 2
unsigned long long test_multi_load_store(unsigned int * restrict ull_arr1, unsigned int ull_len1) {
unsigned long long sum = 0;
for (unsigned int idx = 0; idx < ull_len1; idx++) {
sum += ull_arr1[idx];
}
return sum;
}
//gcc assembler output
//gcc -mavx2 -ftree-vectorize -march=native -fno-inline -O3 -m64 -S
@lydonchandra
lydonchandra / test_reduce_right.cpp
Created December 29, 2013 06:51
test_reduce_right
unsigned long long test_reduce_right() {
__m128i m128_1, m128_2;
__m256i m256_1, m256_2, m256_3;
unsigned long long total;
__asm {
mov r8, 0x4444333322221111
movq xmm8, r8
mov r9, 0x8888777766665555
movq xmm9, r9
@lydonchandra
lydonchandra / copy_string.cpp
Created January 2, 2014 20:17
copy string to [rdi] from [rsi]
char *string_source = (char*)malloc(256 * sizeof(char));
string_source = "1234567";
char *string_dest = (char*)malloc(256 * sizeof(char));
__asm {
mov rsi, string_source
mov rdi, string_dest
movsq //copy 8 bytes to [rdi] from [rsi]
}
printf("string_source: %s\n, string_dest: %s\n", string_source, string_dest);
@lydonchandra
lydonchandra / focus_on_window.js
Created January 7, 2014 03:01
Move focus from URL bar into window (Chrome and IE) or into the first input[type=text] element (Firefox)
var $inputText1 = $('input[type=text]')[0];
setTimeout( function() {
//chrome and IE
//also move focus away from URL bar into the window so users can zoomin/out in IE
//right away after IntraMaps is loaded
window.focus();
//firefox workaround, window.focus() does not work,
//so use focus() and blur()
$inputText1 && $inputText1.focus();
@lydonchandra
lydonchandra / clipMap.cs
Last active January 2, 2016 19:19
Clip Map based on bounds and layer name, and export into a shapefile
int shapefileType = -1;
//#define SHP_POINT 1
//#define SHP_ARC 3
//#define SHP_POLYGON 5
//#define SHP_MULTIPOINT 8
//#define SHP_POINTZ 11
//#define SHP_ARCZ 13
//#define SHP_POLYGONZ 15
//#define SHP_MULTIPOINTZ 18
@lydonchandra
lydonchandra / arm_neon.cpp
Created January 11, 2014 15:47
arm neon simd, on ios7
//
// Created by Moses DeJong on 7/2/13.
// This software has been placed in the public domain.
// This file implements the following C functions for the ARM platform.
// Both ARM6 and ARM7 devices are supported by this implementation.
// This ARM asm file will generate an error with clang 4 (xcode 4.5 and newer) because
// the integrated assembler does not accept AT&T syntax. This .s target will need to
// have the "-no-integrated-as" command line option passed via
@lydonchandra
lydonchandra / getRawImageBytes.m
Created January 16, 2014 16:43
get raw image bytes from camera output and save it as jpeg file
[stillImageOutput captureStillImageAsynchronouslyFromConnection:stillImageConnection
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (error) {
[self displayErrorOnMainQueue:error withMessage:@"Take picture failed"];
}
else {
//got an image
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(imageDataSampleBuffer);
#!/bin/sh -ex
DEVELOPER=`xcode-select --print-path`
PLATFORM="iPhoneOS"
ARCH="armv7"
IPHONE_SDK="7.0"
IPHONE_MIN_VERSION="5.0"
VERSION="1.3.0"
NASM_VERSION="2.10.09"
@lydonchandra
lydonchandra / arm64-registers.cpp
Created February 2, 2014 21:30
ARM64 Registers
Table 2, General purpose registers and AAPCS64 usage
Register Special Role in the procedure call standard
SP The Stack Pointer.
r30 LR The Link Register.
r29 FP The Frame Pointer
r19...r28 Callee-saved registers
@lydonchandra
lydonchandra / malloc-arm64.s
Last active August 29, 2015 13:56
arm64 basic malloc
//extern uint32_t* test_strb1_x64(uint32_t* wordPtr, uint32_t numWords);
//extern uint32_t* test_malloc3(uint32_t* wordPtr, uint32_t numWords);
//extern void test_malloc4();
//extern uint32_t* test_malloc5(uint32_t intToSet);
.private_extern _test_strb1_x64
.globl _test_strb1_x64
.align 2
_test_strb1_x64: