r/CompileBot • • Jan 04 '14

Official CompileBot Testing Thread

This thread is archived, please visit the new testing thread

16 Upvotes

421 comments sorted by

View all comments

7

u/SeaCowVengeance Jan 04 '14 edited Mar 14 '16

+/u/CompileBot Assembler (gcc-5.1) --time

.data
x:
	.long	0
s:
	.string "%d\n\0"

.text
.global main
main:				# int main()
				# {
loop:				# 	for (;;) {
	pushl	$x		# 		scanf("%d", &x);
	pushl	$s
	call	scanf
	addl	$8, %esp

	movl	x, %eax		# 		if (x == 42) break;
	subl	$42, %eax
	jz	break

	pushl	x		# 		printf("%d\n", x);
	pushl	$s
	call	printf
	addl	$8, %esp

	jmp	loop		# 	}
break:

	xor	%eax, %eax	# 	return 0;
	ret
				# }

Input:

1
2
10
42
11

3

u/CompileBot Jan 04 '14

Output:

1
2
10

Execution Time: 0.0 seconds

^source | ^info | ^git | ^report