Skip to content

Instantly share code, notes, and snippets.

View nekketsuuu's full-sized avatar
🍑
I like peaches!

Takuma Ishikawa nekketsuuu

🍑
I like peaches!
View GitHub Profile
@qnighy
qnighy / README.md
Last active January 26, 2017 07:25
Algebraic Topology Literature: strip unnecessary spaces
(* Encoding termination of a Turing machine into a GADT *)
type s0 and s1 and s2 and s3 and s4 and fin
type c0 and c1 and c2 and c3 and blank
type left and right
type endt
type ('st_in, 'head_in, 'st_out, 'head_out, 'lr) transition =
| Tr1 : (s0, 'a, s1, 'a, left) transition
@MasWag
MasWag / thesis.tex
Last active December 1, 2016 04:53
IS/CSの卒論修論用LaTeXクラスファイルのuplatex版
\documentclass[senior,final,11pt]{uiscs-thesis}
% 論文の種類とフォントサイズをオプションに
%-------------------
\etitle{Title in English}
\jtitle{邦文標題}
%
\eauthor{Taro Todai}
\jauthor{東大太郎}
\esupervisor{Masami Hagiya}
\jsupervisor{萩谷昌己}

MIPSのABIは変だという話をこないだのシステムプログラミング会でしたら、ややザワッとしたので、なにがおかしいのかというのをちょっとまとめてみました。まとめてみて思いましたが、やっぱりMIPSのELFファイルはちょっと変です。

謎のmixed endianフィールド

これが僕は一番ひどいと思ったものです。

ファイルにマルチバイトの数値を保存するときはエンディアンというものが問題になります。たとえば0xBEEFという2バイトの数を保存するときは、1バイト目にBE、2バイト目にEFを書くか、逆順で書くかは、ただの決まり事でどっちでもいいわけですが、書く側と読む側で認識があっていないと困ります。世の中的にはリトルエンディアン(下位バイトから書く)のが主流ですがビッグエンディアンなシステムもあります。

それがですね、MIPSのELFヘッダのr_infoという64ビットのフィールドはリトルエンディアンでもビッグエンディアンでもない謎なエンコーディングになっています。具体的には下位32ビットが最初にリトルエンディアンで書かれていて、ビッグエンディアンでエンコードされた上位32ビットがそれに続くという構成になっています。つまりリトルエンディアンだとABCD EFGH、ビッグエンディアンだとHGFE DCBAとなるところが、MIPSのmixed endianだとEFGH DCBAというふうにファイルに書かれていることになります。

@pine
pine / IT_Workshop_Community_Advent_Calendar_20161212.md
Last active October 25, 2020 08:48
IT 勉強会の闇と、如何にして闇を払うか
@uhyo
uhyo / count.sh
Last active January 19, 2017 17:16
Sotsuron word counter
#!/bin/bash
CHAP=
ALLFLAG=0
while getopts ac: OPT
do
case $OPT in
a) ALLFLAG=1;;
c) CHAP=$OPTARG;;
@yohhoy
yohhoy / vlafib.c
Last active July 5, 2022 10:27
Fibonacci with VLA on C99
#include <stdio.h>
size_t f(size_t, char [][*]);
size_t f(size_t n, char r[][2 < n ? f(n-2, 0) + f(n-1, 0) : 1])
{
return sizeof(*r);
}
int main()
@beesandbombs
beesandbombs / bloom.pde
Created May 24, 2017 23:33
blooming dodecahedron
// by david whyte :)
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
// gif by dave aka @beesandbombs :)
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
OpenSimplexNoise noise;
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {