Skip to content

Instantly share code, notes, and snippets.

View giuscri's full-sized avatar

Giuseppe Crinò giuscri

View GitHub Profile
@giuscri
giuscri / ada.asm
Last active August 29, 2015 14:17
;; ada.asm
segment .data
format db "%d + %d = %d", 10, 0
segment .text
global main
extern printf
main:
;; lovelace.asm
segment .data
prompt db "Type in your name: ", 0
buffer times 42 dd 0
printerformat db "Hello %s", 10, 0
scannerformat db "%s", 0
segment .text
global main
@giuscri
giuscri / main.asm
Created March 17, 2015 14:03
Nicy stuff ... :)
;; main.asm
segment .data
promptfirstnumber db "Enter the first number: ", 0
promptsecondnumber db "Enter the second number: ", 0
scanfnumber db "%d", 0
printsum db "%d + %d = %d", 10, 0
a dd 0
b dd 0
;; fact.asm
segment .text
global fact
fact:
;; Reserve no room for the locals ...
enter 0, 0
Delivered-To: [email protected]
Received: by 10.140.106.102 with SMTP id d93csp2368187qgf;
Tue, 24 Mar 2015 12:19:21 -0700 (PDT)
X-Received: by 10.180.106.68 with SMTP id gs4mr31417050wib.39.1427224760288;
Tue, 24 Mar 2015 12:19:20 -0700 (PDT)
Return-Path: <[email protected]>
Received: from DUB004-OMC3S26.hotmail.com (dub004-omc3s26.hotmail.com. [157.55.2.35])
by mx.google.com with ESMTPS id lg5si248270wjb.181.2015.03.24.12.19.19
for <[email protected]>
@giuscri
giuscri / http.js
Last active August 29, 2015 14:22
Homemade http wrapper.
(function () {
"use strict";
/**
* Use case example:
* http.get("/", {foo: "bar", background: "red"})
* .then(function (res) {
* return console.log(res);
* }, function (err) {
* return console.error(err);
* });
#!/usr/bin/sh
BATTERYLEVEL=$(acpi -b|sed -r "s/^.* ([0-9]{1,3})%, .*$/\1/g");
DISCHARGING=$(acpi -b|egrep 'Discharging');
if [[ $BATTERYLEVEL -lt 100 && $DISCHARGING ]]; then
notify-send --urgency=critical --expire-time=5000 "!, close to fucked up baby. $BATTERYLEVEL%." \
"You've a bunch of minutes left to commit everything and put your <b>wonderful</b> laptop @ zzz."
fi;
.text
.global _start
_start:
xorl %ebx, %ebx
movl $buf, %ecx
movl %ebx, (%ecx)
movl $buf_length, %edx
movl $buf, %ecx
movl $0, %ebx
movl $3, %eax
@giuscri
giuscri / main.s
Last active October 1, 2015 16:24
## main.s
## !, assemble and link it (on x86_64) via
## $ as --32 --gstabs main.s -o main.o
## $ ld -m elf_i386 main.o -o main
.section .text
.global _start
__atoi:
### int __atoi (const char * buf, size_t buf_length)
### Convert a string to an integer.
## $ cc -ggdb3 -m32 -Og reverse.cool.s -o reverse.cool
.section .text
.type main, @function
.globl main
main:
pushl %ebp
movl %esp,%ebp
subl $0x10,%esp
movl %esp,-0x10(%ebp)
movl $message,%esi