Skip to content

astyd256/Assembly-Wrappers

Repository files navigation

Assembly Wrappers

Consists of simple functions and simple sorts written in embedded assembly in C++.

Uses MSVC inline assembly (__asm, Intel x86).

Tested in Windows / Visual Studio 2017

Setup

Add both pairs to your project:

  • assembly_inline_functions.h + assembly_inline_functions.cpp
  • assembly_sort_functions.h + assembly_sort_functions.cpp

assembly_inline_functions

Function Returns Instruction(s)
Add(a, b) int add
Sub(a, b) int sub
Mul(a, b) __int64 mul (EDX:EAX)
Div(a, b) int div (64-bit a → EDX:EAX, divide by b)
Equal, Greater, GreaterEqual, Lower, LowerEqual bool cmp + branch
Not, And, Or, Xor bool not / and / or / xor on AL
Index(arr, i) int [ebx + eax*4]
LLShift, RLShift(a, count) int shl, shr
LCShift, RCShift(a, count) int rol, ror

Shift count is __int8 (loaded into CL).

assembly_sort_functions

In-place ascending sort. n = number of int elements.

Function Algorithm
AssemblerBubbleSort(adress, n) bubble
AssemblerSelectionSort(adress, n) selection

Example:

int arr[] = { 5, 2, 8, 1 };
AssemblerBubbleSort(arr, 4);  // arr is modified

The pointer parameter is spelled adress in the headers — keep it when calling.

About

Assembly functions in embedded assembly in C++

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors