Skip to content

Instantly share code, notes, and snippets.

long syscall0(long n);
long syscall1(long n, long a1);
long syscall2(long n, long a1, long a2);
long syscall3(long n, long a1, long a2, long a3);
long syscall4(long n, long a1, long a2, long a3, long a4);
long syscall5(long n, long a1, long a2, long a3, long a4, long a5);
long syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
__asm__(
".text\n"
@ebb
ebb / stdio.84
Last active November 14, 2018 15:19
printf
{
: printf
: print
: print_line
}
Where
Define (printf s)
Define (push_static stack h i)
package = expr ("Where" binder*)*
expr = NUM ; num
expr = STR ; str
expr = "True" ; true
expr = "False" ; false
expr = IDENT ("." IDENT)* ; var
expr = "'" IDENT ("." expr)? ; variant
expr = OP expr ; prefix_app
expr = "[" expr (OP expr)* "]" ; infix
(main)
Where
Define (main)
(option_monad.flat_map
; (option_sequence.sequence ['some.1 & 'none & 'some.2 & 'nil])
(option_sequence.sequence ['some.1 & 'some.2 & 'nil])
Func numbers
Let {}
@ebb
ebb / parser.y
Last active October 17, 2019 16:06
%{
#include <stdio.h>
#include <stdlib.h>
int yylex(void);
void yyerror(const char *s);
%}
%define api.value.type {int}
@ebb
ebb / slr.84
Last active November 10, 2019 23:29
;;; Grammar:
;;;
;;; expr = "True"
;;; expr = "False"
;;; expr = "(" "And" exprs ")"
;;; expr = "(" "Or" exprs ")"
;;;
;;; exprs =
;;; exprs = exprs expr
;;;
@ebb
ebb / line.c
Created January 30, 2020 23:05
//
// Drawing antialiased lines without using floating point numbers
//
// Compile:
//
// $ clang -std=c11 -o line line.c
//
#include <stdio.h>
#include <stdlib.h>
@ebb
ebb / line.c
Created January 31, 2020 00:32
//
// Drawing antialiased lines without using floating point numbers
//
// Compile:
//
// $ clang -std=c11 -o line line.c
//
#include <stdio.h>
#include <stdlib.h>
@ebb
ebb / binex.84
Created September 14, 2020 00:41
Begin {
When [OS.argc != 2] {
(die "usage: binex n")
}
Begin Match (Z.read (OS.argv 1)) {
| 'nothing
(die "usage: binex n")
| 'just.n
[n -> binex1 -> STDIO.print_line]
[n -> binex2 -> STDIO.print_line]
@ebb
ebb / support2.s
Created September 20, 2020 23:14
extern P
global _start
global memcpy
global memset
global strlen
global syscall0
global syscall1