Link Search Menu Expand Document

Below is our example assembly file, example.s, from class today. You can use clang example.s to assemble it and ./a.out to then run it.

	.globl	main        
main:                    
	pushq	%rbp
	movq	$0, %rbp
condition:
	cmpq	$42, %rbp
	jg	after
	movq	%rbp, %rsi
	leaq	fmtstring(%rip), %rdi
	callq	printf
	addq	$1, %rbp
	jmp	condition
after:
	xorl	%eax, %eax
	popq	%rbp
	retq
fmtstring:
	.asciz	"i = %ld\n"

Download


Copyright © 2022 John Hott, portions Luther Tychonievich.
Released under the CC-BY-NC-SA 4.0 license.
Creative Commons License