Skip to content

Instantly share code, notes, and snippets.

View sebbekarlsson's full-sized avatar
🐧
Programming

Sebastian Karlsson (ianertson) sebbekarlsson

🐧
Programming
View GitHub Profile
1446
1893
1827
1565
1728
497
1406
1960
1986
1945
.type itos, @function
itos:
pushl %ebp
movl %esp, %ebp
movl 8(%esp), %eax # number
movl $12, %edi
leal (%esp, %edi, 1), %ebx # buffer
movl $0, %edi # counter
movl $0, %esi
# Convert number to string
# (number, buffer) => buffer
.type itoa, @function
itoa:
pushl %ebp
movl %esp, %ebp
movl $12, %edi
leal (%esp, %edi, 1), %ebx # buffer
movl 8(%esp), %eax # number
.type to_str, @function
to_str:
pushl %ebp
movl %esp, %ebp
movl 8(%esp), %eax
jmp to_str_loop
to_str_loop:
.section .data
divtable:
.long 100, 10, 1, 0
.section .bss
.lcomm buffer, 16
.section .text
hello = (x: string, y:string, z:string) => {
print(x);
print(y);
print(z);
return 0;
};
main = (argc: int, argv: Array<string>):int => {
foo:string = "the first string\n";
@sebbekarlsson
sebbekarlsson / c_vs_cpp.md
Created August 1, 2019 20:20
C vs CPP, binary size

hello_cpp_cout:

#include <iostream>
int main()
{
    std::cout << "Hello world" << std::endl;
    return 0;
}

Size: 14,924 bytes

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct FRUIT_STRUCT
{
char* name;
} fruit_T;
'''
Simple example on how to manually convert hex to decimal without using
'int()' method.
'''
from functools import reduce
def to_decimal(hexnr):
assert hexnr.startswith('0x')
@sebbekarlsson
sebbekarlsson / questions.sh
Created October 11, 2018 06:34
Asking questions in bash
question_state=0
function ask() {
read -p "$1" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
question_state=1
fi
}