This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Credits: https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html | |
; Compile: nasm -f bin -o hello hello.asm | |
BITS 32 | |
org 0x08048000 | |
ehdr: ; Elf32_Ehdr | |
db 0x7F, "ELF", 1, 1, 1, 0 ; e_ident | |
times 8 db 0 | |
dw 2 ; e_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code installs a custom signal handler for the SIGSEGV signal | |
// (segmentation fault) and then purposefully creates a segmentation | |
// fault. The custom handler `handler` is then entered, which now | |
// increases the instruction pointer by 1, skipping the current byte | |
// of the faulty instruction. This is done for as long as the faulty | |
// instruction is still active; in the below case, that's 2 bytes. | |
// Note: This is for 64 bit systems. If you prefer 32 bit, change | |
// `REG_RIP` to `REG_EIP`. I didn't bother putting an appropriate | |
// `#ifdef` here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is my short-ish tutorial on how to implement closures in | |
a simple functional language: Foo. | |
First, some boilerplate. | |
> {-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
> import Control.Applicative | |
> import Control.Monad.Gen | |
> import Control.Monad.Writer | |
> import Data.Functor.Foldable |