Skip to content

Latest commit

 

History

History
37 lines (32 loc) · 598 Bytes

README.md

File metadata and controls

37 lines (32 loc) · 598 Bytes

compiler-book-rs

『低レイヤを知りたい人のためのCコンパイラ作成入門』 をM1 Mac上でRustで追ってみる

Sample

int a;
int *b;
int c[10][10];

int main()
{
	int d;
	a = 10;
	b = &d;
	*b = 10;
	int e[2][3];
	e[1][2] = 2;
	c[9][9] = 10;
	// Line comment
	/*
	 * Block comment
	 */
	/* Inline block comment */printf("hello, world\n");//Inline line comment
	return a + *b + c[9][9] + d + e[1][2];
}
$ cargo run -- sample.c > sample.s
$ cc -o sample sample.s
$ ./sample
hello, world
$ echo $?
42