All Projects → eklitzke → C.sh

eklitzke / C.sh

Inline C/asm in Bash

Programming Languages

c
50402 projects - #5 most used programming language
shell
77523 projects
bash
514 projects

Labels

Projects that are alternatives of or similar to C.sh

Assembly-Lib
A 16-bits x86 DOS Assembly library that provides many useful functions for developing programs. It has both VGA grapics functions as well as general purpose utilities. The main purpose of this library was to be able to implement simple DOS games (in Assembly) using VGA (320x200, 256 colors) display.
Stars: ✭ 36 (-85.06%)
Mutual labels:  asm, x86
Asm Cli
Interactive shell of assembly language(X86/X64) based on unicorn and keystone
Stars: ✭ 211 (-12.45%)
Mutual labels:  x86, asm
Radical-OS
Radical kernel source tree
Stars: ✭ 45 (-81.33%)
Mutual labels:  asm, x86
asmdot
[Unstable] Fast, zero-copy and lightweight (Arm | Mips | x86) assembler in (C | C++ | C# | Go | Haskell | Javascript | Nim | OCaml | Python | Rust).
Stars: ✭ 23 (-90.46%)
Mutual labels:  asm, x86
Asm Space Invaders
A small, bootable game written in x86 Assembly inspired by Space Invaders
Stars: ✭ 202 (-16.18%)
Mutual labels:  x86, asm
creating-controls-in-assembler
Gitbook: https://mrfearless.gitbooks.io/creating-controls-in-assembler
Stars: ✭ 20 (-91.7%)
Mutual labels:  asm, x86
Pillman
Pillman boot sector game, a yellow thing eats pills and is chased by monsters.
Stars: ✭ 298 (+23.65%)
Mutual labels:  x86, asm
FutureDOS
A futuristic DOS
Stars: ✭ 46 (-80.91%)
Mutual labels:  asm, x86
The holy book of x86
A simple guide to x86 architecture, assembly, memory management, paging, segmentation, SMM, BIOS....
Stars: ✭ 577 (+139.42%)
Mutual labels:  x86, asm
Invaders
Invaders game in 512 bytes (boot sector)
Stars: ✭ 461 (+91.29%)
Mutual labels:  x86, asm
CopyToAsm-Plugin-x86
CopyToAsm (x86) - A Plugin For x64dbg
Stars: ✭ 23 (-90.46%)
Mutual labels:  asm, x86
Toledo Atomchess
Toledo Atomchess is the world's smallest chess program in x86 assembly code
Stars: ✭ 69 (-71.37%)
Mutual labels:  x86, asm
dcc
Direct/Interactive C Compiler
Stars: ✭ 18 (-92.53%)
Mutual labels:  asm, x86
LanOS
one mini operating system simplified from linux0.12
Stars: ✭ 61 (-74.69%)
Mutual labels:  asm, x86
APIInfo-Plugin-x86
APIInfo Plugin (x86) - A Plugin For x64dbg
Stars: ✭ 42 (-82.57%)
Mutual labels:  asm, x86
SLAE
Example ASM code following SLAE course and exam assignments.
Stars: ✭ 36 (-85.06%)
Mutual labels:  asm, x86
8086-cheatsheet
8086 Microprocessor Cheat sheet with Programs
Stars: ✭ 81 (-66.39%)
Mutual labels:  asm, x86
kasm
Assembler library for Kotlin
Stars: ✭ 40 (-83.4%)
Mutual labels:  asm, x86
Y86
A Y86 pipeline CPU simulator in JavaScript.
Stars: ✭ 404 (+67.63%)
Mutual labels:  x86, asm
Rappel
A linux-based assembly REPL for x86, amd64, armv7, and armv8
Stars: ✭ 818 (+239.42%)
Mutual labels:  x86, asm

Inline C/Assembler in Bash

Have you ever wanted to combine the speed and safety of Bash with the raw, unbridled power of C? Thanks to @taviso's wonderful ctypes.sh this is possible:

#!/bin/bash

# where ctypes.sh is installed; you will likely have to change this
LD_LIBRARY_PATH=$HOME/local/lib
. ~/code/ctypes.sh/ctypes.sh

# compile stdin to a DSO
function build {
    cfile=$(mktemp /tmp/XXXXXX.c)
    sofile=$(mktemp /tmp/XXXXXX.so)
    while read line; do
        echo $line>>$cfile
    done
    cc -fPIC -shared $cfile -o $sofile
    rm -f $cfile
    echo $sofile
}

# our code
sofile=$(build <<EOF
#include <stdio.h>

void hello_world(void) {
  puts("hello world");
}

int popcnt(int num) {
  int out;
  __asm__("popcnt %1, %0"
          :"=r"(out)
          :"r"(num)
          :"0"
         );
  return out;
}
EOF
)

# clean up when we're done
trap "rm -f $sofile" EXIT

# load the code
dlopen $sofile

# print hello world
dlcall hello_world

# get the popcnt of 5
dlcall -r int -n out popcnt 5
echo $out | egrep -o '[0-9]+'

More details on my blog.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].