talks

git clone git://code.dwrz.net/talks
Log | Files | Refs

control-flow.s (455B)


      1 .data
      2 stop:
      3 	.int 3
      4 
      5 .text
      6 	.global _start
      7 
      8 _start:
      9 	mov $0, %rcx
     10 loop:
     11 	cmp stop, %rcx
     12 	# If equal, change RIP to exit.
     13 	je exit
     14 	inc %rcx
     15 	# Unconditionnaly change RIP to loop.
     16 	jmp loop
     17 exit:
     18 	# Try this: comment out the following three instructions.
     19 	# What happens if you assemble and link? Why?
     20 	# Think about RIP and the Fetch-Decode-Execute cycle.
     21 	mov $231, %rax
     22         mov %rcx, %rdi # Exit code -- let's see the value of %rcx.
     23         syscall